1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
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
118 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
119 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
120 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
121 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
122 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
123 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
124 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
125 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
126 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
127 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
128 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
129 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
130 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
131 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
132 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
133 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
134 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
135 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
136 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
137 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
138 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
139 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
140 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
141 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
142 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
143 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
144 "^X-Received:" "^Content-length:" "X-precedence:"
145 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
146 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
147 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
148 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
149 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
150 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
151 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
152 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
153 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
155 "*All headers that start with this regexp will be hidden.
156 This variable can also be a list of regexps of headers to be ignored.
157 If `gnus-visible-headers' is non-nil, this variable will be ignored."
158 :type '(choice :custom-show nil
161 :group 'gnus-article-hiding)
163 (defcustom gnus-visible-headers
164 "^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:"
165 "*All headers that do not match this regexp will be hidden.
166 This variable can also be a list of regexp of headers to remain visible.
167 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
168 :type '(repeat :value-to-internal (lambda (widget value)
169 (custom-split-regexp-maybe value))
170 :match (lambda (widget value)
172 (widget-editable-list-match widget value)))
174 :group 'gnus-article-hiding)
176 (defcustom gnus-sorted-header-list
177 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
178 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
179 "*This variable is a list of regular expressions.
180 If it is non-nil, headers that match the regular expressions will
181 be placed first in the article buffer in the sequence specified by
183 :type '(repeat regexp)
184 :group 'gnus-article-hiding)
186 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
187 "Headers that are only to be displayed if they have interesting data.
188 Possible values in this list are:
190 'empty Headers with no content.
191 'newsgroups Newsgroup identical to Gnus group.
192 'to-address To identical to To-address.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "Followup-to identical to Newsgroups." followup-to)
202 (const :tag "Reply-to identical to From." reply-to)
203 (const :tag "Date less than four days old." date)
204 (const :tag "To and/or Cc longer than 1024 characters." long-to)
205 (const :tag "Multiple To and/or Cc headers." many-to))
206 :group 'gnus-article-hiding)
208 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
209 "Regexp matching signature separator.
210 This can also be a list of regexps. In that case, it will be checked
211 from head to tail looking for a separator. Searches will be done from
212 the end of the buffer."
213 :type '(repeat string)
214 :group 'gnus-article-signature)
216 (defcustom gnus-signature-limit nil
217 "Provide a limit to what is considered a signature.
218 If it is a number, no signature may not be longer (in characters) than
219 that number. If it is a floating point number, no signature may be
220 longer (in lines) than that number. If it is a function, the function
221 will be called without any parameters, and if it returns nil, there is
222 no signature in the buffer. If it is a string, it will be used as a
223 regexp. If it matches, the text in question is not a signature."
224 :type '(choice (integer :value 200)
226 (function :value fun)
227 (regexp :value ".*"))
228 :group 'gnus-article-signature)
230 (defcustom gnus-hidden-properties '(invisible t intangible t)
231 "Property list to use for hiding text."
233 :group 'gnus-article-hiding)
235 ;; Fixme: This isn't the right thing for mixed graphical and and
236 ;; non-graphical frames in a session.
237 (defcustom gnus-article-x-face-command
240 (if (or (gnus-image-type-available-p 'xface)
241 (gnus-image-type-available-p 'pbm))
242 'gnus-display-x-face-in-from
243 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
244 ((and (fboundp 'image-type-available-p)
245 (module-installed-p 'x-face-e21))
246 'x-face-decode-message-header)
247 ((gnus-image-type-available-p 'pbm)
248 'gnus-display-x-face-in-from)
250 (module-installed-p 'x-face-mule))
251 'x-face-mule-gnus-article-display-x-face)
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
255 "*String or function to be executed to display an X-Face header.
256 If it is a string, the command will be executed in a sub-shell
257 asynchronously. The compressed face will be piped to this command."
259 ,@(let (x-face-e21 x-face-mule)
260 (if (featurep 'xemacs)
262 (setq x-face-e21 (module-installed-p 'x-face-e21)
263 x-face-mule (module-installed-p 'x-face-mule)))
267 (if (or (gnus-image-type-available-p 'xface)
268 (gnus-image-type-available-p 'pbm))
269 '(function-item gnus-display-x-face-in-from))
271 (fboundp 'image-type-available-p))
273 :tag "x-face-decode-message-header (x-face-e21)"
274 x-face-decode-message-header))
277 x-face-mule-gnus-article-display-x-face))
281 :group 'gnus-article-washing)
283 (defcustom gnus-article-x-face-too-ugly nil
284 "Regexp matching posters whose face shouldn't be shown automatically."
285 :type '(choice regexp (const nil))
286 :group 'gnus-article-washing)
288 (defcustom gnus-article-banner-alist nil
289 "Banner alist for stripping.
291 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
293 :type '(repeat (cons symbol regexp))
294 :group 'gnus-article-washing)
296 (gnus-define-group-parameter
299 "Alist of regexps (to match group names) and banner."
300 :variable-group gnus-article-washing
302 '(choice :tag "Banner"
304 (const :tag "Remove signature" signature)
305 (symbol :tag "Item in `gnus-article-banner-alist'" none)
307 (const :tag "None" nil))
309 "If non-nil, specify how to remove `banners' from articles.
311 Symbol `signature' means to remove signatures delimited by
312 `gnus-signature-separator'. Any other symbol is used to look up a
313 regular expression to match the banner in `gnus-article-banner-alist'.
314 A string is used as a regular expression to match the banner
317 (defcustom gnus-article-address-banner-alist nil
318 "Alist of mail addresses and banners.
319 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
320 to match a mail address in the From: header, BANNER is one of a symbol
321 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
322 If ADDRESS matches author's mail address, it will remove things like
323 advertisements. For example:
325 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
329 (regexp :tag "Address")
330 (choice :tag "Banner" :value nil
331 (const :tag "Remove signature" signature)
332 (symbol :tag "Item in `gnus-article-banner-alist'" none)
334 (const :tag "None" nil))))
335 :group 'gnus-article-washing)
337 (defcustom gnus-emphasis-alist
339 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
344 ("_/" "/_" underline-italic)
345 ("_\\*" "\\*_" underline-bold)
346 ("\\*/" "/\\*" bold-italic)
347 ("_\\*/" "/\\*_" underline-bold-italic))))
351 (format format (car spec) (car (cdr spec)))
352 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
354 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
355 2 3 gnus-emphasis-strikethru)
356 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
357 2 3 gnus-emphasis-underline)))
358 "*Alist that says how to fontify certain phrases.
359 Each item looks like this:
361 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
363 The first element is a regular expression to be matched. The second
364 is a number that says what regular expression grouping used to find
365 the entire emphasized word. The third is a number that says what
366 regexp grouping should be displayed and highlighted. The fourth
367 is the face used for highlighting."
368 :type '(repeat (list :value ("" 0 0 default)
370 (integer :tag "Match group")
371 (integer :tag "Emphasize group")
373 :group 'gnus-article-emphasis)
375 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
376 "A regexp to describe whitespace which should not be emphasized.
377 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
378 The former avoids underlining of leading and trailing whitespace,
379 and the latter avoids underlining any whitespace at all."
381 :group 'gnus-article-emphasis
384 (defface gnus-emphasis-bold '((t (:bold t)))
385 "Face used for displaying strong emphasized text (*word*)."
386 :group 'gnus-article-emphasis)
388 (defface gnus-emphasis-italic '((t (:italic t)))
389 "Face used for displaying italic emphasized text (/word/)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-underline '((t (:underline t)))
393 "Face used for displaying underlined emphasized text (_word_)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
397 "Face used for displaying underlined bold emphasized text (_*word*_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
401 "Face used for displaying underlined italic emphasized text (_/word/_)."
402 :group 'gnus-article-emphasis)
404 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
405 "Face used for displaying bold italic emphasized text (/*word*/)."
406 :group 'gnus-article-emphasis)
408 (defface gnus-emphasis-underline-bold-italic
409 '((t (:bold t :italic t :underline t)))
410 "Face used for displaying underlined bold italic emphasized text.
411 Example: (_/*word*/_)."
412 :group 'gnus-article-emphasis)
414 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
415 "Face used for displaying strike-through text (-word-)."
416 :group 'gnus-article-emphasis)
418 (defface gnus-emphasis-highlight-words
419 '((t (:background "black" :foreground "yellow")))
420 "Face used for displaying highlighted words."
421 :group 'gnus-article-emphasis)
423 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
424 "Format for display of Date headers in article bodies.
425 See `format-time-string' for the possible values.
427 The variable can also be function, which should return a complete Date
428 header. The function is called with one argument, the time, which can
429 be fed to `format-time-string'."
430 :type '(choice string symbol)
431 :link '(custom-manual "(gnus)Article Date")
432 :group 'gnus-article-washing)
435 (autoload 'mail-extract-address-components "mail-extr"))
437 (defcustom gnus-save-all-headers t
438 "*If non-nil, don't remove any headers before saving."
439 :group 'gnus-article-saving
442 (defcustom gnus-prompt-before-saving 'always
443 "*This variable says how much prompting is to be done when saving articles.
444 If it is nil, no prompting will be done, and the articles will be
445 saved to the default files. If this variable is `always', each and
446 every article that is saved will be preceded by a prompt, even when
447 saving large batches of articles. If this variable is neither nil not
448 `always', there the user will be prompted once for a file name for
449 each invocation of the saving commands."
450 :group 'gnus-article-saving
451 :type '(choice (item always)
452 (item :tag "never" nil)
453 (sexp :tag "once" :format "%t\n" :value t)))
455 (defcustom gnus-saved-headers gnus-visible-headers
456 "Headers to keep if `gnus-save-all-headers' is nil.
457 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
458 If that variable is nil, however, all headers that match this regexp
459 will be kept while the rest will be deleted before saving."
460 :group 'gnus-article-saving
463 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
464 "A function to save articles in your favourite format.
465 The function must be interactively callable (in other words, it must
466 be an Emacs command).
468 Gnus provides the following functions:
470 * gnus-summary-save-in-rmail (Rmail format)
471 * gnus-summary-save-in-mail (Unix mail format)
472 * gnus-summary-save-in-folder (MH folder)
473 * gnus-summary-save-in-file (article format)
474 * gnus-summary-save-body-in-file (article body)
475 * gnus-summary-save-in-vm (use VM's folder format)
476 * gnus-summary-write-to-file (article format -- overwrite)."
477 :group 'gnus-article-saving
478 :type '(radio (function-item gnus-summary-save-in-rmail)
479 (function-item gnus-summary-save-in-mail)
480 (function-item gnus-summary-save-in-folder)
481 (function-item gnus-summary-save-in-file)
482 (function-item gnus-summary-save-body-in-file)
483 (function-item gnus-summary-save-in-vm)
484 (function-item gnus-summary-write-to-file)))
486 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
487 "A function generating a file name to save articles in Rmail format.
488 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
489 :group 'gnus-article-saving
492 (defcustom gnus-mail-save-name 'gnus-plain-save-name
493 "A function generating a file name to save articles in Unix mail format.
494 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
495 :group 'gnus-article-saving
498 (defcustom gnus-folder-save-name 'gnus-folder-save-name
499 "A function generating a file name to save articles in MH folder.
500 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
501 :group 'gnus-article-saving
504 (defcustom gnus-file-save-name 'gnus-numeric-save-name
505 "A function generating a file name to save articles in article format.
506 The function is called with NEWSGROUP, HEADERS, and optional
508 :group 'gnus-article-saving
511 (defcustom gnus-split-methods
512 '((gnus-article-archive-name)
513 (gnus-article-nndoc-name))
514 "*Variable used to suggest where articles are to be saved.
515 For instance, if you would like to save articles related to Gnus in
516 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
517 you could set this variable to something like:
519 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
520 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
522 This variable is an alist where the where the key is the match and the
523 value is a list of possible files to save in if the match is non-nil.
525 If the match is a string, it is used as a regexp match on the
526 article. If the match is a symbol, that symbol will be funcalled
527 from the buffer of the article to be saved with the newsgroup as the
528 parameter. If it is a list, it will be evaled in the same buffer.
530 If this form or function returns a string, this string will be used as
531 a possible file name; and if it returns a non-nil list, that list will
532 be used as possible file names."
533 :group 'gnus-article-saving
534 :type '(repeat (choice (list :value (fun) function)
535 (cons :value ("" "") regexp (repeat string))
538 (defcustom gnus-article-display-method-for-mime
539 'gnus-article-display-mime-message
540 "Function to display a MIME message.
541 The function is called from the article buffer."
542 :group 'gnus-article-mime
545 (defcustom gnus-article-display-method-for-traditional
546 'gnus-article-display-traditional-message
547 "*Function to display a traditional message.
548 The function is called from the article buffer."
549 :group 'gnus-article-mime
552 (defcustom gnus-page-delimiter "^\^L"
553 "*Regexp describing what to use as article page delimiters.
554 The default value is \"^\^L\", which is a form linefeed at the
555 beginning of a line."
557 :group 'gnus-article-various)
559 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
560 "*The format specification for the article mode line.
561 See `gnus-summary-mode-line-format' for a closer description.
563 The following additional specs are available:
565 %w The article washing status.
566 %m The number of MIME parts in the article."
568 :group 'gnus-article-various)
570 (defcustom gnus-article-mode-hook nil
571 "*A hook for Gnus article mode."
573 :group 'gnus-article-various)
575 (when (featurep 'xemacs)
576 ;; Extracted from gnus-xmas-define in order to preserve user settings
577 (when (fboundp 'turn-off-scroll-in-place)
578 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
579 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
580 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
582 (defcustom gnus-article-menu-hook nil
583 "*Hook run after the creation of the article mode menu."
585 :group 'gnus-article-various)
587 (defcustom gnus-article-prepare-hook nil
588 "*A hook called after an article has been prepared in the article buffer."
590 :group 'gnus-article-various)
592 (defcustom gnus-article-hide-pgp-hook nil
593 "*A hook called after successfully hiding a PGP signature."
595 :group 'gnus-article-various)
597 (defcustom gnus-article-button-face 'bold
598 "Face used for highlighting buttons in the article buffer.
600 An article button is a piece of text that you can activate by pressing
601 `RET' or `mouse-2' above it."
603 :group 'gnus-article-buttons)
605 (defcustom gnus-article-mouse-face 'highlight
606 "Face used for mouse highlighting in the article buffer.
608 Article buttons will be displayed in this face when the cursor is
611 :group 'gnus-article-buttons)
613 (defcustom gnus-signature-face 'gnus-signature-face
614 "Face used for highlighting a signature in the article buffer.
615 Obsolete; use the face `gnus-signature-face' for customizations instead."
617 :group 'gnus-article-highlight
618 :group 'gnus-article-signature)
620 (defface gnus-signature-face
623 "Face used for highlighting a signature in the article buffer."
624 :group 'gnus-article-highlight
625 :group 'gnus-article-signature)
627 (defface gnus-header-from-face
630 (:foreground "spring green"))
633 (:foreground "red3"))
636 "Face used for displaying from headers."
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-subject-face
643 (:foreground "SeaGreen3"))
646 (:foreground "red4"))
648 (:bold t :italic t)))
649 "Face used for displaying subject headers."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-newsgroups-face
656 (:foreground "yellow" :italic t))
659 (:foreground "MidnightBlue" :italic t))
662 "Face used for displaying newsgroups headers."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defface gnus-header-name-face
669 (:foreground "SeaGreen"))
672 (:foreground "maroon"))
675 "Face used for displaying header names."
676 :group 'gnus-article-headers
677 :group 'gnus-article-highlight)
679 (defface gnus-header-content-face
682 (:foreground "forest green" :italic t))
685 (:foreground "indianred4" :italic t))
688 "Face used for displaying header content."
689 :group 'gnus-article-headers
690 :group 'gnus-article-highlight)
692 (defcustom gnus-header-face-alist
693 '(("From" nil gnus-header-from-face)
694 ("Subject" nil gnus-header-subject-face)
695 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
696 ("" gnus-header-name-face gnus-header-content-face))
697 "*Controls highlighting of article header.
699 An alist of the form (HEADER NAME CONTENT).
701 HEADER is a regular expression which should match the name of an
702 header header and NAME and CONTENT are either face names or nil.
704 The name of each header field will be displayed using the face
705 specified by the first element in the list where HEADER match the
706 header name and NAME is non-nil. Similarly, the content will be
707 displayed by the first non-nil matching CONTENT face."
708 :group 'gnus-article-headers
709 :group 'gnus-article-highlight
710 :type '(repeat (list (regexp :tag "Header")
712 (item :tag "skip" nil)
713 (face :value default))
714 (choice :tag "Content"
715 (item :tag "skip" nil)
716 (face :value default)))))
718 (defcustom gnus-article-decode-hook nil
719 "*Hook run to decode charsets in articles."
720 :group 'gnus-article-headers
723 (defcustom gnus-display-mime-function 'gnus-display-mime
724 "Function to display MIME articles."
725 :group 'gnus-article-mime
728 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
729 "Function used to decode headers.")
731 (defvar gnus-article-dumbquotes-map
746 ("\230" "-") ; This might not be correct.
751 "Table for MS-to-Latin1 translation.")
753 (defcustom gnus-ignored-mime-types nil
754 "List of MIME types that should be ignored by Gnus."
756 :group 'gnus-article-mime
757 :type '(repeat regexp))
759 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
760 "List of MIME types that should not be given buttons when rendered inline.
761 See also `gnus-buttonized-mime-types' which may override this variable."
763 :group 'gnus-article-mime
764 :type '(repeat regexp))
766 (defcustom gnus-buttonized-mime-types nil
767 "List of MIME types that should be given buttons when rendered inline.
768 If set, this variable overrides `gnus-unbuttonized-mime-types'.
769 To see e.g. security buttons you could set this to
770 `(\"multipart/signed\")'."
772 :group 'gnus-article-mime
773 :type '(repeat regexp))
775 (defcustom gnus-body-boundary-delimiter "_"
776 "String used to delimit header and body.
777 This variable is used by `gnus-article-treat-body-boundary' which can
778 be controlled by `gnus-treat-body-boundary'."
779 :group 'gnus-article-various
780 :type '(choice (item :tag "None" :value nil)
783 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
784 "Defines the location of the faces database.
785 For information on obtaining this database of pretty pictures, please
786 see http://www.cs.indiana.edu/picons/ftp/index.html"
787 :type '(repeat directory)
788 :link '(url-link :tag "download"
789 "http://www.cs.indiana.edu/picons/ftp/index.html")
790 :link '(custom-manual "(gnus)Picons")
793 (defun gnus-picons-installed-p ()
794 "Say whether picons are installed on your machine."
795 (let ((installed nil))
796 (dolist (database gnus-picon-databases)
797 (when (file-exists-p database)
801 (defcustom gnus-article-mime-part-function nil
802 "Function called with a MIME handle as the argument.
803 This is meant for people who want to do something automatic based
804 on parts -- for instance, adding Vcard info to a database."
805 :group 'gnus-article-mime
808 (defcustom gnus-mime-multipart-functions nil
809 "An alist of MIME types to functions to display them."
811 :group 'gnus-article-mime
814 (defcustom gnus-article-date-lapsed-new-header nil
815 "Whether the X-Sent and Date headers can coexist.
816 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
817 either replace the old \"Date:\" header (if this variable is nil), or
818 be added below it (otherwise)."
820 :group 'gnus-article-headers
823 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
824 "Function called with a MIME handle as the argument.
825 This is meant for people who want to view first matched part.
826 For `undisplayed-alternative' (default), the first undisplayed
827 part or alternative part is used. For `undisplayed', the first
828 undisplayed part is used. For a function, the first part which
829 the function return `t' is used. For `nil', the first part is
832 :group 'gnus-article-mime
834 (item :tag "first" :value nil)
835 (item :tag "undisplayed" :value undisplayed)
836 (item :tag "undisplayed or alternative"
837 :value undisplayed-alternative)
840 (defcustom gnus-mime-action-alist
841 '(("save to file" . gnus-mime-save-part)
842 ("save and strip" . gnus-mime-save-part-and-strip)
843 ("display as text" . gnus-mime-inline-part)
844 ("view the part" . gnus-mime-view-part)
845 ("pipe to command" . gnus-mime-pipe-part)
846 ("toggle display" . gnus-article-press-button)
847 ("toggle display" . gnus-article-view-part-as-charset)
848 ("view as type" . gnus-mime-view-part-as-type)
849 ("view internally" . gnus-mime-view-part-internally)
850 ("view externally" . gnus-mime-view-part-externally))
851 "An alist of actions that run on the MIME attachment."
852 :group 'gnus-article-mime
853 :type '(repeat (cons (string :tag "name")
857 ;;; The treatment variables
860 (defvar gnus-part-display-hook nil
861 "Hook called on parts that are to receive treatment.")
863 (defvar gnus-article-treat-custom
864 '(choice (const :tag "Off" nil)
866 (const :tag "Header" head)
867 (const :tag "Last" last)
868 (const :tag "Mime" mime)
869 (integer :tag "Less")
870 (repeat :tag "Groups" regexp)
871 (sexp :tag "Predicate")))
873 (defvar gnus-article-treat-head-custom
874 '(choice (const :tag "Off" nil)
875 (const :tag "Header" head)))
877 (defvar gnus-article-treat-types '("text/plain")
880 (defvar gnus-inhibit-treatment nil
881 "Whether to inhibit treatment.")
883 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
884 "Highlight the signature.
885 Valid values are nil, t, `head', `last', an integer or a predicate.
886 See Info node `(gnus)Customizing Articles'."
887 :group 'gnus-article-treat
888 :type gnus-article-treat-custom)
889 (put 'gnus-treat-highlight-signature 'highlight t)
891 (defcustom gnus-treat-buttonize 100000
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles'."
895 :group 'gnus-article-treat
896 :type gnus-article-treat-custom)
897 (put 'gnus-treat-buttonize 'highlight t)
899 (defcustom gnus-treat-buttonize-head 'head
900 "Add buttons to the head.
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See Info node `(gnus)Customizing Articles' for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-head-custom)
905 (put 'gnus-treat-buttonize-head 'highlight t)
907 (defcustom gnus-treat-emphasize
908 (and (or window-system
910 (>= (string-to-number emacs-version) 21))
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
917 (put 'gnus-treat-emphasize 'highlight t)
919 (defcustom gnus-treat-strip-cr nil
920 "Remove carriage returns.
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
923 :group 'gnus-article-treat
924 :type gnus-article-treat-custom)
926 (defcustom gnus-treat-unsplit-urls nil
927 "Remove newlines from within URLs.
928 Valid values are nil, t, `head', `last', an integer or a predicate.
929 See Info node `(gnus)Customizing Articles' for details."
930 :group 'gnus-article-treat
931 :type gnus-article-treat-custom)
933 (defcustom gnus-treat-leading-whitespace nil
934 "Remove leading whitespace in headers.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
937 :group 'gnus-article-treat
938 :type gnus-article-treat-custom)
940 (defcustom gnus-treat-hide-headers 'head
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-boring-headers nil
948 "Hide boring headers.
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :type gnus-article-treat-head-custom)
954 (defcustom gnus-treat-hide-signature nil
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See Info node `(gnus)Customizing Articles' for details."
958 :group 'gnus-article-treat
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-fill-article nil
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-hide-citation nil
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 :type gnus-article-treat-custom)
975 (defcustom gnus-treat-hide-citation-maybe nil
977 Valid values are nil, t, `head', `last', an integer or a predicate.
978 See Info node `(gnus)Customizing Articles' for details."
979 :group 'gnus-article-treat
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-strip-list-identifiers 'head
983 "Strip list identifiers from `gnus-list-identifiers`.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
987 :group 'gnus-article-treat
988 :type gnus-article-treat-custom)
990 (defcustom gnus-treat-strip-pgp t
991 "Strip PGP signatures.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-strip-pem nil
998 "Strip PEM signatures.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-strip-banner t
1005 "Strip banners from articles.
1006 The banner to be stripped is specified in the `banner' group parameter.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-highlight-headers 'head
1013 "Highlight the headers.
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :type gnus-article-treat-head-custom)
1018 (put 'gnus-treat-highlight-headers 'highlight t)
1020 (defcustom gnus-treat-highlight-citation t
1021 "Highlight cited text.
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 :type gnus-article-treat-custom)
1026 (put 'gnus-treat-highlight-citation 'highlight t)
1028 (defcustom gnus-treat-date-ut nil
1029 "Display the Date in UT (GMT).
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :type gnus-article-treat-head-custom)
1035 (defcustom gnus-treat-date-local nil
1036 "Display the Date in the local timezone.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1039 :group 'gnus-article-treat
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-head-custom)
1049 (defcustom gnus-treat-date-lapsed nil
1050 "Display the Date header in a way that says how much time has elapsed.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-date-original nil
1057 "Display the date in the original timezone.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :type gnus-article-treat-head-custom)
1063 (defcustom gnus-treat-date-iso8601 nil
1064 "Display the date in the ISO8601 format.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :type gnus-article-treat-head-custom)
1071 (defcustom gnus-treat-date-user-defined nil
1072 "Display the date in a user-defined format.
1073 The format is defined by the `gnus-article-time-format' variable.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :type gnus-article-treat-head-custom)
1079 (defcustom gnus-treat-strip-headers-in-body t
1080 "Strip the X-No-Archive header line from the beginning of the body.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :type gnus-article-treat-custom)
1087 (defcustom gnus-treat-strip-trailing-blank-lines nil
1088 "Strip trailing blank lines.
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 :type gnus-article-treat-custom)
1094 (defcustom gnus-treat-strip-leading-blank-lines nil
1095 "Strip leading blank lines.
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' for details."
1098 :group 'gnus-article-treat
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-multiple-blank-lines nil
1102 "Strip multiple blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :type gnus-article-treat-custom)
1108 (defcustom gnus-treat-unfold-headers 'head
1109 "Unfold folded header lines.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-fold-headers nil
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-fold-newsgroups 'head
1123 "Fold the Newsgroups and Followup-To headers.
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 :type gnus-article-treat-custom)
1129 (defcustom gnus-treat-overstrike t
1130 "Treat overstrike highlighting.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' for details."
1133 :group 'gnus-article-treat
1134 :type gnus-article-treat-custom)
1135 (put 'gnus-treat-overstrike 'highlight t)
1137 (defcustom gnus-treat-display-xface
1138 (and (not noninteractive)
1139 (or (and (fboundp 'image-type-available-p)
1140 (image-type-available-p 'xbm)
1141 (string-match "^0x" (shell-command-to-string "uncompface")))
1142 (and (featurep 'xemacs)
1144 (eq 'x-face-mule-gnus-article-display-x-face
1145 gnus-article-x-face-command))
1147 "Display X-Face headers.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' and Info node
1150 `(gnus)X-Face' for details."
1151 :group 'gnus-article-treat
1153 :type gnus-article-treat-head-custom)
1154 (put 'gnus-treat-display-xface 'highlight t)
1156 (defcustom gnus-article-should-use-smiley-mule
1157 (not (or (featurep 'xemacs)
1158 (gnus-image-type-available-p 'xpm)
1159 (gnus-image-type-available-p 'pbm)))
1160 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1161 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1162 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1163 even if you are using Emacs 21+. It has no effect on XEmacs."
1164 :group 'gnus-article-various
1166 :get (lambda (symbol)
1167 (and (default-value symbol)
1168 (not (featurep 'xemacs))
1169 (module-installed-p 'smiley-mule)
1171 :set (lambda (symbol value)
1172 (set-default symbol (and value
1173 (not (featurep 'xemacs))
1174 (module-installed-p 'smiley-mule)
1177 (defvar gnus-article-smiley-mule-loaded-p nil
1178 "Internal variable used to say whether `smiley-mule' is loaded (whether
1179 smiley functions are not overridden by `smiley').")
1181 (defcustom gnus-treat-display-grey-xface
1182 (and (not noninteractive)
1183 (or (featurep 'xemacs)
1184 (and (fboundp 'display-images-p)
1185 (display-images-p)))
1186 (string-match "^0x" (shell-command-to-string "uncompface"))
1188 "Display grey X-Face headers.
1189 Valid values are nil, t."
1190 :group 'gnus-article-treat
1193 (put 'gnus-treat-display-grey-xface 'highlight t)
1195 (defcustom gnus-treat-display-smileys
1196 (if (or (and (featurep 'xemacs)
1198 (gnus-image-type-available-p 'xpm)
1199 (gnus-image-type-available-p 'pbm)
1200 (and (not (featurep 'xemacs))
1202 (module-installed-p 'smiley-mule)))
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' and Info node
1208 `(gnus)Smileys' for details."
1209 :group 'gnus-article-treat
1211 :type gnus-article-treat-custom)
1212 (put 'gnus-treat-display-smileys 'highlight t)
1214 (defcustom gnus-treat-from-picon
1215 (if (and (gnus-image-type-available-p 'xpm)
1216 (gnus-picons-installed-p))
1218 "Display picons in the From header.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' and Info node
1221 `(gnus)Picons' for details."
1222 :group 'gnus-article-treat
1224 :link '(info-link "(gnus)Customizing Articles")
1225 :link '(info-link "(gnus)Picons")
1226 :type gnus-article-treat-head-custom)
1227 (put 'gnus-treat-from-picon 'highlight t)
1229 (defcustom gnus-treat-mail-picon
1230 (if (and (gnus-image-type-available-p 'xpm)
1231 (gnus-picons-installed-p))
1233 "Display picons in To and Cc headers.
1234 Valid values are nil, t, `head', `last', an integer or a predicate.
1235 See Info node `(gnus)Customizing Articles' and Info node
1236 `(gnus)Picons' for details."
1237 :group 'gnus-article-treat
1239 :link '(info-link "(gnus)Customizing Articles")
1240 :link '(info-link "(gnus)Picons")
1241 :type gnus-article-treat-head-custom)
1242 (put 'gnus-treat-mail-picon 'highlight t)
1244 (defcustom gnus-treat-newsgroups-picon
1245 (if (and (gnus-image-type-available-p 'xpm)
1246 (gnus-picons-installed-p))
1248 "Display picons in the Newsgroups and Followup-To headers.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' and Info node
1251 `(gnus)Picons' for details."
1252 :group 'gnus-article-treat
1254 :link '(info-link "(gnus)Customizing Articles")
1255 :link '(info-link "(gnus)Picons")
1256 :type gnus-article-treat-head-custom)
1257 (put 'gnus-treat-newsgroups-picon 'highlight t)
1259 (defcustom gnus-treat-body-boundary
1260 (if (or gnus-treat-newsgroups-picon
1261 gnus-treat-mail-picon
1262 gnus-treat-from-picon)
1264 "Draw a boundary at the end of the headers.
1265 Valid values are nil, t, `head', `last', an integer or a predicate.
1266 See Info node `(gnus)Customizing Articles' for details."
1268 :group 'gnus-article-treat
1269 :type gnus-article-treat-custom)
1271 (defcustom gnus-treat-capitalize-sentences nil
1272 "Capitalize sentence-starting words.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1276 :group 'gnus-article-treat
1277 :type gnus-article-treat-custom)
1279 (defcustom gnus-treat-fill-long-lines nil
1281 Valid values are nil, t, `head', `last', an integer or a predicate.
1282 See Info node `(gnus)Customizing Articles' for details."
1283 :group 'gnus-article-treat
1284 :type gnus-article-treat-custom)
1286 (defcustom gnus-treat-play-sounds nil
1288 Valid values are nil, t, `head', `last', an integer or a predicate.
1289 See Info node `(gnus)Customizing Articles' for details."
1291 :group 'gnus-article-treat
1292 :type gnus-article-treat-custom)
1294 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1295 "Decode an article as `default-mime-charset'. For instance, if you want to
1296 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1297 you could set this variable to something like: nil for don't decode, t for
1298 decode the body, '(or header t) for the whole article, etc."
1299 :group 'gnus-article-treat
1300 :type '(radio (const :tag "Off" nil)
1301 (const :tag "Decode body" t)
1302 (const :tag "Decode all" (or head t))))
1304 (defcustom gnus-treat-translate nil
1305 "Translate articles from one language to another.
1306 Valid values are nil, t, `head', `last', an integer or a predicate.
1307 See Info node `(gnus)Customizing Articles' for details."
1309 :group 'gnus-article-treat
1310 :type gnus-article-treat-custom)
1312 (defcustom gnus-treat-x-pgp-sig nil
1314 To automatically treat X-PGP-Sig, set it to head.
1315 Valid values are nil, t, `head', `last', an integer or a predicate.
1316 See Info node `(gnus)Customizing Articles' for details."
1317 :group 'gnus-article-treat
1318 :group 'mime-security
1319 :type gnus-article-treat-custom)
1321 (defcustom gnus-treat-monafy nil
1322 "Display body part with mona font.
1323 Valid values are nil, t, `head', `last', an integer or a predicate.
1324 See Info node `(gnus)Customizing Articles' for details."
1325 :group 'gnus-article-treat
1326 :group 'mime-security
1327 :type gnus-article-treat-custom)
1329 (defvar gnus-article-encrypt-protocol-alist
1330 '(("PGP" . mml2015-self-encrypt)))
1332 ;; Set to nil if more than one protocol added to
1333 ;; gnus-article-encrypt-protocol-alist.
1334 (defcustom gnus-article-encrypt-protocol "PGP"
1335 "The protocol used for encrypt articles.
1336 It is a string, such as \"PGP\". If nil, ask user."
1338 :group 'mime-security)
1340 (defvar gnus-article-wash-function nil
1341 "Function used for converting HTML into text.")
1343 ;;; Internal variables
1345 (defvar gnus-english-month-names
1346 '("January" "February" "March" "April" "May" "June" "July" "August"
1347 "September" "October" "November" "December"))
1349 (defvar article-goto-body-goes-to-point-min-p nil)
1350 (defvar gnus-article-wash-types nil)
1351 (defvar gnus-article-emphasis-alist nil)
1352 (defvar gnus-article-image-alist nil)
1354 (defvar gnus-article-mime-handle-alist-1 nil)
1355 (defvar gnus-treatment-function-alist
1356 '((gnus-treat-decode-article-as-default-mime-charset
1357 gnus-article-decode-article-as-default-mime-charset)
1358 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1359 (gnus-treat-monafy gnus-article-monafy)
1360 (gnus-treat-strip-banner gnus-article-strip-banner)
1361 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1362 (gnus-treat-buttonize gnus-article-add-buttons)
1363 (gnus-treat-fill-article gnus-article-fill-cited-article)
1364 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1365 (gnus-treat-strip-cr gnus-article-remove-cr)
1366 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1367 (gnus-treat-date-ut gnus-article-date-ut)
1368 (gnus-treat-date-local gnus-article-date-local)
1369 (gnus-treat-date-english gnus-article-date-english)
1370 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1371 (gnus-treat-date-original gnus-article-date-original)
1372 (gnus-treat-date-user-defined gnus-article-date-user)
1373 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1374 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1375 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1376 (gnus-treat-hide-signature gnus-article-hide-signature)
1377 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1378 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1379 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1380 (gnus-treat-strip-pem gnus-article-hide-pem)
1381 (gnus-treat-from-picon gnus-treat-from-picon)
1382 (gnus-treat-mail-picon gnus-treat-mail-picon)
1383 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1384 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1385 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1386 (gnus-treat-strip-trailing-blank-lines
1387 gnus-article-remove-trailing-blank-lines)
1388 (gnus-treat-strip-leading-blank-lines
1389 gnus-article-strip-leading-blank-lines)
1390 (gnus-treat-strip-multiple-blank-lines
1391 gnus-article-strip-multiple-blank-lines)
1392 (gnus-treat-overstrike gnus-article-treat-overstrike)
1393 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1394 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1395 ;; Displaying X-Face should be done after unfolding headers
1396 ;; to protect bitmap lines.
1397 (gnus-treat-display-xface gnus-article-display-x-face)
1398 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1399 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1400 (gnus-treat-display-smileys gnus-treat-smiley)
1401 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1402 (gnus-treat-emphasize gnus-article-emphasize)
1403 (gnus-treat-hide-citation gnus-article-hide-citation)
1404 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1405 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1406 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1407 (gnus-treat-play-sounds gnus-earcon-display)))
1409 (defvar gnus-article-mime-handle-alist nil)
1410 (defvar article-lapsed-timer nil)
1411 (defvar gnus-article-current-summary nil)
1413 (defvar gnus-article-mode-syntax-table
1414 (let ((table (copy-syntax-table text-mode-syntax-table)))
1415 ;; This causes the citation match run O(2^n).
1416 ;; (modify-syntax-entry ?- "w" table)
1417 (modify-syntax-entry ?> ")<" table)
1418 (modify-syntax-entry ?< "(>" table)
1420 "Syntax table used in article mode buffers.
1421 Initialized from `text-mode-syntax-table.")
1423 (defvar gnus-save-article-buffer nil)
1425 (defvar gnus-article-mode-line-format-alist
1426 (nconc '((?w (gnus-article-wash-status) ?s)
1427 (?m (gnus-article-mime-part-status) ?s))
1428 gnus-summary-mode-line-format-alist))
1430 (defvar gnus-number-of-articles-to-be-saved nil)
1432 (defvar gnus-inhibit-hiding nil)
1434 ;;; Macros for dealing with the article buffer.
1436 (defmacro gnus-with-article-headers (&rest forms)
1438 (set-buffer gnus-article-buffer)
1440 (let ((buffer-read-only nil)
1441 (inhibit-point-motion-hooks t)
1442 (case-fold-search t))
1443 (article-narrow-to-head)
1446 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1447 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1449 (defmacro gnus-with-article-buffer (&rest forms)
1451 (set-buffer gnus-article-buffer)
1452 (let ((buffer-read-only nil))
1455 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1456 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1458 (defun gnus-article-goto-header (header)
1459 "Go to HEADER, which is a regular expression."
1460 (re-search-forward (concat "^\\(" header "\\):") nil t))
1462 (defsubst gnus-article-hide-text (b e props)
1463 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1464 (gnus-add-text-properties-when 'article-type nil b e props)
1465 (when (memq 'intangible props)
1467 (max (1- b) (point-min))
1468 b 'intangible (cddr (memq 'intangible props)))))
1470 (defsubst gnus-article-unhide-text (b e)
1471 "Remove hidden text properties from region between B and E."
1472 (remove-text-properties b e gnus-hidden-properties)
1473 (when (memq 'intangible gnus-hidden-properties)
1474 (put-text-property (max (1- b) (point-min))
1475 b 'intangible nil)))
1477 (defun gnus-article-hide-text-type (b e type)
1478 "Hide text of TYPE between B and E."
1479 (gnus-add-wash-type type)
1480 (gnus-article-hide-text
1481 b e (cons 'article-type (cons type gnus-hidden-properties))))
1483 (defun gnus-article-unhide-text-type (b e type)
1484 "Unhide text of TYPE between B and E."
1485 (gnus-delete-wash-type type)
1486 (remove-text-properties
1487 b e (cons 'article-type (cons type gnus-hidden-properties)))
1488 (when (memq 'intangible gnus-hidden-properties)
1489 (put-text-property (max (1- b) (point-min))
1490 b 'intangible nil)))
1492 (defun gnus-article-hide-text-of-type (type)
1493 "Hide text of TYPE in the current buffer."
1495 (let ((b (point-min))
1497 (while (setq b (text-property-any b e 'article-type type))
1498 (add-text-properties b (incf b) gnus-hidden-properties)))))
1500 (defun gnus-article-delete-text-of-type (type)
1501 "Delete text of TYPE in the current buffer."
1503 (let ((b (point-min)))
1504 (while (setq b (text-property-any b (point-max) 'article-type type))
1506 b (or (text-property-not-all b (point-max) 'article-type type)
1509 (defun gnus-article-delete-invisible-text ()
1510 "Delete all invisible text in the current buffer."
1512 (let ((b (point-min)))
1513 (while (setq b (text-property-any b (point-max) 'invisible t))
1515 b (or (text-property-not-all b (point-max) 'invisible t)
1518 (defun gnus-article-text-type-exists-p (type)
1519 "Say whether any text of type TYPE exists in the buffer."
1520 (text-property-any (point-min) (point-max) 'article-type type))
1522 (defsubst gnus-article-header-rank ()
1523 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1524 (let ((list gnus-sorted-header-list)
1527 (when (looking-at (car list))
1529 (setq list (cdr list))
1533 (defun article-hide-headers (&optional arg delete)
1534 "Hide unwanted headers and possibly sort them as well."
1535 (interactive (gnus-article-hidden-arg))
1536 ;; Lars said that this function might be inhibited.
1537 (if (gnus-article-check-hidden-text 'headers arg)
1539 ;; Show boring headers as well.
1540 (gnus-article-show-hidden-text 'boring-headers)
1541 (when (eq 1 (point-min))
1542 (set-window-start (get-buffer-window (current-buffer)) 1)))
1543 (unless gnus-inhibit-hiding
1546 (let ((inhibit-read-only t)
1547 (case-fold-search t)
1548 (max (1+ (length gnus-sorted-header-list)))
1549 (ignored (when (not gnus-visible-headers)
1550 (cond ((stringp gnus-ignored-headers)
1551 gnus-ignored-headers)
1552 ((listp gnus-ignored-headers)
1553 (mapconcat 'identity gnus-ignored-headers
1556 (cond ((stringp gnus-visible-headers)
1557 gnus-visible-headers)
1558 ((and gnus-visible-headers
1559 (listp gnus-visible-headers))
1560 (mapconcat 'identity gnus-visible-headers "\\|"))))
1561 (inhibit-point-motion-hooks t)
1563 ;; First we narrow to just the headers.
1564 (article-narrow-to-head)
1565 ;; Hide any "From " lines at the beginning of (mail) articles.
1566 (while (looking-at "From ")
1570 (delete-region (point-min) (point))
1571 (gnus-article-hide-text (point-min) (point)
1572 (nconc (list 'article-type 'headers)
1573 gnus-hidden-properties))))
1574 ;; Then treat the rest of the header lines.
1575 ;; Then we use the two regular expressions
1576 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1577 ;; select which header lines is to remain visible in the
1579 (while (re-search-forward "^[^ \t:]*:" nil t)
1581 ;; Mark the rank of the header.
1583 (point) (1+ (point)) 'message-rank
1584 (if (or (and visible (looking-at visible))
1586 (not (looking-at ignored))))
1587 (gnus-article-header-rank)
1590 (message-sort-headers-1)
1591 (when (setq beg (text-property-any
1592 (point-min) (point-max) 'message-rank (+ 2 max)))
1593 ;; We delete or make invisible the unwanted headers.
1594 (gnus-add-wash-type 'headers)
1597 (add-text-properties
1598 (point-min) (+ 5 (point-min))
1599 '(article-type headers dummy-invisible t))
1600 (delete-region beg (point-max)))
1601 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1603 (defun article-hide-boring-headers (&optional arg)
1604 "Toggle hiding of headers that aren't very interesting.
1605 If given a negative prefix, always show; if given a positive prefix,
1607 (interactive (gnus-article-hidden-arg))
1608 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1609 (not gnus-show-all-headers))
1612 (let ((buffer-read-only nil)
1613 (list gnus-boring-article-headers)
1614 (inhibit-point-motion-hooks t)
1616 (article-narrow-to-head)
1618 (setq elem (pop list))
1619 (goto-char (point-min))
1621 ;; Hide empty headers.
1623 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1625 (gnus-article-hide-text-type
1626 (progn (beginning-of-line) (point))
1629 (if (re-search-forward "^[^ \t]" nil t)
1633 ;; Hide boring Newsgroups header.
1634 ((eq elem 'newsgroups)
1635 (when (gnus-string-equal
1636 (gnus-fetch-field "newsgroups")
1637 (gnus-group-real-name
1638 (if (boundp 'gnus-newsgroup-name)
1641 (gnus-article-hide-header "newsgroups")))
1642 ((eq elem 'to-address)
1643 (let ((to (message-fetch-field "to"))
1645 (gnus-parameter-to-address
1646 (if (boundp 'gnus-newsgroup-name)
1647 gnus-newsgroup-name ""))))
1648 (when (and to to-address
1651 ;; only one address in To
1652 (nth 1 (mail-extract-address-components to))
1654 (gnus-article-hide-header "to"))))
1655 ((eq elem 'followup-to)
1656 (when (gnus-string-equal
1657 (message-fetch-field "followup-to")
1658 (message-fetch-field "newsgroups"))
1659 (gnus-article-hide-header "followup-to")))
1660 ((eq elem 'reply-to)
1661 (let ((from (message-fetch-field "from"))
1662 (reply-to (message-fetch-field "reply-to")))
1667 (nth 1 (mail-extract-address-components from))
1668 (nth 1 (mail-extract-address-components reply-to)))))
1669 (gnus-article-hide-header "reply-to"))))
1671 (let ((date (message-fetch-field "date")))
1673 (< (days-between (current-time-string) date)
1675 (gnus-article-hide-header "date"))))
1677 (let ((to (message-fetch-field "to"))
1678 (cc (message-fetch-field "cc")))
1679 (when (> (length to) 1024)
1680 (gnus-article-hide-header "to"))
1681 (when (> (length cc) 1024)
1682 (gnus-article-hide-header "cc"))))
1686 (goto-char (point-min))
1687 (while (re-search-forward "^to:" nil t)
1688 (setq to-count (1+ to-count)))
1689 (when (> to-count 1)
1690 (while (> to-count 0)
1691 (goto-char (point-min))
1693 (re-search-forward "^to:" nil nil to-count)
1695 (narrow-to-region (point) (point-max))
1696 (gnus-article-hide-header "to"))
1697 (setq to-count (1- to-count))))
1698 (goto-char (point-min))
1699 (while (re-search-forward "^cc:" nil t)
1700 (setq cc-count (1+ cc-count)))
1701 (when (> cc-count 1)
1702 (while (> cc-count 0)
1703 (goto-char (point-min))
1705 (re-search-forward "^cc:" nil nil cc-count)
1707 (narrow-to-region (point) (point-max))
1708 (gnus-article-hide-header "cc"))
1709 (setq cc-count (1- cc-count)))))))))))))
1711 (defun gnus-article-hide-header (header)
1713 (goto-char (point-min))
1714 (when (re-search-forward (concat "^" header ":") nil t)
1715 (gnus-article-hide-text-type
1716 (progn (beginning-of-line) (point))
1719 (if (re-search-forward "^[^ \t]" nil t)
1724 (defvar gnus-article-normalized-header-length 40
1725 "Length of normalized headers.")
1727 (defun article-normalize-headers ()
1728 "Make all header lines 40 characters long."
1730 (let ((buffer-read-only nil)
1734 (article-narrow-to-head)
1737 ((< (setq column (- (gnus-point-at-eol) (point)))
1738 gnus-article-normalized-header-length)
1740 (insert (make-string
1741 (- gnus-article-normalized-header-length column)
1743 ((> column gnus-article-normalized-header-length)
1744 (gnus-put-text-property
1746 (forward-char gnus-article-normalized-header-length)
1753 (forward-line 1))))))
1755 (defun article-treat-dumbquotes ()
1756 "Translate M****s*** sm*rtq**t*s into proper text.
1757 Note that this function guesses whether a character is a sm*rtq**t* or
1758 not, so it should only be used interactively.
1760 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1761 in an attempt to provide more quoting characters. If you see
1762 something like \\222 or \\264 where you're expecting some kind of
1763 apostrophe or quotation mark, then try this wash."
1765 (article-translate-strings gnus-article-dumbquotes-map))
1767 (defun article-translate-characters (from to)
1768 "Translate all characters in the body of the article according to FROM and TO.
1769 FROM is a string of characters to translate from; to is a string of
1770 characters to translate to."
1772 (when (article-goto-body)
1773 (let ((buffer-read-only nil)
1774 (x (make-string 225 ?x))
1776 (while (< (incf i) (length x))
1779 (while (< i (length from))
1780 (aset x (aref from i) (aref to i))
1782 (translate-region (point) (point-max) x)))))
1784 (defun article-translate-strings (map)
1785 "Translate all string in the body of the article according to MAP.
1786 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1788 (when (article-goto-body)
1789 (let ((buffer-read-only nil)
1791 (while (setq elem (pop map))
1793 (while (search-forward (car elem) nil t)
1794 (replace-match (cadr elem)))))))))
1796 (defun article-treat-overstrike ()
1797 "Translate overstrikes into bold text."
1800 (when (article-goto-body)
1801 (let ((buffer-read-only nil))
1802 (while (search-forward "\b" nil t)
1803 (let ((next (char-after))
1807 previous (char-after))
1811 ;; We do the boldification/underlining by hiding the
1812 ;; overstrikes and putting the proper text property
1816 (gnus-article-hide-text-type start (point) 'overstrike)
1817 (put-text-property (point) end 'face 'bold))
1819 (gnus-article-hide-text-type
1820 (1- (point)) (1+ (point)) 'overstrike)
1822 start (1- (point)) 'face 'underline))
1824 (gnus-article-hide-text-type start (point) 'overstrike)
1826 (point) end 'face 'underline)))))))))
1828 (defun gnus-article-treat-unfold-headers ()
1829 "Unfold folded message headers.
1830 Only the headers that fit into the current window width will be
1833 (gnus-with-article-headers
1837 (mail-header-narrow-to-field)
1838 (let ((header (buffer-substring (point-min) (point-max))))
1841 (goto-char (point-min))
1842 (while (re-search-forward "\n[\t ]" nil t)
1843 (replace-match " " t t)))
1844 (setq length (- (point-max) (point-min) 1)))
1845 (when (< length (window-width))
1846 (while (re-search-forward "\n[\t ]" nil t)
1847 (replace-match " " t t)))
1848 (goto-char (point-max)))))))
1850 (defun gnus-article-treat-fold-headers ()
1851 "Fold message headers."
1853 (gnus-with-article-headers
1856 (mail-header-narrow-to-field)
1857 (mail-header-fold-field)
1858 (goto-char (point-max))))))
1860 (defun gnus-treat-smiley ()
1861 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1863 (unless (featurep 'xemacs)
1864 (when (and (>= emacs-major-version 21)
1865 (not gnus-article-should-use-smiley-mule)
1866 gnus-article-smiley-mule-loaded-p)
1867 (load "smiley" nil t)
1868 (setq gnus-article-smiley-mule-loaded-p nil))
1869 (when (and gnus-article-should-use-smiley-mule
1870 (not gnus-article-smiley-mule-loaded-p))
1871 (load "smiley-mule" nil t)
1872 (setq gnus-article-smiley-mule-loaded-p t)))
1873 (gnus-with-article-buffer
1874 (if (memq 'smiley gnus-article-wash-types)
1875 (gnus-delete-images 'smiley)
1877 (let ((images (smiley-region (point) (point-max))))
1879 (gnus-add-wash-type 'smiley)
1880 (dolist (image images)
1881 (gnus-add-image 'smiley image)))))))
1883 (defun gnus-article-remove-images ()
1884 "Remove all images from the article buffer."
1886 (gnus-with-article-buffer
1887 (dolist (elem gnus-article-image-alist)
1888 (gnus-delete-images (car elem)))))
1890 (defun gnus-article-treat-fold-newsgroups ()
1891 "Unfold folded message headers.
1892 Only the headers that fit into the current window width will be
1895 (gnus-with-article-headers
1896 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1898 (mail-header-narrow-to-field)
1899 (while (re-search-forward ", *" nil t)
1900 (replace-match ", " t t))
1901 (mail-header-fold-field)
1902 (goto-char (point-max))))))
1904 (defun gnus-article-treat-body-boundary ()
1905 "Place a boundary line at the end of the headers."
1907 (when (and gnus-body-boundary-delimiter
1908 (> (length gnus-body-boundary-delimiter) 0))
1909 (gnus-with-article-headers
1910 (goto-char (point-max))
1911 (let ((start (point)))
1912 (insert "X-Boundary: ")
1913 (gnus-add-text-properties start (point) '(invisible t intangible t))
1915 (while (>= (1- (window-width)) (length str))
1916 (setq str (concat str gnus-body-boundary-delimiter)))
1917 (substring str 0 (1- (window-width))))
1919 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1921 (defun article-fill-long-lines ()
1922 "Fill lines that are wider than the window width."
1925 (let ((buffer-read-only nil)
1926 (width (window-width (get-buffer-window (current-buffer)))))
1929 (let ((adaptive-fill-mode nil)) ;Why? -sm
1932 (when (>= (current-column) (min fill-column width))
1933 (narrow-to-region (min (1+ (point)) (point-max))
1934 (gnus-point-at-bol))
1935 (let ((goback (point-marker)))
1936 (fill-paragraph nil)
1937 (goto-char (marker-position goback)))
1939 (forward-line 1)))))))
1941 (defun article-capitalize-sentences ()
1942 "Capitalize the first word in each sentence."
1945 (let ((buffer-read-only nil)
1946 (paragraph-start "^[\n\^L]"))
1950 (forward-sentence)))))
1952 (defun article-remove-cr ()
1953 "Remove trailing CRs and then translate remaining CRs into LFs."
1956 (let ((buffer-read-only nil))
1957 (goto-char (point-min))
1958 (while (re-search-forward "\r+$" nil t)
1959 (replace-match "" t t))
1960 (goto-char (point-min))
1961 (while (search-forward "\r" nil t)
1962 (replace-match "\n" t t)))))
1964 (defun article-remove-trailing-blank-lines ()
1965 "Remove all trailing blank lines from the article."
1968 (let ((buffer-read-only nil))
1969 (goto-char (point-max))
1973 (while (and (not (bobp))
1974 (looking-at "^[ \t]*$")
1975 (not (gnus-annotation-in-region-p
1976 (point) (gnus-point-at-eol))))
1981 (defun article-display-x-face (&optional force)
1982 "Look for an X-Face header and display it if present."
1983 (interactive (list 'force))
1984 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1985 (gnus-with-article-headers
1986 ;; Delete the old process, if any.
1987 (when (process-status "article-x-face")
1988 (delete-process "article-x-face"))
1989 (if (memq 'xface gnus-article-wash-types)
1990 ;; We have already displayed X-Faces, so we remove them
1992 (gnus-delete-images 'xface)
1994 (let (x-faces from face grey)
1996 (when (and wash-face-p
1998 (goto-char (point-min))
1999 (not (re-search-forward
2000 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2001 (gnus-buffer-live-p gnus-original-article-buffer))
2002 ;; If type `W f', use gnus-original-article-buffer,
2003 ;; otherwise use the current buffer because displaying
2004 ;; RFC822 parts calls this function too.
2005 (set-buffer gnus-original-article-buffer))
2007 (mail-narrow-to-head)
2008 (if gnus-treat-display-grey-xface
2010 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2011 (if (match-beginning 2)
2014 (push (cons (- (string-to-number (match-string 2)))
2015 (mail-header-field-value))
2017 (push (cons 0 (mail-header-field-value)) x-faces)))
2018 (dolist (x-face (prog1
2020 (sort x-faces 'car-less-than-car)
2022 (setq x-faces nil)))
2023 (push (cdr x-face) x-faces)))
2024 (while (gnus-article-goto-header "X-Face")
2025 (push (mail-header-field-value) x-faces)))
2026 (setq from (message-fetch-field "from"))))
2028 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2031 (setq image (gnus-create-image xpm 'xpm t))
2032 (gnus-article-goto-header "from")
2034 (insert "From: [no `from' set]\n")
2036 (gnus-add-wash-type 'xface)
2037 (gnus-add-image 'xface image)
2038 (gnus-put-image image)))
2039 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2040 ;; single external face.
2041 (when (stringp gnus-article-x-face-command)
2042 (setq x-faces (list (car x-faces))))
2043 (while (and (setq face (pop x-faces))
2044 gnus-article-x-face-command
2046 ;; Check whether this face is censored.
2047 (not gnus-article-x-face-too-ugly)
2048 (and gnus-article-x-face-too-ugly from
2049 (not (string-match gnus-article-x-face-too-ugly
2051 ;; We display the face.
2052 (if (symbolp gnus-article-x-face-command)
2053 ;; The command is a lisp function, so we call it.
2054 (if (gnus-functionp gnus-article-x-face-command)
2055 (funcall gnus-article-x-face-command face)
2056 (error "%s is not a function" gnus-article-x-face-command))
2057 ;; The command is a string, so we interpret the command
2058 ;; as a, well, command, and fork it off.
2059 (let ((process-connection-type nil))
2060 (process-kill-without-query
2062 "article-x-face" nil shell-file-name shell-command-switch
2063 gnus-article-x-face-command))
2066 (process-send-region "article-x-face"
2067 (point-min) (point-max)))
2068 (process-send-eof "article-x-face"))))))))))
2070 (defun article-decode-mime-words ()
2071 "Decode all MIME-encoded words in the article."
2074 (set-buffer gnus-article-buffer)
2075 (let ((inhibit-point-motion-hooks t)
2077 (mail-parse-charset gnus-newsgroup-charset)
2078 (mail-parse-ignored-charsets
2079 (save-excursion (set-buffer gnus-summary-buffer)
2080 gnus-newsgroup-ignored-charsets)))
2081 (mail-decode-encoded-word-region (point-min) (point-max)))))
2083 (defun article-decode-charset (&optional prompt)
2084 "Decode charset-encoded text in the article.
2085 If PROMPT (the prefix), prompt for a coding system to use."
2087 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2089 (mail-parse-charset gnus-newsgroup-charset)
2090 (mail-parse-ignored-charsets
2091 (save-excursion (condition-case nil
2092 (set-buffer gnus-summary-buffer)
2094 gnus-newsgroup-ignored-charsets))
2095 ct cte ctl charset format)
2098 (article-narrow-to-head)
2099 (setq ct (message-fetch-field "Content-Type" t)
2100 cte (message-fetch-field "Content-Transfer-Encoding" t)
2101 ctl (and ct (ignore-errors
2102 (mail-header-parse-content-type ct)))
2105 (mm-read-coding-system "Charset to decode: "))
2107 (mail-content-type-get ctl 'charset)))
2108 format (and ctl (mail-content-type-get ctl 'format)))
2110 (setq cte (mail-header-strip cte)))
2111 (if (and ctl (not (string-match "/" (car ctl))))
2113 (goto-char (point-max)))
2116 (narrow-to-region (point) (point-max))
2117 (when (and (eq mail-parse-charset 'gnus-decoded)
2118 (eq (mm-body-7-or-8) '8bit))
2119 ;; The text code could have been decoded.
2120 (setq charset mail-parse-charset))
2121 (when (and (or (not ctl)
2122 (equal (car ctl) "text/plain"))
2123 (not format)) ;; article with format will decode later.
2125 charset (and cte (intern (downcase
2126 (gnus-strip-whitespace cte))))
2129 (defun article-decode-encoded-words ()
2130 "Remove encoded-word encoding from headers."
2131 (let (buffer-read-only)
2132 (let ((charset (save-excursion
2133 (set-buffer gnus-summary-buffer)
2134 default-mime-charset)))
2135 (mime-decode-header-in-buffer charset))))
2137 (defun article-decode-group-name ()
2138 "Decode group names in `Newsgroups:'."
2139 (let ((inhibit-point-motion-hooks t)
2141 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2142 (when (and (or gnus-group-name-charset-method-alist
2143 gnus-group-name-charset-group-alist)
2144 (gnus-buffer-live-p gnus-original-article-buffer))
2145 (when (nnmail-fetch-field "Newsgroups")
2146 (nnheader-replace-header "Newsgroups"
2147 (gnus-decode-newsgroups
2148 (with-current-buffer
2149 gnus-original-article-buffer
2150 (nnmail-fetch-field "Newsgroups"))
2151 gnus-newsgroup-name method)))
2152 (when (nnmail-fetch-field "Followup-To")
2153 (nnheader-replace-header "Followup-To"
2154 (gnus-decode-newsgroups
2155 (with-current-buffer
2156 gnus-original-article-buffer
2157 (nnmail-fetch-field "Followup-To"))
2158 gnus-newsgroup-name method))))))
2160 (defun article-de-quoted-unreadable (&optional force read-charset)
2161 "Translate a quoted-printable-encoded article.
2162 If FORCE, decode the article whether it is marked as quoted-printable
2164 If READ-CHARSET, ask for a coding system."
2165 (interactive (list 'force current-prefix-arg))
2167 (let ((buffer-read-only nil) type charset)
2168 (if (gnus-buffer-live-p gnus-original-article-buffer)
2169 (with-current-buffer gnus-original-article-buffer
2171 (gnus-fetch-field "content-transfer-encoding"))
2172 (let* ((ct (gnus-fetch-field "content-type"))
2175 (mail-header-parse-content-type ct)))))
2176 (setq charset (and ctl
2177 (mail-content-type-get ctl 'charset)))
2178 (if (stringp charset)
2179 (setq charset (intern (downcase charset)))))))
2181 (setq charset (mm-read-coding-system "Charset: " charset)))
2183 (setq charset gnus-newsgroup-charset))
2185 (and type (let ((case-fold-search t))
2186 (string-match "quoted-printable" type))))
2188 (quoted-printable-decode-region
2189 (point) (point-max) (mm-charset-to-coding-system charset))))))
2191 (defun article-de-base64-unreadable (&optional force read-charset)
2192 "Translate a base64 article.
2193 If FORCE, decode the article whether it is marked as base64 not.
2194 If READ-CHARSET, ask for a coding system."
2195 (interactive (list 'force current-prefix-arg))
2197 (let ((buffer-read-only nil) type charset)
2198 (if (gnus-buffer-live-p gnus-original-article-buffer)
2199 (with-current-buffer gnus-original-article-buffer
2201 (gnus-fetch-field "content-transfer-encoding"))
2202 (let* ((ct (gnus-fetch-field "content-type"))
2205 (mail-header-parse-content-type ct)))))
2206 (setq charset (and ctl
2207 (mail-content-type-get ctl 'charset)))
2208 (if (stringp charset)
2209 (setq charset (intern (downcase charset)))))))
2211 (setq charset (mm-read-coding-system "Charset: " charset)))
2213 (setq charset gnus-newsgroup-charset))
2215 (and type (let ((case-fold-search t))
2216 (string-match "base64" type))))
2219 (narrow-to-region (point) (point-max))
2220 (base64-decode-region (point-min) (point-max))
2221 (mm-decode-coding-region
2222 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2227 (defun article-decode-HZ ()
2228 "Translate a HZ-encoded article."
2232 (let ((buffer-read-only nil))
2233 (rfc1843-decode-region (point-min) (point-max)))))
2235 (defun article-unsplit-urls ()
2236 "Remove the newlines that some other mailers insert into URLs."
2239 (let ((buffer-read-only nil))
2240 (goto-char (point-min))
2241 (while (re-search-forward
2242 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2243 (replace-match "\\1\\3" t)))
2244 (when (and gnus-display-mime-function (interactive-p))
2245 (funcall gnus-display-mime-function))))
2248 (defun article-wash-html (&optional read-charset)
2249 "Format an html article.
2250 If READ-CHARSET, ask for a coding system."
2253 (let ((buffer-read-only nil)
2255 (if (gnus-buffer-live-p gnus-original-article-buffer)
2256 (with-current-buffer gnus-original-article-buffer
2257 (let* ((ct (gnus-fetch-field "content-type"))
2260 (mail-header-parse-content-type ct)))))
2261 (setq charset (and ctl
2262 (mail-content-type-get ctl 'charset)))
2263 (if (stringp charset)
2264 (setq charset (intern (downcase charset)))))))
2266 (setq charset (mm-read-coding-system "Charset: " charset)))
2268 (setq charset gnus-newsgroup-charset))
2270 (save-window-excursion
2272 (narrow-to-region (point) (point-max))
2273 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2274 (entry (assq func mm-text-html-washer-alist)))
2276 (setq func (cdr entry)))
2278 ((gnus-functionp func)
2281 (apply (car func) (cdr func))))))))))
2283 (defun gnus-article-wash-html-with-w3 ()
2284 "Wash the current buffer with w3."
2286 (let ((w3-strict-width (window-width))
2287 (url-standalone-mode t)
2288 (url-gateway-unplugged t)
2289 (w3-honor-stylesheets nil))
2291 (w3-region (point-min) (point-max))
2294 (defun gnus-article-wash-html-with-w3m ()
2295 "Wash the current buffer with emacs-w3m."
2298 (narrow-to-region (point) (point-max))
2299 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2302 (w3m-display-inline-images mm-inline-text-html-with-images)
2303 w3m-force-redisplay)
2304 (w3m-region (point-min) (point-max)))
2305 (when mm-inline-text-html-with-w3m-keymap
2306 (add-text-properties
2307 (point-min) (point-max)
2308 (append '(mm-inline-text-html-with-w3m t)
2309 (gnus-local-map-property mm-w3m-mode-map))))))
2311 (defun article-hide-list-identifiers ()
2312 "Remove list identifies from the Subject header.
2313 The `gnus-list-identifiers' variable specifies what to do."
2315 (let ((inhibit-point-motion-hooks t)
2316 (regexp (if (consp gnus-list-identifiers)
2317 (mapconcat 'identity gnus-list-identifiers " *\\|")
2318 gnus-list-identifiers))
2323 (article-narrow-to-head)
2324 (goto-char (point-min))
2325 (while (re-search-forward
2326 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2328 (delete-region (match-beginning 2) (match-end 0))
2329 (beginning-of-line))
2330 (when (re-search-forward
2331 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2332 (delete-region (match-beginning 1) (match-end 1))))))))
2334 (defun article-hide-pgp ()
2335 "Remove any PGP headers and signatures in the current article."
2339 (let ((inhibit-point-motion-hooks t)
2340 buffer-read-only beg end)
2342 ;; Hide the "header".
2343 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2344 (gnus-add-wash-type 'pgp)
2345 (delete-region (match-beginning 0) (match-end 0))
2346 ;; Remove armor headers (rfc2440 6.2)
2347 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2350 ;; Hide the actual signature.
2351 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2352 (setq end (1+ (match-beginning 0)))
2355 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2357 ;; Perhaps we shouldn't hide to the end of the buffer
2358 ;; if there is no end to the signature?
2360 ;; Hide "- " PGP quotation markers.
2362 (narrow-to-region beg end)
2363 (goto-char (point-min))
2364 (while (re-search-forward "^- " nil t)
2366 (match-beginning 0) (match-end 0)))
2368 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2370 (defun article-hide-pem (&optional arg)
2371 "Toggle hiding of any PEM headers and signatures in the current article.
2372 If given a negative prefix, always show; if given a positive prefix,
2374 (interactive (gnus-article-hidden-arg))
2375 (unless (gnus-article-check-hidden-text 'pem arg)
2377 (let (buffer-read-only end)
2378 (goto-char (point-min))
2379 ;; Hide the horrendously ugly "header".
2380 (when (and (search-forward
2381 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2383 (setq end (1+ (match-beginning 0))))
2384 (gnus-add-wash-type 'pem)
2385 (gnus-article-hide-text-type
2387 (if (search-forward "\n\n" nil t)
2391 ;; Hide the trailer as well
2392 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2394 (gnus-article-hide-text-type
2395 (match-beginning 0) (match-end 0) 'pem)))))))
2397 (defun article-strip-banner ()
2398 "Strip the banner specified by the `banner' group parameter."
2402 (let ((inhibit-point-motion-hooks t)
2403 (banner (gnus-parameter-banner gnus-newsgroup-name))
2404 (gnus-signature-limit nil)
2405 buffer-read-only beg end)
2406 (when (and gnus-article-address-banner-alist
2409 (let ((from (save-restriction
2411 (article-narrow-to-head)
2412 (caar (mail-header-parse-addresses
2413 (mail-fetch-field "from"))))))
2415 (dolist (pair gnus-article-address-banner-alist)
2416 (when (string-match (car pair) from)
2417 (throw 'found (cdr pair))))))))
2421 ((eq banner 'signature)
2422 (when (gnus-article-narrow-to-signature)
2425 (delete-region (point) (point-max))))
2427 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2428 (while (re-search-forward banner nil t)
2429 (delete-region (match-beginning 0) (match-end 0)))))
2431 (while (re-search-forward banner nil t)
2432 (delete-region (match-beginning 0) (match-end 0))))))))))
2434 (defun article-babel ()
2435 "Translate article using an online translation service."
2439 (set-buffer gnus-article-buffer)
2440 (when (article-goto-body)
2441 (let* ((buffer-read-only nil)
2444 (orig (buffer-substring start end))
2445 (trans (babel-as-string orig)))
2447 (narrow-to-region start end)
2448 (delete-region start end)
2451 (defun article-hide-signature (&optional arg)
2452 "Hide the signature in the current article.
2453 If given a negative prefix, always show; if given a positive prefix,
2455 (interactive (gnus-article-hidden-arg))
2461 (article-goto-body))
2462 (goto-char (point-min)))
2463 (unless (gnus-article-check-hidden-text 'signature arg)
2464 (let ((buffer-read-only nil)
2466 (while (setq button (text-property-any button (point-max)
2468 'gnus-signature-toggle))
2469 (setq button (text-property-not-all button (point-max)
2471 'gnus-signature-toggle))
2472 (when (and button (not (eobp)))
2473 (gnus-article-hide-text-type
2475 (next-single-property-change (1+ button) 'mime-view-entity
2478 (gnus-set-mode-line 'article))
2480 (defun article-strip-headers-in-body ()
2481 "Strip offensive headers from bodies."
2485 (let ((case-fold-search t))
2486 (when (looking-at "x-no-archive:")
2487 (gnus-delete-line)))))
2489 (defun article-strip-leading-blank-lines ()
2490 "Remove all blank lines from the beginning of the article."
2493 (let ((inhibit-point-motion-hooks t)
2495 (when (article-goto-body)
2496 (while (and (not (eobp))
2497 (looking-at "[ \t]*$"))
2498 (gnus-delete-line))))))
2500 (defun article-narrow-to-head ()
2501 "Narrow the buffer to the head of the message.
2502 Point is left at the beginning of the narrowed-to region."
2504 (goto-char (point-min))
2505 (if (search-forward "\n\n" nil 1)
2508 (goto-char (point-min)))
2510 (defun article-goto-body ()
2511 "Place point at the start of the body."
2512 (goto-char (point-min))
2514 ;; This variable is only bound when dealing with separate
2516 (article-goto-body-goes-to-point-min-p
2518 ((search-forward "\n\n" nil t)
2521 (goto-char (point-max))
2524 (defun article-strip-multiple-blank-lines ()
2525 "Replace consecutive blank lines with one empty line."
2528 (let ((inhibit-point-motion-hooks t)
2530 ;; First make all blank lines empty.
2532 (while (re-search-forward "^[ \t]+$" nil t)
2533 (unless (gnus-annotation-in-region-p
2534 (match-beginning 0) (match-end 0))
2535 (replace-match "" nil t)))
2536 ;; Then replace multiple empty lines with a single empty line.
2538 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2539 (unless (gnus-annotation-in-region-p
2540 (match-beginning 0) (match-end 0))
2541 (delete-region (match-beginning 1) (match-end 1)))))))
2543 (defun article-strip-leading-space ()
2544 "Remove all white space from the beginning of the lines in the article."
2547 (let ((inhibit-point-motion-hooks t)
2550 (while (re-search-forward "^[ \t]+" nil t)
2551 (replace-match "" t t)))))
2553 (defun article-strip-trailing-space ()
2554 "Remove all white space from the end of the lines in the article."
2557 (let ((inhibit-point-motion-hooks t)
2560 (while (re-search-forward "[ \t]+$" nil t)
2561 (replace-match "" t t)))))
2563 (defun article-strip-blank-lines ()
2564 "Strip leading, trailing and multiple blank lines."
2566 (article-strip-leading-blank-lines)
2567 (article-remove-trailing-blank-lines)
2568 (article-strip-multiple-blank-lines))
2570 (defun article-strip-all-blank-lines ()
2571 "Strip all blank lines."
2574 (let ((inhibit-point-motion-hooks t)
2577 (while (re-search-forward "^[ \t]*\n" nil t)
2578 (replace-match "" t t)))))
2580 (defun gnus-article-narrow-to-signature ()
2581 "Narrow to the signature; return t if a signature is found, else nil."
2582 (let ((inhibit-point-motion-hooks t))
2583 (when (gnus-article-search-signature)
2585 ;; Check whether we have some limits to what we consider
2586 ;; to be a signature.
2587 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2588 (list gnus-signature-limit)))
2590 (while (setq limit (pop limits))
2591 (if (or (and (integerp limit)
2592 (< (- (point-max) (point)) limit))
2594 (< (count-lines (point) (point-max)) limit))
2595 (and (gnus-functionp limit)
2597 (and (stringp limit)
2598 (not (re-search-forward limit nil t))))
2599 () ; This limit did not succeed.
2603 (narrow-to-region (point) (point-max))
2606 (defun gnus-article-search-signature ()
2607 "Search the current buffer for the signature separator.
2608 Put point at the beginning of the signature separator."
2609 (let ((cur (point)))
2610 (goto-char (point-max))
2611 (if (if (stringp gnus-signature-separator)
2612 (re-search-backward gnus-signature-separator nil t)
2613 (let ((seps gnus-signature-separator))
2615 (not (re-search-backward (car seps) nil t)))
2622 (defun gnus-article-hidden-arg ()
2623 "Return the current prefix arg as a number, or 0 if no prefix."
2624 (list (if current-prefix-arg
2625 (prefix-numeric-value current-prefix-arg)
2628 (defun gnus-article-check-hidden-text (type arg)
2629 "Return nil if hiding is necessary.
2630 Arg can be nil or a number. nil and positive means hide, negative
2631 means show, 0 means toggle."
2634 (let ((hide (gnus-article-hidden-text-p type)))
2640 (gnus-article-show-hidden-text type)
2643 (if (eq hide 'hidden)
2645 (gnus-article-show-hidden-text type)
2649 (defun gnus-article-hidden-text-p (type)
2650 "Say whether the current buffer contains hidden text of type TYPE."
2651 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2653 (not (get-text-property pos 'invisible))
2654 (not (get-text-property pos 'dummy-invisible)))
2656 (text-property-any (1+ pos) (point-max) 'article-type type)))
2661 (defun gnus-article-show-hidden-text (type &optional dummy)
2662 "Show all hidden text of type TYPE.
2663 Originally it is hide instead of DUMMY."
2664 (let ((buffer-read-only nil)
2665 (inhibit-point-motion-hooks t))
2666 (gnus-remove-text-properties-when
2668 (point-min) (point-max)
2669 (cons 'article-type (cons type
2670 gnus-hidden-properties)))
2671 (gnus-delete-wash-type type)))
2673 (defconst article-time-units
2674 `((year . ,(* 365.25 24 60 60))
2675 (week . ,(* 7 24 60 60))
2676 (day . ,(* 24 60 60))
2680 "Mapping from time units to seconds.")
2682 (defun article-date-ut (&optional type highlight header)
2683 "Convert DATE date to universal time in the current article.
2684 If TYPE is `local', convert to local time; if it is `lapsed', output
2685 how much time has lapsed since DATE. For `lapsed', the value of
2686 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2687 should replace the \"Date:\" one, or should be added below it."
2688 (interactive (list 'ut t))
2689 (let* ((header (or header
2690 (and (eq 1 (point-min))
2691 (mail-header-date (save-excursion
2692 (set-buffer gnus-summary-buffer)
2693 gnus-current-headers)))
2694 (message-fetch-field "date")
2696 (date (if (vectorp header) (mail-header-date header)
2698 (inhibit-point-motion-hooks t)
2699 bface eface date-pos)
2700 (when (and date (not (string= date "")))
2703 (article-narrow-to-head)
2704 (when (or (and (eq type 'lapsed)
2705 gnus-article-date-lapsed-new-header
2706 ;; Attempt to get the face of X-Sent first.
2707 (re-search-forward "^X-Sent:[ \t]" nil t))
2708 (re-search-forward "^Date:[ \t]" nil t)
2709 ;; If Date is missing, try again for X-Sent.
2710 (re-search-forward "^X-Sent:[ \t]" nil t))
2711 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2712 date (or (get-text-property (gnus-point-at-bol)
2715 eface (get-text-property (1- (gnus-point-at-eol))
2717 (let ((buffer-read-only nil))
2718 ;; Delete any old X-Sent headers.
2719 (when (setq date-pos
2720 (text-property-any (point-min) (point-max)
2721 'article-date-lapsed t))
2722 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2723 (delete-region (match-beginning 0)
2724 (progn (forward-line 1) (point))))
2725 (goto-char (point-min))
2726 ;; Delete any old Date headers.
2727 (while (re-search-forward "^Date:[ \t]" nil t)
2729 (setq date-pos (match-beginning 0)))
2730 (unless (and (eq type 'lapsed)
2731 gnus-article-date-lapsed-new-header)
2732 (delete-region (match-beginning 0)
2733 (progn (message-next-header) (point)))))
2736 (goto-char date-pos)
2738 ;; Possibly, Date has been deleted.
2740 (when (and (eq type 'lapsed)
2741 gnus-article-date-lapsed-new-header
2742 (looking-at "Date:"))
2744 (goto-char (point-min)))
2745 (insert (article-make-date-line date type))
2746 (when (eq type 'lapsed)
2747 (put-text-property (gnus-point-at-bol) (point)
2748 'article-date-lapsed t))
2752 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2753 (put-text-property (match-beginning 1) (1+ (match-end 1))
2754 'original-date date)
2755 (put-text-property (match-beginning 1) (1+ (match-end 1))
2757 (put-text-property (match-beginning 2) (match-end 2)
2760 (defun article-make-date-line (date type)
2761 "Return a DATE line of TYPE."
2762 (unless (memq type '(local ut original user iso8601 lapsed english))
2763 (error "Unknown conversion type: %s" type))
2765 (let ((time (date-to-time date)))
2767 ;; Convert to the local timezone.
2769 (let ((tz (car (current-time-zone time))))
2770 (format "Date: %s %s%02d%02d" (current-time-string time)
2771 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2772 (/ (% (abs tz) 3600) 60))))
2773 ;; Convert to Universal Time.
2776 (current-time-string
2777 (let* ((e (parse-time-string date))
2778 (tm (apply 'encode-time e))
2780 (ls (- (cadr tm) (car (current-time-zone time)))))
2781 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2782 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2785 ;; Get the original date from the article.
2786 ((eq type 'original)
2787 (concat "Date: " (if (string-match "\n+$" date)
2788 (substring date 0 (match-beginning 0))
2790 ;; Let the user define the format.
2792 (let ((format (or (condition-case nil
2793 (with-current-buffer gnus-summary-buffer
2794 gnus-article-time-format)
2796 gnus-article-time-format)))
2797 (if (gnus-functionp format)
2798 (funcall format time)
2799 (concat "Date: " (format-time-string format time)))))
2802 (let ((tz (car (current-time-zone time))))
2805 (format-time-string "%Y%m%dT%H%M%S" time)
2806 (format "%s%02d%02d"
2807 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2808 (/ (% (abs tz) 3600) 60)))))
2809 ;; Do an X-Sent lapsed format.
2811 ;; If the date is seriously mangled, the timezone functions are
2812 ;; liable to bug out, so we ignore all errors.
2813 (let* ((now (current-time))
2814 (real-time (subtract-time now time))
2815 (real-sec (and real-time
2816 (+ (* (float (car real-time)) 65536)
2818 (sec (and real-time (abs real-sec)))
2828 ;; This is a bit convoluted, but basically we go
2829 ;; through the time units for years, weeks, etc,
2830 ;; and divide things to see whether that results
2831 ;; in positive answers.
2834 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2835 ;; The (remaining) seconds are too few to
2836 ;; be divided into this time unit.
2838 ;; It's big enough, so we output it.
2839 (setq sec (- sec (* num (cdr unit))))
2841 (concat (if prev ", " "") (int-to-string
2843 " " (symbol-name (car unit))
2844 (if (> num 1) "s" ""))
2846 article-time-units "")
2847 ;; If dates are odd, then it might appear like the
2848 ;; article was sent in the future.
2851 " in the future"))))))
2852 ;; Display the date in proper English
2854 (let ((dtime (decode-time time)))
2857 (number-to-string (nth 3 dtime))
2858 (let ((digit (% (nth 3 dtime) 10)))
2860 ((memq (nth 3 dtime) '(11 12 13)) "th")
2866 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2868 (number-to-string (nth 5 dtime))
2870 (format "%02d" (nth 2 dtime))
2872 (format "%02d" (nth 1 dtime)))))))
2874 (format "Date: %s (from T-gnus)" date))))
2876 (defun article-date-local (&optional highlight)
2877 "Convert the current article date to the local timezone."
2878 (interactive (list t))
2879 (article-date-ut 'local highlight))
2881 (defun article-date-english (&optional highlight)
2882 "Convert the current article date to something that is proper English."
2883 (interactive (list t))
2884 (article-date-ut 'english highlight))
2886 (defun article-date-original (&optional highlight)
2887 "Convert the current article date to what it was originally.
2888 This is only useful if you have used some other date conversion
2889 function and want to see what the date was before converting."
2890 (interactive (list t))
2891 (article-date-ut 'original highlight))
2893 (defun article-date-lapsed (&optional highlight)
2894 "Convert the current article date to time lapsed since it was sent."
2895 (interactive (list t))
2896 (article-date-ut 'lapsed highlight))
2898 (defun article-update-date-lapsed ()
2899 "Function to be run from a timer to update the lapsed time line."
2900 (let (deactivate-mark)
2905 (set-buffer (window-buffer w))
2906 (when (eq major-mode 'gnus-article-mode)
2907 (goto-char (point-min))
2908 (when (re-search-forward "^X-Sent:" nil t)
2909 (article-date-lapsed t))))
2912 (defun gnus-start-date-timer (&optional n)
2913 "Start a timer to update the X-Sent header in the article buffers.
2914 The numerical prefix says how frequently (in seconds) the function
2919 (gnus-stop-date-timer)
2920 (setq article-lapsed-timer
2921 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2923 (defun gnus-stop-date-timer ()
2924 "Stop the X-Sent timer."
2926 (when article-lapsed-timer
2927 (nnheader-cancel-timer article-lapsed-timer)
2928 (setq article-lapsed-timer nil)))
2930 (defun article-date-user (&optional highlight)
2931 "Convert the current article date to the user-defined format.
2932 This format is defined by the `gnus-article-time-format' variable."
2933 (interactive (list t))
2934 (article-date-ut 'user highlight))
2936 (defun article-date-iso8601 (&optional highlight)
2937 "Convert the current article date to ISO8601."
2938 (interactive (list t))
2939 (article-date-ut 'iso8601 highlight))
2941 ;; (defun article-show-all ()
2942 ;; "Show all hidden text in the article buffer."
2946 ;; (let ((buffer-read-only nil))
2947 ;; (gnus-article-unhide-text (point-min) (point-max))
2948 ;; (gnus-remove-text-with-property 'gnus-prev)
2949 ;; (gnus-remove-text-with-property 'gnus-next))))
2951 (defun article-show-all-headers ()
2952 "Show all hidden headers in the article buffer."
2957 (article-narrow-to-head)
2958 (let ((buffer-read-only nil))
2959 (gnus-article-unhide-text (point-min) (point-max))))))
2961 (defun article-remove-leading-whitespace ()
2962 "Remove excessive whitespace from all headers."
2966 (let ((buffer-read-only nil))
2967 (article-narrow-to-head)
2968 (goto-char (point-min))
2969 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2970 (delete-region (match-beginning 1) (match-end 1)))))))
2972 (defun article-emphasize (&optional arg)
2973 "Emphasize text according to `gnus-emphasis-alist'."
2974 (interactive (gnus-article-hidden-arg))
2975 (unless (gnus-article-check-hidden-text 'emphasis arg)
2979 (with-current-buffer gnus-summary-buffer
2980 gnus-article-emphasis-alist)
2982 gnus-emphasis-alist))
2983 (buffer-read-only nil)
2984 (props (append '(article-type emphasis)
2985 gnus-hidden-properties))
2986 regexp elem beg invisible visible face)
2989 (while (setq elem (pop alist))
2991 (setq regexp (car elem)
2992 invisible (nth 1 elem)
2993 visible (nth 2 elem)
2995 (while (re-search-forward regexp nil t)
2996 (when (and (match-beginning visible) (match-beginning invisible))
2997 (gnus-article-hide-text
2998 (match-beginning invisible) (match-end invisible) props)
2999 (gnus-article-unhide-text-type
3000 (match-beginning visible) (match-end visible) 'emphasis)
3001 (gnus-put-overlay-excluding-newlines
3002 (match-beginning visible) (match-end visible) 'face face)
3003 (gnus-add-wash-type 'emphasis)
3004 (goto-char (match-end invisible)))))))))
3006 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3007 "Setup newsgroup emphasis alist."
3008 (unless gnus-article-emphasis-alist
3009 (let ((name (and gnus-newsgroup-name
3010 (gnus-group-real-name gnus-newsgroup-name))))
3011 (make-local-variable 'gnus-article-emphasis-alist)
3012 (setq gnus-article-emphasis-alist
3014 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3015 (while (setq elem (pop alist))
3016 (when (and name (string-match (car elem) name))
3018 highlight (copy-sequence (cdr elem)))))
3020 (copy-sequence highlight-words)
3021 (if gnus-newsgroup-name
3022 (copy-sequence (gnus-group-find-parameter
3023 gnus-newsgroup-name 'highlight-words t)))
3024 gnus-emphasis-alist)))))
3027 (defvar gnus-summary-article-menu)
3028 (defvar gnus-summary-post-menu))
3030 ;;; Saving functions.
3032 (defun gnus-article-save (save-buffer file &optional num)
3033 "Save the currently selected article."
3034 (unless gnus-save-all-headers
3035 ;; Remove headers according to `gnus-saved-headers'.
3036 (let ((gnus-visible-headers
3037 (or gnus-saved-headers gnus-visible-headers))
3038 (gnus-article-buffer save-buffer))
3040 (set-buffer save-buffer)
3041 (article-hide-headers 1 t))))
3042 (save-window-excursion
3043 (if (not gnus-default-article-saver)
3044 (error "No default saver is defined")
3045 ;; !!! Magic! The saving functions all save
3046 ;; `gnus-save-article-buffer' (or so they think), but we
3047 ;; bind that variable to our save-buffer.
3048 (set-buffer gnus-article-buffer)
3049 (let* ((gnus-save-article-buffer save-buffer)
3052 ((not gnus-prompt-before-saving) 'default)
3053 ((eq gnus-prompt-before-saving 'always) nil)
3055 (gnus-number-of-articles-to-be-saved
3056 (when (eq gnus-prompt-before-saving t)
3058 (set-buffer gnus-article-current-summary)
3059 (funcall gnus-default-article-saver filename)))))
3061 (defun gnus-read-save-file-name (prompt &optional filename
3062 function group headers variable)
3064 (funcall function group headers (symbol-value variable)))
3069 ((eq filename 'default)
3075 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3078 (if (and gnus-number-of-articles-to-be-saved
3079 (> gnus-number-of-articles-to-be-saved 1))
3080 (format "these %d articles"
3081 gnus-number-of-articles-to-be-saved)
3084 ;; Let the split methods have their say.
3086 ;; No split name was found.
3089 (concat prompt " (default "
3090 (file-name-nondirectory default-name) ") ")
3091 (file-name-directory default-name)
3093 ;; A single group name is returned.
3094 ((stringp split-name)
3096 (funcall function split-name headers
3097 (symbol-value variable)))
3099 (concat prompt " (default "
3100 (file-name-nondirectory default-name) ") ")
3101 (file-name-directory default-name)
3103 ;; A single split name was found
3104 ((= 1 (length split-name))
3105 (let* ((name (expand-file-name
3107 gnus-article-save-directory))
3108 (dir (cond ((file-directory-p name)
3109 (file-name-as-directory name))
3110 ((file-exists-p name) name)
3111 (t gnus-article-save-directory))))
3113 (concat prompt " (default " name ") ")
3115 ;; A list of splits was found.
3117 (setq split-name (nreverse split-name))
3119 (let ((file-name-history
3120 (nconc split-name file-name-history)))
3124 (concat prompt " (`M-p' for defaults) ")
3125 gnus-article-save-directory
3127 gnus-article-save-directory)))
3128 (car (push result file-name-history)))))))
3129 ;; Create the directory.
3130 (gnus-make-directory (file-name-directory file))
3131 ;; If we have read a directory, we append the default file name.
3132 (when (file-directory-p file)
3133 (setq file (expand-file-name (file-name-nondirectory
3135 (file-name-as-directory file))))
3136 ;; Possibly translate some characters.
3137 (nnheader-translate-file-chars file))))))
3138 (gnus-make-directory (file-name-directory result))
3139 (set variable result)))
3141 (defun gnus-article-archive-name (group)
3142 "Return the first instance of an \"Archive-name\" in the current buffer."
3143 (let ((case-fold-search t))
3144 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3145 (nnheader-concat gnus-article-save-directory
3146 (match-string 1)))))
3148 (defun gnus-article-nndoc-name (group)
3149 "If GROUP is an nndoc group, return the name of the parent group."
3150 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3151 (gnus-group-get-parameter group 'save-article-group)))
3153 (defun gnus-summary-save-in-rmail (&optional filename)
3154 "Append this article to Rmail file.
3155 Optional argument FILENAME specifies file name.
3156 Directory to save to is default to `gnus-article-save-directory'."
3157 (setq filename (gnus-read-save-file-name
3158 "Save %s in rmail file:" filename
3159 gnus-rmail-save-name gnus-newsgroup-name
3160 gnus-current-headers 'gnus-newsgroup-last-rmail))
3161 (gnus-eval-in-buffer-window gnus-save-article-buffer
3165 (gnus-output-to-rmail filename))))
3168 (defun gnus-summary-save-in-mail (&optional filename)
3169 "Append this article to Unix mail file.
3170 Optional argument FILENAME specifies file name.
3171 Directory to save to is default to `gnus-article-save-directory'."
3172 (setq filename (gnus-read-save-file-name
3173 "Save %s in Unix mail file:" filename
3174 gnus-mail-save-name gnus-newsgroup-name
3175 gnus-current-headers 'gnus-newsgroup-last-mail))
3176 (gnus-eval-in-buffer-window gnus-save-article-buffer
3180 (if (and (file-readable-p filename)
3181 (mail-file-babyl-p filename))
3182 (rmail-output-to-rmail-file filename t)
3183 (gnus-output-to-mail filename)))))
3186 (defun gnus-summary-save-in-file (&optional filename overwrite)
3187 "Append this article to file.
3188 Optional argument FILENAME specifies file name.
3189 Directory to save to is default to `gnus-article-save-directory'."
3190 (setq filename (gnus-read-save-file-name
3191 "Save %s in file:" filename
3192 gnus-file-save-name gnus-newsgroup-name
3193 gnus-current-headers 'gnus-newsgroup-last-file))
3194 (gnus-eval-in-buffer-window gnus-save-article-buffer
3198 (when (and overwrite
3199 (file-exists-p filename))
3200 (delete-file filename))
3201 (gnus-output-to-file filename))))
3204 (defun gnus-summary-write-to-file (&optional filename)
3205 "Write this article to a file, overwriting it if the file exists.
3206 Optional argument FILENAME specifies file name.
3207 The directory to save in defaults to `gnus-article-save-directory'."
3208 (gnus-summary-save-in-file nil t))
3210 (defun gnus-summary-save-body-in-file (&optional filename)
3211 "Append this article body to a file.
3212 Optional argument FILENAME specifies file name.
3213 The directory to save in defaults to `gnus-article-save-directory'."
3214 (setq filename (gnus-read-save-file-name
3215 "Save %s body in file:" filename
3216 gnus-file-save-name gnus-newsgroup-name
3217 gnus-current-headers 'gnus-newsgroup-last-file))
3218 (gnus-eval-in-buffer-window gnus-save-article-buffer
3222 (when (article-goto-body)
3223 (narrow-to-region (point) (point-max)))
3224 (gnus-output-to-file filename))))
3227 (defun gnus-summary-save-in-pipe (&optional command)
3228 "Pipe this article to subprocess."
3230 (cond ((and (eq command 'default)
3231 gnus-last-shell-command)
3232 gnus-last-shell-command)
3237 "Shell command on %s: "
3238 (if (and gnus-number-of-articles-to-be-saved
3239 (> gnus-number-of-articles-to-be-saved 1))
3240 (format "these %d articles"
3241 gnus-number-of-articles-to-be-saved)
3243 gnus-last-shell-command))))
3244 (when (string-equal command "")
3245 (if gnus-last-shell-command
3246 (setq command gnus-last-shell-command)
3247 (error "A command is required")))
3248 (gnus-eval-in-buffer-window gnus-article-buffer
3251 (shell-command-on-region (point-min) (point-max) command nil)))
3252 (setq gnus-last-shell-command command))
3254 (defun gnus-summary-pipe-to-muttprint (&optional command)
3255 "Pipe this article to muttprint."
3256 (setq command (read-string
3257 "Print using command: " gnus-summary-muttprint-program
3258 nil gnus-summary-muttprint-program))
3259 (gnus-summary-save-in-pipe command))
3261 ;;; Article file names when saving.
3263 (defun gnus-capitalize-newsgroup (newsgroup)
3264 "Capitalize NEWSGROUP name."
3265 (when (not (zerop (length newsgroup)))
3266 (concat (char-to-string (upcase (aref newsgroup 0)))
3267 (substring newsgroup 1))))
3269 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3270 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3271 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3272 Otherwise, it is like ~/News/news/group/num."
3275 (concat (if (gnus-use-long-file-name 'not-save)
3276 (gnus-capitalize-newsgroup newsgroup)
3277 (gnus-newsgroup-directory-form newsgroup))
3278 "/" (int-to-string (mail-header-number headers)))
3279 gnus-article-save-directory)))
3281 (string-equal (file-name-directory default)
3282 (file-name-directory last-file))
3283 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3285 (or last-file default))))
3287 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3288 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3289 If variable `gnus-use-long-file-name' is non-nil, it is
3290 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3293 (concat (if (gnus-use-long-file-name 'not-save)
3295 (gnus-newsgroup-directory-form newsgroup))
3296 "/" (int-to-string (mail-header-number headers)))
3297 gnus-article-save-directory)))
3299 (string-equal (file-name-directory default)
3300 (file-name-directory last-file))
3301 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3303 (or last-file default))))
3305 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3306 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3307 If variable `gnus-use-long-file-name' is non-nil, it is
3308 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3311 (if (gnus-use-long-file-name 'not-save)
3314 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3316 gnus-article-save-directory)))
3318 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3319 "Generate file name from sender."
3320 (let ((from (mail-header-from headers)))
3322 (if (and from (string-match "\\([^ <]+\\)@" from))
3323 (match-string 1 from)
3325 gnus-article-save-directory)))
3327 (defun article-verify-x-pgp-sig ()
3330 (if (gnus-buffer-live-p gnus-original-article-buffer)
3331 (let ((sig (with-current-buffer gnus-original-article-buffer
3332 (gnus-fetch-field "X-PGP-Sig")))
3336 (mml2015-clear-verify-function))
3338 (insert-buffer-substring gnus-original-article-buffer)
3339 (setq items (split-string sig))
3340 (message-narrow-to-head)
3341 (let ((inhibit-point-motion-hooks t)
3342 (case-fold-search t))
3343 ;; Don't verify multiple headers.
3344 (setq headers (mapconcat (lambda (header)
3346 (mail-fetch-field header) "\n"))
3347 (split-string (nth 1 items) ",") "")))
3348 (delete-region (point-min) (point-max))
3349 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3350 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3355 (if (looking-at "^-")
3358 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3359 (insert "Version: " (car items) "\n\n")
3360 (insert (mapconcat 'identity (cddr items) "\n"))
3361 (insert "\n-----END PGP SIGNATURE-----\n")
3362 (let ((mm-security-handle (list (format "multipart/signed"))))
3363 (mml2015-clean-buffer)
3364 (let ((coding-system-for-write (or gnus-newsgroup-charset
3366 (funcall (mml2015-clear-verify-function)))
3368 (or (mm-handle-multipart-ctl-parameter
3369 mm-security-handle 'gnus-details)
3370 (mm-handle-multipart-ctl-parameter
3371 mm-security-handle 'gnus-info)))))
3373 (let (buffer-read-only bface eface)
3375 (message-narrow-to-head)
3376 (goto-char (point-max))
3378 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3379 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3380 (message-remove-header "X-Gnus-PGP-Verify")
3381 (if (re-search-forward "^X-PGP-Sig:" nil t)
3383 (goto-char (point-max)))
3384 (narrow-to-region (point) (point))
3385 (insert "X-Gnus-PGP-Verify: " info "\n")
3386 (goto-char (point-min))
3389 (if (not (looking-at "^[ \t]"))
3393 (goto-char (point-min))
3394 (when (looking-at "\\([^:]+\\): *")
3395 (put-text-property (match-beginning 1) (1+ (match-end 1))
3397 (put-text-property (match-end 0) (point-max)
3398 'face eface)))))))))
3400 (defun article-verify-cancel-lock ()
3401 "Verify Cancel-Lock header."
3403 (if (gnus-buffer-live-p gnus-original-article-buffer)
3404 (canlock-verify gnus-original-article-buffer)))
3406 (defun article-monafy ()
3407 "Display body part with mona font."
3409 (unless (if (featurep 'xemacs)
3410 (find-face 'gnus-mona-face)
3411 (facep 'gnus-mona-face))
3412 (require 'navi2ch-mona)
3413 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3415 (let ((buffer-read-only nil))
3418 (gnus-make-overlay (point) (point-max))
3419 'face 'gnus-mona-face))))
3426 (setq afunc (car func)
3429 gfunc (intern (format "gnus-%s" func))))
3431 (when (fboundp afunc)
3432 `(lambda (&optional interactive &rest args)
3433 ,(documentation afunc t)
3434 (interactive (list t))
3436 (set-buffer gnus-article-buffer)
3438 (call-interactively ',afunc)
3439 (apply ',afunc args))))))))
3440 '(article-hide-headers
3441 article-verify-x-pgp-sig
3442 article-verify-cancel-lock
3444 article-hide-boring-headers
3445 article-treat-overstrike
3446 article-fill-long-lines
3447 article-capitalize-sentences
3449 article-remove-leading-whitespace
3450 article-display-x-face
3451 article-de-quoted-unreadable
3452 article-de-base64-unreadable
3455 article-unsplit-urls
3456 article-hide-list-identifiers
3458 article-strip-banner
3461 article-hide-signature
3462 article-strip-headers-in-body
3463 article-remove-trailing-blank-lines
3464 article-strip-leading-blank-lines
3465 article-strip-multiple-blank-lines
3466 article-strip-leading-space
3467 article-strip-trailing-space
3468 article-strip-blank-lines
3469 article-strip-all-blank-lines
3471 article-date-english
3472 article-date-iso8601
3473 article-date-original
3475 article-decode-mime-words
3476 article-decode-charset
3477 article-decode-encoded-words
3481 article-treat-dumbquotes
3482 article-normalize-headers
3483 (article-show-all-headers . gnus-article-show-all-headers)
3484 ;; (article-show-all . gnus-article-show-all)
3488 ;;; Gnus article mode
3491 (put 'gnus-article-mode 'mode-class 'special)
3493 (gnus-define-keys gnus-article-mode-map
3494 " " gnus-article-goto-next-page
3495 "\177" gnus-article-goto-prev-page
3496 [delete] gnus-article-goto-prev-page
3497 [backspace] gnus-article-goto-prev-page
3498 "\C-c^" gnus-article-refer-article
3499 "h" gnus-article-show-summary
3500 "s" gnus-article-show-summary
3501 "\C-c\C-m" gnus-article-mail
3502 "?" gnus-article-describe-briefly
3503 "e" gnus-summary-edit-article
3504 "<" beginning-of-buffer
3506 "\C-c\C-i" gnus-info-find-node
3508 "R" gnus-article-reply-with-original
3509 "F" gnus-article-followup-with-original
3510 "\C-hk" gnus-article-describe-key
3511 "\C-hc" gnus-article-describe-key-briefly
3513 "\C-d" gnus-article-read-summary-keys
3514 "\M-*" gnus-article-read-summary-keys
3515 "\M-#" gnus-article-read-summary-keys
3516 "\M-^" gnus-article-read-summary-keys
3517 "\M-g" gnus-article-read-summary-keys)
3519 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3523 (push (char-to-string key) keys)
3525 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3526 (setq key (car elem))
3527 (when (and (> (length key) 0)
3528 (not (eq 'menu-bar (aref key 0)))
3529 (symbolp (lookup-key gnus-summary-mode-map key)))
3532 (unless (lookup-key gnus-article-mode-map key)
3533 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3535 (defun gnus-article-make-menu-bar ()
3536 (unless (boundp 'gnus-article-commands-menu)
3537 (gnus-summary-make-menu-bar))
3538 (gnus-turn-off-edit-menu 'article)
3539 (unless (boundp 'gnus-article-article-menu)
3541 gnus-article-article-menu gnus-article-mode-map ""
3543 ["Scroll forwards" gnus-article-goto-next-page t]
3544 ["Scroll backwards" gnus-article-goto-prev-page t]
3545 ["Show summary" gnus-article-show-summary t]
3546 ["Fetch Message-ID at point" gnus-article-refer-article t]
3547 ["Mail to address at point" gnus-article-mail t]
3548 ["Send a bug report" gnus-bug t]))
3551 gnus-article-treatment-menu gnus-article-mode-map ""
3552 ;; Fixme: this should use :active (and maybe :visible).
3554 ["Hide headers" gnus-article-hide-headers t]
3555 ["Hide signature" gnus-article-hide-signature t]
3556 ["Hide citation" gnus-article-hide-citation t]
3557 ["Treat overstrike" gnus-article-treat-overstrike t]
3558 ["Remove carriage return" gnus-article-remove-cr t]
3559 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3560 ["Treat html" gnus-article-wash-html t]
3561 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3562 ["Decode HZ" gnus-article-decode-HZ t]))
3564 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3566 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3568 (gnus-run-hooks 'gnus-article-menu-hook)))
3570 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3573 (defun gnus-article-mode ()
3574 "Major mode for displaying an article.
3576 All normal editing commands are switched off.
3578 The following commands are available in addition to all summary mode
3580 \\<gnus-article-mode-map>
3581 \\[gnus-article-next-page]\t Scroll the article one page forwards
3582 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3583 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3584 \\[gnus-article-show-summary]\t Display the summary buffer
3585 \\[gnus-article-mail]\t Send a reply to the address near point
3586 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3587 \\[gnus-info-find-node]\t Go to the Gnus info node"
3589 (gnus-simplify-mode-line)
3590 (setq mode-name "Article")
3591 (setq major-mode 'gnus-article-mode)
3592 (make-local-variable 'minor-mode-alist)
3593 (unless (assq 'gnus-show-mime minor-mode-alist)
3594 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3595 (use-local-map gnus-article-mode-map)
3596 (when (gnus-visual-p 'article-menu 'menu)
3597 (gnus-article-make-menu-bar))
3598 (gnus-update-format-specifications nil 'article-mode)
3599 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3600 (make-local-variable 'gnus-page-broken)
3601 (make-local-variable 'gnus-button-marker-list)
3602 (make-local-variable 'gnus-article-current-summary)
3603 (make-local-variable 'gnus-article-mime-handles)
3604 (make-local-variable 'gnus-article-decoded-p)
3605 (make-local-variable 'gnus-article-mime-handle-alist)
3606 (make-local-variable 'gnus-article-wash-types)
3607 (make-local-variable 'gnus-article-image-alist)
3608 (make-local-variable 'gnus-article-charset)
3609 (make-local-variable 'gnus-article-ignored-charsets)
3610 (gnus-set-default-directory)
3611 (buffer-disable-undo)
3612 (setq buffer-read-only t)
3613 (set-syntax-table gnus-article-mode-syntax-table)
3614 (gnus-run-hooks 'gnus-article-mode-hook))
3616 (defun gnus-article-setup-buffer ()
3617 "Initialize the article buffer."
3618 (let* ((name (if gnus-single-article-buffer "*Article*"
3619 (concat "*Article " gnus-newsgroup-name "*")))
3621 (progn (string-match "\\*Article" name)
3622 (concat " *Original Article"
3623 (substring name (match-end 0))))))
3624 (setq gnus-article-buffer name)
3625 (setq gnus-original-article-buffer original)
3626 (setq gnus-article-mime-handle-alist nil)
3627 ;; This might be a variable local to the summary buffer.
3628 (unless gnus-single-article-buffer
3630 (set-buffer gnus-summary-buffer)
3631 (setq gnus-article-buffer name)
3632 (setq gnus-original-article-buffer original)
3633 (gnus-set-global-variables)))
3634 (gnus-article-setup-highlight-words)
3635 ;; Init original article buffer.
3637 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3638 (set-buffer-multibyte t)
3639 (setq major-mode 'gnus-original-article-mode)
3640 (make-local-variable 'gnus-original-article))
3641 (if (get-buffer name)
3644 (buffer-disable-undo)
3645 (setq buffer-read-only t)
3646 (unless (eq major-mode 'gnus-article-mode)
3647 (gnus-article-mode))
3650 (set-buffer (gnus-get-buffer-create name))
3652 (make-local-variable 'gnus-summary-buffer)
3653 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3654 (current-buffer)))))
3656 ;; Set article window start at LINE, where LINE is the number of lines
3657 ;; from the head of the article.
3658 (defun gnus-article-set-window-start (&optional line)
3660 (gnus-get-buffer-window gnus-article-buffer t)
3662 (set-buffer gnus-article-buffer)
3663 (goto-char (point-min))
3666 (gnus-message 6 "Moved to bookmark")
3667 (search-forward "\n\n" nil t)
3671 ;;; @@ article filters
3674 (defun gnus-article-display-mime-message ()
3675 "Article display method for MIME message."
3676 ;; called from `gnus-original-article-buffer'.
3677 (let (charset all-headers)
3678 (with-current-buffer gnus-summary-buffer
3679 (setq charset default-mime-charset
3680 all-headers gnus-have-all-headers))
3681 (make-local-variable 'default-mime-charset)
3682 (setq default-mime-charset charset)
3683 (with-current-buffer (get-buffer-create gnus-article-buffer)
3684 (make-local-variable 'default-mime-charset)
3685 (setq default-mime-charset charset))
3686 (mime-display-message mime-message-structure
3687 gnus-article-buffer nil gnus-article-mode-map)
3689 (gnus-article-hide-headers nil -1)))
3690 (run-hooks 'gnus-mime-article-prepare-hook))
3692 (defun gnus-article-display-traditional-message ()
3693 "Article display method for traditional message."
3694 (set-buffer gnus-article-buffer)
3695 (let (buffer-read-only)
3697 (insert-buffer-substring gnus-original-article-buffer)))
3699 (defun gnus-article-make-full-mail-header (&optional number charset)
3700 "Create a new mail header structure in a raw article buffer."
3701 (unless (and number charset)
3702 (save-current-buffer
3703 (set-buffer gnus-summary-buffer)
3705 (setq number (or (cdr gnus-article-current) 0)))
3707 (setq charset (or default-mime-charset 'x-ctext)))))
3708 (goto-char (point-min))
3709 (let ((header-end (if (search-forward "\n\n" nil t)
3711 (goto-char (point-max))))
3712 (chars (- (point-max) (point)))
3713 (lines (count-lines (point) (point-max)))
3714 (default-mime-charset charset)
3716 (narrow-to-region (point-min) header-end)
3717 (setq xref (std11-fetch-field "xref"))
3719 (make-full-mail-header
3721 (std11-fetch-field "subject")
3722 (std11-fetch-field "from")
3723 (std11-fetch-field "date")
3724 (std11-fetch-field "message-id")
3725 (std11-fetch-field "references")
3728 (when xref (concat "Xref: " xref)))
3731 (defun gnus-article-prepare (article &optional all-headers header)
3732 "Prepare ARTICLE in article mode buffer.
3733 ARTICLE should either be an article number or a Message-ID.
3734 If ARTICLE is an id, HEADER should be the article headers.
3735 If ALL-HEADERS is non-nil, no headers are hidden."
3737 ;; Make sure we start in a summary buffer.
3738 (unless (eq major-mode 'gnus-summary-mode)
3739 (set-buffer gnus-summary-buffer))
3740 (setq gnus-summary-buffer (current-buffer))
3741 (let* ((gnus-article (if header (mail-header-number header) article))
3742 (summary-buffer (current-buffer))
3743 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3744 (group gnus-newsgroup-name)
3747 (gnus-article-setup-buffer)
3748 (set-buffer gnus-article-buffer)
3749 ;; Deactivate active regions.
3750 (when (and (boundp 'transient-mark-mode)
3751 transient-mark-mode)
3752 (setq mark-active nil))
3753 (if (not (setq result (let ((buffer-read-only nil))
3754 (gnus-request-article-this-buffer
3756 ;; There is no such article.
3758 (when (and (numberp article)
3759 (not (memq article gnus-newsgroup-sparse)))
3760 (setq gnus-article-current
3761 (cons gnus-newsgroup-name article))
3762 (set-buffer gnus-summary-buffer)
3763 (setq gnus-current-article article)
3764 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3766 (gnus-summary-set-agent-mark article)
3767 (message "Message marked for downloading"))
3768 (gnus-summary-mark-article article gnus-canceled-mark)
3769 (unless (memq article gnus-newsgroup-sparse)
3770 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3771 (if (or (eq result 'pseudo)
3772 (eq result 'nneething))
3775 (set-buffer summary-buffer)
3776 (push article gnus-newsgroup-history)
3777 (setq gnus-last-article gnus-current-article
3778 gnus-current-article 0
3779 gnus-current-headers nil
3780 gnus-article-current nil)
3781 (if (eq result 'nneething)
3782 (gnus-configure-windows 'summary)
3783 (gnus-configure-windows 'article))
3784 (gnus-set-global-variables))
3785 (let ((gnus-article-mime-handle-alist-1
3786 gnus-article-mime-handle-alist))
3787 (gnus-set-mode-line 'article)))
3788 ;; The result from the `request' was an actual article -
3789 ;; or at least some text that is now displayed in the
3791 (when (and (numberp article)
3792 (not (eq article gnus-current-article)))
3793 ;; Seems like a new article has been selected.
3794 ;; `gnus-current-article' must be an article number.
3796 (set-buffer summary-buffer)
3797 (push article gnus-newsgroup-history)
3798 (setq gnus-last-article gnus-current-article
3799 gnus-current-article article
3800 gnus-current-headers
3801 (gnus-summary-article-header gnus-current-article)
3802 gnus-article-current
3803 (cons gnus-newsgroup-name gnus-current-article))
3804 (unless (vectorp gnus-current-headers)
3805 (setq gnus-current-headers nil))
3806 (gnus-summary-goto-subject gnus-current-article)
3807 (when (gnus-summary-show-thread)
3808 ;; If the summary buffer really was folded, the
3809 ;; previous goto may not actually have gone to
3810 ;; the right article, but the thread root instead.
3812 (gnus-summary-goto-subject gnus-current-article))
3813 (gnus-run-hooks 'gnus-mark-article-hook)
3814 (gnus-set-mode-line 'summary)
3815 (when (gnus-visual-p 'article-highlight 'highlight)
3816 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3817 ;; Set the global newsgroup variables here.
3818 (gnus-set-global-variables)
3819 (setq gnus-have-all-headers
3820 (or all-headers gnus-show-all-headers))))
3822 (gnus-configure-windows 'article))
3823 (when (or (numberp article)
3825 (gnus-article-prepare-display)
3827 (goto-char (point-min))
3828 (setq gnus-page-broken
3829 (when gnus-break-pages
3830 (gnus-narrow-to-page)
3832 (let ((gnus-article-mime-handle-alist-1
3833 gnus-article-mime-handle-alist))
3834 (gnus-set-mode-line 'article))
3838 (set-window-point (get-buffer-window (current-buffer)) (point))
3839 (gnus-configure-windows 'article)
3842 (defun gnus-article-prepare-mime-display (&optional number)
3843 (goto-char (point-min))
3844 (when (re-search-forward "^[^\t ]+:" nil t)
3845 (goto-char (match-beginning 0)))
3846 (let ((entity (if (eq 1 (point-min))
3847 (get-text-property 1 'mime-view-entity)
3848 (get-text-property (point) 'mime-view-entity)))
3849 last-entity child-entity next type)
3850 (setq child-entity (mime-entity-children entity))
3852 (setq last-entity (nth (1- (length child-entity))
3854 (setq last-entity entity))
3856 (narrow-to-region (point)
3857 (if (search-forward "\n\n" nil t)
3860 (gnus-treat-article 'head)
3861 (put-text-property (point-min) (point-max) 'article-treated-header t)
3862 (goto-char (point-max)))
3863 (while (and (not (eobp)) entity)
3864 (setq next (set-marker
3866 (next-single-property-change (point) 'mime-view-entity
3868 (let ((types (mime-entity-content-type entity)))
3869 (while (eq 'multipart (mime-content-type-primary-type types))
3870 (setq entity (car (mime-entity-children entity))
3871 types (mime-entity-content-type entity)))
3873 (setq type (format "%s/%s"
3874 (mime-content-type-primary-type types)
3875 (mime-content-type-subtype types)))))
3876 (if (string-equal type "message/rfc822")
3879 (let ((children (mime-entity-children entity))
3882 (setq last-children (nth (1- (length children)) children))
3885 (not (eq last-children
3886 (get-text-property next 'mime-view-entity)))
3888 (next-single-property-change next
3890 nil (point-max)))))))
3891 (setq next (next-single-property-change next 'mime-view-entity
3894 (narrow-to-region (point) next)
3895 (gnus-article-prepare-mime-display)
3896 (goto-char (point-max)))
3897 (setq entity (get-text-property (point) 'mime-view-entity)))
3899 (narrow-to-region (point) next)
3900 ;; Kludge. We have to count true number, but for now,
3901 ;; part number is here only to achieve `last'.
3902 (gnus-treat-article nil 1
3903 (if (eq entity last-entity)
3906 (goto-char (point-max)))
3907 (setq entity (get-text-property next 'mime-view-entity))))))
3910 (defun gnus-article-prepare-display ()
3911 "Make the current buffer look like a nice article."
3912 (let ((gnus-article-buffer (current-buffer))
3914 (unless (eq major-mode 'gnus-article-mode)
3915 (gnus-article-mode))
3916 (setq buffer-read-only nil
3917 gnus-button-marker-list nil
3918 gnus-article-wash-types nil
3919 gnus-article-image-alist nil)
3922 (static-if (featurep 'xemacs)
3923 (map-extents (lambda (extent maparg) (delete-extent extent)))
3924 (let ((lists (overlay-lists)))
3925 (dolist (overlay (nconc (car lists) (cdr lists)))
3926 (delete-overlay overlay)))))
3927 (gnus-run-hooks 'gnus-tmp-internal-hook))
3928 (set-buffer gnus-original-article-buffer)
3930 (setq mime-message-structure gnus-current-headers)
3931 (mime-buffer-entity-set-buffer-internal mime-message-structure
3932 gnus-original-article-buffer)
3933 (mime-entity-set-representation-type-internal mime-message-structure
3934 'mime-buffer-entity)
3935 (luna-send mime-message-structure 'initialize-instance
3936 mime-message-structure)
3938 (let (mime-display-header-hook mime-display-text/plain-hook)
3939 (funcall gnus-article-display-method-for-mime))
3940 (funcall gnus-article-display-method-for-traditional))
3941 ;; Call the treatment functions.
3942 (let ((inhibit-read-only t))
3946 (gnus-article-prepare-mime-display)
3947 (narrow-to-region (goto-char (point-min))
3948 (if (search-forward "\n\n" nil t)
3951 (gnus-treat-article 'head)
3952 (put-text-property (point-min) (point-max) 'article-treated-header t)
3953 (goto-char (point-max))
3955 (narrow-to-region (point) (point-max))
3956 (gnus-treat-article nil))
3957 (put-text-property (point-min) (point-max) 'read-only nil)))
3958 (gnus-run-hooks 'gnus-article-prepare-hook))
3960 (defun gnus-article-decode-article-as-default-mime-charset ()
3961 "Decode an article as `default-mime-charset'. It won't work if the
3962 value of the variable `gnus-show-mime' is non-nil."
3963 (unless gnus-show-mime
3964 (set (make-local-variable 'default-mime-charset)
3965 (with-current-buffer gnus-summary-buffer
3966 default-mime-charset))
3967 (decode-mime-charset-region (point-min) (point-max)
3968 default-mime-charset)))
3971 ;;; Gnus MIME viewing functions
3974 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3975 "Format of the MIME buttons.
3977 Valid specifiers include:
3979 %T MIME type, along with additional info
3980 %n The `name' parameter
3981 %d The description, if any
3982 %l The length of the encoded part
3983 %p The part identifier number
3984 %e Dots if the part isn't displayed
3986 General format specifiers can also be used. See
3987 (gnus)Formatting Variables.")
3989 (defvar gnus-mime-button-line-format-alist
3990 '((?t gnus-tmp-type ?s)
3991 (?T gnus-tmp-type-long ?s)
3992 (?n gnus-tmp-name ?s)
3993 (?d gnus-tmp-description ?s)
3995 (?l gnus-tmp-length ?d)
3996 (?e gnus-tmp-dots ?s)))
3998 (defvar gnus-mime-button-commands
3999 '((gnus-article-press-button "\r" "Toggle Display")
4000 (gnus-mime-view-part "v" "View Interactively...")
4001 (gnus-mime-view-part-as-type "t" "View As Type...")
4002 (gnus-mime-view-part-as-charset "C" "View As charset...")
4003 (gnus-mime-save-part "o" "Save...")
4004 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4005 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4006 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4007 (gnus-mime-view-part-internally "E" "View Internally")
4008 (gnus-mime-view-part-externally "e" "View Externally")
4009 (gnus-mime-print-part "p" "Print")
4010 (gnus-mime-pipe-part "|" "Pipe To Command...")
4011 (gnus-mime-action-on-part "." "Take action on the part")))
4013 (defun gnus-article-mime-part-status ()
4014 (with-current-buffer gnus-article-buffer
4015 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4018 (setq children (mime-entity-children entity))
4019 (setq children (length children)))
4022 (format " (%d parts)" children))
4025 (defvar gnus-mime-button-map
4026 (let ((map (make-sparse-keymap)))
4027 (unless (>= (string-to-number emacs-version) 21)
4028 ;; XEmacs doesn't care.
4029 (set-keymap-parent map gnus-article-mode-map))
4030 (define-key map gnus-mouse-2 'gnus-article-push-button)
4031 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4032 (dolist (c gnus-mime-button-commands)
4033 (define-key map (cadr c) (car c)))
4036 (defun gnus-mime-button-menu (event)
4037 "Construct a context-sensitive menu of MIME commands."
4039 (save-window-excursion
4040 (let ((pos (event-start event)))
4041 (select-window (posn-window pos))
4042 (goto-char (posn-point pos))
4043 (gnus-article-check-buffer)
4044 (let ((response (x-popup-menu
4046 ("" ,@(mapcar (lambda (c)
4047 (cons (caddr c) (car c)))
4048 gnus-mime-button-commands))))))
4050 (call-interactively response))))))
4052 (defun gnus-mime-view-all-parts (&optional handles)
4053 "View all the MIME parts."
4055 (save-current-buffer
4056 (set-buffer gnus-article-buffer)
4057 (let ((handles (or handles gnus-article-mime-handles))
4058 (mail-parse-charset gnus-newsgroup-charset)
4059 (mail-parse-ignored-charsets
4060 (with-current-buffer gnus-summary-buffer
4061 gnus-newsgroup-ignored-charsets)))
4063 (mm-remove-parts handles)
4064 (goto-char (point-min))
4065 (or (search-forward "\n\n") (goto-char (point-max)))
4066 (let (buffer-read-only)
4067 (delete-region (point) (point-max))
4068 (mm-display-parts handles))))))
4070 (defun gnus-mime-save-part-and-strip ()
4071 "Save the MIME part under point then replace it with an external body."
4073 (gnus-article-check-buffer)
4074 (let* ((data (get-text-property (point) 'gnus-data))
4076 (handles gnus-article-mime-handles))
4077 (if (mm-multiple-handles gnus-article-mime-handles)
4078 (error "This function is not implemented"))
4079 (setq file (and data (mm-save-part data)))
4081 (with-current-buffer (mm-handle-buffer data)
4083 (insert "Content-Type: " (mm-handle-media-type data))
4084 (mml-insert-parameter-string (cdr (mm-handle-type data))
4087 (insert "Content-ID: " (message-make-message-id) "\n")
4088 (insert "Content-Transfer-Encoding: binary\n")
4091 (cdr (mm-make-handle nil
4092 `("message/external-body"
4093 (access-type . "LOCAL-FILE")
4095 (set-buffer gnus-summary-buffer)
4096 (gnus-article-edit-article
4099 (let ((mail-parse-charset (or gnus-article-charset
4100 ',gnus-newsgroup-charset))
4101 (mail-parse-ignored-charsets
4102 (or gnus-article-ignored-charsets
4103 ',gnus-newsgroup-ignored-charsets))
4104 (mbl mml-buffer-list))
4105 (setq mml-buffer-list nil)
4106 (insert-buffer gnus-original-article-buffer)
4107 (mime-to-mml ',handles)
4108 (setq gnus-article-mime-handles nil)
4109 (let ((mbl1 mml-buffer-list))
4110 (setq mml-buffer-list mbl)
4111 (set (make-local-variable 'mml-buffer-list) mbl1))
4112 ;; LOCAL argument of add-hook differs between GNU Emacs
4113 ;; and XEmacs. make-local-hook makes sure they are local.
4114 (make-local-hook 'kill-buffer-hook)
4115 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4116 `(lambda (no-highlight)
4117 (let ((mail-parse-charset (or gnus-article-charset
4118 ',gnus-newsgroup-charset))
4119 (message-options message-options)
4120 (message-options-set-recipient)
4121 (mail-parse-ignored-charsets
4122 (or gnus-article-ignored-charsets
4123 ',gnus-newsgroup-ignored-charsets)))
4125 (mml-destroy-buffers)
4126 (remove-hook 'kill-buffer-hook
4127 'mml-destroy-buffers t)
4128 (kill-local-variable 'mml-buffer-list))
4129 (gnus-summary-edit-article-done
4130 ,(or (mail-header-references gnus-current-headers) "")
4131 ,(gnus-group-read-only-p)
4132 ,gnus-summary-buffer no-highlight))))))
4134 (defun gnus-mime-save-part ()
4135 "Save the MIME part under point."
4137 (gnus-article-check-buffer)
4138 (let ((data (get-text-property (point) 'gnus-data)))
4140 (mm-save-part data))))
4142 (defun gnus-mime-pipe-part ()
4143 "Pipe the MIME part under point to a process."
4145 (gnus-article-check-buffer)
4146 (let ((data (get-text-property (point) 'gnus-data)))
4148 (mm-pipe-part data))))
4150 (defun gnus-mime-view-part ()
4151 "Interactively choose a viewing method for the MIME part under point."
4153 (gnus-article-check-buffer)
4154 (let ((data (get-text-property (point) 'gnus-data)))
4156 (setq gnus-article-mime-handles
4158 gnus-article-mime-handles (setq data (copy-sequence data))))
4159 (mm-interactively-view-part data))))
4161 (defun gnus-mime-view-part-as-type-internal ()
4162 (gnus-article-check-buffer)
4163 (let* ((name (mail-content-type-get
4164 (mm-handle-type (get-text-property (point) 'gnus-data))
4166 (def-type (and name (mm-default-file-encoding name))))
4167 (and def-type (cons def-type 0))))
4169 (defun gnus-mime-view-part-as-type (&optional mime-type)
4170 "Choose a MIME media type, and view the part as such."
4173 (setq mime-type (completing-read
4174 "View as MIME type: "
4175 (mapcar #'list (mailcap-mime-types))
4177 (gnus-mime-view-part-as-type-internal))))
4178 (gnus-article-check-buffer)
4179 (let ((handle (get-text-property (point) 'gnus-data)))
4182 (mm-make-handle (mm-handle-buffer handle)
4183 (cons mime-type (cdr (mm-handle-type handle)))
4184 (mm-handle-encoding handle)
4185 (mm-handle-undisplayer handle)
4186 (mm-handle-disposition handle)
4187 (mm-handle-description handle)
4189 (mm-handle-id handle)))
4190 (setq gnus-article-mime-handles
4191 (mm-merge-handles gnus-article-mime-handles handle))
4192 (gnus-mm-display-part handle))))
4194 (defun gnus-mime-copy-part (&optional handle)
4195 "Put the MIME part under point into a new buffer."
4197 (gnus-article-check-buffer)
4198 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4199 (contents (and handle (mm-get-part handle)))
4201 (file-name-nondirectory
4203 (mail-content-type-get (mm-handle-type handle) 'name)
4204 (mail-content-type-get (mm-handle-type handle)
4207 (buffer (and base (generate-new-buffer base))))
4209 (switch-to-buffer buffer)
4211 ;; We do it this way to make `normal-mode' set the appropriate mode.
4214 (setq buffer-file-name (expand-file-name base))
4216 (setq buffer-file-name nil))
4217 (goto-char (point-min)))))
4219 (defun gnus-mime-print-part (&optional handle filename)
4220 "Print the MIME part under point."
4221 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4222 (gnus-article-check-buffer)
4223 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4224 (contents (and handle (mm-get-part handle)))
4225 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4226 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4231 (with-temp-file file
4233 (call-process shell-file-name nil
4234 (generate-new-buffer " *mm*")
4236 shell-command-switch
4238 printer file (mm-handle-type handle))))
4242 (gnus-print-buffer))
4243 (ps-despool filename)))))
4245 (defun gnus-mime-inline-part (&optional handle arg)
4246 "Insert the MIME part under point into the current buffer."
4247 (interactive (list nil current-prefix-arg))
4248 (gnus-article-check-buffer)
4249 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4254 (if (and (not arg) (mm-handle-undisplayer handle))
4255 (mm-remove-part handle)
4256 (setq contents (mm-get-part handle))
4259 (setq charset (or (mail-content-type-get
4260 (mm-handle-type handle) 'charset)
4261 gnus-newsgroup-charset)))
4263 (if (mm-handle-undisplayer handle)
4264 (mm-remove-part handle))
4267 gnus-summary-show-article-charset-alist))
4268 (mm-read-coding-system "Charset: ")))))
4270 (mm-insert-inline handle
4272 (setq charset (mm-charset-to-coding-system
4274 (not (eq charset 'ascii)))
4275 (mm-decode-coding-string contents charset)
4279 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4280 "Insert the MIME part under point into the current buffer using the
4282 (interactive (list nil current-prefix-arg))
4283 (gnus-article-check-buffer)
4284 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4289 (if (mm-handle-undisplayer handle)
4290 (mm-remove-part handle))
4291 (let ((gnus-newsgroup-charset
4293 gnus-summary-show-article-charset-alist))
4294 (mm-read-coding-system "Charset: ")))
4295 (gnus-newsgroup-ignored-charsets 'gnus-all))
4296 (gnus-article-press-button)))))
4298 (defun gnus-mime-view-part-externally (&optional handle)
4299 "View the MIME part under point with an external viewer."
4301 (gnus-article-check-buffer)
4302 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4303 (mm-user-display-methods nil)
4304 (mm-inlined-types nil)
4305 (mail-parse-charset gnus-newsgroup-charset)
4306 (mail-parse-ignored-charsets
4307 (save-excursion (set-buffer gnus-summary-buffer)
4308 gnus-newsgroup-ignored-charsets)))
4310 (if (mm-handle-undisplayer handle)
4311 (mm-remove-part handle)
4312 (mm-display-part handle)))))
4314 (defun gnus-mime-view-part-internally (&optional handle)
4315 "View the MIME part under point with an internal viewer.
4316 If no internal viewer is available, use an external viewer."
4318 (gnus-article-check-buffer)
4319 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4320 (mm-inlined-types '(".*"))
4321 (mm-inline-large-images t)
4322 (mail-parse-charset gnus-newsgroup-charset)
4323 (mail-parse-ignored-charsets
4324 (save-excursion (set-buffer gnus-summary-buffer)
4325 gnus-newsgroup-ignored-charsets)))
4327 (if (mm-handle-undisplayer handle)
4328 (mm-remove-part handle)
4329 (mm-display-part handle)))))
4331 (defun gnus-mime-action-on-part (&optional action)
4332 "Do something with the MIME attachment at \(point\)."
4334 (list (completing-read "Action: " gnus-mime-action-alist)))
4335 (gnus-article-check-buffer)
4336 (let ((action-pair (assoc action gnus-mime-action-alist)))
4338 (funcall (cdr action-pair)))))
4340 (defun gnus-article-part-wrapper (n function)
4341 (save-current-buffer
4342 (set-buffer gnus-article-buffer)
4343 (when (> n (length gnus-article-mime-handle-alist))
4344 (error "No such part"))
4345 (gnus-article-goto-part n)
4346 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4347 (funcall function handle))))
4349 (defun gnus-article-pipe-part (n)
4350 "Pipe MIME part N, which is the numerical prefix."
4352 (gnus-article-part-wrapper n 'mm-pipe-part))
4354 (defun gnus-article-save-part (n)
4355 "Save MIME part N, which is the numerical prefix."
4357 (gnus-article-part-wrapper n 'mm-save-part))
4359 (defun gnus-article-interactively-view-part (n)
4360 "View MIME part N interactively, which is the numerical prefix."
4362 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4364 (defun gnus-article-copy-part (n)
4365 "Copy MIME part N, which is the numerical prefix."
4367 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4369 (defun gnus-article-view-part-as-charset (n)
4370 "Copy MIME part N, which is the numerical prefix."
4372 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4374 (defun gnus-article-view-part-externally (n)
4375 "View MIME part N externally, which is the numerical prefix."
4377 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4379 (defun gnus-article-inline-part (n)
4380 "Inline MIME part N, which is the numerical prefix."
4382 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4384 (defun gnus-article-mime-match-handle-first (condition)
4386 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4387 (while (setq ihandle (pop alist))
4389 ((functionp condition)
4390 (funcall condition (cdr ihandle)))
4391 ((eq condition 'undisplayed)
4392 (not (or (mm-handle-undisplayer (cdr ihandle))
4393 (equal (mm-handle-media-type (cdr ihandle))
4394 "multipart/alternative"))))
4395 ((eq condition 'undisplayed-alternative)
4396 (not (mm-handle-undisplayer (cdr ihandle))))
4398 (gnus-article-goto-part (car ihandle))
4399 (or (not n) (< (car ihandle) n)))
4400 (setq n (car ihandle))))
4404 (defun gnus-article-view-part (&optional n)
4405 "View MIME part N, which is the numerical prefix."
4407 (save-current-buffer
4408 (set-buffer gnus-article-buffer)
4409 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4410 gnus-article-mime-match-handle-function)))
4411 (when (> n (length gnus-article-mime-handle-alist))
4412 (error "No such part"))
4413 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4414 (when (gnus-article-goto-part n)
4415 (if (equal (car handle) "multipart/alternative")
4416 (gnus-article-press-button)
4417 (when (eq (gnus-mm-display-part handle) 'internal)
4418 (gnus-set-window-start)))))))
4420 (defsubst gnus-article-mime-total-parts ()
4421 (if (bufferp (car gnus-article-mime-handles))
4423 (1- (length gnus-article-mime-handles))))
4425 (defun gnus-mm-display-part (handle)
4426 "Display HANDLE and fix MIME button."
4427 (let ((id (get-text-property (point) 'gnus-part))
4432 (let ((window (selected-window))
4433 (mail-parse-charset gnus-newsgroup-charset)
4434 (mail-parse-ignored-charsets
4435 (if (gnus-buffer-live-p gnus-summary-buffer)
4437 (set-buffer gnus-summary-buffer)
4438 gnus-newsgroup-ignored-charsets)
4442 (let ((win (gnus-get-buffer-window (current-buffer) t))
4445 (select-window win))
4448 (if (mm-handle-displayed-p handle)
4449 ;; This will remove the part.
4450 (mm-display-part handle)
4452 (narrow-to-region (point)
4453 (if (eobp) (point) (1+ (point))))
4454 (mm-display-part handle)
4455 ;; We narrow to the part itself and
4456 ;; then call the treatment functions.
4457 (goto-char (point-min))
4459 (narrow-to-region (point) (point-max))
4462 (gnus-article-mime-total-parts)
4463 (mm-handle-media-type handle)))))
4464 (if (window-live-p window)
4465 (select-window window)))))
4467 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4468 (gnus-insert-mime-button
4469 handle id (list (mm-handle-displayed-p handle)))
4470 (goto-char point))))
4472 (defun gnus-article-goto-part (n)
4473 "Go to MIME part N."
4474 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4476 (goto-char point))))
4478 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4479 (let ((gnus-tmp-name
4480 (or (mail-content-type-get (mm-handle-type handle) 'name)
4481 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4482 (mail-content-type-get (mm-handle-type handle) 'url)
4484 (gnus-tmp-type (mm-handle-media-type handle))
4485 (gnus-tmp-description
4486 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4489 (if (if displayed (car displayed)
4490 (mm-handle-displayed-p handle))
4492 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4494 gnus-tmp-type-long b e)
4495 (when (string-match ".*/" gnus-tmp-name)
4496 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4497 (setq gnus-tmp-type-long (concat gnus-tmp-type
4498 (and (not (equal gnus-tmp-name ""))
4499 (concat "; " gnus-tmp-name))))
4500 (unless (equal gnus-tmp-description "")
4501 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4506 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4507 `(,@(gnus-local-map-property gnus-mime-button-map)
4508 gnus-callback gnus-mm-display-part
4509 gnus-part ,gnus-tmp-id
4510 article-type annotation
4513 (widget-convert-button
4516 :action 'gnus-widget-press-button
4517 :button-keymap gnus-mime-button-map
4519 (lambda (widget/window &optional overlay pos)
4520 ;; Needed to properly clear the message due to a bug in
4521 ;; wid-edit (XEmacs only).
4522 (if (boundp 'help-echo-owns-message)
4523 (setq help-echo-owns-message t))
4525 "%S: %s the MIME part; %S: more options"
4526 (aref gnus-mouse-2 0)
4527 ;; XEmacs will get a single widget arg; Emacs 21 will get
4528 ;; window, overlay, position.
4529 (if (mm-handle-displayed-p
4531 (with-current-buffer (gnus-overlay-buffer overlay)
4532 (widget-get (widget-at (gnus-overlay-start overlay))
4534 (widget-get widget/window :mime-handle)))
4536 (aref gnus-down-mouse-3 0))))))
4538 (defun gnus-widget-press-button (elems el)
4539 (goto-char (widget-get elems :from))
4540 (gnus-article-press-button))
4542 (defvar gnus-displaying-mime nil)
4544 (defun gnus-display-mime (&optional ihandles)
4545 "Display the MIME parts."
4547 (save-selected-window
4548 (let ((window (get-buffer-window gnus-article-buffer))
4551 (select-window window)
4552 ;; We have to do this since selecting the window
4553 ;; may change the point. So we set the window point.
4554 (set-window-point window point)))
4555 (let* ((handles (or ihandles (mm-dissect-buffer
4556 nil gnus-article-loose-mime)
4558 buffer-read-only handle name type b e display)
4559 (when (and (not ihandles)
4560 (not gnus-displaying-mime))
4561 ;; Top-level call; we clean up.
4562 (when gnus-article-mime-handles
4563 (mm-destroy-parts gnus-article-mime-handles)
4564 (setq gnus-article-mime-handle-alist nil));; A trick.
4565 (setq gnus-article-mime-handles handles)
4566 ;; We allow users to glean info from the handles.
4567 (when gnus-article-mime-part-function
4568 (gnus-mime-part-function handles)))
4570 (or (not (stringp (car handles)))
4573 (when (and (not ihandles)
4574 (not gnus-displaying-mime))
4575 ;; Clean up for mime parts.
4577 (delete-region (point) (point-max)))
4578 (let ((gnus-displaying-mime t))
4579 (gnus-mime-display-part handles)))
4582 (narrow-to-region (point) (point-max))
4583 (gnus-treat-article nil 1 1)
4586 ;; Highlight the headers.
4590 (narrow-to-region (point-min) (point))
4591 (gnus-treat-article 'head))))))))
4593 (defvar gnus-mime-display-multipart-as-mixed nil)
4594 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4595 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4597 (defun gnus-mime-display-part (handle)
4600 ((not (stringp (car handle)))
4601 (gnus-mime-display-single handle))
4602 ;; User-defined multipart
4603 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4604 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4606 ;; multipart/alternative
4607 ((and (equal (car handle) "multipart/alternative")
4608 (not (or gnus-mime-display-multipart-as-mixed
4609 gnus-mime-display-multipart-alternative-as-mixed)))
4610 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4611 (push (cons id handle) gnus-article-mime-handle-alist)
4612 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4613 ;; multipart/related
4614 ((and (equal (car handle) "multipart/related")
4615 (not (or gnus-mime-display-multipart-as-mixed
4616 gnus-mime-display-multipart-related-as-mixed)))
4617 ;;;!!!We should find the start part, but we just default
4618 ;;;!!!to the first part.
4619 ;;(gnus-mime-display-part (cadr handle))
4620 ;;;!!! Most multipart/related is an HTML message plus images.
4621 ;;;!!! Unfortunately we are unable to let W3 display those
4622 ;;;!!! included images, so we just display it as a mixed multipart.
4623 ;;(gnus-mime-display-mixed (cdr handle))
4624 ;;;!!! No, w3 can display everything just fine.
4625 (gnus-mime-display-part (cadr handle)))
4626 ((equal (car handle) "multipart/signed")
4627 (gnus-add-wash-type 'signed)
4628 (gnus-mime-display-security handle))
4629 ((equal (car handle) "multipart/encrypted")
4630 (gnus-add-wash-type 'encrypted)
4631 (gnus-mime-display-security handle))
4632 ;; Other multiparts are handled like multipart/mixed.
4634 (gnus-mime-display-mixed (cdr handle)))))
4636 (defun gnus-mime-part-function (handles)
4637 (if (stringp (car handles))
4638 (mapcar 'gnus-mime-part-function (cdr handles))
4639 (funcall gnus-article-mime-part-function handles)))
4641 (defun gnus-mime-display-mixed (handles)
4642 (mapcar 'gnus-mime-display-part handles))
4644 (defun gnus-mime-display-single (handle)
4645 (let ((type (mm-handle-media-type handle))
4646 (ignored gnus-ignored-mime-types)
4653 (when (string-match (pop ignored) type)
4654 (throw 'ignored nil)))
4655 (if (and (setq not-attachment
4656 (and (not (mm-inline-override-p handle))
4657 (or (not (mm-handle-disposition handle))
4658 (equal (car (mm-handle-disposition handle))
4660 (mm-attachment-override-p handle))))
4661 (mm-automatic-display-p handle)
4663 (mm-inlinable-p handle)
4664 (mm-inlined-p handle))
4665 (mm-automatic-external-display-p type)))
4667 (when (equal (mm-handle-media-supertype handle) "text")
4669 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4671 (push (cons id handle) gnus-article-mime-handle-alist)
4672 (when (or (not display)
4673 (not (gnus-unbuttonized-mime-type-p type)))
4674 ;(gnus-article-insert-newline)
4675 (gnus-insert-mime-button
4676 handle id (list (or display (and not-attachment text))))
4677 (gnus-article-insert-newline)
4678 ;(gnus-article-insert-newline)
4679 ;; Remember modify the number of forward lines.
4687 (let ((mail-parse-charset gnus-newsgroup-charset)
4688 (mail-parse-ignored-charsets
4689 (save-excursion (condition-case ()
4690 (set-buffer gnus-summary-buffer)
4692 gnus-newsgroup-ignored-charsets)))
4693 (mm-display-part handle t))
4694 (goto-char (point-max)))
4695 ((and text not-attachment)
4699 (gnus-article-insert-newline)
4700 (mm-insert-inline handle (mm-get-part handle))
4701 (goto-char (point-max))))
4705 (narrow-to-region beg (point))
4708 (gnus-article-mime-total-parts)
4709 (mm-handle-media-type handle)))))))))
4711 (defun gnus-unbuttonized-mime-type-p (type)
4712 "Say whether TYPE is to be unbuttonized."
4713 (unless gnus-inhibit-mime-unbuttonizing
4715 (let ((types gnus-unbuttonized-mime-types))
4717 (when (string-match (pop types) type)
4718 (throw 'found t)))))
4720 (let ((types gnus-buttonized-mime-types))
4722 (when (string-match (pop types) type)
4723 (throw 'found t)))))))))
4725 (defun gnus-article-insert-newline ()
4726 "Insert a newline, but mark it as undeletable."
4727 (gnus-put-text-property
4728 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4730 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4731 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4734 handle buffer-read-only from props begend not-pref)
4735 (save-window-excursion
4738 (narrow-to-region (car ibegend)
4741 (goto-char (car ibegend))
4744 (delete-region (point-min) (point-max))
4745 (mm-remove-parts handles))
4746 (setq begend (list (point-marker)))
4748 (unless (setq not-pref (cadr (member preferred ihandles)))
4749 (setq not-pref (car ihandles)))
4752 (not (gnus-unbuttonized-mime-type-p
4753 "multipart/alternative")))
4754 (gnus-add-text-properties
4757 (insert (format "%d. " id))
4761 (unless ,(not ibegend)
4762 (setq gnus-article-mime-handle-alist
4763 ',gnus-article-mime-handle-alist))
4764 (gnus-mime-display-alternative
4765 ',ihandles ',not-pref ',begend ,id))
4766 ,@(gnus-local-map-property gnus-mime-button-map)
4767 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4768 face ,gnus-article-button-face
4771 (widget-convert-button 'link from (point)
4772 :action 'gnus-widget-press-button
4773 :button-keymap gnus-widget-button-keymap)
4775 (while (setq handle (pop handles))
4776 (gnus-add-text-properties
4779 (insert (format "(%c) %-18s"
4780 (if (equal handle preferred) ?* ? )
4781 (mm-handle-media-type handle)))
4785 (unless ,(not ibegend)
4786 (setq gnus-article-mime-handle-alist
4787 ',gnus-article-mime-handle-alist))
4788 (gnus-mime-display-alternative
4789 ',ihandles ',handle ',begend ,id))
4790 ,@(gnus-local-map-property gnus-mime-button-map)
4791 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4792 face ,gnus-article-button-face
4795 (widget-convert-button 'link from (point)
4796 :action 'gnus-widget-press-button
4797 :button-keymap gnus-widget-button-keymap)
4801 (if (stringp (car preferred))
4802 (gnus-display-mime preferred)
4803 (let ((mail-parse-charset gnus-newsgroup-charset)
4804 (mail-parse-ignored-charsets
4805 (save-excursion (set-buffer gnus-summary-buffer)
4806 gnus-newsgroup-ignored-charsets)))
4807 (mm-display-part preferred)
4811 (narrow-to-region (car begend) (point-max))
4813 nil (length gnus-article-mime-handle-alist)
4814 (gnus-article-mime-total-parts)
4815 (mm-handle-media-type handle))))))
4816 (goto-char (point-max))
4817 (setcdr begend (point-marker)))))
4819 (goto-char point))))
4821 (defconst gnus-article-wash-status-strings
4822 (let ((alist '((cite "c" "Possible hidden citation text"
4823 " " "All citation text visible")
4824 (headers "h" "Hidden headers"
4825 " " "All headers visible.")
4826 (pgp "p" "Encrypted or signed message status hidden"
4827 " " "No hidden encryption nor digital signature status")
4828 (signature "s" "Signature has been hidden"
4829 " " "Signature is visible")
4830 (overstrike "o" "Overstrike (^H) characters applied"
4831 " " "No overstrike characters applied")
4832 (gnus-show-mime "m" "Mime processing is activated"
4833 " " "Mime processing is not activated")
4834 (emphasis "e" "/*_Emphasis_*/ characters applied"
4835 " " "No /*_emphasis_*/ characters applied")))
4837 (dolist (entry alist result)
4838 (let ((key (nth 0 entry))
4839 (on (copy-sequence (nth 1 entry)))
4840 (on-help (nth 2 entry))
4841 (off (copy-sequence (nth 3 entry)))
4842 (off-help (nth 4 entry)))
4843 (put-text-property 0 1 'help-echo on-help on)
4844 (put-text-property 0 1 'help-echo off-help off)
4845 (push (list key on off) result))))
4846 "Alist of strings describing wash status in the mode line.
4847 Each entry has the form (KEY ON OF), where the KEY is a symbol
4848 representing the particular washing function, ON is the string to use
4849 in the article mode line when the washing function is active, and OFF
4850 is the string to use when it is inactive.")
4852 (defun gnus-article-wash-status-entry (key value)
4853 (let ((entry (assoc key gnus-article-wash-status-strings)))
4854 (if value (nth 1 entry) (nth 2 entry))))
4856 (defun gnus-article-wash-status ()
4857 "Return a string which display status of article washing."
4859 (set-buffer gnus-article-buffer)
4860 (let ((cite (memq 'cite gnus-article-wash-types))
4861 (headers (memq 'headers gnus-article-wash-types))
4862 (boring (memq 'boring-headers gnus-article-wash-types))
4863 (pgp (memq 'pgp gnus-article-wash-types))
4864 (pem (memq 'pem gnus-article-wash-types))
4865 (signed (memq 'signed gnus-article-wash-types))
4866 (encrypted (memq 'encrypted gnus-article-wash-types))
4867 (signature (memq 'signature gnus-article-wash-types))
4868 (overstrike (memq 'overstrike gnus-article-wash-types))
4869 (emphasis (memq 'emphasis gnus-article-wash-types)))
4871 (gnus-article-wash-status-entry 'cite cite)
4872 (gnus-article-wash-status-entry 'headers (or headers boring))
4873 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4874 (gnus-article-wash-status-entry 'signature signature)
4875 (gnus-article-wash-status-entry 'overstrike overstrike)
4876 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4877 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4879 (defun gnus-add-wash-type (type)
4880 "Add a washing of TYPE to the current status."
4881 (add-to-list 'gnus-article-wash-types type))
4883 (defun gnus-delete-wash-type (type)
4884 "Add a washing of TYPE to the current status."
4885 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4887 (defun gnus-add-image (category image)
4888 "Add IMAGE of CATEGORY to the list of displayed images."
4889 (let ((entry (assq category gnus-article-image-alist)))
4891 (setq entry (list category))
4892 (push entry gnus-article-image-alist))
4893 (nconc entry (list image))))
4895 (defun gnus-delete-images (category)
4896 "Delete all images in CATEGORY."
4897 (let ((entry (assq category gnus-article-image-alist)))
4898 (dolist (image (cdr entry))
4899 (gnus-remove-image image))
4900 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4901 (gnus-delete-wash-type category)))
4903 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4905 (defun gnus-article-maybe-hide-headers ()
4906 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4907 Provided for backwards compatibility."
4908 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4909 (not (save-excursion (set-buffer gnus-summary-buffer)
4910 gnus-have-all-headers)))
4911 (not gnus-inhibit-hiding))
4912 (gnus-article-hide-headers)))
4916 (defun gnus-output-to-file (file-name)
4917 "Append the current article to a file named FILE-NAME."
4918 (let ((artbuf (current-buffer)))
4920 (insert-buffer-substring artbuf)
4921 ;; Append newline at end of the buffer as separator, and then
4923 (goto-char (point-max))
4925 (let ((file-name-coding-system nnmail-pathname-coding-system)
4926 (pathname-coding-system nnmail-pathname-coding-system))
4927 (write-region-as-binary (point-min) (point-max) file-name 'append))
4930 (defun gnus-narrow-to-page (&optional arg)
4931 "Narrow the article buffer to a page.
4932 If given a numerical ARG, move forward ARG pages."
4934 (setq arg (if arg (prefix-numeric-value arg) 0))
4936 (set-buffer gnus-article-buffer)
4937 (goto-char (point-min))
4939 ;; Remove any old next/prev buttons.
4940 (when (gnus-visual-p 'page-marker)
4941 (let ((buffer-read-only nil))
4942 (gnus-remove-text-with-property 'gnus-prev)
4943 (gnus-remove-text-with-property 'gnus-next)))
4946 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4948 (re-search-forward page-delimiter nil 'move arg)))
4949 (goto-char (match-end 0)))
4952 (if (re-search-forward page-delimiter nil 'move)
4955 (when (and (gnus-visual-p 'page-marker)
4956 (not (= (point-min) 1)))
4958 (goto-char (point-min))
4959 (gnus-insert-prev-page-button)))
4960 (when (and (gnus-visual-p 'page-marker)
4961 (< (+ (point-max) 2) (buffer-size)))
4963 (goto-char (point-max))
4964 (gnus-insert-next-page-button)))))
4966 ;; Article mode commands
4968 (defun gnus-article-goto-next-page ()
4969 "Show the next page of the article."
4971 (when (gnus-article-next-page)
4972 (goto-char (point-min))
4973 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4975 (defun gnus-article-goto-prev-page ()
4976 "Show the next page of the article."
4978 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4979 (gnus-article-prev-page nil)))
4981 (defun gnus-article-next-page (&optional lines)
4982 "Show the next page of the current article.
4983 If end of article, return non-nil. Otherwise return nil.
4984 Argument LINES specifies lines to be scrolled up."
4986 (let ((start (window-start))
4987 end-of-buffer end-of-page)
4989 (move-to-window-line -1)
4990 (if (<= (point) start)
4993 (setq start (point)))
4996 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4997 (and (pos-visible-in-window-p)
4998 (setq end-of-buffer t)))
5000 (setq end-of-page t)))
5002 (move-to-window-line lines)
5003 (unless (search-backward "\n\n" nil t)
5004 (setq start (point)))))
5005 (cond (end-of-buffer t)
5007 (gnus-narrow-to-page 1)
5011 (set-window-start (selected-window) start)
5012 (let (window-pixel-scroll-increment)
5016 (defun gnus-article-prev-page (&optional lines)
5017 "Show previous page of current article.
5018 Argument LINES specifies lines to be scrolled down."
5020 (let (beginning-of-buffer beginning-of-page)
5022 (move-to-window-line 0)
5023 (cond ((eq 1 (point))
5024 (setq beginning-of-buffer t))
5026 (setq beginning-of-page t))))
5027 (cond (beginning-of-buffer)
5029 (gnus-narrow-to-page -1))
5032 (let (window-pixel-scroll-increment)
5033 (scroll-down lines))
5034 (beginning-of-buffer
5035 (goto-char (point-min))))))))
5037 (defun gnus-article-refer-article ()
5038 "Read article specified by message-id around point."
5040 (let ((point (point)))
5041 (search-forward ">" nil t) ;Move point to end of "<....>".
5042 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5043 (let ((message-id (match-string 1)))
5045 (set-buffer gnus-summary-buffer)
5046 (gnus-summary-refer-article message-id))
5048 (error "No references around point"))))
5050 (defun gnus-article-show-summary ()
5051 "Reconfigure windows to show summary buffer."
5053 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5054 (error "There is no summary buffer for this article buffer")
5055 (gnus-article-set-globals)
5056 (gnus-configure-windows 'article)
5057 (gnus-summary-goto-subject gnus-current-article)
5058 (gnus-summary-position-point)))
5060 (defun gnus-article-describe-briefly ()
5061 "Describe article mode commands briefly."
5063 (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")))
5065 (defun gnus-article-summary-command ()
5066 "Execute the last keystroke in the summary buffer."
5068 (let ((obuf (current-buffer))
5069 (owin (current-window-configuration))
5071 (switch-to-buffer gnus-article-current-summary 'norecord)
5072 (setq func (lookup-key (current-local-map) (this-command-keys)))
5073 (call-interactively func)
5075 (set-window-configuration owin)
5076 (set-window-point (get-buffer-window (current-buffer)) (point))))
5078 (defun gnus-article-summary-command-nosave ()
5079 "Execute the last keystroke in the summary buffer."
5082 (pop-to-buffer gnus-article-current-summary 'norecord)
5083 (setq func (lookup-key (current-local-map) (this-command-keys)))
5084 (call-interactively func)))
5086 (defun gnus-article-check-buffer ()
5087 "Beep if not in an article buffer."
5088 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5089 (error "Command invoked outside of a Gnus article buffer")))
5091 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5092 "Read a summary buffer key sequence and execute it from the article buffer."
5094 (gnus-article-check-buffer)
5096 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5097 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5098 "=" "^" "\M-^" "|"))
5104 '("n" "Gn" "p" "Gp"))
5107 (set-buffer gnus-article-current-summary)
5108 (let (gnus-pick-mode)
5109 (push (or key last-command-event) unread-command-events)
5110 (setq keys (static-if (featurep 'xemacs)
5111 (events-to-keys (read-key-sequence nil))
5112 (read-key-sequence nil)))))
5115 (if (or (member keys nosaves)
5116 (member keys nosave-but-article)
5117 (member keys nosave-in-article))
5119 (save-window-excursion
5120 (pop-to-buffer gnus-article-current-summary 'norecord)
5121 ;; We disable the pick minor mode commands.
5122 (let (gnus-pick-mode)
5123 (setq func (lookup-key (current-local-map) keys))))
5127 (unless (member keys nosave-in-article)
5128 (set-buffer gnus-article-current-summary))
5129 (call-interactively func)
5130 (setq new-sum-point (point)))
5131 (when (member keys nosave-but-article)
5132 (pop-to-buffer gnus-article-buffer 'norecord)))
5133 ;; These commands should restore window configuration.
5134 (let ((obuf (current-buffer))
5135 (owin (current-window-configuration))
5137 (summary gnus-article-current-summary)
5138 func in-buffer selected)
5139 (if not-restore-window
5140 (pop-to-buffer summary 'norecord)
5141 (switch-to-buffer summary 'norecord))
5142 (setq in-buffer (current-buffer))
5143 ;; We disable the pick minor mode commands.
5144 (if (and (setq func (let (gnus-pick-mode)
5145 (lookup-key (current-local-map) keys)))
5148 (call-interactively func)
5149 (setq new-sum-point (point))
5150 (when (eq in-buffer (current-buffer))
5151 (setq selected (gnus-summary-select-article))
5153 (unless not-restore-window
5154 (set-window-configuration owin))
5155 (when (eq selected 'old)
5157 (set-window-start (get-buffer-window (current-buffer))
5159 (set-window-point (get-buffer-window (current-buffer))
5161 (let ((win (get-buffer-window gnus-article-current-summary)))
5163 (set-window-point win new-sum-point)))) )
5164 (switch-to-buffer gnus-article-buffer)
5167 (defun gnus-article-describe-key (key)
5168 "Display documentation of the function invoked by KEY. KEY is a string."
5169 (interactive "kDescribe key: ")
5170 (gnus-article-check-buffer)
5171 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5173 (set-buffer gnus-article-current-summary)
5174 (let (gnus-pick-mode)
5175 (if (featurep 'xemacs)
5177 (push (elt key 0) unread-command-events)
5178 (setq key (events-to-keys
5179 (read-key-sequence "Describe key: "))))
5180 (setq unread-command-events
5182 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5184 (setq key (read-key-sequence "Describe key: "))))
5186 (describe-key key)))
5188 (defun gnus-article-describe-key-briefly (key &optional insert)
5189 "Display documentation of the function invoked by KEY. KEY is a string."
5190 (interactive "kDescribe key: \nP")
5191 (gnus-article-check-buffer)
5192 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5194 (set-buffer gnus-article-current-summary)
5195 (let (gnus-pick-mode)
5196 (if (featurep 'xemacs)
5198 (push (elt key 0) unread-command-events)
5199 (setq key (events-to-keys
5200 (read-key-sequence "Describe key: "))))
5201 (setq unread-command-events
5203 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5205 (setq key (read-key-sequence "Describe key: "))))
5206 (describe-key-briefly key insert))
5207 (describe-key-briefly key insert)))
5209 (defun gnus-article-reply-with-original (&optional wide)
5210 "Start composing a reply mail to the current message.
5211 The text in the region will be yanked. If the region isn't active,
5212 the entire article will be yanked."
5214 (let ((article (cdr gnus-article-current)) cont)
5216 (with-current-buffer gnus-summary-buffer
5217 (gnus-summary-reply (list (list article)) wide))
5218 (setq cont (buffer-substring (point) (mark t)))
5219 ;; Deactivate active regions.
5220 (when (and (boundp 'transient-mark-mode)
5221 transient-mark-mode)
5222 (setq mark-active nil))
5223 (with-current-buffer gnus-summary-buffer
5225 (list (list article cont)) wide)))))
5227 (defun gnus-article-followup-with-original ()
5228 "Compose a followup to the current article.
5229 The text in the region will be yanked. If the region isn't active,
5230 the entire article will be yanked."
5232 (let ((article (cdr gnus-article-current)) cont)
5234 (with-current-buffer gnus-summary-buffer
5235 (gnus-summary-followup (list (list article))))
5236 (setq cont (buffer-substring (point) (mark t)))
5237 ;; Deactivate active regions.
5238 (when (and (boundp 'transient-mark-mode)
5239 transient-mark-mode)
5240 (setq mark-active nil))
5241 (with-current-buffer gnus-summary-buffer
5242 (gnus-summary-followup
5243 (list (list article cont)))))))
5245 (defun gnus-article-hide (&optional arg force)
5246 "Hide all the gruft in the current article.
5247 This means that PGP stuff, signatures, cited text and (some)
5248 headers will be hidden.
5249 If given a prefix, show the hidden text instead."
5250 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5251 (gnus-article-hide-headers arg)
5252 (gnus-article-hide-list-identifiers arg)
5253 (gnus-article-hide-pgp arg)
5254 (gnus-article-hide-citation-maybe arg force)
5255 (gnus-article-hide-signature arg))
5257 (defun gnus-article-maybe-highlight ()
5258 "Do some article highlighting if article highlighting is requested."
5259 (when (gnus-visual-p 'article-highlight 'highlight)
5260 (gnus-article-highlight-some)))
5262 (defun gnus-check-group-server ()
5263 ;; Make sure the connection to the server is alive.
5264 (unless (gnus-server-opened
5265 (gnus-find-method-for-group gnus-newsgroup-name))
5266 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5267 (gnus-request-group gnus-newsgroup-name t)))
5270 (autoload 'nneething-get-file-name "nneething"))
5272 (defun gnus-request-article-this-buffer (article group)
5273 "Get an article and insert it into this buffer."
5274 (let (do-update-line sparse-header)
5278 (gnus-kill-all-overlays)
5279 (setq group (or group gnus-newsgroup-name))
5281 ;; Using `gnus-request-article' directly will insert the article into
5282 ;; `nntp-server-buffer' - so we'll save some time by not having to
5283 ;; copy it from the server buffer into the article buffer.
5285 ;; We only request an article by message-id when we do not have the
5286 ;; headers for it, so we'll have to get those.
5287 (when (stringp article)
5288 (gnus-read-header article))
5290 ;; If the article number is negative, that means that this article
5291 ;; doesn't belong in this newsgroup (possibly), so we find its
5292 ;; message-id and request it by id instead of number.
5293 (when (and (numberp article)
5295 (get-buffer gnus-summary-buffer)
5296 (gnus-buffer-exists-p gnus-summary-buffer))
5298 (set-buffer gnus-summary-buffer)
5299 (let ((header (gnus-summary-article-header article)))
5302 ((memq article gnus-newsgroup-sparse)
5303 ;; This is a sparse gap article.
5304 (setq do-update-line article)
5305 (setq article (mail-header-id header))
5306 (setq sparse-header (gnus-read-header article))
5307 (setq gnus-newsgroup-sparse
5308 (delq article gnus-newsgroup-sparse)))
5310 ;; It's a real article.
5311 (setq article (mail-header-id header)))
5313 ;; It is an extracted pseudo-article.
5314 (setq article 'pseudo)
5315 (gnus-request-pseudo-article header))))
5317 (let ((method (gnus-find-method-for-group
5318 gnus-newsgroup-name)))
5319 (when (and (eq (car method) 'nneething)
5321 (let ((dir (nneething-get-file-name
5322 (mail-header-id header))))
5323 (when (and (stringp dir)
5324 (file-directory-p dir))
5325 (setq article 'nneething)
5326 (gnus-group-enter-directory dir))))))))
5329 ;; Refuse to select canceled articles.
5330 ((and (numberp article)
5332 (get-buffer gnus-summary-buffer)
5333 (gnus-buffer-exists-p gnus-summary-buffer)
5334 (eq (cdr (save-excursion
5335 (set-buffer gnus-summary-buffer)
5336 (assq article gnus-newsgroup-reads)))
5337 gnus-canceled-mark))
5339 ;; We first check `gnus-original-article-buffer'.
5340 ((and (get-buffer gnus-original-article-buffer)
5343 (set-buffer gnus-original-article-buffer)
5344 (and (equal (car gnus-original-article) group)
5345 (eq (cdr gnus-original-article) article))))
5346 (insert-buffer-substring gnus-original-article-buffer)
5348 ;; Check the backlog.
5349 ((and gnus-keep-backlog
5350 (gnus-backlog-request-article group article (current-buffer)))
5352 ;; Check asynchronous pre-fetch.
5353 ((gnus-async-request-fetched-article group article (current-buffer))
5354 (gnus-async-prefetch-next group article gnus-summary-buffer)
5355 (when (and (numberp article) gnus-keep-backlog)
5356 (gnus-backlog-enter-article group article (current-buffer)))
5359 ((and gnus-use-cache
5361 (gnus-cache-request-article article group))
5363 ;; Check the agent cache.
5364 ((and gnus-agent gnus-agent-cache gnus-plugged
5366 (gnus-agent-request-article article group))
5368 ;; Get the article and put into the article buffer.
5369 ((or (stringp article)
5371 (let ((gnus-override-method gnus-override-method)
5372 (methods (and (stringp article)
5373 gnus-refer-article-method))
5374 (backend (car (gnus-find-method-for-group
5375 gnus-newsgroup-name)))
5377 (buffer-read-only nil))
5378 (if (or (not (listp methods))
5379 (and (symbolp (car methods))
5380 (assq (car methods) nnoo-definition-alist)))
5381 (setq methods (list methods)))
5382 (when (and (null gnus-override-method)
5384 (setq gnus-override-method (pop methods)))
5386 (when (eq gnus-override-method 'current)
5387 (setq gnus-override-method
5388 (with-current-buffer gnus-summary-buffer
5389 gnus-current-select-method)))
5391 (gnus-kill-all-overlays)
5392 (let ((gnus-newsgroup-name group))
5393 (gnus-check-group-server))
5395 ((gnus-request-article article group (current-buffer))
5396 (when (numberp article)
5397 (gnus-async-prefetch-next group article
5398 gnus-summary-buffer)
5399 (when gnus-keep-backlog
5400 (gnus-backlog-enter-article
5401 group article (current-buffer))))
5402 (setq result 'article))
5404 (setq gnus-override-method (pop methods)))
5405 ((not (string-match "^400 "
5406 (nnheader-get-report backend)))
5407 ;; If we get 400 server disconnect, reconnect and
5408 ;; retry; otherwise, assume the article has expired.
5409 (setq result 'done))))
5410 (and (eq result 'article) 'article)))
5414 ;; Associate this article with the current summary buffer.
5415 (setq gnus-article-current-summary gnus-summary-buffer)
5417 ;; Take the article from the original article buffer
5418 ;; and place it in the buffer it's supposed to be in.
5419 (when (and (get-buffer gnus-article-buffer)
5420 (equal (buffer-name (current-buffer))
5421 (buffer-name (get-buffer gnus-article-buffer))))
5423 (if (get-buffer gnus-original-article-buffer)
5424 (set-buffer gnus-original-article-buffer)
5425 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5426 (buffer-disable-undo)
5427 (setq major-mode 'gnus-original-article-mode)
5428 (setq buffer-read-only t))
5429 (let (buffer-read-only)
5431 (insert-buffer-substring gnus-article-buffer))
5432 (setq gnus-original-article (cons group article)))
5435 (run-hooks 'gnus-article-decode-hook)
5436 ;; Mark article as decoded or not.
5437 (setq gnus-article-decoded-p gnus-article-decode-hook))
5439 ;; Update sparse articles.
5440 (when (and do-update-line
5441 (or (numberp article)
5443 (let ((buf (current-buffer)))
5444 (set-buffer gnus-summary-buffer)
5445 (gnus-summary-update-article do-update-line sparse-header)
5446 (gnus-summary-goto-subject do-update-line nil t)
5447 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5449 (set-buffer buf))))))
5455 (defcustom gnus-article-edit-mode-hook nil
5456 "Hook run in article edit mode buffers."
5457 :group 'gnus-article-various
5460 (defcustom gnus-article-edit-article-setup-function
5461 'gnus-article-mime-edit-article-setup
5462 "Function called to setup an editing article buffer."
5463 :group 'gnus-article-various
5466 (defvar gnus-article-edit-done-function nil)
5468 (defvar gnus-article-edit-mode-map nil)
5470 ;; Should we be using derived.el for this?
5471 (unless gnus-article-edit-mode-map
5472 (setq gnus-article-edit-mode-map (make-keymap))
5473 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5475 (gnus-define-keys gnus-article-edit-mode-map
5476 "\C-c?" describe-mode
5477 "\C-c\C-c" gnus-article-edit-done
5478 "\C-c\C-k" gnus-article-edit-exit
5479 "\C-c\C-f\C-t" message-goto-to
5480 "\C-c\C-f\C-o" message-goto-from
5481 "\C-c\C-f\C-b" message-goto-bcc
5482 ;;"\C-c\C-f\C-w" message-goto-fcc
5483 "\C-c\C-f\C-c" message-goto-cc
5484 "\C-c\C-f\C-s" message-goto-subject
5485 "\C-c\C-f\C-r" message-goto-reply-to
5486 "\C-c\C-f\C-n" message-goto-newsgroups
5487 "\C-c\C-f\C-d" message-goto-distribution
5488 "\C-c\C-f\C-f" message-goto-followup-to
5489 "\C-c\C-f\C-m" message-goto-mail-followup-to
5490 "\C-c\C-f\C-k" message-goto-keywords
5491 "\C-c\C-f\C-u" message-goto-summary
5492 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5493 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5494 "\C-c\C-b" message-goto-body
5495 "\C-c\C-i" message-goto-signature
5497 "\C-c\C-t" message-insert-to
5498 "\C-c\C-n" message-insert-newsgroups
5499 "\C-c\C-o" message-sort-headers
5500 "\C-c\C-e" message-elide-region
5501 "\C-c\C-v" message-delete-not-region
5502 "\C-c\C-z" message-kill-to-signature
5503 "\M-\r" message-newline-and-reformat
5504 "\C-c\C-a" mml-attach-file
5505 "\C-a" message-beginning-of-line
5507 "\M-;" comment-region)
5509 (gnus-define-keys (gnus-article-edit-wash-map
5510 "\C-c\C-w" gnus-article-edit-mode-map)
5511 "f" gnus-article-edit-full-stops))
5514 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5516 ["Fetch To" message-insert-to t]
5517 ["Fetch Newsgroups" message-insert-newsgroups t]
5519 ["To" message-goto-to t]
5520 ["From" message-goto-from t]
5521 ["Subject" message-goto-subject t]
5522 ["Cc" message-goto-cc t]
5523 ["Reply-To" message-goto-reply-to t]
5524 ["Summary" message-goto-summary t]
5525 ["Keywords" message-goto-keywords t]
5526 ["Newsgroups" message-goto-newsgroups t]
5527 ["Followup-To" message-goto-followup-to t]
5528 ["Mail-Followup-To" message-goto-mail-followup-to t]
5529 ["Distribution" message-goto-distribution t]
5530 ["Body" message-goto-body t]
5531 ["Signature" message-goto-signature t]))
5533 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5534 "Major mode for editing articles.
5535 This is an extended text-mode.
5537 \\{gnus-article-edit-mode-map}"
5538 (make-local-variable 'gnus-article-edit-done-function)
5539 (make-local-variable 'gnus-prev-winconf)
5540 (set (make-local-variable 'font-lock-defaults)
5541 '(message-font-lock-keywords t))
5542 (set (make-local-variable 'mail-header-separator) "")
5543 (easy-menu-add message-mode-field-menu message-mode-map)
5544 (setq buffer-read-only nil)
5545 (buffer-enable-undo)
5548 (defun gnus-article-edit (&optional force)
5549 "Edit the current article.
5550 This will have permanent effect only in mail groups.
5551 If FORCE is non-nil, allow editing of articles even in read-only
5554 (when (and (not force)
5555 (gnus-group-read-only-p))
5556 (error "The current newsgroup does not support article editing"))
5557 (gnus-article-date-original)
5558 (gnus-article-edit-article
5560 `(lambda (no-highlight)
5562 (gnus-summary-edit-article-done
5563 ,(or (mail-header-references gnus-current-headers) "")
5564 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5566 (defun gnus-article-edit-article (start-func exit-func)
5567 "Start editing the contents of the current article buffer."
5568 (let ((winconf (current-window-configuration)))
5569 (set-buffer gnus-article-buffer)
5570 (gnus-article-edit-mode)
5571 (funcall start-func)
5572 (set-buffer-modified-p nil)
5573 (gnus-configure-windows 'edit-article)
5574 (setq gnus-article-edit-done-function exit-func)
5575 (setq gnus-prev-winconf winconf)
5576 (when gnus-article-edit-article-setup-function
5577 (funcall gnus-article-edit-article-setup-function))
5578 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5580 (defun gnus-article-edit-done (&optional arg)
5581 "Update the article edits and exit."
5583 (let ((func gnus-article-edit-done-function)
5584 (buf (current-buffer))
5585 (start (window-start))
5587 (winconf gnus-prev-winconf))
5588 (remove-hook 'gnus-article-mode-hook
5589 'gnus-article-mime-edit-article-unwind)
5590 (widen) ;; Widen it in case that users narrowed the buffer.
5593 ;; The cache and backlog have to be flushed somewhat.
5594 (when gnus-keep-backlog
5595 (gnus-backlog-remove-article
5596 (car gnus-article-current) (cdr gnus-article-current)))
5597 ;; Flush original article as well.
5599 (when (get-buffer gnus-original-article-buffer)
5600 (set-buffer gnus-original-article-buffer)
5601 (setq gnus-original-article nil)))
5602 (when gnus-use-cache
5603 (gnus-cache-update-article
5604 (car gnus-article-current) (cdr gnus-article-current)))
5605 ;; We remove all text props from the article buffer.
5606 (kill-all-local-variables)
5607 (gnus-set-text-properties (point-min) (point-max) nil)
5609 (set-window-configuration winconf)
5611 (set-window-start (get-buffer-window buf) start)
5612 (set-window-point (get-buffer-window buf) (point))))
5614 (defun gnus-article-edit-exit ()
5615 "Exit the article editing without updating."
5617 (when (or (not (buffer-modified-p))
5618 (yes-or-no-p "Article modified; kill anyway? "))
5619 (let ((curbuf (current-buffer))
5621 (window-start (window-start)))
5623 (if (gnus-buffer-live-p gnus-original-article-buffer)
5624 (insert-buffer-substring gnus-original-article-buffer))
5625 (let ((winconf gnus-prev-winconf))
5627 (set-window-configuration winconf)
5628 ;; Tippy-toe some to make sure that point remains where it was.
5629 (save-current-buffer
5631 (set-window-start (get-buffer-window (current-buffer)) window-start)
5634 (defun gnus-article-edit-full-stops ()
5635 "Interactively repair spacing at end of sentences."
5638 (goto-char (point-min))
5639 (search-forward-regexp "^$" nil t)
5640 (let ((case-fold-search nil))
5641 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5644 ;;; Article editing with MIME-Edit
5647 (defcustom gnus-article-mime-edit-article-setup-hook nil
5648 "Hook run after setting up a MIME editing article buffer."
5649 :group 'gnus-article-various
5652 (defun gnus-article-mime-edit-article-unwind ()
5653 "Unwind `gnus-article-buffer' if article editing was given up."
5654 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5655 (when (featurep 'font-lock)
5656 (setq font-lock-defaults nil)
5657 (font-lock-mode -1))
5658 (when mime-edit-mode-flag
5659 (mime-edit-exit 'nomime 'no-error)
5662 (defun gnus-article-mime-edit-article-setup ()
5663 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5664 after replacing with the original article."
5665 (setq gnus-show-mime t)
5666 (setq gnus-article-edit-done-function
5667 `(lambda (&rest args)
5668 (when mime-edit-mode-flag
5669 (let (mime-edit-insert-user-agent-field)
5672 (goto-char (point-min))
5673 (let (case-fold-search)
5674 (when (re-search-forward
5675 (format "^%s$" (regexp-quote mail-header-separator))
5677 (replace-match "")))
5678 (apply ,gnus-article-edit-done-function args)
5681 (buffer-substring-no-properties (point-min) (point-max))
5682 (set-buffer (get-buffer-create gnus-original-article-buffer))
5684 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5685 (set-buffer gnus-article-buffer)
5686 (gnus-article-prepare-display)))
5687 (substitute-key-definition 'gnus-article-edit-done
5688 'gnus-article-mime-edit-done
5689 gnus-article-edit-mode-map)
5690 (substitute-key-definition 'gnus-article-edit-exit
5691 'gnus-article-mime-edit-exit
5692 gnus-article-edit-mode-map)
5694 (insert-buffer-substring gnus-original-article-buffer)
5695 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5696 (fset 'mime-edit-decode-single-part-in-buffer
5697 (lambda (&rest args)
5698 (if (let ((content-type (car args)))
5699 (and (eq 'message (mime-content-type-primary-type
5701 (eq 'rfc822 (mime-content-type-subtype content-type))))
5702 (setcar (cdr args) 'not-decode-text))
5706 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5707 (when (featurep 'font-lock)
5708 (set (make-local-variable 'font-lock-defaults)
5709 '(message-font-lock-keywords t))
5710 (font-lock-set-defaults)
5711 (turn-on-font-lock))
5712 (set-buffer-modified-p nil)
5713 (delete-other-windows)
5714 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5715 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5717 (defun gnus-article-mime-edit-done (&optional arg)
5718 "Update the article MIME edits and exit."
5720 (when (featurep 'font-lock)
5721 (setq font-lock-defaults nil)
5722 (font-lock-mode -1))
5723 (gnus-article-edit-done arg))
5725 (defun gnus-article-mime-edit-exit ()
5726 "Exit the article MIME editing without updating."
5728 (when (or (not (buffer-modified-p))
5729 (yes-or-no-p "Article modified; kill anyway? "))
5730 (when (featurep 'font-lock)
5731 (setq font-lock-defaults nil)
5732 (font-lock-mode -1))
5733 (when mime-edit-mode-flag
5734 (let (mime-edit-insert-user-agent-field)
5737 (goto-char (point-min))
5738 (let (case-fold-search)
5739 (when (re-search-forward
5740 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5741 (replace-match "")))
5742 (let ((winconf gnus-prev-winconf))
5744 (buffer-substring-no-properties (point-min) (point-max))
5745 (set-buffer (get-buffer-create gnus-original-article-buffer))
5747 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5748 (set-buffer gnus-article-buffer)
5749 (gnus-article-prepare-display)
5750 (set-window-configuration winconf))))
5753 ;;; Article highlights
5756 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5758 ;;; Internal Variables:
5760 (defcustom gnus-button-url-regexp
5761 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5762 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-zA-Z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
5763 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)")
5764 "Regular expression that matches URLs."
5765 :group 'gnus-article-buttons
5768 (defcustom gnus-button-man-handler 'man
5769 "Function to use for displaying man pages.
5770 The function must take at least one argument with a string naming the
5772 :type '(choice (function-item :tag "Man" man)
5773 (function-item :tag "Woman" woman)
5774 (function :tag "Other"))
5775 :group 'gnus-article-buttons)
5777 (defcustom gnus-button-prefer-mid-or-mail 'guess
5778 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5779 Strings like this can be either a message ID or a mail address. If the
5780 variable is set to the symbol `ask', query the user what do do. If it is the
5781 symbol `guess', Gnus will do a guess and query the user what do do if it is
5782 ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume
5783 that the string is a message ID or a mail address, respectivly. See the
5784 variable `gnus-button-guessed-mid-regexp' for details concerning the
5786 ;; FIXME: doc-string could/should be improved.
5787 :group 'gnus-article-buttons
5788 :type '(choice (const ask)
5793 (defcustom gnus-button-guessed-mid-regexp
5795 "^<?\\(slrn\\|Pine\\.\\)"
5796 "\\|\\.fsf@\\|\\.ln@\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5797 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5798 "Regular expression that matches message IDs and not mail addresses."
5799 ;; TODO: Incorporate more matches from
5800 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5801 ;; Perl-REs to Elisp-REs.
5802 :group 'gnus-article-buttons
5805 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5806 (let* ((pref gnus-button-prefer-mid-or-mail)
5807 (url-mid (concat "news" ":" mid-or-mail))
5808 (url-mailto (concat "mailto" ":" mid-or-mail)))
5809 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5810 ;; If it looks like a MID (well known readers or servers) use 'mid,
5811 ;; otherwise 'ask the user.
5812 (if (eq pref 'guess)
5813 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5817 (save-window-excursion
5818 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5821 (cond ((eq pref 'mid)
5822 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5823 (gnus-button-handle-news url-mid))
5825 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5826 (gnus-url-mailto url-mailto)))))
5828 (defun gnus-button-handle-custom (url)
5829 "Follow a Custom URL."
5830 (customize-apropos (gnus-url-unhex-string url)))
5832 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[F1]1>?\\)")
5834 (defun gnus-button-handle-describe-function (url)
5835 "Call describe-function when pushing the corresponing URL button."
5838 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5840 (defun gnus-button-handle-describe-variable (url)
5841 "Call describe-variable when pushing the corresponing URL button."
5844 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5846 ;; FIXME: Is is possible to implement this? Else it should be removed here
5847 ;; and in `gnus-button-alist'.
5848 (defun gnus-button-handle-describe-key (url)
5849 "Call describe-key when pushing the corresponing URL button."
5850 (error "not implemented"))
5852 (defun gnus-button-handle-apropos (url)
5853 "Call apropos when pushing the corresponing URL button."
5854 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5856 (defun gnus-button-handle-apropos-command (url)
5857 "Call apropos when pushing the corresponing URL button."
5858 (apropos-command (gnus-replace-in-string url
5859 gnus-button-handle-describe-prefix "")))
5861 (defun gnus-button-handle-apropos-variable (url)
5862 "Call apropos when pushing the corresponing URL button."
5863 (apropos-variable (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5865 (defcustom gnus-button-man-level 5
5866 "*Integer that says how many man-related buttons Gnus will show.
5867 The higher the number, the more buttons will appear and the more false
5868 positves are possible. Note that you can set this variable local to
5869 specifific groups. Setting it higher in Unix groups is probably a good idea.
5870 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5871 how to set variables in specific groups."
5872 :group 'gnus-article-buttons
5875 (defcustom gnus-button-emacs-level 5
5876 "*Integer that says how many emacs-related buttons Gnus will show.
5877 The higher the number, the more buttons will appear and the more false
5878 positves are possible. Note that you can set this variable local to
5879 specifific groups. Setting it higher in Emacs or Gnus related groups is
5880 probably a good idea.See Info node `(gnus)Group Parameters' and the variable
5881 `gnus-parameters' on how to set variables in specific groups."
5882 :group 'gnus-article-buttons
5885 (defcustom gnus-button-mail-level 5
5886 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5887 The higher the number, the more buttons will appear and the more false
5888 positves are possible."
5889 :group 'gnus-article-buttons
5892 (defcustom gnus-button-alist
5893 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5894 0 t gnus-button-handle-news 3)
5895 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5896 gnus-button-handle-news 2)
5897 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5899 gnus-button-fetch-group 4)
5900 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5901 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5902 t gnus-button-message-id 3)
5903 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5904 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5905 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5907 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5908 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5910 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5911 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5912 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5913 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5914 ;; Emacs help commands
5915 ("M-x[ \t\n]apropos[ \t\n]\\([^ ]+\\)[ \t\n]RET"
5916 ;; regexp doesn't match arguments containing ` '.
5917 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5918 ("M-x[ \t\n]apropos-command[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5919 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5920 ("M-x[ \t\n]apropos-variable[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5921 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5922 ("\\W\\(C-h\\|<?[F1]1>?\\)[ \t\n]f[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5923 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5924 ("\\W\\(C-h\\|<?[F1]1>?\\)[ \t\n]v[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5925 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5926 ("\\W\\(C-h\\|<?[F1]1>?\\)[ \t\n]k[ \t\n]\\([^ ]+\\)[ \t\n]" 0
5927 ;; this regexp needs to be fixed!
5928 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5929 ;; This is how URLs _should_ be embedded in text...
5930 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5932 (gnus-button-url-regexp 0 t browse-url 0)
5934 ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0
5935 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5936 gnus-button-handle-man 1)
5937 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5938 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0
5939 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5940 gnus-button-handle-man 1)
5941 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv)
5942 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0
5943 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5944 ;; MID or mail: To avoid too many false positives we don't try to catch
5945 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5946 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5947 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5948 ;; so that non-ambiguous entries (see above) match first.
5949 ("\\b\\(<?[a-zA-Z0-9][^<>\")!;:,{}\n\t ]*@[a-zA-Z0-9][-.a-zA-Z0-9]+\\.\\([a-zA-Z][a-zA-Z]\\([a-zA-Z]\\)?\\|[Ii][Nn][Ff][Oo]\\|[Nn][Aa][Mm][Ee]\\)>?\\)\\b"
5950 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5951 "*Alist of regexps matching buttons in article bodies.
5953 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5954 REGEXP: is the string matching text around the button (can also be lisp
5955 expression evaluating to a string),
5956 BUTTON: is the number of the regexp grouping actually matching the button,
5957 FORM: is a lisp expression which must eval to true for the button to
5959 CALLBACK: is the function to call when the user push this button, and each
5960 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5962 CALLBACK can also be a variable, in that case the value of that
5963 variable it the real callback function."
5964 :group 'gnus-article-buttons
5965 :type '(repeat (list (choice regexp variable)
5966 (integer :tag "Button")
5968 (function :tag "Callback")
5971 (integer :tag "Regexp group")))))
5973 (defcustom gnus-header-button-alist
5974 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5975 0 t gnus-button-message-id 0)
5976 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5977 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5978 0 t gnus-button-mailto 0)
5979 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5980 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5981 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5982 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5983 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5984 gnus-button-message-id 3))
5985 "*Alist of headers and regexps to match buttons in article heads.
5987 This alist is very similar to `gnus-button-alist', except that each
5988 alist has an additional HEADER element first in each entry:
5990 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5992 HEADER is a regexp to match a header. For a fuller explanation, see
5993 `gnus-button-alist'."
5994 :group 'gnus-article-buttons
5995 :group 'gnus-article-headers
5996 :type '(repeat (list (regexp :tag "Header")
5998 (integer :tag "Button")
6000 (function :tag "Callback")
6003 (integer :tag "Regexp group")))))
6005 (defvar gnus-button-regexp nil)
6006 (defvar gnus-button-marker-list nil)
6007 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6009 (defvar gnus-button-last nil)
6010 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6014 (defun gnus-article-push-button (event)
6015 "Check text under the mouse pointer for a callback function.
6016 If the text under the mouse pointer has a `gnus-callback' property,
6017 call it with the value of the `gnus-data' text property."
6019 (set-buffer (window-buffer (posn-window (event-start event))))
6020 (let* ((pos (posn-point (event-start event)))
6021 (data (get-text-property pos 'gnus-data))
6022 (fun (get-text-property pos 'gnus-callback)))
6025 (funcall fun data))))
6027 (defun gnus-article-press-button ()
6028 "Check text at point for a callback function.
6029 If the text at point has a `gnus-callback' property,
6030 call it with the value of the `gnus-data' text property."
6032 (let* ((data (get-text-property (point) 'gnus-data))
6033 (fun (get-text-property (point) 'gnus-callback)))
6035 (funcall fun data))))
6037 (defun gnus-article-prev-button (n)
6038 "Move point to N buttons backward.
6039 If N is negative, move forward instead."
6041 (gnus-article-next-button (- n)))
6043 (defun gnus-article-next-button (n)
6044 "Move point to N buttons forward.
6045 If N is negative, move backward instead."
6047 (let ((function (if (< n 0) 'previous-single-property-change
6048 'next-single-property-change))
6049 (inhibit-point-motion-hooks t)
6051 (limit (if (< n 0) (point-min) (point-max))))
6053 (while (and (not (= limit (point)))
6055 ;; Skip past the current button.
6056 (when (get-text-property (point) 'gnus-callback)
6057 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6058 ;; Go to the next (or previous) button.
6059 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6060 ;; Put point at the start of the button.
6061 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6062 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6063 ;; Skip past intangible buttons.
6064 (when (get-text-property (point) 'intangible)
6068 (gnus-message 5 "No more buttons"))
6071 (defun gnus-article-highlight (&optional force)
6072 "Highlight current article.
6073 This function calls `gnus-article-highlight-headers',
6074 `gnus-article-highlight-citation',
6075 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6076 do the highlighting. See the documentation for those functions."
6077 (interactive (list 'force))
6078 (gnus-article-highlight-headers)
6079 (gnus-article-highlight-citation force)
6080 (gnus-article-highlight-signature)
6081 (gnus-article-add-buttons force)
6082 (gnus-article-add-buttons-to-head))
6084 (defun gnus-article-highlight-some (&optional force)
6085 "Highlight current article.
6086 This function calls `gnus-article-highlight-headers',
6087 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6088 do the highlighting. See the documentation for those functions."
6089 (interactive (list 'force))
6090 (gnus-article-highlight-headers)
6091 (gnus-article-highlight-signature)
6092 (gnus-article-add-buttons))
6094 (defun gnus-article-highlight-headers ()
6095 "Highlight article headers as specified by `gnus-header-face-alist'."
6098 (set-buffer gnus-article-buffer)
6100 (let ((alist gnus-header-face-alist)
6101 (buffer-read-only nil)
6102 (case-fold-search t)
6103 (inhibit-point-motion-hooks t)
6104 entry regexp header-face field-face from hpoints fpoints)
6105 (article-narrow-to-head)
6106 (while (setq entry (pop alist))
6107 (goto-char (point-min))
6108 (setq regexp (concat "^\\("
6109 (if (string-equal "" (nth 0 entry))
6113 header-face (nth 1 entry)
6114 field-face (nth 2 entry))
6115 (while (and (re-search-forward regexp nil t)
6119 (unless (search-forward ":" nil t)
6121 (when (and header-face
6122 (not (memq (point) hpoints)))
6123 (push (point) hpoints)
6124 (gnus-put-text-property from (point) 'face header-face))
6125 (when (and field-face
6126 (not (memq (setq from (point)) fpoints)))
6128 (if (re-search-forward "^[^ \t]" nil t)
6130 (goto-char (point-max)))
6131 (gnus-put-text-property from (point) 'face field-face))))))))
6133 (defun gnus-article-highlight-signature ()
6134 "Highlight the signature in an article.
6135 It does this by highlighting everything after
6136 `gnus-signature-separator' using `gnus-signature-face'."
6138 (when gnus-signature-face
6140 (set-buffer gnus-article-buffer)
6141 (let ((buffer-read-only nil)
6142 (inhibit-point-motion-hooks t))
6144 (when (gnus-article-narrow-to-signature)
6145 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6146 'face gnus-signature-face)))))))
6148 (defun gnus-article-buttonize-signature ()
6149 "Add button to the signature."
6152 (set-buffer gnus-article-buffer)
6153 (let ((buffer-read-only nil)
6154 (inhibit-point-motion-hooks t))
6155 (when (gnus-article-search-signature)
6156 (gnus-article-add-button (match-beginning 0) (match-end 0)
6157 'gnus-signature-toggle
6158 (set-marker (make-marker)
6159 (1+ (match-end 0))))))))
6161 (defun gnus-button-in-region-p (b e prop)
6162 "Say whether PROP exists in the region."
6163 (text-property-not-all b e prop nil))
6165 (defun gnus-article-add-buttons (&optional force)
6166 "Find external references in the article and make buttons of them.
6167 \"External references\" are things like Message-IDs and URLs, as
6168 specified by `gnus-button-alist'."
6169 (interactive (list 'force))
6171 (set-buffer gnus-article-buffer)
6172 (let ((buffer-read-only nil)
6173 (inhibit-point-motion-hooks t)
6174 (case-fold-search t)
6175 (alist gnus-button-alist)
6177 ;; Remove all old markers.
6178 (let (marker entry new-list)
6179 (while (setq marker (pop gnus-button-marker-list))
6180 (if (or (< marker (point-min)) (>= marker (point-max)))
6181 (push marker new-list)
6183 (when (setq entry (gnus-button-entry))
6184 (put-text-property (match-beginning (nth 1 entry))
6185 (match-end (nth 1 entry))
6186 'gnus-callback nil))
6187 (set-marker marker nil)))
6188 (setq gnus-button-marker-list new-list))
6189 ;; We skip the headers.
6192 (while (setq entry (pop alist))
6193 (setq regexp (eval (car entry)))
6195 (while (re-search-forward regexp nil t)
6196 (let* ((start (and entry (match-beginning (nth 1 entry))))
6197 (end (and entry (match-end (nth 1 entry))))
6198 (from (match-beginning 0)))
6199 (when (and (or (eq t (nth 2 entry))
6200 (eval (nth 2 entry)))
6201 (not (gnus-button-in-region-p
6202 start end 'gnus-callback)))
6203 ;; That optional form returned non-nil, so we add the
6205 (gnus-article-add-button
6206 start end 'gnus-button-push
6207 (car (push (set-marker (make-marker) from)
6208 gnus-button-marker-list))))))))))
6210 ;; Add buttons to the head of an article.
6211 (defun gnus-article-add-buttons-to-head ()
6212 "Add buttons to the head of the article."
6215 (set-buffer gnus-article-buffer)
6217 (let ((buffer-read-only nil)
6218 (inhibit-point-motion-hooks t)
6219 (case-fold-search t)
6220 (alist gnus-header-button-alist)
6222 (article-narrow-to-head)
6224 ;; Each alist entry.
6225 (setq entry (car alist)
6227 (goto-char (point-min))
6228 (while (re-search-forward (car entry) nil t)
6229 ;; Each header matching the entry.
6230 (setq beg (match-beginning 0))
6231 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6232 (match-beginning 0))
6235 (while (re-search-forward (eval (nth 1 entry)) end t)
6236 ;; Each match within a header.
6237 (let* ((entry (cdr entry))
6238 (start (match-beginning (nth 1 entry)))
6239 (end (match-end (nth 1 entry)))
6240 (form (nth 2 entry)))
6241 (goto-char (match-end 0))
6243 (gnus-article-add-button
6244 start end (nth 3 entry)
6245 (buffer-substring (match-beginning (nth 4 entry))
6246 (match-end (nth 4 entry)))))))
6247 (goto-char end)))))))
6249 ;;; External functions:
6251 (defun gnus-article-add-button (from to fun &optional data)
6252 "Create a button between FROM and TO with callback FUN and data DATA."
6253 (when gnus-article-button-face
6254 (gnus-overlay-put (gnus-make-overlay from to)
6255 'face gnus-article-button-face))
6256 (gnus-add-text-properties
6258 (nconc (and gnus-article-mouse-face
6259 (list gnus-mouse-face-prop gnus-article-mouse-face))
6260 (list 'gnus-callback fun)
6261 (and data (list 'gnus-data data))))
6262 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6263 ;; Quote `:button-keymap' for Mule 2.3
6264 ;; but it won't work.
6265 ':button-keymap gnus-widget-button-keymap))
6267 ;;; Internal functions:
6269 (defun gnus-article-set-globals ()
6271 (set-buffer gnus-summary-buffer)
6272 (gnus-set-global-variables)))
6274 (defun gnus-signature-toggle (end)
6276 (set-buffer gnus-article-buffer)
6277 (let ((buffer-read-only nil)
6278 (inhibit-point-motion-hooks t)
6279 (limit (next-single-property-change end 'mime-view-entity
6281 (if (text-property-any end limit 'article-type 'signature)
6283 (gnus-delete-wash-type 'signature)
6284 (gnus-remove-text-properties-when
6285 'article-type 'signature end limit
6286 (cons 'article-type (cons 'signature
6287 gnus-hidden-properties))))
6288 (gnus-add-wash-type 'signature)
6289 (gnus-add-text-properties-when
6290 'article-type nil end limit
6291 (cons 'article-type (cons 'signature
6292 gnus-hidden-properties)))))
6293 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6294 (gnus-set-mode-line 'article))))
6296 (defun gnus-button-entry ()
6297 ;; Return the first entry in `gnus-button-alist' matching this place.
6298 (let ((alist gnus-button-alist)
6301 (setq entry (pop alist))
6302 (if (looking-at (eval (car entry)))
6307 (defun gnus-button-push (marker)
6308 ;; Push button starting at MARKER.
6311 (let* ((entry (gnus-button-entry))
6312 (inhibit-point-motion-hooks t)
6314 (args (mapcar (lambda (group)
6315 (let ((string (match-string group)))
6316 (gnus-set-text-properties
6317 0 (length string) nil string)
6324 (fboundp (symbol-value fun)))
6325 (apply (symbol-value fun) args))
6327 (gnus-message 1 "You must define `%S' to use this button"
6328 (cons fun args)))))))
6330 (defun gnus-parse-news-url (url)
6331 (let (scheme server group message-id articles)
6334 (goto-char (point-min))
6335 (when (looking-at "\\([A-Za-z]+\\):")
6336 (setq scheme (match-string 1))
6337 (goto-char (match-end 0)))
6338 (when (looking-at "//\\([^/]+\\)/")
6339 (setq server (match-string 1))
6340 (goto-char (match-end 0)))
6343 ((looking-at "\\(.*@.*\\)")
6344 (setq message-id (match-string 1)))
6345 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6346 (setq group (match-string 1)
6347 articles (split-string (match-string 2) "-")))
6348 ((looking-at "\\([^/]+\\)/?")
6349 (setq group (match-string 1)))
6351 (error "Unknown news URL syntax"))))
6352 (list scheme server group message-id articles)))
6354 (defun gnus-button-handle-news (url)
6356 (destructuring-bind (scheme server group message-id articles)
6357 (gnus-parse-news-url url)
6361 (set-buffer gnus-summary-buffer)
6363 (let ((gnus-refer-article-method (list (list 'nntp server))))
6364 (gnus-summary-refer-article message-id))
6365 (gnus-summary-refer-article message-id))))
6367 (gnus-button-fetch-group url)))))
6369 (defun gnus-button-handle-man (url)
6371 (funcall gnus-button-man-handler url))
6373 (defun gnus-button-handle-info (url)
6374 "Fetch an info URL."
6376 "^\\([^:/]+\\)?/\\(.*\\)"
6378 (gnus-info-find-node
6379 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6382 (gnus-url-unhex-string (match-string 2 url))))
6383 (error "Can't parse %s" url)))
6385 (defun gnus-button-message-id (message-id)
6388 (set-buffer gnus-summary-buffer)
6389 (gnus-summary-refer-article message-id)))
6391 (defun gnus-button-fetch-group (address)
6392 "Fetch GROUP specified by ADDRESS."
6393 (if (not (string-match "[:/]" address))
6394 ;; This is just a simple group url.
6395 (gnus-group-read-ephemeral-group address gnus-select-method)
6398 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6400 (error "Can't parse %s" address)
6401 (gnus-group-read-ephemeral-group
6402 (match-string 4 address)
6403 `(nntp ,(match-string 1 address)
6404 (nntp-address ,(match-string 1 address))
6405 (nntp-port-number ,(if (match-end 3)
6406 (match-string 3 address)
6409 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6411 (defun gnus-url-parse-query-string (query &optional downcase)
6412 (let (retval pairs cur key val)
6413 (setq pairs (split-string query "&"))
6415 (setq cur (car pairs)
6417 (if (not (string-match "=" cur))
6419 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6420 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6422 (setq key (downcase key)))
6423 (setq cur (assoc key retval))
6425 (setcdr cur (cons val (cdr cur)))
6426 (setq retval (cons (list key val) retval)))))
6429 (defun gnus-url-mailto (url)
6430 ;; Send mail to someone
6431 (when (string-match "mailto:/*\\(.*\\)" url)
6432 (setq url (substring url (match-beginning 1) nil)))
6433 (let (to args subject func)
6434 (if (string-match (regexp-quote "?") url)
6435 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6436 args (gnus-url-parse-query-string
6437 (substring url (match-end 0) nil) t))
6438 (setq to (gnus-url-unhex-string url)))
6439 (setq args (cons (list "to" to) args)
6440 subject (cdr-safe (assoc "subject" args)))
6443 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6446 (message-position-on-field (caar args)))
6447 (insert (mapconcat 'identity (cdar args) ", "))
6448 (setq args (cdr args)))
6451 (message-goto-subject))))
6453 (defun gnus-button-embedded-url (address)
6454 "Activate ADDRESS with `browse-url'."
6455 (browse-url (gnus-strip-whitespace address)))
6457 ;;; Next/prev buttons in the article buffer.
6459 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6460 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6462 (defvar gnus-prev-page-map
6463 (let ((map (make-sparse-keymap)))
6464 (unless (>= emacs-major-version 21)
6465 ;; XEmacs doesn't care.
6466 (set-keymap-parent map gnus-article-mode-map))
6467 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6468 (define-key map "\r" 'gnus-button-prev-page)
6471 (defun gnus-insert-prev-page-button ()
6473 (buffer-read-only nil)
6474 (situation (get-text-property (point-min) 'mime-view-situation)))
6476 gnus-prev-page-line-format nil
6477 `(,@(gnus-local-map-property gnus-prev-page-map)
6479 gnus-callback gnus-article-button-prev-page
6480 article-type annotation
6481 mime-view-situation ,situation))
6482 (widget-convert-button
6484 :action 'gnus-button-prev-page
6485 :button-keymap gnus-prev-page-map)))
6487 (defvar gnus-next-page-map
6488 (let ((map (make-sparse-keymap)))
6489 (unless (>= emacs-major-version 21)
6490 ;; XEmacs doesn't care.
6491 (set-keymap-parent map gnus-article-mode-map))
6492 (define-key map gnus-mouse-2 'gnus-button-next-page)
6493 (define-key map "\r" 'gnus-button-next-page)
6496 (defun gnus-button-next-page (&optional args more-args)
6497 "Go to the next page."
6499 (let ((win (selected-window)))
6500 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6501 (gnus-article-next-page)
6502 (select-window win)))
6504 (defun gnus-button-prev-page (&optional args more-args)
6505 "Go to the prev page."
6507 (let ((win (selected-window)))
6508 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6509 (gnus-article-prev-page)
6510 (select-window win)))
6512 (defun gnus-insert-next-page-button ()
6514 (buffer-read-only nil)
6515 (situation (get-text-property (point-min) 'mime-view-situation)))
6516 (gnus-eval-format gnus-next-page-line-format nil
6517 `(,@(gnus-local-map-property gnus-next-page-map)
6519 gnus-callback gnus-article-button-next-page
6520 article-type annotation
6521 mime-view-situation ,situation))
6522 (widget-convert-button
6524 :action 'gnus-button-next-page
6525 :button-keymap gnus-next-page-map)))
6527 (defun gnus-article-button-next-page (arg)
6528 "Go to the next page."
6530 (let ((win (selected-window)))
6531 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6532 (gnus-article-next-page)
6533 (select-window win)))
6535 (defun gnus-article-button-prev-page (arg)
6536 "Go to the prev page."
6538 (let ((win (selected-window)))
6539 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6540 (gnus-article-prev-page)
6541 (select-window win)))
6543 (defvar gnus-decode-header-methods
6544 '(mail-decode-encoded-word-region)
6545 "List of methods used to decode headers.
6547 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6548 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6549 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6550 whose names match REGEXP.
6553 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6554 mail-decode-encoded-word-region
6555 (\"chinese\" . rfc1843-decode-region))
6558 (defvar gnus-decode-header-methods-cache nil)
6560 (defun gnus-multi-decode-header (start end)
6561 "Apply the functions from `gnus-encoded-word-methods' that match."
6562 (unless (and gnus-decode-header-methods-cache
6563 (eq gnus-newsgroup-name
6564 (car gnus-decode-header-methods-cache)))
6565 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6568 (nconc gnus-decode-header-methods-cache (list x))
6569 (if (and gnus-newsgroup-name
6570 (string-match (car x) gnus-newsgroup-name))
6571 (nconc gnus-decode-header-methods-cache
6573 gnus-decode-header-methods))
6574 (let ((xlist gnus-decode-header-methods-cache))
6577 (narrow-to-region start end)
6579 (funcall (pop xlist) (point-min) (point-max))))))
6582 ;;; Treatment top-level handling.
6585 (defun gnus-treat-article (condition &optional part-number total-parts type)
6586 (let ((length (- (point-max) (point-min)))
6587 (alist gnus-treatment-function-alist)
6588 (article-goto-body-goes-to-point-min-p t)
6592 (let ((list gnus-article-treat-types))
6594 (when (string-match (pop list) type)
6595 (throw 'found t)))))))
6596 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6597 (entity (static-unless (featurep 'xemacs)
6598 (when (eq 'head condition)
6599 (get-text-property (point-min) 'mime-view-entity))))
6600 val elem buttonized)
6601 (gnus-run-hooks 'gnus-part-display-hook)
6602 (unless gnus-inhibit-treatment
6603 (while (setq elem (pop alist))
6606 (if (gnus-buffer-live-p gnus-summary-buffer)
6607 (set-buffer gnus-summary-buffer))
6608 (symbol-value (car elem))))
6609 (when (and (or (consp val)
6611 (gnus-treat-predicate val)
6612 (or (not (get (car elem) 'highlight))
6614 (when (and (not buttonized)
6616 '(gnus-treat-hide-signature
6617 gnus-treat-highlight-signature)))
6618 (gnus-article-buttonize-signature)
6619 (setq buttonized t))
6621 (funcall (cadr elem)))))
6622 ;; FSF Emacsen does not inherit the existing text properties
6623 ;; in the new text, so we should do it for `mime-view-entity'.
6624 (static-unless (featurep 'xemacs)
6626 (put-text-property (point-min) (point-max)
6627 'mime-view-entity entity))))))
6629 ;; Dynamic variables.
6631 (defvar part-number)
6632 (defvar total-parts)
6637 (defun gnus-treat-predicate (val)
6642 (stringp (car val)))
6643 (apply 'gnus-or (mapcar `(lambda (s)
6644 (string-match s ,(or gnus-newsgroup-name "")))
6647 (let ((pred (pop val)))
6650 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6652 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6654 (not (gnus-treat-predicate (car val))))
6656 (equal (car val) type))
6658 (error "%S is not a valid predicate" pred)))))
6668 (eq part-number total-parts))
6672 (error "%S is not a valid value" val))))
6674 (defun gnus-article-encrypt-body (protocol &optional n)
6675 "Encrypt the article body."
6678 (or gnus-article-encrypt-protocol
6679 (completing-read "Encrypt protocol: "
6680 gnus-article-encrypt-protocol-alist
6682 current-prefix-arg))
6683 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6685 (error (format "Can't find the encrypt protocol %s" protocol)))
6686 (if (equal gnus-newsgroup-name "nndraft:drafts")
6687 (error "Can't encrypt the article in group nndraft:drafts"))
6688 (if (equal gnus-newsgroup-name "nndraft:queue")
6689 (error "Don't encrypt the article in group nndraft:queue"))
6690 (gnus-summary-iterate n
6692 (set-buffer gnus-summary-buffer)
6693 (let ((mail-parse-charset gnus-newsgroup-charset)
6694 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6695 (summary-buffer gnus-summary-buffer)
6697 (gnus-set-global-variables)
6698 (when (gnus-group-read-only-p)
6699 (error "The current newsgroup does not support article encrypt"))
6700 (gnus-summary-show-article t)
6702 (or (mail-header-references gnus-current-headers) ""))
6703 (set-buffer gnus-article-buffer)
6704 (let* ((buffer-read-only nil)
6706 (mapcar (lambda (field)
6707 (and (save-restriction
6708 (message-narrow-to-head)
6709 (goto-char (point-min))
6710 (search-forward field nil t))
6712 (message-narrow-to-field)
6713 (buffer-substring (point-min) (point-max))
6714 (delete-region (point-min) (point-max))
6716 '("Content-Type:" "Content-Transfer-Encoding:"
6717 "Content-Disposition:"))))
6718 (message-narrow-to-head)
6719 (message-remove-header "MIME-Version")
6720 (goto-char (point-max))
6721 (setq point (point))
6722 (insert (apply 'concat headers))
6724 (narrow-to-region point (point-max))
6725 (let ((message-options message-options))
6726 (message-options-set 'message-sender user-mail-address)
6727 (message-options-set 'message-recipients user-mail-address)
6728 (message-options-set 'message-sign-encrypt 'not)
6730 (goto-char (point-min))
6731 (insert "MIME-Version: 1.0\n")
6733 (gnus-summary-edit-article-done
6734 references nil summary-buffer t))
6735 (when gnus-keep-backlog
6736 (gnus-backlog-remove-article
6737 (car gnus-article-current) (cdr gnus-article-current)))
6739 (when (get-buffer gnus-original-article-buffer)
6740 (set-buffer gnus-original-article-buffer)
6741 (setq gnus-original-article nil)))
6742 (when gnus-use-cache
6743 (gnus-cache-update-article
6744 (car gnus-article-current) (cdr gnus-article-current))))))))
6746 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6747 "The following specs can be used:
6748 %t The security MIME type
6751 %D Details if button is pressed")
6753 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6754 "The following specs can be used:
6755 %t The security MIME type
6758 %D Details if button is pressed")
6760 (defvar gnus-mime-security-button-line-format-alist
6761 '((?t gnus-tmp-type ?s)
6762 (?i gnus-tmp-info ?s)
6763 (?d gnus-tmp-details ?s)
6764 (?D gnus-tmp-pressed-details ?s)))
6766 (defvar gnus-mime-security-button-map
6767 (let ((map (make-sparse-keymap)))
6768 (unless (>= (string-to-number emacs-version) 21)
6769 (set-keymap-parent map gnus-article-mode-map))
6770 (define-key map gnus-mouse-2 'gnus-article-push-button)
6771 (define-key map "\r" 'gnus-article-press-button)
6774 (defvar gnus-mime-security-details-buffer nil)
6776 (defvar gnus-mime-security-button-pressed nil)
6778 (defvar gnus-mime-security-show-details-inline t
6779 "If non-nil, show details in the article buffer.")
6781 (defun gnus-mime-security-verify-or-decrypt (handle)
6782 (mm-remove-parts (cdr handle))
6783 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6784 point buffer-read-only)
6786 (goto-char (car region)))
6788 (narrow-to-region (point) (point))
6789 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6790 (let* ((mm-verify-option 'known)
6791 (mm-decrypt-option 'known)
6792 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6793 (unless (eq nparts (cdr handle))
6794 (mm-destroy-parts (cdr handle))
6795 (setcdr handle nparts))))
6796 (setq point (point))
6797 (gnus-mime-display-security handle)
6798 (goto-char (point-max)))
6800 (delete-region (point) (cdr region))
6801 (set-marker (car region) nil)
6802 (set-marker (cdr region) nil))
6805 (defun gnus-mime-security-show-details (handle)
6806 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6808 (if gnus-mime-security-show-details-inline
6809 (let ((gnus-mime-security-button-pressed t)
6810 (gnus-mime-security-button-line-format
6811 (get-text-property (point) 'gnus-line-format))
6814 (while (eq (get-text-property (point) 'gnus-line-format)
6815 gnus-mime-security-button-line-format)
6819 (narrow-to-region (point) (point))
6820 (gnus-insert-mime-security-button handle))
6821 (delete-region (point)
6822 (or (text-property-not-all
6825 gnus-mime-security-button-line-format)
6827 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6828 (with-current-buffer gnus-mime-security-details-buffer
6831 (setq gnus-mime-security-details-buffer
6832 (gnus-get-buffer-create "*MIME Security Details*")))
6833 (with-current-buffer gnus-mime-security-details-buffer
6835 (goto-char (point-min)))
6836 (pop-to-buffer gnus-mime-security-details-buffer))
6837 (gnus-message 5 "No details."))))
6839 (defun gnus-mime-security-press-button (handle)
6840 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6841 (gnus-mime-security-show-details handle)
6842 (gnus-mime-security-verify-or-decrypt handle)))
6844 (defun gnus-insert-mime-security-button (handle &optional displayed)
6845 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6848 (or (nth 2 (assoc protocol mm-verify-function-alist))
6849 (nth 2 (assoc protocol mm-decrypt-function-alist))
6851 (if (equal (car handle) "multipart/signed")
6852 " Signed" " Encrypted")
6855 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6858 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6859 gnus-tmp-pressed-details
6861 (setq gnus-tmp-details
6862 (if gnus-tmp-details
6863 (concat "\n" gnus-tmp-details) ""))
6864 (setq gnus-tmp-pressed-details
6865 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6870 gnus-mime-security-button-line-format
6871 gnus-mime-security-button-line-format-alist
6872 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6873 gnus-callback gnus-mime-security-press-button
6874 gnus-line-format ,gnus-mime-security-button-line-format
6875 article-type annotation
6878 (widget-convert-button
6881 :action 'gnus-widget-press-button
6882 :button-keymap gnus-mime-security-button-map
6884 (lambda (widget/window &optional overlay pos)
6885 ;; Needed to properly clear the message due to a bug in
6886 ;; wid-edit (XEmacs only).
6887 (if (boundp 'help-echo-owns-message)
6888 (setq help-echo-owns-message t))
6891 (aref gnus-mouse-2 0))))))
6893 (defun gnus-mime-display-security (handle)
6895 (narrow-to-region (point) (point))
6896 (unless (gnus-unbuttonized-mime-type-p (car handle))
6897 (gnus-insert-mime-security-button handle))
6898 (gnus-mime-display-mixed (cdr handle))
6901 (unless (gnus-unbuttonized-mime-type-p (car handle))
6902 (let ((gnus-mime-security-button-line-format
6903 gnus-mime-security-button-end-line-format))
6904 (gnus-insert-mime-security-button handle)))
6905 (mm-set-handle-multipart-parameter
6907 (cons (set-marker (make-marker) (point-min))
6908 (set-marker (make-marker) (point-max))))))
6914 (defun gnus-article-header-presentation-method (entity situation)
6915 (mime-insert-header entity)
6916 (article-decode-group-name))
6918 (set-alist 'mime-header-presentation-method-alist
6919 'gnus-original-article-mode
6920 #'gnus-article-header-presentation-method)
6922 (defun gnus-mime-preview-quitting-method ()
6923 (mime-preview-kill-buffer)
6924 (delete-other-windows)
6925 (gnus-article-show-summary)
6926 (gnus-summary-select-article gnus-show-all-headers t))
6928 (set-alist 'mime-preview-quitting-method-alist
6929 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6931 (set-alist 'mime-preview-following-method-alist
6932 'gnus-original-article-mode #'gnus-following-method)
6934 (set-alist 'mime-preview-over-to-previous-method-alist
6935 'gnus-original-article-mode
6937 (if (> (point-min) 1)
6938 (gnus-article-prev-page)
6939 (gnus-article-read-summary-keys
6940 nil (gnus-character-to-event ?P)))))
6942 (set-alist 'mime-preview-over-to-next-method-alist
6943 'gnus-original-article-mode'
6945 (if (< (point-max) (buffer-size))
6946 (gnus-article-next-page)
6947 (gnus-article-read-summary-keys
6948 nil (gnus-character-to-event ?N)))))
6958 (run-hooks 'gnus-art-load-hook)
6960 ;;; gnus-art.el ends here