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 'followup-to Followup-to identical to Newsgroups.
198 'reply-to Reply-to identical to From.
199 'date Date less than four days old.
200 'long-to To and/or Cc longer than 1024 characters.
201 'many-to Multiple To and/or Cc."
202 :type '(set (const :tag "Headers with no content." empty)
203 (const :tag "Newsgroups identical to Gnus group." newsgroups)
204 (const :tag "To identical to To-address." to-address)
205 (const :tag "Followup-to identical to Newsgroups." followup-to)
206 (const :tag "Reply-to identical to From." reply-to)
207 (const :tag "Date less than four days old." date)
208 (const :tag "To and/or Cc longer than 1024 characters." long-to)
209 (const :tag "Multiple To and/or Cc headers." many-to))
210 :group 'gnus-article-hiding)
212 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
213 "Regexp matching signature separator.
214 This can also be a list of regexps. In that case, it will be checked
215 from head to tail looking for a separator. Searches will be done from
216 the end of the buffer."
217 :type '(repeat string)
218 :group 'gnus-article-signature)
220 (defcustom gnus-signature-limit nil
221 "Provide a limit to what is considered a signature.
222 If it is a number, no signature may not be longer (in characters) than
223 that number. If it is a floating point number, no signature may be
224 longer (in lines) than that number. If it is a function, the function
225 will be called without any parameters, and if it returns nil, there is
226 no signature in the buffer. If it is a string, it will be used as a
227 regexp. If it matches, the text in question is not a signature."
228 :type '(choice (integer :value 200)
230 (function :value fun)
231 (regexp :value ".*"))
232 :group 'gnus-article-signature)
234 (defcustom gnus-hidden-properties '(invisible t intangible t)
235 "Property list to use for hiding text."
237 :group 'gnus-article-hiding)
239 ;; Fixme: This isn't the right thing for mixed graphical and and
240 ;; non-graphical frames in a session.
241 (defcustom gnus-article-x-face-command
244 (if (or (gnus-image-type-available-p 'xface)
245 (gnus-image-type-available-p 'pbm))
246 'gnus-display-x-face-in-from
247 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
248 ((and (fboundp 'image-type-available-p)
249 (module-installed-p 'x-face-e21))
250 'x-face-decode-message-header)
251 ((gnus-image-type-available-p 'pbm)
252 'gnus-display-x-face-in-from)
254 (module-installed-p 'x-face-mule))
255 'x-face-mule-gnus-article-display-x-face)
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
259 "*String or function to be executed to display an X-Face header.
260 If it is a string, the command will be executed in a sub-shell
261 asynchronously. The compressed face will be piped to this command."
263 ,@(let (x-face-e21 x-face-mule)
264 (if (featurep 'xemacs)
266 (setq x-face-e21 (module-installed-p 'x-face-e21)
267 x-face-mule (module-installed-p 'x-face-mule)))
271 (if (or (gnus-image-type-available-p 'xface)
272 (gnus-image-type-available-p 'pbm))
273 '(function-item gnus-display-x-face-in-from))
275 (fboundp 'image-type-available-p))
277 :tag "x-face-decode-message-header (x-face-e21)"
278 x-face-decode-message-header))
281 x-face-mule-gnus-article-display-x-face))
285 :group 'gnus-article-washing)
287 (defcustom gnus-article-x-face-too-ugly nil
288 "Regexp matching posters whose face shouldn't be shown automatically."
289 :type '(choice regexp (const nil))
290 :group 'gnus-article-washing)
292 (defcustom gnus-article-banner-alist nil
293 "Banner alist for stripping.
295 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
297 :type '(repeat (cons symbol regexp))
298 :group 'gnus-article-washing)
300 (gnus-define-group-parameter
303 "Alist of regexps (to match group names) and banner."
304 :variable-group gnus-article-washing
306 '(choice :tag "Banner"
308 (const :tag "Remove signature" signature)
309 (symbol :tag "Item in `gnus-article-banner-alist'" none)
311 (const :tag "None" nil))
313 "If non-nil, specify how to remove `banners' from articles.
315 Symbol `signature' means to remove signatures delimited by
316 `gnus-signature-separator'. Any other symbol is used to look up a
317 regular expression to match the banner in `gnus-article-banner-alist'.
318 A string is used as a regular expression to match the banner
321 (defcustom gnus-article-address-banner-alist nil
322 "Alist of mail addresses and banners.
323 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
324 to match a mail address in the From: header, BANNER is one of a symbol
325 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
326 If ADDRESS matches author's mail address, it will remove things like
327 advertisements. For example:
329 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
333 (regexp :tag "Address")
334 (choice :tag "Banner" :value nil
335 (const :tag "Remove signature" signature)
336 (symbol :tag "Item in `gnus-article-banner-alist'" none)
338 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defcustom gnus-emphasis-alist
343 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
348 ("_/" "/_" underline-italic)
349 ("_\\*" "\\*_" underline-bold)
350 ("\\*/" "/\\*" bold-italic)
351 ("_\\*/" "/\\*_" underline-bold-italic))))
355 (format format (car spec) (car (cdr spec)))
356 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
358 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
359 2 3 gnus-emphasis-strikethru)
360 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
361 2 3 gnus-emphasis-underline)))
362 "*Alist that says how to fontify certain phrases.
363 Each item looks like this:
365 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
367 The first element is a regular expression to be matched. The second
368 is a number that says what regular expression grouping used to find
369 the entire emphasized word. The third is a number that says what
370 regexp grouping should be displayed and highlighted. The fourth
371 is the face used for highlighting."
372 :type '(repeat (list :value ("" 0 0 default)
374 (integer :tag "Match group")
375 (integer :tag "Emphasize group")
377 :group 'gnus-article-emphasis)
379 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
380 "A regexp to describe whitespace which should not be emphasized.
381 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
382 The former avoids underlining of leading and trailing whitespace,
383 and the latter avoids underlining any whitespace at all."
385 :group 'gnus-article-emphasis
388 (defface gnus-emphasis-bold '((t (:bold t)))
389 "Face used for displaying strong emphasized text (*word*)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-italic '((t (:italic t)))
393 "Face used for displaying italic emphasized text (/word/)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-underline '((t (:underline t)))
397 "Face used for displaying underlined emphasized text (_word_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
401 "Face used for displaying underlined bold emphasized text (_*word*_)."
402 :group 'gnus-article-emphasis)
404 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
405 "Face used for displaying underlined italic emphasized text (_/word/_)."
406 :group 'gnus-article-emphasis)
408 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
409 "Face used for displaying bold italic emphasized text (/*word*/)."
410 :group 'gnus-article-emphasis)
412 (defface gnus-emphasis-underline-bold-italic
413 '((t (:bold t :italic t :underline t)))
414 "Face used for displaying underlined bold italic emphasized text.
415 Example: (_/*word*/_)."
416 :group 'gnus-article-emphasis)
418 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
419 "Face used for displaying strike-through text (-word-)."
420 :group 'gnus-article-emphasis)
422 (defface gnus-emphasis-highlight-words
423 '((t (:background "black" :foreground "yellow")))
424 "Face used for displaying highlighted words."
425 :group 'gnus-article-emphasis)
427 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
428 "Format for display of Date headers in article bodies.
429 See `format-time-string' for the possible values.
431 The variable can also be function, which should return a complete Date
432 header. The function is called with one argument, the time, which can
433 be fed to `format-time-string'."
434 :type '(choice string symbol)
435 :link '(custom-manual "(gnus)Article Date")
436 :group 'gnus-article-washing)
439 (autoload 'mail-extract-address-components "mail-extr"))
441 (defcustom gnus-save-all-headers t
442 "*If non-nil, don't remove any headers before saving."
443 :group 'gnus-article-saving
446 (defcustom gnus-prompt-before-saving 'always
447 "*This variable says how much prompting is to be done when saving articles.
448 If it is nil, no prompting will be done, and the articles will be
449 saved to the default files. If this variable is `always', each and
450 every article that is saved will be preceded by a prompt, even when
451 saving large batches of articles. If this variable is neither nil not
452 `always', there the user will be prompted once for a file name for
453 each invocation of the saving commands."
454 :group 'gnus-article-saving
455 :type '(choice (item always)
456 (item :tag "never" nil)
457 (sexp :tag "once" :format "%t\n" :value t)))
459 (defcustom gnus-saved-headers gnus-visible-headers
460 "Headers to keep if `gnus-save-all-headers' is nil.
461 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
462 If that variable is nil, however, all headers that match this regexp
463 will be kept while the rest will be deleted before saving."
464 :group 'gnus-article-saving
467 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
468 "A function to save articles in your favourite format.
469 The function must be interactively callable (in other words, it must
470 be an Emacs command).
472 Gnus provides the following functions:
474 * gnus-summary-save-in-rmail (Rmail format)
475 * gnus-summary-save-in-mail (Unix mail format)
476 * gnus-summary-save-in-folder (MH folder)
477 * gnus-summary-save-in-file (article format)
478 * gnus-summary-save-body-in-file (article body)
479 * gnus-summary-save-in-vm (use VM's folder format)
480 * gnus-summary-write-to-file (article format -- overwrite)."
481 :group 'gnus-article-saving
482 :type '(radio (function-item gnus-summary-save-in-rmail)
483 (function-item gnus-summary-save-in-mail)
484 (function-item gnus-summary-save-in-folder)
485 (function-item gnus-summary-save-in-file)
486 (function-item gnus-summary-save-body-in-file)
487 (function-item gnus-summary-save-in-vm)
488 (function-item gnus-summary-write-to-file)))
490 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
491 "A function generating a file name to save articles in Rmail format.
492 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
493 :group 'gnus-article-saving
496 (defcustom gnus-mail-save-name 'gnus-plain-save-name
497 "A function generating a file name to save articles in Unix mail format.
498 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
499 :group 'gnus-article-saving
502 (defcustom gnus-folder-save-name 'gnus-folder-save-name
503 "A function generating a file name to save articles in MH folder.
504 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
505 :group 'gnus-article-saving
508 (defcustom gnus-file-save-name 'gnus-numeric-save-name
509 "A function generating a file name to save articles in article format.
510 The function is called with NEWSGROUP, HEADERS, and optional
512 :group 'gnus-article-saving
515 (defcustom gnus-split-methods
516 '((gnus-article-archive-name)
517 (gnus-article-nndoc-name))
518 "*Variable used to suggest where articles are to be saved.
519 For instance, if you would like to save articles related to Gnus in
520 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
521 you could set this variable to something like:
523 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
524 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
526 This variable is an alist where the where the key is the match and the
527 value is a list of possible files to save in if the match is non-nil.
529 If the match is a string, it is used as a regexp match on the
530 article. If the match is a symbol, that symbol will be funcalled
531 from the buffer of the article to be saved with the newsgroup as the
532 parameter. If it is a list, it will be evaled in the same buffer.
534 If this form or function returns a string, this string will be used as
535 a possible file name; and if it returns a non-nil list, that list will
536 be used as possible file names."
537 :group 'gnus-article-saving
538 :type '(repeat (choice (list :value (fun) function)
539 (cons :value ("" "") regexp (repeat string))
542 (defcustom gnus-article-display-method-for-mime
543 'gnus-article-display-mime-message
544 "Function to display a MIME message.
545 The function is called from the article buffer."
546 :group 'gnus-article-mime
549 (defcustom gnus-article-display-method-for-traditional
550 'gnus-article-display-traditional-message
551 "*Function to display a traditional message.
552 The function is called from the article buffer."
553 :group 'gnus-article-mime
556 (defcustom gnus-page-delimiter "^\^L"
557 "*Regexp describing what to use as article page delimiters.
558 The default value is \"^\^L\", which is a form linefeed at the
559 beginning of a line."
561 :group 'gnus-article-various)
563 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
564 "*The format specification for the article mode line.
565 See `gnus-summary-mode-line-format' for a closer description.
567 The following additional specs are available:
569 %w The article washing status.
570 %m The number of MIME parts in the article."
572 :group 'gnus-article-various)
574 (defcustom gnus-article-mode-hook nil
575 "*A hook for Gnus article mode."
577 :group 'gnus-article-various)
579 (when (featurep 'xemacs)
580 ;; Extracted from gnus-xmas-define in order to preserve user settings
581 (when (fboundp 'turn-off-scroll-in-place)
582 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
583 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
584 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
586 (defcustom gnus-article-menu-hook nil
587 "*Hook run after the creation of the article mode menu."
589 :group 'gnus-article-various)
591 (defcustom gnus-article-prepare-hook nil
592 "*A hook called after an article has been prepared in the article buffer."
594 :group 'gnus-article-various)
596 (defvar gnus-article-hide-pgp-hook nil)
597 (make-obsolete-variable 'gnus-article-hide-pgp-hook
598 "This variable is obsolete in Gnus 5.10.")
600 (defcustom gnus-article-button-face 'bold
601 "Face used for highlighting buttons in the article buffer.
603 An article button is a piece of text that you can activate by pressing
604 `RET' or `mouse-2' above it."
606 :group 'gnus-article-buttons)
608 (defcustom gnus-article-mouse-face 'highlight
609 "Face used for mouse highlighting in the article buffer.
611 Article buttons will be displayed in this face when the cursor is
614 :group 'gnus-article-buttons)
616 (defcustom gnus-signature-face 'gnus-signature-face
617 "Face used for highlighting a signature in the article buffer.
618 Obsolete; use the face `gnus-signature-face' for customizations instead."
620 :group 'gnus-article-highlight
621 :group 'gnus-article-signature)
623 (defface gnus-signature-face
626 "Face used for highlighting a signature in the article buffer."
627 :group 'gnus-article-highlight
628 :group 'gnus-article-signature)
630 (defface gnus-header-from-face
633 (:foreground "spring green"))
636 (:foreground "red3"))
639 "Face used for displaying from headers."
640 :group 'gnus-article-headers
641 :group 'gnus-article-highlight)
643 (defface gnus-header-subject-face
646 (:foreground "SeaGreen3"))
649 (:foreground "red4"))
651 (:bold t :italic t)))
652 "Face used for displaying subject headers."
653 :group 'gnus-article-headers
654 :group 'gnus-article-highlight)
656 (defface gnus-header-newsgroups-face
659 (:foreground "yellow" :italic t))
662 (:foreground "MidnightBlue" :italic t))
665 "Face used for displaying newsgroups headers."
666 :group 'gnus-article-headers
667 :group 'gnus-article-highlight)
669 (defface gnus-header-name-face
672 (:foreground "SeaGreen"))
675 (:foreground "maroon"))
678 "Face used for displaying header names."
679 :group 'gnus-article-headers
680 :group 'gnus-article-highlight)
682 (defface gnus-header-content-face
685 (:foreground "forest green" :italic t))
688 (:foreground "indianred4" :italic t))
691 "Face used for displaying header content."
692 :group 'gnus-article-headers
693 :group 'gnus-article-highlight)
695 (defcustom gnus-header-face-alist
696 '(("From" nil gnus-header-from-face)
697 ("Subject" nil gnus-header-subject-face)
698 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
699 ("" gnus-header-name-face gnus-header-content-face))
700 "*Controls highlighting of article header.
702 An alist of the form (HEADER NAME CONTENT).
704 HEADER is a regular expression which should match the name of an
705 header header and NAME and CONTENT are either face names or nil.
707 The name of each header field will be displayed using the face
708 specified by the first element in the list where HEADER match the
709 header name and NAME is non-nil. Similarly, the content will be
710 displayed by the first non-nil matching CONTENT face."
711 :group 'gnus-article-headers
712 :group 'gnus-article-highlight
713 :type '(repeat (list (regexp :tag "Header")
715 (item :tag "skip" nil)
716 (face :value default))
717 (choice :tag "Content"
718 (item :tag "skip" nil)
719 (face :value default)))))
721 (defcustom gnus-article-decode-hook nil
722 "*Hook run to decode charsets in articles."
723 :group 'gnus-article-headers
726 (defcustom gnus-display-mime-function 'gnus-display-mime
727 "Function to display MIME articles."
728 :group 'gnus-article-mime
731 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
732 "Function used to decode headers.")
734 (defvar gnus-article-dumbquotes-map
754 "Table for MS-to-Latin1 translation.")
756 (defcustom gnus-ignored-mime-types nil
757 "List of MIME types that should be ignored by Gnus."
759 :group 'gnus-article-mime
760 :type '(repeat regexp))
762 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
763 "List of MIME types that should not be given buttons when rendered inline.
764 See also `gnus-buttonized-mime-types' which may override this variable.
765 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
767 :group 'gnus-article-mime
768 :type '(repeat regexp))
770 (defcustom gnus-buttonized-mime-types nil
771 "List of MIME types that should be given buttons when rendered inline.
772 If set, this variable overrides `gnus-unbuttonized-mime-types'.
773 To see e.g. security buttons you could set this to
774 `(\"multipart/signed\")'.
775 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
777 :group 'gnus-article-mime
778 :type '(repeat regexp))
780 (defcustom gnus-inhibit-mime-unbuttonizing nil
781 "If non-nil, all MIME parts get buttons.
782 When nil (the default value), then some MIME parts do not get buttons,
783 as described by the variables `gnus-buttonized-mime-types' and
784 `gnus-unbuttonized-mime-types'."
788 (defcustom gnus-body-boundary-delimiter "_"
789 "String used to delimit header and body.
790 This variable is used by `gnus-article-treat-body-boundary' which can
791 be controlled by `gnus-treat-body-boundary'."
792 :group 'gnus-article-various
793 :type '(choice (item :tag "None" :value nil)
796 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
797 "Defines the location of the faces database.
798 For information on obtaining this database of pretty pictures, please
799 see http://www.cs.indiana.edu/picons/ftp/index.html"
800 :type '(repeat directory)
801 :link '(url-link :tag "download"
802 "http://www.cs.indiana.edu/picons/ftp/index.html")
803 :link '(custom-manual "(gnus)Picons")
806 (defun gnus-picons-installed-p ()
807 "Say whether picons are installed on your machine."
808 (let ((installed nil))
809 (dolist (database gnus-picon-databases)
810 (when (file-exists-p database)
814 (defcustom gnus-article-mime-part-function nil
815 "Function called with a MIME handle as the argument.
816 This is meant for people who want to do something automatic based
817 on parts -- for instance, adding Vcard info to a database."
818 :group 'gnus-article-mime
821 (defcustom gnus-mime-multipart-functions nil
822 "An alist of MIME types to functions to display them."
824 :group 'gnus-article-mime
827 (defcustom gnus-article-date-lapsed-new-header nil
828 "Whether the X-Sent and Date headers can coexist.
829 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
830 either replace the old \"Date:\" header (if this variable is nil), or
831 be added below it (otherwise)."
833 :group 'gnus-article-headers
836 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
837 "Function called with a MIME handle as the argument.
838 This is meant for people who want to view first matched part.
839 For `undisplayed-alternative' (default), the first undisplayed
840 part or alternative part is used. For `undisplayed', the first
841 undisplayed part is used. For a function, the first part which
842 the function return t is used. For nil, the first part is
845 :group 'gnus-article-mime
847 (item :tag "first" :value nil)
848 (item :tag "undisplayed" :value undisplayed)
849 (item :tag "undisplayed or alternative"
850 :value undisplayed-alternative)
853 (defcustom gnus-mime-action-alist
854 '(("save to file" . gnus-mime-save-part)
855 ("save and strip" . gnus-mime-save-part-and-strip)
856 ("display as text" . gnus-mime-inline-part)
857 ("view the part" . gnus-mime-view-part)
858 ("pipe to command" . gnus-mime-pipe-part)
859 ("toggle display" . gnus-article-press-button)
860 ("toggle display" . gnus-article-view-part-as-charset)
861 ("view as type" . gnus-mime-view-part-as-type)
862 ("view internally" . gnus-mime-view-part-internally)
863 ("view externally" . gnus-mime-view-part-externally))
864 "An alist of actions that run on the MIME attachment."
865 :group 'gnus-article-mime
866 :type '(repeat (cons (string :tag "name")
870 ;;; The treatment variables
873 (defvar gnus-part-display-hook nil
874 "Hook called on parts that are to receive treatment.")
876 (defvar gnus-article-treat-custom
877 '(choice (const :tag "Off" nil)
879 (const :tag "Header" head)
880 (const :tag "Last" last)
881 (const :tag "Mime" mime)
882 (integer :tag "Less")
883 (repeat :tag "Groups" regexp)
884 (sexp :tag "Predicate")))
886 (defvar gnus-article-treat-head-custom
887 '(choice (const :tag "Off" nil)
888 (const :tag "Header" head)))
890 (defvar gnus-article-treat-types '("text/plain")
893 (defvar gnus-inhibit-treatment nil
894 "Whether to inhibit treatment.")
896 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
897 "Highlight the signature.
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles'."
900 :group 'gnus-article-treat
901 :link '(custom-manual "(gnus)Customizing Articles")
902 :type gnus-article-treat-custom)
903 (put 'gnus-treat-highlight-signature 'highlight t)
905 (defcustom gnus-treat-buttonize 100000
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles'."
909 :group 'gnus-article-treat
910 :link '(custom-manual "(gnus)Customizing Articles")
911 :type gnus-article-treat-custom)
912 (put 'gnus-treat-buttonize 'highlight t)
914 (defcustom gnus-treat-buttonize-head 'head
915 "Add buttons to the head.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-head-custom)
921 (put 'gnus-treat-buttonize-head 'highlight t)
923 (defcustom gnus-treat-emphasize
924 (and (or window-system
926 (>= (string-to-number emacs-version) 21))
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See Info node `(gnus)Customizing Articles' for details."
931 :group 'gnus-article-treat
932 :link '(custom-manual "(gnus)Customizing Articles")
933 :type gnus-article-treat-custom)
934 (put 'gnus-treat-emphasize 'highlight t)
936 (defcustom gnus-treat-strip-cr nil
937 "Remove carriage returns.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :link '(custom-manual "(gnus)Customizing Articles")
942 :type gnus-article-treat-custom)
944 (defcustom gnus-treat-unsplit-urls nil
945 "Remove newlines from within URLs.
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)
952 (defcustom gnus-treat-leading-whitespace nil
953 "Remove leading whitespace in headers.
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles' for details."
956 :group 'gnus-article-treat
957 :link '(custom-manual "(gnus)Customizing Articles")
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-hide-headers 'head
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-head-custom)
968 (defcustom gnus-treat-hide-boring-headers nil
969 "Hide boring headers.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
972 :group 'gnus-article-treat
973 :link '(custom-manual "(gnus)Customizing Articles")
974 :type gnus-article-treat-head-custom)
976 (defcustom gnus-treat-hide-signature nil
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles' for details."
980 :group 'gnus-article-treat
981 :link '(custom-manual "(gnus)Customizing Articles")
982 :type gnus-article-treat-custom)
984 (defcustom gnus-treat-fill-article nil
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :link '(custom-manual "(gnus)Customizing Articles")
990 :type gnus-article-treat-custom)
992 (defcustom gnus-treat-hide-citation nil
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :link '(custom-manual "(gnus)Customizing Articles")
998 :type gnus-article-treat-custom)
1000 (defcustom gnus-treat-hide-citation-maybe nil
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-strip-list-identifiers 'head
1009 "Strip list identifiers from `gnus-list-identifiers`.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 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 (make-obsolete-variable 'gnus-treat-strip-pgp
1018 "This option is obsolete in Gnus 5.10.")
1020 (defcustom gnus-treat-strip-pem nil
1021 "Strip PEM signatures.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-strip-banner t
1029 "Strip banners from articles.
1030 The banner to be stripped is specified in the `banner' group parameter.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-highlight-headers 'head
1038 "Highlight the headers.
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-head-custom)
1044 (put 'gnus-treat-highlight-headers 'highlight t)
1046 (defcustom gnus-treat-highlight-citation t
1047 "Highlight cited text.
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)
1053 (put 'gnus-treat-highlight-citation 'highlight t)
1055 (defcustom gnus-treat-date-ut nil
1056 "Display the Date in UT (GMT).
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-head-custom)
1063 (defcustom gnus-treat-date-local nil
1064 "Display the Date in the local timezone.
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-head-custom)
1071 (defcustom gnus-treat-date-english nil
1072 "Display the Date in a format that can be read aloud in English.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-head-custom)
1079 (defcustom gnus-treat-date-lapsed nil
1080 "Display the Date header in a way that says how much time has elapsed.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-head-custom)
1087 (defcustom gnus-treat-date-original nil
1088 "Display the date in the original timezone.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-head-custom)
1095 (defcustom gnus-treat-date-iso8601 nil
1096 "Display the date in the ISO8601 format.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 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-user-defined nil
1105 "Display the date in a user-defined format.
1106 The format is defined by the `gnus-article-time-format' variable.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1113 (defcustom gnus-treat-strip-headers-in-body t
1114 "Strip the X-No-Archive header line from the beginning of the body.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-strip-trailing-blank-lines nil
1123 "Strip trailing blank lines.
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-custom)
1130 (defcustom gnus-treat-strip-leading-blank-lines nil
1131 "Strip leading blank lines.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-strip-multiple-blank-lines nil
1139 "Strip multiple blank lines.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1146 (defcustom gnus-treat-unfold-headers 'head
1147 "Unfold folded header lines.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom)
1154 (defcustom gnus-treat-fold-headers nil
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1162 (defcustom gnus-treat-fold-newsgroups 'head
1163 "Fold the Newsgroups and Followup-To headers.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-custom)
1170 (defcustom gnus-treat-overstrike t
1171 "Treat overstrike highlighting.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1177 (put 'gnus-treat-overstrike 'highlight t)
1179 (defcustom gnus-treat-display-xface
1180 (and (not noninteractive)
1181 (or (and (fboundp 'image-type-available-p)
1182 (image-type-available-p 'xbm)
1183 (string-match "^0x" (shell-command-to-string "uncompface")))
1184 (and (featurep 'xemacs)
1186 (eq 'x-face-mule-gnus-article-display-x-face
1187 gnus-article-x-face-command))
1189 "Display X-Face headers.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' and Info node
1192 `(gnus)X-Face' for details."
1193 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :link '(custom-manual "(gnus)X-Face")
1197 :type gnus-article-treat-head-custom)
1198 (put 'gnus-treat-display-xface 'highlight t)
1200 (defcustom gnus-article-should-use-smiley-mule
1201 (not (or (featurep 'xemacs)
1202 (gnus-image-type-available-p 'xpm)
1203 (gnus-image-type-available-p 'pbm)))
1204 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1205 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1206 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1207 even if you are using Emacs 21+. It has no effect on XEmacs."
1208 :group 'gnus-article-various
1210 :get (lambda (symbol)
1211 (and (default-value symbol)
1212 (not (featurep 'xemacs))
1213 (module-installed-p 'smiley-mule)
1215 :set (lambda (symbol value)
1216 (set-default symbol (and value
1217 (not (featurep 'xemacs))
1218 (module-installed-p 'smiley-mule)
1221 (defvar gnus-article-smiley-mule-loaded-p nil
1222 "Internal variable used to say whether `smiley-mule' is loaded (whether
1223 smiley functions are not overridden by `smiley').")
1225 (defcustom gnus-treat-display-face
1226 (and (not noninteractive)
1227 (or (and (fboundp 'image-type-available-p)
1228 (image-type-available-p 'png))
1229 (and (featurep 'xemacs)
1232 "Display Face headers.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' and Info node
1235 `(gnus)X-Face' for details."
1236 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :link '(custom-manual "(gnus)X-Face")
1240 :type gnus-article-treat-head-custom)
1241 (put 'gnus-treat-display-face 'highlight t)
1243 (defcustom gnus-treat-display-smileys
1244 (if (or (and (featurep 'xemacs)
1246 (gnus-image-type-available-p 'xpm)
1247 (gnus-image-type-available-p 'pbm)
1248 (and (not (featurep 'xemacs))
1250 (module-installed-p 'smiley-mule)))
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' and Info node
1256 `(gnus)Smileys' for details."
1257 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :link '(custom-manual "(gnus)Smileys")
1261 :type gnus-article-treat-custom)
1262 (put 'gnus-treat-display-smileys 'highlight t)
1264 (defcustom gnus-treat-from-picon
1265 (if (and (gnus-image-type-available-p 'xpm)
1266 (gnus-picons-installed-p))
1268 "Display picons in the From header.
1269 Valid values are nil, t, `head', `last', an integer or a predicate.
1270 See Info node `(gnus)Customizing Articles' and Info node
1271 `(gnus)Picons' for details."
1272 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :link '(custom-manual "(gnus)Picons")
1276 :type gnus-article-treat-head-custom)
1277 (put 'gnus-treat-from-picon 'highlight t)
1279 (defcustom gnus-treat-mail-picon
1280 (if (and (gnus-image-type-available-p 'xpm)
1281 (gnus-picons-installed-p))
1283 "Display picons in To and Cc headers.
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' and Info node
1286 `(gnus)Picons' for details."
1287 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :link '(custom-manual "(gnus)Picons")
1291 :type gnus-article-treat-head-custom)
1292 (put 'gnus-treat-mail-picon 'highlight t)
1294 (defcustom gnus-treat-newsgroups-picon
1295 (if (and (gnus-image-type-available-p 'xpm)
1296 (gnus-picons-installed-p))
1298 "Display picons in the Newsgroups and Followup-To headers.
1299 Valid values are nil, t, `head', `last', an integer or a predicate.
1300 See Info node `(gnus)Customizing Articles' and Info node
1301 `(gnus)Picons' for details."
1302 :group 'gnus-article-treat
1304 :link '(custom-manual "(gnus)Customizing Articles")
1305 :link '(custom-manual "(gnus)Picons")
1306 :type gnus-article-treat-head-custom)
1307 (put 'gnus-treat-newsgroups-picon 'highlight t)
1309 (defcustom gnus-treat-body-boundary
1310 (if (or gnus-treat-newsgroups-picon
1311 gnus-treat-mail-picon
1312 gnus-treat-from-picon)
1314 "Draw a boundary at the end of the headers.
1315 Valid values are nil, t, `head', `last', an integer or a predicate.
1316 See Info node `(gnus)Customizing Articles' for details."
1318 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom)
1322 (defcustom gnus-treat-capitalize-sentences nil
1323 "Capitalize sentence-starting words.
1324 Valid values are nil, t, `head', `last', an integer or a predicate.
1325 See Info node `(gnus)Customizing Articles' for details."
1327 :group 'gnus-article-treat
1328 :link '(custom-manual "(gnus)Customizing Articles")
1329 :type gnus-article-treat-custom)
1331 (defcustom gnus-treat-wash-html nil
1333 Valid values are nil, t, `head', `last', an integer or a predicate.
1334 See Info node `(gnus)Customizing Articles' for details."
1335 :group 'gnus-article-treat
1336 :link '(custom-manual "(gnus)Customizing Articles")
1337 :type gnus-article-treat-custom)
1339 (defcustom gnus-treat-fill-long-lines nil
1341 Valid values are nil, t, `head', `last', an integer or a predicate.
1342 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-play-sounds nil
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-decode-article-as-default-mime-charset nil
1357 "Decode an article as `default-mime-charset'. For instance, if you want to
1358 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1359 you could set this variable to something like: nil for don't decode, t for
1360 decode the body, '(or header t) for the whole article, etc."
1361 :group 'gnus-article-treat
1362 :type '(radio (const :tag "Off" nil)
1363 (const :tag "Decode body" t)
1364 (const :tag "Decode all" (or head t))))
1366 (defcustom gnus-treat-translate nil
1367 "Translate articles from one language to another.
1368 Valid values are nil, t, `head', `last', an integer or a predicate.
1369 See Info node `(gnus)Customizing Articles' for details."
1371 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :type gnus-article-treat-custom)
1375 (defcustom gnus-treat-x-pgp-sig nil
1377 To automatically treat X-PGP-Sig, set it to head.
1378 Valid values are nil, t, `head', `last', an integer or a predicate.
1379 See Info node `(gnus)Customizing Articles' for details."
1380 :group 'gnus-article-treat
1381 :group 'mime-security
1382 :type gnus-article-treat-custom)
1384 (defcustom gnus-treat-monafy nil
1385 "Display body part with mona font.
1386 Valid values are nil, t, `head', `last', an integer or a predicate.
1387 See Info node `(gnus)Customizing Articles' for details."
1388 :group 'gnus-article-treat
1389 :group 'mime-security
1390 :link '(custom-manual "(gnus)Customizing Articles")
1391 :type gnus-article-treat-custom)
1393 (defvar gnus-article-encrypt-protocol-alist
1394 '(("PGP" . mml2015-self-encrypt)))
1396 ;; Set to nil if more than one protocol added to
1397 ;; gnus-article-encrypt-protocol-alist.
1398 (defcustom gnus-article-encrypt-protocol "PGP"
1399 "The protocol used for encrypt articles.
1400 It is a string, such as \"PGP\". If nil, ask user."
1402 :group 'mime-security)
1404 (defvar gnus-article-wash-function nil
1405 "Function used for converting HTML into text.")
1407 ;;; Internal variables
1409 (defvar gnus-english-month-names
1410 '("January" "February" "March" "April" "May" "June" "July" "August"
1411 "September" "October" "November" "December"))
1413 (defvar article-goto-body-goes-to-point-min-p nil)
1414 (defvar gnus-article-wash-types nil)
1415 (defvar gnus-article-emphasis-alist nil)
1416 (defvar gnus-article-image-alist nil)
1418 (defvar gnus-article-mime-handle-alist-1 nil)
1419 (defvar gnus-treatment-function-alist
1420 '((gnus-treat-decode-article-as-default-mime-charset
1421 gnus-article-decode-article-as-default-mime-charset)
1422 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1423 (gnus-treat-monafy gnus-article-monafy)
1424 (gnus-treat-strip-banner gnus-article-strip-banner)
1425 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1426 (gnus-treat-buttonize gnus-article-add-buttons)
1427 (gnus-treat-fill-article gnus-article-fill-cited-article)
1428 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1429 (gnus-treat-strip-cr gnus-article-remove-cr)
1430 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1431 (gnus-treat-date-ut gnus-article-date-ut)
1432 (gnus-treat-date-local gnus-article-date-local)
1433 (gnus-treat-date-english gnus-article-date-english)
1434 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1435 (gnus-treat-date-original gnus-article-date-original)
1436 (gnus-treat-date-user-defined gnus-article-date-user)
1437 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1438 (gnus-treat-display-face gnus-article-display-face)
1439 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1440 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1441 (gnus-treat-hide-signature gnus-article-hide-signature)
1442 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1443 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1444 (gnus-treat-strip-pem gnus-article-hide-pem)
1445 (gnus-treat-from-picon gnus-treat-from-picon)
1446 (gnus-treat-mail-picon gnus-treat-mail-picon)
1447 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1448 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1449 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1450 (gnus-treat-strip-trailing-blank-lines
1451 gnus-article-remove-trailing-blank-lines)
1452 (gnus-treat-strip-leading-blank-lines
1453 gnus-article-strip-leading-blank-lines)
1454 (gnus-treat-strip-multiple-blank-lines
1455 gnus-article-strip-multiple-blank-lines)
1456 (gnus-treat-overstrike gnus-article-treat-overstrike)
1457 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1458 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1459 ;; Displaying X-Face should be done after unfolding headers
1460 ;; to protect bitmap lines.
1461 (gnus-treat-display-xface gnus-article-display-x-face)
1462 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1463 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1464 (gnus-treat-display-smileys gnus-treat-smiley)
1465 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1466 (gnus-treat-wash-html gnus-article-wash-html)
1467 (gnus-treat-emphasize gnus-article-emphasize)
1468 (gnus-treat-hide-citation gnus-article-hide-citation)
1469 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1470 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1471 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1472 (gnus-treat-play-sounds gnus-earcon-display)))
1474 (defvar gnus-article-mime-handle-alist nil)
1475 (defvar article-lapsed-timer nil)
1476 (defvar gnus-article-current-summary nil)
1478 (defvar gnus-article-mode-syntax-table
1479 (let ((table (copy-syntax-table text-mode-syntax-table)))
1480 ;; This causes the citation match run O(2^n).
1481 ;; (modify-syntax-entry ?- "w" table)
1482 (modify-syntax-entry ?> ")<" table)
1483 (modify-syntax-entry ?< "(>" table)
1484 ;; make M-. in article buffers work for `foo' strings
1485 (modify-syntax-entry ?' " " table)
1486 (modify-syntax-entry ?` " " table)
1488 "Syntax table used in article mode buffers.
1489 Initialized from `text-mode-syntax-table.")
1491 (defvar gnus-save-article-buffer nil)
1493 (defvar gnus-article-mode-line-format-alist
1494 (nconc '((?w (gnus-article-wash-status) ?s)
1495 (?m (gnus-article-mime-part-status) ?s))
1496 gnus-summary-mode-line-format-alist))
1498 (defvar gnus-number-of-articles-to-be-saved nil)
1500 (defvar gnus-inhibit-hiding nil)
1502 ;;; Macros for dealing with the article buffer.
1504 (defmacro gnus-with-article-headers (&rest forms)
1506 (set-buffer gnus-article-buffer)
1508 (let ((buffer-read-only nil)
1509 (inhibit-point-motion-hooks t)
1510 (case-fold-search t))
1511 (article-narrow-to-head)
1514 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1515 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1517 (defmacro gnus-with-article-buffer (&rest forms)
1519 (set-buffer gnus-article-buffer)
1520 (let ((buffer-read-only nil))
1523 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1524 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1526 (defun gnus-article-goto-header (header)
1527 "Go to HEADER, which is a regular expression."
1528 (re-search-forward (concat "^\\(" header "\\):") nil t))
1530 (defsubst gnus-article-hide-text (b e props)
1531 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1532 (gnus-add-text-properties-when 'article-type nil b e props)
1533 (when (memq 'intangible props)
1535 (max (1- b) (point-min))
1536 b 'intangible (cddr (memq 'intangible props)))))
1538 (defsubst gnus-article-unhide-text (b e)
1539 "Remove hidden text properties from region between B and E."
1540 (remove-text-properties b e gnus-hidden-properties)
1541 (when (memq 'intangible gnus-hidden-properties)
1542 (put-text-property (max (1- b) (point-min))
1543 b 'intangible nil)))
1545 (defun gnus-article-hide-text-type (b e type)
1546 "Hide text of TYPE between B and E."
1547 (gnus-add-wash-type type)
1548 (gnus-article-hide-text
1549 b e (cons 'article-type (cons type gnus-hidden-properties))))
1551 (defun gnus-article-unhide-text-type (b e type)
1552 "Unhide text of TYPE between B and E."
1553 (gnus-delete-wash-type type)
1554 (remove-text-properties
1555 b e (cons 'article-type (cons type gnus-hidden-properties)))
1556 (when (memq 'intangible gnus-hidden-properties)
1557 (put-text-property (max (1- b) (point-min))
1558 b 'intangible nil)))
1560 (defun gnus-article-hide-text-of-type (type)
1561 "Hide text of TYPE in the current buffer."
1563 (let ((b (point-min))
1565 (while (setq b (text-property-any b e 'article-type type))
1566 (add-text-properties b (incf b) gnus-hidden-properties)))))
1568 (defun gnus-article-delete-text-of-type (type)
1569 "Delete text of TYPE in the current buffer."
1571 (let ((b (point-min)))
1572 (while (setq b (text-property-any b (point-max) 'article-type type))
1574 b (or (text-property-not-all b (point-max) 'article-type type)
1577 (defun gnus-article-delete-invisible-text ()
1578 "Delete all invisible text in the current buffer."
1580 (let ((b (point-min)))
1581 (while (setq b (text-property-any b (point-max) 'invisible t))
1583 b (or (text-property-not-all b (point-max) 'invisible t)
1586 (defun gnus-article-text-type-exists-p (type)
1587 "Say whether any text of type TYPE exists in the buffer."
1588 (text-property-any (point-min) (point-max) 'article-type type))
1590 (defsubst gnus-article-header-rank ()
1591 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1592 (let ((list gnus-sorted-header-list)
1595 (if (looking-at (car list))
1597 (setq list (cdr list))
1601 (defun article-hide-headers (&optional arg delete)
1602 "Hide unwanted headers and possibly sort them as well."
1603 (interactive (gnus-article-hidden-arg))
1604 ;; Lars said that this function might be inhibited.
1605 (if (gnus-article-check-hidden-text 'headers arg)
1607 ;; Show boring headers as well.
1608 (gnus-article-show-hidden-text 'boring-headers)
1609 (when (eq 1 (point-min))
1610 (set-window-start (get-buffer-window (current-buffer)) 1)))
1611 (unless gnus-inhibit-hiding
1614 (let ((inhibit-read-only t)
1615 (case-fold-search t)
1616 (max (1+ (length gnus-sorted-header-list)))
1617 (ignored (when (not gnus-visible-headers)
1618 (cond ((stringp gnus-ignored-headers)
1619 gnus-ignored-headers)
1620 ((listp gnus-ignored-headers)
1621 (mapconcat 'identity gnus-ignored-headers
1624 (cond ((stringp gnus-visible-headers)
1625 gnus-visible-headers)
1626 ((and gnus-visible-headers
1627 (listp gnus-visible-headers))
1628 (mapconcat 'identity gnus-visible-headers "\\|"))))
1629 (inhibit-point-motion-hooks t)
1631 ;; First we narrow to just the headers.
1632 (article-narrow-to-head)
1633 ;; Hide any "From " lines at the beginning of (mail) articles.
1634 (while (looking-at "From ")
1638 (delete-region (point-min) (point))
1639 (gnus-article-hide-text (point-min) (point)
1640 (nconc (list 'article-type 'headers)
1641 gnus-hidden-properties))))
1642 ;; Then treat the rest of the header lines.
1643 ;; Then we use the two regular expressions
1644 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1645 ;; select which header lines is to remain visible in the
1647 (while (re-search-forward "^[^ \t:]*:" nil t)
1649 ;; Mark the rank of the header.
1651 (point) (1+ (point)) 'message-rank
1652 (if (or (and visible (looking-at visible))
1654 (not (looking-at ignored))))
1655 (gnus-article-header-rank)
1658 (message-sort-headers-1)
1659 (when (setq beg (text-property-any
1660 (point-min) (point-max) 'message-rank (+ 2 max)))
1661 ;; We delete or make invisible the unwanted headers.
1662 (gnus-add-wash-type 'headers)
1665 (add-text-properties
1666 (point-min) (+ 5 (point-min))
1667 '(article-type headers dummy-invisible t))
1668 (delete-region beg (point-max)))
1669 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1671 (defun article-hide-boring-headers (&optional arg)
1672 "Toggle hiding of headers that aren't very interesting.
1673 If given a negative prefix, always show; if given a positive prefix,
1675 (interactive (gnus-article-hidden-arg))
1676 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1677 (not gnus-show-all-headers))
1680 (let ((buffer-read-only nil)
1681 (list gnus-boring-article-headers)
1682 (inhibit-point-motion-hooks t)
1684 (article-narrow-to-head)
1686 (setq elem (pop list))
1687 (goto-char (point-min))
1689 ;; Hide empty headers.
1691 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1693 (gnus-article-hide-text-type
1694 (progn (beginning-of-line) (point))
1697 (if (re-search-forward "^[^ \t]" nil t)
1701 ;; Hide boring Newsgroups header.
1702 ((eq elem 'newsgroups)
1703 (when (gnus-string-equal
1704 (gnus-fetch-field "newsgroups")
1705 (gnus-group-real-name
1706 (if (boundp 'gnus-newsgroup-name)
1709 (gnus-article-hide-header "newsgroups")))
1710 ((eq elem 'to-address)
1711 (let ((to (message-fetch-field "to"))
1713 (gnus-parameter-to-address
1714 (if (boundp 'gnus-newsgroup-name)
1715 gnus-newsgroup-name ""))))
1716 (when (and to to-address
1719 ;; only one address in To
1720 (nth 1 (mail-extract-address-components to))
1722 (gnus-article-hide-header "to"))))
1723 ((eq elem 'followup-to)
1724 (when (gnus-string-equal
1725 (message-fetch-field "followup-to")
1726 (message-fetch-field "newsgroups"))
1727 (gnus-article-hide-header "followup-to")))
1728 ((eq elem 'reply-to)
1729 (let ((from (message-fetch-field "from"))
1730 (reply-to (message-fetch-field "reply-to")))
1735 (nth 1 (mail-extract-address-components from))
1736 (nth 1 (mail-extract-address-components reply-to)))))
1737 (gnus-article-hide-header "reply-to"))))
1739 (let ((date (message-fetch-field "date")))
1741 (< (days-between (current-time-string) date)
1743 (gnus-article-hide-header "date"))))
1745 (let ((to (message-fetch-field "to"))
1746 (cc (message-fetch-field "cc")))
1747 (when (> (length to) 1024)
1748 (gnus-article-hide-header "to"))
1749 (when (> (length cc) 1024)
1750 (gnus-article-hide-header "cc"))))
1754 (goto-char (point-min))
1755 (while (re-search-forward "^to:" nil t)
1756 (setq to-count (1+ to-count)))
1757 (when (> to-count 1)
1758 (while (> to-count 0)
1759 (goto-char (point-min))
1761 (re-search-forward "^to:" nil nil to-count)
1763 (narrow-to-region (point) (point-max))
1764 (gnus-article-hide-header "to"))
1765 (setq to-count (1- to-count))))
1766 (goto-char (point-min))
1767 (while (re-search-forward "^cc:" nil t)
1768 (setq cc-count (1+ cc-count)))
1769 (when (> cc-count 1)
1770 (while (> cc-count 0)
1771 (goto-char (point-min))
1773 (re-search-forward "^cc:" nil nil cc-count)
1775 (narrow-to-region (point) (point-max))
1776 (gnus-article-hide-header "cc"))
1777 (setq cc-count (1- cc-count)))))))))))))
1779 (defun gnus-article-hide-header (header)
1781 (goto-char (point-min))
1782 (when (re-search-forward (concat "^" header ":") nil t)
1783 (gnus-article-hide-text-type
1784 (progn (beginning-of-line) (point))
1787 (if (re-search-forward "^[^ \t]" nil t)
1792 (defvar gnus-article-normalized-header-length 40
1793 "Length of normalized headers.")
1795 (defun article-normalize-headers ()
1796 "Make all header lines 40 characters long."
1798 (let ((buffer-read-only nil)
1802 (article-narrow-to-head)
1805 ((< (setq column (- (gnus-point-at-eol) (point)))
1806 gnus-article-normalized-header-length)
1808 (insert (make-string
1809 (- gnus-article-normalized-header-length column)
1811 ((> column gnus-article-normalized-header-length)
1812 (gnus-put-text-property
1814 (forward-char gnus-article-normalized-header-length)
1821 (forward-line 1))))))
1823 (defun article-treat-dumbquotes ()
1824 "Translate M****s*** sm*rtq**t*s into proper text.
1825 Note that this function guesses whether a character is a sm*rtq**t* or
1826 not, so it should only be used interactively.
1828 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1829 in an attempt to provide more quoting characters. If you see
1830 something like \\222 or \\264 where you're expecting some kind of
1831 apostrophe or quotation mark, then try this wash."
1833 (article-translate-strings gnus-article-dumbquotes-map))
1835 (defun article-translate-characters (from to)
1836 "Translate all characters in the body of the article according to FROM and TO.
1837 FROM is a string of characters to translate from; to is a string of
1838 characters to translate to."
1840 (when (article-goto-body)
1841 (let ((buffer-read-only nil)
1842 (x (make-string 225 ?x))
1844 (while (< (incf i) (length x))
1847 (while (< i (length from))
1848 (aset x (aref from i) (aref to i))
1850 (translate-region (point) (point-max) x)))))
1852 (defun article-translate-strings (map)
1853 "Translate all string in the body of the article according to MAP.
1854 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1856 (when (article-goto-body)
1857 (let ((buffer-read-only nil)
1859 (while (setq elem (pop map))
1861 (while (search-forward (car elem) nil t)
1862 (replace-match (cadr elem)))))))))
1864 (defun article-treat-overstrike ()
1865 "Translate overstrikes into bold text."
1868 (when (article-goto-body)
1869 (let ((buffer-read-only nil))
1870 (while (search-forward "\b" nil t)
1871 (let ((next (char-after))
1875 previous (char-after))
1879 ;; We do the boldification/underlining by hiding the
1880 ;; overstrikes and putting the proper text property
1884 (gnus-article-hide-text-type start (point) 'overstrike)
1885 (put-text-property (point) end 'face 'bold))
1887 (gnus-article-hide-text-type
1888 (1- (point)) (1+ (point)) 'overstrike)
1890 start (1- (point)) 'face 'underline))
1892 (gnus-article-hide-text-type start (point) 'overstrike)
1894 (point) end 'face 'underline)))))))))
1896 (defun gnus-article-treat-unfold-headers ()
1897 "Unfold folded message headers.
1898 Only the headers that fit into the current window width will be
1901 (gnus-with-article-headers
1905 (mail-header-narrow-to-field)
1906 (let ((header (buffer-substring (point-min) (point-max))))
1909 (goto-char (point-min))
1910 (while (re-search-forward "\n[\t ]" nil t)
1911 (replace-match " " t t)))
1912 (setq length (- (point-max) (point-min) 1)))
1913 (when (< length (window-width))
1914 (while (re-search-forward "\n[\t ]" nil t)
1915 (replace-match " " t t)))
1916 (goto-char (point-max)))))))
1918 (defun gnus-article-treat-fold-headers ()
1919 "Fold message headers."
1921 (gnus-with-article-headers
1924 (mail-header-narrow-to-field)
1925 (mail-header-fold-field)
1926 (goto-char (point-max))))))
1928 (defun gnus-treat-smiley ()
1929 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1931 (unless (featurep 'xemacs)
1932 (when (and (>= emacs-major-version 21)
1933 (not gnus-article-should-use-smiley-mule)
1934 gnus-article-smiley-mule-loaded-p)
1935 (load "smiley" nil t)
1936 (setq gnus-article-smiley-mule-loaded-p nil))
1937 (when (and gnus-article-should-use-smiley-mule
1938 (not gnus-article-smiley-mule-loaded-p))
1939 (load "smiley-mule" nil t)
1940 (setq gnus-article-smiley-mule-loaded-p t)))
1941 (gnus-with-article-buffer
1942 (if (memq 'smiley gnus-article-wash-types)
1943 (gnus-delete-images 'smiley)
1945 (let ((images (smiley-region (point) (point-max))))
1947 (gnus-add-wash-type 'smiley)
1948 (dolist (image images)
1949 (gnus-add-image 'smiley image)))))))
1951 (defun gnus-article-remove-images ()
1952 "Remove all images from the article buffer."
1954 (gnus-with-article-buffer
1955 (dolist (elem gnus-article-image-alist)
1956 (gnus-delete-images (car elem)))))
1958 (defun gnus-article-treat-fold-newsgroups ()
1959 "Unfold folded message headers.
1960 Only the headers that fit into the current window width will be
1963 (gnus-with-article-headers
1964 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1966 (mail-header-narrow-to-field)
1967 (while (re-search-forward ", *" nil t)
1968 (replace-match ", " t t))
1969 (mail-header-fold-field)
1970 (goto-char (point-max))))))
1972 (defun gnus-article-treat-body-boundary ()
1973 "Place a boundary line at the end of the headers."
1975 (when (and gnus-body-boundary-delimiter
1976 (> (length gnus-body-boundary-delimiter) 0))
1977 (gnus-with-article-headers
1978 (goto-char (point-max))
1979 (let ((start (point)))
1980 (insert "X-Boundary: ")
1981 (gnus-add-text-properties start (point) '(invisible t intangible t))
1983 (while (>= (1- (window-width)) (length str))
1984 (setq str (concat str gnus-body-boundary-delimiter)))
1985 (substring str 0 (1- (window-width))))
1987 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1989 (defun article-fill-long-lines ()
1990 "Fill lines that are wider than the window width."
1993 (let ((buffer-read-only nil)
1994 (width (window-width (get-buffer-window (current-buffer)))))
1997 (let ((adaptive-fill-mode nil)) ;Why? -sm
2000 (when (>= (current-column) (min fill-column width))
2001 (narrow-to-region (min (1+ (point)) (point-max))
2002 (gnus-point-at-bol))
2003 (let ((goback (point-marker)))
2004 (fill-paragraph nil)
2005 (goto-char (marker-position goback)))
2007 (forward-line 1)))))))
2009 (defun article-capitalize-sentences ()
2010 "Capitalize the first word in each sentence."
2013 (let ((buffer-read-only nil)
2014 (paragraph-start "^[\n\^L]"))
2018 (forward-sentence)))))
2020 (defun article-remove-cr ()
2021 "Remove trailing CRs and then translate remaining CRs into LFs."
2024 (let ((buffer-read-only nil))
2025 (goto-char (point-min))
2026 (while (re-search-forward "\r+$" nil t)
2027 (replace-match "" t t))
2028 (goto-char (point-min))
2029 (while (search-forward "\r" nil t)
2030 (replace-match "\n" t t)))))
2032 (defun article-remove-trailing-blank-lines ()
2033 "Remove all trailing blank lines from the article."
2036 (let ((buffer-read-only nil))
2037 (goto-char (point-max))
2041 (while (and (not (bobp))
2042 (looking-at "^[ \t]*$")
2043 (not (gnus-annotation-in-region-p
2044 (point) (gnus-point-at-eol))))
2049 (defun article-display-face ()
2050 "Display any Face headers in the header."
2052 (gnus-with-article-headers
2055 (when (gnus-buffer-live-p gnus-original-article-buffer)
2056 (set-buffer gnus-original-article-buffer)
2057 (setq face (message-fetch-field "face"))))
2059 (let ((png (gnus-convert-face-to-png face))
2062 (setq image (gnus-create-image png 'png t))
2063 (gnus-article-goto-header "from")
2065 (insert "From: [no `from' set]\n")
2067 (gnus-add-wash-type 'face)
2068 (gnus-add-image 'face image)
2069 (gnus-put-image image)))))))
2071 (defun article-display-x-face (&optional force)
2072 "Look for an X-Face header and display it if present."
2073 (interactive (list 'force))
2074 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2075 (gnus-with-article-headers
2076 ;; Delete the old process, if any.
2077 (when (process-status "article-x-face")
2078 (delete-process "article-x-face"))
2079 (if (memq 'xface gnus-article-wash-types)
2080 ;; We have already displayed X-Faces, so we remove them
2082 (gnus-delete-images 'xface)
2084 (let (x-faces from face)
2086 (when (and wash-face-p
2088 (goto-char (point-min))
2089 (not (re-search-forward
2090 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2091 (gnus-buffer-live-p gnus-original-article-buffer))
2092 ;; If type `W f', use gnus-original-article-buffer,
2093 ;; otherwise use the current buffer because displaying
2094 ;; RFC822 parts calls this function too.
2095 (set-buffer gnus-original-article-buffer))
2097 (mail-narrow-to-head)
2098 (while (gnus-article-goto-header "X-Face")
2099 (push (mail-header-field-value) x-faces))
2100 (setq from (message-fetch-field "from"))))
2101 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2102 ;; single external face.
2103 (when (stringp gnus-article-x-face-command)
2104 (setq x-faces (list (car x-faces))))
2105 (while (and (setq face (pop x-faces))
2106 gnus-article-x-face-command
2108 ;; Check whether this face is censored.
2109 (not gnus-article-x-face-too-ugly)
2110 (and gnus-article-x-face-too-ugly from
2111 (not (string-match gnus-article-x-face-too-ugly
2113 ;; We display the face.
2114 (if (symbolp gnus-article-x-face-command)
2115 ;; The command is a lisp function, so we call it.
2116 (if (gnus-functionp gnus-article-x-face-command)
2117 (funcall gnus-article-x-face-command face)
2118 (error "%s is not a function" gnus-article-x-face-command))
2119 ;; The command is a string, so we interpret the command
2120 ;; as a, well, command, and fork it off.
2121 (let ((process-connection-type nil))
2122 (process-kill-without-query
2124 "article-x-face" nil shell-file-name shell-command-switch
2125 gnus-article-x-face-command))
2128 (process-send-region "article-x-face"
2129 (point-min) (point-max)))
2130 (process-send-eof "article-x-face")))))))))
2132 (defun article-decode-mime-words ()
2133 "Decode all MIME-encoded words in the article."
2136 (set-buffer gnus-article-buffer)
2137 (let ((inhibit-point-motion-hooks t)
2139 (mail-parse-charset gnus-newsgroup-charset)
2140 (mail-parse-ignored-charsets
2141 (save-excursion (set-buffer gnus-summary-buffer)
2142 gnus-newsgroup-ignored-charsets)))
2143 (mail-decode-encoded-word-region (point-min) (point-max)))))
2145 (defun article-decode-charset (&optional prompt)
2146 "Decode charset-encoded text in the article.
2147 If PROMPT (the prefix), prompt for a coding system to use."
2149 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2151 (mail-parse-charset gnus-newsgroup-charset)
2152 (mail-parse-ignored-charsets
2153 (save-excursion (condition-case nil
2154 (set-buffer gnus-summary-buffer)
2156 gnus-newsgroup-ignored-charsets))
2157 ct cte ctl charset format)
2160 (article-narrow-to-head)
2161 (setq ct (message-fetch-field "Content-Type" t)
2162 cte (message-fetch-field "Content-Transfer-Encoding" t)
2163 ctl (and ct (ignore-errors
2164 (mail-header-parse-content-type ct)))
2167 (mm-read-coding-system "Charset to decode: "))
2169 (mail-content-type-get ctl 'charset)))
2170 format (and ctl (mail-content-type-get ctl 'format)))
2172 (setq cte (mail-header-strip cte)))
2173 (if (and ctl (not (string-match "/" (car ctl))))
2175 (goto-char (point-max)))
2178 (narrow-to-region (point) (point-max))
2179 (when (and (eq mail-parse-charset 'gnus-decoded)
2180 (eq (mm-body-7-or-8) '8bit))
2181 ;; The text code could have been decoded.
2182 (setq charset mail-parse-charset))
2183 (when (and (or (not ctl)
2184 (equal (car ctl) "text/plain"))
2185 (not format)) ;; article with format will decode later.
2187 charset (and cte (intern (downcase
2188 (gnus-strip-whitespace cte))))
2191 (defun article-decode-encoded-words ()
2192 "Remove encoded-word encoding from headers."
2193 (let (buffer-read-only)
2194 (let ((charset (save-excursion
2195 (set-buffer gnus-summary-buffer)
2196 default-mime-charset)))
2197 (mime-decode-header-in-buffer charset))))
2199 (defun article-decode-group-name ()
2200 "Decode group names in `Newsgroups:'."
2201 (let ((inhibit-point-motion-hooks t)
2203 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2204 (when (and (or gnus-group-name-charset-method-alist
2205 gnus-group-name-charset-group-alist)
2206 (gnus-buffer-live-p gnus-original-article-buffer))
2207 (when (nnmail-fetch-field "Newsgroups")
2208 (nnheader-replace-header "Newsgroups"
2209 (gnus-decode-newsgroups
2210 (with-current-buffer
2211 gnus-original-article-buffer
2212 (nnmail-fetch-field "Newsgroups"))
2213 gnus-newsgroup-name method)))
2214 (when (nnmail-fetch-field "Followup-To")
2215 (nnheader-replace-header "Followup-To"
2216 (gnus-decode-newsgroups
2217 (with-current-buffer
2218 gnus-original-article-buffer
2219 (nnmail-fetch-field "Followup-To"))
2220 gnus-newsgroup-name method))))))
2222 (defun article-de-quoted-unreadable (&optional force read-charset)
2223 "Translate a quoted-printable-encoded article.
2224 If FORCE, decode the article whether it is marked as quoted-printable
2226 If READ-CHARSET, ask for a coding system."
2227 (interactive (list 'force current-prefix-arg))
2229 (let ((buffer-read-only nil) type charset)
2230 (if (gnus-buffer-live-p gnus-original-article-buffer)
2231 (with-current-buffer gnus-original-article-buffer
2233 (gnus-fetch-field "content-transfer-encoding"))
2234 (let* ((ct (gnus-fetch-field "content-type"))
2237 (mail-header-parse-content-type ct)))))
2238 (setq charset (and ctl
2239 (mail-content-type-get ctl 'charset)))
2240 (if (stringp charset)
2241 (setq charset (intern (downcase charset)))))))
2243 (setq charset (mm-read-coding-system "Charset: " charset)))
2245 (setq charset gnus-newsgroup-charset))
2247 (and type (let ((case-fold-search t))
2248 (string-match "quoted-printable" type))))
2250 (quoted-printable-decode-region
2251 (point) (point-max) (mm-charset-to-coding-system charset))))))
2253 (defun article-de-base64-unreadable (&optional force read-charset)
2254 "Translate a base64 article.
2255 If FORCE, decode the article whether it is marked as base64 not.
2256 If READ-CHARSET, ask for a coding system."
2257 (interactive (list 'force current-prefix-arg))
2259 (let ((buffer-read-only nil) type charset)
2260 (if (gnus-buffer-live-p gnus-original-article-buffer)
2261 (with-current-buffer gnus-original-article-buffer
2263 (gnus-fetch-field "content-transfer-encoding"))
2264 (let* ((ct (gnus-fetch-field "content-type"))
2267 (mail-header-parse-content-type ct)))))
2268 (setq charset (and ctl
2269 (mail-content-type-get ctl 'charset)))
2270 (if (stringp charset)
2271 (setq charset (intern (downcase charset)))))))
2273 (setq charset (mm-read-coding-system "Charset: " charset)))
2275 (setq charset gnus-newsgroup-charset))
2277 (and type (let ((case-fold-search t))
2278 (string-match "base64" type))))
2281 (narrow-to-region (point) (point-max))
2282 (base64-decode-region (point-min) (point-max))
2283 (mm-decode-coding-region
2284 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2289 (defun article-decode-HZ ()
2290 "Translate a HZ-encoded article."
2294 (let ((buffer-read-only nil))
2295 (rfc1843-decode-region (point-min) (point-max)))))
2297 (defun article-unsplit-urls ()
2298 "Remove the newlines that some other mailers insert into URLs."
2301 (let ((buffer-read-only nil))
2302 (goto-char (point-min))
2303 (while (re-search-forward
2304 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2305 (replace-match "\\1\\3" t)))
2306 (when (and gnus-display-mime-function (interactive-p))
2307 (funcall gnus-display-mime-function))))
2310 (defun article-wash-html (&optional read-charset)
2311 "Format an HTML article.
2312 If READ-CHARSET, ask for a coding system."
2315 (let ((buffer-read-only nil)
2317 (when (gnus-buffer-live-p gnus-original-article-buffer)
2318 (with-current-buffer gnus-original-article-buffer
2319 (let* ((ct (gnus-fetch-field "content-type"))
2322 (mail-header-parse-content-type ct)))))
2323 (setq charset (and ctl
2324 (mail-content-type-get ctl 'charset)))
2325 (when (stringp charset)
2326 (setq charset (intern (downcase charset)))))))
2328 (setq charset (mm-read-coding-system "Charset: " charset)))
2330 (setq charset gnus-newsgroup-charset))
2332 (save-window-excursion
2334 (narrow-to-region (point) (point-max))
2335 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2336 (entry (assq func mm-text-html-washer-alist)))
2338 (setq func (cdr entry)))
2340 ((gnus-functionp func)
2343 (apply (car func) (cdr func))))))))))
2345 (defun gnus-article-wash-html-with-w3 ()
2346 "Wash the current buffer with w3."
2348 (let ((w3-strict-width (window-width))
2349 (url-standalone-mode t)
2350 (url-gateway-unplugged t)
2351 (w3-honor-stylesheets nil))
2353 (w3-region (point-min) (point-max))
2356 (defun gnus-article-wash-html-with-w3m ()
2357 "Wash the current buffer with emacs-w3m."
2360 (narrow-to-region (point) (point-max))
2361 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2364 (w3m-display-inline-images mm-inline-text-html-with-images)
2365 w3m-force-redisplay)
2366 (w3m-region (point-min) (point-max)))
2367 (when mm-inline-text-html-with-w3m-keymap
2368 (add-text-properties
2369 (point-min) (point-max)
2370 (nconc (mm-w3m-local-map-property)
2371 '(mm-inline-text-html-with-w3m t))))))
2373 (defun article-hide-list-identifiers ()
2374 "Remove list identifies from the Subject header.
2375 The `gnus-list-identifiers' variable specifies what to do."
2377 (let ((inhibit-point-motion-hooks t)
2378 (regexp (if (consp gnus-list-identifiers)
2379 (mapconcat 'identity gnus-list-identifiers " *\\|")
2380 gnus-list-identifiers))
2385 (article-narrow-to-head)
2386 (goto-char (point-min))
2387 (while (re-search-forward
2388 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2390 (delete-region (match-beginning 2) (match-end 0))
2391 (beginning-of-line))
2392 (when (re-search-forward
2393 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2394 (delete-region (match-beginning 1) (match-end 1))))))))
2396 (defun article-hide-pem (&optional arg)
2397 "Toggle hiding of any PEM headers and signatures in the current article.
2398 If given a negative prefix, always show; if given a positive prefix,
2400 (interactive (gnus-article-hidden-arg))
2401 (unless (gnus-article-check-hidden-text 'pem arg)
2403 (let (buffer-read-only end)
2404 (goto-char (point-min))
2405 ;; Hide the horrendously ugly "header".
2406 (when (and (search-forward
2407 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2409 (setq end (1+ (match-beginning 0))))
2410 (gnus-add-wash-type 'pem)
2411 (gnus-article-hide-text-type
2413 (if (search-forward "\n\n" nil t)
2417 ;; Hide the trailer as well
2418 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2420 (gnus-article-hide-text-type
2421 (match-beginning 0) (match-end 0) 'pem)))))))
2423 (defun article-strip-banner ()
2424 "Strip the banner specified by the `banner' group parameter."
2428 (let ((inhibit-point-motion-hooks t)
2429 (banner (gnus-parameter-banner gnus-newsgroup-name))
2430 (gnus-signature-limit nil)
2431 buffer-read-only beg end)
2432 (when (and gnus-article-address-banner-alist
2435 (let ((from (save-restriction
2437 (article-narrow-to-head)
2438 (mail-fetch-field "from"))))
2441 (caar (mail-header-parse-addresses from))))
2443 (dolist (pair gnus-article-address-banner-alist)
2444 (when (string-match (car pair) from)
2445 (throw 'found (cdr pair)))))))))
2449 ((eq banner 'signature)
2450 (when (gnus-article-narrow-to-signature)
2453 (delete-region (point) (point-max))))
2455 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2456 (while (re-search-forward banner nil t)
2457 (delete-region (match-beginning 0) (match-end 0)))))
2459 (while (re-search-forward banner nil t)
2460 (delete-region (match-beginning 0) (match-end 0))))))))))
2462 (defun article-babel ()
2463 "Translate article using an online translation service."
2467 (set-buffer gnus-article-buffer)
2468 (when (article-goto-body)
2469 (let* ((buffer-read-only nil)
2472 (orig (buffer-substring start end))
2473 (trans (babel-as-string orig)))
2475 (narrow-to-region start end)
2476 (delete-region start end)
2479 (defun article-hide-signature (&optional arg)
2480 "Hide the signature in the current article.
2481 If given a negative prefix, always show; if given a positive prefix,
2483 (interactive (gnus-article-hidden-arg))
2489 (article-goto-body))
2490 (goto-char (point-min)))
2491 (unless (gnus-article-check-hidden-text 'signature arg)
2492 (let ((buffer-read-only nil)
2494 (while (setq button (text-property-any button (point-max)
2496 'gnus-signature-toggle))
2497 (setq button (text-property-not-all button (point-max)
2499 'gnus-signature-toggle))
2500 (when (and button (not (eobp)))
2501 (gnus-article-hide-text-type
2503 (next-single-property-change (1+ button) 'mime-view-entity
2506 (gnus-set-mode-line 'article))
2508 (defun article-strip-headers-in-body ()
2509 "Strip offensive headers from bodies."
2513 (let ((case-fold-search t))
2514 (when (looking-at "x-no-archive:")
2515 (gnus-delete-line)))))
2517 (defun article-strip-leading-blank-lines ()
2518 "Remove all blank lines from the beginning of the article."
2521 (let ((inhibit-point-motion-hooks t)
2523 (when (article-goto-body)
2524 (while (and (not (eobp))
2525 (looking-at "[ \t]*$"))
2526 (gnus-delete-line))))))
2528 (defun article-narrow-to-head ()
2529 "Narrow the buffer to the head of the message.
2530 Point is left at the beginning of the narrowed-to region."
2532 (goto-char (point-min))
2533 (if (search-forward "\n\n" nil 1)
2536 (goto-char (point-min)))
2538 (defun article-goto-body ()
2539 "Place point at the start of the body."
2540 (goto-char (point-min))
2542 ;; This variable is only bound when dealing with separate
2544 (article-goto-body-goes-to-point-min-p
2546 ((search-forward "\n\n" nil t)
2549 (goto-char (point-max))
2552 (defun article-strip-multiple-blank-lines ()
2553 "Replace consecutive blank lines with one empty line."
2556 (let ((inhibit-point-motion-hooks t)
2558 ;; First make all blank lines empty.
2560 (while (re-search-forward "^[ \t]+$" nil t)
2561 (unless (gnus-annotation-in-region-p
2562 (match-beginning 0) (match-end 0))
2563 (replace-match "" nil t)))
2564 ;; Then replace multiple empty lines with a single empty line.
2566 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2567 (unless (gnus-annotation-in-region-p
2568 (match-beginning 0) (match-end 0))
2569 (delete-region (match-beginning 1) (match-end 1)))))))
2571 (defun article-strip-leading-space ()
2572 "Remove all white space from the beginning of the lines in the article."
2575 (let ((inhibit-point-motion-hooks t)
2578 (while (re-search-forward "^[ \t]+" nil t)
2579 (replace-match "" t t)))))
2581 (defun article-strip-trailing-space ()
2582 "Remove all white space from the end of the lines in the article."
2585 (let ((inhibit-point-motion-hooks t)
2588 (while (re-search-forward "[ \t]+$" nil t)
2589 (replace-match "" t t)))))
2591 (defun article-strip-blank-lines ()
2592 "Strip leading, trailing and multiple blank lines."
2594 (article-strip-leading-blank-lines)
2595 (article-remove-trailing-blank-lines)
2596 (article-strip-multiple-blank-lines))
2598 (defun article-strip-all-blank-lines ()
2599 "Strip all blank lines."
2602 (let ((inhibit-point-motion-hooks t)
2605 (while (re-search-forward "^[ \t]*\n" nil t)
2606 (replace-match "" t t)))))
2608 (defun gnus-article-narrow-to-signature ()
2609 "Narrow to the signature; return t if a signature is found, else nil."
2610 (let ((inhibit-point-motion-hooks t))
2611 (when (gnus-article-search-signature)
2613 ;; Check whether we have some limits to what we consider
2614 ;; to be a signature.
2615 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2616 (list gnus-signature-limit)))
2618 (while (setq limit (pop limits))
2619 (if (or (and (integerp limit)
2620 (< (- (point-max) (point)) limit))
2622 (< (count-lines (point) (point-max)) limit))
2623 (and (gnus-functionp limit)
2625 (and (stringp limit)
2626 (not (re-search-forward limit nil t))))
2627 () ; This limit did not succeed.
2631 (narrow-to-region (point) (point-max))
2634 (defun gnus-article-search-signature ()
2635 "Search the current buffer for the signature separator.
2636 Put point at the beginning of the signature separator."
2637 (let ((cur (point)))
2638 (goto-char (point-max))
2639 (if (if (stringp gnus-signature-separator)
2640 (re-search-backward gnus-signature-separator nil t)
2641 (let ((seps gnus-signature-separator))
2643 (not (re-search-backward (car seps) nil t)))
2650 (defun gnus-article-hidden-arg ()
2651 "Return the current prefix arg as a number, or 0 if no prefix."
2652 (list (if current-prefix-arg
2653 (prefix-numeric-value current-prefix-arg)
2656 (defun gnus-article-check-hidden-text (type arg)
2657 "Return nil if hiding is necessary.
2658 Arg can be nil or a number. nil and positive means hide, negative
2659 means show, 0 means toggle."
2662 (let ((hide (gnus-article-hidden-text-p type)))
2668 (gnus-article-show-hidden-text type)
2671 (if (eq hide 'hidden)
2673 (gnus-article-show-hidden-text type)
2677 (defun gnus-article-hidden-text-p (type)
2678 "Say whether the current buffer contains hidden text of type TYPE."
2679 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2681 (not (get-text-property pos 'invisible))
2682 (not (get-text-property pos 'dummy-invisible)))
2684 (text-property-any (1+ pos) (point-max) 'article-type type)))
2689 (defun gnus-article-show-hidden-text (type &optional dummy)
2690 "Show all hidden text of type TYPE.
2691 Originally it is hide instead of DUMMY."
2692 (let ((buffer-read-only nil)
2693 (inhibit-point-motion-hooks t))
2694 (gnus-remove-text-properties-when
2696 (point-min) (point-max)
2697 (cons 'article-type (cons type
2698 gnus-hidden-properties)))
2699 (gnus-delete-wash-type type)))
2701 (defconst article-time-units
2702 `((year . ,(* 365.25 24 60 60))
2703 (week . ,(* 7 24 60 60))
2704 (day . ,(* 24 60 60))
2708 "Mapping from time units to seconds.")
2710 (defun gnus-article-forward-header ()
2711 "Move point to the start of the next header.
2712 If the current header is a continuation header, this can be several
2717 (if (looking-at "[ \t]+[^ \t]")
2721 (defun article-date-ut (&optional type highlight header)
2722 "Convert DATE date to universal time in the current article.
2723 If TYPE is `local', convert to local time; if it is `lapsed', output
2724 how much time has lapsed since DATE. For `lapsed', the value of
2725 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2726 should replace the \"Date:\" one, or should be added below it."
2727 (interactive (list 'ut t))
2728 (let* ((header (or header
2729 (and (eq 1 (point-min))
2730 (mail-header-date (save-excursion
2731 (set-buffer gnus-summary-buffer)
2732 gnus-current-headers)))
2733 (message-fetch-field "date")
2735 (date (if (vectorp header) (mail-header-date header)
2737 (inhibit-point-motion-hooks t)
2738 bface eface date-pos)
2739 (when (and date (not (string= date "")))
2742 (article-narrow-to-head)
2743 (when (or (and (eq type 'lapsed)
2744 gnus-article-date-lapsed-new-header
2745 ;; Attempt to get the face of X-Sent first.
2746 (re-search-forward "^X-Sent:[ \t]" nil t))
2747 (re-search-forward "^Date:[ \t]" nil t)
2748 ;; If Date is missing, try again for X-Sent.
2749 (re-search-forward "^X-Sent:[ \t]" nil t))
2750 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2751 date (or (get-text-property (gnus-point-at-bol)
2754 eface (get-text-property (1- (gnus-point-at-eol))
2756 (let ((buffer-read-only nil))
2757 ;; Delete any old X-Sent headers.
2758 (when (setq date-pos
2759 (text-property-any (point-min) (point-max)
2760 'article-date-lapsed t))
2761 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2762 (delete-region (match-beginning 0)
2763 (progn (forward-line 1) (point))))
2764 (goto-char (point-min))
2765 ;; Delete any old Date headers.
2766 (while (re-search-forward "^Date:[ \t]" nil t)
2768 (setq date-pos (match-beginning 0)))
2769 (unless (and (eq type 'lapsed)
2770 gnus-article-date-lapsed-new-header)
2771 (delete-region (match-beginning 0)
2772 (progn (message-next-header) (point)))))
2775 (goto-char date-pos)
2777 ;; Possibly, Date has been deleted.
2779 (when (and (eq type 'lapsed)
2780 gnus-article-date-lapsed-new-header
2781 (looking-at "Date:"))
2783 (goto-char (point-min)))
2784 (insert (article-make-date-line date type))
2785 (when (eq type 'lapsed)
2786 (put-text-property (gnus-point-at-bol) (point)
2787 'article-date-lapsed t))
2791 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2792 (put-text-property (match-beginning 1) (1+ (match-end 1))
2793 'original-date date)
2794 (put-text-property (match-beginning 1) (1+ (match-end 1))
2796 (put-text-property (match-beginning 2) (match-end 2)
2799 (defun article-make-date-line (date type)
2800 "Return a DATE line of TYPE."
2801 (unless (memq type '(local ut original user iso8601 lapsed english))
2802 (error "Unknown conversion type: %s" type))
2804 (let ((time (date-to-time date)))
2806 ;; Convert to the local timezone.
2808 (let ((tz (car (current-time-zone time))))
2809 (format "Date: %s %s%02d%02d" (current-time-string time)
2810 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2811 (/ (% (abs tz) 3600) 60))))
2812 ;; Convert to Universal Time.
2815 (current-time-string
2816 (let* ((e (parse-time-string date))
2817 (tm (apply 'encode-time e))
2819 (ls (- (cadr tm) (car (current-time-zone time)))))
2820 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2821 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2824 ;; Get the original date from the article.
2825 ((eq type 'original)
2826 (concat "Date: " (if (string-match "\n+$" date)
2827 (substring date 0 (match-beginning 0))
2829 ;; Let the user define the format.
2831 (let ((format (or (condition-case nil
2832 (with-current-buffer gnus-summary-buffer
2833 gnus-article-time-format)
2835 gnus-article-time-format)))
2836 (if (gnus-functionp format)
2837 (funcall format time)
2838 (concat "Date: " (format-time-string format time)))))
2841 (let ((tz (car (current-time-zone time))))
2844 (format-time-string "%Y%m%dT%H%M%S" time)
2845 (format "%s%02d%02d"
2846 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2847 (/ (% (abs tz) 3600) 60)))))
2848 ;; Do an X-Sent lapsed format.
2850 ;; If the date is seriously mangled, the timezone functions are
2851 ;; liable to bug out, so we ignore all errors.
2852 (let* ((now (current-time))
2853 (real-time (subtract-time now time))
2854 (real-sec (and real-time
2855 (+ (* (float (car real-time)) 65536)
2857 (sec (and real-time (abs real-sec)))
2867 ;; This is a bit convoluted, but basically we go
2868 ;; through the time units for years, weeks, etc,
2869 ;; and divide things to see whether that results
2870 ;; in positive answers.
2873 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2874 ;; The (remaining) seconds are too few to
2875 ;; be divided into this time unit.
2877 ;; It's big enough, so we output it.
2878 (setq sec (- sec (* num (cdr unit))))
2880 (concat (if prev ", " "") (int-to-string
2882 " " (symbol-name (car unit))
2883 (if (> num 1) "s" ""))
2885 article-time-units "")
2886 ;; If dates are odd, then it might appear like the
2887 ;; article was sent in the future.
2890 " in the future"))))))
2891 ;; Display the date in proper English
2893 (let ((dtime (decode-time time)))
2896 (number-to-string (nth 3 dtime))
2897 (let ((digit (% (nth 3 dtime) 10)))
2899 ((memq (nth 3 dtime) '(11 12 13)) "th")
2905 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2907 (number-to-string (nth 5 dtime))
2909 (format "%02d" (nth 2 dtime))
2911 (format "%02d" (nth 1 dtime)))))))
2913 (format "Date: %s (from T-gnus)" date))))
2915 (defun article-date-local (&optional highlight)
2916 "Convert the current article date to the local timezone."
2917 (interactive (list t))
2918 (article-date-ut 'local highlight))
2920 (defun article-date-english (&optional highlight)
2921 "Convert the current article date to something that is proper English."
2922 (interactive (list t))
2923 (article-date-ut 'english highlight))
2925 (defun article-date-original (&optional highlight)
2926 "Convert the current article date to what it was originally.
2927 This is only useful if you have used some other date conversion
2928 function and want to see what the date was before converting."
2929 (interactive (list t))
2930 (article-date-ut 'original highlight))
2932 (defun article-date-lapsed (&optional highlight)
2933 "Convert the current article date to time lapsed since it was sent."
2934 (interactive (list t))
2935 (article-date-ut 'lapsed highlight))
2937 (defun article-update-date-lapsed ()
2938 "Function to be run from a timer to update the lapsed time line."
2939 (let (deactivate-mark)
2944 (set-buffer (window-buffer w))
2945 (when (eq major-mode 'gnus-article-mode)
2946 (goto-char (point-min))
2947 (when (re-search-forward "^X-Sent:" nil t)
2948 (article-date-lapsed t))))
2951 (defun gnus-start-date-timer (&optional n)
2952 "Start a timer to update the X-Sent header in the article buffers.
2953 The numerical prefix says how frequently (in seconds) the function
2958 (gnus-stop-date-timer)
2959 (setq article-lapsed-timer
2960 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2962 (defun gnus-stop-date-timer ()
2963 "Stop the X-Sent timer."
2965 (when article-lapsed-timer
2966 (nnheader-cancel-timer article-lapsed-timer)
2967 (setq article-lapsed-timer nil)))
2969 (defun article-date-user (&optional highlight)
2970 "Convert the current article date to the user-defined format.
2971 This format is defined by the `gnus-article-time-format' variable."
2972 (interactive (list t))
2973 (article-date-ut 'user highlight))
2975 (defun article-date-iso8601 (&optional highlight)
2976 "Convert the current article date to ISO8601."
2977 (interactive (list t))
2978 (article-date-ut 'iso8601 highlight))
2980 ;; (defun article-show-all ()
2981 ;; "Show all hidden text in the article buffer."
2985 ;; (let ((buffer-read-only nil))
2986 ;; (gnus-article-unhide-text (point-min) (point-max))
2987 ;; (gnus-remove-text-with-property 'gnus-prev)
2988 ;; (gnus-remove-text-with-property 'gnus-next))))
2990 (defun article-show-all-headers ()
2991 "Show all hidden headers in the article buffer."
2996 (article-narrow-to-head)
2997 (let ((buffer-read-only nil))
2998 (gnus-article-unhide-text (point-min) (point-max))))))
3000 (defun article-remove-leading-whitespace ()
3001 "Remove excessive whitespace from all headers."
3005 (let ((buffer-read-only nil))
3006 (article-narrow-to-head)
3007 (goto-char (point-min))
3008 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3009 (delete-region (match-beginning 1) (match-end 1)))))))
3011 (defun article-emphasize (&optional arg)
3012 "Emphasize text according to `gnus-emphasis-alist'."
3013 (interactive (gnus-article-hidden-arg))
3014 (unless (gnus-article-check-hidden-text 'emphasis arg)
3018 (with-current-buffer gnus-summary-buffer
3019 gnus-article-emphasis-alist)
3021 gnus-emphasis-alist))
3022 (buffer-read-only nil)
3023 (props (append '(article-type emphasis)
3024 gnus-hidden-properties))
3025 regexp elem beg invisible visible face)
3028 (while (setq elem (pop alist))
3030 (setq regexp (car elem)
3031 invisible (nth 1 elem)
3032 visible (nth 2 elem)
3034 (while (re-search-forward regexp nil t)
3035 (when (and (match-beginning visible) (match-beginning invisible))
3036 (gnus-article-hide-text
3037 (match-beginning invisible) (match-end invisible) props)
3038 (gnus-article-unhide-text-type
3039 (match-beginning visible) (match-end visible) 'emphasis)
3040 (gnus-put-overlay-excluding-newlines
3041 (match-beginning visible) (match-end visible) 'face face)
3042 (gnus-add-wash-type 'emphasis)
3043 (goto-char (match-end invisible)))))))))
3045 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3046 "Setup newsgroup emphasis alist."
3047 (unless gnus-article-emphasis-alist
3048 (let ((name (and gnus-newsgroup-name
3049 (gnus-group-real-name gnus-newsgroup-name))))
3050 (make-local-variable 'gnus-article-emphasis-alist)
3051 (setq gnus-article-emphasis-alist
3053 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3054 (while (setq elem (pop alist))
3055 (when (and name (string-match (car elem) name))
3057 highlight (copy-sequence (cdr elem)))))
3059 (copy-sequence highlight-words)
3060 (if gnus-newsgroup-name
3061 (copy-sequence (gnus-group-find-parameter
3062 gnus-newsgroup-name 'highlight-words t)))
3063 gnus-emphasis-alist)))))
3066 (defvar gnus-summary-article-menu)
3067 (defvar gnus-summary-post-menu))
3069 ;;; Saving functions.
3071 (defun gnus-article-save (save-buffer file &optional num)
3072 "Save the currently selected article."
3073 (unless gnus-save-all-headers
3074 ;; Remove headers according to `gnus-saved-headers'.
3075 (let ((gnus-visible-headers
3076 (or gnus-saved-headers gnus-visible-headers))
3077 (gnus-article-buffer save-buffer))
3079 (set-buffer save-buffer)
3080 (article-hide-headers 1 t))))
3081 (save-window-excursion
3082 (if (not gnus-default-article-saver)
3083 (error "No default saver is defined")
3084 ;; !!! Magic! The saving functions all save
3085 ;; `gnus-save-article-buffer' (or so they think), but we
3086 ;; bind that variable to our save-buffer.
3087 (set-buffer gnus-article-buffer)
3088 (let* ((gnus-save-article-buffer save-buffer)
3091 ((not gnus-prompt-before-saving) 'default)
3092 ((eq gnus-prompt-before-saving 'always) nil)
3094 (gnus-number-of-articles-to-be-saved
3095 (when (eq gnus-prompt-before-saving t)
3097 (set-buffer gnus-article-current-summary)
3098 (funcall gnus-default-article-saver filename)))))
3100 (defun gnus-read-save-file-name (prompt &optional filename
3101 function group headers variable)
3103 (funcall function group headers (symbol-value variable)))
3108 ((eq filename 'default)
3114 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3117 (if (and gnus-number-of-articles-to-be-saved
3118 (> gnus-number-of-articles-to-be-saved 1))
3119 (format "these %d articles"
3120 gnus-number-of-articles-to-be-saved)
3123 ;; Let the split methods have their say.
3125 ;; No split name was found.
3128 (concat prompt " (default "
3129 (file-name-nondirectory default-name) ") ")
3130 (file-name-directory default-name)
3132 ;; A single group name is returned.
3133 ((stringp split-name)
3135 (funcall function split-name headers
3136 (symbol-value variable)))
3138 (concat prompt " (default "
3139 (file-name-nondirectory default-name) ") ")
3140 (file-name-directory default-name)
3142 ;; A single split name was found
3143 ((= 1 (length split-name))
3144 (let* ((name (expand-file-name
3146 gnus-article-save-directory))
3147 (dir (cond ((file-directory-p name)
3148 (file-name-as-directory name))
3149 ((file-exists-p name) name)
3150 (t gnus-article-save-directory))))
3152 (concat prompt " (default " name ") ")
3154 ;; A list of splits was found.
3156 (setq split-name (nreverse split-name))
3158 (let ((file-name-history
3159 (nconc split-name file-name-history)))
3163 (concat prompt " (`M-p' for defaults) ")
3164 gnus-article-save-directory
3166 gnus-article-save-directory)))
3167 (car (push result file-name-history)))))))
3168 ;; Create the directory.
3169 (gnus-make-directory (file-name-directory file))
3170 ;; If we have read a directory, we append the default file name.
3171 (when (file-directory-p file)
3172 (setq file (expand-file-name (file-name-nondirectory
3174 (file-name-as-directory file))))
3175 ;; Possibly translate some characters.
3176 (nnheader-translate-file-chars file))))))
3177 (gnus-make-directory (file-name-directory result))
3178 (set variable result)))
3180 (defun gnus-article-archive-name (group)
3181 "Return the first instance of an \"Archive-name\" in the current buffer."
3182 (let ((case-fold-search t))
3183 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3184 (nnheader-concat gnus-article-save-directory
3185 (match-string 1)))))
3187 (defun gnus-article-nndoc-name (group)
3188 "If GROUP is an nndoc group, return the name of the parent group."
3189 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3190 (gnus-group-get-parameter group 'save-article-group)))
3192 (defun gnus-summary-save-in-rmail (&optional filename)
3193 "Append this article to Rmail file.
3194 Optional argument FILENAME specifies file name.
3195 Directory to save to is default to `gnus-article-save-directory'."
3196 (setq filename (gnus-read-save-file-name
3197 "Save %s in rmail file:" filename
3198 gnus-rmail-save-name gnus-newsgroup-name
3199 gnus-current-headers 'gnus-newsgroup-last-rmail))
3200 (gnus-eval-in-buffer-window gnus-save-article-buffer
3204 (gnus-output-to-rmail filename))))
3207 (defun gnus-summary-save-in-mail (&optional filename)
3208 "Append this article to Unix mail file.
3209 Optional argument FILENAME specifies file name.
3210 Directory to save to is default to `gnus-article-save-directory'."
3211 (setq filename (gnus-read-save-file-name
3212 "Save %s in Unix mail file:" filename
3213 gnus-mail-save-name gnus-newsgroup-name
3214 gnus-current-headers 'gnus-newsgroup-last-mail))
3215 (gnus-eval-in-buffer-window gnus-save-article-buffer
3219 (if (and (file-readable-p filename)
3220 (file-regular-p filename)
3221 (mail-file-babyl-p filename))
3222 (rmail-output-to-rmail-file filename t)
3223 (gnus-output-to-mail filename)))))
3226 (defun gnus-summary-save-in-file (&optional filename overwrite)
3227 "Append this article to file.
3228 Optional argument FILENAME specifies file name.
3229 Directory to save to is default to `gnus-article-save-directory'."
3230 (setq filename (gnus-read-save-file-name
3231 "Save %s in file:" filename
3232 gnus-file-save-name gnus-newsgroup-name
3233 gnus-current-headers 'gnus-newsgroup-last-file))
3234 (gnus-eval-in-buffer-window gnus-save-article-buffer
3238 (when (and overwrite
3239 (file-exists-p filename))
3240 (delete-file filename))
3241 (gnus-output-to-file filename))))
3244 (defun gnus-summary-write-to-file (&optional filename)
3245 "Write this article to a file, overwriting it if the file exists.
3246 Optional argument FILENAME specifies file name.
3247 The directory to save in defaults to `gnus-article-save-directory'."
3248 (gnus-summary-save-in-file nil t))
3250 (defun gnus-summary-save-body-in-file (&optional filename)
3251 "Append this article body to a file.
3252 Optional argument FILENAME specifies file name.
3253 The directory to save in defaults to `gnus-article-save-directory'."
3254 (setq filename (gnus-read-save-file-name
3255 "Save %s body in file:" filename
3256 gnus-file-save-name gnus-newsgroup-name
3257 gnus-current-headers 'gnus-newsgroup-last-file))
3258 (gnus-eval-in-buffer-window gnus-save-article-buffer
3262 (when (article-goto-body)
3263 (narrow-to-region (point) (point-max)))
3264 (gnus-output-to-file filename))))
3267 (defun gnus-summary-save-in-pipe (&optional command)
3268 "Pipe this article to subprocess."
3270 (cond ((and (eq command 'default)
3271 gnus-last-shell-command)
3272 gnus-last-shell-command)
3277 "Shell command on %s: "
3278 (if (and gnus-number-of-articles-to-be-saved
3279 (> gnus-number-of-articles-to-be-saved 1))
3280 (format "these %d articles"
3281 gnus-number-of-articles-to-be-saved)
3283 gnus-last-shell-command))))
3284 (when (string-equal command "")
3285 (if gnus-last-shell-command
3286 (setq command gnus-last-shell-command)
3287 (error "A command is required")))
3288 (gnus-eval-in-buffer-window gnus-article-buffer
3291 (shell-command-on-region (point-min) (point-max) command nil)))
3292 (setq gnus-last-shell-command command))
3294 (defun gnus-summary-pipe-to-muttprint (&optional command)
3295 "Pipe this article to muttprint."
3296 (setq command (read-string
3297 "Print using command: " gnus-summary-muttprint-program
3298 nil gnus-summary-muttprint-program))
3299 (gnus-summary-save-in-pipe command))
3301 ;;; Article file names when saving.
3303 (defun gnus-capitalize-newsgroup (newsgroup)
3304 "Capitalize NEWSGROUP name."
3305 (when (not (zerop (length newsgroup)))
3306 (concat (char-to-string (upcase (aref newsgroup 0)))
3307 (substring newsgroup 1))))
3309 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3310 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3311 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3312 Otherwise, it is like ~/News/news/group/num."
3315 (concat (if (gnus-use-long-file-name 'not-save)
3316 (gnus-capitalize-newsgroup newsgroup)
3317 (gnus-newsgroup-directory-form newsgroup))
3318 "/" (int-to-string (mail-header-number headers)))
3319 gnus-article-save-directory)))
3321 (string-equal (file-name-directory default)
3322 (file-name-directory last-file))
3323 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3325 (or last-file default))))
3327 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3328 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3329 If variable `gnus-use-long-file-name' is non-nil, it is
3330 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3333 (concat (if (gnus-use-long-file-name 'not-save)
3335 (gnus-newsgroup-directory-form newsgroup))
3336 "/" (int-to-string (mail-header-number headers)))
3337 gnus-article-save-directory)))
3339 (string-equal (file-name-directory default)
3340 (file-name-directory last-file))
3341 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3343 (or last-file default))))
3345 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3346 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3347 If variable `gnus-use-long-file-name' is non-nil, it is
3348 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3351 (if (gnus-use-long-file-name 'not-save)
3354 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3356 gnus-article-save-directory)))
3358 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3359 "Generate file name from sender."
3360 (let ((from (mail-header-from headers)))
3362 (if (and from (string-match "\\([^ <]+\\)@" from))
3363 (match-string 1 from)
3365 gnus-article-save-directory)))
3367 (defun article-verify-x-pgp-sig ()
3370 (if (gnus-buffer-live-p gnus-original-article-buffer)
3371 (let ((sig (with-current-buffer gnus-original-article-buffer
3372 (gnus-fetch-field "X-PGP-Sig")))
3376 (mml2015-clear-verify-function))
3378 (insert-buffer-substring gnus-original-article-buffer)
3379 (setq items (split-string sig))
3380 (message-narrow-to-head)
3381 (let ((inhibit-point-motion-hooks t)
3382 (case-fold-search t))
3383 ;; Don't verify multiple headers.
3384 (setq headers (mapconcat (lambda (header)
3386 (mail-fetch-field header) "\n"))
3387 (split-string (nth 1 items) ",") "")))
3388 (delete-region (point-min) (point-max))
3389 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3390 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3395 (if (looking-at "^-")
3398 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3399 (insert "Version: " (car items) "\n\n")
3400 (insert (mapconcat 'identity (cddr items) "\n"))
3401 (insert "\n-----END PGP SIGNATURE-----\n")
3402 (let ((mm-security-handle (list (format "multipart/signed"))))
3403 (mml2015-clean-buffer)
3404 (let ((coding-system-for-write (or gnus-newsgroup-charset
3406 (funcall (mml2015-clear-verify-function)))
3408 (or (mm-handle-multipart-ctl-parameter
3409 mm-security-handle 'gnus-details)
3410 (mm-handle-multipart-ctl-parameter
3411 mm-security-handle 'gnus-info)))))
3413 (let (buffer-read-only bface eface)
3415 (message-narrow-to-head)
3416 (goto-char (point-max))
3418 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3419 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3420 (message-remove-header "X-Gnus-PGP-Verify")
3421 (if (re-search-forward "^X-PGP-Sig:" nil t)
3423 (goto-char (point-max)))
3424 (narrow-to-region (point) (point))
3425 (insert "X-Gnus-PGP-Verify: " info "\n")
3426 (goto-char (point-min))
3429 (if (not (looking-at "^[ \t]"))
3433 (goto-char (point-min))
3434 (when (looking-at "\\([^:]+\\): *")
3435 (put-text-property (match-beginning 1) (1+ (match-end 1))
3437 (put-text-property (match-end 0) (point-max)
3438 'face eface)))))))))
3440 (defun article-verify-cancel-lock ()
3441 "Verify Cancel-Lock header."
3443 (if (gnus-buffer-live-p gnus-original-article-buffer)
3444 (canlock-verify gnus-original-article-buffer)))
3446 (defun article-monafy ()
3447 "Display body part with mona font."
3449 (unless (if (featurep 'xemacs)
3450 (find-face 'gnus-mona-face)
3451 (facep 'gnus-mona-face))
3452 (require 'navi2ch-mona)
3453 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3455 (let ((buffer-read-only nil))
3458 (gnus-make-overlay (point) (point-max))
3459 'face 'gnus-mona-face))))
3466 (setq afunc (car func)
3469 gfunc (intern (format "gnus-%s" func))))
3471 (when (fboundp afunc)
3472 `(lambda (&optional interactive &rest args)
3473 ,(documentation afunc t)
3474 (interactive (list t))
3476 (set-buffer gnus-article-buffer)
3478 (call-interactively ',afunc)
3479 (apply ',afunc args))))))))
3480 '(article-hide-headers
3481 article-verify-x-pgp-sig
3482 article-verify-cancel-lock
3484 article-hide-boring-headers
3485 article-treat-overstrike
3486 article-fill-long-lines
3487 article-capitalize-sentences
3489 article-remove-leading-whitespace
3490 article-display-x-face
3491 article-display-face
3492 article-de-quoted-unreadable
3493 article-de-base64-unreadable
3496 article-unsplit-urls
3497 article-hide-list-identifiers
3498 article-strip-banner
3501 article-hide-signature
3502 article-strip-headers-in-body
3503 article-remove-trailing-blank-lines
3504 article-strip-leading-blank-lines
3505 article-strip-multiple-blank-lines
3506 article-strip-leading-space
3507 article-strip-trailing-space
3508 article-strip-blank-lines
3509 article-strip-all-blank-lines
3511 article-date-english
3512 article-date-iso8601
3513 article-date-original
3515 article-decode-mime-words
3516 article-decode-charset
3517 article-decode-encoded-words
3521 article-treat-dumbquotes
3522 article-normalize-headers
3523 (article-show-all-headers . gnus-article-show-all-headers)
3524 ;; (article-show-all . gnus-article-show-all)
3528 ;;; Gnus article mode
3531 (put 'gnus-article-mode 'mode-class 'special)
3533 (gnus-define-keys gnus-article-mode-map
3534 " " gnus-article-goto-next-page
3535 "\177" gnus-article-goto-prev-page
3536 [delete] gnus-article-goto-prev-page
3537 [backspace] gnus-article-goto-prev-page
3538 "\C-c^" gnus-article-refer-article
3539 "h" gnus-article-show-summary
3540 "s" gnus-article-show-summary
3541 "\C-c\C-m" gnus-article-mail
3542 "?" gnus-article-describe-briefly
3543 "e" gnus-summary-edit-article
3544 "<" beginning-of-buffer
3546 "\C-c\C-i" gnus-info-find-node
3548 "R" gnus-article-reply-with-original
3549 "F" gnus-article-followup-with-original
3550 "\C-hk" gnus-article-describe-key
3551 "\C-hc" gnus-article-describe-key-briefly
3553 "\C-d" gnus-article-read-summary-keys
3554 "\M-*" gnus-article-read-summary-keys
3555 "\M-#" gnus-article-read-summary-keys
3556 "\M-^" gnus-article-read-summary-keys
3557 "\M-g" gnus-article-read-summary-keys)
3559 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3563 (push (char-to-string key) keys)
3565 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3566 (setq key (car elem))
3567 (when (and (> (length key) 0)
3568 (not (eq 'menu-bar (aref key 0)))
3569 (symbolp (lookup-key gnus-summary-mode-map key)))
3572 (unless (lookup-key gnus-article-mode-map key)
3573 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3575 (defun gnus-article-make-menu-bar ()
3576 (unless (boundp 'gnus-article-commands-menu)
3577 (gnus-summary-make-menu-bar))
3578 (gnus-turn-off-edit-menu 'article)
3579 (unless (boundp 'gnus-article-article-menu)
3581 gnus-article-article-menu gnus-article-mode-map ""
3583 ["Scroll forwards" gnus-article-goto-next-page t]
3584 ["Scroll backwards" gnus-article-goto-prev-page t]
3585 ["Show summary" gnus-article-show-summary t]
3586 ["Fetch Message-ID at point" gnus-article-refer-article t]
3587 ["Mail to address at point" gnus-article-mail t]
3588 ["Send a bug report" gnus-bug t]))
3591 gnus-article-treatment-menu gnus-article-mode-map ""
3592 ;; Fixme: this should use :active (and maybe :visible).
3594 ["Hide headers" gnus-article-hide-headers t]
3595 ["Hide signature" gnus-article-hide-signature t]
3596 ["Hide citation" gnus-article-hide-citation t]
3597 ["Treat overstrike" gnus-article-treat-overstrike t]
3598 ["Remove carriage return" gnus-article-remove-cr t]
3599 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3600 ["Treat html" gnus-article-wash-html t]
3601 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3602 ["Decode HZ" gnus-article-decode-HZ t]))
3604 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3606 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3608 (gnus-run-hooks 'gnus-article-menu-hook)))
3610 (defun gnus-article-mode ()
3611 "Major mode for displaying an article.
3613 All normal editing commands are switched off.
3615 The following commands are available in addition to all summary mode
3617 \\<gnus-article-mode-map>
3618 \\[gnus-article-next-page]\t Scroll the article one page forwards
3619 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3620 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3621 \\[gnus-article-show-summary]\t Display the summary buffer
3622 \\[gnus-article-mail]\t Send a reply to the address near point
3623 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3624 \\[gnus-info-find-node]\t Go to the Gnus info node"
3626 (gnus-simplify-mode-line)
3627 (setq mode-name "Article")
3628 (setq major-mode 'gnus-article-mode)
3629 (make-local-variable 'minor-mode-alist)
3630 (unless (assq 'gnus-show-mime minor-mode-alist)
3631 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3632 (use-local-map gnus-article-mode-map)
3633 (when (gnus-visual-p 'article-menu 'menu)
3634 (gnus-article-make-menu-bar)
3635 (when gnus-summary-tool-bar-map
3636 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3637 (gnus-update-format-specifications nil 'article-mode)
3638 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3639 (make-local-variable 'gnus-page-broken)
3640 (make-local-variable 'gnus-button-marker-list)
3641 (make-local-variable 'gnus-article-current-summary)
3642 (make-local-variable 'gnus-article-mime-handles)
3643 (make-local-variable 'gnus-article-decoded-p)
3644 (make-local-variable 'gnus-article-mime-handle-alist)
3645 (make-local-variable 'gnus-article-wash-types)
3646 (make-local-variable 'gnus-article-image-alist)
3647 (make-local-variable 'gnus-article-charset)
3648 (make-local-variable 'gnus-article-ignored-charsets)
3649 (gnus-set-default-directory)
3650 (buffer-disable-undo)
3651 (setq buffer-read-only t)
3652 (set-syntax-table gnus-article-mode-syntax-table)
3653 (gnus-run-hooks 'gnus-article-mode-hook))
3655 (defun gnus-article-setup-buffer ()
3656 "Initialize the article buffer."
3657 (let* ((name (if gnus-single-article-buffer "*Article*"
3658 (concat "*Article " gnus-newsgroup-name "*")))
3660 (progn (string-match "\\*Article" name)
3661 (concat " *Original Article"
3662 (substring name (match-end 0))))))
3663 (setq gnus-article-buffer name)
3664 (setq gnus-original-article-buffer original)
3665 (setq gnus-article-mime-handle-alist nil)
3666 ;; This might be a variable local to the summary buffer.
3667 (unless gnus-single-article-buffer
3669 (set-buffer gnus-summary-buffer)
3670 (setq gnus-article-buffer name)
3671 (setq gnus-original-article-buffer original)
3672 (gnus-set-global-variables)))
3673 (gnus-article-setup-highlight-words)
3674 ;; Init original article buffer.
3676 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3677 (set-buffer-multibyte t)
3678 (setq major-mode 'gnus-original-article-mode)
3679 (make-local-variable 'gnus-original-article))
3680 (if (get-buffer name)
3683 (when (and gnus-article-edit-mode
3686 (y-or-n-p "Article mode edit in progress; discard? ")))
3687 (error "Action aborted"))
3688 (set (make-local-variable 'gnus-article-edit-mode) nil)
3689 (buffer-disable-undo)
3690 (setq buffer-read-only t)
3691 ;; This list just keeps growing if we don't reset it.
3692 (setq gnus-button-marker-list nil)
3693 (unless (eq major-mode 'gnus-article-mode)
3694 (gnus-article-mode))
3697 (set-buffer (gnus-get-buffer-create name))
3699 (make-local-variable 'gnus-summary-buffer)
3700 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3701 (current-buffer)))))
3703 ;; Set article window start at LINE, where LINE is the number of lines
3704 ;; from the head of the article.
3705 (defun gnus-article-set-window-start (&optional line)
3707 (gnus-get-buffer-window gnus-article-buffer t)
3709 (set-buffer gnus-article-buffer)
3710 (goto-char (point-min))
3713 (gnus-message 6 "Moved to bookmark")
3714 (search-forward "\n\n" nil t)
3718 ;;; @@ article filters
3721 (defun gnus-article-display-mime-message ()
3722 "Article display method for MIME message."
3723 ;; called from `gnus-original-article-buffer'.
3724 (let (charset all-headers)
3725 (with-current-buffer gnus-summary-buffer
3726 (setq charset default-mime-charset
3727 all-headers gnus-have-all-headers))
3728 (make-local-variable 'default-mime-charset)
3729 (setq default-mime-charset charset)
3730 (with-current-buffer (get-buffer-create gnus-article-buffer)
3731 (make-local-variable 'default-mime-charset)
3732 (setq default-mime-charset charset))
3733 (mime-display-message mime-message-structure
3734 gnus-article-buffer nil gnus-article-mode-map)
3736 (gnus-article-hide-headers nil -1)))
3737 (run-hooks 'gnus-mime-article-prepare-hook))
3739 (defun gnus-article-display-traditional-message ()
3740 "Article display method for traditional message."
3741 (set-buffer gnus-article-buffer)
3742 (let (buffer-read-only)
3744 (insert-buffer-substring gnus-original-article-buffer)))
3746 (defun gnus-article-make-full-mail-header (&optional number charset)
3747 "Create a new mail header structure in a raw article buffer."
3748 (unless (and number charset)
3749 (save-current-buffer
3750 (set-buffer gnus-summary-buffer)
3752 (setq number (or (cdr gnus-article-current) 0)))
3754 (setq charset (or default-mime-charset 'x-ctext)))))
3755 (goto-char (point-min))
3756 (let ((header-end (if (search-forward "\n\n" nil t)
3758 (goto-char (point-max))))
3759 (chars (- (point-max) (point)))
3760 (lines (count-lines (point) (point-max)))
3761 (default-mime-charset charset)
3763 (narrow-to-region (point-min) header-end)
3764 (setq xref (std11-fetch-field "xref"))
3766 (make-full-mail-header
3768 (std11-fetch-field "subject")
3769 (std11-fetch-field "from")
3770 (std11-fetch-field "date")
3771 (std11-fetch-field "message-id")
3772 (std11-fetch-field "references")
3775 (when xref (concat "Xref: " xref)))
3778 (defun gnus-article-prepare (article &optional all-headers header)
3779 "Prepare ARTICLE in article mode buffer.
3780 ARTICLE should either be an article number or a Message-ID.
3781 If ARTICLE is an id, HEADER should be the article headers.
3782 If ALL-HEADERS is non-nil, no headers are hidden."
3784 ;; Make sure we start in a summary buffer.
3785 (unless (eq major-mode 'gnus-summary-mode)
3786 (set-buffer gnus-summary-buffer))
3787 (setq gnus-summary-buffer (current-buffer))
3788 (let* ((gnus-article (if header (mail-header-number header) article))
3789 (summary-buffer (current-buffer))
3790 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3791 (group gnus-newsgroup-name)
3794 (gnus-article-setup-buffer)
3795 (set-buffer gnus-article-buffer)
3796 ;; Deactivate active regions.
3797 (when (and (boundp 'transient-mark-mode)
3798 transient-mark-mode)
3799 (setq mark-active nil))
3800 (if (not (setq result (let ((buffer-read-only nil))
3801 (gnus-request-article-this-buffer
3803 ;; There is no such article.
3805 (when (and (numberp article)
3806 (not (memq article gnus-newsgroup-sparse)))
3807 (setq gnus-article-current
3808 (cons gnus-newsgroup-name article))
3809 (set-buffer gnus-summary-buffer)
3810 (setq gnus-current-article article)
3811 (if (memq article gnus-newsgroup-undownloaded)
3813 (gnus-summary-set-agent-mark article)
3814 (message "Message marked for downloading"))
3815 (gnus-summary-mark-article article gnus-canceled-mark)
3816 (unless (memq article gnus-newsgroup-sparse)
3817 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3818 (if (or (eq result 'pseudo)
3819 (eq result 'nneething))
3822 (set-buffer summary-buffer)
3823 (push article gnus-newsgroup-history)
3824 (setq gnus-last-article gnus-current-article
3825 gnus-current-article 0
3826 gnus-current-headers nil
3827 gnus-article-current nil)
3828 (if (eq result 'nneething)
3829 (gnus-configure-windows 'summary)
3830 (gnus-configure-windows 'article))
3831 (gnus-set-global-variables))
3832 (let ((gnus-article-mime-handle-alist-1
3833 gnus-article-mime-handle-alist))
3834 (gnus-set-mode-line 'article)))
3835 ;; The result from the `request' was an actual article -
3836 ;; or at least some text that is now displayed in the
3838 (when (and (numberp article)
3839 (not (eq article gnus-current-article)))
3840 ;; Seems like a new article has been selected.
3841 ;; `gnus-current-article' must be an article number.
3843 (set-buffer summary-buffer)
3844 (push article gnus-newsgroup-history)
3845 (setq gnus-last-article gnus-current-article
3846 gnus-current-article article
3847 gnus-current-headers
3848 (gnus-summary-article-header gnus-current-article)
3849 gnus-article-current
3850 (cons gnus-newsgroup-name gnus-current-article))
3851 (unless (vectorp gnus-current-headers)
3852 (setq gnus-current-headers nil))
3853 (gnus-summary-goto-subject gnus-current-article)
3854 (when (gnus-summary-show-thread)
3855 ;; If the summary buffer really was folded, the
3856 ;; previous goto may not actually have gone to
3857 ;; the right article, but the thread root instead.
3859 (gnus-summary-goto-subject gnus-current-article))
3860 (gnus-run-hooks 'gnus-mark-article-hook)
3861 (gnus-set-mode-line 'summary)
3862 (when (gnus-visual-p 'article-highlight 'highlight)
3863 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3864 ;; Set the global newsgroup variables here.
3865 (gnus-set-global-variables)
3866 (setq gnus-have-all-headers
3867 (or all-headers gnus-show-all-headers))))
3869 (gnus-configure-windows 'article))
3870 (when (or (numberp article)
3872 (gnus-article-prepare-display)
3874 (goto-char (point-min))
3875 (setq gnus-page-broken
3876 (when gnus-break-pages
3877 (gnus-narrow-to-page)
3879 (let ((gnus-article-mime-handle-alist-1
3880 gnus-article-mime-handle-alist))
3881 (gnus-set-mode-line 'article))
3885 (set-window-point (get-buffer-window (current-buffer)) (point))
3886 (gnus-configure-windows 'article)
3889 (defun gnus-article-prepare-mime-display (&optional number)
3890 (goto-char (point-min))
3891 (when (re-search-forward "^[^\t ]+:" nil t)
3892 (goto-char (match-beginning 0)))
3893 (let ((entity (if (eq 1 (point-min))
3894 (get-text-property 1 'mime-view-entity)
3895 (get-text-property (point) 'mime-view-entity)))
3896 last-entity child-entity next type)
3897 (setq child-entity (mime-entity-children entity))
3899 (setq last-entity (nth (1- (length child-entity))
3901 (setq last-entity entity))
3903 (narrow-to-region (point)
3904 (if (search-forward "\n\n" nil t)
3907 (gnus-treat-article 'head)
3908 (put-text-property (point-min) (point-max) 'article-treated-header t)
3909 (goto-char (point-max)))
3910 (while (and (not (eobp)) entity)
3911 (setq next (set-marker
3913 (next-single-property-change (point) 'mime-view-entity
3915 (let ((types (mime-entity-content-type entity)))
3916 (while (eq 'multipart (mime-content-type-primary-type types))
3917 (setq entity (car (mime-entity-children entity))
3918 types (mime-entity-content-type entity)))
3920 (setq type (format "%s/%s"
3921 (mime-content-type-primary-type types)
3922 (mime-content-type-subtype types)))))
3923 (if (string-equal type "message/rfc822")
3926 (let ((children (mime-entity-children entity))
3929 (setq last-children (nth (1- (length children)) children))
3932 (not (eq last-children
3933 (get-text-property next 'mime-view-entity)))
3935 (next-single-property-change next
3937 nil (point-max)))))))
3938 (setq next (next-single-property-change next 'mime-view-entity
3941 (narrow-to-region (point) next)
3942 (gnus-article-prepare-mime-display)
3943 (goto-char (point-max)))
3944 (setq entity (get-text-property (point) 'mime-view-entity)))
3946 (narrow-to-region (point) next)
3947 ;; Kludge. We have to count true number, but for now,
3948 ;; part number is here only to achieve `last'.
3949 (gnus-treat-article nil 1
3950 (if (eq entity last-entity)
3953 (goto-char (point-max)))
3954 (setq entity (get-text-property next 'mime-view-entity))))))
3957 (defun gnus-article-prepare-display ()
3958 "Make the current buffer look like a nice article."
3959 (let ((gnus-article-buffer (current-buffer))
3961 (unless (eq major-mode 'gnus-article-mode)
3962 (gnus-article-mode))
3963 (setq buffer-read-only nil
3964 gnus-button-marker-list nil
3965 gnus-article-wash-types nil
3966 gnus-article-image-alist nil)
3969 (static-if (featurep 'xemacs)
3970 (map-extents (lambda (extent maparg) (delete-extent extent)))
3971 (let ((lists (overlay-lists)))
3972 (dolist (overlay (nconc (car lists) (cdr lists)))
3973 (delete-overlay overlay)))))
3974 (gnus-run-hooks 'gnus-tmp-internal-hook))
3975 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
3978 (inhibit-read-only t))
3979 (set-buffer gnus-original-article-buffer)
3981 (setq mime-message-structure gnus-current-headers)
3982 (mime-buffer-entity-set-buffer-internal mime-message-structure
3983 gnus-original-article-buffer)
3984 (mime-entity-set-representation-type-internal mime-message-structure
3985 'mime-buffer-entity)
3986 (luna-send mime-message-structure 'initialize-instance
3987 mime-message-structure)
3989 (let (mime-display-header-hook mime-display-text/plain-hook)
3990 (funcall gnus-article-display-method-for-mime))
3991 (funcall gnus-article-display-method-for-traditional))
3992 ;; Call the treatment functions.
3996 (gnus-article-prepare-mime-display)
3997 (narrow-to-region (goto-char (point-min))
3998 (if (search-forward "\n\n" nil t)
4001 (gnus-treat-article 'head)
4002 (put-text-property (point-min) (point-max) 'article-treated-header t)
4003 (goto-char (point-max))
4005 (narrow-to-region (point) (point-max))
4006 (gnus-treat-article nil))
4007 (put-text-property (point-min) (point-max) 'read-only nil)))
4008 (gnus-run-hooks 'gnus-article-prepare-hook))
4010 (defun gnus-article-decode-article-as-default-mime-charset ()
4011 "Decode an article as `default-mime-charset'. It won't work if the
4012 value of the variable `gnus-show-mime' is non-nil."
4013 (unless (or gnus-show-mime
4014 (member gnus-newsgroup-name '("nndraft:delayed"
4016 (set (make-local-variable 'default-mime-charset)
4017 (with-current-buffer gnus-summary-buffer
4018 default-mime-charset))
4019 (decode-mime-charset-region (point-min) (point-max)
4020 default-mime-charset)))
4023 ;;; Gnus MIME viewing functions
4026 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4027 "Format of the MIME buttons.
4029 Valid specifiers include:
4031 %T MIME type, along with additional info
4032 %n The `name' parameter
4033 %d The description, if any
4034 %l The length of the encoded part
4035 %p The part identifier number
4036 %e Dots if the part isn't displayed
4038 General format specifiers can also be used. See Info node
4039 `(gnus)Formatting Variables'.")
4041 (defvar gnus-mime-button-line-format-alist
4042 '((?t gnus-tmp-type ?s)
4043 (?T gnus-tmp-type-long ?s)
4044 (?n gnus-tmp-name ?s)
4045 (?d gnus-tmp-description ?s)
4047 (?l gnus-tmp-length ?d)
4048 (?e gnus-tmp-dots ?s)))
4050 (defvar gnus-mime-button-commands
4051 '((gnus-article-press-button "\r" "Toggle Display")
4052 (gnus-mime-view-part "v" "View Interactively...")
4053 (gnus-mime-view-part-as-type "t" "View As Type...")
4054 (gnus-mime-view-part-as-charset "C" "View As charset...")
4055 (gnus-mime-save-part "o" "Save...")
4056 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4057 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4058 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4059 (gnus-mime-view-part-internally "E" "View Internally")
4060 (gnus-mime-view-part-externally "e" "View Externally")
4061 (gnus-mime-print-part "p" "Print")
4062 (gnus-mime-pipe-part "|" "Pipe To Command...")
4063 (gnus-mime-action-on-part "." "Take action on the part")))
4065 (defun gnus-article-mime-part-status ()
4066 (with-current-buffer gnus-article-buffer
4067 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4070 (setq children (mime-entity-children entity))
4071 (setq children (length children)))
4074 (format " (%d parts)" children))
4077 (defvar gnus-mime-button-map
4078 (let ((map (make-sparse-keymap)))
4079 (unless (>= (string-to-number emacs-version) 21)
4080 ;; XEmacs doesn't care.
4081 (set-keymap-parent map gnus-article-mode-map))
4082 (define-key map gnus-mouse-2 'gnus-article-push-button)
4083 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4084 (dolist (c gnus-mime-button-commands)
4085 (define-key map (cadr c) (car c)))
4088 (defun gnus-mime-button-menu (event)
4089 "Construct a context-sensitive menu of MIME commands."
4091 (save-window-excursion
4092 (let ((pos (event-start event)))
4093 (select-window (posn-window pos))
4094 (goto-char (posn-point pos))
4095 (gnus-article-check-buffer)
4096 (let ((response (x-popup-menu
4098 ("" ,@(mapcar (lambda (c)
4099 (cons (caddr c) (car c)))
4100 gnus-mime-button-commands))))))
4102 (call-interactively response))))))
4104 (defun gnus-mime-view-all-parts (&optional handles)
4105 "View all the MIME parts."
4107 (save-current-buffer
4108 (set-buffer gnus-article-buffer)
4109 (let ((handles (or handles gnus-article-mime-handles))
4110 (mail-parse-charset gnus-newsgroup-charset)
4111 (mail-parse-ignored-charsets
4112 (with-current-buffer gnus-summary-buffer
4113 gnus-newsgroup-ignored-charsets)))
4115 (mm-remove-parts handles)
4116 (goto-char (point-min))
4117 (or (search-forward "\n\n") (goto-char (point-max)))
4118 (let (buffer-read-only)
4119 (delete-region (point) (point-max))
4120 (mm-display-parts handles))))))
4122 (defun gnus-mime-save-part-and-strip ()
4123 "Save the MIME part under point then replace it with an external body."
4125 (gnus-article-check-buffer)
4126 (let* ((data (get-text-property (point) 'gnus-data))
4128 (handles gnus-article-mime-handles))
4129 (if (mm-multiple-handles gnus-article-mime-handles)
4130 (error "This function is not implemented"))
4131 (setq file (and data (mm-save-part data)))
4133 (with-current-buffer (mm-handle-buffer data)
4135 (insert "Content-Type: " (mm-handle-media-type data))
4136 (mml-insert-parameter-string (cdr (mm-handle-type data))
4139 (insert "Content-ID: " (message-make-message-id) "\n")
4140 (insert "Content-Transfer-Encoding: binary\n")
4143 (cdr (mm-make-handle nil
4144 `("message/external-body"
4145 (access-type . "LOCAL-FILE")
4147 (set-buffer gnus-summary-buffer)
4148 (gnus-article-edit-article
4151 (let ((mail-parse-charset (or gnus-article-charset
4152 ',gnus-newsgroup-charset))
4153 (mail-parse-ignored-charsets
4154 (or gnus-article-ignored-charsets
4155 ',gnus-newsgroup-ignored-charsets))
4156 (mbl mml-buffer-list))
4157 (setq mml-buffer-list nil)
4158 (insert-buffer gnus-original-article-buffer)
4159 (mime-to-mml ',handles)
4160 (setq gnus-article-mime-handles nil)
4161 (let ((mbl1 mml-buffer-list))
4162 (setq mml-buffer-list mbl)
4163 (set (make-local-variable 'mml-buffer-list) mbl1))
4164 ;; LOCAL argument of add-hook differs between GNU Emacs
4165 ;; and XEmacs. make-local-hook makes sure they are local.
4166 (make-local-hook 'kill-buffer-hook)
4167 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4168 `(lambda (no-highlight)
4169 (let ((mail-parse-charset (or gnus-article-charset
4170 ',gnus-newsgroup-charset))
4171 (message-options message-options)
4172 (message-options-set-recipient)
4173 (mail-parse-ignored-charsets
4174 (or gnus-article-ignored-charsets
4175 ',gnus-newsgroup-ignored-charsets)))
4177 (mml-destroy-buffers)
4178 (remove-hook 'kill-buffer-hook
4179 'mml-destroy-buffers t)
4180 (kill-local-variable 'mml-buffer-list))
4181 (gnus-summary-edit-article-done
4182 ,(or (mail-header-references gnus-current-headers) "")
4183 ,(gnus-group-read-only-p)
4184 ,gnus-summary-buffer no-highlight))))))
4186 (defun gnus-mime-save-part ()
4187 "Save the MIME part under point."
4189 (gnus-article-check-buffer)
4190 (let ((data (get-text-property (point) 'gnus-data)))
4192 (mm-save-part data))))
4194 (defun gnus-mime-pipe-part ()
4195 "Pipe the MIME part under point to a process."
4197 (gnus-article-check-buffer)
4198 (let ((data (get-text-property (point) 'gnus-data)))
4200 (mm-pipe-part data))))
4202 (defun gnus-mime-view-part ()
4203 "Interactively choose a viewing method for the MIME part under point."
4205 (gnus-article-check-buffer)
4206 (let ((data (get-text-property (point) 'gnus-data)))
4208 (setq gnus-article-mime-handles
4210 gnus-article-mime-handles (setq data (copy-sequence data))))
4211 (mm-interactively-view-part data))))
4213 (defun gnus-mime-view-part-as-type-internal ()
4214 (gnus-article-check-buffer)
4215 (let* ((name (mail-content-type-get
4216 (mm-handle-type (get-text-property (point) 'gnus-data))
4218 (def-type (and name (mm-default-file-encoding name))))
4219 (and def-type (cons def-type 0))))
4221 (defun gnus-mime-view-part-as-type (&optional mime-type)
4222 "Choose a MIME media type, and view the part as such."
4225 (setq mime-type (completing-read
4226 "View as MIME type: "
4227 (mapcar #'list (mailcap-mime-types))
4229 (gnus-mime-view-part-as-type-internal))))
4230 (gnus-article-check-buffer)
4231 (let ((handle (get-text-property (point) 'gnus-data)))
4234 (mm-make-handle (mm-handle-buffer handle)
4235 (cons mime-type (cdr (mm-handle-type handle)))
4236 (mm-handle-encoding handle)
4237 (mm-handle-undisplayer handle)
4238 (mm-handle-disposition handle)
4239 (mm-handle-description handle)
4241 (mm-handle-id handle)))
4242 (setq gnus-article-mime-handles
4243 (mm-merge-handles gnus-article-mime-handles handle))
4244 (gnus-mm-display-part handle))))
4247 (require 'jka-compr))
4249 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4250 ;; emacs can do that itself.
4252 (defun gnus-mime-jka-compr-maybe-uncompress ()
4253 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4254 The uncompress method used is derived from `buffer-file-name'."
4255 (when (and (fboundp 'jka-compr-installed-p)
4256 (jka-compr-installed-p))
4257 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4259 (let ((basename (file-name-nondirectory buffer-file-name))
4260 (args (jka-compr-info-uncompress-args info))
4261 (prog (jka-compr-info-uncompress-program info))
4262 (message (jka-compr-info-uncompress-message info))
4263 (err-file (jka-compr-make-temp-name)))
4265 (message "%s %s..." message basename))
4267 (unless (memq (apply 'call-process-region
4268 (point-min) (point-max)
4270 t (list t err-file) nil
4272 jka-compr-acceptable-retval-list)
4273 (jka-compr-error prog args basename message err-file))
4274 (jka-compr-delete-temp-file err-file)))))))
4276 (defun gnus-mime-copy-part (&optional handle)
4277 "Put the MIME part under point into a new buffer.
4278 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4281 (gnus-article-check-buffer)
4282 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4283 (contents (and handle (mm-get-part handle)))
4285 (file-name-nondirectory
4287 (mail-content-type-get (mm-handle-type handle) 'name)
4288 (mail-content-type-get (mm-handle-disposition handle)
4291 (buffer (and base (generate-new-buffer base))))
4293 (switch-to-buffer buffer)
4295 ;; We do it this way to make `normal-mode' set the appropriate mode.
4298 (setq buffer-file-name (expand-file-name base))
4299 (gnus-mime-jka-compr-maybe-uncompress)
4301 (setq buffer-file-name nil))
4302 (goto-char (point-min)))))
4304 (defun gnus-mime-print-part (&optional handle filename)
4305 "Print the MIME part under point."
4306 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4307 (gnus-article-check-buffer)
4308 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4309 (contents (and handle (mm-get-part handle)))
4310 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4311 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4316 (mm-save-part-to-file handle file)
4317 (call-process shell-file-name nil
4318 (generate-new-buffer " *mm*")
4320 shell-command-switch
4322 printer file (mm-handle-type handle))))
4326 (gnus-print-buffer))
4327 (ps-despool filename)))))
4329 (defun gnus-mime-inline-part (&optional handle arg)
4330 "Insert the MIME part under point into the current buffer."
4331 (interactive (list nil current-prefix-arg))
4332 (gnus-article-check-buffer)
4333 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4338 (if (and (not arg) (mm-handle-undisplayer handle))
4339 (mm-remove-part handle)
4340 (setq contents (mm-get-part handle))
4343 (setq charset (or (mail-content-type-get
4344 (mm-handle-type handle) 'charset)
4345 gnus-newsgroup-charset)))
4347 (if (mm-handle-undisplayer handle)
4348 (mm-remove-part handle))
4351 gnus-summary-show-article-charset-alist))
4352 (mm-read-coding-system "Charset: ")))))
4354 (mm-insert-inline handle
4356 (setq charset (mm-charset-to-coding-system
4358 (not (eq charset 'ascii)))
4359 (mm-decode-coding-string contents charset)
4363 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4364 "Insert the MIME part under point into the current buffer using the
4366 (interactive (list nil current-prefix-arg))
4367 (gnus-article-check-buffer)
4368 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4373 (if (mm-handle-undisplayer handle)
4374 (mm-remove-part handle))
4375 (let ((gnus-newsgroup-charset
4377 gnus-summary-show-article-charset-alist))
4378 (mm-read-coding-system "Charset: ")))
4379 (gnus-newsgroup-ignored-charsets 'gnus-all))
4380 (gnus-article-press-button)))))
4382 (defun gnus-mime-view-part-externally (&optional handle)
4383 "View the MIME part under point with an external viewer."
4385 (gnus-article-check-buffer)
4386 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4387 (mm-user-display-methods nil)
4388 (mm-inlined-types nil)
4389 (mail-parse-charset gnus-newsgroup-charset)
4390 (mail-parse-ignored-charsets
4391 (save-excursion (set-buffer gnus-summary-buffer)
4392 gnus-newsgroup-ignored-charsets)))
4394 (if (mm-handle-undisplayer handle)
4395 (mm-remove-part handle)
4396 (mm-display-part handle)))))
4398 (defun gnus-mime-view-part-internally (&optional handle)
4399 "View the MIME part under point with an internal viewer.
4400 If no internal viewer is available, use an external viewer."
4402 (gnus-article-check-buffer)
4403 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4404 (mm-inlined-types '(".*"))
4405 (mm-inline-large-images t)
4406 (mail-parse-charset gnus-newsgroup-charset)
4407 (mail-parse-ignored-charsets
4408 (save-excursion (set-buffer gnus-summary-buffer)
4409 gnus-newsgroup-ignored-charsets))
4412 (if (mm-handle-undisplayer handle)
4413 (mm-remove-part handle)
4414 (mm-display-part handle)))))
4416 (defun gnus-mime-action-on-part (&optional action)
4417 "Do something with the MIME attachment at \(point\)."
4419 (list (completing-read "Action: " gnus-mime-action-alist)))
4420 (gnus-article-check-buffer)
4421 (let ((action-pair (assoc action gnus-mime-action-alist)))
4423 (funcall (cdr action-pair)))))
4425 (defun gnus-article-part-wrapper (n function)
4426 (save-current-buffer
4427 (set-buffer gnus-article-buffer)
4428 (when (> n (length gnus-article-mime-handle-alist))
4429 (error "No such part"))
4430 (gnus-article-goto-part n)
4431 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4432 (funcall function handle))))
4434 (defun gnus-article-pipe-part (n)
4435 "Pipe MIME part N, which is the numerical prefix."
4437 (gnus-article-part-wrapper n 'mm-pipe-part))
4439 (defun gnus-article-save-part (n)
4440 "Save MIME part N, which is the numerical prefix."
4442 (gnus-article-part-wrapper n 'mm-save-part))
4444 (defun gnus-article-interactively-view-part (n)
4445 "View MIME part N interactively, which is the numerical prefix."
4447 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4449 (defun gnus-article-copy-part (n)
4450 "Copy MIME part N, which is the numerical prefix."
4452 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4454 (defun gnus-article-view-part-as-charset (n)
4455 "Copy MIME part N, which is the numerical prefix."
4457 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4459 (defun gnus-article-view-part-externally (n)
4460 "View MIME part N externally, which is the numerical prefix."
4462 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4464 (defun gnus-article-inline-part (n)
4465 "Inline MIME part N, which is the numerical prefix."
4467 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4469 (defun gnus-article-mime-match-handle-first (condition)
4471 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4472 (while (setq ihandle (pop alist))
4474 ((functionp condition)
4475 (funcall condition (cdr ihandle)))
4476 ((eq condition 'undisplayed)
4477 (not (or (mm-handle-undisplayer (cdr ihandle))
4478 (equal (mm-handle-media-type (cdr ihandle))
4479 "multipart/alternative"))))
4480 ((eq condition 'undisplayed-alternative)
4481 (not (mm-handle-undisplayer (cdr ihandle))))
4483 (gnus-article-goto-part (car ihandle))
4484 (or (not n) (< (car ihandle) n)))
4485 (setq n (car ihandle))))
4489 (defun gnus-article-view-part (&optional n)
4490 "View MIME part N, which is the numerical prefix."
4492 (save-current-buffer
4493 (set-buffer gnus-article-buffer)
4494 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4495 gnus-article-mime-match-handle-function)))
4496 (when (> n (length gnus-article-mime-handle-alist))
4497 (error "No such part"))
4498 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4499 (when (gnus-article-goto-part n)
4500 (if (equal (car handle) "multipart/alternative")
4501 (gnus-article-press-button)
4502 (when (eq (gnus-mm-display-part handle) 'internal)
4503 (gnus-set-window-start)))))))
4505 (defsubst gnus-article-mime-total-parts ()
4506 (if (bufferp (car gnus-article-mime-handles))
4508 (1- (length gnus-article-mime-handles))))
4510 (defun gnus-mm-display-part (handle)
4511 "Display HANDLE and fix MIME button."
4512 (let ((id (get-text-property (point) 'gnus-part))
4517 (let ((window (selected-window))
4518 (mail-parse-charset gnus-newsgroup-charset)
4519 (mail-parse-ignored-charsets
4520 (if (gnus-buffer-live-p gnus-summary-buffer)
4522 (set-buffer gnus-summary-buffer)
4523 gnus-newsgroup-ignored-charsets)
4527 (let ((win (gnus-get-buffer-window (current-buffer) t))
4530 (select-window win))
4533 (if (mm-handle-displayed-p handle)
4534 ;; This will remove the part.
4535 (mm-display-part handle)
4537 (narrow-to-region (point)
4538 (if (eobp) (point) (1+ (point))))
4539 (mm-display-part handle)
4540 ;; We narrow to the part itself and
4541 ;; then call the treatment functions.
4542 (goto-char (point-min))
4544 (narrow-to-region (point) (point-max))
4547 (gnus-article-mime-total-parts)
4548 (mm-handle-media-type handle)))))
4549 (if (window-live-p window)
4550 (select-window window)))))
4552 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4553 (gnus-insert-mime-button
4554 handle id (list (mm-handle-displayed-p handle)))
4555 (goto-char point))))
4557 (defun gnus-article-goto-part (n)
4558 "Go to MIME part N."
4559 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4561 (goto-char point))))
4563 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4564 (let ((gnus-tmp-name
4565 (or (mail-content-type-get (mm-handle-type handle) 'name)
4566 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4567 (mail-content-type-get (mm-handle-type handle) 'url)
4569 (gnus-tmp-type (mm-handle-media-type handle))
4570 (gnus-tmp-description
4571 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4574 (if (if displayed (car displayed)
4575 (mm-handle-displayed-p handle))
4577 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4579 gnus-tmp-type-long b e)
4580 (when (string-match ".*/" gnus-tmp-name)
4581 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4582 (setq gnus-tmp-type-long (concat gnus-tmp-type
4583 (and (not (equal gnus-tmp-name ""))
4584 (concat "; " gnus-tmp-name))))
4585 (unless (equal gnus-tmp-description "")
4586 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4591 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4592 `(,@(gnus-local-map-property gnus-mime-button-map)
4593 gnus-callback gnus-mm-display-part
4594 gnus-part ,gnus-tmp-id
4595 article-type annotation
4598 (widget-convert-button
4601 :action 'gnus-widget-press-button
4602 :button-keymap gnus-mime-button-map
4604 (lambda (widget/window &optional overlay pos)
4605 ;; Needed to properly clear the message due to a bug in
4606 ;; wid-edit (XEmacs only).
4607 (if (boundp 'help-echo-owns-message)
4608 (setq help-echo-owns-message t))
4610 "%S: %s the MIME part; %S: more options"
4611 (aref gnus-mouse-2 0)
4612 ;; XEmacs will get a single widget arg; Emacs 21 will get
4613 ;; window, overlay, position.
4614 (if (mm-handle-displayed-p
4616 (with-current-buffer (gnus-overlay-buffer overlay)
4617 (widget-get (widget-at (gnus-overlay-start overlay))
4619 (widget-get widget/window :mime-handle)))
4621 (aref gnus-down-mouse-3 0))))))
4623 (defun gnus-widget-press-button (elems el)
4624 (goto-char (widget-get elems :from))
4625 (gnus-article-press-button))
4627 (defvar gnus-displaying-mime nil)
4629 (defun gnus-display-mime (&optional ihandles)
4630 "Display the MIME parts."
4632 (save-selected-window
4633 (let ((window (get-buffer-window gnus-article-buffer))
4636 (select-window window)
4637 ;; We have to do this since selecting the window
4638 ;; may change the point. So we set the window point.
4639 (set-window-point window point)))
4640 (let* ((handles (or ihandles
4641 (mm-dissect-buffer nil gnus-article-loose-mime)
4642 (and gnus-article-emulate-mime
4644 buffer-read-only handle name type b e display)
4645 (when (and (not ihandles)
4646 (not gnus-displaying-mime))
4647 ;; Top-level call; we clean up.
4648 (when gnus-article-mime-handles
4649 (mm-destroy-parts gnus-article-mime-handles)
4650 (setq gnus-article-mime-handle-alist nil));; A trick.
4651 (setq gnus-article-mime-handles handles)
4652 ;; We allow users to glean info from the handles.
4653 (when gnus-article-mime-part-function
4654 (gnus-mime-part-function handles)))
4656 (or (not (stringp (car handles)))
4659 (when (and (not ihandles)
4660 (not gnus-displaying-mime))
4661 ;; Clean up for mime parts.
4663 (delete-region (point) (point-max)))
4664 (let ((gnus-displaying-mime t))
4665 (gnus-mime-display-part handles)))
4668 (narrow-to-region (point) (point-max))
4669 (gnus-treat-article nil 1 1)
4672 ;; Highlight the headers.
4676 (narrow-to-region (point-min) (point))
4677 (gnus-treat-article 'head))))))))
4679 (defvar gnus-mime-display-multipart-as-mixed nil)
4680 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4681 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4683 (defun gnus-mime-display-part (handle)
4686 ((not (stringp (car handle)))
4687 (gnus-mime-display-single handle))
4688 ;; User-defined multipart
4689 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4690 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4692 ;; multipart/alternative
4693 ((and (equal (car handle) "multipart/alternative")
4694 (not (or gnus-mime-display-multipart-as-mixed
4695 gnus-mime-display-multipart-alternative-as-mixed)))
4696 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4697 (push (cons id handle) gnus-article-mime-handle-alist)
4698 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4699 ;; multipart/related
4700 ((and (equal (car handle) "multipart/related")
4701 (not (or gnus-mime-display-multipart-as-mixed
4702 gnus-mime-display-multipart-related-as-mixed)))
4703 ;;;!!!We should find the start part, but we just default
4704 ;;;!!!to the first part.
4705 ;;(gnus-mime-display-part (cadr handle))
4706 ;;;!!! Most multipart/related is an HTML message plus images.
4707 ;;;!!! Unfortunately we are unable to let W3 display those
4708 ;;;!!! included images, so we just display it as a mixed multipart.
4709 ;;(gnus-mime-display-mixed (cdr handle))
4710 ;;;!!! No, w3 can display everything just fine.
4711 (gnus-mime-display-part (cadr handle)))
4712 ((equal (car handle) "multipart/signed")
4713 (gnus-add-wash-type 'signed)
4714 (gnus-mime-display-security handle))
4715 ((equal (car handle) "multipart/encrypted")
4716 (gnus-add-wash-type 'encrypted)
4717 (gnus-mime-display-security handle))
4718 ;; Other multiparts are handled like multipart/mixed.
4720 (gnus-mime-display-mixed (cdr handle)))))
4722 (defun gnus-mime-part-function (handles)
4723 (if (stringp (car handles))
4724 (mapcar 'gnus-mime-part-function (cdr handles))
4725 (funcall gnus-article-mime-part-function handles)))
4727 (defun gnus-mime-display-mixed (handles)
4728 (mapcar 'gnus-mime-display-part handles))
4730 (defun gnus-mime-display-single (handle)
4731 (let ((type (mm-handle-media-type handle))
4732 (ignored gnus-ignored-mime-types)
4739 (when (string-match (pop ignored) type)
4740 (throw 'ignored nil)))
4741 (if (and (setq not-attachment
4742 (and (not (mm-inline-override-p handle))
4743 (or (not (mm-handle-disposition handle))
4744 (equal (car (mm-handle-disposition handle))
4746 (mm-attachment-override-p handle))))
4747 (mm-automatic-display-p handle)
4749 (mm-inlinable-p handle)
4750 (mm-inlined-p handle))
4751 (mm-automatic-external-display-p type)))
4753 (when (equal (mm-handle-media-supertype handle) "text")
4755 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4757 (push (cons id handle) gnus-article-mime-handle-alist)
4758 (when (or (not display)
4759 (not (gnus-unbuttonized-mime-type-p type)))
4760 ;(gnus-article-insert-newline)
4761 (gnus-insert-mime-button
4762 handle id (list (or display (and not-attachment text))))
4763 (gnus-article-insert-newline)
4764 ;(gnus-article-insert-newline)
4765 ;; Remember modify the number of forward lines.
4773 (let ((mail-parse-charset gnus-newsgroup-charset)
4774 (mail-parse-ignored-charsets
4775 (save-excursion (condition-case ()
4776 (set-buffer gnus-summary-buffer)
4778 gnus-newsgroup-ignored-charsets)))
4779 (mm-display-part handle t))
4780 (goto-char (point-max)))
4781 ((and text not-attachment)
4785 (gnus-article-insert-newline)
4786 (mm-insert-inline handle (mm-get-part handle))
4787 (goto-char (point-max))))
4791 (narrow-to-region beg (point))
4794 (gnus-article-mime-total-parts)
4795 (mm-handle-media-type handle)))))))))
4797 (defun gnus-unbuttonized-mime-type-p (type)
4798 "Say whether TYPE is to be unbuttonized."
4799 (unless gnus-inhibit-mime-unbuttonizing
4801 (let ((types gnus-unbuttonized-mime-types))
4803 (when (string-match (pop types) type)
4804 (throw 'found t)))))
4806 (let ((types gnus-buttonized-mime-types))
4808 (when (string-match (pop types) type)
4809 (throw 'found t)))))))))
4811 (defun gnus-article-insert-newline ()
4812 "Insert a newline, but mark it as undeletable."
4813 (gnus-put-text-property
4814 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4816 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4817 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4820 handle buffer-read-only from props begend not-pref)
4821 (save-window-excursion
4824 (narrow-to-region (car ibegend)
4827 (goto-char (car ibegend))
4830 (delete-region (point-min) (point-max))
4831 (mm-remove-parts handles))
4832 (setq begend (list (point-marker)))
4834 (unless (setq not-pref (cadr (member preferred ihandles)))
4835 (setq not-pref (car ihandles)))
4838 (not (gnus-unbuttonized-mime-type-p
4839 "multipart/alternative")))
4840 (gnus-add-text-properties
4843 (insert (format "%d. " id))
4847 (unless ,(not ibegend)
4848 (setq gnus-article-mime-handle-alist
4849 ',gnus-article-mime-handle-alist))
4850 (gnus-mime-display-alternative
4851 ',ihandles ',not-pref ',begend ,id))
4852 ,@(gnus-local-map-property gnus-mime-button-map)
4853 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4854 face ,gnus-article-button-face
4857 (widget-convert-button 'link from (point)
4858 :action 'gnus-widget-press-button
4859 :button-keymap gnus-widget-button-keymap)
4861 (while (setq handle (pop handles))
4862 (gnus-add-text-properties
4865 (insert (format "(%c) %-18s"
4866 (if (equal handle preferred) ?* ? )
4867 (mm-handle-media-type handle)))
4871 (unless ,(not ibegend)
4872 (setq gnus-article-mime-handle-alist
4873 ',gnus-article-mime-handle-alist))
4874 (gnus-mime-display-alternative
4875 ',ihandles ',handle ',begend ,id))
4876 ,@(gnus-local-map-property gnus-mime-button-map)
4877 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4878 face ,gnus-article-button-face
4881 (widget-convert-button 'link from (point)
4882 :action 'gnus-widget-press-button
4883 :button-keymap gnus-widget-button-keymap)
4887 (if (stringp (car preferred))
4888 (gnus-display-mime preferred)
4889 (let ((mail-parse-charset gnus-newsgroup-charset)
4890 (mail-parse-ignored-charsets
4891 (save-excursion (set-buffer gnus-summary-buffer)
4892 gnus-newsgroup-ignored-charsets)))
4893 (mm-display-part preferred)
4897 (narrow-to-region (car begend) (point-max))
4899 nil (length gnus-article-mime-handle-alist)
4900 (gnus-article-mime-total-parts)
4901 (mm-handle-media-type handle))))))
4902 (goto-char (point-max))
4903 (setcdr begend (point-marker)))))
4905 (goto-char point))))
4907 (defconst gnus-article-wash-status-strings
4908 (let ((alist '((cite "c" "Possible hidden citation text"
4909 " " "All citation text visible")
4910 (headers "h" "Hidden headers"
4911 " " "All headers visible.")
4912 (pgp "p" "Encrypted or signed message status hidden"
4913 " " "No hidden encryption nor digital signature status")
4914 (signature "s" "Signature has been hidden"
4915 " " "Signature is visible")
4916 (overstrike "o" "Overstrike (^H) characters applied"
4917 " " "No overstrike characters applied")
4918 (gnus-show-mime "m" "Mime processing is activated"
4919 " " "Mime processing is not activated")
4920 (emphasis "e" "/*_Emphasis_*/ characters applied"
4921 " " "No /*_emphasis_*/ characters applied")))
4923 (dolist (entry alist result)
4924 (let ((key (nth 0 entry))
4925 (on (copy-sequence (nth 1 entry)))
4926 (on-help (nth 2 entry))
4927 (off (copy-sequence (nth 3 entry)))
4928 (off-help (nth 4 entry)))
4929 (put-text-property 0 1 'help-echo on-help on)
4930 (put-text-property 0 1 'help-echo off-help off)
4931 (push (list key on off) result))))
4932 "Alist of strings describing wash status in the mode line.
4933 Each entry has the form (KEY ON OF), where the KEY is a symbol
4934 representing the particular washing function, ON is the string to use
4935 in the article mode line when the washing function is active, and OFF
4936 is the string to use when it is inactive.")
4938 (defun gnus-article-wash-status-entry (key value)
4939 (let ((entry (assoc key gnus-article-wash-status-strings)))
4940 (if value (nth 1 entry) (nth 2 entry))))
4942 (defun gnus-article-wash-status ()
4943 "Return a string which display status of article washing."
4945 (set-buffer gnus-article-buffer)
4946 (let ((cite (memq 'cite gnus-article-wash-types))
4947 (headers (memq 'headers gnus-article-wash-types))
4948 (boring (memq 'boring-headers gnus-article-wash-types))
4949 (pgp (memq 'pgp gnus-article-wash-types))
4950 (pem (memq 'pem gnus-article-wash-types))
4951 (signed (memq 'signed gnus-article-wash-types))
4952 (encrypted (memq 'encrypted gnus-article-wash-types))
4953 (signature (memq 'signature gnus-article-wash-types))
4954 (overstrike (memq 'overstrike gnus-article-wash-types))
4955 (emphasis (memq 'emphasis gnus-article-wash-types)))
4957 (gnus-article-wash-status-entry 'cite cite)
4958 (gnus-article-wash-status-entry 'headers (or headers boring))
4959 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4960 (gnus-article-wash-status-entry 'signature signature)
4961 (gnus-article-wash-status-entry 'overstrike overstrike)
4962 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4963 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4965 (defun gnus-add-wash-type (type)
4966 "Add a washing of TYPE to the current status."
4967 (add-to-list 'gnus-article-wash-types type))
4969 (defun gnus-delete-wash-type (type)
4970 "Add a washing of TYPE to the current status."
4971 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4973 (defun gnus-add-image (category image)
4974 "Add IMAGE of CATEGORY to the list of displayed images."
4975 (let ((entry (assq category gnus-article-image-alist)))
4977 (setq entry (list category))
4978 (push entry gnus-article-image-alist))
4979 (nconc entry (list image))))
4981 (defun gnus-delete-images (category)
4982 "Delete all images in CATEGORY."
4983 (let ((entry (assq category gnus-article-image-alist)))
4984 (dolist (image (cdr entry))
4985 (gnus-remove-image image))
4986 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4987 (gnus-delete-wash-type category)))
4989 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4991 (defun gnus-article-maybe-hide-headers ()
4992 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4993 Provided for backwards compatibility."
4994 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4995 (not (save-excursion (set-buffer gnus-summary-buffer)
4996 gnus-have-all-headers)))
4997 (not gnus-inhibit-hiding))
4998 (gnus-article-hide-headers)))
5002 (defun gnus-output-to-file (file-name)
5003 "Append the current article to a file named FILE-NAME."
5004 (let ((artbuf (current-buffer)))
5006 (insert-buffer-substring artbuf)
5007 ;; Append newline at end of the buffer as separator, and then
5009 (goto-char (point-max))
5011 (let ((file-name-coding-system nnmail-pathname-coding-system)
5012 (pathname-coding-system nnmail-pathname-coding-system))
5013 (write-region-as-binary (point-min) (point-max) file-name 'append))
5016 (defun gnus-narrow-to-page (&optional arg)
5017 "Narrow the article buffer to a page.
5018 If given a numerical ARG, move forward ARG pages."
5020 (setq arg (if arg (prefix-numeric-value arg) 0))
5022 (set-buffer gnus-article-buffer)
5023 (goto-char (point-min))
5025 ;; Remove any old next/prev buttons.
5026 (when (gnus-visual-p 'page-marker)
5027 (let ((buffer-read-only nil))
5028 (gnus-remove-text-with-property 'gnus-prev)
5029 (gnus-remove-text-with-property 'gnus-next)))
5032 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5034 (re-search-forward page-delimiter nil 'move arg)))
5035 (goto-char (match-end 0)))
5038 (if (re-search-forward page-delimiter nil 'move)
5041 (when (and (gnus-visual-p 'page-marker)
5042 (not (= (point-min) 1)))
5044 (goto-char (point-min))
5045 (gnus-insert-prev-page-button)))
5046 (when (and (gnus-visual-p 'page-marker)
5047 (< (+ (point-max) 2) (buffer-size)))
5049 (goto-char (point-max))
5050 (gnus-insert-next-page-button)))))
5052 ;; Article mode commands
5054 (defun gnus-article-goto-next-page ()
5055 "Show the next page of the article."
5057 (when (gnus-article-next-page)
5058 (goto-char (point-min))
5059 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5061 (defun gnus-article-goto-prev-page ()
5062 "Show the next page of the article."
5064 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5065 (gnus-article-prev-page nil)))
5067 (defun gnus-article-next-page (&optional lines)
5068 "Show the next page of the current article.
5069 If end of article, return non-nil. Otherwise return nil.
5070 Argument LINES specifies lines to be scrolled up."
5072 (let ((start (window-start))
5073 end-of-buffer end-of-page)
5075 (move-to-window-line -1)
5076 (if (<= (point) start)
5079 (setq start (point)))
5082 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5083 (and (pos-visible-in-window-p)
5084 (setq end-of-buffer t)))
5086 (setq end-of-page t)))
5088 (move-to-window-line lines)
5089 (unless (search-backward "\n\n" nil t)
5090 (setq start (point)))))
5091 (cond (end-of-buffer t)
5093 (gnus-narrow-to-page 1)
5097 (set-window-start (selected-window) start)
5098 (let (window-pixel-scroll-increment)
5102 (defun gnus-article-prev-page (&optional lines)
5103 "Show previous page of current article.
5104 Argument LINES specifies lines to be scrolled down."
5106 (let (beginning-of-buffer beginning-of-page)
5108 (move-to-window-line 0)
5109 (cond ((eq 1 (point))
5110 (setq beginning-of-buffer t))
5112 (setq beginning-of-page t))))
5113 (cond (beginning-of-buffer)
5115 (gnus-narrow-to-page -1))
5118 (let (window-pixel-scroll-increment)
5119 (scroll-down lines))
5120 (beginning-of-buffer
5121 (goto-char (point-min))))))))
5123 (defun gnus-article-refer-article ()
5124 "Read article specified by message-id around point."
5126 (let ((point (point)))
5127 (search-forward ">" nil t) ;Move point to end of "<....>".
5128 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5129 (let ((message-id (match-string 1)))
5131 (set-buffer gnus-summary-buffer)
5132 (gnus-summary-refer-article message-id))
5134 (error "No references around point"))))
5136 (defun gnus-article-show-summary ()
5137 "Reconfigure windows to show summary buffer."
5139 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5140 (error "There is no summary buffer for this article buffer")
5141 (gnus-article-set-globals)
5142 (gnus-configure-windows 'article)
5143 (gnus-summary-goto-subject gnus-current-article)
5144 (gnus-summary-position-point)))
5146 (defun gnus-article-describe-briefly ()
5147 "Describe article mode commands briefly."
5149 (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")))
5151 (defun gnus-article-summary-command ()
5152 "Execute the last keystroke in the summary buffer."
5154 (let ((obuf (current-buffer))
5155 (owin (current-window-configuration))
5157 (switch-to-buffer gnus-article-current-summary 'norecord)
5158 (setq func (lookup-key (current-local-map) (this-command-keys)))
5159 (call-interactively func)
5161 (set-window-configuration owin)
5162 (set-window-point (get-buffer-window (current-buffer)) (point))))
5164 (defun gnus-article-summary-command-nosave ()
5165 "Execute the last keystroke in the summary buffer."
5168 (pop-to-buffer gnus-article-current-summary 'norecord)
5169 (setq func (lookup-key (current-local-map) (this-command-keys)))
5170 (call-interactively func)))
5172 (defun gnus-article-check-buffer ()
5173 "Beep if not in an article buffer."
5174 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5175 (error "Command invoked outside of a Gnus article buffer")))
5177 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5178 "Read a summary buffer key sequence and execute it from the article buffer."
5180 (gnus-article-check-buffer)
5182 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5183 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5184 "=" "^" "\M-^" "|"))
5190 '("n" "Gn" "p" "Gp"))
5193 (set-buffer gnus-article-current-summary)
5194 (let (gnus-pick-mode)
5195 (push (or key last-command-event) unread-command-events)
5196 (setq keys (static-if (featurep 'xemacs)
5197 (events-to-keys (read-key-sequence nil))
5198 (read-key-sequence nil)))))
5201 (if (or (member keys nosaves)
5202 (member keys nosave-but-article)
5203 (member keys nosave-in-article))
5205 (save-window-excursion
5206 (pop-to-buffer gnus-article-current-summary 'norecord)
5207 ;; We disable the pick minor mode commands.
5208 (let (gnus-pick-mode)
5209 (setq func (lookup-key (current-local-map) keys))))
5213 (unless (member keys nosave-in-article)
5214 (set-buffer gnus-article-current-summary))
5215 (call-interactively func)
5216 (setq new-sum-point (point)))
5217 (when (member keys nosave-but-article)
5218 (pop-to-buffer gnus-article-buffer 'norecord)))
5219 ;; These commands should restore window configuration.
5220 (let ((obuf (current-buffer))
5221 (owin (current-window-configuration))
5223 (summary gnus-article-current-summary)
5224 func in-buffer selected)
5225 (if not-restore-window
5226 (pop-to-buffer summary 'norecord)
5227 (switch-to-buffer summary 'norecord))
5228 (setq in-buffer (current-buffer))
5229 ;; We disable the pick minor mode commands.
5230 (if (and (setq func (let (gnus-pick-mode)
5231 (lookup-key (current-local-map) keys)))
5234 (call-interactively func)
5235 (setq new-sum-point (point))
5236 (when (eq in-buffer (current-buffer))
5237 (setq selected (gnus-summary-select-article))
5239 (unless not-restore-window
5240 (set-window-configuration owin))
5241 (when (eq selected 'old)
5243 (set-window-start (get-buffer-window (current-buffer))
5245 (set-window-point (get-buffer-window (current-buffer))
5247 (let ((win (get-buffer-window gnus-article-current-summary)))
5249 (set-window-point win new-sum-point)))) )
5250 (switch-to-buffer gnus-article-buffer)
5253 (defun gnus-article-describe-key (key)
5254 "Display documentation of the function invoked by KEY. KEY is a string."
5255 (interactive "kDescribe key: ")
5256 (gnus-article-check-buffer)
5257 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5259 (set-buffer gnus-article-current-summary)
5260 (let (gnus-pick-mode)
5261 (if (featurep 'xemacs)
5263 (push (elt key 0) unread-command-events)
5264 (setq key (events-to-keys
5265 (read-key-sequence "Describe key: "))))
5266 (setq unread-command-events
5268 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5270 (setq key (read-key-sequence "Describe key: "))))
5272 (describe-key key)))
5274 (defun gnus-article-describe-key-briefly (key &optional insert)
5275 "Display documentation of the function invoked by KEY. KEY is a string."
5276 (interactive "kDescribe key: \nP")
5277 (gnus-article-check-buffer)
5278 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5280 (set-buffer gnus-article-current-summary)
5281 (let (gnus-pick-mode)
5282 (if (featurep 'xemacs)
5284 (push (elt key 0) unread-command-events)
5285 (setq key (events-to-keys
5286 (read-key-sequence "Describe key: "))))
5287 (setq unread-command-events
5289 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5291 (setq key (read-key-sequence "Describe key: "))))
5292 (describe-key-briefly key insert))
5293 (describe-key-briefly key insert)))
5295 (defun gnus-article-reply-with-original (&optional wide)
5296 "Start composing a reply mail to the current message.
5297 The text in the region will be yanked. If the region isn't active,
5298 the entire article will be yanked."
5300 (let ((article (cdr gnus-article-current))
5302 (if (not (gnus-mark-active-p))
5303 (with-current-buffer gnus-summary-buffer
5304 (gnus-summary-reply (list (list article)) wide))
5305 (setq contents (buffer-substring (point) (mark t)))
5306 ;; Deactivate active regions.
5307 (when (and (boundp 'transient-mark-mode)
5308 transient-mark-mode)
5309 (setq mark-active nil))
5310 (with-current-buffer gnus-summary-buffer
5312 (list (list article contents)) wide)))))
5314 (defun gnus-article-followup-with-original ()
5315 "Compose a followup to the current article.
5316 The text in the region will be yanked. If the region isn't active,
5317 the entire article will be yanked."
5319 (let ((article (cdr gnus-article-current))
5321 (if (not (gnus-mark-active-p))
5322 (with-current-buffer gnus-summary-buffer
5323 (gnus-summary-followup (list (list article))))
5324 (setq contents (buffer-substring (point) (mark t)))
5325 ;; Deactivate active regions.
5326 (when (and (boundp 'transient-mark-mode)
5327 transient-mark-mode)
5328 (setq mark-active nil))
5329 (with-current-buffer gnus-summary-buffer
5330 (gnus-summary-followup
5331 (list (list article contents)))))))
5333 (defun gnus-article-hide (&optional arg force)
5334 "Hide all the gruft in the current article.
5335 This means that signatures, cited text and (some) headers will be
5337 If given a prefix, show the hidden text instead."
5338 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5339 (gnus-article-hide-headers arg)
5340 (gnus-article-hide-list-identifiers arg)
5341 (gnus-article-hide-citation-maybe arg force)
5342 (gnus-article-hide-signature arg))
5344 (defun gnus-article-maybe-highlight ()
5345 "Do some article highlighting if article highlighting is requested."
5346 (when (gnus-visual-p 'article-highlight 'highlight)
5347 (gnus-article-highlight-some)))
5349 (defun gnus-check-group-server ()
5350 ;; Make sure the connection to the server is alive.
5351 (unless (gnus-server-opened
5352 (gnus-find-method-for-group gnus-newsgroup-name))
5353 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5354 (gnus-request-group gnus-newsgroup-name t)))
5357 (autoload 'nneething-get-file-name "nneething"))
5359 (defun gnus-request-article-this-buffer (article group)
5360 "Get an article and insert it into this buffer."
5361 (let (do-update-line sparse-header)
5365 (gnus-kill-all-overlays)
5366 (setq group (or group gnus-newsgroup-name))
5368 ;; Using `gnus-request-article' directly will insert the article into
5369 ;; `nntp-server-buffer' - so we'll save some time by not having to
5370 ;; copy it from the server buffer into the article buffer.
5372 ;; We only request an article by message-id when we do not have the
5373 ;; headers for it, so we'll have to get those.
5374 (when (stringp article)
5375 (gnus-read-header article))
5377 ;; If the article number is negative, that means that this article
5378 ;; doesn't belong in this newsgroup (possibly), so we find its
5379 ;; message-id and request it by id instead of number.
5380 (when (and (numberp article)
5382 (get-buffer gnus-summary-buffer)
5383 (gnus-buffer-exists-p gnus-summary-buffer))
5385 (set-buffer gnus-summary-buffer)
5386 (let ((header (gnus-summary-article-header article)))
5389 ((memq article gnus-newsgroup-sparse)
5390 ;; This is a sparse gap article.
5391 (setq do-update-line article)
5392 (setq article (mail-header-id header))
5393 (setq sparse-header (gnus-read-header article))
5394 (setq gnus-newsgroup-sparse
5395 (delq article gnus-newsgroup-sparse)))
5397 ;; It's a real article.
5398 (setq article (mail-header-id header)))
5400 ;; It is an extracted pseudo-article.
5401 (setq article 'pseudo)
5402 (gnus-request-pseudo-article header))))
5404 (let ((method (gnus-find-method-for-group
5405 gnus-newsgroup-name)))
5406 (when (and (eq (car method) 'nneething)
5408 (let ((dir (nneething-get-file-name
5409 (mail-header-id header))))
5410 (when (and (stringp dir)
5411 (file-directory-p dir))
5412 (setq article 'nneething)
5413 (gnus-group-enter-directory dir))))))))
5416 ;; Refuse to select canceled articles.
5417 ((and (numberp article)
5419 (get-buffer gnus-summary-buffer)
5420 (gnus-buffer-exists-p gnus-summary-buffer)
5421 (eq (cdr (save-excursion
5422 (set-buffer gnus-summary-buffer)
5423 (assq article gnus-newsgroup-reads)))
5424 gnus-canceled-mark))
5426 ;; We first check `gnus-original-article-buffer'.
5427 ((and (get-buffer gnus-original-article-buffer)
5430 (set-buffer gnus-original-article-buffer)
5431 (and (equal (car gnus-original-article) group)
5432 (eq (cdr gnus-original-article) article))))
5433 (insert-buffer-substring gnus-original-article-buffer)
5435 ;; Check the backlog.
5436 ((and gnus-keep-backlog
5437 (gnus-backlog-request-article group article (current-buffer)))
5439 ;; Check asynchronous pre-fetch.
5440 ((gnus-async-request-fetched-article group article (current-buffer))
5441 (gnus-async-prefetch-next group article gnus-summary-buffer)
5442 (when (and (numberp article) gnus-keep-backlog)
5443 (gnus-backlog-enter-article group article (current-buffer)))
5446 ((and gnus-use-cache
5448 (gnus-cache-request-article article group))
5450 ;; Check the agent cache.
5451 ((and gnus-agent gnus-agent-cache gnus-plugged
5453 (gnus-agent-request-article article group))
5455 ;; Get the article and put into the article buffer.
5456 ((or (stringp article)
5458 (let ((gnus-override-method gnus-override-method)
5459 (methods (and (stringp article)
5460 gnus-refer-article-method))
5461 (backend (car (gnus-find-method-for-group
5462 gnus-newsgroup-name)))
5464 (buffer-read-only nil))
5465 (if (or (not (listp methods))
5466 (and (symbolp (car methods))
5467 (assq (car methods) nnoo-definition-alist)))
5468 (setq methods (list methods)))
5469 (when (and (null gnus-override-method)
5471 (setq gnus-override-method (pop methods)))
5473 (when (eq gnus-override-method 'current)
5474 (setq gnus-override-method
5475 (with-current-buffer gnus-summary-buffer
5476 gnus-current-select-method)))
5478 (gnus-kill-all-overlays)
5479 (let ((gnus-newsgroup-name group))
5480 (gnus-check-group-server))
5482 ((gnus-request-article article group (current-buffer))
5483 (when (numberp article)
5484 (gnus-async-prefetch-next group article
5485 gnus-summary-buffer)
5486 (when gnus-keep-backlog
5487 (gnus-backlog-enter-article
5488 group article (current-buffer))))
5489 (setq result 'article))
5491 (setq gnus-override-method (pop methods)))
5492 ((not (string-match "^400 "
5493 (nnheader-get-report backend)))
5494 ;; If we get 400 server disconnect, reconnect and
5495 ;; retry; otherwise, assume the article has expired.
5496 (setq result 'done))))
5497 (and (eq result 'article) 'article)))
5501 ;; Associate this article with the current summary buffer.
5502 (setq gnus-article-current-summary gnus-summary-buffer)
5504 ;; Take the article from the original article buffer
5505 ;; and place it in the buffer it's supposed to be in.
5506 (when (and (get-buffer gnus-article-buffer)
5507 (equal (buffer-name (current-buffer))
5508 (buffer-name (get-buffer gnus-article-buffer))))
5510 (if (get-buffer gnus-original-article-buffer)
5511 (set-buffer gnus-original-article-buffer)
5512 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5513 (buffer-disable-undo)
5514 (setq major-mode 'gnus-original-article-mode)
5515 (setq buffer-read-only t))
5516 (let (buffer-read-only)
5518 (insert-buffer-substring gnus-article-buffer))
5519 (setq gnus-original-article (cons group article)))
5522 (run-hooks 'gnus-article-decode-hook)
5523 ;; Mark article as decoded or not.
5524 (setq gnus-article-decoded-p gnus-article-decode-hook))
5526 ;; Update sparse articles.
5527 (when (and do-update-line
5528 (or (numberp article)
5530 (let ((buf (current-buffer)))
5531 (set-buffer gnus-summary-buffer)
5532 (gnus-summary-update-article do-update-line sparse-header)
5533 (gnus-summary-goto-subject do-update-line nil t)
5534 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5536 (set-buffer buf))))))
5542 (defcustom gnus-article-edit-mode-hook nil
5543 "Hook run in article edit mode buffers."
5544 :group 'gnus-article-various
5547 (defcustom gnus-article-edit-article-setup-function
5548 'gnus-article-mime-edit-article-setup
5549 "Function called to setup an editing article buffer."
5550 :group 'gnus-article-various
5553 (defvar gnus-article-edit-done-function nil)
5555 (defvar gnus-article-edit-mode-map nil)
5556 (defvar gnus-article-edit-mode nil)
5558 ;; Should we be using derived.el for this?
5559 (unless gnus-article-edit-mode-map
5560 (setq gnus-article-edit-mode-map (make-keymap))
5561 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5563 (gnus-define-keys gnus-article-edit-mode-map
5564 "\C-c?" describe-mode
5565 "\C-c\C-c" gnus-article-edit-done
5566 "\C-c\C-k" gnus-article-edit-exit
5567 "\C-c\C-f\C-t" message-goto-to
5568 "\C-c\C-f\C-o" message-goto-from
5569 "\C-c\C-f\C-b" message-goto-bcc
5570 ;;"\C-c\C-f\C-w" message-goto-fcc
5571 "\C-c\C-f\C-c" message-goto-cc
5572 "\C-c\C-f\C-s" message-goto-subject
5573 "\C-c\C-f\C-r" message-goto-reply-to
5574 "\C-c\C-f\C-n" message-goto-newsgroups
5575 "\C-c\C-f\C-d" message-goto-distribution
5576 "\C-c\C-f\C-f" message-goto-followup-to
5577 "\C-c\C-f\C-m" message-goto-mail-followup-to
5578 "\C-c\C-f\C-k" message-goto-keywords
5579 "\C-c\C-f\C-u" message-goto-summary
5580 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5581 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5582 "\C-c\C-b" message-goto-body
5583 "\C-c\C-i" message-goto-signature
5585 "\C-c\C-t" message-insert-to
5586 "\C-c\C-n" message-insert-newsgroups
5587 "\C-c\C-o" message-sort-headers
5588 "\C-c\C-e" message-elide-region
5589 "\C-c\C-v" message-delete-not-region
5590 "\C-c\C-z" message-kill-to-signature
5591 "\M-\r" message-newline-and-reformat
5592 "\C-c\C-a" mml-attach-file
5593 "\C-a" message-beginning-of-line
5595 "\M-;" comment-region)
5597 (gnus-define-keys (gnus-article-edit-wash-map
5598 "\C-c\C-w" gnus-article-edit-mode-map)
5599 "f" gnus-article-edit-full-stops))
5602 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5604 ["Fetch To" message-insert-to t]
5605 ["Fetch Newsgroups" message-insert-newsgroups t]
5607 ["To" message-goto-to t]
5608 ["From" message-goto-from t]
5609 ["Subject" message-goto-subject t]
5610 ["Cc" message-goto-cc t]
5611 ["Reply-To" message-goto-reply-to t]
5612 ["Summary" message-goto-summary t]
5613 ["Keywords" message-goto-keywords t]
5614 ["Newsgroups" message-goto-newsgroups t]
5615 ["Followup-To" message-goto-followup-to t]
5616 ["Mail-Followup-To" message-goto-mail-followup-to t]
5617 ["Distribution" message-goto-distribution t]
5618 ["Body" message-goto-body t]
5619 ["Signature" message-goto-signature t]))
5621 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5622 "Major mode for editing articles.
5623 This is an extended text-mode.
5625 \\{gnus-article-edit-mode-map}"
5626 (make-local-variable 'gnus-article-edit-done-function)
5627 (make-local-variable 'gnus-prev-winconf)
5628 (set (make-local-variable 'font-lock-defaults)
5629 '(message-font-lock-keywords t))
5630 (set (make-local-variable 'mail-header-separator) "")
5631 (set (make-local-variable 'gnus-article-edit-mode) t)
5632 (easy-menu-add message-mode-field-menu message-mode-map)
5633 (setq buffer-read-only nil)
5634 (buffer-enable-undo)
5637 (defun gnus-article-edit (&optional force)
5638 "Edit the current article.
5639 This will have permanent effect only in mail groups.
5640 If FORCE is non-nil, allow editing of articles even in read-only
5643 (when (and (not force)
5644 (gnus-group-read-only-p))
5645 (error "The current newsgroup does not support article editing"))
5646 (gnus-article-date-original)
5647 (gnus-article-edit-article
5649 `(lambda (no-highlight)
5651 (gnus-summary-edit-article-done
5652 ,(or (mail-header-references gnus-current-headers) "")
5653 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5655 (defun gnus-article-edit-article (start-func exit-func)
5656 "Start editing the contents of the current article buffer."
5657 (let ((winconf (current-window-configuration)))
5658 (set-buffer gnus-article-buffer)
5659 (gnus-article-edit-mode)
5660 (funcall start-func)
5661 (set-buffer-modified-p nil)
5662 (gnus-configure-windows 'edit-article)
5663 (setq gnus-article-edit-done-function exit-func)
5664 (setq gnus-prev-winconf winconf)
5665 (when gnus-article-edit-article-setup-function
5666 (funcall gnus-article-edit-article-setup-function))
5667 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5669 (defun gnus-article-edit-done (&optional arg)
5670 "Update the article edits and exit."
5672 (let ((func gnus-article-edit-done-function)
5673 (buf (current-buffer))
5674 (start (window-start))
5676 (winconf gnus-prev-winconf))
5677 (remove-hook 'gnus-article-mode-hook
5678 'gnus-article-mime-edit-article-unwind)
5679 (widen) ;; Widen it in case that users narrowed the buffer.
5682 ;; The cache and backlog have to be flushed somewhat.
5683 (when gnus-keep-backlog
5684 (gnus-backlog-remove-article
5685 (car gnus-article-current) (cdr gnus-article-current)))
5686 ;; Flush original article as well.
5688 (when (get-buffer gnus-original-article-buffer)
5689 (set-buffer gnus-original-article-buffer)
5690 (setq gnus-original-article nil)))
5691 (when gnus-use-cache
5692 (gnus-cache-update-article
5693 (car gnus-article-current) (cdr gnus-article-current)))
5694 ;; We remove all text props from the article buffer.
5695 (kill-all-local-variables)
5696 (gnus-set-text-properties (point-min) (point-max) nil)
5698 (set-window-configuration winconf)
5700 (set-window-start (get-buffer-window buf) start)
5701 (set-window-point (get-buffer-window buf) (point))))
5703 (defun gnus-article-edit-exit ()
5704 "Exit the article editing without updating."
5706 (when (or (not (buffer-modified-p))
5707 (yes-or-no-p "Article modified; kill anyway? "))
5708 (let ((curbuf (current-buffer))
5710 (window-start (window-start)))
5712 (if (gnus-buffer-live-p gnus-original-article-buffer)
5713 (insert-buffer-substring gnus-original-article-buffer))
5714 (let ((winconf gnus-prev-winconf))
5715 (kill-all-local-variables)
5717 (set-window-configuration winconf)
5718 ;; Tippy-toe some to make sure that point remains where it was.
5719 (save-current-buffer
5721 (set-window-start (get-buffer-window (current-buffer)) window-start)
5724 (defun gnus-article-edit-full-stops ()
5725 "Interactively repair spacing at end of sentences."
5728 (goto-char (point-min))
5729 (search-forward-regexp "^$" nil t)
5730 (let ((case-fold-search nil))
5731 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5734 ;;; Article editing with MIME-Edit
5737 (defcustom gnus-article-mime-edit-article-setup-hook nil
5738 "Hook run after setting up a MIME editing article buffer."
5739 :group 'gnus-article-various
5742 (defun gnus-article-mime-edit-article-unwind ()
5743 "Unwind `gnus-article-buffer' if article editing was given up."
5744 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5745 (when (featurep 'font-lock)
5746 (setq font-lock-defaults nil)
5747 (font-lock-mode -1))
5748 (when mime-edit-mode-flag
5749 (mime-edit-exit 'nomime 'no-error)
5752 (defun gnus-article-mime-edit-article-setup ()
5753 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5754 after replacing with the original article."
5755 (setq gnus-show-mime t)
5756 (setq gnus-article-edit-done-function
5757 `(lambda (&rest args)
5758 (when mime-edit-mode-flag
5759 (let (mime-edit-insert-user-agent-field)
5762 (goto-char (point-min))
5763 (let (case-fold-search)
5764 (when (re-search-forward
5765 (format "^%s$" (regexp-quote mail-header-separator))
5767 (replace-match "")))
5768 (apply ,gnus-article-edit-done-function args)
5771 (buffer-substring-no-properties (point-min) (point-max))
5772 (set-buffer (get-buffer-create gnus-original-article-buffer))
5774 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5775 (set-buffer gnus-article-buffer)
5776 (gnus-article-prepare-display)))
5777 (substitute-key-definition 'gnus-article-edit-done
5778 'gnus-article-mime-edit-done
5779 gnus-article-edit-mode-map)
5780 (substitute-key-definition 'gnus-article-edit-exit
5781 'gnus-article-mime-edit-exit
5782 gnus-article-edit-mode-map)
5784 (insert-buffer-substring gnus-original-article-buffer)
5785 (unless (member (with-current-buffer gnus-summary-buffer
5786 gnus-newsgroup-name)
5787 '("nndraft:delayed" "nndraft:drafts"))
5788 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5789 (fset 'mime-edit-decode-single-part-in-buffer
5790 (lambda (&rest args)
5791 (if (let ((content-type (car args)))
5792 (and (eq 'message (mime-content-type-primary-type
5794 (eq 'rfc822 (mime-content-type-subtype
5796 (setcar (cdr args) 'not-decode-text))
5800 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
5801 (when (featurep 'font-lock)
5802 (set (make-local-variable 'font-lock-defaults)
5803 '(message-font-lock-keywords t))
5804 (font-lock-set-defaults)
5805 (turn-on-font-lock))
5806 (set-buffer-modified-p nil)
5807 (delete-other-windows)
5808 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5809 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5811 (defun gnus-article-mime-edit-done (&optional arg)
5812 "Update the article MIME edits and exit."
5814 (when (featurep 'font-lock)
5815 (setq font-lock-defaults nil)
5816 (font-lock-mode -1))
5817 (let ((inhibit-read-only t))
5818 (gnus-article-edit-done arg)))
5820 (defun gnus-article-mime-edit-exit ()
5821 "Exit the article MIME editing without updating."
5823 (when (or (not (buffer-modified-p))
5824 (yes-or-no-p "Article modified; kill anyway? "))
5825 (when (featurep 'font-lock)
5826 (setq font-lock-defaults nil)
5827 (font-lock-mode -1))
5828 (when mime-edit-mode-flag
5829 (let (mime-edit-insert-user-agent-field)
5832 (goto-char (point-min))
5833 (let (case-fold-search)
5834 (when (re-search-forward
5835 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5836 (replace-match "")))
5837 (let ((winconf gnus-prev-winconf))
5839 (buffer-substring-no-properties (point-min) (point-max))
5840 (set-buffer (get-buffer-create gnus-original-article-buffer))
5842 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5843 (set-buffer gnus-article-buffer)
5844 (gnus-article-prepare-display)
5845 (set-window-configuration winconf))))
5848 ;;; Article highlights
5851 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5853 ;;; Internal Variables:
5855 (defcustom gnus-button-url-regexp
5856 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5857 "\\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:]]\\)"
5858 "\\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\\)\\)")
5859 "Regular expression that matches URLs."
5860 :group 'gnus-article-buttons
5863 (defcustom gnus-button-valid-fqdn-regexp
5864 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5866 "\\([a-z][a-z]" ;; two letter country TDLs
5867 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5868 "\\|aero\\|coop\\|info\\|name\\|museum"
5869 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5871 "Regular expression that matches a valid FQDN."
5872 :group 'gnus-article-buttons
5875 (defcustom gnus-button-man-handler 'manual-entry
5876 "Function to use for displaying man pages.
5877 The function must take at least one argument with a string naming the
5879 :type '(choice (function-item :tag "Man" manual-entry)
5880 (function-item :tag "Woman" woman)
5881 (function :tag "Other"))
5882 :group 'gnus-article-buttons)
5884 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5885 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5886 If the default site is too slow, try to find a CTAN mirror, see
5887 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5888 the variable `gnus-button-handle-ctan'."
5889 :group 'gnus-article-buttons
5890 :link '(custom-manual "(gnus)Group Parameters")
5891 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5892 (const "http://tug.ctan.org/tex-archive/")
5893 (const "http://www.dante.de/CTAN/")
5894 (string :tag "Other")))
5896 (defcustom gnus-button-ctan-handler 'browse-url
5897 "Function to use for displaying CTAN links.
5898 The function must take one argument, the string naming the URL."
5899 :type '(choice (function-item :tag "Browse Url" browse-url)
5900 (function :tag "Other"))
5901 :group 'gnus-article-buttons)
5903 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5904 "Bogus strings removed from CTAN URLs."
5905 :group 'gnus-article-buttons
5906 :type '(choice (const "^/?tex-archive/\\|/")
5907 (regexp :tag "Other")))
5909 (defcustom gnus-button-mid-or-mail-regexp
5910 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5911 gnus-button-valid-fqdn-regexp
5913 "Regular expression that matches a message ID or a mail address."
5914 :group 'gnus-article-buttons
5917 (defcustom gnus-button-prefer-mid-or-mail 'guess
5918 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5919 Strings like this can be either a message ID or a mail address. If the
5920 variable is set to the symbol `ask', query the user what do do. If it is the
5921 symbol `guess', Gnus will do a guess and query the user what do do if it is
5922 ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details
5923 concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus
5924 will always assume that the string is a message ID or a mail address,
5926 ;; FIXME: doc-string could/should be improved.
5927 :group 'gnus-article-buttons
5928 :type '(choice (const ask)
5933 (defcustom gnus-button-guessed-mid-regexp
5935 "^<?\\(slrn\\|Pine\\.\\)"
5936 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5937 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5938 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5939 "Regular expression that matches message IDs and not mail addresses."
5940 ;; TODO: Incorporate more matches from
5941 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5942 ;; Perl-REs to Elisp-REs.
5943 :group 'gnus-article-buttons
5946 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5947 (let* ((pref gnus-button-prefer-mid-or-mail)
5948 (url-mid (concat "news" ":" mid-or-mail))
5949 (url-mailto (concat "mailto" ":" mid-or-mail)))
5950 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5951 ;; If it looks like a MID (well known readers or servers) use 'mid,
5952 ;; otherwise 'ask the user.
5953 (if (eq pref 'guess)
5954 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5958 (save-window-excursion
5959 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5962 (cond ((eq pref 'mid)
5963 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5964 (gnus-button-handle-news url-mid))
5966 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5967 (gnus-url-mailto url-mailto)))))
5969 (defun gnus-button-handle-custom (url)
5970 "Follow a Custom URL."
5971 (customize-apropos (gnus-url-unhex-string url)))
5973 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5975 (defun gnus-button-handle-describe-function (url)
5976 "Call `describe-function' when pushing the corresponding URL button."
5979 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5981 (defun gnus-button-handle-describe-variable (url)
5982 "Call `describe-variable' when pushing the corresponding URL button."
5985 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5987 (defun gnus-button-handle-describe-key (url)
5988 "Call `describe-key' when pushing the corresponding URL button."
5990 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5991 (keys (ignore-errors (eval `(kbd ,key-string)))))
5994 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5996 (defun gnus-button-handle-apropos (url)
5997 "Call `apropos' when pushing the corresponding URL button."
5998 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6000 (defun gnus-button-handle-apropos-command (url)
6001 "Call `apropos' when pushing the corresponding URL button."
6003 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6005 (defun gnus-button-handle-apropos-variable (url)
6006 "Call `apropos' when pushing the corresponding URL button."
6008 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6009 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6011 (defun gnus-button-handle-apropos-documentation (url)
6012 "Call `apropos' when pushing the corresponding URL button."
6014 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6015 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6017 (defun gnus-button-handle-ctan (url)
6018 "Call `browse-url' when pushing a CTAN URL button."
6020 gnus-button-ctan-handler
6023 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6025 (defcustom gnus-button-tex-level 5
6026 "*Integer that says how many TeX-related buttons Gnus will show.
6027 The higher the number, the more buttons will appear and the more false
6028 positives are possible. Note that you can set this variable local to
6029 specifific groups. Setting it higher in TeX groups is probably a good idea.
6030 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6031 how to set variables in specific groups."
6032 :group 'gnus-article-buttons
6033 :link '(custom-manual "(gnus)Group Parameters")
6036 (defcustom gnus-button-man-level 5
6037 "*Integer that says how many man-related buttons Gnus will show.
6038 The higher the number, the more buttons will appear and the more false
6039 positives are possible. Note that you can set this variable local to
6040 specifific groups. Setting it higher in Unix groups is probably a good idea.
6041 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6042 how to set variables in specific groups."
6043 :group 'gnus-article-buttons
6044 :link '(custom-manual "(gnus)Group Parameters")
6047 (defcustom gnus-button-emacs-level 5
6048 "*Integer that says how many emacs-related buttons Gnus will show.
6049 The higher the number, the more buttons will appear and the more false
6050 positives are possible. Note that you can set this variable local to
6051 specifific groups. Setting it higher in Emacs or Gnus related groups is
6052 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6053 `gnus-parameters' on how to set variables in specific groups."
6054 :group 'gnus-article-buttons
6055 :link '(custom-manual "(gnus)Group Parameters")
6058 (defcustom gnus-button-mail-level 5
6059 "*Integer that says how many buttons for message IDs or mail addresses will appear.
6060 The higher the number, the more buttons will appear and the more false
6061 positives are possible."
6062 :group 'gnus-article-buttons
6065 (defcustom gnus-button-alist
6066 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6067 0 t gnus-button-handle-news 3)
6068 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6069 gnus-button-handle-news 2)
6070 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6072 gnus-button-fetch-group 4)
6073 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
6074 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
6075 t gnus-button-message-id 3)
6076 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
6077 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6078 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
6080 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
6081 gnus-button-handle-ctan 1)
6083 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6084 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
6086 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6087 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6088 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6089 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6090 ;; Emacs help commands
6091 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6092 ;; regexp doesn't match arguments containing ` '.
6093 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6094 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6095 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6096 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6097 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6098 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6099 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6100 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6101 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6102 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6103 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6104 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
6105 ;; Unlike the other regexps we really have to require quoting
6106 ;; here to determine where it ends.
6107 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6108 ;; This is how URLs _should_ be embedded in text...
6109 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
6111 (gnus-button-url-regexp 0 t browse-url 0)
6113 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
6114 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6115 gnus-button-handle-man 1)
6116 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6117 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
6118 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6119 gnus-button-handle-man 1)
6120 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6121 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
6122 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
6123 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6124 ;; MID or mail: To avoid too many false positives we don't try to catch
6125 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6126 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6127 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6128 ;; so that non-ambiguous entries (see above) match first.
6129 (gnus-button-mid-or-mail-regexp
6130 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6131 "*Alist of regexps matching buttons in article bodies.
6133 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6134 REGEXP: is the string (case insensitive) matching text around the button (can
6135 also be lisp expression evaluating to a string),
6136 BUTTON: is the number of the regexp grouping actually matching the button,
6137 FORM: is a lisp expression which must eval to true for the button to
6139 CALLBACK: is the function to call when the user push this button, and each
6140 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6142 CALLBACK can also be a variable, in that case the value of that
6143 variable it the real callback function."
6144 :group 'gnus-article-buttons
6145 :type '(repeat (list (choice regexp variable)
6146 (integer :tag "Button")
6148 (function :tag "Callback")
6151 (integer :tag "Regexp group")))))
6153 (defcustom gnus-header-button-alist
6154 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6155 0 t gnus-button-message-id 0)
6156 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6157 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6158 0 t gnus-button-mailto 0)
6159 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6160 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6161 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6162 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6163 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6164 gnus-button-message-id 3))
6165 "*Alist of headers and regexps to match buttons in article heads.
6167 This alist is very similar to `gnus-button-alist', except that each
6168 alist has an additional HEADER element first in each entry:
6170 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6172 HEADER is a regexp to match a header. For a fuller explanation, see
6173 `gnus-button-alist'."
6174 :group 'gnus-article-buttons
6175 :group 'gnus-article-headers
6176 :type '(repeat (list (regexp :tag "Header")
6178 (integer :tag "Button")
6180 (function :tag "Callback")
6183 (integer :tag "Regexp group")))))
6185 (defvar gnus-button-regexp nil)
6186 (defvar gnus-button-marker-list nil)
6187 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6189 (defvar gnus-button-last nil)
6190 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6194 (defun gnus-article-push-button (event)
6195 "Check text under the mouse pointer for a callback function.
6196 If the text under the mouse pointer has a `gnus-callback' property,
6197 call it with the value of the `gnus-data' text property."
6199 (set-buffer (window-buffer (posn-window (event-start event))))
6200 (let* ((pos (posn-point (event-start event)))
6201 (data (get-text-property pos 'gnus-data))
6202 (fun (get-text-property pos 'gnus-callback)))
6205 (funcall fun data))))
6207 (defun gnus-article-press-button ()
6208 "Check text at point for a callback function.
6209 If the text at point has a `gnus-callback' property,
6210 call it with the value of the `gnus-data' text property."
6212 (let ((data (get-text-property (point) 'gnus-data))
6213 (fun (get-text-property (point) 'gnus-callback)))
6215 (funcall fun data))))
6217 (defun gnus-article-prev-button (n)
6218 "Move point to N buttons backward.
6219 If N is negative, move forward instead."
6221 (gnus-article-next-button (- n)))
6223 (defun gnus-article-next-button (n)
6224 "Move point to N buttons forward.
6225 If N is negative, move backward instead."
6227 (let ((function (if (< n 0) 'previous-single-property-change
6228 'next-single-property-change))
6229 (inhibit-point-motion-hooks t)
6231 (limit (if (< n 0) (point-min) (point-max))))
6233 (while (and (not (= limit (point)))
6235 ;; Skip past the current button.
6236 (when (get-text-property (point) 'gnus-callback)
6237 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6238 ;; Go to the next (or previous) button.
6239 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6240 ;; Put point at the start of the button.
6241 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6242 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6243 ;; Skip past intangible buttons.
6244 (when (get-text-property (point) 'intangible)
6248 (gnus-message 5 "No more buttons"))
6251 (defun gnus-article-highlight (&optional force)
6252 "Highlight current article.
6253 This function calls `gnus-article-highlight-headers',
6254 `gnus-article-highlight-citation',
6255 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6256 do the highlighting. See the documentation for those functions."
6257 (interactive (list 'force))
6258 (gnus-article-highlight-headers)
6259 (gnus-article-highlight-citation force)
6260 (gnus-article-highlight-signature)
6261 (gnus-article-add-buttons force)
6262 (gnus-article-add-buttons-to-head))
6264 (defun gnus-article-highlight-some (&optional force)
6265 "Highlight current article.
6266 This function calls `gnus-article-highlight-headers',
6267 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6268 do the highlighting. See the documentation for those functions."
6269 (interactive (list 'force))
6270 (gnus-article-highlight-headers)
6271 (gnus-article-highlight-signature)
6272 (gnus-article-add-buttons))
6274 (defun gnus-article-highlight-headers ()
6275 "Highlight article headers as specified by `gnus-header-face-alist'."
6278 (set-buffer gnus-article-buffer)
6280 (let ((alist gnus-header-face-alist)
6281 (buffer-read-only nil)
6282 (case-fold-search t)
6283 (inhibit-point-motion-hooks t)
6284 entry regexp header-face field-face from hpoints fpoints)
6285 (article-narrow-to-head)
6286 (while (setq entry (pop alist))
6287 (goto-char (point-min))
6288 (setq regexp (concat "^\\("
6289 (if (string-equal "" (nth 0 entry))
6293 header-face (nth 1 entry)
6294 field-face (nth 2 entry))
6295 (while (and (re-search-forward regexp nil t)
6299 (unless (search-forward ":" nil t)
6301 (when (and header-face
6302 (not (memq (point) hpoints)))
6303 (push (point) hpoints)
6304 (gnus-put-text-property from (point) 'face header-face))
6305 (when (and field-face
6306 (not (memq (setq from (point)) fpoints)))
6308 (if (re-search-forward "^[^ \t]" nil t)
6310 (goto-char (point-max)))
6311 (gnus-put-text-property from (point) 'face field-face))))))))
6313 (defun gnus-article-highlight-signature ()
6314 "Highlight the signature in an article.
6315 It does this by highlighting everything after
6316 `gnus-signature-separator' using `gnus-signature-face'."
6318 (when gnus-signature-face
6320 (set-buffer gnus-article-buffer)
6321 (let ((buffer-read-only nil)
6322 (inhibit-point-motion-hooks t))
6324 (when (gnus-article-narrow-to-signature)
6325 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6326 'face gnus-signature-face)))))))
6328 (defun gnus-article-buttonize-signature ()
6329 "Add button to the signature."
6332 (set-buffer gnus-article-buffer)
6333 (let ((buffer-read-only nil)
6334 (inhibit-point-motion-hooks t))
6335 (when (gnus-article-search-signature)
6336 (gnus-article-add-button (match-beginning 0) (match-end 0)
6337 'gnus-signature-toggle
6338 (set-marker (make-marker)
6339 (1+ (match-end 0))))))))
6341 (defun gnus-button-in-region-p (b e prop)
6342 "Say whether PROP exists in the region."
6343 (text-property-not-all b e prop nil))
6345 (defun gnus-article-add-buttons (&optional force)
6346 "Find external references in the article and make buttons of them.
6347 \"External references\" are things like Message-IDs and URLs, as
6348 specified by `gnus-button-alist'."
6349 (interactive (list 'force))
6351 (set-buffer gnus-article-buffer)
6352 (let ((buffer-read-only nil)
6353 (inhibit-point-motion-hooks t)
6354 (case-fold-search t)
6355 (alist gnus-button-alist)
6357 ;; Remove all old markers.
6358 (let (marker entry new-list)
6359 (while (setq marker (pop gnus-button-marker-list))
6360 (if (or (< marker (point-min)) (>= marker (point-max)))
6361 (push marker new-list)
6363 (when (setq entry (gnus-button-entry))
6364 (put-text-property (match-beginning (nth 1 entry))
6365 (match-end (nth 1 entry))
6366 'gnus-callback nil))
6367 (set-marker marker nil)))
6368 (setq gnus-button-marker-list new-list))
6369 ;; We skip the headers.
6372 (while (setq entry (pop alist))
6373 (setq regexp (eval (car entry)))
6375 (while (re-search-forward regexp nil t)
6376 (let* ((start (and entry (match-beginning (nth 1 entry))))
6377 (end (and entry (match-end (nth 1 entry))))
6378 (from (match-beginning 0)))
6379 (when (and (or (eq t (nth 2 entry))
6380 (eval (nth 2 entry)))
6381 (not (gnus-button-in-region-p
6382 start end 'gnus-callback)))
6383 ;; That optional form returned non-nil, so we add the
6385 (gnus-article-add-button
6386 start end 'gnus-button-push
6387 (car (push (set-marker (make-marker) from)
6388 gnus-button-marker-list))))))))))
6390 ;; Add buttons to the head of an article.
6391 (defun gnus-article-add-buttons-to-head ()
6392 "Add buttons to the head of the article."
6395 (set-buffer gnus-article-buffer)
6397 (let ((buffer-read-only nil)
6398 (inhibit-point-motion-hooks t)
6399 (case-fold-search t)
6400 (alist gnus-header-button-alist)
6402 (article-narrow-to-head)
6404 ;; Each alist entry.
6405 (setq entry (car alist)
6407 (goto-char (point-min))
6408 (while (re-search-forward (car entry) nil t)
6409 ;; Each header matching the entry.
6410 (setq beg (match-beginning 0))
6411 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6412 (match-beginning 0))
6415 (while (re-search-forward (eval (nth 1 entry)) end t)
6416 ;; Each match within a header.
6417 (let* ((entry (cdr entry))
6418 (start (match-beginning (nth 1 entry)))
6419 (end (match-end (nth 1 entry)))
6420 (form (nth 2 entry)))
6421 (goto-char (match-end 0))
6423 (gnus-article-add-button
6424 start end (nth 3 entry)
6425 (buffer-substring (match-beginning (nth 4 entry))
6426 (match-end (nth 4 entry)))))))
6427 (goto-char end)))))))
6429 ;;; External functions:
6431 (defun gnus-article-add-button (from to fun &optional data)
6432 "Create a button between FROM and TO with callback FUN and data DATA."
6433 (when gnus-article-button-face
6434 (gnus-overlay-put (gnus-make-overlay from to)
6435 'face gnus-article-button-face))
6436 (gnus-add-text-properties
6438 (nconc (and gnus-article-mouse-face
6439 (list gnus-mouse-face-prop gnus-article-mouse-face))
6440 (list 'gnus-callback fun)
6441 (and data (list 'gnus-data data))))
6442 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6443 ;; Quote `:button-keymap' for Mule 2.3
6444 ;; but it won't work.
6445 ':button-keymap gnus-widget-button-keymap))
6447 ;;; Internal functions:
6449 (defun gnus-article-set-globals ()
6451 (set-buffer gnus-summary-buffer)
6452 (gnus-set-global-variables)))
6454 (defun gnus-signature-toggle (end)
6456 (set-buffer gnus-article-buffer)
6457 (let ((buffer-read-only nil)
6458 (inhibit-point-motion-hooks t)
6459 (limit (next-single-property-change end 'mime-view-entity
6461 (if (text-property-any end limit 'article-type 'signature)
6463 (gnus-delete-wash-type 'signature)
6464 (gnus-remove-text-properties-when
6465 'article-type 'signature end limit
6466 (cons 'article-type (cons 'signature
6467 gnus-hidden-properties))))
6468 (gnus-add-wash-type 'signature)
6469 (gnus-add-text-properties-when
6470 'article-type nil end limit
6471 (cons 'article-type (cons 'signature
6472 gnus-hidden-properties)))))
6473 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6474 (gnus-set-mode-line 'article))))
6476 (defun gnus-button-entry ()
6477 ;; Return the first entry in `gnus-button-alist' matching this place.
6478 (let ((alist gnus-button-alist)
6481 (setq entry (pop alist))
6482 (if (looking-at (eval (car entry)))
6487 (defun gnus-button-push (marker)
6488 ;; Push button starting at MARKER.
6491 (let* ((entry (gnus-button-entry))
6492 (inhibit-point-motion-hooks t)
6494 (args (mapcar (lambda (group)
6495 (let ((string (match-string group)))
6496 (gnus-set-text-properties
6497 0 (length string) nil string)
6504 (fboundp (symbol-value fun)))
6505 (apply (symbol-value fun) args))
6507 (gnus-message 1 "You must define `%S' to use this button"
6508 (cons fun args)))))))
6510 (defun gnus-parse-news-url (url)
6511 (let (scheme server group message-id articles)
6514 (goto-char (point-min))
6515 (when (looking-at "\\([A-Za-z]+\\):")
6516 (setq scheme (match-string 1))
6517 (goto-char (match-end 0)))
6518 (when (looking-at "//\\([^/]+\\)/")
6519 (setq server (match-string 1))
6520 (goto-char (match-end 0)))
6523 ((looking-at "\\(.*@.*\\)")
6524 (setq message-id (match-string 1)))
6525 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6526 (setq group (match-string 1)
6527 articles (split-string (match-string 2) "-")))
6528 ((looking-at "\\([^/]+\\)/?")
6529 (setq group (match-string 1)))
6531 (error "Unknown news URL syntax"))))
6532 (list scheme server group message-id articles)))
6534 (defun gnus-button-handle-news (url)
6536 (destructuring-bind (scheme server group message-id articles)
6537 (gnus-parse-news-url url)
6541 (set-buffer gnus-summary-buffer)
6543 (let ((gnus-refer-article-method (list (list 'nntp server))))
6544 (gnus-summary-refer-article message-id))
6545 (gnus-summary-refer-article message-id))))
6547 (gnus-button-fetch-group url)))))
6549 (defun gnus-button-handle-man (url)
6551 (funcall gnus-button-man-handler url))
6553 (defun gnus-button-handle-info (url)
6554 "Fetch an info URL."
6556 "^\\([^:/]+\\)?/\\(.*\\)"
6558 (gnus-info-find-node
6559 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6562 (gnus-url-unhex-string (match-string 2 url))))
6563 (error "Can't parse %s" url)))
6565 (defun gnus-button-message-id (message-id)
6568 (set-buffer gnus-summary-buffer)
6569 (gnus-summary-refer-article message-id)))
6571 (defun gnus-button-fetch-group (address)
6572 "Fetch GROUP specified by ADDRESS."
6573 (if (not (string-match "[:/]" address))
6574 ;; This is just a simple group url.
6575 (gnus-group-read-ephemeral-group address gnus-select-method)
6578 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6580 (error "Can't parse %s" address)
6581 (gnus-group-read-ephemeral-group
6582 (match-string 4 address)
6583 `(nntp ,(match-string 1 address)
6584 (nntp-address ,(match-string 1 address))
6585 (nntp-port-number ,(if (match-end 3)
6586 (match-string 3 address)
6589 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6591 (defun gnus-url-parse-query-string (query &optional downcase)
6592 (let (retval pairs cur key val)
6593 (setq pairs (split-string query "&"))
6595 (setq cur (car pairs)
6597 (if (not (string-match "=" cur))
6599 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6600 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6602 (setq key (downcase key)))
6603 (setq cur (assoc key retval))
6605 (setcdr cur (cons val (cdr cur)))
6606 (setq retval (cons (list key val) retval)))))
6609 (defun gnus-url-mailto (url)
6610 ;; Send mail to someone
6611 (when (string-match "mailto:/*\\(.*\\)" url)
6612 (setq url (substring url (match-beginning 1) nil)))
6613 (let (to args subject func)
6614 (if (string-match (regexp-quote "?") url)
6615 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6616 args (gnus-url-parse-query-string
6617 (substring url (match-end 0) nil) t))
6618 (setq to (gnus-url-unhex-string url)))
6619 (setq args (cons (list "to" to) args)
6620 subject (cdr-safe (assoc "subject" args)))
6623 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6626 (message-position-on-field (caar args)))
6627 (insert (mapconcat 'identity (cdar args) ", "))
6628 (setq args (cdr args)))
6631 (message-goto-subject))))
6633 (defun gnus-button-embedded-url (address)
6634 "Activate ADDRESS with `browse-url'."
6635 (browse-url (gnus-strip-whitespace address)))
6637 ;;; Next/prev buttons in the article buffer.
6639 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6640 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6642 (defvar gnus-prev-page-map
6643 (let ((map (make-sparse-keymap)))
6644 (unless (>= emacs-major-version 21)
6645 ;; XEmacs doesn't care.
6646 (set-keymap-parent map gnus-article-mode-map))
6647 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6648 (define-key map "\r" 'gnus-button-prev-page)
6651 (defun gnus-insert-prev-page-button ()
6653 (buffer-read-only nil)
6654 (situation (get-text-property (point-min) 'mime-view-situation)))
6656 gnus-prev-page-line-format nil
6657 `(,@(gnus-local-map-property gnus-prev-page-map)
6659 gnus-callback gnus-article-button-prev-page
6660 article-type annotation
6661 mime-view-situation ,situation))
6662 (widget-convert-button
6664 :action 'gnus-button-prev-page
6665 :button-keymap gnus-prev-page-map)))
6667 (defvar gnus-next-page-map
6668 (let ((map (make-sparse-keymap)))
6669 (unless (>= emacs-major-version 21)
6670 ;; XEmacs doesn't care.
6671 (set-keymap-parent map gnus-article-mode-map))
6672 (define-key map gnus-mouse-2 'gnus-button-next-page)
6673 (define-key map "\r" 'gnus-button-next-page)
6676 (defun gnus-button-next-page (&optional args more-args)
6677 "Go to the next page."
6679 (let ((win (selected-window)))
6680 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6681 (gnus-article-next-page)
6682 (select-window win)))
6684 (defun gnus-button-prev-page (&optional args more-args)
6685 "Go to the prev page."
6687 (let ((win (selected-window)))
6688 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6689 (gnus-article-prev-page)
6690 (select-window win)))
6692 (defun gnus-insert-next-page-button ()
6694 (buffer-read-only nil)
6695 (situation (get-text-property (point-min) 'mime-view-situation)))
6696 (gnus-eval-format gnus-next-page-line-format nil
6697 `(,@(gnus-local-map-property gnus-next-page-map)
6699 gnus-callback gnus-article-button-next-page
6700 article-type annotation
6701 mime-view-situation ,situation))
6702 (widget-convert-button
6704 :action 'gnus-button-next-page
6705 :button-keymap gnus-next-page-map)))
6707 (defun gnus-article-button-next-page (arg)
6708 "Go to the next page."
6710 (let ((win (selected-window)))
6711 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6712 (gnus-article-next-page)
6713 (select-window win)))
6715 (defun gnus-article-button-prev-page (arg)
6716 "Go to the prev page."
6718 (let ((win (selected-window)))
6719 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6720 (gnus-article-prev-page)
6721 (select-window win)))
6723 (defvar gnus-decode-header-methods
6724 '(mail-decode-encoded-word-region)
6725 "List of methods used to decode headers.
6727 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6728 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6729 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6730 whose names match REGEXP.
6733 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6734 mail-decode-encoded-word-region
6735 (\"chinese\" . rfc1843-decode-region))
6738 (defvar gnus-decode-header-methods-cache nil)
6740 (defun gnus-multi-decode-header (start end)
6741 "Apply the functions from `gnus-encoded-word-methods' that match."
6742 (unless (and gnus-decode-header-methods-cache
6743 (eq gnus-newsgroup-name
6744 (car gnus-decode-header-methods-cache)))
6745 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6748 (nconc gnus-decode-header-methods-cache (list x))
6749 (if (and gnus-newsgroup-name
6750 (string-match (car x) gnus-newsgroup-name))
6751 (nconc gnus-decode-header-methods-cache
6753 gnus-decode-header-methods))
6754 (let ((xlist gnus-decode-header-methods-cache))
6757 (narrow-to-region start end)
6759 (funcall (pop xlist) (point-min) (point-max))))))
6762 ;;; Treatment top-level handling.
6765 (defun gnus-treat-article (condition &optional part-number total-parts type)
6766 (let ((length (- (point-max) (point-min)))
6767 (alist gnus-treatment-function-alist)
6768 (article-goto-body-goes-to-point-min-p t)
6772 (let ((list gnus-article-treat-types))
6774 (when (string-match (pop list) type)
6775 (throw 'found t)))))))
6776 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6777 (entity (static-unless (featurep 'xemacs)
6778 (when (eq 'head condition)
6779 (get-text-property (point-min) 'mime-view-entity))))
6780 val elem buttonized)
6781 (gnus-run-hooks 'gnus-part-display-hook)
6782 (unless gnus-inhibit-treatment
6783 (dolist (elem alist)
6786 (when (gnus-buffer-live-p gnus-summary-buffer)
6787 (set-buffer gnus-summary-buffer))
6788 (symbol-value (car elem))))
6789 (when (and (or (consp val)
6791 (gnus-treat-predicate val)
6792 (or (not (get (car elem) 'highlight))
6794 (when (and (not buttonized)
6796 '(gnus-treat-hide-signature
6797 gnus-treat-highlight-signature)))
6798 (gnus-article-buttonize-signature)
6799 (setq buttonized t))
6801 (funcall (cadr elem)))))
6802 ;; FSF Emacsen does not inherit the existing text properties
6803 ;; in the new text, so we should do it for `mime-view-entity'.
6804 (static-unless (featurep 'xemacs)
6806 (put-text-property (point-min) (point-max)
6807 'mime-view-entity entity))))))
6809 ;; Dynamic variables.
6811 (defvar part-number)
6812 (defvar total-parts)
6817 (defun gnus-treat-predicate (val)
6822 (stringp (car val)))
6823 (apply 'gnus-or (mapcar `(lambda (s)
6824 (string-match s ,(or gnus-newsgroup-name "")))
6827 (let ((pred (pop val)))
6830 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6832 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6834 (not (gnus-treat-predicate (car val))))
6836 (equal (car val) type))
6838 (error "%S is not a valid predicate" pred)))))
6848 (eq part-number total-parts))
6852 (error "%S is not a valid value" val))))
6854 (defun gnus-article-encrypt-body (protocol &optional n)
6855 "Encrypt the article body."
6858 (or gnus-article-encrypt-protocol
6859 (completing-read "Encrypt protocol: "
6860 gnus-article-encrypt-protocol-alist
6862 current-prefix-arg))
6863 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6865 (error (format "Can't find the encrypt protocol %s" protocol)))
6866 (if (member gnus-newsgroup-name '("nndraft:delayed"
6869 (error "Can't encrypt the article in group %s"
6870 gnus-newsgroup-name))
6871 (gnus-summary-iterate n
6873 (set-buffer gnus-summary-buffer)
6874 (let ((mail-parse-charset gnus-newsgroup-charset)
6875 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6876 (summary-buffer gnus-summary-buffer)
6878 (gnus-set-global-variables)
6879 (when (gnus-group-read-only-p)
6880 (error "The current newsgroup does not support article encrypt"))
6881 (gnus-summary-show-article t)
6883 (or (mail-header-references gnus-current-headers) ""))
6884 (set-buffer gnus-article-buffer)
6885 (let* ((buffer-read-only nil)
6887 (mapcar (lambda (field)
6888 (and (save-restriction
6889 (message-narrow-to-head)
6890 (goto-char (point-min))
6891 (search-forward field nil t))
6893 (message-narrow-to-field)
6894 (buffer-substring (point-min) (point-max))
6895 (delete-region (point-min) (point-max))
6897 '("Content-Type:" "Content-Transfer-Encoding:"
6898 "Content-Disposition:"))))
6899 (message-narrow-to-head)
6900 (message-remove-header "MIME-Version")
6901 (goto-char (point-max))
6902 (setq point (point))
6903 (insert (apply 'concat headers))
6905 (narrow-to-region point (point-max))
6906 (let ((message-options message-options))
6907 (message-options-set 'message-sender user-mail-address)
6908 (message-options-set 'message-recipients user-mail-address)
6909 (message-options-set 'message-sign-encrypt 'not)
6911 (goto-char (point-min))
6912 (insert "MIME-Version: 1.0\n")
6914 (gnus-summary-edit-article-done
6915 references nil summary-buffer t))
6916 (when gnus-keep-backlog
6917 (gnus-backlog-remove-article
6918 (car gnus-article-current) (cdr gnus-article-current)))
6920 (when (get-buffer gnus-original-article-buffer)
6921 (set-buffer gnus-original-article-buffer)
6922 (setq gnus-original-article nil)))
6923 (when gnus-use-cache
6924 (gnus-cache-update-article
6925 (car gnus-article-current) (cdr gnus-article-current))))))))
6927 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6928 "The following specs can be used:
6929 %t The security MIME type
6932 %D Details if button is pressed")
6934 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6935 "The following specs can be used:
6936 %t The security MIME type
6939 %D Details if button is pressed")
6941 (defvar gnus-mime-security-button-line-format-alist
6942 '((?t gnus-tmp-type ?s)
6943 (?i gnus-tmp-info ?s)
6944 (?d gnus-tmp-details ?s)
6945 (?D gnus-tmp-pressed-details ?s)))
6947 (defvar gnus-mime-security-button-map
6948 (let ((map (make-sparse-keymap)))
6949 (unless (>= (string-to-number emacs-version) 21)
6950 (set-keymap-parent map gnus-article-mode-map))
6951 (define-key map gnus-mouse-2 'gnus-article-push-button)
6952 (define-key map "\r" 'gnus-article-press-button)
6955 (defvar gnus-mime-security-details-buffer nil)
6957 (defvar gnus-mime-security-button-pressed nil)
6959 (defvar gnus-mime-security-show-details-inline t
6960 "If non-nil, show details in the article buffer.")
6962 (defun gnus-mime-security-verify-or-decrypt (handle)
6963 (mm-remove-parts (cdr handle))
6964 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6965 point buffer-read-only)
6967 (goto-char (car region)))
6969 (narrow-to-region (point) (point))
6970 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6971 (let* ((mm-verify-option 'known)
6972 (mm-decrypt-option 'known)
6973 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6974 (unless (eq nparts (cdr handle))
6975 (mm-destroy-parts (cdr handle))
6976 (setcdr handle nparts))))
6977 (setq point (point))
6978 (gnus-mime-display-security handle)
6979 (goto-char (point-max)))
6981 (delete-region (point) (cdr region))
6982 (set-marker (car region) nil)
6983 (set-marker (cdr region) nil))
6986 (defun gnus-mime-security-show-details (handle)
6987 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6989 (gnus-message 5 "No details.")
6990 (if gnus-mime-security-show-details-inline
6991 (let ((gnus-mime-security-button-pressed
6992 (not (get-text-property (point) 'gnus-mime-details)))
6993 (gnus-mime-security-button-line-format
6994 (get-text-property (point) 'gnus-line-format))
6997 (while (eq (get-text-property (point) 'gnus-line-format)
6998 gnus-mime-security-button-line-format)
7002 (narrow-to-region (point) (point))
7003 (gnus-insert-mime-security-button handle))
7004 (delete-region (point)
7005 (or (text-property-not-all
7008 gnus-mime-security-button-line-format)
7011 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7012 (with-current-buffer gnus-mime-security-details-buffer
7015 (setq gnus-mime-security-details-buffer
7016 (gnus-get-buffer-create "*MIME Security Details*")))
7017 (with-current-buffer gnus-mime-security-details-buffer
7019 (goto-char (point-min)))
7020 (pop-to-buffer gnus-mime-security-details-buffer)))))
7022 (defun gnus-mime-security-press-button (handle)
7024 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7025 (gnus-mime-security-show-details handle)
7026 (gnus-mime-security-verify-or-decrypt handle))))
7028 (defun gnus-insert-mime-security-button (handle &optional displayed)
7029 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7032 (or (nth 2 (assoc protocol mm-verify-function-alist))
7033 (nth 2 (assoc protocol mm-decrypt-function-alist))
7035 (if (equal (car handle) "multipart/signed")
7036 " Signed" " Encrypted")
7039 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7042 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7043 gnus-tmp-pressed-details
7045 (setq gnus-tmp-details
7046 (if gnus-tmp-details
7047 (concat "\n" gnus-tmp-details)
7049 (setq gnus-tmp-pressed-details
7050 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7055 gnus-mime-security-button-line-format
7056 gnus-mime-security-button-line-format-alist
7057 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7058 gnus-callback gnus-mime-security-press-button
7059 gnus-line-format ,gnus-mime-security-button-line-format
7060 gnus-mime-details ,gnus-mime-security-button-pressed
7061 article-type annotation
7064 (widget-convert-button
7067 :action 'gnus-widget-press-button
7068 :button-keymap gnus-mime-security-button-map
7070 (lambda (widget/window &optional overlay pos)
7071 ;; Needed to properly clear the message due to a bug in
7072 ;; wid-edit (XEmacs only).
7073 (when (boundp 'help-echo-owns-message)
7074 (setq help-echo-owns-message t))
7077 (aref gnus-mouse-2 0))))))
7079 (defun gnus-mime-display-security (handle)
7081 (narrow-to-region (point) (point))
7082 (unless (gnus-unbuttonized-mime-type-p (car handle))
7083 (gnus-insert-mime-security-button handle))
7084 (gnus-mime-display-mixed (cdr handle))
7087 (unless (gnus-unbuttonized-mime-type-p (car handle))
7088 (let ((gnus-mime-security-button-line-format
7089 gnus-mime-security-button-end-line-format))
7090 (gnus-insert-mime-security-button handle)))
7091 (mm-set-handle-multipart-parameter
7093 (cons (set-marker (make-marker) (point-min))
7094 (set-marker (make-marker) (point-max))))))
7100 (defun gnus-article-header-presentation-method (entity situation)
7101 (mime-insert-header entity)
7102 (article-decode-group-name))
7104 (set-alist 'mime-header-presentation-method-alist
7105 'gnus-original-article-mode
7106 #'gnus-article-header-presentation-method)
7108 (defun gnus-mime-preview-quitting-method ()
7109 (mime-preview-kill-buffer)
7110 (delete-other-windows)
7111 (gnus-article-show-summary)
7112 (gnus-summary-select-article gnus-show-all-headers t))
7114 (set-alist 'mime-preview-quitting-method-alist
7115 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7117 (set-alist 'mime-preview-following-method-alist
7118 'gnus-original-article-mode #'gnus-following-method)
7120 (set-alist 'mime-preview-over-to-previous-method-alist
7121 'gnus-original-article-mode
7123 (if (> (point-min) 1)
7124 (gnus-article-prev-page)
7125 (gnus-article-read-summary-keys
7126 nil (gnus-character-to-event ?P)))))
7128 (set-alist 'mime-preview-over-to-next-method-alist
7129 'gnus-original-article-mode'
7131 (if (< (point-max) (buffer-size))
7132 (gnus-article-next-page)
7133 (gnus-article-read-summary-keys
7134 nil (gnus-character-to-event ?N)))))
7144 (run-hooks 'gnus-art-load-hook)
7146 ;;; gnus-art.el ends here