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
737 '(article-decode-group-name article-decode-idna-rhs)
738 "*Hook run to decode charsets in articles."
739 :group 'gnus-article-headers
742 (defcustom gnus-display-mime-function 'gnus-display-mime
743 "Function to display MIME articles."
744 :group 'gnus-article-mime
747 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
748 "Function used to decode headers.")
750 (defvar gnus-article-dumbquotes-map
770 "Table for MS-to-Latin1 translation.")
772 (defcustom gnus-ignored-mime-types nil
773 "List of MIME types that should be ignored by Gnus."
775 :group 'gnus-article-mime
776 :type '(repeat regexp))
778 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
779 "List of MIME types that should not be given buttons when rendered inline.
780 See also `gnus-buttonized-mime-types' which may override this variable.
781 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
783 :group 'gnus-article-mime
784 :type '(repeat regexp))
786 (defcustom gnus-buttonized-mime-types nil
787 "List of MIME types that should be given buttons when rendered inline.
788 If set, this variable overrides `gnus-unbuttonized-mime-types'.
789 To see e.g. security buttons you could set this to
790 `(\"multipart/signed\")'.
791 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
793 :group 'gnus-article-mime
794 :type '(repeat regexp))
796 (defcustom gnus-inhibit-mime-unbuttonizing nil
797 "If non-nil, all MIME parts get buttons.
798 When nil (the default value), then some MIME parts do not get buttons,
799 as described by the variables `gnus-buttonized-mime-types' and
800 `gnus-unbuttonized-mime-types'."
804 (defcustom gnus-body-boundary-delimiter "_"
805 "String used to delimit header and body.
806 This variable is used by `gnus-article-treat-body-boundary' which can
807 be controlled by `gnus-treat-body-boundary'."
808 :group 'gnus-article-various
809 :type '(choice (item :tag "None" :value nil)
812 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
813 "Defines the location of the faces database.
814 For information on obtaining this database of pretty pictures, please
815 see http://www.cs.indiana.edu/picons/ftp/index.html"
816 :type '(repeat directory)
817 :link '(url-link :tag "download"
818 "http://www.cs.indiana.edu/picons/ftp/index.html")
819 :link '(custom-manual "(gnus)Picons")
822 (defun gnus-picons-installed-p ()
823 "Say whether picons are installed on your machine."
824 (let ((installed nil))
825 (dolist (database gnus-picon-databases)
826 (when (file-exists-p database)
830 (defcustom gnus-article-mime-part-function nil
831 "Function called with a MIME handle as the argument.
832 This is meant for people who want to do something automatic based
833 on parts -- for instance, adding Vcard info to a database."
834 :group 'gnus-article-mime
837 (defcustom gnus-mime-multipart-functions nil
838 "An alist of MIME types to functions to display them."
840 :group 'gnus-article-mime
843 (defcustom gnus-article-date-lapsed-new-header nil
844 "Whether the X-Sent and Date headers can coexist.
845 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
846 either replace the old \"Date:\" header (if this variable is nil), or
847 be added below it (otherwise)."
849 :group 'gnus-article-headers
852 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
853 "Function called with a MIME handle as the argument.
854 This is meant for people who want to view first matched part.
855 For `undisplayed-alternative' (default), the first undisplayed
856 part or alternative part is used. For `undisplayed', the first
857 undisplayed part is used. For a function, the first part which
858 the function return t is used. For nil, the first part is
861 :group 'gnus-article-mime
863 (item :tag "first" :value nil)
864 (item :tag "undisplayed" :value undisplayed)
865 (item :tag "undisplayed or alternative"
866 :value undisplayed-alternative)
869 (defcustom gnus-mime-action-alist
870 '(("save to file" . gnus-mime-save-part)
871 ("save and strip" . gnus-mime-save-part-and-strip)
872 ("delete part" . gnus-mime-delete-part)
873 ("display as text" . gnus-mime-inline-part)
874 ("view the part" . gnus-mime-view-part)
875 ("pipe to command" . gnus-mime-pipe-part)
876 ("toggle display" . gnus-article-press-button)
877 ("toggle display" . gnus-article-view-part-as-charset)
878 ("view as type" . gnus-mime-view-part-as-type)
879 ("view internally" . gnus-mime-view-part-internally)
880 ("view externally" . gnus-mime-view-part-externally))
881 "An alist of actions that run on the MIME attachment."
882 :group 'gnus-article-mime
883 :type '(repeat (cons (string :tag "name")
887 ;;; The treatment variables
890 (defvar gnus-part-display-hook nil
891 "Hook called on parts that are to receive treatment.")
893 (defvar gnus-article-treat-custom
894 '(choice (const :tag "Off" nil)
896 (const :tag "Header" head)
897 (const :tag "Last" last)
898 (const :tag "Mime" mime)
899 (integer :tag "Less")
900 (repeat :tag "Groups" regexp)
901 (sexp :tag "Predicate")))
903 (defvar gnus-article-treat-head-custom
904 '(choice (const :tag "Off" nil)
905 (const :tag "Header" head)))
907 (defvar gnus-article-treat-types '("text/plain")
910 (defvar gnus-inhibit-treatment nil
911 "Whether to inhibit treatment.")
913 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
914 "Highlight the signature.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See Info node `(gnus)Customizing Articles'."
917 :group 'gnus-article-treat
918 :link '(custom-manual "(gnus)Customizing Articles")
919 :type gnus-article-treat-custom)
920 (put 'gnus-treat-highlight-signature 'highlight t)
922 (defcustom gnus-treat-buttonize 100000
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See Info node `(gnus)Customizing Articles'."
926 :group 'gnus-article-treat
927 :link '(custom-manual "(gnus)Customizing Articles")
928 :type gnus-article-treat-custom)
929 (put 'gnus-treat-buttonize 'highlight t)
931 (defcustom gnus-treat-buttonize-head 'head
932 "Add buttons to the head.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
938 (put 'gnus-treat-buttonize-head 'highlight t)
940 (defcustom gnus-treat-emphasize
941 (and (or window-system
943 (>= (string-to-number emacs-version) 21))
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles' for details."
948 :group 'gnus-article-treat
949 :link '(custom-manual "(gnus)Customizing Articles")
950 :type gnus-article-treat-custom)
951 (put 'gnus-treat-emphasize 'highlight t)
953 (defcustom gnus-treat-strip-cr nil
954 "Remove carriage returns.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-unsplit-urls nil
962 "Remove newlines from within URLs.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-leading-whitespace nil
970 "Remove leading whitespace in headers.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-hide-headers 'head
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-head-custom)
985 (defcustom gnus-treat-hide-boring-headers nil
986 "Hide boring headers.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-head-custom)
993 (defcustom gnus-treat-hide-signature nil
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-fill-article nil
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-hide-citation nil
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-custom)
1017 (defcustom gnus-treat-hide-citation-maybe nil
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1025 (defcustom gnus-treat-strip-list-identifiers 'head
1026 "Strip list identifiers from `gnus-list-identifiers`.
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-custom)
1034 (make-obsolete-variable 'gnus-treat-strip-pgp
1035 "This option is obsolete in Gnus 5.10.")
1037 (defcustom gnus-treat-strip-pem nil
1038 "Strip PEM signatures.
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-strip-banner t
1046 "Strip banners from articles.
1047 The banner to be stripped is specified in the `banner' group parameter.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-custom)
1054 (defcustom gnus-treat-highlight-headers 'head
1055 "Highlight the headers.
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See Info node `(gnus)Customizing Articles' for details."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-head-custom)
1061 (put 'gnus-treat-highlight-headers 'highlight t)
1063 (defcustom gnus-treat-highlight-citation t
1064 "Highlight cited text.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-custom)
1070 (put 'gnus-treat-highlight-citation 'highlight t)
1072 (defcustom gnus-treat-date-ut nil
1073 "Display the Date in UT (GMT).
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :link '(custom-manual "(gnus)Customizing Articles")
1078 :type gnus-article-treat-head-custom)
1080 (defcustom gnus-treat-date-local nil
1081 "Display the Date in the local timezone.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :link '(custom-manual "(gnus)Customizing Articles")
1086 :type gnus-article-treat-head-custom)
1088 (defcustom gnus-treat-date-english nil
1089 "Display the Date in a format that can be read aloud in English.
1090 Valid values are nil, t, `head', `last', an integer or a predicate.
1091 See Info node `(gnus)Customizing Articles' for details."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-head-custom)
1096 (defcustom gnus-treat-date-lapsed nil
1097 "Display the Date header in a way that says how much time has elapsed.
1098 Valid values are nil, t, `head', `last', an integer or a predicate.
1099 See Info node `(gnus)Customizing Articles' for details."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-head-custom)
1104 (defcustom gnus-treat-date-original nil
1105 "Display the date in the original timezone.
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See Info node `(gnus)Customizing Articles' for details."
1108 :group 'gnus-article-treat
1109 :link '(custom-manual "(gnus)Customizing Articles")
1110 :type gnus-article-treat-head-custom)
1112 (defcustom gnus-treat-date-iso8601 nil
1113 "Display the date in the ISO8601 format.
1114 Valid values are nil, t, `head', `last', an integer or a predicate.
1115 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-head-custom)
1121 (defcustom gnus-treat-date-user-defined nil
1122 "Display the date in a user-defined format.
1123 The format is defined by the `gnus-article-time-format' variable.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-head-custom)
1130 (defcustom gnus-treat-strip-headers-in-body t
1131 "Strip the X-No-Archive header line from the beginning of the body.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1139 (defcustom gnus-treat-strip-trailing-blank-lines nil
1140 "Strip trailing blank lines.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 See Info node `(gnus)Customizing Articles' for details."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1147 (defcustom gnus-treat-strip-leading-blank-lines nil
1148 "Strip leading blank lines.
1149 Valid values are nil, t, `head', `last', an integer or a predicate.
1150 See Info node `(gnus)Customizing Articles' for details."
1151 :group 'gnus-article-treat
1152 :link '(custom-manual "(gnus)Customizing Articles")
1153 :type gnus-article-treat-custom)
1155 (defcustom gnus-treat-strip-multiple-blank-lines nil
1156 "Strip multiple blank lines.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' for details."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-custom)
1163 (defcustom gnus-treat-unfold-headers 'head
1164 "Unfold folded header lines.
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1167 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-custom)
1171 (defcustom gnus-treat-fold-headers nil
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-custom)
1179 (defcustom gnus-treat-fold-newsgroups 'head
1180 "Fold the Newsgroups and Followup-To headers.
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom)
1187 (defcustom gnus-treat-overstrike t
1188 "Treat overstrike highlighting.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' for details."
1191 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-custom)
1194 (put 'gnus-treat-overstrike 'highlight t)
1196 (defcustom gnus-treat-display-xface
1197 (and (not noninteractive)
1198 (or (memq gnus-article-x-face-command
1199 '(x-face-decode-message-header
1200 x-face-mule-gnus-article-display-x-face))
1201 (and (fboundp 'image-type-available-p)
1202 (image-type-available-p 'xbm)
1203 (string-match "^0x" (shell-command-to-string "uncompface"))
1204 (executable-find "icontopbm"))
1205 (and (featurep 'xemacs)
1208 "Display X-Face headers.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' and Info node
1211 `(gnus)X-Face' for details."
1212 :group 'gnus-article-treat
1214 :link '(custom-manual "(gnus)Customizing Articles")
1215 :link '(custom-manual "(gnus)X-Face")
1216 :type gnus-article-treat-head-custom)
1217 (put 'gnus-treat-display-xface 'highlight t)
1219 (defcustom gnus-article-should-use-smiley-mule
1220 (not (or (featurep 'xemacs)
1221 (gnus-image-type-available-p 'xpm)
1222 (gnus-image-type-available-p 'pbm)))
1223 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1224 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1225 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1226 even if you are using Emacs 21+. It has no effect on XEmacs."
1227 :group 'gnus-article-various
1229 :get (lambda (symbol)
1230 (and (not noninteractive)
1231 (default-value symbol)
1232 (not (featurep 'xemacs))
1233 (module-installed-p 'smiley-mule)
1235 :set (lambda (symbol value)
1236 (set-default symbol (and (not noninteractive)
1238 (not (featurep 'xemacs))
1239 (module-installed-p 'smiley-mule)
1242 (defvar gnus-article-smiley-mule-loaded-p nil
1243 "Internal variable used to say whether `smiley-mule' is loaded (whether
1244 smiley functions are not overridden by `smiley').")
1246 (defcustom gnus-treat-display-face
1247 (and (not noninteractive)
1248 ;; x-face-e21 handles both X-Face and Face headers.
1249 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1250 (module-installed-p 'x-face-e21)))
1251 (or (and (fboundp 'image-type-available-p)
1252 (image-type-available-p 'png))
1253 (and (featurep 'xemacs)
1256 "Display Face headers.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' and Info node
1259 `(gnus)X-Face' for details."
1260 :group 'gnus-article-treat
1262 :link '(custom-manual "(gnus)Customizing Articles")
1263 :link '(custom-manual "(gnus)X-Face")
1264 :type gnus-article-treat-head-custom)
1265 (put 'gnus-treat-display-face 'highlight t)
1267 (defcustom gnus-treat-display-smileys
1268 (if (and (not noninteractive)
1269 (or (and (featurep 'xemacs)
1271 (gnus-image-type-available-p 'xpm)
1272 (gnus-image-type-available-p 'pbm)
1273 (and (not (featurep 'xemacs))
1275 (module-installed-p 'smiley-mule))))
1279 Valid values are nil, t, `head', `last', an integer or a predicate.
1280 See Info node `(gnus)Customizing Articles' and Info node
1281 `(gnus)Smileys' for details."
1282 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles")
1285 :link '(custom-manual "(gnus)Smileys")
1286 :type gnus-article-treat-custom)
1287 (put 'gnus-treat-display-smileys 'highlight t)
1289 (defcustom gnus-treat-from-picon
1290 (if (and (gnus-image-type-available-p 'xpm)
1291 (gnus-picons-installed-p))
1293 "Display picons in the From header.
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' and Info node
1296 `(gnus)Picons' for details."
1297 :group 'gnus-article-treat
1299 :link '(custom-manual "(gnus)Customizing Articles")
1300 :link '(custom-manual "(gnus)Picons")
1301 :type gnus-article-treat-head-custom)
1302 (put 'gnus-treat-from-picon 'highlight t)
1304 (defcustom gnus-treat-mail-picon
1305 (if (and (gnus-image-type-available-p 'xpm)
1306 (gnus-picons-installed-p))
1308 "Display picons in To and Cc headers.
1309 Valid values are nil, t, `head', `last', an integer or a predicate.
1310 See Info node `(gnus)Customizing Articles' and Info node
1311 `(gnus)Picons' for details."
1312 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :link '(custom-manual "(gnus)Picons")
1316 :type gnus-article-treat-head-custom)
1317 (put 'gnus-treat-mail-picon 'highlight t)
1319 (defcustom gnus-treat-newsgroups-picon
1320 (if (and (gnus-image-type-available-p 'xpm)
1321 (gnus-picons-installed-p))
1323 "Display picons in the Newsgroups and Followup-To headers.
1324 Valid values are nil, t, `head', `last', an integer or a predicate.
1325 See Info node `(gnus)Customizing Articles' and Info node
1326 `(gnus)Picons' for details."
1327 :group 'gnus-article-treat
1329 :link '(custom-manual "(gnus)Customizing Articles")
1330 :link '(custom-manual "(gnus)Picons")
1331 :type gnus-article-treat-head-custom)
1332 (put 'gnus-treat-newsgroups-picon 'highlight t)
1334 (defcustom gnus-treat-body-boundary
1335 (if (or gnus-treat-newsgroups-picon
1336 gnus-treat-mail-picon
1337 gnus-treat-from-picon)
1339 "Draw a boundary at the end of the headers.
1340 Valid values are nil, t, `head', `last', an integer or a predicate.
1341 See Info node `(gnus)Customizing Articles' for details."
1343 :group 'gnus-article-treat
1344 :link '(custom-manual "(gnus)Customizing Articles")
1345 :type gnus-article-treat-custom)
1347 (defcustom gnus-treat-capitalize-sentences nil
1348 "Capitalize sentence-starting words.
1349 Valid values are nil, t, `head', `last', an integer or a predicate.
1350 See Info node `(gnus)Customizing Articles' for details."
1352 :group 'gnus-article-treat
1353 :link '(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-custom)
1356 (defcustom gnus-treat-wash-html nil
1358 Valid values are nil, t, `head', `last', an integer or a predicate.
1359 See Info node `(gnus)Customizing Articles' for details."
1360 :group 'gnus-article-treat
1361 :link '(custom-manual "(gnus)Customizing Articles")
1362 :type gnus-article-treat-custom)
1364 (defcustom gnus-treat-fill-long-lines nil
1366 Valid values are nil, t, `head', `last', an integer or a predicate.
1367 See Info node `(gnus)Customizing Articles' for details."
1368 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :type gnus-article-treat-custom)
1372 (defcustom gnus-treat-play-sounds nil
1374 Valid values are nil, t, `head', `last', an integer or a predicate.
1375 See Info node `(gnus)Customizing Articles' for details."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom)
1381 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1382 "Decode an article as `default-mime-charset'. For instance, if you want to
1383 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1384 you could set this variable to something like: nil for don't decode, t for
1385 decode the body, '(or header t) for the whole article, etc."
1386 :group 'gnus-article-treat
1387 :type '(radio (const :tag "Off" nil)
1388 (const :tag "Decode body" t)
1389 (const :tag "Decode all" (or head t))))
1391 (defcustom gnus-treat-translate nil
1392 "Translate articles from one language to another.
1393 Valid values are nil, t, `head', `last', an integer or a predicate.
1394 See Info node `(gnus)Customizing Articles' for details."
1396 :group 'gnus-article-treat
1397 :link '(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom)
1400 (defcustom gnus-treat-x-pgp-sig nil
1402 To automatically treat X-PGP-Sig, set it to head.
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' for details."
1405 :group 'gnus-article-treat
1406 :group 'mime-security
1407 :type gnus-article-treat-custom)
1409 (defcustom gnus-treat-monafy nil
1410 "Display body part with mona font.
1411 Valid values are nil, t, `head', `last', an integer or a predicate.
1412 See Info node `(gnus)Customizing Articles' for details."
1413 :group 'gnus-article-treat
1414 :group 'mime-security
1415 :link '(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom)
1418 (defvar gnus-article-encrypt-protocol-alist
1419 '(("PGP" . mml2015-self-encrypt)))
1421 ;; Set to nil if more than one protocol added to
1422 ;; gnus-article-encrypt-protocol-alist.
1423 (defcustom gnus-article-encrypt-protocol "PGP"
1424 "The protocol used for encrypt articles.
1425 It is a string, such as \"PGP\". If nil, ask user."
1427 :group 'mime-security)
1429 (defvar gnus-article-wash-function nil
1430 "Function used for converting HTML into text.")
1432 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1433 (fboundp 'coding-system-p)
1434 (coding-system-p 'utf-8))
1435 "Whether IDNA decoding of headers is used when viewing messages.
1436 This requires GNU Libidn, and by default only enabled if it is found."
1437 :group 'gnus-article-headers
1440 ;;; Internal variables
1442 (defvar gnus-english-month-names
1443 '("January" "February" "March" "April" "May" "June" "July" "August"
1444 "September" "October" "November" "December"))
1446 (defvar article-goto-body-goes-to-point-min-p nil)
1447 (defvar gnus-article-wash-types nil)
1448 (defvar gnus-article-emphasis-alist nil)
1449 (defvar gnus-article-image-alist nil)
1451 (defvar gnus-article-mime-handle-alist-1 nil)
1452 (defvar gnus-treatment-function-alist
1453 '((gnus-treat-decode-article-as-default-mime-charset
1454 gnus-article-decode-article-as-default-mime-charset)
1455 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1456 (gnus-treat-monafy gnus-article-monafy)
1457 (gnus-treat-strip-banner gnus-article-strip-banner)
1458 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1459 (gnus-treat-buttonize gnus-article-add-buttons)
1460 (gnus-treat-fill-article gnus-article-fill-cited-article)
1461 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1462 (gnus-treat-strip-cr gnus-article-remove-cr)
1463 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1464 (gnus-treat-date-ut gnus-article-date-ut)
1465 (gnus-treat-date-local gnus-article-date-local)
1466 (gnus-treat-date-english gnus-article-date-english)
1467 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1468 (gnus-treat-date-original gnus-article-date-original)
1469 (gnus-treat-date-user-defined gnus-article-date-user)
1470 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1471 (gnus-treat-display-face gnus-article-display-face)
1472 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1473 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1474 (gnus-treat-hide-signature gnus-article-hide-signature)
1475 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1476 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1477 (gnus-treat-strip-pem gnus-article-hide-pem)
1478 (gnus-treat-from-picon gnus-treat-from-picon)
1479 (gnus-treat-mail-picon gnus-treat-mail-picon)
1480 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1481 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1482 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1483 (gnus-treat-strip-trailing-blank-lines
1484 gnus-article-remove-trailing-blank-lines)
1485 (gnus-treat-strip-leading-blank-lines
1486 gnus-article-strip-leading-blank-lines)
1487 (gnus-treat-strip-multiple-blank-lines
1488 gnus-article-strip-multiple-blank-lines)
1489 (gnus-treat-overstrike gnus-article-treat-overstrike)
1490 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1491 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1492 ;; Displaying X-Face should be done after unfolding headers
1493 ;; to protect bitmap lines.
1494 (gnus-treat-display-xface gnus-article-display-x-face)
1495 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1496 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1497 (gnus-treat-display-smileys gnus-treat-smiley)
1498 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1499 (gnus-treat-wash-html gnus-article-wash-html)
1500 (gnus-treat-emphasize gnus-article-emphasize)
1501 (gnus-treat-hide-citation gnus-article-hide-citation)
1502 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1503 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1504 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1505 (gnus-treat-play-sounds gnus-earcon-display)))
1507 (defvar gnus-article-mime-handle-alist nil)
1508 (defvar article-lapsed-timer nil)
1509 (defvar gnus-article-current-summary nil)
1511 (defvar gnus-article-mode-syntax-table
1512 (let ((table (copy-syntax-table text-mode-syntax-table)))
1513 ;; This causes the citation match run O(2^n).
1514 ;; (modify-syntax-entry ?- "w" table)
1515 (modify-syntax-entry ?> ")<" table)
1516 (modify-syntax-entry ?< "(>" table)
1517 ;; make M-. in article buffers work for `foo' strings
1518 (modify-syntax-entry ?' " " table)
1519 (modify-syntax-entry ?` " " table)
1521 "Syntax table used in article mode buffers.
1522 Initialized from `text-mode-syntax-table.")
1524 (defvar gnus-save-article-buffer nil)
1526 (defvar gnus-article-mode-line-format-alist
1527 (nconc '((?w (gnus-article-wash-status) ?s)
1528 (?m (gnus-article-mime-part-status) ?s))
1529 gnus-summary-mode-line-format-alist))
1531 (defvar gnus-number-of-articles-to-be-saved nil)
1533 (defvar gnus-inhibit-hiding nil)
1535 ;;; Macros for dealing with the article buffer.
1537 (defmacro gnus-with-article-headers (&rest forms)
1539 (set-buffer gnus-article-buffer)
1541 (let ((buffer-read-only nil)
1542 (inhibit-point-motion-hooks t)
1543 (case-fold-search t))
1544 (article-narrow-to-head)
1547 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1548 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1550 (defmacro gnus-with-article-buffer (&rest forms)
1552 (set-buffer gnus-article-buffer)
1553 (let ((buffer-read-only nil))
1556 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1557 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1559 (defun gnus-article-goto-header (header)
1560 "Go to HEADER, which is a regular expression."
1561 (re-search-forward (concat "^\\(" header "\\):") nil t))
1563 (defsubst gnus-article-hide-text (b e props)
1564 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1565 (gnus-add-text-properties-when 'article-type nil b e props)
1566 (when (memq 'intangible props)
1568 (max (1- b) (point-min))
1569 b 'intangible (cddr (memq 'intangible props)))))
1571 (defsubst gnus-article-unhide-text (b e)
1572 "Remove hidden text properties from region between B and E."
1573 (remove-text-properties b e gnus-hidden-properties)
1574 (when (memq 'intangible gnus-hidden-properties)
1575 (put-text-property (max (1- b) (point-min))
1576 b 'intangible nil)))
1578 (defun gnus-article-hide-text-type (b e type)
1579 "Hide text of TYPE between B and E."
1580 (gnus-add-wash-type type)
1581 (gnus-article-hide-text
1582 b e (cons 'article-type (cons type gnus-hidden-properties))))
1584 (defun gnus-article-unhide-text-type (b e type)
1585 "Unhide text of TYPE between B and E."
1586 (gnus-delete-wash-type type)
1587 (remove-text-properties
1588 b e (cons 'article-type (cons type gnus-hidden-properties)))
1589 (when (memq 'intangible gnus-hidden-properties)
1590 (put-text-property (max (1- b) (point-min))
1591 b 'intangible nil)))
1593 (defun gnus-article-hide-text-of-type (type)
1594 "Hide text of TYPE in the current buffer."
1596 (let ((b (point-min))
1598 (while (setq b (text-property-any b e 'article-type type))
1599 (add-text-properties b (incf b) gnus-hidden-properties)))))
1601 (defun gnus-article-delete-text-of-type (type)
1602 "Delete text of TYPE in the current buffer."
1604 (let ((b (point-min)))
1605 (while (setq b (text-property-any b (point-max) 'article-type type))
1607 b (or (text-property-not-all b (point-max) 'article-type type)
1610 (defun gnus-article-delete-invisible-text ()
1611 "Delete all invisible text in the current buffer."
1613 (let ((b (point-min)))
1614 (while (setq b (text-property-any b (point-max) 'invisible t))
1616 b (or (text-property-not-all b (point-max) 'invisible t)
1619 (defun gnus-article-text-type-exists-p (type)
1620 "Say whether any text of type TYPE exists in the buffer."
1621 (text-property-any (point-min) (point-max) 'article-type type))
1623 (defsubst gnus-article-header-rank ()
1624 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1625 (let ((list gnus-sorted-header-list)
1628 (if (looking-at (car list))
1630 (setq list (cdr list))
1634 (defun article-hide-headers (&optional arg delete)
1635 "Hide unwanted headers and possibly sort them as well."
1636 (interactive (gnus-article-hidden-arg))
1637 ;; Lars said that this function might be inhibited.
1638 (if (gnus-article-check-hidden-text 'headers arg)
1640 ;; Show boring headers as well.
1641 (gnus-article-show-hidden-text 'boring-headers)
1642 (when (eq 1 (point-min))
1643 (set-window-start (get-buffer-window (current-buffer)) 1)))
1644 (unless gnus-inhibit-hiding
1647 (let ((inhibit-read-only t)
1648 (case-fold-search t)
1649 (max (1+ (length gnus-sorted-header-list)))
1650 (ignored (when (not gnus-visible-headers)
1651 (cond ((stringp gnus-ignored-headers)
1652 gnus-ignored-headers)
1653 ((listp gnus-ignored-headers)
1654 (mapconcat 'identity gnus-ignored-headers
1657 (cond ((stringp gnus-visible-headers)
1658 gnus-visible-headers)
1659 ((and gnus-visible-headers
1660 (listp gnus-visible-headers))
1661 (mapconcat 'identity gnus-visible-headers "\\|"))))
1662 (inhibit-point-motion-hooks t)
1664 ;; First we narrow to just the headers.
1665 (article-narrow-to-head)
1666 ;; Hide any "From " lines at the beginning of (mail) articles.
1667 (while (looking-at "From ")
1671 (delete-region (point-min) (point))
1672 (gnus-article-hide-text (point-min) (point)
1673 (nconc (list 'article-type 'headers)
1674 gnus-hidden-properties))))
1675 ;; Then treat the rest of the header lines.
1676 ;; Then we use the two regular expressions
1677 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1678 ;; select which header lines is to remain visible in the
1680 (while (re-search-forward "^[^ \t:]*:" nil t)
1682 ;; Mark the rank of the header.
1684 (point) (1+ (point)) 'message-rank
1685 (if (or (and visible (looking-at visible))
1687 (not (looking-at ignored))))
1688 (gnus-article-header-rank)
1691 (message-sort-headers-1)
1692 (when (setq beg (text-property-any
1693 (point-min) (point-max) 'message-rank (+ 2 max)))
1694 ;; We delete or make invisible the unwanted headers.
1695 (gnus-add-wash-type 'headers)
1698 (add-text-properties
1699 (point-min) (+ 5 (point-min))
1700 '(article-type headers dummy-invisible t))
1701 (delete-region beg (point-max)))
1702 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1704 (defun article-hide-boring-headers (&optional arg)
1705 "Toggle hiding of headers that aren't very interesting.
1706 If given a negative prefix, always show; if given a positive prefix,
1708 (interactive (gnus-article-hidden-arg))
1709 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1710 (not gnus-show-all-headers))
1713 (let ((buffer-read-only nil)
1714 (list gnus-boring-article-headers)
1715 (inhibit-point-motion-hooks t)
1717 (article-narrow-to-head)
1719 (setq elem (pop list))
1720 (goto-char (point-min))
1722 ;; Hide empty headers.
1724 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1726 (gnus-article-hide-text-type
1730 (if (re-search-forward "^[^ \t]" nil t)
1734 ;; Hide boring Newsgroups header.
1735 ((eq elem 'newsgroups)
1736 (when (gnus-string-equal
1737 (gnus-fetch-field "newsgroups")
1738 (gnus-group-real-name
1739 (if (boundp 'gnus-newsgroup-name)
1742 (gnus-article-hide-header "newsgroups")))
1743 ((eq elem 'to-address)
1744 (let ((to (message-fetch-field "to"))
1746 (gnus-parameter-to-address
1747 (if (boundp 'gnus-newsgroup-name)
1748 gnus-newsgroup-name ""))))
1749 (when (and to to-address
1752 ;; only one address in To
1753 (nth 1 (mail-extract-address-components to))
1755 (gnus-article-hide-header "to"))))
1757 (let ((to (message-fetch-field "to"))
1759 (gnus-parameter-to-list
1760 (if (boundp 'gnus-newsgroup-name)
1761 gnus-newsgroup-name ""))))
1762 (when (and to to-list
1765 ;; only one address in To
1766 (nth 1 (mail-extract-address-components to))
1768 (gnus-article-hide-header "to"))))
1770 (let ((cc (message-fetch-field "cc"))
1772 (gnus-parameter-to-list
1773 (if (boundp 'gnus-newsgroup-name)
1774 gnus-newsgroup-name ""))))
1775 (when (and cc to-list
1778 ;; only one address in CC
1779 (nth 1 (mail-extract-address-components cc))
1781 (gnus-article-hide-header "cc"))))
1782 ((eq elem 'followup-to)
1783 (when (gnus-string-equal
1784 (message-fetch-field "followup-to")
1785 (message-fetch-field "newsgroups"))
1786 (gnus-article-hide-header "followup-to")))
1787 ((eq elem 'reply-to)
1788 (let ((from (message-fetch-field "from"))
1789 (reply-to (message-fetch-field "reply-to")))
1794 (nth 1 (mail-extract-address-components from))
1795 (nth 1 (mail-extract-address-components reply-to)))))
1796 (gnus-article-hide-header "reply-to"))))
1798 (let ((date (message-fetch-field "date")))
1800 (< (days-between (current-time-string) date)
1802 (gnus-article-hide-header "date"))))
1804 (let ((to (message-fetch-field "to"))
1805 (cc (message-fetch-field "cc")))
1806 (when (> (length to) 1024)
1807 (gnus-article-hide-header "to"))
1808 (when (> (length cc) 1024)
1809 (gnus-article-hide-header "cc"))))
1813 (goto-char (point-min))
1814 (while (re-search-forward "^to:" nil t)
1815 (setq to-count (1+ to-count)))
1816 (when (> to-count 1)
1817 (while (> to-count 0)
1818 (goto-char (point-min))
1820 (re-search-forward "^to:" nil nil to-count)
1822 (narrow-to-region (point) (point-max))
1823 (gnus-article-hide-header "to"))
1824 (setq to-count (1- to-count))))
1825 (goto-char (point-min))
1826 (while (re-search-forward "^cc:" nil t)
1827 (setq cc-count (1+ cc-count)))
1828 (when (> cc-count 1)
1829 (while (> cc-count 0)
1830 (goto-char (point-min))
1832 (re-search-forward "^cc:" nil nil cc-count)
1834 (narrow-to-region (point) (point-max))
1835 (gnus-article-hide-header "cc"))
1836 (setq cc-count (1- cc-count)))))))))))))
1838 (defun gnus-article-hide-header (header)
1840 (goto-char (point-min))
1841 (when (re-search-forward (concat "^" header ":") nil t)
1842 (gnus-article-hide-text-type
1846 (if (re-search-forward "^[^ \t]" nil t)
1851 (defvar gnus-article-normalized-header-length 40
1852 "Length of normalized headers.")
1854 (defun article-normalize-headers ()
1855 "Make all header lines 40 characters long."
1857 (let ((buffer-read-only nil)
1861 (article-narrow-to-head)
1864 ((< (setq column (- (gnus-point-at-eol) (point)))
1865 gnus-article-normalized-header-length)
1867 (insert (make-string
1868 (- gnus-article-normalized-header-length column)
1870 ((> column gnus-article-normalized-header-length)
1871 (gnus-put-text-property
1873 (forward-char gnus-article-normalized-header-length)
1880 (forward-line 1))))))
1882 (defun article-treat-dumbquotes ()
1883 "Translate M****s*** sm*rtq**t*s into proper text.
1884 Note that this function guesses whether a character is a sm*rtq**t* or
1885 not, so it should only be used interactively.
1887 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1888 in an attempt to provide more quoting characters. If you see
1889 something like \\222 or \\264 where you're expecting some kind of
1890 apostrophe or quotation mark, then try this wash."
1892 (article-translate-strings gnus-article-dumbquotes-map))
1894 (defun article-translate-characters (from to)
1895 "Translate all characters in the body of the article according to FROM and TO.
1896 FROM is a string of characters to translate from; to is a string of
1897 characters to translate to."
1899 (when (article-goto-body)
1900 (let ((buffer-read-only nil)
1901 (x (make-string 225 ?x))
1903 (while (< (incf i) (length x))
1906 (while (< i (length from))
1907 (aset x (aref from i) (aref to i))
1909 (translate-region (point) (point-max) x)))))
1911 (defun article-translate-strings (map)
1912 "Translate all string in the body of the article according to MAP.
1913 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1915 (when (article-goto-body)
1916 (let ((buffer-read-only nil)
1918 (while (setq elem (pop map))
1920 (while (search-forward (car elem) nil t)
1921 (replace-match (cadr elem)))))))))
1923 (defun article-treat-overstrike ()
1924 "Translate overstrikes into bold text."
1927 (when (article-goto-body)
1928 (let ((buffer-read-only nil))
1929 (while (search-forward "\b" nil t)
1930 (let ((next (char-after))
1934 previous (char-after))
1938 ;; We do the boldification/underlining by hiding the
1939 ;; overstrikes and putting the proper text property
1943 (gnus-article-hide-text-type start (point) 'overstrike)
1944 (put-text-property (point) end 'face 'bold))
1946 (gnus-article-hide-text-type
1947 (1- (point)) (1+ (point)) 'overstrike)
1949 start (1- (point)) 'face 'underline))
1951 (gnus-article-hide-text-type start (point) 'overstrike)
1953 (point) end 'face 'underline)))))))))
1955 (defun gnus-article-treat-unfold-headers ()
1956 "Unfold folded message headers.
1957 Only the headers that fit into the current window width will be
1960 (gnus-with-article-headers
1964 (mail-header-narrow-to-field)
1965 (let ((header (buffer-string)))
1968 (goto-char (point-min))
1969 (while (re-search-forward "\n[\t ]" nil t)
1970 (replace-match " " t t)))
1971 (setq length (- (point-max) (point-min) 1)))
1972 (when (< length (window-width))
1973 (while (re-search-forward "\n[\t ]" nil t)
1974 (replace-match " " t t)))
1975 (goto-char (point-max)))))))
1977 (defun gnus-article-treat-fold-headers ()
1978 "Fold message headers."
1980 (gnus-with-article-headers
1983 (mail-header-narrow-to-field)
1984 (mail-header-fold-field)
1985 (goto-char (point-max))))))
1987 (defun gnus-treat-smiley ()
1988 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1990 (unless (featurep 'xemacs)
1991 (when (and (>= emacs-major-version 21)
1992 (not gnus-article-should-use-smiley-mule)
1993 gnus-article-smiley-mule-loaded-p)
1994 (load "smiley" nil t)
1995 (setq gnus-article-smiley-mule-loaded-p nil))
1996 (when (and gnus-article-should-use-smiley-mule
1997 (not gnus-article-smiley-mule-loaded-p))
1998 (load "smiley-mule" nil t)
1999 (setq gnus-article-smiley-mule-loaded-p t)))
2000 (gnus-with-article-buffer
2001 (if (memq 'smiley gnus-article-wash-types)
2002 (gnus-delete-images 'smiley)
2004 (let ((images (smiley-region (point) (point-max))))
2006 (gnus-add-wash-type 'smiley)
2007 (dolist (image images)
2008 (gnus-add-image 'smiley image)))))))
2010 (defun gnus-article-remove-images ()
2011 "Remove all images from the article buffer."
2013 (gnus-with-article-buffer
2014 (dolist (elem gnus-article-image-alist)
2015 (gnus-delete-images (car elem)))))
2017 (defun gnus-article-treat-fold-newsgroups ()
2018 "Unfold folded message headers.
2019 Only the headers that fit into the current window width will be
2022 (gnus-with-article-headers
2023 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2025 (mail-header-narrow-to-field)
2026 (while (re-search-forward ", *" nil t)
2027 (replace-match ", " t t))
2028 (mail-header-fold-field)
2029 (goto-char (point-max))))))
2031 (defun gnus-article-treat-body-boundary ()
2032 "Place a boundary line at the end of the headers."
2034 (when (and gnus-body-boundary-delimiter
2035 (> (length gnus-body-boundary-delimiter) 0))
2036 (gnus-with-article-headers
2037 (goto-char (point-max))
2038 (let ((start (point)))
2039 (insert "X-Boundary: ")
2040 (gnus-add-text-properties start (point) '(invisible t intangible t))
2042 (while (>= (1- (window-width)) (length str))
2043 (setq str (concat str gnus-body-boundary-delimiter)))
2044 (substring str 0 (1- (window-width))))
2046 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2048 (defun article-fill-long-lines ()
2049 "Fill lines that are wider than the window width."
2052 (let ((buffer-read-only nil)
2053 (width (window-width (get-buffer-window (current-buffer)))))
2056 (let ((adaptive-fill-mode nil)) ;Why? -sm
2059 (when (>= (current-column) (min fill-column width))
2060 (narrow-to-region (min (1+ (point)) (point-max))
2061 (gnus-point-at-bol))
2062 (let ((goback (point-marker)))
2063 (fill-paragraph nil)
2064 (goto-char (marker-position goback)))
2066 (forward-line 1)))))))
2068 (defun article-capitalize-sentences ()
2069 "Capitalize the first word in each sentence."
2072 (let ((buffer-read-only nil)
2073 (paragraph-start "^[\n\^L]"))
2077 (forward-sentence)))))
2079 (defun article-remove-cr ()
2080 "Remove trailing CRs and then translate remaining CRs into LFs."
2083 (let ((buffer-read-only nil))
2084 (goto-char (point-min))
2085 (while (re-search-forward "\r+$" nil t)
2086 (replace-match "" t t))
2087 (goto-char (point-min))
2088 (while (search-forward "\r" nil t)
2089 (replace-match "\n" t t)))))
2091 (defun article-remove-trailing-blank-lines ()
2092 "Remove all trailing blank lines from the article."
2095 (let ((buffer-read-only nil))
2096 (goto-char (point-max))
2100 (while (and (not (bobp))
2101 (looking-at "^[ \t]*$")
2102 (not (gnus-annotation-in-region-p
2103 (point) (gnus-point-at-eol))))
2108 (defun article-display-face ()
2109 "Display any Face headers in the header."
2111 (gnus-with-article-headers
2112 (let ((face (message-fetch-field "face")))
2114 (let ((png (gnus-convert-face-to-png face))
2117 (setq image (gnus-create-image png 'png t))
2118 (gnus-article-goto-header "from")
2120 (insert "From: [no `from' set]\n")
2122 (gnus-add-wash-type 'face)
2123 (gnus-add-image 'face image)
2124 (gnus-put-image image)))))))
2126 (defun article-display-x-face (&optional force)
2127 "Look for an X-Face header and display it if present."
2128 (interactive (list 'force))
2129 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2130 (gnus-with-article-headers
2131 ;; Delete the old process, if any.
2132 (when (process-status "article-x-face")
2133 (delete-process "article-x-face"))
2134 (if (memq 'xface gnus-article-wash-types)
2135 ;; We have already displayed X-Faces, so we remove them
2137 (gnus-delete-images 'xface)
2139 (let (x-faces from face)
2141 (when (and wash-face-p
2143 (goto-char (point-min))
2144 (not (re-search-forward
2145 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2146 (gnus-buffer-live-p gnus-original-article-buffer))
2147 ;; If type `W f', use gnus-original-article-buffer,
2148 ;; otherwise use the current buffer because displaying
2149 ;; RFC822 parts calls this function too.
2150 (set-buffer gnus-original-article-buffer))
2152 (mail-narrow-to-head)
2153 (while (gnus-article-goto-header "X-Face")
2154 (push (mail-header-field-value) x-faces))
2155 (setq from (message-fetch-field "from"))))
2156 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2157 ;; single external face.
2158 (when (stringp gnus-article-x-face-command)
2159 (setq x-faces (list (car x-faces))))
2160 (while (and (setq face (pop x-faces))
2161 gnus-article-x-face-command
2163 ;; Check whether this face is censored.
2164 (not gnus-article-x-face-too-ugly)
2165 (and gnus-article-x-face-too-ugly from
2166 (not (string-match gnus-article-x-face-too-ugly
2168 ;; We display the face.
2169 (if (symbolp gnus-article-x-face-command)
2170 ;; The command is a lisp function, so we call it.
2171 (if (gnus-functionp gnus-article-x-face-command)
2172 (funcall gnus-article-x-face-command face)
2173 (error "%s is not a function" gnus-article-x-face-command))
2174 ;; The command is a string, so we interpret the command
2175 ;; as a, well, command, and fork it off.
2176 (let ((process-connection-type nil))
2177 (process-kill-without-query
2179 "article-x-face" nil shell-file-name shell-command-switch
2180 gnus-article-x-face-command))
2183 (process-send-region "article-x-face"
2184 (point-min) (point-max)))
2185 (process-send-eof "article-x-face")))))))))
2187 (defun article-decode-mime-words ()
2188 "Decode all MIME-encoded words in the article."
2191 (set-buffer gnus-article-buffer)
2192 (let ((inhibit-point-motion-hooks t)
2194 (mail-parse-charset gnus-newsgroup-charset)
2195 (mail-parse-ignored-charsets
2196 (save-excursion (set-buffer gnus-summary-buffer)
2197 gnus-newsgroup-ignored-charsets)))
2198 (mail-decode-encoded-word-region (point-min) (point-max)))))
2200 (defun article-decode-charset (&optional prompt)
2201 "Decode charset-encoded text in the article.
2202 If PROMPT (the prefix), prompt for a coding system to use."
2204 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2206 (mail-parse-charset gnus-newsgroup-charset)
2207 (mail-parse-ignored-charsets
2208 (save-excursion (condition-case nil
2209 (set-buffer gnus-summary-buffer)
2211 gnus-newsgroup-ignored-charsets))
2212 ct cte ctl charset format)
2215 (article-narrow-to-head)
2216 (setq ct (message-fetch-field "Content-Type" t)
2217 cte (message-fetch-field "Content-Transfer-Encoding" t)
2218 ctl (and ct (ignore-errors
2219 (mail-header-parse-content-type ct)))
2222 (mm-read-coding-system "Charset to decode: "))
2224 (mail-content-type-get ctl 'charset)))
2225 format (and ctl (mail-content-type-get ctl 'format)))
2227 (setq cte (mail-header-strip cte)))
2228 (if (and ctl (not (string-match "/" (car ctl))))
2230 (goto-char (point-max)))
2233 (narrow-to-region (point) (point-max))
2234 (when (and (eq mail-parse-charset 'gnus-decoded)
2235 (eq (mm-body-7-or-8) '8bit))
2236 ;; The text code could have been decoded.
2237 (setq charset mail-parse-charset))
2238 (when (and (or (not ctl)
2239 (equal (car ctl) "text/plain"))
2240 (not format)) ;; article with format will decode later.
2242 charset (and cte (intern (downcase
2243 (gnus-strip-whitespace cte))))
2244 (car ctl) prompt))))))
2246 (defun article-decode-encoded-words ()
2247 "Remove encoded-word encoding from headers."
2248 (let (buffer-read-only)
2249 (let ((charset (save-excursion
2250 (set-buffer gnus-summary-buffer)
2251 default-mime-charset)))
2252 (mime-decode-header-in-buffer charset))))
2254 (defun article-decode-group-name ()
2255 "Decode group names in `Newsgroups:'."
2256 (let ((inhibit-point-motion-hooks t)
2258 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2259 (when (and (or gnus-group-name-charset-method-alist
2260 gnus-group-name-charset-group-alist)
2261 (gnus-buffer-live-p gnus-original-article-buffer))
2263 (article-narrow-to-head)
2264 (with-current-buffer gnus-original-article-buffer
2265 (goto-char (point-min)))
2266 (while (re-search-forward "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2268 (replace-match (save-match-data
2269 (gnus-decode-newsgroups
2270 ;; XXX how to use data in article buffer?
2271 (with-current-buffer gnus-original-article-buffer
2273 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2276 gnus-newsgroup-name method))
2278 (goto-char (point-min))
2279 (with-current-buffer gnus-original-article-buffer
2280 (goto-char (point-min)))
2281 (while (re-search-forward "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2283 (replace-match (save-match-data
2284 (gnus-decode-newsgroups
2285 ;; XXX how to use data in article buffer?
2286 (with-current-buffer gnus-original-article-buffer
2288 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2291 gnus-newsgroup-name method))
2294 (autoload 'idna-to-unicode "idna")
2296 (defun article-decode-idna-rhs ()
2297 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2300 (let ((inhibit-point-motion-hooks t)
2302 (article-narrow-to-head)
2303 (goto-char (point-min))
2304 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2306 (when (save-match-data
2307 (and (setq ace (match-string 1))
2309 (and (re-search-backward "^[^ \t]" nil t)
2310 (looking-at "From\\|To\\|Cc")))
2311 (save-excursion (backward-char)
2312 (message-idna-inside-rhs-p))
2313 (setq unicode (idna-to-unicode ace))))
2314 (unless (string= ace unicode)
2315 (replace-match unicode nil nil nil 1)))))))))
2317 (defun article-de-quoted-unreadable (&optional force read-charset)
2318 "Translate a quoted-printable-encoded article.
2319 If FORCE, decode the article whether it is marked as quoted-printable
2321 If READ-CHARSET, ask for a coding system."
2322 (interactive (list 'force current-prefix-arg))
2324 (let ((buffer-read-only nil) type charset)
2325 (if (gnus-buffer-live-p gnus-original-article-buffer)
2326 (with-current-buffer gnus-original-article-buffer
2328 (gnus-fetch-field "content-transfer-encoding"))
2329 (let* ((ct (gnus-fetch-field "content-type"))
2332 (mail-header-parse-content-type ct)))))
2333 (setq charset (and ctl
2334 (mail-content-type-get ctl 'charset)))
2335 (if (stringp charset)
2336 (setq charset (intern (downcase charset)))))))
2338 (setq charset (mm-read-coding-system "Charset: " charset)))
2340 (setq charset gnus-newsgroup-charset))
2342 (and type (let ((case-fold-search t))
2343 (string-match "quoted-printable" type))))
2345 (quoted-printable-decode-region
2346 (point) (point-max) (mm-charset-to-coding-system charset))))))
2348 (defun article-de-base64-unreadable (&optional force read-charset)
2349 "Translate a base64 article.
2350 If FORCE, decode the article whether it is marked as base64 not.
2351 If READ-CHARSET, ask for a coding system."
2352 (interactive (list 'force current-prefix-arg))
2354 (let ((buffer-read-only nil) type charset)
2355 (if (gnus-buffer-live-p gnus-original-article-buffer)
2356 (with-current-buffer gnus-original-article-buffer
2358 (gnus-fetch-field "content-transfer-encoding"))
2359 (let* ((ct (gnus-fetch-field "content-type"))
2362 (mail-header-parse-content-type ct)))))
2363 (setq charset (and ctl
2364 (mail-content-type-get ctl 'charset)))
2365 (if (stringp charset)
2366 (setq charset (intern (downcase charset)))))))
2368 (setq charset (mm-read-coding-system "Charset: " charset)))
2370 (setq charset gnus-newsgroup-charset))
2372 (and type (let ((case-fold-search t))
2373 (string-match "base64" type))))
2376 (narrow-to-region (point) (point-max))
2377 (base64-decode-region (point-min) (point-max))
2378 (mm-decode-coding-region
2379 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2384 (defun article-decode-HZ ()
2385 "Translate a HZ-encoded article."
2389 (let ((buffer-read-only nil))
2390 (rfc1843-decode-region (point-min) (point-max)))))
2392 (defun article-unsplit-urls ()
2393 "Remove the newlines that some other mailers insert into URLs."
2396 (let ((buffer-read-only nil))
2397 (goto-char (point-min))
2398 (while (re-search-forward
2399 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2400 (replace-match "\\1\\3" t)))
2401 (when (and gnus-display-mime-function (interactive-p))
2402 (funcall gnus-display-mime-function))))
2405 (defun article-wash-html (&optional read-charset)
2406 "Format an HTML article.
2407 If READ-CHARSET, ask for a coding system."
2410 (let ((buffer-read-only nil)
2412 (when (gnus-buffer-live-p gnus-original-article-buffer)
2413 (with-current-buffer gnus-original-article-buffer
2414 (let* ((ct (gnus-fetch-field "content-type"))
2417 (mail-header-parse-content-type ct)))))
2418 (setq charset (and ctl
2419 (mail-content-type-get ctl 'charset)))
2420 (when (stringp charset)
2421 (setq charset (intern (downcase charset)))))))
2423 (setq charset (mm-read-coding-system "Charset: " charset)))
2425 (setq charset gnus-newsgroup-charset))
2427 (save-window-excursion
2429 (narrow-to-region (point) (point-max))
2430 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2431 (entry (assq func mm-text-html-washer-alist)))
2433 (setq func (cdr entry)))
2435 ((gnus-functionp func)
2438 (apply (car func) (cdr func))))))))))
2440 (defun gnus-article-wash-html-with-w3 ()
2441 "Wash the current buffer with w3."
2443 (let ((w3-strict-width (window-width))
2444 (url-standalone-mode t)
2445 (url-gateway-unplugged t)
2446 (w3-honor-stylesheets nil))
2448 (w3-region (point-min) (point-max))
2451 (defun gnus-article-wash-html-with-w3m ()
2452 "Wash the current buffer with emacs-w3m."
2455 (narrow-to-region (point) (point-max))
2456 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2459 w3m-force-redisplay)
2460 (w3m-region (point-min) (point-max)))
2461 (when mm-inline-text-html-with-w3m-keymap
2462 (add-text-properties
2463 (point-min) (point-max)
2464 (nconc (mm-w3m-local-map-property)
2465 '(mm-inline-text-html-with-w3m t))))))
2467 (defun article-hide-list-identifiers ()
2468 "Remove list identifies from the Subject header.
2469 The `gnus-list-identifiers' variable specifies what to do."
2471 (let ((inhibit-point-motion-hooks t)
2472 (regexp (if (consp gnus-list-identifiers)
2473 (mapconcat 'identity gnus-list-identifiers " *\\|")
2474 gnus-list-identifiers))
2479 (article-narrow-to-head)
2480 (goto-char (point-min))
2481 (while (re-search-forward
2482 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2484 (delete-region (match-beginning 2) (match-end 0))
2485 (beginning-of-line))
2486 (when (re-search-forward
2487 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2488 (delete-region (match-beginning 1) (match-end 1))))))))
2490 (defun article-hide-pem (&optional arg)
2491 "Toggle hiding of any PEM headers and signatures in the current article.
2492 If given a negative prefix, always show; if given a positive prefix,
2494 (interactive (gnus-article-hidden-arg))
2495 (unless (gnus-article-check-hidden-text 'pem arg)
2497 (let (buffer-read-only end)
2498 (goto-char (point-min))
2499 ;; Hide the horrendously ugly "header".
2500 (when (and (search-forward
2501 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2503 (setq end (1+ (match-beginning 0))))
2504 (gnus-add-wash-type 'pem)
2505 (gnus-article-hide-text-type
2507 (if (search-forward "\n\n" nil t)
2511 ;; Hide the trailer as well
2512 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2514 (gnus-article-hide-text-type
2515 (match-beginning 0) (match-end 0) 'pem)))))))
2517 (defun article-strip-banner ()
2518 "Strip the banners specified by the `banner' group parameter and by
2519 `gnus-article-address-banner-alist'."
2523 (let ((inhibit-point-motion-hooks t))
2524 (when (gnus-parameter-banner gnus-newsgroup-name)
2525 (article-really-strip-banner
2526 (gnus-parameter-banner gnus-newsgroup-name)))
2527 (when gnus-article-address-banner-alist
2528 (article-really-strip-banner
2529 (let ((from (save-restriction
2531 (article-narrow-to-head)
2532 (mail-fetch-field "from"))))
2535 (caar (mail-header-parse-addresses from))))
2537 (dolist (pair gnus-article-address-banner-alist)
2538 (when (string-match (car pair) from)
2539 (throw 'found (cdr pair)))))))))))))
2541 (defun article-really-strip-banner (banner)
2542 "Strip the banner specified by the argument."
2545 (let ((inhibit-point-motion-hooks t)
2546 (gnus-signature-limit nil)
2550 ((eq banner 'signature)
2551 (when (gnus-article-narrow-to-signature)
2554 (delete-region (point) (point-max))))
2556 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2557 (while (re-search-forward banner nil t)
2558 (delete-region (match-beginning 0) (match-end 0)))))
2560 (while (re-search-forward banner nil t)
2561 (delete-region (match-beginning 0) (match-end 0)))))))))
2563 (defun article-babel ()
2564 "Translate article using an online translation service."
2568 (set-buffer gnus-article-buffer)
2569 (when (article-goto-body)
2570 (let* ((buffer-read-only nil)
2573 (orig (buffer-substring start end))
2574 (trans (babel-as-string orig)))
2576 (narrow-to-region start end)
2577 (delete-region start end)
2580 (defun article-hide-signature (&optional arg)
2581 "Hide the signature in the current article.
2582 If given a negative prefix, always show; if given a positive prefix,
2584 (interactive (gnus-article-hidden-arg))
2590 (article-goto-body))
2591 (goto-char (point-min)))
2592 (unless (gnus-article-check-hidden-text 'signature arg)
2593 (let ((buffer-read-only nil)
2595 (while (setq button (text-property-any button (point-max)
2597 'gnus-signature-toggle))
2598 (setq button (text-property-not-all button (point-max)
2600 'gnus-signature-toggle))
2601 (when (and button (not (eobp)))
2602 (gnus-article-hide-text-type
2604 (next-single-property-change (1+ button) 'mime-view-entity
2607 (gnus-set-mode-line 'article))
2609 (defun article-strip-headers-in-body ()
2610 "Strip offensive headers from bodies."
2614 (let ((case-fold-search t))
2615 (when (looking-at "x-no-archive:")
2616 (gnus-delete-line)))))
2618 (defun article-strip-leading-blank-lines ()
2619 "Remove all blank lines from the beginning of the article."
2622 (let ((inhibit-point-motion-hooks t)
2624 (when (article-goto-body)
2625 (while (and (not (eobp))
2626 (looking-at "[ \t]*$"))
2627 (gnus-delete-line))))))
2629 (defun article-narrow-to-head ()
2630 "Narrow the buffer to the head of the message.
2631 Point is left at the beginning of the narrowed-to region."
2633 (goto-char (point-min))
2634 (if (search-forward "\n\n" nil 1)
2637 (goto-char (point-min)))
2639 (defun article-goto-body ()
2640 "Place point at the start of the body."
2641 (goto-char (point-min))
2643 ;; This variable is only bound when dealing with separate
2645 (article-goto-body-goes-to-point-min-p
2647 ((search-forward "\n\n" nil t)
2650 (goto-char (point-max))
2653 (defun article-strip-multiple-blank-lines ()
2654 "Replace consecutive blank lines with one empty line."
2657 (let ((inhibit-point-motion-hooks t)
2659 ;; First make all blank lines empty.
2661 (while (re-search-forward "^[ \t]+$" nil t)
2662 (unless (gnus-annotation-in-region-p
2663 (match-beginning 0) (match-end 0))
2664 (replace-match "" nil t)))
2665 ;; Then replace multiple empty lines with a single empty line.
2667 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2668 (unless (gnus-annotation-in-region-p
2669 (match-beginning 0) (match-end 0))
2670 (delete-region (match-beginning 1) (match-end 1)))))))
2672 (defun article-strip-leading-space ()
2673 "Remove all white space from the beginning of the lines in the article."
2676 (let ((inhibit-point-motion-hooks t)
2679 (while (re-search-forward "^[ \t]+" nil t)
2680 (replace-match "" t t)))))
2682 (defun article-strip-trailing-space ()
2683 "Remove all white space from the end of the lines in the article."
2686 (let ((inhibit-point-motion-hooks t)
2689 (while (re-search-forward "[ \t]+$" nil t)
2690 (replace-match "" t t)))))
2692 (defun article-strip-blank-lines ()
2693 "Strip leading, trailing and multiple blank lines."
2695 (article-strip-leading-blank-lines)
2696 (article-remove-trailing-blank-lines)
2697 (article-strip-multiple-blank-lines))
2699 (defun article-strip-all-blank-lines ()
2700 "Strip all blank lines."
2703 (let ((inhibit-point-motion-hooks t)
2706 (while (re-search-forward "^[ \t]*\n" nil t)
2707 (replace-match "" t t)))))
2709 (defun gnus-article-narrow-to-signature ()
2710 "Narrow to the signature; return t if a signature is found, else nil."
2711 (let ((inhibit-point-motion-hooks t))
2712 (when (gnus-article-search-signature)
2714 ;; Check whether we have some limits to what we consider
2715 ;; to be a signature.
2716 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2717 (list gnus-signature-limit)))
2719 (while (setq limit (pop limits))
2720 (if (or (and (integerp limit)
2721 (< (- (point-max) (point)) limit))
2723 (< (count-lines (point) (point-max)) limit))
2724 (and (gnus-functionp limit)
2726 (and (stringp limit)
2727 (not (re-search-forward limit nil t))))
2728 () ; This limit did not succeed.
2732 (narrow-to-region (point) (point-max))
2735 (defun gnus-article-search-signature ()
2736 "Search the current buffer for the signature separator.
2737 Put point at the beginning of the signature separator."
2738 (let ((cur (point)))
2739 (goto-char (point-max))
2740 (if (if (stringp gnus-signature-separator)
2741 (re-search-backward gnus-signature-separator nil t)
2742 (let ((seps gnus-signature-separator))
2744 (not (re-search-backward (car seps) nil t)))
2751 (defun gnus-article-hidden-arg ()
2752 "Return the current prefix arg as a number, or 0 if no prefix."
2753 (list (if current-prefix-arg
2754 (prefix-numeric-value current-prefix-arg)
2757 (defun gnus-article-check-hidden-text (type arg)
2758 "Return nil if hiding is necessary.
2759 Arg can be nil or a number. nil and positive means hide, negative
2760 means show, 0 means toggle."
2763 (let ((hide (gnus-article-hidden-text-p type)))
2769 (gnus-article-show-hidden-text type)
2772 (if (eq hide 'hidden)
2774 (gnus-article-show-hidden-text type)
2778 (defun gnus-article-hidden-text-p (type)
2779 "Say whether the current buffer contains hidden text of type TYPE."
2780 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2782 (not (get-text-property pos 'invisible))
2783 (not (get-text-property pos 'dummy-invisible)))
2785 (text-property-any (1+ pos) (point-max) 'article-type type)))
2790 (defun gnus-article-show-hidden-text (type &optional dummy)
2791 "Show all hidden text of type TYPE.
2792 Originally it is hide instead of DUMMY."
2793 (let ((buffer-read-only nil)
2794 (inhibit-point-motion-hooks t))
2795 (gnus-remove-text-properties-when
2797 (point-min) (point-max)
2798 (cons 'article-type (cons type
2799 gnus-hidden-properties)))
2800 (gnus-delete-wash-type type)))
2802 (defconst article-time-units
2803 `((year . ,(* 365.25 24 60 60))
2804 (week . ,(* 7 24 60 60))
2805 (day . ,(* 24 60 60))
2809 "Mapping from time units to seconds.")
2811 (defun gnus-article-forward-header ()
2812 "Move point to the start of the next header.
2813 If the current header is a continuation header, this can be several
2818 (if (looking-at "[ \t]+[^ \t]")
2822 (defun article-date-ut (&optional type highlight header)
2823 "Convert DATE date to universal time in the current article.
2824 If TYPE is `local', convert to local time; if it is `lapsed', output
2825 how much time has lapsed since DATE. For `lapsed', the value of
2826 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2827 should replace the \"Date:\" one, or should be added below it."
2828 (interactive (list 'ut t))
2829 (let* ((header (or header
2830 (and (eq 1 (point-min))
2831 (mail-header-date (save-excursion
2832 (set-buffer gnus-summary-buffer)
2833 gnus-current-headers)))
2834 (message-fetch-field "date")
2836 (date (if (vectorp header) (mail-header-date header)
2838 (inhibit-point-motion-hooks t)
2839 bface eface date-pos)
2840 (when (and date (not (string= date "")))
2843 (article-narrow-to-head)
2844 (when (or (and (eq type 'lapsed)
2845 gnus-article-date-lapsed-new-header
2846 ;; Attempt to get the face of X-Sent first.
2847 (re-search-forward "^X-Sent:[ \t]" nil t))
2848 (re-search-forward "^Date:[ \t]" nil t)
2849 ;; If Date is missing, try again for X-Sent.
2850 (re-search-forward "^X-Sent:[ \t]" nil t))
2851 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2852 date (or (get-text-property (gnus-point-at-bol)
2855 eface (get-text-property (1- (gnus-point-at-eol))
2857 (let ((buffer-read-only nil))
2858 ;; Delete any old X-Sent headers.
2859 (when (setq date-pos
2860 (text-property-any (point-min) (point-max)
2861 'article-date-lapsed t))
2862 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2863 (delete-region (match-beginning 0)
2864 (progn (forward-line 1) (point))))
2865 (goto-char (point-min))
2866 ;; Delete any old Date headers.
2867 (while (re-search-forward "^Date:[ \t]" nil t)
2869 (setq date-pos (match-beginning 0)))
2870 (unless (and (eq type 'lapsed)
2871 gnus-article-date-lapsed-new-header)
2872 (delete-region (match-beginning 0)
2873 (progn (message-next-header) (point)))))
2876 (goto-char date-pos)
2878 ;; Possibly, Date has been deleted.
2880 (when (and (eq type 'lapsed)
2881 gnus-article-date-lapsed-new-header
2882 (looking-at "Date:"))
2884 (goto-char (point-min)))
2885 (insert (article-make-date-line date type))
2886 (when (eq type 'lapsed)
2887 (put-text-property (gnus-point-at-bol) (point)
2888 'article-date-lapsed t))
2892 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2893 (put-text-property (match-beginning 1) (1+ (match-end 1))
2894 'original-date date)
2895 (put-text-property (match-beginning 1) (1+ (match-end 1))
2897 (put-text-property (match-beginning 2) (match-end 2)
2900 (defun article-make-date-line (date type)
2901 "Return a DATE line of TYPE."
2902 (unless (memq type '(local ut original user iso8601 lapsed english))
2903 (error "Unknown conversion type: %s" type))
2905 (let ((time (date-to-time date)))
2907 ;; Convert to the local timezone.
2909 (let ((tz (car (current-time-zone time))))
2910 (format "Date: %s %s%02d%02d" (current-time-string time)
2911 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2912 (/ (% (abs tz) 3600) 60))))
2913 ;; Convert to Universal Time.
2916 (current-time-string
2917 (let* ((e (parse-time-string date))
2918 (tm (apply 'encode-time e))
2920 (ls (- (cadr tm) (car (current-time-zone time)))))
2921 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2922 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2925 ;; Get the original date from the article.
2926 ((eq type 'original)
2927 (concat "Date: " (if (string-match "\n+$" date)
2928 (substring date 0 (match-beginning 0))
2930 ;; Let the user define the format.
2932 (let ((format (or (condition-case nil
2933 (with-current-buffer gnus-summary-buffer
2934 gnus-article-time-format)
2936 gnus-article-time-format)))
2937 (if (gnus-functionp format)
2938 (funcall format time)
2939 (concat "Date: " (format-time-string format time)))))
2942 (let ((tz (car (current-time-zone time))))
2945 (format-time-string "%Y%m%dT%H%M%S" time)
2946 (format "%s%02d%02d"
2947 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2948 (/ (% (abs tz) 3600) 60)))))
2949 ;; Do an X-Sent lapsed format.
2951 ;; If the date is seriously mangled, the timezone functions are
2952 ;; liable to bug out, so we ignore all errors.
2953 (let* ((now (current-time))
2954 (real-time (subtract-time now time))
2955 (real-sec (and real-time
2956 (+ (* (float (car real-time)) 65536)
2958 (sec (and real-time (abs real-sec)))
2968 ;; This is a bit convoluted, but basically we go
2969 ;; through the time units for years, weeks, etc,
2970 ;; and divide things to see whether that results
2971 ;; in positive answers.
2974 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2975 ;; The (remaining) seconds are too few to
2976 ;; be divided into this time unit.
2978 ;; It's big enough, so we output it.
2979 (setq sec (- sec (* num (cdr unit))))
2981 (concat (if prev ", " "") (int-to-string
2983 " " (symbol-name (car unit))
2984 (if (> num 1) "s" ""))
2986 article-time-units "")
2987 ;; If dates are odd, then it might appear like the
2988 ;; article was sent in the future.
2991 " in the future"))))))
2992 ;; Display the date in proper English
2994 (let ((dtime (decode-time time)))
2997 (number-to-string (nth 3 dtime))
2998 (let ((digit (% (nth 3 dtime) 10)))
3000 ((memq (nth 3 dtime) '(11 12 13)) "th")
3006 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3008 (number-to-string (nth 5 dtime))
3010 (format "%02d" (nth 2 dtime))
3012 (format "%02d" (nth 1 dtime)))))))
3014 (format "Date: %s (from T-gnus)" date))))
3016 (defun article-date-local (&optional highlight)
3017 "Convert the current article date to the local timezone."
3018 (interactive (list t))
3019 (article-date-ut 'local highlight))
3021 (defun article-date-english (&optional highlight)
3022 "Convert the current article date to something that is proper English."
3023 (interactive (list t))
3024 (article-date-ut 'english highlight))
3026 (defun article-date-original (&optional highlight)
3027 "Convert the current article date to what it was originally.
3028 This is only useful if you have used some other date conversion
3029 function and want to see what the date was before converting."
3030 (interactive (list t))
3031 (article-date-ut 'original highlight))
3033 (defun article-date-lapsed (&optional highlight)
3034 "Convert the current article date to time lapsed since it was sent."
3035 (interactive (list t))
3036 (article-date-ut 'lapsed highlight))
3038 (defun article-update-date-lapsed ()
3039 "Function to be run from a timer to update the lapsed time line."
3040 (let (deactivate-mark)
3045 (set-buffer (window-buffer w))
3046 (when (eq major-mode 'gnus-article-mode)
3047 (goto-char (point-min))
3048 (when (re-search-forward "^X-Sent:" nil t)
3049 (article-date-lapsed t))))
3052 (defun gnus-start-date-timer (&optional n)
3053 "Start a timer to update the X-Sent header in the article buffers.
3054 The numerical prefix says how frequently (in seconds) the function
3059 (gnus-stop-date-timer)
3060 (setq article-lapsed-timer
3061 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3063 (defun gnus-stop-date-timer ()
3064 "Stop the X-Sent timer."
3066 (when article-lapsed-timer
3067 (nnheader-cancel-timer article-lapsed-timer)
3068 (setq article-lapsed-timer nil)))
3070 (defun article-date-user (&optional highlight)
3071 "Convert the current article date to the user-defined format.
3072 This format is defined by the `gnus-article-time-format' variable."
3073 (interactive (list t))
3074 (article-date-ut 'user highlight))
3076 (defun article-date-iso8601 (&optional highlight)
3077 "Convert the current article date to ISO8601."
3078 (interactive (list t))
3079 (article-date-ut 'iso8601 highlight))
3081 ;; (defun article-show-all ()
3082 ;; "Show all hidden text in the article buffer."
3086 ;; (let ((buffer-read-only nil))
3087 ;; (gnus-article-unhide-text (point-min) (point-max))
3088 ;; (gnus-remove-text-with-property 'gnus-prev)
3089 ;; (gnus-remove-text-with-property 'gnus-next))))
3091 (defun article-show-all-headers ()
3092 "Show all hidden headers in the article buffer."
3097 (article-narrow-to-head)
3098 (let ((buffer-read-only nil))
3099 (gnus-article-unhide-text (point-min) (point-max))))))
3101 (defun article-remove-leading-whitespace ()
3102 "Remove excessive whitespace from all headers."
3106 (let ((buffer-read-only nil))
3107 (article-narrow-to-head)
3108 (goto-char (point-min))
3109 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3110 (delete-region (match-beginning 1) (match-end 1)))))))
3112 (defun article-emphasize (&optional arg)
3113 "Emphasize text according to `gnus-emphasis-alist'."
3114 (interactive (gnus-article-hidden-arg))
3115 (unless (gnus-article-check-hidden-text 'emphasis arg)
3119 (with-current-buffer gnus-summary-buffer
3120 gnus-article-emphasis-alist)
3122 gnus-emphasis-alist))
3123 (buffer-read-only nil)
3124 (props (append '(article-type emphasis)
3125 gnus-hidden-properties))
3126 regexp elem beg invisible visible face)
3129 (while (setq elem (pop alist))
3131 (setq regexp (car elem)
3132 invisible (nth 1 elem)
3133 visible (nth 2 elem)
3135 (while (re-search-forward regexp nil t)
3136 (when (and (match-beginning visible) (match-beginning invisible))
3137 (gnus-article-hide-text
3138 (match-beginning invisible) (match-end invisible) props)
3139 (gnus-article-unhide-text-type
3140 (match-beginning visible) (match-end visible) 'emphasis)
3141 (gnus-put-overlay-excluding-newlines
3142 (match-beginning visible) (match-end visible) 'face face)
3143 (gnus-add-wash-type 'emphasis)
3144 (goto-char (match-end invisible)))))))))
3146 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3147 "Setup newsgroup emphasis alist."
3148 (unless gnus-article-emphasis-alist
3149 (let ((name (and gnus-newsgroup-name
3150 (gnus-group-real-name gnus-newsgroup-name))))
3151 (make-local-variable 'gnus-article-emphasis-alist)
3152 (setq gnus-article-emphasis-alist
3154 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3155 (while (setq elem (pop alist))
3156 (when (and name (string-match (car elem) name))
3158 highlight (copy-sequence (cdr elem)))))
3160 (copy-sequence highlight-words)
3161 (if gnus-newsgroup-name
3162 (copy-sequence (gnus-group-find-parameter
3163 gnus-newsgroup-name 'highlight-words t)))
3164 gnus-emphasis-alist)))))
3167 (defvar gnus-summary-article-menu)
3168 (defvar gnus-summary-post-menu))
3170 ;;; Saving functions.
3172 (defun gnus-article-save (save-buffer file &optional num)
3173 "Save the currently selected article."
3174 (unless gnus-save-all-headers
3175 ;; Remove headers according to `gnus-saved-headers'.
3176 (let ((gnus-visible-headers
3177 (or gnus-saved-headers gnus-visible-headers))
3178 (gnus-article-buffer save-buffer))
3180 (set-buffer save-buffer)
3181 (article-hide-headers 1 t))))
3182 (save-window-excursion
3183 (if (not gnus-default-article-saver)
3184 (error "No default saver is defined")
3185 ;; !!! Magic! The saving functions all save
3186 ;; `gnus-save-article-buffer' (or so they think), but we
3187 ;; bind that variable to our save-buffer.
3188 (set-buffer gnus-article-buffer)
3189 (let* ((gnus-save-article-buffer save-buffer)
3192 ((not gnus-prompt-before-saving) 'default)
3193 ((eq gnus-prompt-before-saving 'always) nil)
3195 (gnus-number-of-articles-to-be-saved
3196 (when (eq gnus-prompt-before-saving t)
3198 (set-buffer gnus-article-current-summary)
3199 (funcall gnus-default-article-saver filename)))))
3201 (defun gnus-read-save-file-name (prompt &optional filename
3202 function group headers variable)
3204 (funcall function group headers (symbol-value variable)))
3209 ((eq filename 'default)
3215 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3218 (if (and gnus-number-of-articles-to-be-saved
3219 (> gnus-number-of-articles-to-be-saved 1))
3220 (format "these %d articles"
3221 gnus-number-of-articles-to-be-saved)
3224 ;; Let the split methods have their say.
3226 ;; No split name was found.
3229 (concat prompt " (default "
3230 (file-name-nondirectory default-name) ") ")
3231 (file-name-directory default-name)
3233 ;; A single group name is returned.
3234 ((stringp split-name)
3236 (funcall function split-name headers
3237 (symbol-value variable)))
3239 (concat prompt " (default "
3240 (file-name-nondirectory default-name) ") ")
3241 (file-name-directory default-name)
3243 ;; A single split name was found
3244 ((= 1 (length split-name))
3245 (let* ((name (expand-file-name
3247 gnus-article-save-directory))
3248 (dir (cond ((file-directory-p name)
3249 (file-name-as-directory name))
3250 ((file-exists-p name) name)
3251 (t gnus-article-save-directory))))
3253 (concat prompt " (default " name ") ")
3255 ;; A list of splits was found.
3257 (setq split-name (nreverse split-name))
3259 (let ((file-name-history
3260 (nconc split-name file-name-history)))
3264 (concat prompt " (`M-p' for defaults) ")
3265 gnus-article-save-directory
3267 gnus-article-save-directory)))
3268 (car (push result file-name-history)))))))
3269 ;; Create the directory.
3270 (gnus-make-directory (file-name-directory file))
3271 ;; If we have read a directory, we append the default file name.
3272 (when (file-directory-p file)
3273 (setq file (expand-file-name (file-name-nondirectory
3275 (file-name-as-directory file))))
3276 ;; Possibly translate some characters.
3277 (nnheader-translate-file-chars file))))))
3278 (gnus-make-directory (file-name-directory result))
3279 (set variable result)))
3281 (defun gnus-article-archive-name (group)
3282 "Return the first instance of an \"Archive-name\" in the current buffer."
3283 (let ((case-fold-search t))
3284 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3285 (nnheader-concat gnus-article-save-directory
3286 (match-string 1)))))
3288 (defun gnus-article-nndoc-name (group)
3289 "If GROUP is an nndoc group, return the name of the parent group."
3290 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3291 (gnus-group-get-parameter group 'save-article-group)))
3293 (defun gnus-summary-save-in-rmail (&optional filename)
3294 "Append this article to Rmail file.
3295 Optional argument FILENAME specifies file name.
3296 Directory to save to is default to `gnus-article-save-directory'."
3297 (setq filename (gnus-read-save-file-name
3298 "Save %s in rmail file:" filename
3299 gnus-rmail-save-name gnus-newsgroup-name
3300 gnus-current-headers 'gnus-newsgroup-last-rmail))
3301 (gnus-eval-in-buffer-window gnus-save-article-buffer
3305 (gnus-output-to-rmail filename))))
3308 (defun gnus-summary-save-in-mail (&optional filename)
3309 "Append this article to Unix mail file.
3310 Optional argument FILENAME specifies file name.
3311 Directory to save to is default to `gnus-article-save-directory'."
3312 (setq filename (gnus-read-save-file-name
3313 "Save %s in Unix mail file:" filename
3314 gnus-mail-save-name gnus-newsgroup-name
3315 gnus-current-headers 'gnus-newsgroup-last-mail))
3316 (gnus-eval-in-buffer-window gnus-save-article-buffer
3320 (if (and (file-readable-p filename)
3321 (file-regular-p filename)
3322 (mail-file-babyl-p filename))
3323 (rmail-output-to-rmail-file filename t)
3324 (gnus-output-to-mail filename)))))
3327 (defun gnus-summary-save-in-file (&optional filename overwrite)
3328 "Append this article to file.
3329 Optional argument FILENAME specifies file name.
3330 Directory to save to is default to `gnus-article-save-directory'."
3331 (setq filename (gnus-read-save-file-name
3332 "Save %s in file:" filename
3333 gnus-file-save-name gnus-newsgroup-name
3334 gnus-current-headers 'gnus-newsgroup-last-file))
3335 (gnus-eval-in-buffer-window gnus-save-article-buffer
3339 (when (and overwrite
3340 (file-exists-p filename))
3341 (delete-file filename))
3342 (gnus-output-to-file filename))))
3345 (defun gnus-summary-write-to-file (&optional filename)
3346 "Write this article to a file, overwriting it if the file exists.
3347 Optional argument FILENAME specifies file name.
3348 The directory to save in defaults to `gnus-article-save-directory'."
3349 (gnus-summary-save-in-file nil t))
3351 (defun gnus-summary-save-body-in-file (&optional filename)
3352 "Append this article body to a file.
3353 Optional argument FILENAME specifies file name.
3354 The directory to save in defaults to `gnus-article-save-directory'."
3355 (setq filename (gnus-read-save-file-name
3356 "Save %s body in file:" filename
3357 gnus-file-save-name gnus-newsgroup-name
3358 gnus-current-headers 'gnus-newsgroup-last-file))
3359 (gnus-eval-in-buffer-window gnus-save-article-buffer
3363 (when (article-goto-body)
3364 (narrow-to-region (point) (point-max)))
3365 (gnus-output-to-file filename))))
3368 (defun gnus-summary-save-in-pipe (&optional command)
3369 "Pipe this article to subprocess."
3371 (cond ((and (eq command 'default)
3372 gnus-last-shell-command)
3373 gnus-last-shell-command)
3378 "Shell command on %s: "
3379 (if (and gnus-number-of-articles-to-be-saved
3380 (> gnus-number-of-articles-to-be-saved 1))
3381 (format "these %d articles"
3382 gnus-number-of-articles-to-be-saved)
3384 gnus-last-shell-command))))
3385 (when (string-equal command "")
3386 (if gnus-last-shell-command
3387 (setq command gnus-last-shell-command)
3388 (error "A command is required")))
3389 (gnus-eval-in-buffer-window gnus-article-buffer
3392 (shell-command-on-region (point-min) (point-max) command nil)))
3393 (setq gnus-last-shell-command command))
3395 (defun gnus-summary-pipe-to-muttprint (&optional command)
3396 "Pipe this article to muttprint."
3397 (setq command (read-string
3398 "Print using command: " gnus-summary-muttprint-program
3399 nil gnus-summary-muttprint-program))
3400 (gnus-summary-save-in-pipe command))
3402 ;;; Article file names when saving.
3404 (defun gnus-capitalize-newsgroup (newsgroup)
3405 "Capitalize NEWSGROUP name."
3406 (when (not (zerop (length newsgroup)))
3407 (concat (char-to-string (upcase (aref newsgroup 0)))
3408 (substring newsgroup 1))))
3410 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3411 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3412 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3413 Otherwise, it is like ~/News/news/group/num."
3416 (concat (if (gnus-use-long-file-name 'not-save)
3417 (gnus-capitalize-newsgroup newsgroup)
3418 (gnus-newsgroup-directory-form newsgroup))
3419 "/" (int-to-string (mail-header-number headers)))
3420 gnus-article-save-directory)))
3422 (string-equal (file-name-directory default)
3423 (file-name-directory last-file))
3424 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3426 (or last-file default))))
3428 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3429 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3430 If variable `gnus-use-long-file-name' is non-nil, it is
3431 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3434 (concat (if (gnus-use-long-file-name 'not-save)
3436 (gnus-newsgroup-directory-form newsgroup))
3437 "/" (int-to-string (mail-header-number headers)))
3438 gnus-article-save-directory)))
3440 (string-equal (file-name-directory default)
3441 (file-name-directory last-file))
3442 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3444 (or last-file default))))
3446 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3447 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3448 If variable `gnus-use-long-file-name' is non-nil, it is
3449 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3452 (if (gnus-use-long-file-name 'not-save)
3455 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3457 gnus-article-save-directory)))
3459 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3460 "Generate file name from sender."
3461 (let ((from (mail-header-from headers)))
3463 (if (and from (string-match "\\([^ <]+\\)@" from))
3464 (match-string 1 from)
3466 gnus-article-save-directory)))
3468 (defun article-verify-x-pgp-sig ()
3471 (if (gnus-buffer-live-p gnus-original-article-buffer)
3472 (let ((sig (with-current-buffer gnus-original-article-buffer
3473 (gnus-fetch-field "X-PGP-Sig")))
3477 (mml2015-clear-verify-function))
3479 (insert-buffer-substring gnus-original-article-buffer)
3480 (setq items (split-string sig))
3481 (message-narrow-to-head)
3482 (let ((inhibit-point-motion-hooks t)
3483 (case-fold-search t))
3484 ;; Don't verify multiple headers.
3485 (setq headers (mapconcat (lambda (header)
3487 (mail-fetch-field header) "\n"))
3488 (split-string (nth 1 items) ",") "")))
3489 (delete-region (point-min) (point-max))
3490 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3491 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3496 (if (looking-at "^-")
3499 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3500 (insert "Version: " (car items) "\n\n")
3501 (insert (mapconcat 'identity (cddr items) "\n"))
3502 (insert "\n-----END PGP SIGNATURE-----\n")
3503 (let ((mm-security-handle (list (format "multipart/signed"))))
3504 (mml2015-clean-buffer)
3505 (let ((coding-system-for-write (or gnus-newsgroup-charset
3507 (funcall (mml2015-clear-verify-function)))
3509 (or (mm-handle-multipart-ctl-parameter
3510 mm-security-handle 'gnus-details)
3511 (mm-handle-multipart-ctl-parameter
3512 mm-security-handle 'gnus-info)))))
3514 (let (buffer-read-only bface eface)
3516 (message-narrow-to-head)
3517 (goto-char (point-max))
3519 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3520 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3521 (message-remove-header "X-Gnus-PGP-Verify")
3522 (if (re-search-forward "^X-PGP-Sig:" nil t)
3524 (goto-char (point-max)))
3525 (narrow-to-region (point) (point))
3526 (insert "X-Gnus-PGP-Verify: " info "\n")
3527 (goto-char (point-min))
3530 (if (not (looking-at "^[ \t]"))
3534 (goto-char (point-min))
3535 (when (looking-at "\\([^:]+\\): *")
3536 (put-text-property (match-beginning 1) (1+ (match-end 1))
3538 (put-text-property (match-end 0) (point-max)
3539 'face eface)))))))))
3541 (defun article-verify-cancel-lock ()
3542 "Verify Cancel-Lock header."
3544 (if (gnus-buffer-live-p gnus-original-article-buffer)
3545 (canlock-verify gnus-original-article-buffer)))
3547 (defun article-monafy ()
3548 "Display body part with mona font."
3550 (unless (if (featurep 'xemacs)
3551 (find-face 'gnus-mona-face)
3552 (facep 'gnus-mona-face))
3553 (require 'navi2ch-mona)
3554 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3556 (let ((buffer-read-only nil))
3559 (gnus-make-overlay (point) (point-max))
3560 'face 'gnus-mona-face))))
3567 (setq afunc (car func)
3570 gfunc (intern (format "gnus-%s" func))))
3572 (when (fboundp afunc)
3573 `(lambda (&optional interactive &rest args)
3574 ,(documentation afunc t)
3575 (interactive (list t))
3577 (set-buffer gnus-article-buffer)
3579 (call-interactively ',afunc)
3580 (apply ',afunc args))))))))
3581 '(article-hide-headers
3582 article-verify-x-pgp-sig
3583 article-verify-cancel-lock
3585 article-hide-boring-headers
3586 article-treat-overstrike
3587 article-fill-long-lines
3588 article-capitalize-sentences
3590 article-remove-leading-whitespace
3591 article-display-x-face
3592 article-display-face
3593 article-de-quoted-unreadable
3594 article-de-base64-unreadable
3597 article-unsplit-urls
3598 article-hide-list-identifiers
3599 article-strip-banner
3602 article-hide-signature
3603 article-strip-headers-in-body
3604 article-remove-trailing-blank-lines
3605 article-strip-leading-blank-lines
3606 article-strip-multiple-blank-lines
3607 article-strip-leading-space
3608 article-strip-trailing-space
3609 article-strip-blank-lines
3610 article-strip-all-blank-lines
3612 article-date-english
3613 article-date-iso8601
3614 article-date-original
3616 article-decode-mime-words
3617 article-decode-charset
3618 article-decode-encoded-words
3622 article-treat-dumbquotes
3623 article-normalize-headers
3624 (article-show-all-headers . gnus-article-show-all-headers)
3625 ;; (article-show-all . gnus-article-show-all)
3629 ;;; Gnus article mode
3632 (put 'gnus-article-mode 'mode-class 'special)
3634 (gnus-define-keys gnus-article-mode-map
3635 " " gnus-article-goto-next-page
3636 "\177" gnus-article-goto-prev-page
3637 [delete] gnus-article-goto-prev-page
3638 [backspace] gnus-article-goto-prev-page
3639 "\C-c^" gnus-article-refer-article
3640 "h" gnus-article-show-summary
3641 "s" gnus-article-show-summary
3642 "\C-c\C-m" gnus-article-mail
3643 "?" gnus-article-describe-briefly
3644 "e" gnus-summary-edit-article
3645 "<" beginning-of-buffer
3647 "\C-c\C-i" gnus-info-find-node
3649 "R" gnus-article-reply-with-original
3650 "F" gnus-article-followup-with-original
3651 "\C-hk" gnus-article-describe-key
3652 "\C-hc" gnus-article-describe-key-briefly
3654 "\C-d" gnus-article-read-summary-keys
3655 "\M-*" gnus-article-read-summary-keys
3656 "\M-#" gnus-article-read-summary-keys
3657 "\M-^" gnus-article-read-summary-keys
3658 "\M-g" gnus-article-read-summary-keys)
3660 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3664 (push (char-to-string key) keys)
3666 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3667 (setq key (car elem))
3668 (when (and (> (length key) 0)
3669 (not (eq 'menu-bar (aref key 0)))
3670 (symbolp (lookup-key gnus-summary-mode-map key)))
3673 (unless (lookup-key gnus-article-mode-map key)
3674 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3676 (defun gnus-article-make-menu-bar ()
3677 (unless (boundp 'gnus-article-commands-menu)
3678 (gnus-summary-make-menu-bar))
3679 (gnus-turn-off-edit-menu 'article)
3680 (unless (boundp 'gnus-article-article-menu)
3682 gnus-article-article-menu gnus-article-mode-map ""
3684 ["Scroll forwards" gnus-article-goto-next-page t]
3685 ["Scroll backwards" gnus-article-goto-prev-page t]
3686 ["Show summary" gnus-article-show-summary t]
3687 ["Fetch Message-ID at point" gnus-article-refer-article t]
3688 ["Mail to address at point" gnus-article-mail t]
3689 ["Send a bug report" gnus-bug t]))
3692 gnus-article-treatment-menu gnus-article-mode-map ""
3693 ;; Fixme: this should use :active (and maybe :visible).
3695 ["Hide headers" gnus-article-hide-headers t]
3696 ["Hide signature" gnus-article-hide-signature t]
3697 ["Hide citation" gnus-article-hide-citation t]
3698 ["Treat overstrike" gnus-article-treat-overstrike t]
3699 ["Remove carriage return" gnus-article-remove-cr t]
3700 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3701 ["Treat html" gnus-article-wash-html t]
3702 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3703 ["Decode HZ" gnus-article-decode-HZ t]))
3705 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3707 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3709 (gnus-run-hooks 'gnus-article-menu-hook)))
3711 (defun gnus-article-mode ()
3712 "Major mode for displaying an article.
3714 All normal editing commands are switched off.
3716 The following commands are available in addition to all summary mode
3718 \\<gnus-article-mode-map>
3719 \\[gnus-article-next-page]\t Scroll the article one page forwards
3720 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3721 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3722 \\[gnus-article-show-summary]\t Display the summary buffer
3723 \\[gnus-article-mail]\t Send a reply to the address near point
3724 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3725 \\[gnus-info-find-node]\t Go to the Gnus info node"
3727 (gnus-simplify-mode-line)
3728 (setq mode-name "Article")
3729 (setq major-mode 'gnus-article-mode)
3730 (make-local-variable 'minor-mode-alist)
3731 (unless (assq 'gnus-show-mime minor-mode-alist)
3732 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3733 (use-local-map gnus-article-mode-map)
3734 (when (gnus-visual-p 'article-menu 'menu)
3735 (gnus-article-make-menu-bar)
3736 (when gnus-summary-tool-bar-map
3737 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3738 (gnus-update-format-specifications nil 'article-mode)
3739 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3740 (make-local-variable 'gnus-page-broken)
3741 (make-local-variable 'gnus-button-marker-list)
3742 (make-local-variable 'gnus-article-current-summary)
3743 (make-local-variable 'gnus-article-mime-handles)
3744 (make-local-variable 'gnus-article-decoded-p)
3745 (make-local-variable 'gnus-article-mime-handle-alist)
3746 (make-local-variable 'gnus-article-wash-types)
3747 (make-local-variable 'gnus-article-image-alist)
3748 (make-local-variable 'gnus-article-charset)
3749 (make-local-variable 'gnus-article-ignored-charsets)
3750 (gnus-set-default-directory)
3751 (buffer-disable-undo)
3752 (setq buffer-read-only t)
3753 (set-syntax-table gnus-article-mode-syntax-table)
3754 (gnus-run-hooks 'gnus-article-mode-hook))
3756 (defun gnus-article-setup-buffer ()
3757 "Initialize the article buffer."
3758 (let* ((name (if gnus-single-article-buffer "*Article*"
3759 (concat "*Article " gnus-newsgroup-name "*")))
3761 (progn (string-match "\\*Article" name)
3762 (concat " *Original Article"
3763 (substring name (match-end 0))))))
3764 (setq gnus-article-buffer name)
3765 (setq gnus-original-article-buffer original)
3766 (setq gnus-article-mime-handle-alist nil)
3767 ;; This might be a variable local to the summary buffer.
3768 (unless gnus-single-article-buffer
3770 (set-buffer gnus-summary-buffer)
3771 (setq gnus-article-buffer name)
3772 (setq gnus-original-article-buffer original)
3773 (gnus-set-global-variables)))
3774 (gnus-article-setup-highlight-words)
3775 ;; Init original article buffer.
3777 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3778 (set-buffer-multibyte t)
3779 (setq major-mode 'gnus-original-article-mode)
3780 (make-local-variable 'gnus-original-article))
3781 (if (get-buffer name)
3784 (when (and gnus-article-edit-mode
3787 (y-or-n-p "Article mode edit in progress; discard? ")))
3788 (error "Action aborted"))
3789 (set (make-local-variable 'gnus-article-edit-mode) nil)
3790 (buffer-disable-undo)
3791 (setq buffer-read-only t)
3792 ;; This list just keeps growing if we don't reset it.
3793 (setq gnus-button-marker-list nil)
3794 (unless (eq major-mode 'gnus-article-mode)
3795 (gnus-article-mode))
3798 (set-buffer (gnus-get-buffer-create name))
3800 (make-local-variable 'gnus-summary-buffer)
3801 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3802 (current-buffer)))))
3804 ;; Set article window start at LINE, where LINE is the number of lines
3805 ;; from the head of the article.
3806 (defun gnus-article-set-window-start (&optional line)
3808 (gnus-get-buffer-window gnus-article-buffer t)
3810 (set-buffer gnus-article-buffer)
3811 (goto-char (point-min))
3814 (gnus-message 6 "Moved to bookmark")
3815 (search-forward "\n\n" nil t)
3819 ;;; @@ article filters
3822 (defun gnus-article-display-mime-message ()
3823 "Article display method for MIME message."
3824 ;; called from `gnus-original-article-buffer'.
3825 (let (charset all-headers)
3826 (with-current-buffer gnus-summary-buffer
3827 (setq charset default-mime-charset
3828 all-headers gnus-have-all-headers))
3829 (make-local-variable 'default-mime-charset)
3830 (setq default-mime-charset charset)
3831 (with-current-buffer (get-buffer-create gnus-article-buffer)
3832 (make-local-variable 'default-mime-charset)
3833 (setq default-mime-charset charset))
3834 (mime-display-message mime-message-structure
3835 gnus-article-buffer nil gnus-article-mode-map)
3837 (gnus-article-hide-headers nil -1)))
3838 (run-hooks 'gnus-mime-article-prepare-hook))
3840 (defun gnus-article-display-traditional-message ()
3841 "Article display method for traditional message."
3842 (set-buffer gnus-article-buffer)
3843 (let (buffer-read-only)
3845 (insert-buffer-substring gnus-original-article-buffer)))
3847 (defun gnus-article-make-full-mail-header (&optional number charset)
3848 "Create a new mail header structure in a raw article buffer."
3849 (unless (and number charset)
3850 (save-current-buffer
3851 (set-buffer gnus-summary-buffer)
3853 (setq number (or (cdr gnus-article-current) 0)))
3855 (setq charset (or default-mime-charset 'x-ctext)))))
3856 (goto-char (point-min))
3857 (let ((header-end (if (search-forward "\n\n" nil t)
3859 (goto-char (point-max))))
3860 (chars (- (point-max) (point)))
3861 (lines (count-lines (point) (point-max)))
3862 (default-mime-charset charset)
3864 (narrow-to-region (point-min) header-end)
3865 (setq xref (std11-fetch-field "xref"))
3867 (make-full-mail-header
3869 (std11-fetch-field "subject")
3870 (std11-fetch-field "from")
3871 (std11-fetch-field "date")
3872 (std11-fetch-field "message-id")
3873 (std11-fetch-field "references")
3876 (when xref (concat "Xref: " xref)))
3879 (defun gnus-article-prepare (article &optional all-headers header)
3880 "Prepare ARTICLE in article mode buffer.
3881 ARTICLE should either be an article number or a Message-ID.
3882 If ARTICLE is an id, HEADER should be the article headers.
3883 If ALL-HEADERS is non-nil, no headers are hidden."
3885 ;; Make sure we start in a summary buffer.
3886 (unless (eq major-mode 'gnus-summary-mode)
3887 (set-buffer gnus-summary-buffer))
3888 (setq gnus-summary-buffer (current-buffer))
3889 (let* ((gnus-article (if header (mail-header-number header) article))
3890 (summary-buffer (current-buffer))
3891 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3892 (group gnus-newsgroup-name)
3895 (gnus-article-setup-buffer)
3896 (set-buffer gnus-article-buffer)
3897 ;; Deactivate active regions.
3898 (when (and (boundp 'transient-mark-mode)
3899 transient-mark-mode)
3900 (setq mark-active nil))
3901 (if (not (setq result (let ((buffer-read-only nil))
3902 (gnus-request-article-this-buffer
3904 ;; There is no such article.
3906 (when (and (numberp article)
3907 (not (memq article gnus-newsgroup-sparse)))
3908 (setq gnus-article-current
3909 (cons gnus-newsgroup-name article))
3910 (set-buffer gnus-summary-buffer)
3911 (setq gnus-current-article article)
3912 (if (and (memq article gnus-newsgroup-undownloaded)
3913 (not (gnus-online (gnus-find-method-for-group
3914 gnus-newsgroup-name))))
3916 (gnus-summary-set-agent-mark article)
3917 (message "Message marked for downloading"))
3918 (gnus-summary-mark-article article gnus-canceled-mark)
3919 (unless (memq article gnus-newsgroup-sparse)
3920 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3921 (if (or (eq result 'pseudo)
3922 (eq result 'nneething))
3925 (set-buffer summary-buffer)
3926 (push article gnus-newsgroup-history)
3927 (setq gnus-last-article gnus-current-article
3928 gnus-current-article 0
3929 gnus-current-headers nil
3930 gnus-article-current nil)
3931 (if (eq result 'nneething)
3932 (gnus-configure-windows 'summary)
3933 (gnus-configure-windows 'article))
3934 (gnus-set-global-variables))
3935 (let ((gnus-article-mime-handle-alist-1
3936 gnus-article-mime-handle-alist))
3937 (gnus-set-mode-line 'article)))
3938 ;; The result from the `request' was an actual article -
3939 ;; or at least some text that is now displayed in the
3941 (when (and (numberp article)
3942 (not (eq article gnus-current-article)))
3943 ;; Seems like a new article has been selected.
3944 ;; `gnus-current-article' must be an article number.
3946 (set-buffer summary-buffer)
3947 (push article gnus-newsgroup-history)
3948 (setq gnus-last-article gnus-current-article
3949 gnus-current-article article
3950 gnus-current-headers
3951 (gnus-summary-article-header gnus-current-article)
3952 gnus-article-current
3953 (cons gnus-newsgroup-name gnus-current-article))
3954 (unless (vectorp gnus-current-headers)
3955 (setq gnus-current-headers nil))
3956 (gnus-summary-goto-subject gnus-current-article)
3957 (when (gnus-summary-show-thread)
3958 ;; If the summary buffer really was folded, the
3959 ;; previous goto may not actually have gone to
3960 ;; the right article, but the thread root instead.
3962 (gnus-summary-goto-subject gnus-current-article))
3963 (gnus-run-hooks 'gnus-mark-article-hook)
3964 (gnus-set-mode-line 'summary)
3965 (when (gnus-visual-p 'article-highlight 'highlight)
3966 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3967 ;; Set the global newsgroup variables here.
3968 (gnus-set-global-variables)
3969 (setq gnus-have-all-headers
3970 (or all-headers gnus-show-all-headers))))
3972 (gnus-configure-windows 'article))
3973 (when (or (numberp article)
3975 (gnus-article-prepare-display)
3977 (goto-char (point-min))
3978 (setq gnus-page-broken
3979 (when gnus-break-pages
3980 (gnus-narrow-to-page)
3982 (let ((gnus-article-mime-handle-alist-1
3983 gnus-article-mime-handle-alist))
3984 (gnus-set-mode-line 'article))
3988 (set-window-point (get-buffer-window (current-buffer)) (point))
3989 (gnus-configure-windows 'article)
3992 (defun gnus-article-prepare-mime-display (&optional number)
3993 (goto-char (point-min))
3994 (when (re-search-forward "^[^\t ]+:" nil t)
3995 (goto-char (match-beginning 0)))
3996 (let ((entity (if (eq 1 (point-min))
3997 (get-text-property 1 'mime-view-entity)
3998 (get-text-property (point) 'mime-view-entity)))
3999 last-entity child-entity next type)
4000 (setq child-entity (mime-entity-children entity))
4002 (setq last-entity (nth (1- (length child-entity))
4004 (setq last-entity entity))
4006 (narrow-to-region (point)
4007 (if (search-forward "\n\n" nil t)
4010 (gnus-treat-article 'head)
4011 (put-text-property (point-min) (point-max) 'article-treated-header t)
4012 (goto-char (point-max)))
4013 (while (and (not (eobp)) entity)
4014 (setq next (set-marker
4016 (next-single-property-change (point) 'mime-view-entity
4018 (let ((types (mime-entity-content-type entity)))
4019 (while (eq 'multipart (mime-content-type-primary-type types))
4020 (setq entity (car (mime-entity-children entity))
4021 types (mime-entity-content-type entity)))
4023 (setq type (format "%s/%s"
4024 (mime-content-type-primary-type types)
4025 (mime-content-type-subtype types)))))
4026 (if (string-equal type "message/rfc822")
4029 (let ((children (mime-entity-children entity))
4032 (setq last-children (nth (1- (length children)) children))
4035 (not (eq last-children
4036 (get-text-property next 'mime-view-entity)))
4038 (next-single-property-change next
4040 nil (point-max)))))))
4041 (setq next (next-single-property-change next 'mime-view-entity
4044 (narrow-to-region (point) next)
4045 (gnus-article-prepare-mime-display)
4046 (goto-char (point-max)))
4047 (setq entity (get-text-property (point) 'mime-view-entity)))
4049 (narrow-to-region (point) next)
4050 ;; Kludge. We have to count true number, but for now,
4051 ;; part number is here only to achieve `last'.
4052 (gnus-treat-article nil 1
4053 (if (eq entity last-entity)
4056 (goto-char (point-max)))
4057 (setq entity (get-text-property next 'mime-view-entity))))))
4060 (defun gnus-article-prepare-display ()
4061 "Make the current buffer look like a nice article."
4062 (let ((gnus-article-buffer (current-buffer))
4064 (unless (eq major-mode 'gnus-article-mode)
4065 (gnus-article-mode))
4066 (setq buffer-read-only nil
4067 gnus-button-marker-list nil
4068 gnus-article-wash-types nil
4069 gnus-article-image-alist nil)
4072 (static-if (featurep 'xemacs)
4073 (map-extents (lambda (extent maparg) (delete-extent extent)))
4074 (let ((lists (overlay-lists)))
4075 (dolist (overlay (nconc (car lists) (cdr lists)))
4076 (delete-overlay overlay)))))
4077 (gnus-run-hooks 'gnus-tmp-internal-hook))
4078 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4081 (inhibit-read-only t))
4082 (set-buffer gnus-original-article-buffer)
4084 (setq mime-message-structure gnus-current-headers)
4085 (mime-buffer-entity-set-buffer-internal mime-message-structure
4086 gnus-original-article-buffer)
4087 (mime-entity-set-representation-type-internal mime-message-structure
4088 'mime-buffer-entity)
4089 (luna-send mime-message-structure 'initialize-instance
4090 mime-message-structure)
4092 (let (mime-display-header-hook mime-display-text/plain-hook)
4093 (funcall gnus-article-display-method-for-mime))
4094 (funcall gnus-article-display-method-for-traditional))
4095 ;; Call the treatment functions.
4099 (gnus-article-prepare-mime-display)
4100 (narrow-to-region (goto-char (point-min))
4101 (if (search-forward "\n\n" nil t)
4104 (gnus-treat-article 'head)
4105 (put-text-property (point-min) (point-max) 'article-treated-header t)
4106 (goto-char (point-max))
4108 (narrow-to-region (point) (point-max))
4109 (gnus-treat-article nil))
4110 (put-text-property (point-min) (point-max) 'read-only nil)))
4111 (gnus-run-hooks 'gnus-article-prepare-hook))
4113 (defun gnus-article-decode-article-as-default-mime-charset ()
4114 "Decode an article as `default-mime-charset'. It won't work if the
4115 value of the variable `gnus-show-mime' is non-nil."
4116 (unless (or gnus-show-mime
4117 (member gnus-newsgroup-name '("nndraft:delayed"
4119 (set (make-local-variable 'default-mime-charset)
4120 (with-current-buffer gnus-summary-buffer
4121 default-mime-charset))
4122 (decode-mime-charset-region (point-min) (point-max)
4123 default-mime-charset)))
4126 ;;; Gnus MIME viewing functions
4129 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4130 "Format of the MIME buttons.
4132 Valid specifiers include:
4134 %T MIME type, along with additional info
4135 %n The `name' parameter
4136 %d The description, if any
4137 %l The length of the encoded part
4138 %p The part identifier number
4139 %e Dots if the part isn't displayed
4141 General format specifiers can also be used. See Info node
4142 `(gnus)Formatting Variables'.")
4144 (defvar gnus-mime-button-line-format-alist
4145 '((?t gnus-tmp-type ?s)
4146 (?T gnus-tmp-type-long ?s)
4147 (?n gnus-tmp-name ?s)
4148 (?d gnus-tmp-description ?s)
4150 (?l gnus-tmp-length ?d)
4151 (?e gnus-tmp-dots ?s)))
4153 (defvar gnus-mime-button-commands
4154 '((gnus-article-press-button "\r" "Toggle Display")
4155 (gnus-mime-view-part "v" "View Interactively...")
4156 (gnus-mime-view-part-as-type "t" "View As Type...")
4157 (gnus-mime-view-part-as-charset "C" "View As charset...")
4158 (gnus-mime-save-part "o" "Save...")
4159 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4160 (gnus-mime-delete-part "d" "Delete part")
4161 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4162 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4163 (gnus-mime-view-part-internally "E" "View Internally")
4164 (gnus-mime-view-part-externally "e" "View Externally")
4165 (gnus-mime-print-part "p" "Print")
4166 (gnus-mime-pipe-part "|" "Pipe To Command...")
4167 (gnus-mime-action-on-part "." "Take action on the part...")))
4169 (defun gnus-article-mime-part-status ()
4170 (with-current-buffer gnus-article-buffer
4171 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4174 (setq children (mime-entity-children entity))
4175 (setq children (length children)))
4178 (format " (%d parts)" children))
4181 (defvar gnus-mime-button-map
4182 (let ((map (make-sparse-keymap)))
4183 (unless (>= (string-to-number emacs-version) 21)
4184 ;; XEmacs doesn't care.
4185 (set-keymap-parent map gnus-article-mode-map))
4186 (define-key map gnus-mouse-2 'gnus-article-push-button)
4187 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4188 (dolist (c gnus-mime-button-commands)
4189 (define-key map (cadr c) (car c)))
4192 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4194 ,@(mapcar (lambda (c)
4195 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
4198 (define-compiler-macro popup-menu (&whole form
4199 menu &optional position prefix)
4200 (if (and (fboundp 'popup-menu)
4201 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4203 ;; Gnus is probably running under Emacs 20.
4204 `(let* ((menu (cdr ,menu))
4205 (response (x-popup-menu
4207 (cons "" (mapcar (lambda (c)
4208 (cons (caddr c) (car c)))
4211 (call-interactively (nth 3 (assq response menu))))))))
4213 (defun gnus-mime-button-menu (event prefix)
4214 "Construct a context-sensitive menu of MIME commands."
4215 (interactive "e\nP")
4216 (save-window-excursion
4217 (let ((pos (event-start event)))
4218 (select-window (posn-window pos))
4219 (goto-char (posn-point pos))
4220 (gnus-article-check-buffer)
4221 (popup-menu gnus-mime-button-menu nil prefix))))
4223 (defun gnus-mime-view-all-parts (&optional handles)
4224 "View all the MIME parts."
4226 (save-current-buffer
4227 (set-buffer gnus-article-buffer)
4228 (let ((handles (or handles gnus-article-mime-handles))
4229 (mail-parse-charset gnus-newsgroup-charset)
4230 (mail-parse-ignored-charsets
4231 (with-current-buffer gnus-summary-buffer
4232 gnus-newsgroup-ignored-charsets)))
4234 (mm-remove-parts handles)
4235 (goto-char (point-min))
4236 (or (search-forward "\n\n") (goto-char (point-max)))
4237 (let (buffer-read-only)
4238 (delete-region (point) (point-max))
4239 (mm-display-parts handles))))))
4241 (defun gnus-mime-save-part-and-strip ()
4242 "Save the MIME part under point then replace it with an external body."
4244 (gnus-article-check-buffer)
4245 (let* ((data (get-text-property (point) 'gnus-data))
4247 (handles gnus-article-mime-handles))
4248 (if (mm-multiple-handles gnus-article-mime-handles)
4249 (error "This function is not implemented"))
4250 (setq file (and data (mm-save-part data)))
4252 (with-current-buffer (mm-handle-buffer data)
4254 (insert "Content-Type: " (mm-handle-media-type data))
4255 (mml-insert-parameter-string (cdr (mm-handle-type data))
4258 (insert "Content-ID: " (message-make-message-id) "\n")
4259 (insert "Content-Transfer-Encoding: binary\n")
4262 (cdr (mm-make-handle nil
4263 `("message/external-body"
4264 (access-type . "LOCAL-FILE")
4266 (set-buffer gnus-summary-buffer)
4267 (gnus-article-edit-article
4270 (let ((mail-parse-charset (or gnus-article-charset
4271 ',gnus-newsgroup-charset))
4272 (mail-parse-ignored-charsets
4273 (or gnus-article-ignored-charsets
4274 ',gnus-newsgroup-ignored-charsets))
4275 (mbl mml-buffer-list))
4276 (setq mml-buffer-list nil)
4277 (insert-buffer gnus-original-article-buffer)
4278 (mime-to-mml ',handles)
4279 (setq gnus-article-mime-handles nil)
4280 (let ((mbl1 mml-buffer-list))
4281 (setq mml-buffer-list mbl)
4282 (set (make-local-variable 'mml-buffer-list) mbl1))
4283 ;; LOCAL argument of add-hook differs between GNU Emacs
4284 ;; and XEmacs. make-local-hook makes sure they are local.
4285 (make-local-hook 'kill-buffer-hook)
4286 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4287 `(lambda (no-highlight)
4288 (let ((mail-parse-charset (or gnus-article-charset
4289 ',gnus-newsgroup-charset))
4290 (message-options message-options)
4291 (message-options-set-recipient)
4292 (mail-parse-ignored-charsets
4293 (or gnus-article-ignored-charsets
4294 ',gnus-newsgroup-ignored-charsets)))
4296 (mml-destroy-buffers)
4297 (remove-hook 'kill-buffer-hook
4298 'mml-destroy-buffers t)
4299 (kill-local-variable 'mml-buffer-list))
4300 (gnus-summary-edit-article-done
4301 ,(or (mail-header-references gnus-current-headers) "")
4302 ,(gnus-group-read-only-p)
4303 ,gnus-summary-buffer no-highlight))))))
4305 (defun gnus-mime-delete-part ()
4306 "Delete the MIME part under point.
4307 Replace it with some information about the removed part."
4309 (gnus-article-check-buffer)
4310 (let* ((data (get-text-property (point) 'gnus-data))
4311 (handles gnus-article-mime-handles)
4315 (mail-decode-encoded-word-string (or (mm-handle-description data)
4318 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4320 (type (mm-handle-media-type data)))
4321 (if (mm-multiple-handles gnus-article-mime-handles)
4322 (error "This function is not implemented"))
4323 (with-current-buffer (mm-handle-buffer data)
4324 (let ((bsize (format "%s" (buffer-size))))
4328 "<#part type=text/plain nofile=yes disposition=attachment"
4329 " description=\"Deleted attachment (" bsize " Byte)\">"
4331 "| The following attachment has been deleted:\n"
4333 "| Type: " type "\n"
4334 "| Filename: " filename "\n"
4335 "| Size (encoded): " bsize " Byte\n"
4336 "| Description: " description "\n"
4340 (cdr (mm-make-handle nil `("text/plain"))))))
4341 (set-buffer gnus-summary-buffer)
4342 ;; FIXME: maybe some of the following code (borrowed from
4343 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4344 (gnus-article-edit-article
4347 (let ((mail-parse-charset (or gnus-article-charset
4348 ',gnus-newsgroup-charset))
4349 (mail-parse-ignored-charsets
4350 (or gnus-article-ignored-charsets
4351 ',gnus-newsgroup-ignored-charsets))
4352 (mbl mml-buffer-list))
4353 (setq mml-buffer-list nil)
4354 (insert-buffer gnus-original-article-buffer)
4355 (mime-to-mml ',handles)
4356 (setq gnus-article-mime-handles nil)
4357 (let ((mbl1 mml-buffer-list))
4358 (setq mml-buffer-list mbl)
4359 (set (make-local-variable 'mml-buffer-list) mbl1))
4360 ;; LOCAL argument of add-hook differs between GNU Emacs
4361 ;; and XEmacs. make-local-hook makes sure they are local.
4362 (make-local-hook 'kill-buffer-hook)
4363 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4364 `(lambda (no-highlight)
4365 (let ((mail-parse-charset (or gnus-article-charset
4366 ',gnus-newsgroup-charset))
4367 (message-options message-options)
4368 (message-options-set-recipient)
4369 (mail-parse-ignored-charsets
4370 (or gnus-article-ignored-charsets
4371 ',gnus-newsgroup-ignored-charsets)))
4373 (mml-destroy-buffers)
4374 (remove-hook 'kill-buffer-hook
4375 'mml-destroy-buffers t)
4376 (kill-local-variable 'mml-buffer-list))
4377 (gnus-summary-edit-article-done
4378 ,(or (mail-header-references gnus-current-headers) "")
4379 ,(gnus-group-read-only-p)
4380 ,gnus-summary-buffer no-highlight))))
4381 ;; Not in `gnus-mime-save-part-and-strip':
4382 (gnus-article-edit-done)
4383 (gnus-summary-expand-window)
4384 (gnus-summary-show-article))
4386 (defun gnus-mime-save-part ()
4387 "Save the MIME part under point."
4389 (gnus-article-check-buffer)
4390 (let ((data (get-text-property (point) 'gnus-data)))
4392 (mm-save-part data))))
4394 (defun gnus-mime-pipe-part ()
4395 "Pipe the MIME part under point to a process."
4397 (gnus-article-check-buffer)
4398 (let ((data (get-text-property (point) 'gnus-data)))
4400 (mm-pipe-part data))))
4402 (defun gnus-mime-view-part ()
4403 "Interactively choose a viewing method for the MIME part under point."
4405 (gnus-article-check-buffer)
4406 (let ((data (get-text-property (point) 'gnus-data)))
4408 (setq gnus-article-mime-handles
4410 gnus-article-mime-handles (setq data (copy-sequence data))))
4411 (mm-interactively-view-part data))))
4413 (defun gnus-mime-view-part-as-type-internal ()
4414 (gnus-article-check-buffer)
4415 (let* ((name (mail-content-type-get
4416 (mm-handle-type (get-text-property (point) 'gnus-data))
4418 (def-type (and name (mm-default-file-encoding name))))
4419 (and def-type (cons def-type 0))))
4421 (defun gnus-mime-view-part-as-type (&optional mime-type)
4422 "Choose a MIME media type, and view the part as such."
4425 (setq mime-type (completing-read
4426 "View as MIME type: "
4427 (mapcar #'list (mailcap-mime-types))
4429 (gnus-mime-view-part-as-type-internal))))
4430 (gnus-article-check-buffer)
4431 (let ((handle (get-text-property (point) 'gnus-data)))
4434 (mm-make-handle (mm-handle-buffer handle)
4435 (cons mime-type (cdr (mm-handle-type handle)))
4436 (mm-handle-encoding handle)
4437 (mm-handle-undisplayer handle)
4438 (mm-handle-disposition handle)
4439 (mm-handle-description handle)
4441 (mm-handle-id handle)))
4442 (setq gnus-article-mime-handles
4443 (mm-merge-handles gnus-article-mime-handles handle))
4444 (gnus-mm-display-part handle))))
4447 (require 'jka-compr))
4449 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4450 ;; emacs can do that itself.
4452 (defun gnus-mime-jka-compr-maybe-uncompress ()
4453 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4454 The uncompress method used is derived from `buffer-file-name'."
4455 (when (and (fboundp 'jka-compr-installed-p)
4456 (jka-compr-installed-p))
4457 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4459 (let ((basename (file-name-nondirectory buffer-file-name))
4460 (args (jka-compr-info-uncompress-args info))
4461 (prog (jka-compr-info-uncompress-program info))
4462 (message (jka-compr-info-uncompress-message info))
4463 (err-file (jka-compr-make-temp-name)))
4465 (message "%s %s..." message basename))
4467 (unless (memq (apply 'call-process-region
4468 (point-min) (point-max)
4470 t (list t err-file) nil
4472 jka-compr-acceptable-retval-list)
4473 (jka-compr-error prog args basename message err-file))
4474 (jka-compr-delete-temp-file err-file)))))))
4476 (defun gnus-mime-copy-part (&optional handle)
4477 "Put the MIME part under point into a new buffer.
4478 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4481 (gnus-article-check-buffer)
4482 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4483 (contents (and handle (mm-get-part handle)))
4485 (file-name-nondirectory
4487 (mail-content-type-get (mm-handle-type handle) 'name)
4488 (mail-content-type-get (mm-handle-disposition handle)
4491 (buffer (and base (generate-new-buffer base))))
4493 (switch-to-buffer buffer)
4495 ;; We do it this way to make `normal-mode' set the appropriate mode.
4498 (setq buffer-file-name (expand-file-name base))
4499 (gnus-mime-jka-compr-maybe-uncompress)
4501 (setq buffer-file-name nil))
4502 (goto-char (point-min)))))
4504 (defun gnus-mime-print-part (&optional handle filename)
4505 "Print the MIME part under point."
4506 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4507 (gnus-article-check-buffer)
4508 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4509 (contents (and handle (mm-get-part handle)))
4510 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4511 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4516 (mm-save-part-to-file handle file)
4517 (call-process shell-file-name nil
4518 (generate-new-buffer " *mm*")
4520 shell-command-switch
4522 printer file (mm-handle-type handle))))
4526 (gnus-print-buffer))
4527 (ps-despool filename)))))
4529 (defun gnus-mime-inline-part (&optional handle arg)
4530 "Insert the MIME part under point into the current buffer."
4531 (interactive (list nil current-prefix-arg))
4532 (gnus-article-check-buffer)
4533 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4538 (if (and (not arg) (mm-handle-undisplayer handle))
4539 (mm-remove-part handle)
4540 (setq contents (mm-get-part handle))
4543 (setq charset (or (mail-content-type-get
4544 (mm-handle-type handle) 'charset)
4545 gnus-newsgroup-charset)))
4547 (if (mm-handle-undisplayer handle)
4548 (mm-remove-part handle))
4551 gnus-summary-show-article-charset-alist))
4552 (mm-read-coding-system "Charset: ")))))
4554 (mm-insert-inline handle
4556 (setq charset (mm-charset-to-coding-system
4558 (not (eq charset 'ascii)))
4559 (mm-decode-coding-string contents charset)
4563 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4564 "Insert the MIME part under point into the current buffer using the
4566 (interactive (list nil current-prefix-arg))
4567 (gnus-article-check-buffer)
4568 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4573 (if (mm-handle-undisplayer handle)
4574 (mm-remove-part handle))
4575 (let ((gnus-newsgroup-charset
4577 gnus-summary-show-article-charset-alist))
4578 (mm-read-coding-system "Charset: ")))
4579 (gnus-newsgroup-ignored-charsets 'gnus-all))
4580 (gnus-article-press-button)))))
4582 (defun gnus-mime-view-part-externally (&optional handle)
4583 "View the MIME part under point with an external viewer."
4585 (gnus-article-check-buffer)
4586 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4587 (mm-user-display-methods nil)
4588 (mm-inlined-types nil)
4589 (mail-parse-charset gnus-newsgroup-charset)
4590 (mail-parse-ignored-charsets
4591 (save-excursion (set-buffer gnus-summary-buffer)
4592 gnus-newsgroup-ignored-charsets)))
4594 (if (mm-handle-undisplayer handle)
4595 (mm-remove-part handle)
4596 (mm-display-part handle)))))
4598 (defun gnus-mime-view-part-internally (&optional handle)
4599 "View the MIME part under point with an internal viewer.
4600 If no internal viewer is available, use an external viewer."
4602 (gnus-article-check-buffer)
4603 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4604 (mm-inlined-types '(".*"))
4605 (mm-inline-large-images t)
4606 (mail-parse-charset gnus-newsgroup-charset)
4607 (mail-parse-ignored-charsets
4608 (save-excursion (set-buffer gnus-summary-buffer)
4609 gnus-newsgroup-ignored-charsets))
4612 (if (mm-handle-undisplayer handle)
4613 (mm-remove-part handle)
4614 (mm-display-part handle)))))
4616 (defun gnus-mime-action-on-part (&optional action)
4617 "Do something with the MIME attachment at \(point\)."
4619 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4620 (gnus-article-check-buffer)
4621 (let ((action-pair (assoc action gnus-mime-action-alist)))
4623 (funcall (cdr action-pair)))))
4625 (defun gnus-article-part-wrapper (n function)
4626 (save-current-buffer
4627 (set-buffer gnus-article-buffer)
4628 (when (> n (length gnus-article-mime-handle-alist))
4629 (error "No such part"))
4630 (gnus-article-goto-part n)
4631 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4632 (funcall function handle))))
4634 (defun gnus-article-pipe-part (n)
4635 "Pipe MIME part N, which is the numerical prefix."
4637 (gnus-article-part-wrapper n 'mm-pipe-part))
4639 (defun gnus-article-save-part (n)
4640 "Save MIME part N, which is the numerical prefix."
4642 (gnus-article-part-wrapper n 'mm-save-part))
4644 (defun gnus-article-interactively-view-part (n)
4645 "View MIME part N interactively, which is the numerical prefix."
4647 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4649 (defun gnus-article-copy-part (n)
4650 "Copy MIME part N, which is the numerical prefix."
4652 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4654 (defun gnus-article-view-part-as-charset (n)
4655 "Copy MIME part N, which is the numerical prefix."
4657 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4659 (defun gnus-article-view-part-externally (n)
4660 "View MIME part N externally, which is the numerical prefix."
4662 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4664 (defun gnus-article-inline-part (n)
4665 "Inline MIME part N, which is the numerical prefix."
4667 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4669 (defun gnus-article-mime-match-handle-first (condition)
4671 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4672 (while (setq ihandle (pop alist))
4674 ((functionp condition)
4675 (funcall condition (cdr ihandle)))
4676 ((eq condition 'undisplayed)
4677 (not (or (mm-handle-undisplayer (cdr ihandle))
4678 (equal (mm-handle-media-type (cdr ihandle))
4679 "multipart/alternative"))))
4680 ((eq condition 'undisplayed-alternative)
4681 (not (mm-handle-undisplayer (cdr ihandle))))
4683 (gnus-article-goto-part (car ihandle))
4684 (or (not n) (< (car ihandle) n)))
4685 (setq n (car ihandle))))
4689 (defun gnus-article-view-part (&optional n)
4690 "View MIME part N, which is the numerical prefix."
4692 (save-current-buffer
4693 (set-buffer gnus-article-buffer)
4694 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4695 gnus-article-mime-match-handle-function)))
4696 (when (> n (length gnus-article-mime-handle-alist))
4697 (error "No such part"))
4698 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4699 (when (gnus-article-goto-part n)
4700 (if (equal (car handle) "multipart/alternative")
4701 (gnus-article-press-button)
4702 (when (eq (gnus-mm-display-part handle) 'internal)
4703 (gnus-set-window-start)))))))
4705 (defsubst gnus-article-mime-total-parts ()
4706 (if (bufferp (car gnus-article-mime-handles))
4708 (1- (length gnus-article-mime-handles))))
4710 (defun gnus-mm-display-part (handle)
4711 "Display HANDLE and fix MIME button."
4712 (let ((id (get-text-property (point) 'gnus-part))
4717 (let ((window (selected-window))
4718 (mail-parse-charset gnus-newsgroup-charset)
4719 (mail-parse-ignored-charsets
4720 (if (gnus-buffer-live-p gnus-summary-buffer)
4722 (set-buffer gnus-summary-buffer)
4723 gnus-newsgroup-ignored-charsets)
4727 (let ((win (gnus-get-buffer-window (current-buffer) t))
4730 (select-window win))
4733 (if (mm-handle-displayed-p handle)
4734 ;; This will remove the part.
4735 (mm-display-part handle)
4737 (narrow-to-region (point)
4738 (if (eobp) (point) (1+ (point))))
4739 (mm-display-part handle)
4740 ;; We narrow to the part itself and
4741 ;; then call the treatment functions.
4742 (goto-char (point-min))
4744 (narrow-to-region (point) (point-max))
4747 (gnus-article-mime-total-parts)
4748 (mm-handle-media-type handle)))))
4749 (if (window-live-p window)
4750 (select-window window)))))
4753 (gnus-insert-mime-button
4754 handle id (list (mm-handle-displayed-p handle)))
4755 (goto-char point))))
4757 (defun gnus-article-goto-part (n)
4758 "Go to MIME part N."
4759 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4761 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4762 (let ((gnus-tmp-name
4763 (or (mail-content-type-get (mm-handle-type handle) 'name)
4764 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4765 (mail-content-type-get (mm-handle-type handle) 'url)
4767 (gnus-tmp-type (mm-handle-media-type handle))
4768 (gnus-tmp-description
4769 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4772 (if (if displayed (car displayed)
4773 (mm-handle-displayed-p handle))
4775 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4777 gnus-tmp-type-long b e)
4778 (when (string-match ".*/" gnus-tmp-name)
4779 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4780 (setq gnus-tmp-type-long (concat gnus-tmp-type
4781 (and (not (equal gnus-tmp-name ""))
4782 (concat "; " gnus-tmp-name))))
4783 (unless (equal gnus-tmp-description "")
4784 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4789 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4790 `(,@(gnus-local-map-property gnus-mime-button-map)
4791 gnus-callback gnus-mm-display-part
4792 gnus-part ,gnus-tmp-id
4793 article-type annotation
4796 ;; Exclude a newline.
4799 (widget-convert-button
4802 :action 'gnus-widget-press-button
4803 :button-keymap gnus-mime-button-map
4805 (lambda (widget/window &optional overlay pos)
4806 ;; Needed to properly clear the message due to a bug in
4807 ;; wid-edit (XEmacs only).
4808 (if (boundp 'help-echo-owns-message)
4809 (setq help-echo-owns-message t))
4811 "%S: %s the MIME part; %S: more options"
4812 (aref gnus-mouse-2 0)
4813 ;; XEmacs will get a single widget arg; Emacs 21 will get
4814 ;; window, overlay, position.
4815 (if (mm-handle-displayed-p
4817 (with-current-buffer (gnus-overlay-buffer overlay)
4818 (widget-get (widget-at (gnus-overlay-start overlay))
4820 (widget-get widget/window :mime-handle)))
4822 (aref gnus-down-mouse-3 0))))))
4824 (defun gnus-widget-press-button (elems el)
4825 (goto-char (widget-get elems :from))
4826 (gnus-article-press-button))
4828 (defvar gnus-displaying-mime nil)
4830 (defun gnus-display-mime (&optional ihandles)
4831 "Display the MIME parts."
4833 (save-selected-window
4834 (let ((window (get-buffer-window gnus-article-buffer))
4837 (select-window window)
4838 ;; We have to do this since selecting the window
4839 ;; may change the point. So we set the window point.
4840 (set-window-point window point)))
4841 (let* ((handles (or ihandles
4842 (mm-dissect-buffer nil gnus-article-loose-mime)
4843 (and gnus-article-emulate-mime
4845 buffer-read-only handle name type b e display)
4846 (when (and (not ihandles)
4847 (not gnus-displaying-mime))
4848 ;; Top-level call; we clean up.
4849 (when gnus-article-mime-handles
4850 (mm-destroy-parts gnus-article-mime-handles)
4851 (setq gnus-article-mime-handle-alist nil));; A trick.
4852 (setq gnus-article-mime-handles handles)
4853 ;; We allow users to glean info from the handles.
4854 (when gnus-article-mime-part-function
4855 (gnus-mime-part-function handles)))
4857 (or (not (stringp (car handles)))
4860 (when (and (not ihandles)
4861 (not gnus-displaying-mime))
4862 ;; Clean up for mime parts.
4864 (delete-region (point) (point-max)))
4865 (let ((gnus-displaying-mime t))
4866 (gnus-mime-display-part handles)))
4869 (narrow-to-region (point) (point-max))
4870 (gnus-treat-article nil 1 1)
4873 ;; Highlight the headers.
4877 (narrow-to-region (point-min) (point))
4878 (gnus-treat-article 'head))))))))
4880 (defvar gnus-mime-display-multipart-as-mixed nil)
4881 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4882 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4884 (defun gnus-mime-display-part (handle)
4887 ((not (stringp (car handle)))
4888 (gnus-mime-display-single handle))
4889 ;; User-defined multipart
4890 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4891 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4893 ;; multipart/alternative
4894 ((and (equal (car handle) "multipart/alternative")
4895 (not (or gnus-mime-display-multipart-as-mixed
4896 gnus-mime-display-multipart-alternative-as-mixed)))
4897 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4898 (push (cons id handle) gnus-article-mime-handle-alist)
4899 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4900 ;; multipart/related
4901 ((and (equal (car handle) "multipart/related")
4902 (not (or gnus-mime-display-multipart-as-mixed
4903 gnus-mime-display-multipart-related-as-mixed)))
4904 ;;;!!!We should find the start part, but we just default
4905 ;;;!!!to the first part.
4906 ;;(gnus-mime-display-part (cadr handle))
4907 ;;;!!! Most multipart/related is an HTML message plus images.
4908 ;;;!!! Unfortunately we are unable to let W3 display those
4909 ;;;!!! included images, so we just display it as a mixed multipart.
4910 ;;(gnus-mime-display-mixed (cdr handle))
4911 ;;;!!! No, w3 can display everything just fine.
4912 (gnus-mime-display-part (cadr handle)))
4913 ((equal (car handle) "multipart/signed")
4914 (gnus-add-wash-type 'signed)
4915 (gnus-mime-display-security handle))
4916 ((equal (car handle) "multipart/encrypted")
4917 (gnus-add-wash-type 'encrypted)
4918 (gnus-mime-display-security handle))
4919 ;; Other multiparts are handled like multipart/mixed.
4921 (gnus-mime-display-mixed (cdr handle)))))
4923 (defun gnus-mime-part-function (handles)
4924 (if (stringp (car handles))
4925 (mapcar 'gnus-mime-part-function (cdr handles))
4926 (funcall gnus-article-mime-part-function handles)))
4928 (defun gnus-mime-display-mixed (handles)
4929 (mapcar 'gnus-mime-display-part handles))
4931 (defun gnus-mime-display-single (handle)
4932 (let ((type (mm-handle-media-type handle))
4933 (ignored gnus-ignored-mime-types)
4940 (when (string-match (pop ignored) type)
4941 (throw 'ignored nil)))
4942 (if (and (setq not-attachment
4943 (and (not (mm-inline-override-p handle))
4944 (or (not (mm-handle-disposition handle))
4945 (equal (car (mm-handle-disposition handle))
4947 (mm-attachment-override-p handle))))
4948 (mm-automatic-display-p handle)
4950 (mm-inlinable-p handle)
4951 (mm-inlined-p handle))
4952 (mm-automatic-external-display-p type)))
4954 (when (equal (mm-handle-media-supertype handle) "text")
4956 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4958 (push (cons id handle) gnus-article-mime-handle-alist)
4959 (when (or (not display)
4960 (not (gnus-unbuttonized-mime-type-p type)))
4961 ;(gnus-article-insert-newline)
4962 (gnus-insert-mime-button
4963 handle id (list (or display (and not-attachment text))))
4964 (gnus-article-insert-newline)
4965 ;(gnus-article-insert-newline)
4966 ;; Remember modify the number of forward lines.
4974 (let ((mail-parse-charset gnus-newsgroup-charset)
4975 (mail-parse-ignored-charsets
4976 (save-excursion (condition-case ()
4977 (set-buffer gnus-summary-buffer)
4979 gnus-newsgroup-ignored-charsets)))
4980 (mm-display-part handle t))
4981 (goto-char (point-max)))
4982 ((and text not-attachment)
4986 (gnus-article-insert-newline)
4987 (mm-insert-inline handle (mm-get-part handle))
4988 (goto-char (point-max))))
4992 (narrow-to-region beg (point))
4995 (gnus-article-mime-total-parts)
4996 (mm-handle-media-type handle)))))))))
4998 (defun gnus-unbuttonized-mime-type-p (type)
4999 "Say whether TYPE is to be unbuttonized."
5000 (unless gnus-inhibit-mime-unbuttonizing
5002 (let ((types gnus-unbuttonized-mime-types))
5004 (when (string-match (pop types) type)
5005 (throw 'found t)))))
5007 (let ((types gnus-buttonized-mime-types))
5009 (when (string-match (pop types) type)
5010 (throw 'found t)))))))))
5012 (defun gnus-article-insert-newline ()
5013 "Insert a newline, but mark it as undeletable."
5014 (gnus-put-text-property
5015 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5017 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5018 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5021 handle buffer-read-only from props begend not-pref)
5022 (save-window-excursion
5025 (narrow-to-region (car ibegend)
5028 (goto-char (car ibegend))
5031 (delete-region (point-min) (point-max))
5032 (mm-remove-parts handles))
5033 (setq begend (list (point-marker)))
5035 (unless (setq not-pref (cadr (member preferred ihandles)))
5036 (setq not-pref (car ihandles)))
5039 (not (gnus-unbuttonized-mime-type-p
5040 "multipart/alternative")))
5041 (gnus-add-text-properties
5044 (insert (format "%d. " id))
5048 (unless ,(not ibegend)
5049 (setq gnus-article-mime-handle-alist
5050 ',gnus-article-mime-handle-alist))
5051 (gnus-mime-display-alternative
5052 ',ihandles ',not-pref ',begend ,id))
5053 ,@(gnus-local-map-property gnus-mime-button-map)
5054 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5055 face ,gnus-article-button-face
5058 (widget-convert-button 'link from (point)
5059 :action 'gnus-widget-press-button
5060 :button-keymap gnus-widget-button-keymap)
5062 (while (setq handle (pop handles))
5063 (gnus-add-text-properties
5066 (insert (format "(%c) %-18s"
5067 (if (equal handle preferred) ?* ? )
5068 (mm-handle-media-type handle)))
5072 (unless ,(not ibegend)
5073 (setq gnus-article-mime-handle-alist
5074 ',gnus-article-mime-handle-alist))
5075 (gnus-mime-display-alternative
5076 ',ihandles ',handle ',begend ,id))
5077 ,@(gnus-local-map-property gnus-mime-button-map)
5078 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5079 face ,gnus-article-button-face
5082 (widget-convert-button 'link from (point)
5083 :action 'gnus-widget-press-button
5084 :button-keymap gnus-widget-button-keymap)
5088 (if (stringp (car preferred))
5089 (gnus-display-mime preferred)
5090 (let ((mail-parse-charset gnus-newsgroup-charset)
5091 (mail-parse-ignored-charsets
5092 (save-excursion (set-buffer gnus-summary-buffer)
5093 gnus-newsgroup-ignored-charsets)))
5094 (mm-display-part preferred)
5098 (narrow-to-region (car begend) (point-max))
5100 nil (length gnus-article-mime-handle-alist)
5101 (gnus-article-mime-total-parts)
5102 (mm-handle-media-type handle))))))
5103 (goto-char (point-max))
5104 (setcdr begend (point-marker)))))
5106 (goto-char point))))
5108 (defconst gnus-article-wash-status-strings
5109 (let ((alist '((cite "c" "Possible hidden citation text"
5110 " " "All citation text visible")
5111 (headers "h" "Hidden headers"
5112 " " "All headers visible.")
5113 (pgp "p" "Encrypted or signed message status hidden"
5114 " " "No hidden encryption nor digital signature status")
5115 (signature "s" "Signature has been hidden"
5116 " " "Signature is visible")
5117 (overstrike "o" "Overstrike (^H) characters applied"
5118 " " "No overstrike characters applied")
5119 (gnus-show-mime "m" "Mime processing is activated"
5120 " " "Mime processing is not activated")
5121 (emphasis "e" "/*_Emphasis_*/ characters applied"
5122 " " "No /*_emphasis_*/ characters applied")))
5124 (dolist (entry alist result)
5125 (let ((key (nth 0 entry))
5126 (on (copy-sequence (nth 1 entry)))
5127 (on-help (nth 2 entry))
5128 (off (copy-sequence (nth 3 entry)))
5129 (off-help (nth 4 entry)))
5130 (put-text-property 0 1 'help-echo on-help on)
5131 (put-text-property 0 1 'help-echo off-help off)
5132 (push (list key on off) result))))
5133 "Alist of strings describing wash status in the mode line.
5134 Each entry has the form (KEY ON OF), where the KEY is a symbol
5135 representing the particular washing function, ON is the string to use
5136 in the article mode line when the washing function is active, and OFF
5137 is the string to use when it is inactive.")
5139 (defun gnus-article-wash-status-entry (key value)
5140 (let ((entry (assoc key gnus-article-wash-status-strings)))
5141 (if value (nth 1 entry) (nth 2 entry))))
5143 (defun gnus-article-wash-status ()
5144 "Return a string which display status of article washing."
5146 (set-buffer gnus-article-buffer)
5147 (let ((cite (memq 'cite gnus-article-wash-types))
5148 (headers (memq 'headers gnus-article-wash-types))
5149 (boring (memq 'boring-headers gnus-article-wash-types))
5150 (pgp (memq 'pgp gnus-article-wash-types))
5151 (pem (memq 'pem gnus-article-wash-types))
5152 (signed (memq 'signed gnus-article-wash-types))
5153 (encrypted (memq 'encrypted gnus-article-wash-types))
5154 (signature (memq 'signature gnus-article-wash-types))
5155 (overstrike (memq 'overstrike gnus-article-wash-types))
5156 (emphasis (memq 'emphasis gnus-article-wash-types)))
5158 (gnus-article-wash-status-entry 'cite cite)
5159 (gnus-article-wash-status-entry 'headers (or headers boring))
5160 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5161 (gnus-article-wash-status-entry 'signature signature)
5162 (gnus-article-wash-status-entry 'overstrike overstrike)
5163 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5164 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5166 (defun gnus-add-wash-type (type)
5167 "Add a washing of TYPE to the current status."
5168 (add-to-list 'gnus-article-wash-types type))
5170 (defun gnus-delete-wash-type (type)
5171 "Add a washing of TYPE to the current status."
5172 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5174 (defun gnus-add-image (category image)
5175 "Add IMAGE of CATEGORY to the list of displayed images."
5176 (let ((entry (assq category gnus-article-image-alist)))
5178 (setq entry (list category))
5179 (push entry gnus-article-image-alist))
5180 (nconc entry (list image))))
5182 (defun gnus-delete-images (category)
5183 "Delete all images in CATEGORY."
5184 (let ((entry (assq category gnus-article-image-alist)))
5185 (dolist (image (cdr entry))
5186 (gnus-remove-image image))
5187 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5188 (gnus-delete-wash-type category)))
5190 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5192 (defun gnus-article-maybe-hide-headers ()
5193 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5194 Provided for backwards compatibility."
5195 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5196 (not (save-excursion (set-buffer gnus-summary-buffer)
5197 gnus-have-all-headers)))
5198 (not gnus-inhibit-hiding))
5199 (gnus-article-hide-headers)))
5203 (defun gnus-output-to-file (file-name)
5204 "Append the current article to a file named FILE-NAME."
5205 (let ((artbuf (current-buffer)))
5207 (insert-buffer-substring artbuf)
5208 ;; Append newline at end of the buffer as separator, and then
5210 (goto-char (point-max))
5212 (let ((file-name-coding-system nnmail-pathname-coding-system)
5213 (pathname-coding-system nnmail-pathname-coding-system))
5214 (write-region-as-binary (point-min) (point-max) file-name 'append))
5217 (defun gnus-narrow-to-page (&optional arg)
5218 "Narrow the article buffer to a page.
5219 If given a numerical ARG, move forward ARG pages."
5221 (setq arg (if arg (prefix-numeric-value arg) 0))
5223 (set-buffer gnus-article-buffer)
5224 (goto-char (point-min))
5226 ;; Remove any old next/prev buttons.
5227 (when (gnus-visual-p 'page-marker)
5228 (let ((buffer-read-only nil))
5229 (gnus-remove-text-with-property 'gnus-prev)
5230 (gnus-remove-text-with-property 'gnus-next)))
5233 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5235 (re-search-forward page-delimiter nil 'move arg)))
5236 (goto-char (match-end 0)))
5239 (if (re-search-forward page-delimiter nil 'move)
5242 (when (and (gnus-visual-p 'page-marker)
5243 (not (= (point-min) 1)))
5245 (goto-char (point-min))
5246 (gnus-insert-prev-page-button)))
5247 (when (and (gnus-visual-p 'page-marker)
5248 (< (+ (point-max) 2) (buffer-size)))
5250 (goto-char (point-max))
5251 (gnus-insert-next-page-button)))))
5253 ;; Article mode commands
5255 (defun gnus-article-goto-next-page ()
5256 "Show the next page of the article."
5258 (gnus-eval-in-buffer-window gnus-summary-buffer
5259 (gnus-summary-next-page)))
5261 (defun gnus-article-goto-prev-page ()
5262 "Show the next page of the article."
5264 (gnus-eval-in-buffer-window gnus-summary-buffer
5265 (gnus-summary-prev-page)))
5267 (defun gnus-article-next-page (&optional lines)
5268 "Show the next page of the current article.
5269 If end of article, return non-nil. Otherwise return nil.
5270 Argument LINES specifies lines to be scrolled up."
5272 (let ((start (window-start))
5273 end-of-buffer end-of-page)
5275 (move-to-window-line -1)
5276 (if (<= (point) start)
5279 (setq start (point)))
5282 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5283 (and (pos-visible-in-window-p)
5284 (setq end-of-buffer t)))
5286 (setq end-of-page t)))
5288 (move-to-window-line lines)
5289 (unless (search-backward "\n\n" nil t)
5290 (setq start (point)))))
5291 (cond (end-of-buffer t)
5293 (gnus-narrow-to-page 1)
5297 (set-window-start (selected-window) start)
5298 (let (window-pixel-scroll-increment)
5302 (defun gnus-article-prev-page (&optional lines)
5303 "Show previous page of current article.
5304 Argument LINES specifies lines to be scrolled down."
5306 (let (beginning-of-buffer beginning-of-page)
5308 (move-to-window-line 0)
5309 (cond ((eq 1 (point))
5310 (setq beginning-of-buffer t))
5312 (setq beginning-of-page t))))
5313 (cond (beginning-of-buffer)
5315 (gnus-narrow-to-page -1))
5318 (let (window-pixel-scroll-increment)
5319 (scroll-down lines))
5320 (beginning-of-buffer
5321 (goto-char (point-min))))))))
5323 (defun gnus-article-only-boring-p ()
5324 "Decide whether there is only boring text remaining in the article.
5325 Something \"interesting\" is a word of at least two letters that does
5326 not have a face in `gnus-article-boring-faces'."
5327 (when (and gnus-article-skip-boring
5328 (boundp 'gnus-article-boring-faces)
5329 (symbol-value 'gnus-article-boring-faces))
5332 (while (re-search-forward "\\b\\w\\w" nil t)
5334 (when (not (gnus-intersection
5335 (gnus-faces-at (point))
5336 (symbol-value 'gnus-article-boring-faces)))
5337 (throw 'only-boring nil)))
5338 (throw 'only-boring t)))))
5340 (defun gnus-article-refer-article ()
5341 "Read article specified by message-id around point."
5344 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5345 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5346 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5347 (let ((msg-id (concat "<" (match-string 0) ">")))
5348 (set-buffer gnus-summary-buffer)
5349 (gnus-summary-refer-article msg-id))
5350 (error "No references around point"))))
5352 (defun gnus-article-show-summary ()
5353 "Reconfigure windows to show summary buffer."
5355 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5356 (error "There is no summary buffer for this article buffer")
5357 (gnus-article-set-globals)
5358 (gnus-configure-windows 'article)
5359 (gnus-summary-goto-subject gnus-current-article)
5360 (gnus-summary-position-point)))
5362 (defun gnus-article-describe-briefly ()
5363 "Describe article mode commands briefly."
5365 (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")))
5367 (defun gnus-article-summary-command ()
5368 "Execute the last keystroke in the summary buffer."
5370 (let ((obuf (current-buffer))
5371 (owin (current-window-configuration))
5373 (switch-to-buffer gnus-article-current-summary 'norecord)
5374 (setq func (lookup-key (current-local-map) (this-command-keys)))
5375 (call-interactively func)
5377 (set-window-configuration owin)
5378 (set-window-point (get-buffer-window (current-buffer)) (point))))
5380 (defun gnus-article-summary-command-nosave ()
5381 "Execute the last keystroke in the summary buffer."
5384 (pop-to-buffer gnus-article-current-summary 'norecord)
5385 (setq func (lookup-key (current-local-map) (this-command-keys)))
5386 (call-interactively func)))
5388 (defun gnus-article-check-buffer ()
5389 "Beep if not in an article buffer."
5390 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5391 (error "Command invoked outside of a Gnus article buffer")))
5393 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5394 "Read a summary buffer key sequence and execute it from the article buffer."
5396 (gnus-article-check-buffer)
5398 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5399 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5400 "=" "^" "\M-^" "|"))
5406 '("n" "Gn" "p" "Gp"))
5409 (set-buffer gnus-article-current-summary)
5410 (let (gnus-pick-mode)
5411 (push (or key last-command-event) unread-command-events)
5412 (setq keys (static-if (featurep 'xemacs)
5413 (events-to-keys (read-key-sequence nil))
5414 (read-key-sequence nil)))))
5417 (if (or (member keys nosaves)
5418 (member keys nosave-but-article)
5419 (member keys nosave-in-article))
5421 (save-window-excursion
5422 (pop-to-buffer gnus-article-current-summary 'norecord)
5423 ;; We disable the pick minor mode commands.
5424 (let (gnus-pick-mode)
5425 (setq func (lookup-key (current-local-map) keys))))
5429 (unless (member keys nosave-in-article)
5430 (set-buffer gnus-article-current-summary))
5431 (call-interactively func)
5432 (setq new-sum-point (point)))
5433 (when (member keys nosave-but-article)
5434 (pop-to-buffer gnus-article-buffer 'norecord)))
5435 ;; These commands should restore window configuration.
5436 (let ((obuf (current-buffer))
5437 (owin (current-window-configuration))
5439 (summary gnus-article-current-summary)
5440 func in-buffer selected)
5441 (if not-restore-window
5442 (pop-to-buffer summary 'norecord)
5443 (switch-to-buffer summary 'norecord))
5444 (setq in-buffer (current-buffer))
5445 ;; We disable the pick minor mode commands.
5446 (if (and (setq func (let (gnus-pick-mode)
5447 (lookup-key (current-local-map) keys)))
5450 (call-interactively func)
5451 (setq new-sum-point (point))
5452 (when (eq in-buffer (current-buffer))
5453 (setq selected (gnus-summary-select-article))
5455 (unless not-restore-window
5456 (set-window-configuration owin))
5457 (when (eq selected 'old)
5459 (set-window-start (get-buffer-window (current-buffer))
5461 (set-window-point (get-buffer-window (current-buffer))
5463 (let ((win (get-buffer-window gnus-article-current-summary)))
5465 (set-window-point win new-sum-point)))) )
5466 (switch-to-buffer gnus-article-buffer)
5469 (defun gnus-article-describe-key (key)
5470 "Display documentation of the function invoked by KEY. KEY is a string."
5471 (interactive "kDescribe key: ")
5472 (gnus-article-check-buffer)
5473 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5475 (set-buffer gnus-article-current-summary)
5476 (let (gnus-pick-mode)
5477 (if (featurep 'xemacs)
5479 (push (elt key 0) unread-command-events)
5480 (setq key (events-to-keys
5481 (read-key-sequence "Describe key: "))))
5482 (setq unread-command-events
5484 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5486 (setq key (read-key-sequence "Describe key: "))))
5488 (describe-key key)))
5490 (defun gnus-article-describe-key-briefly (key &optional insert)
5491 "Display documentation of the function invoked by KEY. KEY is a string."
5492 (interactive "kDescribe key: \nP")
5493 (gnus-article-check-buffer)
5494 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5496 (set-buffer gnus-article-current-summary)
5497 (let (gnus-pick-mode)
5498 (if (featurep 'xemacs)
5500 (push (elt key 0) unread-command-events)
5501 (setq key (events-to-keys
5502 (read-key-sequence "Describe key: "))))
5503 (setq unread-command-events
5505 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5507 (setq key (read-key-sequence "Describe key: "))))
5508 (describe-key-briefly key insert))
5509 (describe-key-briefly key insert)))
5511 (defun gnus-article-reply-with-original (&optional wide)
5512 "Start composing a reply mail to the current message.
5513 The text in the region will be yanked. If the region isn't active,
5514 the entire article will be yanked."
5516 (let ((article (cdr gnus-article-current))
5518 (if (not (gnus-mark-active-p))
5519 (with-current-buffer gnus-summary-buffer
5520 (gnus-summary-reply (list (list article)) wide))
5521 (setq contents (buffer-substring (point) (mark t)))
5522 ;; Deactivate active regions.
5523 (when (and (boundp 'transient-mark-mode)
5524 transient-mark-mode)
5525 (setq mark-active nil))
5526 (with-current-buffer gnus-summary-buffer
5528 (list (list article contents)) wide)))))
5530 (defun gnus-article-followup-with-original ()
5531 "Compose a followup to the current article.
5532 The text in the region will be yanked. If the region isn't active,
5533 the entire article will be yanked."
5535 (let ((article (cdr gnus-article-current))
5537 (if (not (gnus-mark-active-p))
5538 (with-current-buffer gnus-summary-buffer
5539 (gnus-summary-followup (list (list article))))
5540 (setq contents (buffer-substring (point) (mark t)))
5541 ;; Deactivate active regions.
5542 (when (and (boundp 'transient-mark-mode)
5543 transient-mark-mode)
5544 (setq mark-active nil))
5545 (with-current-buffer gnus-summary-buffer
5546 (gnus-summary-followup
5547 (list (list article contents)))))))
5549 (defun gnus-article-hide (&optional arg force)
5550 "Hide all the gruft in the current article.
5551 This means that signatures, cited text and (some) headers will be
5553 If given a prefix, show the hidden text instead."
5554 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5555 (gnus-article-hide-headers arg)
5556 (gnus-article-hide-list-identifiers arg)
5557 (gnus-article-hide-citation-maybe arg force)
5558 (gnus-article-hide-signature arg))
5560 (defun gnus-article-maybe-highlight ()
5561 "Do some article highlighting if article highlighting is requested."
5562 (when (gnus-visual-p 'article-highlight 'highlight)
5563 (gnus-article-highlight-some)))
5565 (defun gnus-check-group-server ()
5566 ;; Make sure the connection to the server is alive.
5567 (unless (gnus-server-opened
5568 (gnus-find-method-for-group gnus-newsgroup-name))
5569 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5570 (gnus-request-group gnus-newsgroup-name t)))
5573 (autoload 'nneething-get-file-name "nneething"))
5575 (defun gnus-request-article-this-buffer (article group)
5576 "Get an article and insert it into this buffer."
5577 (let (do-update-line sparse-header)
5581 (gnus-kill-all-overlays)
5582 (setq group (or group gnus-newsgroup-name))
5584 ;; Using `gnus-request-article' directly will insert the article into
5585 ;; `nntp-server-buffer' - so we'll save some time by not having to
5586 ;; copy it from the server buffer into the article buffer.
5588 ;; We only request an article by message-id when we do not have the
5589 ;; headers for it, so we'll have to get those.
5590 (when (stringp article)
5591 (gnus-read-header article))
5593 ;; If the article number is negative, that means that this article
5594 ;; doesn't belong in this newsgroup (possibly), so we find its
5595 ;; message-id and request it by id instead of number.
5596 (when (and (numberp article)
5598 (get-buffer gnus-summary-buffer)
5599 (gnus-buffer-exists-p gnus-summary-buffer))
5601 (set-buffer gnus-summary-buffer)
5602 (let ((header (gnus-summary-article-header article)))
5605 ((memq article gnus-newsgroup-sparse)
5606 ;; This is a sparse gap article.
5607 (setq do-update-line article)
5608 (setq article (mail-header-id header))
5609 (setq sparse-header (gnus-read-header article))
5610 (setq gnus-newsgroup-sparse
5611 (delq article gnus-newsgroup-sparse)))
5613 ;; It's a real article.
5614 (setq article (mail-header-id header)))
5616 ;; It is an extracted pseudo-article.
5617 (setq article 'pseudo)
5618 (gnus-request-pseudo-article header))))
5620 (let ((method (gnus-find-method-for-group
5621 gnus-newsgroup-name)))
5622 (when (and (eq (car method) 'nneething)
5624 (let ((dir (nneething-get-file-name
5625 (mail-header-id header))))
5626 (when (and (stringp dir)
5627 (file-directory-p dir))
5628 (setq article 'nneething)
5629 (gnus-group-enter-directory dir))))))))
5632 ;; Refuse to select canceled articles.
5633 ((and (numberp article)
5635 (get-buffer gnus-summary-buffer)
5636 (gnus-buffer-exists-p gnus-summary-buffer)
5637 (eq (cdr (save-excursion
5638 (set-buffer gnus-summary-buffer)
5639 (assq article gnus-newsgroup-reads)))
5640 gnus-canceled-mark))
5642 ;; We first check `gnus-original-article-buffer'.
5643 ((and (get-buffer gnus-original-article-buffer)
5646 (set-buffer gnus-original-article-buffer)
5647 (and (equal (car gnus-original-article) group)
5648 (eq (cdr gnus-original-article) article))))
5649 (insert-buffer-substring gnus-original-article-buffer)
5651 ;; Check the backlog.
5652 ((and gnus-keep-backlog
5653 (gnus-backlog-request-article group article (current-buffer)))
5655 ;; Check asynchronous pre-fetch.
5656 ((gnus-async-request-fetched-article group article (current-buffer))
5657 (gnus-async-prefetch-next group article gnus-summary-buffer)
5658 (when (and (numberp article) gnus-keep-backlog)
5659 (gnus-backlog-enter-article group article (current-buffer)))
5662 ((and gnus-use-cache
5664 (gnus-cache-request-article article group))
5666 ;; Check the agent cache.
5667 ((gnus-agent-request-article article group)
5669 ;; Get the article and put into the article buffer.
5670 ((or (stringp article)
5672 (let ((gnus-override-method gnus-override-method)
5673 (methods (and (stringp article)
5674 gnus-refer-article-method))
5675 (backend (car (gnus-find-method-for-group
5676 gnus-newsgroup-name)))
5678 (buffer-read-only nil))
5679 (if (or (not (listp methods))
5680 (and (symbolp (car methods))
5681 (assq (car methods) nnoo-definition-alist)))
5682 (setq methods (list methods)))
5683 (when (and (null gnus-override-method)
5685 (setq gnus-override-method (pop methods)))
5687 (when (eq gnus-override-method 'current)
5688 (setq gnus-override-method
5689 (with-current-buffer gnus-summary-buffer
5690 gnus-current-select-method)))
5692 (gnus-kill-all-overlays)
5693 (let ((gnus-newsgroup-name group))
5694 (gnus-check-group-server))
5696 ((gnus-request-article article group (current-buffer))
5697 (when (numberp article)
5698 (gnus-async-prefetch-next group article
5699 gnus-summary-buffer)
5700 (when gnus-keep-backlog
5701 (gnus-backlog-enter-article
5702 group article (current-buffer))))
5703 (setq result 'article))
5705 (setq gnus-override-method (pop methods)))
5706 ((not (string-match "^400 "
5707 (nnheader-get-report backend)))
5708 ;; If we get 400 server disconnect, reconnect and
5709 ;; retry; otherwise, assume the article has expired.
5710 (setq result 'done))))
5711 (and (eq result 'article) 'article)))
5715 ;; Associate this article with the current summary buffer.
5716 (setq gnus-article-current-summary gnus-summary-buffer)
5718 ;; Take the article from the original article buffer
5719 ;; and place it in the buffer it's supposed to be in.
5720 (when (and (get-buffer gnus-article-buffer)
5721 (equal (buffer-name (current-buffer))
5722 (buffer-name (get-buffer gnus-article-buffer))))
5724 (if (get-buffer gnus-original-article-buffer)
5725 (set-buffer gnus-original-article-buffer)
5726 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5727 (buffer-disable-undo)
5728 (setq major-mode 'gnus-original-article-mode)
5729 (setq buffer-read-only t))
5730 (let (buffer-read-only)
5732 (insert-buffer-substring gnus-article-buffer))
5733 (setq gnus-original-article (cons group article)))
5736 (run-hooks 'gnus-article-decode-hook)
5737 ;; Mark article as decoded or not.
5738 (setq gnus-article-decoded-p gnus-article-decode-hook))
5740 ;; Update sparse articles.
5741 (when (and do-update-line
5742 (or (numberp article)
5744 (let ((buf (current-buffer)))
5745 (set-buffer gnus-summary-buffer)
5746 (gnus-summary-update-article do-update-line sparse-header)
5747 (gnus-summary-goto-subject do-update-line nil t)
5748 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5750 (set-buffer buf))))))
5756 (defcustom gnus-article-edit-mode-hook nil
5757 "Hook run in article edit mode buffers."
5758 :group 'gnus-article-various
5761 (defcustom gnus-article-edit-article-setup-function
5762 'gnus-article-mime-edit-article-setup
5763 "Function called to setup an editing article buffer."
5764 :group 'gnus-article-various
5767 (defvar gnus-article-edit-done-function nil)
5769 (defvar gnus-article-edit-mode-map nil)
5770 (defvar gnus-article-edit-mode nil)
5772 ;; Should we be using derived.el for this?
5773 (unless gnus-article-edit-mode-map
5774 (setq gnus-article-edit-mode-map (make-keymap))
5775 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5777 (gnus-define-keys gnus-article-edit-mode-map
5778 "\C-c?" describe-mode
5779 "\C-c\C-c" gnus-article-edit-done
5780 "\C-c\C-k" gnus-article-edit-exit
5781 "\C-c\C-f\C-t" message-goto-to
5782 "\C-c\C-f\C-o" message-goto-from
5783 "\C-c\C-f\C-b" message-goto-bcc
5784 ;;"\C-c\C-f\C-w" message-goto-fcc
5785 "\C-c\C-f\C-c" message-goto-cc
5786 "\C-c\C-f\C-s" message-goto-subject
5787 "\C-c\C-f\C-r" message-goto-reply-to
5788 "\C-c\C-f\C-n" message-goto-newsgroups
5789 "\C-c\C-f\C-d" message-goto-distribution
5790 "\C-c\C-f\C-f" message-goto-followup-to
5791 "\C-c\C-f\C-m" message-goto-mail-followup-to
5792 "\C-c\C-f\C-k" message-goto-keywords
5793 "\C-c\C-f\C-u" message-goto-summary
5794 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5795 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5796 "\C-c\C-b" message-goto-body
5797 "\C-c\C-i" message-goto-signature
5799 "\C-c\C-t" message-insert-to
5800 "\C-c\C-n" message-insert-newsgroups
5801 "\C-c\C-o" message-sort-headers
5802 "\C-c\C-e" message-elide-region
5803 "\C-c\C-v" message-delete-not-region
5804 "\C-c\C-z" message-kill-to-signature
5805 "\M-\r" message-newline-and-reformat
5806 "\C-c\C-a" mml-attach-file
5807 "\C-a" message-beginning-of-line
5809 "\M-;" comment-region)
5811 (gnus-define-keys (gnus-article-edit-wash-map
5812 "\C-c\C-w" gnus-article-edit-mode-map)
5813 "f" gnus-article-edit-full-stops))
5816 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5818 ["Fetch To" message-insert-to t]
5819 ["Fetch Newsgroups" message-insert-newsgroups t]
5821 ["To" message-goto-to t]
5822 ["From" message-goto-from t]
5823 ["Subject" message-goto-subject t]
5824 ["Cc" message-goto-cc t]
5825 ["Reply-To" message-goto-reply-to t]
5826 ["Summary" message-goto-summary t]
5827 ["Keywords" message-goto-keywords t]
5828 ["Newsgroups" message-goto-newsgroups t]
5829 ["Followup-To" message-goto-followup-to t]
5830 ["Mail-Followup-To" message-goto-mail-followup-to t]
5831 ["Distribution" message-goto-distribution t]
5832 ["Body" message-goto-body t]
5833 ["Signature" message-goto-signature t]))
5835 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5836 "Major mode for editing articles.
5837 This is an extended text-mode.
5839 \\{gnus-article-edit-mode-map}"
5840 (make-local-variable 'gnus-article-edit-done-function)
5841 (make-local-variable 'gnus-prev-winconf)
5842 (set (make-local-variable 'font-lock-defaults)
5843 '(message-font-lock-keywords t))
5844 (set (make-local-variable 'mail-header-separator) "")
5845 (set (make-local-variable 'gnus-article-edit-mode) t)
5846 (easy-menu-add message-mode-field-menu message-mode-map)
5847 (setq buffer-read-only nil)
5848 (buffer-enable-undo)
5851 (defun gnus-article-edit (&optional force)
5852 "Edit the current article.
5853 This will have permanent effect only in mail groups.
5854 If FORCE is non-nil, allow editing of articles even in read-only
5857 (when (and (not force)
5858 (gnus-group-read-only-p))
5859 (error "The current newsgroup does not support article editing"))
5860 (gnus-article-date-original)
5861 (gnus-article-edit-article
5863 `(lambda (no-highlight)
5865 (gnus-summary-edit-article-done
5866 ,(or (mail-header-references gnus-current-headers) "")
5867 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5869 (defun gnus-article-edit-article (start-func exit-func)
5870 "Start editing the contents of the current article buffer."
5871 (let ((winconf (current-window-configuration)))
5872 (set-buffer gnus-article-buffer)
5873 (gnus-article-edit-mode)
5874 (funcall start-func)
5875 (set-buffer-modified-p nil)
5876 (gnus-configure-windows 'edit-article)
5877 (setq gnus-article-edit-done-function exit-func)
5878 (setq gnus-prev-winconf winconf)
5879 (when gnus-article-edit-article-setup-function
5880 (funcall gnus-article-edit-article-setup-function))
5881 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5883 (defun gnus-article-edit-done (&optional arg)
5884 "Update the article edits and exit."
5886 (let ((func gnus-article-edit-done-function)
5887 (buf (current-buffer))
5888 (start (window-start))
5890 (winconf gnus-prev-winconf))
5891 (remove-hook 'gnus-article-mode-hook
5892 'gnus-article-mime-edit-article-unwind)
5893 (widen) ;; Widen it in case that users narrowed the buffer.
5896 ;; The cache and backlog have to be flushed somewhat.
5897 (when gnus-keep-backlog
5898 (gnus-backlog-remove-article
5899 (car gnus-article-current) (cdr gnus-article-current)))
5900 ;; Flush original article as well.
5902 (when (get-buffer gnus-original-article-buffer)
5903 (set-buffer gnus-original-article-buffer)
5904 (setq gnus-original-article nil)))
5905 (when gnus-use-cache
5906 (gnus-cache-update-article
5907 (car gnus-article-current) (cdr gnus-article-current)))
5908 ;; We remove all text props from the article buffer.
5909 (kill-all-local-variables)
5910 (gnus-set-text-properties (point-min) (point-max) nil)
5912 (set-window-configuration winconf)
5914 (set-window-start (get-buffer-window buf) start)
5915 (set-window-point (get-buffer-window buf) (point))))
5917 (defun gnus-article-edit-exit ()
5918 "Exit the article editing without updating."
5920 (when (or (not (buffer-modified-p))
5921 (yes-or-no-p "Article modified; kill anyway? "))
5922 (let ((curbuf (current-buffer))
5924 (window-start (window-start)))
5926 (if (gnus-buffer-live-p gnus-original-article-buffer)
5927 (insert-buffer-substring gnus-original-article-buffer))
5928 (let ((winconf gnus-prev-winconf))
5929 (kill-all-local-variables)
5931 (set-window-configuration winconf)
5932 ;; Tippy-toe some to make sure that point remains where it was.
5933 (save-current-buffer
5935 (set-window-start (get-buffer-window (current-buffer)) window-start)
5938 (defun gnus-article-edit-full-stops ()
5939 "Interactively repair spacing at end of sentences."
5942 (goto-char (point-min))
5943 (search-forward-regexp "^$" nil t)
5944 (let ((case-fold-search nil))
5945 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5948 ;;; Article editing with MIME-Edit
5951 (defcustom gnus-article-mime-edit-article-setup-hook nil
5952 "Hook run after setting up a MIME editing article buffer."
5953 :group 'gnus-article-various
5956 (defun gnus-article-mime-edit-article-unwind ()
5957 "Unwind `gnus-article-buffer' if article editing was given up."
5958 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5959 (when (featurep 'font-lock)
5960 (setq font-lock-defaults nil)
5961 (font-lock-mode -1))
5962 (when mime-edit-mode-flag
5963 (mime-edit-exit 'nomime 'no-error)
5966 (defun gnus-article-mime-edit-article-setup ()
5967 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5968 after replacing with the original article."
5969 (setq gnus-show-mime t)
5970 (setq gnus-article-edit-done-function
5971 `(lambda (&rest args)
5972 (when mime-edit-mode-flag
5973 (let (mime-edit-insert-user-agent-field)
5976 (goto-char (point-min))
5977 (let (case-fold-search)
5978 (when (re-search-forward
5979 (format "^%s$" (regexp-quote mail-header-separator))
5981 (replace-match "")))
5982 (apply ,gnus-article-edit-done-function args)
5985 (buffer-substring-no-properties (point-min) (point-max))
5986 (set-buffer (get-buffer-create gnus-original-article-buffer))
5988 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5989 (set-buffer gnus-article-buffer)
5990 (gnus-article-prepare-display)))
5991 (substitute-key-definition 'gnus-article-edit-done
5992 'gnus-article-mime-edit-done
5993 gnus-article-edit-mode-map)
5994 (substitute-key-definition 'gnus-article-edit-exit
5995 'gnus-article-mime-edit-exit
5996 gnus-article-edit-mode-map)
5998 (insert-buffer-substring gnus-original-article-buffer)
5999 (unless (member (with-current-buffer gnus-summary-buffer
6000 gnus-newsgroup-name)
6001 '("nndraft:delayed" "nndraft:drafts"))
6002 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6003 (fset 'mime-edit-decode-single-part-in-buffer
6004 (lambda (&rest args)
6005 (if (let ((content-type (car args)))
6006 (and (eq 'message (mime-content-type-primary-type
6008 (eq 'rfc822 (mime-content-type-subtype
6010 (setcar (cdr args) 'not-decode-text))
6014 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6015 (when (featurep 'font-lock)
6016 (set (make-local-variable 'font-lock-defaults)
6017 '(message-font-lock-keywords t))
6018 (font-lock-set-defaults)
6019 (turn-on-font-lock))
6020 (set-buffer-modified-p nil)
6021 (delete-other-windows)
6022 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6023 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6025 (defun gnus-article-mime-edit-done (&optional arg)
6026 "Update the article MIME edits and exit."
6028 (when (featurep 'font-lock)
6029 (setq font-lock-defaults nil)
6030 (font-lock-mode -1))
6031 (let ((inhibit-read-only t))
6032 (gnus-article-edit-done arg)))
6034 (defun gnus-article-mime-edit-exit ()
6035 "Exit the article MIME editing without updating."
6037 (when (or (not (buffer-modified-p))
6038 (yes-or-no-p "Article modified; kill anyway? "))
6039 (when (featurep 'font-lock)
6040 (setq font-lock-defaults nil)
6041 (font-lock-mode -1))
6042 (when mime-edit-mode-flag
6043 (let (mime-edit-insert-user-agent-field)
6046 (goto-char (point-min))
6047 (let (case-fold-search)
6048 (when (re-search-forward
6049 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6050 (replace-match "")))
6051 (let ((winconf gnus-prev-winconf))
6053 (buffer-substring-no-properties (point-min) (point-max))
6054 (set-buffer (get-buffer-create gnus-original-article-buffer))
6056 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6057 (set-buffer gnus-article-buffer)
6058 (gnus-article-prepare-display)
6059 (set-window-configuration winconf))))
6062 ;;; Article highlights
6065 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6067 ;;; Internal Variables:
6069 (defcustom gnus-button-url-regexp
6070 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6071 "\\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:]]\\)"
6072 "\\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\\)\\)")
6073 "Regular expression that matches URLs."
6074 :group 'gnus-article-buttons
6077 (defcustom gnus-button-valid-fqdn-regexp
6078 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
6080 "\\([a-z][a-z]" ;; two letter country TDLs
6081 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
6082 "\\|aero\\|coop\\|info\\|name\\|museum"
6083 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
6085 "Regular expression that matches a valid FQDN."
6086 :group 'gnus-article-buttons
6089 (defcustom gnus-button-man-handler 'manual-entry
6090 "Function to use for displaying man pages.
6091 The function must take at least one argument with a string naming the
6093 :type '(choice (function-item :tag "Man" manual-entry)
6094 (function-item :tag "Woman" woman)
6095 (function :tag "Other"))
6096 :group 'gnus-article-buttons)
6098 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6099 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6100 If the default site is too slow, try to find a CTAN mirror, see
6101 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6102 the variable `gnus-button-handle-ctan'."
6103 :group 'gnus-article-buttons
6104 :link '(custom-manual "(gnus)Group Parameters")
6105 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6106 (const "http://tug.ctan.org/tex-archive/")
6107 (const "http://www.dante.de/CTAN/")
6108 (string :tag "Other")))
6110 (defcustom gnus-button-ctan-handler 'browse-url
6111 "Function to use for displaying CTAN links.
6112 The function must take one argument, the string naming the URL."
6113 :type '(choice (function-item :tag "Browse Url" browse-url)
6114 (function :tag "Other"))
6115 :group 'gnus-article-buttons)
6117 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6118 "Bogus strings removed from CTAN URLs."
6119 :group 'gnus-article-buttons
6120 :type '(choice (const "^/?tex-archive/\\|/")
6121 (regexp :tag "Other")))
6123 (defcustom gnus-button-mid-or-mail-regexp
6124 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6125 gnus-button-valid-fqdn-regexp
6127 "Regular expression that matches a message ID or a mail address."
6128 :group 'gnus-article-buttons
6131 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6132 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6133 Strings like this can be either a message ID or a mail address. If it is one
6134 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6135 message ID or a mail address, respectivly. If this variable is set to the
6136 symbol `ask', always query the user what do do. If it is a function, this
6137 function will be called with the string as it's only argument. The function
6138 must return `mid', `mail', `invalid' or `ask'."
6139 :group 'gnus-article-buttons
6140 :type '(choice (function-item :tag "Heuristic function"
6141 gnus-button-mid-or-mail-heuristic)
6146 (defcustom gnus-button-mid-or-mail-heuristic-alist
6147 '((-10.0 . ".+\\$.+@")
6150 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6151 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6152 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6153 (-1.0 . "^[^a-z]+@")
6155 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6156 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6157 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6158 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6161 (-1.0 . "^[0-9][0-9]")
6163 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6164 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6165 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6166 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6168 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6169 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6172 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6174 ;; compensation for TDMA dated mail addresses:
6175 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6177 (-20.0 . "\\.fsf@") ;; Gnus
6180 (-20.0 . "_-_") ;; Subject change in thread
6182 (-20.0 . "\\.ln@") ;; leafnode
6183 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6184 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6186 ;; (5.0 . "") ;; $local_part_len <= 7
6187 (10.0 . "^[^0-9]+@")
6188 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6189 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6192 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6194 (0.5 . "^[A-Z][a-z]")
6195 (0.5 . "^[A-Z][a-z][a-z]")
6196 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6197 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6198 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6200 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6201 address. The REGEXP is processed with `case-fold-search' set to `nil'."
6202 :group 'gnus-article-buttons
6203 :type '(repeat (cons (number :tag "Rate")
6204 (regexp :tag "Regexp"))))
6206 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6207 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6208 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6209 address, `ask' if unsure and `invalid' if the string is invalid."
6210 (let ((case-fold-search nil)
6211 (list gnus-button-mid-or-mail-heuristic-alist)
6212 (result 0) rate regexp lpartlen elem)
6214 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6215 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6216 ;; Certain special cases...
6219 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6220 "^[0-9]+\.[0-9]+\@compuserve")
6222 (gnus-message 8 "`%s' is a known mail address.")
6223 (setq result 'mail))
6224 (when (string-match "@.*@\\| " mid-or-mail)
6225 (gnus-message 8 "`%s' is invalid.")
6226 (setq result 'invalid))
6227 ;; Nothing more to do, if result is not a number here...
6228 (when (numberp result)
6230 (setq elem (car list)
6234 (when (string-match regexp mid-or-mail)
6235 (setq result (+ result rate))
6237 9 "`%s' matched `%s', rate `%s', result `%s'."
6238 mid-or-mail regexp rate result)))
6239 (when (<= lpartlen 7)
6240 (setq result (+ result 5.0))
6241 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6242 mid-or-mail result))
6243 (when (>= lpartlen 12)
6244 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6246 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6247 ;; Long local part should contain realname if e-mail address,
6248 ;; too many digits: message-id.
6249 ;; $score -= 5.0 + 0.1 * $local_part_len;
6250 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6251 (setq result (+ result rate))
6253 9 "Many digits in `%s', rate `%s', result `%s'."
6254 mid-or-mail rate result))
6255 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6257 ;; Too few vowels [^aeiouy]{4,}.*\@
6258 (setq result (+ result -5.0))
6260 9 "Few vowels in `%s', rate `%s', result `%s'."
6261 mid-or-mail -5.0 result))
6263 (setq result (+ result 5.0))
6265 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6266 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6268 ;; Maybe we should make this a customizable alist: (condition . 'result)
6269 ((< result -10.0) 'mid)
6270 ((> result 10.0) 'mail)
6273 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6274 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6275 (url-mid (concat "news" ":" mid-or-mail))
6276 (url-mailto (concat "mailto" ":" mid-or-mail)))
6277 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6278 (when (fboundp pref)
6280 ;; get rid of surrounding angles...
6282 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6283 (if (or (eq 'mid guessed) (eq 'mail guessed))
6287 (save-window-excursion
6288 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6291 (cond ((eq pref 'mid)
6292 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6293 (gnus-button-handle-news url-mid))
6295 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6296 (gnus-url-mailto url-mailto))
6297 (t (gnus-message 3 "Invalid string.")))))
6299 (defun gnus-button-handle-custom (url)
6300 "Follow a Custom URL."
6301 (customize-apropos (gnus-url-unhex-string url)))
6303 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6305 (defun gnus-button-handle-describe-function (url)
6306 "Call `describe-function' when pushing the corresponding URL button."
6309 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6311 (defun gnus-button-handle-describe-variable (url)
6312 "Call `describe-variable' when pushing the corresponding URL button."
6315 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6317 (defun gnus-button-handle-describe-key (url)
6318 "Call `describe-key' when pushing the corresponding URL button."
6320 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6321 (keys (ignore-errors (eval `(kbd ,key-string)))))
6324 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6326 (defun gnus-button-handle-apropos (url)
6327 "Call `apropos' when pushing the corresponding URL button."
6328 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6330 (defun gnus-button-handle-apropos-command (url)
6331 "Call `apropos' when pushing the corresponding URL button."
6333 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6335 (defun gnus-button-handle-apropos-variable (url)
6336 "Call `apropos' when pushing the corresponding URL button."
6338 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6339 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6341 (defun gnus-button-handle-apropos-documentation (url)
6342 "Call `apropos' when pushing the corresponding URL button."
6344 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6345 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6347 (defun gnus-button-handle-ctan (url)
6348 "Call `browse-url' when pushing a CTAN URL button."
6350 gnus-button-ctan-handler
6353 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6355 (defcustom gnus-button-tex-level 5
6356 "*Integer that says how many TeX-related buttons Gnus will show.
6357 The higher the number, the more buttons will appear and the more false
6358 positives are possible. Note that you can set this variable local to
6359 specifific groups. Setting it higher in TeX groups is probably a good idea.
6360 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6361 how to set variables in specific groups."
6362 :group 'gnus-article-buttons
6363 :link '(custom-manual "(gnus)Group Parameters")
6366 (defcustom gnus-button-man-level 5
6367 "*Integer that says how many man-related buttons Gnus will show.
6368 The higher the number, the more buttons will appear and the more false
6369 positives are possible. Note that you can set this variable local to
6370 specifific groups. Setting it higher in Unix groups is probably a good idea.
6371 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6372 how to set variables in specific groups."
6373 :group 'gnus-article-buttons
6374 :link '(custom-manual "(gnus)Group Parameters")
6377 (defcustom gnus-button-emacs-level 5
6378 "*Integer that says how many emacs-related buttons Gnus will show.
6379 The higher the number, the more buttons will appear and the more false
6380 positives are possible. Note that you can set this variable local to
6381 specifific groups. Setting it higher in Emacs or Gnus related groups is
6382 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6383 `gnus-parameters' on how to set variables in specific groups."
6384 :group 'gnus-article-buttons
6385 :link '(custom-manual "(gnus)Group Parameters")
6388 (defcustom gnus-button-mail-level 5
6389 "*Integer that says how many buttons for message IDs or mail addresses will appear.
6390 The higher the number, the more buttons will appear and the more false
6391 positives are possible."
6392 :group 'gnus-article-buttons
6395 (defcustom gnus-button-alist
6396 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6397 0 t gnus-button-handle-news 3)
6398 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6399 gnus-button-handle-news 2)
6400 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6402 gnus-button-fetch-group 4)
6403 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
6404 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
6405 t gnus-button-message-id 3)
6406 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
6407 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6408 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
6410 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
6411 gnus-button-handle-ctan 1)
6413 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6414 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
6416 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6417 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6418 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6419 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6420 ;; Emacs help commands
6421 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6422 ;; regexp doesn't match arguments containing ` '.
6423 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6424 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6425 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6426 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6427 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6428 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6429 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6430 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6431 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6432 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6433 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6434 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
6435 ;; Unlike the other regexps we really have to require quoting
6436 ;; here to determine where it ends.
6437 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6438 ;; This is how URLs _should_ be embedded in text...
6439 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
6441 (gnus-button-url-regexp 0 t browse-url 0)
6443 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
6444 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6445 gnus-button-handle-man 1)
6446 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6447 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
6448 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6449 gnus-button-handle-man 1)
6450 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6451 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
6452 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
6453 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6454 ;; MID or mail: To avoid too many false positives we don't try to catch
6455 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6456 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6457 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6458 ;; so that non-ambiguous entries (see above) match first.
6459 (gnus-button-mid-or-mail-regexp
6460 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6461 "*Alist of regexps matching buttons in article bodies.
6463 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6464 REGEXP: is the string (case insensitive) matching text around the button (can
6465 also be lisp expression evaluating to a string),
6466 BUTTON: is the number of the regexp grouping actually matching the button,
6467 FORM: is a lisp expression which must eval to true for the button to
6469 CALLBACK: is the function to call when the user push this button, and each
6470 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6472 CALLBACK can also be a variable, in that case the value of that
6473 variable it the real callback function."
6474 :group 'gnus-article-buttons
6475 :type '(repeat (list (choice regexp variable)
6476 (integer :tag "Button")
6478 (function :tag "Callback")
6481 (integer :tag "Regexp group")))))
6483 (defcustom gnus-header-button-alist
6484 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6485 0 t gnus-button-message-id 0)
6486 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6487 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6488 0 t gnus-button-mailto 0)
6489 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6490 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6491 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6492 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6493 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6494 gnus-button-message-id 3))
6495 "*Alist of headers and regexps to match buttons in article heads.
6497 This alist is very similar to `gnus-button-alist', except that each
6498 alist has an additional HEADER element first in each entry:
6500 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6502 HEADER is a regexp to match a header. For a fuller explanation, see
6503 `gnus-button-alist'."
6504 :group 'gnus-article-buttons
6505 :group 'gnus-article-headers
6506 :type '(repeat (list (regexp :tag "Header")
6508 (integer :tag "Button")
6510 (function :tag "Callback")
6513 (integer :tag "Regexp group")))))
6515 (defvar gnus-button-regexp nil)
6516 (defvar gnus-button-marker-list nil)
6517 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6519 (defvar gnus-button-last nil)
6520 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6524 (defun gnus-article-push-button (event)
6525 "Check text under the mouse pointer for a callback function.
6526 If the text under the mouse pointer has a `gnus-callback' property,
6527 call it with the value of the `gnus-data' text property."
6529 (set-buffer (window-buffer (posn-window (event-start event))))
6530 (let* ((pos (posn-point (event-start event)))
6531 (data (get-text-property pos 'gnus-data))
6532 (fun (get-text-property pos 'gnus-callback)))
6535 (funcall fun data))))
6537 (defun gnus-article-press-button ()
6538 "Check text at point for a callback function.
6539 If the text at point has a `gnus-callback' property,
6540 call it with the value of the `gnus-data' text property."
6542 (let ((data (get-text-property (point) 'gnus-data))
6543 (fun (get-text-property (point) 'gnus-callback)))
6545 (funcall fun data))))
6547 (defun gnus-article-prev-button (n)
6548 "Move point to N buttons backward.
6549 If N is negative, move forward instead."
6551 (gnus-article-next-button (- n)))
6553 (defun gnus-article-next-button (n)
6554 "Move point to N buttons forward.
6555 If N is negative, move backward instead."
6557 (let ((function (if (< n 0) 'previous-single-property-change
6558 'next-single-property-change))
6559 (inhibit-point-motion-hooks t)
6561 (limit (if (< n 0) (point-min) (point-max))))
6563 (while (and (not (= limit (point)))
6565 ;; Skip past the current button.
6566 (when (get-text-property (point) 'gnus-callback)
6567 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6568 ;; Go to the next (or previous) button.
6569 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6570 ;; Put point at the start of the button.
6571 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6572 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6573 ;; Skip past intangible buttons.
6574 (when (get-text-property (point) 'intangible)
6578 (gnus-message 5 "No more buttons"))
6581 (defun gnus-article-highlight (&optional force)
6582 "Highlight current article.
6583 This function calls `gnus-article-highlight-headers',
6584 `gnus-article-highlight-citation',
6585 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6586 do the highlighting. See the documentation for those functions."
6587 (interactive (list 'force))
6588 (gnus-article-highlight-headers)
6589 (gnus-article-highlight-citation force)
6590 (gnus-article-highlight-signature)
6591 (gnus-article-add-buttons force)
6592 (gnus-article-add-buttons-to-head))
6594 (defun gnus-article-highlight-some (&optional force)
6595 "Highlight current article.
6596 This function calls `gnus-article-highlight-headers',
6597 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6598 do the highlighting. See the documentation for those functions."
6599 (interactive (list 'force))
6600 (gnus-article-highlight-headers)
6601 (gnus-article-highlight-signature)
6602 (gnus-article-add-buttons))
6604 (defun gnus-article-highlight-headers ()
6605 "Highlight article headers as specified by `gnus-header-face-alist'."
6608 (set-buffer gnus-article-buffer)
6610 (let ((alist gnus-header-face-alist)
6611 (buffer-read-only nil)
6612 (case-fold-search t)
6613 (inhibit-point-motion-hooks t)
6614 entry regexp header-face field-face from hpoints fpoints)
6615 (article-narrow-to-head)
6616 (while (setq entry (pop alist))
6617 (goto-char (point-min))
6618 (setq regexp (concat "^\\("
6619 (if (string-equal "" (nth 0 entry))
6623 header-face (nth 1 entry)
6624 field-face (nth 2 entry))
6625 (while (and (re-search-forward regexp nil t)
6629 (unless (search-forward ":" nil t)
6631 (when (and header-face
6632 (not (memq (point) hpoints)))
6633 (push (point) hpoints)
6634 (gnus-put-text-property from (point) 'face header-face))
6635 (when (and field-face
6636 (not (memq (setq from (point)) fpoints)))
6638 (if (re-search-forward "^[^ \t]" nil t)
6640 (goto-char (point-max)))
6641 (gnus-put-text-property from (point) 'face field-face))))))))
6643 (defun gnus-article-highlight-signature ()
6644 "Highlight the signature in an article.
6645 It does this by highlighting everything after
6646 `gnus-signature-separator' using `gnus-signature-face'."
6648 (when gnus-signature-face
6650 (set-buffer gnus-article-buffer)
6651 (let ((buffer-read-only nil)
6652 (inhibit-point-motion-hooks t))
6654 (when (gnus-article-narrow-to-signature)
6655 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6656 'face gnus-signature-face)))))))
6658 (defun gnus-article-buttonize-signature ()
6659 "Add button to the signature."
6662 (set-buffer gnus-article-buffer)
6663 (let ((buffer-read-only nil)
6664 (inhibit-point-motion-hooks t))
6665 (when (gnus-article-search-signature)
6666 (gnus-article-add-button (match-beginning 0) (match-end 0)
6667 'gnus-signature-toggle
6668 (set-marker (make-marker)
6669 (1+ (match-end 0))))))))
6671 (defun gnus-button-in-region-p (b e prop)
6672 "Say whether PROP exists in the region."
6673 (text-property-not-all b e prop nil))
6675 (defun gnus-article-add-buttons (&optional force)
6676 "Find external references in the article and make buttons of them.
6677 \"External references\" are things like Message-IDs and URLs, as
6678 specified by `gnus-button-alist'."
6679 (interactive (list 'force))
6681 (set-buffer gnus-article-buffer)
6682 (let ((buffer-read-only nil)
6683 (inhibit-point-motion-hooks t)
6684 (case-fold-search t)
6685 (alist gnus-button-alist)
6687 ;; Remove all old markers.
6688 (let (marker entry new-list)
6689 (while (setq marker (pop gnus-button-marker-list))
6690 (if (or (< marker (point-min)) (>= marker (point-max)))
6691 (push marker new-list)
6693 (when (setq entry (gnus-button-entry))
6694 (put-text-property (match-beginning (nth 1 entry))
6695 (match-end (nth 1 entry))
6696 'gnus-callback nil))
6697 (set-marker marker nil)))
6698 (setq gnus-button-marker-list new-list))
6699 ;; We skip the headers.
6702 (while (setq entry (pop alist))
6703 (setq regexp (eval (car entry)))
6705 (while (re-search-forward regexp nil t)
6706 (let* ((start (and entry (match-beginning (nth 1 entry))))
6707 (end (and entry (match-end (nth 1 entry))))
6708 (from (match-beginning 0)))
6709 (when (and (or (eq t (nth 2 entry))
6710 (eval (nth 2 entry)))
6711 (not (gnus-button-in-region-p
6712 start end 'gnus-callback)))
6713 ;; That optional form returned non-nil, so we add the
6715 (gnus-article-add-button
6716 start end 'gnus-button-push
6717 (car (push (set-marker (make-marker) from)
6718 gnus-button-marker-list))))))))))
6720 ;; Add buttons to the head of an article.
6721 (defun gnus-article-add-buttons-to-head ()
6722 "Add buttons to the head of the article."
6725 (set-buffer gnus-article-buffer)
6727 (let ((buffer-read-only nil)
6728 (inhibit-point-motion-hooks t)
6729 (case-fold-search t)
6730 (alist gnus-header-button-alist)
6732 (article-narrow-to-head)
6734 ;; Each alist entry.
6735 (setq entry (car alist)
6737 (goto-char (point-min))
6738 (while (re-search-forward (car entry) nil t)
6739 ;; Each header matching the entry.
6740 (setq beg (match-beginning 0))
6741 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6742 (match-beginning 0))
6745 (while (re-search-forward (eval (nth 1 entry)) end t)
6746 ;; Each match within a header.
6747 (let* ((entry (cdr entry))
6748 (start (match-beginning (nth 1 entry)))
6749 (end (match-end (nth 1 entry)))
6750 (form (nth 2 entry)))
6751 (goto-char (match-end 0))
6753 (gnus-article-add-button
6754 start end (nth 3 entry)
6755 (buffer-substring (match-beginning (nth 4 entry))
6756 (match-end (nth 4 entry)))))))
6757 (goto-char end)))))))
6759 ;;; External functions:
6761 (defun gnus-article-add-button (from to fun &optional data)
6762 "Create a button between FROM and TO with callback FUN and data DATA."
6763 (when gnus-article-button-face
6764 (gnus-overlay-put (gnus-make-overlay from to)
6765 'face gnus-article-button-face))
6766 (gnus-add-text-properties
6768 (nconc (and gnus-article-mouse-face
6769 (list gnus-mouse-face-prop gnus-article-mouse-face))
6770 (list 'gnus-callback fun)
6771 (and data (list 'gnus-data data))))
6772 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6773 ;; Quote `:button-keymap' for Mule 2.3
6774 ;; but it won't work.
6775 ':button-keymap gnus-widget-button-keymap))
6777 ;;; Internal functions:
6779 (defun gnus-article-set-globals ()
6781 (set-buffer gnus-summary-buffer)
6782 (gnus-set-global-variables)))
6784 (defun gnus-signature-toggle (end)
6786 (set-buffer gnus-article-buffer)
6787 (let ((buffer-read-only nil)
6788 (inhibit-point-motion-hooks t)
6789 (limit (next-single-property-change end 'mime-view-entity
6791 (if (text-property-any end limit 'article-type 'signature)
6793 (gnus-delete-wash-type 'signature)
6794 (gnus-remove-text-properties-when
6795 'article-type 'signature end limit
6796 (cons 'article-type (cons 'signature
6797 gnus-hidden-properties))))
6798 (gnus-add-wash-type 'signature)
6799 (gnus-add-text-properties-when
6800 'article-type nil end limit
6801 (cons 'article-type (cons 'signature
6802 gnus-hidden-properties)))))
6803 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6804 (gnus-set-mode-line 'article))))
6806 (defun gnus-button-entry ()
6807 ;; Return the first entry in `gnus-button-alist' matching this place.
6808 (let ((alist gnus-button-alist)
6811 (setq entry (pop alist))
6812 (if (looking-at (eval (car entry)))
6817 (defun gnus-button-push (marker)
6818 ;; Push button starting at MARKER.
6821 (let* ((entry (gnus-button-entry))
6822 (inhibit-point-motion-hooks t)
6824 (args (mapcar (lambda (group)
6825 (let ((string (match-string group)))
6826 (gnus-set-text-properties
6827 0 (length string) nil string)
6834 (fboundp (symbol-value fun)))
6835 (apply (symbol-value fun) args))
6837 (gnus-message 1 "You must define `%S' to use this button"
6838 (cons fun args)))))))
6840 (defun gnus-parse-news-url (url)
6841 (let (scheme server group message-id articles)
6844 (goto-char (point-min))
6845 (when (looking-at "\\([A-Za-z]+\\):")
6846 (setq scheme (match-string 1))
6847 (goto-char (match-end 0)))
6848 (when (looking-at "//\\([^/]+\\)/")
6849 (setq server (match-string 1))
6850 (goto-char (match-end 0)))
6853 ((looking-at "\\(.*@.*\\)")
6854 (setq message-id (match-string 1)))
6855 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6856 (setq group (match-string 1)
6857 articles (split-string (match-string 2) "-")))
6858 ((looking-at "\\([^/]+\\)/?")
6859 (setq group (match-string 1)))
6861 (error "Unknown news URL syntax"))))
6862 (list scheme server group message-id articles)))
6864 (defun gnus-button-handle-news (url)
6866 (destructuring-bind (scheme server group message-id articles)
6867 (gnus-parse-news-url url)
6871 (set-buffer gnus-summary-buffer)
6873 (let ((gnus-refer-article-method (list (list 'nntp server))))
6874 (gnus-summary-refer-article message-id))
6875 (gnus-summary-refer-article message-id))))
6877 (gnus-button-fetch-group url)))))
6879 (defun gnus-button-handle-man (url)
6881 (funcall gnus-button-man-handler url))
6883 (defun gnus-button-handle-info (url)
6884 "Fetch an info URL."
6886 "^\\([^:/]+\\)?/\\(.*\\)"
6888 (gnus-info-find-node
6889 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6892 (gnus-url-unhex-string (match-string 2 url))))
6893 (error "Can't parse %s" url)))
6895 (defun gnus-button-message-id (message-id)
6898 (set-buffer gnus-summary-buffer)
6899 (gnus-summary-refer-article message-id)))
6901 (defun gnus-button-fetch-group (address)
6902 "Fetch GROUP specified by ADDRESS."
6903 (if (not (string-match "[:/]" address))
6904 ;; This is just a simple group url.
6905 (gnus-group-read-ephemeral-group address gnus-select-method)
6908 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6910 (error "Can't parse %s" address)
6911 (gnus-group-read-ephemeral-group
6912 (match-string 4 address)
6913 `(nntp ,(match-string 1 address)
6914 (nntp-address ,(match-string 1 address))
6915 (nntp-port-number ,(if (match-end 3)
6916 (match-string 3 address)
6919 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6921 (defun gnus-url-parse-query-string (query &optional downcase)
6922 (let (retval pairs cur key val)
6923 (setq pairs (split-string query "&"))
6925 (setq cur (car pairs)
6927 (if (not (string-match "=" cur))
6929 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6930 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6932 (setq key (downcase key)))
6933 (setq cur (assoc key retval))
6935 (setcdr cur (cons val (cdr cur)))
6936 (setq retval (cons (list key val) retval)))))
6939 (defun gnus-url-mailto (url)
6940 ;; Send mail to someone
6941 (when (string-match "mailto:/*\\(.*\\)" url)
6942 (setq url (substring url (match-beginning 1) nil)))
6943 (let (to args subject func)
6944 (if (string-match (regexp-quote "?") url)
6945 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6946 args (gnus-url-parse-query-string
6947 (substring url (match-end 0) nil) t))
6948 (setq to (gnus-url-unhex-string url)))
6949 (setq args (cons (list "to" to) args)
6950 subject (cdr-safe (assoc "subject" args)))
6953 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6956 (message-position-on-field (caar args)))
6957 (insert (mapconcat 'identity (cdar args) ", "))
6958 (setq args (cdr args)))
6961 (message-goto-subject))))
6963 (defun gnus-button-embedded-url (address)
6964 "Activate ADDRESS with `browse-url'."
6965 (browse-url (gnus-strip-whitespace address)))
6967 ;;; Next/prev buttons in the article buffer.
6969 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6970 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6972 (defvar gnus-prev-page-map
6973 (let ((map (make-sparse-keymap)))
6974 (unless (>= emacs-major-version 21)
6975 ;; XEmacs doesn't care.
6976 (set-keymap-parent map gnus-article-mode-map))
6977 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6978 (define-key map "\r" 'gnus-button-prev-page)
6981 (defun gnus-insert-prev-page-button ()
6983 (buffer-read-only nil)
6984 (situation (get-text-property (point-min) 'mime-view-situation)))
6986 gnus-prev-page-line-format nil
6987 `(,@(gnus-local-map-property gnus-prev-page-map)
6989 gnus-callback gnus-article-button-prev-page
6990 article-type annotation
6991 mime-view-situation ,situation))
6992 (widget-convert-button
6994 ;; Exclude a newline.
6997 :action 'gnus-button-prev-page
6998 :button-keymap gnus-prev-page-map)))
7000 (defvar gnus-next-page-map
7001 (let ((map (make-sparse-keymap)))
7002 (unless (>= emacs-major-version 21)
7003 ;; XEmacs doesn't care.
7004 (set-keymap-parent map gnus-article-mode-map))
7005 (define-key map gnus-mouse-2 'gnus-button-next-page)
7006 (define-key map "\r" 'gnus-button-next-page)
7009 (defun gnus-button-next-page (&optional args more-args)
7010 "Go to the next page."
7012 (let ((win (selected-window)))
7013 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7014 (gnus-article-next-page)
7015 (select-window win)))
7017 (defun gnus-button-prev-page (&optional args more-args)
7018 "Go to the prev page."
7020 (let ((win (selected-window)))
7021 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7022 (gnus-article-prev-page)
7023 (select-window win)))
7025 (defun gnus-insert-next-page-button ()
7027 (buffer-read-only nil)
7028 (situation (get-text-property (point-min) 'mime-view-situation)))
7029 (gnus-eval-format gnus-next-page-line-format nil
7030 `(,@(gnus-local-map-property gnus-next-page-map)
7032 gnus-callback gnus-article-button-next-page
7033 article-type annotation
7034 mime-view-situation ,situation))
7035 (widget-convert-button
7037 ;; Exclude a newline.
7040 :action 'gnus-button-next-page
7041 :button-keymap gnus-next-page-map)))
7043 (defun gnus-article-button-next-page (arg)
7044 "Go to the next page."
7046 (let ((win (selected-window)))
7047 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7048 (gnus-article-next-page)
7049 (select-window win)))
7051 (defun gnus-article-button-prev-page (arg)
7052 "Go to the prev page."
7054 (let ((win (selected-window)))
7055 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7056 (gnus-article-prev-page)
7057 (select-window win)))
7059 (defvar gnus-decode-header-methods
7060 '(mail-decode-encoded-word-region)
7061 "List of methods used to decode headers.
7063 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7064 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7065 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
7066 whose names match REGEXP.
7069 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7070 mail-decode-encoded-word-region
7071 (\"chinese\" . rfc1843-decode-region))
7074 (defvar gnus-decode-header-methods-cache nil)
7076 (defun gnus-multi-decode-header (start end)
7077 "Apply the functions from `gnus-encoded-word-methods' that match."
7078 (unless (and gnus-decode-header-methods-cache
7079 (eq gnus-newsgroup-name
7080 (car gnus-decode-header-methods-cache)))
7081 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7084 (nconc gnus-decode-header-methods-cache (list x))
7085 (if (and gnus-newsgroup-name
7086 (string-match (car x) gnus-newsgroup-name))
7087 (nconc gnus-decode-header-methods-cache
7089 gnus-decode-header-methods))
7090 (let ((xlist gnus-decode-header-methods-cache))
7093 (narrow-to-region start end)
7095 (funcall (pop xlist) (point-min) (point-max))))))
7098 ;;; Treatment top-level handling.
7101 (defun gnus-treat-article (condition &optional part-number total-parts type)
7102 (let ((length (- (point-max) (point-min)))
7103 (alist gnus-treatment-function-alist)
7104 (article-goto-body-goes-to-point-min-p t)
7108 (let ((list gnus-article-treat-types))
7110 (when (string-match (pop list) type)
7111 (throw 'found t)))))))
7112 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7113 (entity (static-unless (featurep 'xemacs)
7114 (when (eq 'head condition)
7115 (get-text-property (point-min) 'mime-view-entity))))
7116 val elem buttonized)
7117 (gnus-run-hooks 'gnus-part-display-hook)
7118 (unless gnus-inhibit-treatment
7119 (dolist (elem alist)
7122 (when (gnus-buffer-live-p gnus-summary-buffer)
7123 (set-buffer gnus-summary-buffer))
7124 (symbol-value (car elem))))
7125 (when (and (or (consp val)
7127 (gnus-treat-predicate val)
7128 (or (not (get (car elem) 'highlight))
7130 (when (and (not buttonized)
7132 '(gnus-treat-hide-signature
7133 gnus-treat-highlight-signature)))
7134 (gnus-article-buttonize-signature)
7135 (setq buttonized t))
7137 (funcall (cadr elem)))))
7138 ;; FSF Emacsen does not inherit the existing text properties
7139 ;; in the new text, so we should do it for `mime-view-entity'.
7140 (static-unless (featurep 'xemacs)
7142 (put-text-property (point-min) (point-max)
7143 'mime-view-entity entity))))))
7145 ;; Dynamic variables.
7147 (defvar part-number)
7148 (defvar total-parts)
7153 (defun gnus-treat-predicate (val)
7158 (stringp (car val)))
7159 (apply 'gnus-or (mapcar `(lambda (s)
7160 (string-match s ,(or gnus-newsgroup-name "")))
7163 (let ((pred (pop val)))
7166 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7168 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7170 (not (gnus-treat-predicate (car val))))
7172 (equal (car val) type))
7174 (error "%S is not a valid predicate" pred)))))
7184 (eq part-number total-parts))
7188 (error "%S is not a valid value" val))))
7190 (defun gnus-article-encrypt-body (protocol &optional n)
7191 "Encrypt the article body."
7194 (or gnus-article-encrypt-protocol
7195 (completing-read "Encrypt protocol: "
7196 gnus-article-encrypt-protocol-alist
7198 current-prefix-arg))
7199 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7201 (error (format "Can't find the encrypt protocol %s" protocol)))
7202 (if (member gnus-newsgroup-name '("nndraft:delayed"
7205 (error "Can't encrypt the article in group %s"
7206 gnus-newsgroup-name))
7207 (gnus-summary-iterate n
7209 (set-buffer gnus-summary-buffer)
7210 (let ((mail-parse-charset gnus-newsgroup-charset)
7211 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7212 (summary-buffer gnus-summary-buffer)
7214 (gnus-set-global-variables)
7215 (when (gnus-group-read-only-p)
7216 (error "The current newsgroup does not support article encrypt"))
7217 (gnus-summary-show-article t)
7219 (or (mail-header-references gnus-current-headers) ""))
7220 (set-buffer gnus-article-buffer)
7221 (let* ((buffer-read-only nil)
7223 (mapcar (lambda (field)
7224 (and (save-restriction
7225 (message-narrow-to-head)
7226 (goto-char (point-min))
7227 (search-forward field nil t))
7229 (message-narrow-to-field)
7231 (delete-region (point-min) (point-max))
7233 '("Content-Type:" "Content-Transfer-Encoding:"
7234 "Content-Disposition:"))))
7235 (message-narrow-to-head)
7236 (message-remove-header "MIME-Version")
7237 (goto-char (point-max))
7238 (setq point (point))
7239 (insert (apply 'concat headers))
7241 (narrow-to-region point (point-max))
7242 (let ((message-options message-options))
7243 (message-options-set 'message-sender user-mail-address)
7244 (message-options-set 'message-recipients user-mail-address)
7245 (message-options-set 'message-sign-encrypt 'not)
7247 (goto-char (point-min))
7248 (insert "MIME-Version: 1.0\n")
7250 (gnus-summary-edit-article-done
7251 references nil summary-buffer t))
7252 (when gnus-keep-backlog
7253 (gnus-backlog-remove-article
7254 (car gnus-article-current) (cdr gnus-article-current)))
7256 (when (get-buffer gnus-original-article-buffer)
7257 (set-buffer gnus-original-article-buffer)
7258 (setq gnus-original-article nil)))
7259 (when gnus-use-cache
7260 (gnus-cache-update-article
7261 (car gnus-article-current) (cdr gnus-article-current))))))))
7263 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7264 "The following specs can be used:
7265 %t The security MIME type
7268 %D Details if button is pressed")
7270 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7271 "The following specs can be used:
7272 %t The security MIME type
7275 %D Details if button is pressed")
7277 (defvar gnus-mime-security-button-line-format-alist
7278 '((?t gnus-tmp-type ?s)
7279 (?i gnus-tmp-info ?s)
7280 (?d gnus-tmp-details ?s)
7281 (?D gnus-tmp-pressed-details ?s)))
7283 (defvar gnus-mime-security-button-map
7284 (let ((map (make-sparse-keymap)))
7285 (unless (>= (string-to-number emacs-version) 21)
7286 (set-keymap-parent map gnus-article-mode-map))
7287 (define-key map gnus-mouse-2 'gnus-article-push-button)
7288 (define-key map "\r" 'gnus-article-press-button)
7291 (defvar gnus-mime-security-details-buffer nil)
7293 (defvar gnus-mime-security-button-pressed nil)
7295 (defvar gnus-mime-security-show-details-inline t
7296 "If non-nil, show details in the article buffer.")
7298 (defun gnus-mime-security-verify-or-decrypt (handle)
7299 (mm-remove-parts (cdr handle))
7300 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7301 point buffer-read-only)
7303 (goto-char (car region)))
7305 (narrow-to-region (point) (point))
7306 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7307 (let* ((mm-verify-option 'known)
7308 (mm-decrypt-option 'known)
7309 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7310 (unless (eq nparts (cdr handle))
7311 (mm-destroy-parts (cdr handle))
7312 (setcdr handle nparts))))
7313 (setq point (point))
7314 (gnus-mime-display-security handle)
7315 (goto-char (point-max)))
7317 (delete-region (point) (cdr region))
7318 (set-marker (car region) nil)
7319 (set-marker (cdr region) nil))
7322 (defun gnus-mime-security-show-details (handle)
7323 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7325 (gnus-message 5 "No details.")
7326 (if gnus-mime-security-show-details-inline
7327 (let ((gnus-mime-security-button-pressed
7328 (not (get-text-property (point) 'gnus-mime-details)))
7329 (gnus-mime-security-button-line-format
7330 (get-text-property (point) 'gnus-line-format))
7333 (while (eq (get-text-property (point) 'gnus-line-format)
7334 gnus-mime-security-button-line-format)
7338 (narrow-to-region (point) (point))
7339 (gnus-insert-mime-security-button handle))
7340 (delete-region (point)
7341 (or (text-property-not-all
7344 gnus-mime-security-button-line-format)
7347 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7348 (with-current-buffer gnus-mime-security-details-buffer
7351 (setq gnus-mime-security-details-buffer
7352 (gnus-get-buffer-create "*MIME Security Details*")))
7353 (with-current-buffer gnus-mime-security-details-buffer
7355 (goto-char (point-min)))
7356 (pop-to-buffer gnus-mime-security-details-buffer)))))
7358 (defun gnus-mime-security-press-button (handle)
7360 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7361 (gnus-mime-security-show-details handle)
7362 (gnus-mime-security-verify-or-decrypt handle))))
7364 (defun gnus-insert-mime-security-button (handle &optional displayed)
7365 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7368 (or (nth 2 (assoc protocol mm-verify-function-alist))
7369 (nth 2 (assoc protocol mm-decrypt-function-alist))
7371 (if (equal (car handle) "multipart/signed")
7372 " Signed" " Encrypted")
7375 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7378 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7379 gnus-tmp-pressed-details
7381 (setq gnus-tmp-details
7382 (if gnus-tmp-details
7383 (concat "\n" gnus-tmp-details)
7385 (setq gnus-tmp-pressed-details
7386 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7391 gnus-mime-security-button-line-format
7392 gnus-mime-security-button-line-format-alist
7393 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7394 gnus-callback gnus-mime-security-press-button
7395 gnus-line-format ,gnus-mime-security-button-line-format
7396 gnus-mime-details ,gnus-mime-security-button-pressed
7397 article-type annotation
7400 ;; Exclude a newline.
7403 (widget-convert-button
7406 :action 'gnus-widget-press-button
7407 :button-keymap gnus-mime-security-button-map
7409 (lambda (widget/window &optional overlay pos)
7410 ;; Needed to properly clear the message due to a bug in
7411 ;; wid-edit (XEmacs only).
7412 (when (boundp 'help-echo-owns-message)
7413 (setq help-echo-owns-message t))
7416 (aref gnus-mouse-2 0))))))
7418 (defun gnus-mime-display-security (handle)
7420 (narrow-to-region (point) (point))
7421 (unless (gnus-unbuttonized-mime-type-p (car handle))
7422 (gnus-insert-mime-security-button handle))
7423 (gnus-mime-display-mixed (cdr handle))
7426 (unless (gnus-unbuttonized-mime-type-p (car handle))
7427 (let ((gnus-mime-security-button-line-format
7428 gnus-mime-security-button-end-line-format))
7429 (gnus-insert-mime-security-button handle)))
7430 (mm-set-handle-multipart-parameter
7432 (cons (set-marker (make-marker) (point-min))
7433 (set-marker (make-marker) (point-max))))))
7439 (defun gnus-article-header-presentation-method (entity situation)
7440 (mime-insert-header entity)
7441 (article-decode-group-name))
7443 (set-alist 'mime-header-presentation-method-alist
7444 'gnus-original-article-mode
7445 #'gnus-article-header-presentation-method)
7447 (defun gnus-mime-preview-quitting-method ()
7448 (mime-preview-kill-buffer)
7449 (delete-other-windows)
7450 (gnus-article-show-summary)
7451 (gnus-summary-select-article gnus-show-all-headers t))
7453 (set-alist 'mime-preview-quitting-method-alist
7454 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7456 (set-alist 'mime-preview-following-method-alist
7457 'gnus-original-article-mode #'gnus-following-method)
7459 (set-alist 'mime-preview-over-to-previous-method-alist
7460 'gnus-original-article-mode
7462 (if (> (point-min) 1)
7463 (gnus-article-prev-page)
7464 (gnus-article-read-summary-keys
7465 nil (gnus-character-to-event ?P)))))
7467 (set-alist 'mime-preview-over-to-next-method-alist
7468 'gnus-original-article-mode'
7470 (if (< (point-max) (buffer-size))
7471 (gnus-article-next-page)
7472 (gnus-article-read-summary-keys
7473 nil (gnus-character-to-event ?N)))))
7483 (run-hooks 'gnus-art-load-hook)
7485 ;;; gnus-art.el ends here