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
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 :link '(custom-manual "(gnus)Customizing Articles")
889 :type gnus-article-treat-custom)
890 (put 'gnus-treat-highlight-signature 'highlight t)
892 (defcustom gnus-treat-buttonize 100000
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See Info node `(gnus)Customizing Articles'."
896 :group 'gnus-article-treat
897 :link '(custom-manual "(gnus)Customizing Articles")
898 :type gnus-article-treat-custom)
899 (put 'gnus-treat-buttonize 'highlight t)
901 (defcustom gnus-treat-buttonize-head 'head
902 "Add buttons to the head.
903 Valid values are nil, t, `head', `last', an integer or a predicate.
904 See Info node `(gnus)Customizing Articles' for details."
905 :group 'gnus-article-treat
906 :link '(custom-manual "(gnus)Customizing Articles")
907 :type gnus-article-treat-head-custom)
908 (put 'gnus-treat-buttonize-head 'highlight t)
910 (defcustom gnus-treat-emphasize
911 (and (or window-system
913 (>= (string-to-number emacs-version) 21))
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-custom)
921 (put 'gnus-treat-emphasize 'highlight t)
923 (defcustom gnus-treat-strip-cr nil
924 "Remove carriage returns.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-unsplit-urls nil
932 "Remove newlines from within URLs.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-custom)
939 (defcustom gnus-treat-leading-whitespace nil
940 "Remove leading whitespace in headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-custom)
947 (defcustom gnus-treat-hide-headers 'head
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 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-head-custom)
955 (defcustom gnus-treat-hide-boring-headers nil
956 "Hide boring headers.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-head-custom)
963 (defcustom gnus-treat-hide-signature nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-fill-article nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-hide-citation nil
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :link '(custom-manual "(gnus)Customizing Articles")
985 :type gnus-article-treat-custom)
987 (defcustom gnus-treat-hide-citation-maybe nil
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (defcustom gnus-treat-strip-list-identifiers 'head
996 "Strip list identifiers from `gnus-list-identifiers`.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-strip-pgp t
1005 "Strip PGP signatures.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-strip-pem nil
1013 "Strip PEM signatures.
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 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-strip-banner t
1021 "Strip banners from articles.
1022 The banner to be stripped is specified in the `banner' group parameter.
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :link '(custom-manual "(gnus)Customizing Articles")
1027 :type gnus-article-treat-custom)
1029 (defcustom gnus-treat-highlight-headers 'head
1030 "Highlight the headers.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-head-custom)
1036 (put 'gnus-treat-highlight-headers 'highlight t)
1038 (defcustom gnus-treat-highlight-citation t
1039 "Highlight cited text.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-custom)
1045 (put 'gnus-treat-highlight-citation 'highlight t)
1047 (defcustom gnus-treat-date-ut nil
1048 "Display the Date in UT (GMT).
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-head-custom)
1055 (defcustom gnus-treat-date-local nil
1056 "Display the Date in the local timezone.
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-head-custom)
1063 (defcustom gnus-treat-date-english nil
1064 "Display the Date in a format that can be read aloud in English.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-head-custom)
1071 (defcustom gnus-treat-date-lapsed nil
1072 "Display the Date header in a way that says how much time has elapsed.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-head-custom)
1079 (defcustom gnus-treat-date-original nil
1080 "Display the date in the original timezone.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-head-custom)
1087 (defcustom gnus-treat-date-iso8601 nil
1088 "Display the date in the ISO8601 format.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-head-custom)
1096 (defcustom gnus-treat-date-user-defined nil
1097 "Display the date in a user-defined format.
1098 The format is defined by the `gnus-article-time-format' variable.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-head-custom)
1105 (defcustom gnus-treat-strip-headers-in-body t
1106 "Strip the X-No-Archive header line from the beginning of the body.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-strip-trailing-blank-lines nil
1115 "Strip trailing blank lines.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-strip-leading-blank-lines nil
1123 "Strip leading blank lines.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-strip-multiple-blank-lines nil
1131 "Strip multiple blank lines.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-unfold-headers 'head
1139 "Unfold folded header lines.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1146 (defcustom gnus-treat-fold-headers nil
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom)
1154 (defcustom gnus-treat-fold-newsgroups 'head
1155 "Fold the Newsgroups and Followup-To headers.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1162 (defcustom gnus-treat-overstrike t
1163 "Treat overstrike highlighting.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-custom)
1169 (put 'gnus-treat-overstrike 'highlight t)
1171 (defcustom gnus-treat-display-xface
1172 (and (not noninteractive)
1173 (or (and (fboundp 'image-type-available-p)
1174 (image-type-available-p 'xbm)
1175 (string-match "^0x" (shell-command-to-string "uncompface")))
1176 (and (featurep 'xemacs)
1178 (eq 'x-face-mule-gnus-article-display-x-face
1179 gnus-article-x-face-command))
1181 "Display X-Face headers.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' and Info node
1184 `(gnus)X-Face' for details."
1185 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :link '(custom-manual "(gnus)X-Face")
1189 :type gnus-article-treat-head-custom)
1190 (put 'gnus-treat-display-xface 'highlight t)
1192 (defcustom gnus-article-should-use-smiley-mule
1193 (not (or (featurep 'xemacs)
1194 (gnus-image-type-available-p 'xpm)
1195 (gnus-image-type-available-p 'pbm)))
1196 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1197 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1198 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1199 even if you are using Emacs 21+. It has no effect on XEmacs."
1200 :group 'gnus-article-various
1202 :get (lambda (symbol)
1203 (and (default-value symbol)
1204 (not (featurep 'xemacs))
1205 (module-installed-p 'smiley-mule)
1207 :set (lambda (symbol value)
1208 (set-default symbol (and value
1209 (not (featurep 'xemacs))
1210 (module-installed-p 'smiley-mule)
1213 (defvar gnus-article-smiley-mule-loaded-p nil
1214 "Internal variable used to say whether `smiley-mule' is loaded (whether
1215 smiley functions are not overridden by `smiley').")
1217 (defcustom gnus-treat-display-grey-xface
1218 (and (not noninteractive)
1219 (or (featurep 'xemacs)
1220 (and (fboundp 'display-images-p)
1221 (display-images-p)))
1222 (string-match "^0x" (shell-command-to-string "uncompface"))
1224 "Display grey X-Face headers.
1225 Valid values are nil, t."
1226 :group 'gnus-article-treat
1229 (put 'gnus-treat-display-grey-xface 'highlight t)
1231 (defcustom gnus-treat-display-smileys
1232 (if (or (and (featurep 'xemacs)
1234 (gnus-image-type-available-p 'xpm)
1235 (gnus-image-type-available-p 'pbm)
1236 (and (not (featurep 'xemacs))
1238 (module-installed-p 'smiley-mule)))
1242 Valid values are nil, t, `head', `last', an integer or a predicate.
1243 See Info node `(gnus)Customizing Articles' and Info node
1244 `(gnus)Smileys' for details."
1245 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :link '(custom-manual "(gnus)Smileys")
1249 :type gnus-article-treat-custom)
1250 (put 'gnus-treat-display-smileys 'highlight t)
1252 (defcustom gnus-treat-from-picon
1253 (if (and (gnus-image-type-available-p 'xpm)
1254 (gnus-picons-installed-p))
1256 "Display picons in the From header.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' and Info node
1259 `(gnus)Picons' for details."
1260 :group 'gnus-article-treat
1262 :link '(custom-manual "(gnus)Customizing Articles")
1263 :link '(custom-manual "(gnus)Picons")
1264 :type gnus-article-treat-head-custom)
1265 (put 'gnus-treat-from-picon 'highlight t)
1267 (defcustom gnus-treat-mail-picon
1268 (if (and (gnus-image-type-available-p 'xpm)
1269 (gnus-picons-installed-p))
1271 "Display picons in To and Cc headers.
1272 Valid values are nil, t, `head', `last', an integer or a predicate.
1273 See Info node `(gnus)Customizing Articles' and Info node
1274 `(gnus)Picons' for details."
1275 :group 'gnus-article-treat
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :link '(custom-manual "(gnus)Picons")
1279 :type gnus-article-treat-head-custom)
1280 (put 'gnus-treat-mail-picon 'highlight t)
1282 (defcustom gnus-treat-newsgroups-picon
1283 (if (and (gnus-image-type-available-p 'xpm)
1284 (gnus-picons-installed-p))
1286 "Display picons in the Newsgroups and Followup-To headers.
1287 Valid values are nil, t, `head', `last', an integer or a predicate.
1288 See Info node `(gnus)Customizing Articles' and Info node
1289 `(gnus)Picons' for details."
1290 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :link '(custom-manual "(gnus)Picons")
1294 :type gnus-article-treat-head-custom)
1295 (put 'gnus-treat-newsgroups-picon 'highlight t)
1297 (defcustom gnus-treat-body-boundary
1298 (if (or gnus-treat-newsgroups-picon
1299 gnus-treat-mail-picon
1300 gnus-treat-from-picon)
1302 "Draw a boundary at the end of the headers.
1303 Valid values are nil, t, `head', `last', an integer or a predicate.
1304 See Info node `(gnus)Customizing Articles' for details."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-custom)
1310 (defcustom gnus-treat-capitalize-sentences nil
1311 "Capitalize sentence-starting words.
1312 Valid values are nil, t, `head', `last', an integer or a predicate.
1313 See Info node `(gnus)Customizing Articles' for details."
1315 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-custom)
1319 (defcustom gnus-treat-fill-long-lines nil
1321 Valid values are nil, t, `head', `last', an integer or a predicate.
1322 See Info node `(gnus)Customizing Articles' for details."
1323 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :type gnus-article-treat-custom)
1327 (defcustom gnus-treat-play-sounds nil
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' for details."
1332 :group 'gnus-article-treat
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-custom)
1336 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1337 "Decode an article as `default-mime-charset'. For instance, if you want to
1338 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1339 you could set this variable to something like: nil for don't decode, t for
1340 decode the body, '(or header t) for the whole article, etc."
1341 :group 'gnus-article-treat
1342 :type '(radio (const :tag "Off" nil)
1343 (const :tag "Decode body" t)
1344 (const :tag "Decode all" (or head t))))
1346 (defcustom gnus-treat-translate nil
1347 "Translate articles from one language to another.
1348 Valid values are nil, t, `head', `last', an integer or a predicate.
1349 See Info node `(gnus)Customizing Articles' for details."
1351 :group 'gnus-article-treat
1352 :link '(custom-manual "(gnus)Customizing Articles")
1353 :type gnus-article-treat-custom)
1355 (defcustom gnus-treat-x-pgp-sig nil
1357 To automatically treat X-PGP-Sig, set it to head.
1358 Valid values are nil, t, `head', `last', an integer or a predicate.
1359 See Info node `(gnus)Customizing Articles' for details."
1360 :group 'gnus-article-treat
1361 :group 'mime-security
1362 :type gnus-article-treat-custom)
1364 (defcustom gnus-treat-monafy nil
1365 "Display body part with mona font.
1366 Valid values are nil, t, `head', `last', an integer or a predicate.
1367 See Info node `(gnus)Customizing Articles' for details."
1368 :group 'gnus-article-treat
1369 :group 'mime-security
1370 :link '(custom-manual "(gnus)Customizing Articles")
1371 :type gnus-article-treat-custom)
1373 (defvar gnus-article-encrypt-protocol-alist
1374 '(("PGP" . mml2015-self-encrypt)))
1376 ;; Set to nil if more than one protocol added to
1377 ;; gnus-article-encrypt-protocol-alist.
1378 (defcustom gnus-article-encrypt-protocol "PGP"
1379 "The protocol used for encrypt articles.
1380 It is a string, such as \"PGP\". If nil, ask user."
1382 :group 'mime-security)
1384 (defvar gnus-article-wash-function nil
1385 "Function used for converting HTML into text.")
1387 ;;; Internal variables
1389 (defvar gnus-english-month-names
1390 '("January" "February" "March" "April" "May" "June" "July" "August"
1391 "September" "October" "November" "December"))
1393 (defvar article-goto-body-goes-to-point-min-p nil)
1394 (defvar gnus-article-wash-types nil)
1395 (defvar gnus-article-emphasis-alist nil)
1396 (defvar gnus-article-image-alist nil)
1398 (defvar gnus-article-mime-handle-alist-1 nil)
1399 (defvar gnus-treatment-function-alist
1400 '((gnus-treat-decode-article-as-default-mime-charset
1401 gnus-article-decode-article-as-default-mime-charset)
1402 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1403 (gnus-treat-monafy gnus-article-monafy)
1404 (gnus-treat-strip-banner gnus-article-strip-banner)
1405 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1406 (gnus-treat-buttonize gnus-article-add-buttons)
1407 (gnus-treat-fill-article gnus-article-fill-cited-article)
1408 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1409 (gnus-treat-strip-cr gnus-article-remove-cr)
1410 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1411 (gnus-treat-date-ut gnus-article-date-ut)
1412 (gnus-treat-date-local gnus-article-date-local)
1413 (gnus-treat-date-english gnus-article-date-english)
1414 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1415 (gnus-treat-date-original gnus-article-date-original)
1416 (gnus-treat-date-user-defined gnus-article-date-user)
1417 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1418 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1419 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1420 (gnus-treat-hide-signature gnus-article-hide-signature)
1421 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1422 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1423 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1424 (gnus-treat-strip-pem gnus-article-hide-pem)
1425 (gnus-treat-from-picon gnus-treat-from-picon)
1426 (gnus-treat-mail-picon gnus-treat-mail-picon)
1427 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1428 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1429 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1430 (gnus-treat-strip-trailing-blank-lines
1431 gnus-article-remove-trailing-blank-lines)
1432 (gnus-treat-strip-leading-blank-lines
1433 gnus-article-strip-leading-blank-lines)
1434 (gnus-treat-strip-multiple-blank-lines
1435 gnus-article-strip-multiple-blank-lines)
1436 (gnus-treat-overstrike gnus-article-treat-overstrike)
1437 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1438 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1439 ;; Displaying X-Face should be done after unfolding headers
1440 ;; to protect bitmap lines.
1441 (gnus-treat-display-xface gnus-article-display-x-face)
1442 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1443 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1444 (gnus-treat-display-smileys gnus-treat-smiley)
1445 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1446 (gnus-treat-emphasize gnus-article-emphasize)
1447 (gnus-treat-hide-citation gnus-article-hide-citation)
1448 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1449 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1450 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1451 (gnus-treat-play-sounds gnus-earcon-display)))
1453 (defvar gnus-article-mime-handle-alist nil)
1454 (defvar article-lapsed-timer nil)
1455 (defvar gnus-article-current-summary nil)
1457 (defvar gnus-article-mode-syntax-table
1458 (let ((table (copy-syntax-table text-mode-syntax-table)))
1459 ;; This causes the citation match run O(2^n).
1460 ;; (modify-syntax-entry ?- "w" table)
1461 (modify-syntax-entry ?> ")<" table)
1462 (modify-syntax-entry ?< "(>" table)
1463 ;; make M-. in article buffers work for `foo' strings
1464 (modify-syntax-entry ?' " " table)
1465 (modify-syntax-entry ?` " " table)
1467 "Syntax table used in article mode buffers.
1468 Initialized from `text-mode-syntax-table.")
1470 (defvar gnus-save-article-buffer nil)
1472 (defvar gnus-article-mode-line-format-alist
1473 (nconc '((?w (gnus-article-wash-status) ?s)
1474 (?m (gnus-article-mime-part-status) ?s))
1475 gnus-summary-mode-line-format-alist))
1477 (defvar gnus-number-of-articles-to-be-saved nil)
1479 (defvar gnus-inhibit-hiding nil)
1481 ;;; Macros for dealing with the article buffer.
1483 (defmacro gnus-with-article-headers (&rest forms)
1485 (set-buffer gnus-article-buffer)
1487 (let ((buffer-read-only nil)
1488 (inhibit-point-motion-hooks t)
1489 (case-fold-search t))
1490 (article-narrow-to-head)
1493 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1494 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1496 (defmacro gnus-with-article-buffer (&rest forms)
1498 (set-buffer gnus-article-buffer)
1499 (let ((buffer-read-only nil))
1502 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1503 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1505 (defun gnus-article-goto-header (header)
1506 "Go to HEADER, which is a regular expression."
1507 (re-search-forward (concat "^\\(" header "\\):") nil t))
1509 (defsubst gnus-article-hide-text (b e props)
1510 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1511 (gnus-add-text-properties-when 'article-type nil b e props)
1512 (when (memq 'intangible props)
1514 (max (1- b) (point-min))
1515 b 'intangible (cddr (memq 'intangible props)))))
1517 (defsubst gnus-article-unhide-text (b e)
1518 "Remove hidden text properties from region between B and E."
1519 (remove-text-properties b e gnus-hidden-properties)
1520 (when (memq 'intangible gnus-hidden-properties)
1521 (put-text-property (max (1- b) (point-min))
1522 b 'intangible nil)))
1524 (defun gnus-article-hide-text-type (b e type)
1525 "Hide text of TYPE between B and E."
1526 (gnus-add-wash-type type)
1527 (gnus-article-hide-text
1528 b e (cons 'article-type (cons type gnus-hidden-properties))))
1530 (defun gnus-article-unhide-text-type (b e type)
1531 "Unhide text of TYPE between B and E."
1532 (gnus-delete-wash-type type)
1533 (remove-text-properties
1534 b e (cons 'article-type (cons type gnus-hidden-properties)))
1535 (when (memq 'intangible gnus-hidden-properties)
1536 (put-text-property (max (1- b) (point-min))
1537 b 'intangible nil)))
1539 (defun gnus-article-hide-text-of-type (type)
1540 "Hide text of TYPE in the current buffer."
1542 (let ((b (point-min))
1544 (while (setq b (text-property-any b e 'article-type type))
1545 (add-text-properties b (incf b) gnus-hidden-properties)))))
1547 (defun gnus-article-delete-text-of-type (type)
1548 "Delete text of TYPE in the current buffer."
1550 (let ((b (point-min)))
1551 (while (setq b (text-property-any b (point-max) 'article-type type))
1553 b (or (text-property-not-all b (point-max) 'article-type type)
1556 (defun gnus-article-delete-invisible-text ()
1557 "Delete all invisible text in the current buffer."
1559 (let ((b (point-min)))
1560 (while (setq b (text-property-any b (point-max) 'invisible t))
1562 b (or (text-property-not-all b (point-max) 'invisible t)
1565 (defun gnus-article-text-type-exists-p (type)
1566 "Say whether any text of type TYPE exists in the buffer."
1567 (text-property-any (point-min) (point-max) 'article-type type))
1569 (defsubst gnus-article-header-rank ()
1570 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1571 (let ((list gnus-sorted-header-list)
1574 (when (looking-at (car list))
1576 (setq list (cdr list))
1580 (defun article-hide-headers (&optional arg delete)
1581 "Hide unwanted headers and possibly sort them as well."
1582 (interactive (gnus-article-hidden-arg))
1583 ;; Lars said that this function might be inhibited.
1584 (if (gnus-article-check-hidden-text 'headers arg)
1586 ;; Show boring headers as well.
1587 (gnus-article-show-hidden-text 'boring-headers)
1588 (when (eq 1 (point-min))
1589 (set-window-start (get-buffer-window (current-buffer)) 1)))
1590 (unless gnus-inhibit-hiding
1593 (let ((inhibit-read-only t)
1594 (case-fold-search t)
1595 (max (1+ (length gnus-sorted-header-list)))
1596 (ignored (when (not gnus-visible-headers)
1597 (cond ((stringp gnus-ignored-headers)
1598 gnus-ignored-headers)
1599 ((listp gnus-ignored-headers)
1600 (mapconcat 'identity gnus-ignored-headers
1603 (cond ((stringp gnus-visible-headers)
1604 gnus-visible-headers)
1605 ((and gnus-visible-headers
1606 (listp gnus-visible-headers))
1607 (mapconcat 'identity gnus-visible-headers "\\|"))))
1608 (inhibit-point-motion-hooks t)
1610 ;; First we narrow to just the headers.
1611 (article-narrow-to-head)
1612 ;; Hide any "From " lines at the beginning of (mail) articles.
1613 (while (looking-at "From ")
1617 (delete-region (point-min) (point))
1618 (gnus-article-hide-text (point-min) (point)
1619 (nconc (list 'article-type 'headers)
1620 gnus-hidden-properties))))
1621 ;; Then treat the rest of the header lines.
1622 ;; Then we use the two regular expressions
1623 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1624 ;; select which header lines is to remain visible in the
1626 (while (re-search-forward "^[^ \t:]*:" nil t)
1628 ;; Mark the rank of the header.
1630 (point) (1+ (point)) 'message-rank
1631 (if (or (and visible (looking-at visible))
1633 (not (looking-at ignored))))
1634 (gnus-article-header-rank)
1637 (message-sort-headers-1)
1638 (when (setq beg (text-property-any
1639 (point-min) (point-max) 'message-rank (+ 2 max)))
1640 ;; We delete or make invisible the unwanted headers.
1641 (gnus-add-wash-type 'headers)
1644 (add-text-properties
1645 (point-min) (+ 5 (point-min))
1646 '(article-type headers dummy-invisible t))
1647 (delete-region beg (point-max)))
1648 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1650 (defun article-hide-boring-headers (&optional arg)
1651 "Toggle hiding of headers that aren't very interesting.
1652 If given a negative prefix, always show; if given a positive prefix,
1654 (interactive (gnus-article-hidden-arg))
1655 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1656 (not gnus-show-all-headers))
1659 (let ((buffer-read-only nil)
1660 (list gnus-boring-article-headers)
1661 (inhibit-point-motion-hooks t)
1663 (article-narrow-to-head)
1665 (setq elem (pop list))
1666 (goto-char (point-min))
1668 ;; Hide empty headers.
1670 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1672 (gnus-article-hide-text-type
1673 (progn (beginning-of-line) (point))
1676 (if (re-search-forward "^[^ \t]" nil t)
1680 ;; Hide boring Newsgroups header.
1681 ((eq elem 'newsgroups)
1682 (when (gnus-string-equal
1683 (gnus-fetch-field "newsgroups")
1684 (gnus-group-real-name
1685 (if (boundp 'gnus-newsgroup-name)
1688 (gnus-article-hide-header "newsgroups")))
1689 ((eq elem 'to-address)
1690 (let ((to (message-fetch-field "to"))
1692 (gnus-parameter-to-address
1693 (if (boundp 'gnus-newsgroup-name)
1694 gnus-newsgroup-name ""))))
1695 (when (and to to-address
1698 ;; only one address in To
1699 (nth 1 (mail-extract-address-components to))
1701 (gnus-article-hide-header "to"))))
1702 ((eq elem 'followup-to)
1703 (when (gnus-string-equal
1704 (message-fetch-field "followup-to")
1705 (message-fetch-field "newsgroups"))
1706 (gnus-article-hide-header "followup-to")))
1707 ((eq elem 'reply-to)
1708 (let ((from (message-fetch-field "from"))
1709 (reply-to (message-fetch-field "reply-to")))
1714 (nth 1 (mail-extract-address-components from))
1715 (nth 1 (mail-extract-address-components reply-to)))))
1716 (gnus-article-hide-header "reply-to"))))
1718 (let ((date (message-fetch-field "date")))
1720 (< (days-between (current-time-string) date)
1722 (gnus-article-hide-header "date"))))
1724 (let ((to (message-fetch-field "to"))
1725 (cc (message-fetch-field "cc")))
1726 (when (> (length to) 1024)
1727 (gnus-article-hide-header "to"))
1728 (when (> (length cc) 1024)
1729 (gnus-article-hide-header "cc"))))
1733 (goto-char (point-min))
1734 (while (re-search-forward "^to:" nil t)
1735 (setq to-count (1+ to-count)))
1736 (when (> to-count 1)
1737 (while (> to-count 0)
1738 (goto-char (point-min))
1740 (re-search-forward "^to:" nil nil to-count)
1742 (narrow-to-region (point) (point-max))
1743 (gnus-article-hide-header "to"))
1744 (setq to-count (1- to-count))))
1745 (goto-char (point-min))
1746 (while (re-search-forward "^cc:" nil t)
1747 (setq cc-count (1+ cc-count)))
1748 (when (> cc-count 1)
1749 (while (> cc-count 0)
1750 (goto-char (point-min))
1752 (re-search-forward "^cc:" nil nil cc-count)
1754 (narrow-to-region (point) (point-max))
1755 (gnus-article-hide-header "cc"))
1756 (setq cc-count (1- cc-count)))))))))))))
1758 (defun gnus-article-hide-header (header)
1760 (goto-char (point-min))
1761 (when (re-search-forward (concat "^" header ":") nil t)
1762 (gnus-article-hide-text-type
1763 (progn (beginning-of-line) (point))
1766 (if (re-search-forward "^[^ \t]" nil t)
1771 (defvar gnus-article-normalized-header-length 40
1772 "Length of normalized headers.")
1774 (defun article-normalize-headers ()
1775 "Make all header lines 40 characters long."
1777 (let ((buffer-read-only nil)
1781 (article-narrow-to-head)
1784 ((< (setq column (- (gnus-point-at-eol) (point)))
1785 gnus-article-normalized-header-length)
1787 (insert (make-string
1788 (- gnus-article-normalized-header-length column)
1790 ((> column gnus-article-normalized-header-length)
1791 (gnus-put-text-property
1793 (forward-char gnus-article-normalized-header-length)
1800 (forward-line 1))))))
1802 (defun article-treat-dumbquotes ()
1803 "Translate M****s*** sm*rtq**t*s into proper text.
1804 Note that this function guesses whether a character is a sm*rtq**t* or
1805 not, so it should only be used interactively.
1807 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1808 in an attempt to provide more quoting characters. If you see
1809 something like \\222 or \\264 where you're expecting some kind of
1810 apostrophe or quotation mark, then try this wash."
1812 (article-translate-strings gnus-article-dumbquotes-map))
1814 (defun article-translate-characters (from to)
1815 "Translate all characters in the body of the article according to FROM and TO.
1816 FROM is a string of characters to translate from; to is a string of
1817 characters to translate to."
1819 (when (article-goto-body)
1820 (let ((buffer-read-only nil)
1821 (x (make-string 225 ?x))
1823 (while (< (incf i) (length x))
1826 (while (< i (length from))
1827 (aset x (aref from i) (aref to i))
1829 (translate-region (point) (point-max) x)))))
1831 (defun article-translate-strings (map)
1832 "Translate all string in the body of the article according to MAP.
1833 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1835 (when (article-goto-body)
1836 (let ((buffer-read-only nil)
1838 (while (setq elem (pop map))
1840 (while (search-forward (car elem) nil t)
1841 (replace-match (cadr elem)))))))))
1843 (defun article-treat-overstrike ()
1844 "Translate overstrikes into bold text."
1847 (when (article-goto-body)
1848 (let ((buffer-read-only nil))
1849 (while (search-forward "\b" nil t)
1850 (let ((next (char-after))
1854 previous (char-after))
1858 ;; We do the boldification/underlining by hiding the
1859 ;; overstrikes and putting the proper text property
1863 (gnus-article-hide-text-type start (point) 'overstrike)
1864 (put-text-property (point) end 'face 'bold))
1866 (gnus-article-hide-text-type
1867 (1- (point)) (1+ (point)) 'overstrike)
1869 start (1- (point)) 'face 'underline))
1871 (gnus-article-hide-text-type start (point) 'overstrike)
1873 (point) end 'face 'underline)))))))))
1875 (defun gnus-article-treat-unfold-headers ()
1876 "Unfold folded message headers.
1877 Only the headers that fit into the current window width will be
1880 (gnus-with-article-headers
1884 (mail-header-narrow-to-field)
1885 (let ((header (buffer-substring (point-min) (point-max))))
1888 (goto-char (point-min))
1889 (while (re-search-forward "\n[\t ]" nil t)
1890 (replace-match " " t t)))
1891 (setq length (- (point-max) (point-min) 1)))
1892 (when (< length (window-width))
1893 (while (re-search-forward "\n[\t ]" nil t)
1894 (replace-match " " t t)))
1895 (goto-char (point-max)))))))
1897 (defun gnus-article-treat-fold-headers ()
1898 "Fold message headers."
1900 (gnus-with-article-headers
1903 (mail-header-narrow-to-field)
1904 (mail-header-fold-field)
1905 (goto-char (point-max))))))
1907 (defun gnus-treat-smiley ()
1908 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1910 (unless (featurep 'xemacs)
1911 (when (and (>= emacs-major-version 21)
1912 (not gnus-article-should-use-smiley-mule)
1913 gnus-article-smiley-mule-loaded-p)
1914 (load "smiley" nil t)
1915 (setq gnus-article-smiley-mule-loaded-p nil))
1916 (when (and gnus-article-should-use-smiley-mule
1917 (not gnus-article-smiley-mule-loaded-p))
1918 (load "smiley-mule" nil t)
1919 (setq gnus-article-smiley-mule-loaded-p t)))
1920 (gnus-with-article-buffer
1921 (if (memq 'smiley gnus-article-wash-types)
1922 (gnus-delete-images 'smiley)
1924 (let ((images (smiley-region (point) (point-max))))
1926 (gnus-add-wash-type 'smiley)
1927 (dolist (image images)
1928 (gnus-add-image 'smiley image)))))))
1930 (defun gnus-article-remove-images ()
1931 "Remove all images from the article buffer."
1933 (gnus-with-article-buffer
1934 (dolist (elem gnus-article-image-alist)
1935 (gnus-delete-images (car elem)))))
1937 (defun gnus-article-treat-fold-newsgroups ()
1938 "Unfold folded message headers.
1939 Only the headers that fit into the current window width will be
1942 (gnus-with-article-headers
1943 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1945 (mail-header-narrow-to-field)
1946 (while (re-search-forward ", *" nil t)
1947 (replace-match ", " t t))
1948 (mail-header-fold-field)
1949 (goto-char (point-max))))))
1951 (defun gnus-article-treat-body-boundary ()
1952 "Place a boundary line at the end of the headers."
1954 (when (and gnus-body-boundary-delimiter
1955 (> (length gnus-body-boundary-delimiter) 0))
1956 (gnus-with-article-headers
1957 (goto-char (point-max))
1958 (let ((start (point)))
1959 (insert "X-Boundary: ")
1960 (gnus-add-text-properties start (point) '(invisible t intangible t))
1962 (while (>= (1- (window-width)) (length str))
1963 (setq str (concat str gnus-body-boundary-delimiter)))
1964 (substring str 0 (1- (window-width))))
1966 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1968 (defun article-fill-long-lines ()
1969 "Fill lines that are wider than the window width."
1972 (let ((buffer-read-only nil)
1973 (width (window-width (get-buffer-window (current-buffer)))))
1976 (let ((adaptive-fill-mode nil)) ;Why? -sm
1979 (when (>= (current-column) (min fill-column width))
1980 (narrow-to-region (min (1+ (point)) (point-max))
1981 (gnus-point-at-bol))
1982 (let ((goback (point-marker)))
1983 (fill-paragraph nil)
1984 (goto-char (marker-position goback)))
1986 (forward-line 1)))))))
1988 (defun article-capitalize-sentences ()
1989 "Capitalize the first word in each sentence."
1992 (let ((buffer-read-only nil)
1993 (paragraph-start "^[\n\^L]"))
1997 (forward-sentence)))))
1999 (defun article-remove-cr ()
2000 "Remove trailing CRs and then translate remaining CRs into LFs."
2003 (let ((buffer-read-only nil))
2004 (goto-char (point-min))
2005 (while (re-search-forward "\r+$" nil t)
2006 (replace-match "" t t))
2007 (goto-char (point-min))
2008 (while (search-forward "\r" nil t)
2009 (replace-match "\n" t t)))))
2011 (defun article-remove-trailing-blank-lines ()
2012 "Remove all trailing blank lines from the article."
2015 (let ((buffer-read-only nil))
2016 (goto-char (point-max))
2020 (while (and (not (bobp))
2021 (looking-at "^[ \t]*$")
2022 (not (gnus-annotation-in-region-p
2023 (point) (gnus-point-at-eol))))
2028 (defun article-display-x-face (&optional force)
2029 "Look for an X-Face header and display it if present."
2030 (interactive (list 'force))
2031 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2032 (gnus-with-article-headers
2033 ;; Delete the old process, if any.
2034 (when (process-status "article-x-face")
2035 (delete-process "article-x-face"))
2036 (if (memq 'xface gnus-article-wash-types)
2037 ;; We have already displayed X-Faces, so we remove them
2039 (gnus-delete-images 'xface)
2041 (let (x-faces from face grey)
2043 (when (and wash-face-p
2045 (goto-char (point-min))
2046 (not (re-search-forward
2047 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2048 (gnus-buffer-live-p gnus-original-article-buffer))
2049 ;; If type `W f', use gnus-original-article-buffer,
2050 ;; otherwise use the current buffer because displaying
2051 ;; RFC822 parts calls this function too.
2052 (set-buffer gnus-original-article-buffer))
2054 (mail-narrow-to-head)
2055 (if gnus-treat-display-grey-xface
2057 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2058 (if (match-beginning 2)
2061 (push (cons (- (string-to-number (match-string 2)))
2062 (mail-header-field-value))
2064 (push (cons 0 (mail-header-field-value)) x-faces)))
2065 (dolist (x-face (prog1
2067 (sort x-faces 'car-less-than-car)
2069 (setq x-faces nil)))
2070 (push (cdr x-face) x-faces)))
2071 (while (gnus-article-goto-header "X-Face")
2072 (push (mail-header-field-value) x-faces)))
2073 (setq from (message-fetch-field "from"))))
2075 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2078 (setq image (gnus-create-image xpm 'xpm t))
2079 (gnus-article-goto-header "from")
2081 (insert "From: [no `from' set]\n")
2083 (gnus-add-wash-type 'xface)
2084 (gnus-add-image 'xface image)
2085 (gnus-put-image image)))
2086 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2087 ;; single external face.
2088 (when (stringp gnus-article-x-face-command)
2089 (setq x-faces (list (car x-faces))))
2090 (while (and (setq face (pop x-faces))
2091 gnus-article-x-face-command
2093 ;; Check whether this face is censored.
2094 (not gnus-article-x-face-too-ugly)
2095 (and gnus-article-x-face-too-ugly from
2096 (not (string-match gnus-article-x-face-too-ugly
2098 ;; We display the face.
2099 (if (symbolp gnus-article-x-face-command)
2100 ;; The command is a lisp function, so we call it.
2101 (if (gnus-functionp gnus-article-x-face-command)
2102 (funcall gnus-article-x-face-command face)
2103 (error "%s is not a function" gnus-article-x-face-command))
2104 ;; The command is a string, so we interpret the command
2105 ;; as a, well, command, and fork it off.
2106 (let ((process-connection-type nil))
2107 (process-kill-without-query
2109 "article-x-face" nil shell-file-name shell-command-switch
2110 gnus-article-x-face-command))
2113 (process-send-region "article-x-face"
2114 (point-min) (point-max)))
2115 (process-send-eof "article-x-face"))))))))))
2117 (defun article-decode-mime-words ()
2118 "Decode all MIME-encoded words in the article."
2121 (set-buffer gnus-article-buffer)
2122 (let ((inhibit-point-motion-hooks t)
2124 (mail-parse-charset gnus-newsgroup-charset)
2125 (mail-parse-ignored-charsets
2126 (save-excursion (set-buffer gnus-summary-buffer)
2127 gnus-newsgroup-ignored-charsets)))
2128 (mail-decode-encoded-word-region (point-min) (point-max)))))
2130 (defun article-decode-charset (&optional prompt)
2131 "Decode charset-encoded text in the article.
2132 If PROMPT (the prefix), prompt for a coding system to use."
2134 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2136 (mail-parse-charset gnus-newsgroup-charset)
2137 (mail-parse-ignored-charsets
2138 (save-excursion (condition-case nil
2139 (set-buffer gnus-summary-buffer)
2141 gnus-newsgroup-ignored-charsets))
2142 ct cte ctl charset format)
2145 (article-narrow-to-head)
2146 (setq ct (message-fetch-field "Content-Type" t)
2147 cte (message-fetch-field "Content-Transfer-Encoding" t)
2148 ctl (and ct (ignore-errors
2149 (mail-header-parse-content-type ct)))
2152 (mm-read-coding-system "Charset to decode: "))
2154 (mail-content-type-get ctl 'charset)))
2155 format (and ctl (mail-content-type-get ctl 'format)))
2157 (setq cte (mail-header-strip cte)))
2158 (if (and ctl (not (string-match "/" (car ctl))))
2160 (goto-char (point-max)))
2163 (narrow-to-region (point) (point-max))
2164 (when (and (eq mail-parse-charset 'gnus-decoded)
2165 (eq (mm-body-7-or-8) '8bit))
2166 ;; The text code could have been decoded.
2167 (setq charset mail-parse-charset))
2168 (when (and (or (not ctl)
2169 (equal (car ctl) "text/plain"))
2170 (not format)) ;; article with format will decode later.
2172 charset (and cte (intern (downcase
2173 (gnus-strip-whitespace cte))))
2176 (defun article-decode-encoded-words ()
2177 "Remove encoded-word encoding from headers."
2178 (let (buffer-read-only)
2179 (let ((charset (save-excursion
2180 (set-buffer gnus-summary-buffer)
2181 default-mime-charset)))
2182 (mime-decode-header-in-buffer charset))))
2184 (defun article-decode-group-name ()
2185 "Decode group names in `Newsgroups:'."
2186 (let ((inhibit-point-motion-hooks t)
2188 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2189 (when (and (or gnus-group-name-charset-method-alist
2190 gnus-group-name-charset-group-alist)
2191 (gnus-buffer-live-p gnus-original-article-buffer))
2192 (when (nnmail-fetch-field "Newsgroups")
2193 (nnheader-replace-header "Newsgroups"
2194 (gnus-decode-newsgroups
2195 (with-current-buffer
2196 gnus-original-article-buffer
2197 (nnmail-fetch-field "Newsgroups"))
2198 gnus-newsgroup-name method)))
2199 (when (nnmail-fetch-field "Followup-To")
2200 (nnheader-replace-header "Followup-To"
2201 (gnus-decode-newsgroups
2202 (with-current-buffer
2203 gnus-original-article-buffer
2204 (nnmail-fetch-field "Followup-To"))
2205 gnus-newsgroup-name method))))))
2207 (defun article-de-quoted-unreadable (&optional force read-charset)
2208 "Translate a quoted-printable-encoded article.
2209 If FORCE, decode the article whether it is marked as quoted-printable
2211 If READ-CHARSET, ask for a coding system."
2212 (interactive (list 'force current-prefix-arg))
2214 (let ((buffer-read-only nil) type charset)
2215 (if (gnus-buffer-live-p gnus-original-article-buffer)
2216 (with-current-buffer gnus-original-article-buffer
2218 (gnus-fetch-field "content-transfer-encoding"))
2219 (let* ((ct (gnus-fetch-field "content-type"))
2222 (mail-header-parse-content-type ct)))))
2223 (setq charset (and ctl
2224 (mail-content-type-get ctl 'charset)))
2225 (if (stringp charset)
2226 (setq charset (intern (downcase charset)))))))
2228 (setq charset (mm-read-coding-system "Charset: " charset)))
2230 (setq charset gnus-newsgroup-charset))
2232 (and type (let ((case-fold-search t))
2233 (string-match "quoted-printable" type))))
2235 (quoted-printable-decode-region
2236 (point) (point-max) (mm-charset-to-coding-system charset))))))
2238 (defun article-de-base64-unreadable (&optional force read-charset)
2239 "Translate a base64 article.
2240 If FORCE, decode the article whether it is marked as base64 not.
2241 If READ-CHARSET, ask for a coding system."
2242 (interactive (list 'force current-prefix-arg))
2244 (let ((buffer-read-only nil) type charset)
2245 (if (gnus-buffer-live-p gnus-original-article-buffer)
2246 (with-current-buffer gnus-original-article-buffer
2248 (gnus-fetch-field "content-transfer-encoding"))
2249 (let* ((ct (gnus-fetch-field "content-type"))
2252 (mail-header-parse-content-type ct)))))
2253 (setq charset (and ctl
2254 (mail-content-type-get ctl 'charset)))
2255 (if (stringp charset)
2256 (setq charset (intern (downcase charset)))))))
2258 (setq charset (mm-read-coding-system "Charset: " charset)))
2260 (setq charset gnus-newsgroup-charset))
2262 (and type (let ((case-fold-search t))
2263 (string-match "base64" type))))
2266 (narrow-to-region (point) (point-max))
2267 (base64-decode-region (point-min) (point-max))
2268 (mm-decode-coding-region
2269 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2274 (defun article-decode-HZ ()
2275 "Translate a HZ-encoded article."
2279 (let ((buffer-read-only nil))
2280 (rfc1843-decode-region (point-min) (point-max)))))
2282 (defun article-unsplit-urls ()
2283 "Remove the newlines that some other mailers insert into URLs."
2286 (let ((buffer-read-only nil))
2287 (goto-char (point-min))
2288 (while (re-search-forward
2289 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2290 (replace-match "\\1\\3" t)))
2291 (when (and gnus-display-mime-function (interactive-p))
2292 (funcall gnus-display-mime-function))))
2295 (defun article-wash-html (&optional read-charset)
2296 "Format an html article.
2297 If READ-CHARSET, ask for a coding system."
2300 (let ((buffer-read-only nil)
2302 (if (gnus-buffer-live-p gnus-original-article-buffer)
2303 (with-current-buffer gnus-original-article-buffer
2304 (let* ((ct (gnus-fetch-field "content-type"))
2307 (mail-header-parse-content-type ct)))))
2308 (setq charset (and ctl
2309 (mail-content-type-get ctl 'charset)))
2310 (if (stringp charset)
2311 (setq charset (intern (downcase charset)))))))
2313 (setq charset (mm-read-coding-system "Charset: " charset)))
2315 (setq charset gnus-newsgroup-charset))
2317 (save-window-excursion
2319 (narrow-to-region (point) (point-max))
2320 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2321 (entry (assq func mm-text-html-washer-alist)))
2323 (setq func (cdr entry)))
2325 ((gnus-functionp func)
2328 (apply (car func) (cdr func))))))))))
2330 (defun gnus-article-wash-html-with-w3 ()
2331 "Wash the current buffer with w3."
2333 (let ((w3-strict-width (window-width))
2334 (url-standalone-mode t)
2335 (url-gateway-unplugged t)
2336 (w3-honor-stylesheets nil))
2338 (w3-region (point-min) (point-max))
2341 (defun gnus-article-wash-html-with-w3m ()
2342 "Wash the current buffer with emacs-w3m."
2345 (narrow-to-region (point) (point-max))
2346 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2349 (w3m-display-inline-images mm-inline-text-html-with-images)
2350 w3m-force-redisplay)
2351 (w3m-region (point-min) (point-max)))
2352 (when mm-inline-text-html-with-w3m-keymap
2353 (add-text-properties
2354 (point-min) (point-max)
2355 (nconc (mm-w3m-local-map-property)
2356 '(mm-inline-text-html-with-w3m t))))))
2358 (defun article-hide-list-identifiers ()
2359 "Remove list identifies from the Subject header.
2360 The `gnus-list-identifiers' variable specifies what to do."
2362 (let ((inhibit-point-motion-hooks t)
2363 (regexp (if (consp gnus-list-identifiers)
2364 (mapconcat 'identity gnus-list-identifiers " *\\|")
2365 gnus-list-identifiers))
2370 (article-narrow-to-head)
2371 (goto-char (point-min))
2372 (while (re-search-forward
2373 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2375 (delete-region (match-beginning 2) (match-end 0))
2376 (beginning-of-line))
2377 (when (re-search-forward
2378 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2379 (delete-region (match-beginning 1) (match-end 1))))))))
2381 (defun article-hide-pgp ()
2382 "Remove any PGP headers and signatures in the current article."
2386 (let ((inhibit-point-motion-hooks t)
2387 buffer-read-only beg end)
2389 ;; Hide the "header".
2390 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2391 (gnus-add-wash-type 'pgp)
2392 (delete-region (match-beginning 0) (match-end 0))
2393 ;; Remove armor headers (rfc2440 6.2)
2394 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2397 ;; Hide the actual signature.
2398 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2399 (setq end (1+ (match-beginning 0)))
2402 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2404 ;; Perhaps we shouldn't hide to the end of the buffer
2405 ;; if there is no end to the signature?
2407 ;; Hide "- " PGP quotation markers.
2409 (narrow-to-region beg end)
2410 (goto-char (point-min))
2411 (while (re-search-forward "^- " nil t)
2413 (match-beginning 0) (match-end 0)))
2415 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2417 (defun article-hide-pem (&optional arg)
2418 "Toggle hiding of any PEM headers and signatures in the current article.
2419 If given a negative prefix, always show; if given a positive prefix,
2421 (interactive (gnus-article-hidden-arg))
2422 (unless (gnus-article-check-hidden-text 'pem arg)
2424 (let (buffer-read-only end)
2425 (goto-char (point-min))
2426 ;; Hide the horrendously ugly "header".
2427 (when (and (search-forward
2428 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2430 (setq end (1+ (match-beginning 0))))
2431 (gnus-add-wash-type 'pem)
2432 (gnus-article-hide-text-type
2434 (if (search-forward "\n\n" nil t)
2438 ;; Hide the trailer as well
2439 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2441 (gnus-article-hide-text-type
2442 (match-beginning 0) (match-end 0) 'pem)))))))
2444 (defun article-strip-banner ()
2445 "Strip the banner specified by the `banner' group parameter."
2449 (let ((inhibit-point-motion-hooks t)
2450 (banner (gnus-parameter-banner gnus-newsgroup-name))
2451 (gnus-signature-limit nil)
2452 buffer-read-only beg end)
2453 (when (and gnus-article-address-banner-alist
2456 (let ((from (save-restriction
2458 (article-narrow-to-head)
2459 (mail-fetch-field "from"))))
2462 (caar (mail-header-parse-addresses from))))
2464 (dolist (pair gnus-article-address-banner-alist)
2465 (when (string-match (car pair) from)
2466 (throw 'found (cdr pair)))))))))
2470 ((eq banner 'signature)
2471 (when (gnus-article-narrow-to-signature)
2474 (delete-region (point) (point-max))))
2476 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2477 (while (re-search-forward banner nil t)
2478 (delete-region (match-beginning 0) (match-end 0)))))
2480 (while (re-search-forward banner nil t)
2481 (delete-region (match-beginning 0) (match-end 0))))))))))
2483 (defun article-babel ()
2484 "Translate article using an online translation service."
2488 (set-buffer gnus-article-buffer)
2489 (when (article-goto-body)
2490 (let* ((buffer-read-only nil)
2493 (orig (buffer-substring start end))
2494 (trans (babel-as-string orig)))
2496 (narrow-to-region start end)
2497 (delete-region start end)
2500 (defun article-hide-signature (&optional arg)
2501 "Hide the signature in the current article.
2502 If given a negative prefix, always show; if given a positive prefix,
2504 (interactive (gnus-article-hidden-arg))
2510 (article-goto-body))
2511 (goto-char (point-min)))
2512 (unless (gnus-article-check-hidden-text 'signature arg)
2513 (let ((buffer-read-only nil)
2515 (while (setq button (text-property-any button (point-max)
2517 'gnus-signature-toggle))
2518 (setq button (text-property-not-all button (point-max)
2520 'gnus-signature-toggle))
2521 (when (and button (not (eobp)))
2522 (gnus-article-hide-text-type
2524 (next-single-property-change (1+ button) 'mime-view-entity
2527 (gnus-set-mode-line 'article))
2529 (defun article-strip-headers-in-body ()
2530 "Strip offensive headers from bodies."
2534 (let ((case-fold-search t))
2535 (when (looking-at "x-no-archive:")
2536 (gnus-delete-line)))))
2538 (defun article-strip-leading-blank-lines ()
2539 "Remove all blank lines from the beginning of the article."
2542 (let ((inhibit-point-motion-hooks t)
2544 (when (article-goto-body)
2545 (while (and (not (eobp))
2546 (looking-at "[ \t]*$"))
2547 (gnus-delete-line))))))
2549 (defun article-narrow-to-head ()
2550 "Narrow the buffer to the head of the message.
2551 Point is left at the beginning of the narrowed-to region."
2553 (goto-char (point-min))
2554 (if (search-forward "\n\n" nil 1)
2557 (goto-char (point-min)))
2559 (defun article-goto-body ()
2560 "Place point at the start of the body."
2561 (goto-char (point-min))
2563 ;; This variable is only bound when dealing with separate
2565 (article-goto-body-goes-to-point-min-p
2567 ((search-forward "\n\n" nil t)
2570 (goto-char (point-max))
2573 (defun article-strip-multiple-blank-lines ()
2574 "Replace consecutive blank lines with one empty line."
2577 (let ((inhibit-point-motion-hooks t)
2579 ;; First make all blank lines empty.
2581 (while (re-search-forward "^[ \t]+$" nil t)
2582 (unless (gnus-annotation-in-region-p
2583 (match-beginning 0) (match-end 0))
2584 (replace-match "" nil t)))
2585 ;; Then replace multiple empty lines with a single empty line.
2587 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2588 (unless (gnus-annotation-in-region-p
2589 (match-beginning 0) (match-end 0))
2590 (delete-region (match-beginning 1) (match-end 1)))))))
2592 (defun article-strip-leading-space ()
2593 "Remove all white space from the beginning of the lines in the article."
2596 (let ((inhibit-point-motion-hooks t)
2599 (while (re-search-forward "^[ \t]+" nil t)
2600 (replace-match "" t t)))))
2602 (defun article-strip-trailing-space ()
2603 "Remove all white space from the end of the lines in the article."
2606 (let ((inhibit-point-motion-hooks t)
2609 (while (re-search-forward "[ \t]+$" nil t)
2610 (replace-match "" t t)))))
2612 (defun article-strip-blank-lines ()
2613 "Strip leading, trailing and multiple blank lines."
2615 (article-strip-leading-blank-lines)
2616 (article-remove-trailing-blank-lines)
2617 (article-strip-multiple-blank-lines))
2619 (defun article-strip-all-blank-lines ()
2620 "Strip all blank lines."
2623 (let ((inhibit-point-motion-hooks t)
2626 (while (re-search-forward "^[ \t]*\n" nil t)
2627 (replace-match "" t t)))))
2629 (defun gnus-article-narrow-to-signature ()
2630 "Narrow to the signature; return t if a signature is found, else nil."
2631 (let ((inhibit-point-motion-hooks t))
2632 (when (gnus-article-search-signature)
2634 ;; Check whether we have some limits to what we consider
2635 ;; to be a signature.
2636 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2637 (list gnus-signature-limit)))
2639 (while (setq limit (pop limits))
2640 (if (or (and (integerp limit)
2641 (< (- (point-max) (point)) limit))
2643 (< (count-lines (point) (point-max)) limit))
2644 (and (gnus-functionp limit)
2646 (and (stringp limit)
2647 (not (re-search-forward limit nil t))))
2648 () ; This limit did not succeed.
2652 (narrow-to-region (point) (point-max))
2655 (defun gnus-article-search-signature ()
2656 "Search the current buffer for the signature separator.
2657 Put point at the beginning of the signature separator."
2658 (let ((cur (point)))
2659 (goto-char (point-max))
2660 (if (if (stringp gnus-signature-separator)
2661 (re-search-backward gnus-signature-separator nil t)
2662 (let ((seps gnus-signature-separator))
2664 (not (re-search-backward (car seps) nil t)))
2671 (defun gnus-article-hidden-arg ()
2672 "Return the current prefix arg as a number, or 0 if no prefix."
2673 (list (if current-prefix-arg
2674 (prefix-numeric-value current-prefix-arg)
2677 (defun gnus-article-check-hidden-text (type arg)
2678 "Return nil if hiding is necessary.
2679 Arg can be nil or a number. nil and positive means hide, negative
2680 means show, 0 means toggle."
2683 (let ((hide (gnus-article-hidden-text-p type)))
2689 (gnus-article-show-hidden-text type)
2692 (if (eq hide 'hidden)
2694 (gnus-article-show-hidden-text type)
2698 (defun gnus-article-hidden-text-p (type)
2699 "Say whether the current buffer contains hidden text of type TYPE."
2700 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2702 (not (get-text-property pos 'invisible))
2703 (not (get-text-property pos 'dummy-invisible)))
2705 (text-property-any (1+ pos) (point-max) 'article-type type)))
2710 (defun gnus-article-show-hidden-text (type &optional dummy)
2711 "Show all hidden text of type TYPE.
2712 Originally it is hide instead of DUMMY."
2713 (let ((buffer-read-only nil)
2714 (inhibit-point-motion-hooks t))
2715 (gnus-remove-text-properties-when
2717 (point-min) (point-max)
2718 (cons 'article-type (cons type
2719 gnus-hidden-properties)))
2720 (gnus-delete-wash-type type)))
2722 (defconst article-time-units
2723 `((year . ,(* 365.25 24 60 60))
2724 (week . ,(* 7 24 60 60))
2725 (day . ,(* 24 60 60))
2729 "Mapping from time units to seconds.")
2731 (defun article-date-ut (&optional type highlight header)
2732 "Convert DATE date to universal time in the current article.
2733 If TYPE is `local', convert to local time; if it is `lapsed', output
2734 how much time has lapsed since DATE. For `lapsed', the value of
2735 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2736 should replace the \"Date:\" one, or should be added below it."
2737 (interactive (list 'ut t))
2738 (let* ((header (or header
2739 (and (eq 1 (point-min))
2740 (mail-header-date (save-excursion
2741 (set-buffer gnus-summary-buffer)
2742 gnus-current-headers)))
2743 (message-fetch-field "date")
2745 (date (if (vectorp header) (mail-header-date header)
2747 (inhibit-point-motion-hooks t)
2748 bface eface date-pos)
2749 (when (and date (not (string= date "")))
2752 (article-narrow-to-head)
2753 (when (or (and (eq type 'lapsed)
2754 gnus-article-date-lapsed-new-header
2755 ;; Attempt to get the face of X-Sent first.
2756 (re-search-forward "^X-Sent:[ \t]" nil t))
2757 (re-search-forward "^Date:[ \t]" nil t)
2758 ;; If Date is missing, try again for X-Sent.
2759 (re-search-forward "^X-Sent:[ \t]" nil t))
2760 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2761 date (or (get-text-property (gnus-point-at-bol)
2764 eface (get-text-property (1- (gnus-point-at-eol))
2766 (let ((buffer-read-only nil))
2767 ;; Delete any old X-Sent headers.
2768 (when (setq date-pos
2769 (text-property-any (point-min) (point-max)
2770 'article-date-lapsed t))
2771 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2772 (delete-region (match-beginning 0)
2773 (progn (forward-line 1) (point))))
2774 (goto-char (point-min))
2775 ;; Delete any old Date headers.
2776 (while (re-search-forward "^Date:[ \t]" nil t)
2778 (setq date-pos (match-beginning 0)))
2779 (unless (and (eq type 'lapsed)
2780 gnus-article-date-lapsed-new-header)
2781 (delete-region (match-beginning 0)
2782 (progn (message-next-header) (point)))))
2785 (goto-char date-pos)
2787 ;; Possibly, Date has been deleted.
2789 (when (and (eq type 'lapsed)
2790 gnus-article-date-lapsed-new-header
2791 (looking-at "Date:"))
2793 (goto-char (point-min)))
2794 (insert (article-make-date-line date type))
2795 (when (eq type 'lapsed)
2796 (put-text-property (gnus-point-at-bol) (point)
2797 'article-date-lapsed t))
2801 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2802 (put-text-property (match-beginning 1) (1+ (match-end 1))
2803 'original-date date)
2804 (put-text-property (match-beginning 1) (1+ (match-end 1))
2806 (put-text-property (match-beginning 2) (match-end 2)
2809 (defun article-make-date-line (date type)
2810 "Return a DATE line of TYPE."
2811 (unless (memq type '(local ut original user iso8601 lapsed english))
2812 (error "Unknown conversion type: %s" type))
2814 (let ((time (date-to-time date)))
2816 ;; Convert to the local timezone.
2818 (let ((tz (car (current-time-zone time))))
2819 (format "Date: %s %s%02d%02d" (current-time-string time)
2820 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2821 (/ (% (abs tz) 3600) 60))))
2822 ;; Convert to Universal Time.
2825 (current-time-string
2826 (let* ((e (parse-time-string date))
2827 (tm (apply 'encode-time e))
2829 (ls (- (cadr tm) (car (current-time-zone time)))))
2830 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2831 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2834 ;; Get the original date from the article.
2835 ((eq type 'original)
2836 (concat "Date: " (if (string-match "\n+$" date)
2837 (substring date 0 (match-beginning 0))
2839 ;; Let the user define the format.
2841 (let ((format (or (condition-case nil
2842 (with-current-buffer gnus-summary-buffer
2843 gnus-article-time-format)
2845 gnus-article-time-format)))
2846 (if (gnus-functionp format)
2847 (funcall format time)
2848 (concat "Date: " (format-time-string format time)))))
2851 (let ((tz (car (current-time-zone time))))
2854 (format-time-string "%Y%m%dT%H%M%S" time)
2855 (format "%s%02d%02d"
2856 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2857 (/ (% (abs tz) 3600) 60)))))
2858 ;; Do an X-Sent lapsed format.
2860 ;; If the date is seriously mangled, the timezone functions are
2861 ;; liable to bug out, so we ignore all errors.
2862 (let* ((now (current-time))
2863 (real-time (subtract-time now time))
2864 (real-sec (and real-time
2865 (+ (* (float (car real-time)) 65536)
2867 (sec (and real-time (abs real-sec)))
2877 ;; This is a bit convoluted, but basically we go
2878 ;; through the time units for years, weeks, etc,
2879 ;; and divide things to see whether that results
2880 ;; in positive answers.
2883 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2884 ;; The (remaining) seconds are too few to
2885 ;; be divided into this time unit.
2887 ;; It's big enough, so we output it.
2888 (setq sec (- sec (* num (cdr unit))))
2890 (concat (if prev ", " "") (int-to-string
2892 " " (symbol-name (car unit))
2893 (if (> num 1) "s" ""))
2895 article-time-units "")
2896 ;; If dates are odd, then it might appear like the
2897 ;; article was sent in the future.
2900 " in the future"))))))
2901 ;; Display the date in proper English
2903 (let ((dtime (decode-time time)))
2906 (number-to-string (nth 3 dtime))
2907 (let ((digit (% (nth 3 dtime) 10)))
2909 ((memq (nth 3 dtime) '(11 12 13)) "th")
2915 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2917 (number-to-string (nth 5 dtime))
2919 (format "%02d" (nth 2 dtime))
2921 (format "%02d" (nth 1 dtime)))))))
2923 (format "Date: %s (from T-gnus)" date))))
2925 (defun article-date-local (&optional highlight)
2926 "Convert the current article date to the local timezone."
2927 (interactive (list t))
2928 (article-date-ut 'local highlight))
2930 (defun article-date-english (&optional highlight)
2931 "Convert the current article date to something that is proper English."
2932 (interactive (list t))
2933 (article-date-ut 'english highlight))
2935 (defun article-date-original (&optional highlight)
2936 "Convert the current article date to what it was originally.
2937 This is only useful if you have used some other date conversion
2938 function and want to see what the date was before converting."
2939 (interactive (list t))
2940 (article-date-ut 'original highlight))
2942 (defun article-date-lapsed (&optional highlight)
2943 "Convert the current article date to time lapsed since it was sent."
2944 (interactive (list t))
2945 (article-date-ut 'lapsed highlight))
2947 (defun article-update-date-lapsed ()
2948 "Function to be run from a timer to update the lapsed time line."
2949 (let (deactivate-mark)
2954 (set-buffer (window-buffer w))
2955 (when (eq major-mode 'gnus-article-mode)
2956 (goto-char (point-min))
2957 (when (re-search-forward "^X-Sent:" nil t)
2958 (article-date-lapsed t))))
2961 (defun gnus-start-date-timer (&optional n)
2962 "Start a timer to update the X-Sent header in the article buffers.
2963 The numerical prefix says how frequently (in seconds) the function
2968 (gnus-stop-date-timer)
2969 (setq article-lapsed-timer
2970 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2972 (defun gnus-stop-date-timer ()
2973 "Stop the X-Sent timer."
2975 (when article-lapsed-timer
2976 (nnheader-cancel-timer article-lapsed-timer)
2977 (setq article-lapsed-timer nil)))
2979 (defun article-date-user (&optional highlight)
2980 "Convert the current article date to the user-defined format.
2981 This format is defined by the `gnus-article-time-format' variable."
2982 (interactive (list t))
2983 (article-date-ut 'user highlight))
2985 (defun article-date-iso8601 (&optional highlight)
2986 "Convert the current article date to ISO8601."
2987 (interactive (list t))
2988 (article-date-ut 'iso8601 highlight))
2990 ;; (defun article-show-all ()
2991 ;; "Show all hidden text in the article buffer."
2995 ;; (let ((buffer-read-only nil))
2996 ;; (gnus-article-unhide-text (point-min) (point-max))
2997 ;; (gnus-remove-text-with-property 'gnus-prev)
2998 ;; (gnus-remove-text-with-property 'gnus-next))))
3000 (defun article-show-all-headers ()
3001 "Show all hidden headers in the article buffer."
3006 (article-narrow-to-head)
3007 (let ((buffer-read-only nil))
3008 (gnus-article-unhide-text (point-min) (point-max))))))
3010 (defun article-remove-leading-whitespace ()
3011 "Remove excessive whitespace from all headers."
3015 (let ((buffer-read-only nil))
3016 (article-narrow-to-head)
3017 (goto-char (point-min))
3018 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3019 (delete-region (match-beginning 1) (match-end 1)))))))
3021 (defun article-emphasize (&optional arg)
3022 "Emphasize text according to `gnus-emphasis-alist'."
3023 (interactive (gnus-article-hidden-arg))
3024 (unless (gnus-article-check-hidden-text 'emphasis arg)
3028 (with-current-buffer gnus-summary-buffer
3029 gnus-article-emphasis-alist)
3031 gnus-emphasis-alist))
3032 (buffer-read-only nil)
3033 (props (append '(article-type emphasis)
3034 gnus-hidden-properties))
3035 regexp elem beg invisible visible face)
3038 (while (setq elem (pop alist))
3040 (setq regexp (car elem)
3041 invisible (nth 1 elem)
3042 visible (nth 2 elem)
3044 (while (re-search-forward regexp nil t)
3045 (when (and (match-beginning visible) (match-beginning invisible))
3046 (gnus-article-hide-text
3047 (match-beginning invisible) (match-end invisible) props)
3048 (gnus-article-unhide-text-type
3049 (match-beginning visible) (match-end visible) 'emphasis)
3050 (gnus-put-overlay-excluding-newlines
3051 (match-beginning visible) (match-end visible) 'face face)
3052 (gnus-add-wash-type 'emphasis)
3053 (goto-char (match-end invisible)))))))))
3055 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3056 "Setup newsgroup emphasis alist."
3057 (unless gnus-article-emphasis-alist
3058 (let ((name (and gnus-newsgroup-name
3059 (gnus-group-real-name gnus-newsgroup-name))))
3060 (make-local-variable 'gnus-article-emphasis-alist)
3061 (setq gnus-article-emphasis-alist
3063 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3064 (while (setq elem (pop alist))
3065 (when (and name (string-match (car elem) name))
3067 highlight (copy-sequence (cdr elem)))))
3069 (copy-sequence highlight-words)
3070 (if gnus-newsgroup-name
3071 (copy-sequence (gnus-group-find-parameter
3072 gnus-newsgroup-name 'highlight-words t)))
3073 gnus-emphasis-alist)))))
3076 (defvar gnus-summary-article-menu)
3077 (defvar gnus-summary-post-menu))
3079 ;;; Saving functions.
3081 (defun gnus-article-save (save-buffer file &optional num)
3082 "Save the currently selected article."
3083 (unless gnus-save-all-headers
3084 ;; Remove headers according to `gnus-saved-headers'.
3085 (let ((gnus-visible-headers
3086 (or gnus-saved-headers gnus-visible-headers))
3087 (gnus-article-buffer save-buffer))
3089 (set-buffer save-buffer)
3090 (article-hide-headers 1 t))))
3091 (save-window-excursion
3092 (if (not gnus-default-article-saver)
3093 (error "No default saver is defined")
3094 ;; !!! Magic! The saving functions all save
3095 ;; `gnus-save-article-buffer' (or so they think), but we
3096 ;; bind that variable to our save-buffer.
3097 (set-buffer gnus-article-buffer)
3098 (let* ((gnus-save-article-buffer save-buffer)
3101 ((not gnus-prompt-before-saving) 'default)
3102 ((eq gnus-prompt-before-saving 'always) nil)
3104 (gnus-number-of-articles-to-be-saved
3105 (when (eq gnus-prompt-before-saving t)
3107 (set-buffer gnus-article-current-summary)
3108 (funcall gnus-default-article-saver filename)))))
3110 (defun gnus-read-save-file-name (prompt &optional filename
3111 function group headers variable)
3113 (funcall function group headers (symbol-value variable)))
3118 ((eq filename 'default)
3124 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3127 (if (and gnus-number-of-articles-to-be-saved
3128 (> gnus-number-of-articles-to-be-saved 1))
3129 (format "these %d articles"
3130 gnus-number-of-articles-to-be-saved)
3133 ;; Let the split methods have their say.
3135 ;; No split name was found.
3138 (concat prompt " (default "
3139 (file-name-nondirectory default-name) ") ")
3140 (file-name-directory default-name)
3142 ;; A single group name is returned.
3143 ((stringp split-name)
3145 (funcall function split-name headers
3146 (symbol-value variable)))
3148 (concat prompt " (default "
3149 (file-name-nondirectory default-name) ") ")
3150 (file-name-directory default-name)
3152 ;; A single split name was found
3153 ((= 1 (length split-name))
3154 (let* ((name (expand-file-name
3156 gnus-article-save-directory))
3157 (dir (cond ((file-directory-p name)
3158 (file-name-as-directory name))
3159 ((file-exists-p name) name)
3160 (t gnus-article-save-directory))))
3162 (concat prompt " (default " name ") ")
3164 ;; A list of splits was found.
3166 (setq split-name (nreverse split-name))
3168 (let ((file-name-history
3169 (nconc split-name file-name-history)))
3173 (concat prompt " (`M-p' for defaults) ")
3174 gnus-article-save-directory
3176 gnus-article-save-directory)))
3177 (car (push result file-name-history)))))))
3178 ;; Create the directory.
3179 (gnus-make-directory (file-name-directory file))
3180 ;; If we have read a directory, we append the default file name.
3181 (when (file-directory-p file)
3182 (setq file (expand-file-name (file-name-nondirectory
3184 (file-name-as-directory file))))
3185 ;; Possibly translate some characters.
3186 (nnheader-translate-file-chars file))))))
3187 (gnus-make-directory (file-name-directory result))
3188 (set variable result)))
3190 (defun gnus-article-archive-name (group)
3191 "Return the first instance of an \"Archive-name\" in the current buffer."
3192 (let ((case-fold-search t))
3193 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3194 (nnheader-concat gnus-article-save-directory
3195 (match-string 1)))))
3197 (defun gnus-article-nndoc-name (group)
3198 "If GROUP is an nndoc group, return the name of the parent group."
3199 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3200 (gnus-group-get-parameter group 'save-article-group)))
3202 (defun gnus-summary-save-in-rmail (&optional filename)
3203 "Append this article to Rmail file.
3204 Optional argument FILENAME specifies file name.
3205 Directory to save to is default to `gnus-article-save-directory'."
3206 (setq filename (gnus-read-save-file-name
3207 "Save %s in rmail file:" filename
3208 gnus-rmail-save-name gnus-newsgroup-name
3209 gnus-current-headers 'gnus-newsgroup-last-rmail))
3210 (gnus-eval-in-buffer-window gnus-save-article-buffer
3214 (gnus-output-to-rmail filename))))
3217 (defun gnus-summary-save-in-mail (&optional filename)
3218 "Append this article to Unix mail file.
3219 Optional argument FILENAME specifies file name.
3220 Directory to save to is default to `gnus-article-save-directory'."
3221 (setq filename (gnus-read-save-file-name
3222 "Save %s in Unix mail file:" filename
3223 gnus-mail-save-name gnus-newsgroup-name
3224 gnus-current-headers 'gnus-newsgroup-last-mail))
3225 (gnus-eval-in-buffer-window gnus-save-article-buffer
3229 (if (and (file-readable-p filename)
3230 (mail-file-babyl-p filename))
3231 (rmail-output-to-rmail-file filename t)
3232 (gnus-output-to-mail filename)))))
3235 (defun gnus-summary-save-in-file (&optional filename overwrite)
3236 "Append this article to file.
3237 Optional argument FILENAME specifies file name.
3238 Directory to save to is default to `gnus-article-save-directory'."
3239 (setq filename (gnus-read-save-file-name
3240 "Save %s in file:" filename
3241 gnus-file-save-name gnus-newsgroup-name
3242 gnus-current-headers 'gnus-newsgroup-last-file))
3243 (gnus-eval-in-buffer-window gnus-save-article-buffer
3247 (when (and overwrite
3248 (file-exists-p filename))
3249 (delete-file filename))
3250 (gnus-output-to-file filename))))
3253 (defun gnus-summary-write-to-file (&optional filename)
3254 "Write this article to a file, overwriting it if the file exists.
3255 Optional argument FILENAME specifies file name.
3256 The directory to save in defaults to `gnus-article-save-directory'."
3257 (gnus-summary-save-in-file nil t))
3259 (defun gnus-summary-save-body-in-file (&optional filename)
3260 "Append this article body to a file.
3261 Optional argument FILENAME specifies file name.
3262 The directory to save in defaults to `gnus-article-save-directory'."
3263 (setq filename (gnus-read-save-file-name
3264 "Save %s body in file:" filename
3265 gnus-file-save-name gnus-newsgroup-name
3266 gnus-current-headers 'gnus-newsgroup-last-file))
3267 (gnus-eval-in-buffer-window gnus-save-article-buffer
3271 (when (article-goto-body)
3272 (narrow-to-region (point) (point-max)))
3273 (gnus-output-to-file filename))))
3276 (defun gnus-summary-save-in-pipe (&optional command)
3277 "Pipe this article to subprocess."
3279 (cond ((and (eq command 'default)
3280 gnus-last-shell-command)
3281 gnus-last-shell-command)
3286 "Shell command on %s: "
3287 (if (and gnus-number-of-articles-to-be-saved
3288 (> gnus-number-of-articles-to-be-saved 1))
3289 (format "these %d articles"
3290 gnus-number-of-articles-to-be-saved)
3292 gnus-last-shell-command))))
3293 (when (string-equal command "")
3294 (if gnus-last-shell-command
3295 (setq command gnus-last-shell-command)
3296 (error "A command is required")))
3297 (gnus-eval-in-buffer-window gnus-article-buffer
3300 (shell-command-on-region (point-min) (point-max) command nil)))
3301 (setq gnus-last-shell-command command))
3303 (defun gnus-summary-pipe-to-muttprint (&optional command)
3304 "Pipe this article to muttprint."
3305 (setq command (read-string
3306 "Print using command: " gnus-summary-muttprint-program
3307 nil gnus-summary-muttprint-program))
3308 (gnus-summary-save-in-pipe command))
3310 ;;; Article file names when saving.
3312 (defun gnus-capitalize-newsgroup (newsgroup)
3313 "Capitalize NEWSGROUP name."
3314 (when (not (zerop (length newsgroup)))
3315 (concat (char-to-string (upcase (aref newsgroup 0)))
3316 (substring newsgroup 1))))
3318 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3319 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3320 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3321 Otherwise, it is like ~/News/news/group/num."
3324 (concat (if (gnus-use-long-file-name 'not-save)
3325 (gnus-capitalize-newsgroup newsgroup)
3326 (gnus-newsgroup-directory-form newsgroup))
3327 "/" (int-to-string (mail-header-number headers)))
3328 gnus-article-save-directory)))
3330 (string-equal (file-name-directory default)
3331 (file-name-directory last-file))
3332 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3334 (or last-file default))))
3336 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3337 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3338 If variable `gnus-use-long-file-name' is non-nil, it is
3339 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3342 (concat (if (gnus-use-long-file-name 'not-save)
3344 (gnus-newsgroup-directory-form newsgroup))
3345 "/" (int-to-string (mail-header-number headers)))
3346 gnus-article-save-directory)))
3348 (string-equal (file-name-directory default)
3349 (file-name-directory last-file))
3350 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3352 (or last-file default))))
3354 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3355 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3356 If variable `gnus-use-long-file-name' is non-nil, it is
3357 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3360 (if (gnus-use-long-file-name 'not-save)
3363 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3365 gnus-article-save-directory)))
3367 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3368 "Generate file name from sender."
3369 (let ((from (mail-header-from headers)))
3371 (if (and from (string-match "\\([^ <]+\\)@" from))
3372 (match-string 1 from)
3374 gnus-article-save-directory)))
3376 (defun article-verify-x-pgp-sig ()
3379 (if (gnus-buffer-live-p gnus-original-article-buffer)
3380 (let ((sig (with-current-buffer gnus-original-article-buffer
3381 (gnus-fetch-field "X-PGP-Sig")))
3385 (mml2015-clear-verify-function))
3387 (insert-buffer-substring gnus-original-article-buffer)
3388 (setq items (split-string sig))
3389 (message-narrow-to-head)
3390 (let ((inhibit-point-motion-hooks t)
3391 (case-fold-search t))
3392 ;; Don't verify multiple headers.
3393 (setq headers (mapconcat (lambda (header)
3395 (mail-fetch-field header) "\n"))
3396 (split-string (nth 1 items) ",") "")))
3397 (delete-region (point-min) (point-max))
3398 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3399 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3404 (if (looking-at "^-")
3407 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3408 (insert "Version: " (car items) "\n\n")
3409 (insert (mapconcat 'identity (cddr items) "\n"))
3410 (insert "\n-----END PGP SIGNATURE-----\n")
3411 (let ((mm-security-handle (list (format "multipart/signed"))))
3412 (mml2015-clean-buffer)
3413 (let ((coding-system-for-write (or gnus-newsgroup-charset
3415 (funcall (mml2015-clear-verify-function)))
3417 (or (mm-handle-multipart-ctl-parameter
3418 mm-security-handle 'gnus-details)
3419 (mm-handle-multipart-ctl-parameter
3420 mm-security-handle 'gnus-info)))))
3422 (let (buffer-read-only bface eface)
3424 (message-narrow-to-head)
3425 (goto-char (point-max))
3427 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3428 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3429 (message-remove-header "X-Gnus-PGP-Verify")
3430 (if (re-search-forward "^X-PGP-Sig:" nil t)
3432 (goto-char (point-max)))
3433 (narrow-to-region (point) (point))
3434 (insert "X-Gnus-PGP-Verify: " info "\n")
3435 (goto-char (point-min))
3438 (if (not (looking-at "^[ \t]"))
3442 (goto-char (point-min))
3443 (when (looking-at "\\([^:]+\\): *")
3444 (put-text-property (match-beginning 1) (1+ (match-end 1))
3446 (put-text-property (match-end 0) (point-max)
3447 'face eface)))))))))
3449 (defun article-verify-cancel-lock ()
3450 "Verify Cancel-Lock header."
3452 (if (gnus-buffer-live-p gnus-original-article-buffer)
3453 (canlock-verify gnus-original-article-buffer)))
3455 (defun article-monafy ()
3456 "Display body part with mona font."
3458 (unless (if (featurep 'xemacs)
3459 (find-face 'gnus-mona-face)
3460 (facep 'gnus-mona-face))
3461 (require 'navi2ch-mona)
3462 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3464 (let ((buffer-read-only nil))
3467 (gnus-make-overlay (point) (point-max))
3468 'face 'gnus-mona-face))))
3475 (setq afunc (car func)
3478 gfunc (intern (format "gnus-%s" func))))
3480 (when (fboundp afunc)
3481 `(lambda (&optional interactive &rest args)
3482 ,(documentation afunc t)
3483 (interactive (list t))
3485 (set-buffer gnus-article-buffer)
3487 (call-interactively ',afunc)
3488 (apply ',afunc args))))))))
3489 '(article-hide-headers
3490 article-verify-x-pgp-sig
3491 article-verify-cancel-lock
3493 article-hide-boring-headers
3494 article-treat-overstrike
3495 article-fill-long-lines
3496 article-capitalize-sentences
3498 article-remove-leading-whitespace
3499 article-display-x-face
3500 article-de-quoted-unreadable
3501 article-de-base64-unreadable
3504 article-unsplit-urls
3505 article-hide-list-identifiers
3507 article-strip-banner
3510 article-hide-signature
3511 article-strip-headers-in-body
3512 article-remove-trailing-blank-lines
3513 article-strip-leading-blank-lines
3514 article-strip-multiple-blank-lines
3515 article-strip-leading-space
3516 article-strip-trailing-space
3517 article-strip-blank-lines
3518 article-strip-all-blank-lines
3520 article-date-english
3521 article-date-iso8601
3522 article-date-original
3524 article-decode-mime-words
3525 article-decode-charset
3526 article-decode-encoded-words
3530 article-treat-dumbquotes
3531 article-normalize-headers
3532 (article-show-all-headers . gnus-article-show-all-headers)
3533 ;; (article-show-all . gnus-article-show-all)
3537 ;;; Gnus article mode
3540 (put 'gnus-article-mode 'mode-class 'special)
3542 (gnus-define-keys gnus-article-mode-map
3543 " " gnus-article-goto-next-page
3544 "\177" gnus-article-goto-prev-page
3545 [delete] gnus-article-goto-prev-page
3546 [backspace] gnus-article-goto-prev-page
3547 "\C-c^" gnus-article-refer-article
3548 "h" gnus-article-show-summary
3549 "s" gnus-article-show-summary
3550 "\C-c\C-m" gnus-article-mail
3551 "?" gnus-article-describe-briefly
3552 "e" gnus-summary-edit-article
3553 "<" beginning-of-buffer
3555 "\C-c\C-i" gnus-info-find-node
3557 "R" gnus-article-reply-with-original
3558 "F" gnus-article-followup-with-original
3559 "\C-hk" gnus-article-describe-key
3560 "\C-hc" gnus-article-describe-key-briefly
3562 "\C-d" gnus-article-read-summary-keys
3563 "\M-*" gnus-article-read-summary-keys
3564 "\M-#" gnus-article-read-summary-keys
3565 "\M-^" gnus-article-read-summary-keys
3566 "\M-g" gnus-article-read-summary-keys)
3568 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3572 (push (char-to-string key) keys)
3574 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3575 (setq key (car elem))
3576 (when (and (> (length key) 0)
3577 (not (eq 'menu-bar (aref key 0)))
3578 (symbolp (lookup-key gnus-summary-mode-map key)))
3581 (unless (lookup-key gnus-article-mode-map key)
3582 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3584 (defun gnus-article-make-menu-bar ()
3585 (unless (boundp 'gnus-article-commands-menu)
3586 (gnus-summary-make-menu-bar))
3587 (gnus-turn-off-edit-menu 'article)
3588 (unless (boundp 'gnus-article-article-menu)
3590 gnus-article-article-menu gnus-article-mode-map ""
3592 ["Scroll forwards" gnus-article-goto-next-page t]
3593 ["Scroll backwards" gnus-article-goto-prev-page t]
3594 ["Show summary" gnus-article-show-summary t]
3595 ["Fetch Message-ID at point" gnus-article-refer-article t]
3596 ["Mail to address at point" gnus-article-mail t]
3597 ["Send a bug report" gnus-bug t]))
3600 gnus-article-treatment-menu gnus-article-mode-map ""
3601 ;; Fixme: this should use :active (and maybe :visible).
3603 ["Hide headers" gnus-article-hide-headers t]
3604 ["Hide signature" gnus-article-hide-signature t]
3605 ["Hide citation" gnus-article-hide-citation t]
3606 ["Treat overstrike" gnus-article-treat-overstrike t]
3607 ["Remove carriage return" gnus-article-remove-cr t]
3608 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3609 ["Treat html" gnus-article-wash-html t]
3610 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3611 ["Decode HZ" gnus-article-decode-HZ t]))
3613 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3615 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3617 (gnus-run-hooks 'gnus-article-menu-hook)))
3619 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3622 (defun gnus-article-mode ()
3623 "Major mode for displaying an article.
3625 All normal editing commands are switched off.
3627 The following commands are available in addition to all summary mode
3629 \\<gnus-article-mode-map>
3630 \\[gnus-article-next-page]\t Scroll the article one page forwards
3631 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3632 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3633 \\[gnus-article-show-summary]\t Display the summary buffer
3634 \\[gnus-article-mail]\t Send a reply to the address near point
3635 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3636 \\[gnus-info-find-node]\t Go to the Gnus info node"
3638 (gnus-simplify-mode-line)
3639 (setq mode-name "Article")
3640 (setq major-mode 'gnus-article-mode)
3641 (make-local-variable 'minor-mode-alist)
3642 (unless (assq 'gnus-show-mime minor-mode-alist)
3643 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3644 (use-local-map gnus-article-mode-map)
3645 (when (gnus-visual-p 'article-menu 'menu)
3646 (gnus-article-make-menu-bar))
3647 (gnus-update-format-specifications nil 'article-mode)
3648 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3649 (make-local-variable 'gnus-page-broken)
3650 (make-local-variable 'gnus-button-marker-list)
3651 (make-local-variable 'gnus-article-current-summary)
3652 (make-local-variable 'gnus-article-mime-handles)
3653 (make-local-variable 'gnus-article-decoded-p)
3654 (make-local-variable 'gnus-article-mime-handle-alist)
3655 (make-local-variable 'gnus-article-wash-types)
3656 (make-local-variable 'gnus-article-image-alist)
3657 (make-local-variable 'gnus-article-charset)
3658 (make-local-variable 'gnus-article-ignored-charsets)
3659 (gnus-set-default-directory)
3660 (buffer-disable-undo)
3661 (setq buffer-read-only t)
3662 (set-syntax-table gnus-article-mode-syntax-table)
3663 (gnus-run-hooks 'gnus-article-mode-hook))
3665 (defun gnus-article-setup-buffer ()
3666 "Initialize the article buffer."
3667 (let* ((name (if gnus-single-article-buffer "*Article*"
3668 (concat "*Article " gnus-newsgroup-name "*")))
3670 (progn (string-match "\\*Article" name)
3671 (concat " *Original Article"
3672 (substring name (match-end 0))))))
3673 (setq gnus-article-buffer name)
3674 (setq gnus-original-article-buffer original)
3675 (setq gnus-article-mime-handle-alist nil)
3676 ;; This might be a variable local to the summary buffer.
3677 (unless gnus-single-article-buffer
3679 (set-buffer gnus-summary-buffer)
3680 (setq gnus-article-buffer name)
3681 (setq gnus-original-article-buffer original)
3682 (gnus-set-global-variables)))
3683 (gnus-article-setup-highlight-words)
3684 ;; Init original article buffer.
3686 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3687 (set-buffer-multibyte t)
3688 (setq major-mode 'gnus-original-article-mode)
3689 (make-local-variable 'gnus-original-article))
3690 (if (get-buffer name)
3693 (buffer-disable-undo)
3694 (setq buffer-read-only t)
3695 (unless (eq major-mode 'gnus-article-mode)
3696 (gnus-article-mode))
3699 (set-buffer (gnus-get-buffer-create name))
3701 (make-local-variable 'gnus-summary-buffer)
3702 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3703 (current-buffer)))))
3705 ;; Set article window start at LINE, where LINE is the number of lines
3706 ;; from the head of the article.
3707 (defun gnus-article-set-window-start (&optional line)
3709 (gnus-get-buffer-window gnus-article-buffer t)
3711 (set-buffer gnus-article-buffer)
3712 (goto-char (point-min))
3715 (gnus-message 6 "Moved to bookmark")
3716 (search-forward "\n\n" nil t)
3720 ;;; @@ article filters
3723 (defun gnus-article-display-mime-message ()
3724 "Article display method for MIME message."
3725 ;; called from `gnus-original-article-buffer'.
3726 (let (charset all-headers)
3727 (with-current-buffer gnus-summary-buffer
3728 (setq charset default-mime-charset
3729 all-headers gnus-have-all-headers))
3730 (make-local-variable 'default-mime-charset)
3731 (setq default-mime-charset charset)
3732 (with-current-buffer (get-buffer-create gnus-article-buffer)
3733 (make-local-variable 'default-mime-charset)
3734 (setq default-mime-charset charset))
3735 (mime-display-message mime-message-structure
3736 gnus-article-buffer nil gnus-article-mode-map)
3738 (gnus-article-hide-headers nil -1)))
3739 (run-hooks 'gnus-mime-article-prepare-hook))
3741 (defun gnus-article-display-traditional-message ()
3742 "Article display method for traditional message."
3743 (set-buffer gnus-article-buffer)
3744 (let (buffer-read-only)
3746 (insert-buffer-substring gnus-original-article-buffer)))
3748 (defun gnus-article-make-full-mail-header (&optional number charset)
3749 "Create a new mail header structure in a raw article buffer."
3750 (unless (and number charset)
3751 (save-current-buffer
3752 (set-buffer gnus-summary-buffer)
3754 (setq number (or (cdr gnus-article-current) 0)))
3756 (setq charset (or default-mime-charset 'x-ctext)))))
3757 (goto-char (point-min))
3758 (let ((header-end (if (search-forward "\n\n" nil t)
3760 (goto-char (point-max))))
3761 (chars (- (point-max) (point)))
3762 (lines (count-lines (point) (point-max)))
3763 (default-mime-charset charset)
3765 (narrow-to-region (point-min) header-end)
3766 (setq xref (std11-fetch-field "xref"))
3768 (make-full-mail-header
3770 (std11-fetch-field "subject")
3771 (std11-fetch-field "from")
3772 (std11-fetch-field "date")
3773 (std11-fetch-field "message-id")
3774 (std11-fetch-field "references")
3777 (when xref (concat "Xref: " xref)))
3780 (defun gnus-article-prepare (article &optional all-headers header)
3781 "Prepare ARTICLE in article mode buffer.
3782 ARTICLE should either be an article number or a Message-ID.
3783 If ARTICLE is an id, HEADER should be the article headers.
3784 If ALL-HEADERS is non-nil, no headers are hidden."
3786 ;; Make sure we start in a summary buffer.
3787 (unless (eq major-mode 'gnus-summary-mode)
3788 (set-buffer gnus-summary-buffer))
3789 (setq gnus-summary-buffer (current-buffer))
3790 (let* ((gnus-article (if header (mail-header-number header) article))
3791 (summary-buffer (current-buffer))
3792 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3793 (group gnus-newsgroup-name)
3796 (gnus-article-setup-buffer)
3797 (set-buffer gnus-article-buffer)
3798 ;; Deactivate active regions.
3799 (when (and (boundp 'transient-mark-mode)
3800 transient-mark-mode)
3801 (setq mark-active nil))
3802 (if (not (setq result (let ((buffer-read-only nil))
3803 (gnus-request-article-this-buffer
3805 ;; There is no such article.
3807 (when (and (numberp article)
3808 (not (memq article gnus-newsgroup-sparse)))
3809 (setq gnus-article-current
3810 (cons gnus-newsgroup-name article))
3811 (set-buffer gnus-summary-buffer)
3812 (setq gnus-current-article article)
3813 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3815 (gnus-summary-set-agent-mark article)
3816 (message "Message marked for downloading"))
3817 (gnus-summary-mark-article article gnus-canceled-mark)
3818 (unless (memq article gnus-newsgroup-sparse)
3819 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3820 (if (or (eq result 'pseudo)
3821 (eq result 'nneething))
3824 (set-buffer summary-buffer)
3825 (push article gnus-newsgroup-history)
3826 (setq gnus-last-article gnus-current-article
3827 gnus-current-article 0
3828 gnus-current-headers nil
3829 gnus-article-current nil)
3830 (if (eq result 'nneething)
3831 (gnus-configure-windows 'summary)
3832 (gnus-configure-windows 'article))
3833 (gnus-set-global-variables))
3834 (let ((gnus-article-mime-handle-alist-1
3835 gnus-article-mime-handle-alist))
3836 (gnus-set-mode-line 'article)))
3837 ;; The result from the `request' was an actual article -
3838 ;; or at least some text that is now displayed in the
3840 (when (and (numberp article)
3841 (not (eq article gnus-current-article)))
3842 ;; Seems like a new article has been selected.
3843 ;; `gnus-current-article' must be an article number.
3845 (set-buffer summary-buffer)
3846 (push article gnus-newsgroup-history)
3847 (setq gnus-last-article gnus-current-article
3848 gnus-current-article article
3849 gnus-current-headers
3850 (gnus-summary-article-header gnus-current-article)
3851 gnus-article-current
3852 (cons gnus-newsgroup-name gnus-current-article))
3853 (unless (vectorp gnus-current-headers)
3854 (setq gnus-current-headers nil))
3855 (gnus-summary-goto-subject gnus-current-article)
3856 (when (gnus-summary-show-thread)
3857 ;; If the summary buffer really was folded, the
3858 ;; previous goto may not actually have gone to
3859 ;; the right article, but the thread root instead.
3861 (gnus-summary-goto-subject gnus-current-article))
3862 (gnus-run-hooks 'gnus-mark-article-hook)
3863 (gnus-set-mode-line 'summary)
3864 (when (gnus-visual-p 'article-highlight 'highlight)
3865 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3866 ;; Set the global newsgroup variables here.
3867 (gnus-set-global-variables)
3868 (setq gnus-have-all-headers
3869 (or all-headers gnus-show-all-headers))))
3871 (gnus-configure-windows 'article))
3872 (when (or (numberp article)
3874 (gnus-article-prepare-display)
3876 (goto-char (point-min))
3877 (setq gnus-page-broken
3878 (when gnus-break-pages
3879 (gnus-narrow-to-page)
3881 (let ((gnus-article-mime-handle-alist-1
3882 gnus-article-mime-handle-alist))
3883 (gnus-set-mode-line 'article))
3887 (set-window-point (get-buffer-window (current-buffer)) (point))
3888 (gnus-configure-windows 'article)
3891 (defun gnus-article-prepare-mime-display (&optional number)
3892 (goto-char (point-min))
3893 (when (re-search-forward "^[^\t ]+:" nil t)
3894 (goto-char (match-beginning 0)))
3895 (let ((entity (if (eq 1 (point-min))
3896 (get-text-property 1 'mime-view-entity)
3897 (get-text-property (point) 'mime-view-entity)))
3898 last-entity child-entity next type)
3899 (setq child-entity (mime-entity-children entity))
3901 (setq last-entity (nth (1- (length child-entity))
3903 (setq last-entity entity))
3905 (narrow-to-region (point)
3906 (if (search-forward "\n\n" nil t)
3909 (gnus-treat-article 'head)
3910 (put-text-property (point-min) (point-max) 'article-treated-header t)
3911 (goto-char (point-max)))
3912 (while (and (not (eobp)) entity)
3913 (setq next (set-marker
3915 (next-single-property-change (point) 'mime-view-entity
3917 (let ((types (mime-entity-content-type entity)))
3918 (while (eq 'multipart (mime-content-type-primary-type types))
3919 (setq entity (car (mime-entity-children entity))
3920 types (mime-entity-content-type entity)))
3922 (setq type (format "%s/%s"
3923 (mime-content-type-primary-type types)
3924 (mime-content-type-subtype types)))))
3925 (if (string-equal type "message/rfc822")
3928 (let ((children (mime-entity-children entity))
3931 (setq last-children (nth (1- (length children)) children))
3934 (not (eq last-children
3935 (get-text-property next 'mime-view-entity)))
3937 (next-single-property-change next
3939 nil (point-max)))))))
3940 (setq next (next-single-property-change next 'mime-view-entity
3943 (narrow-to-region (point) next)
3944 (gnus-article-prepare-mime-display)
3945 (goto-char (point-max)))
3946 (setq entity (get-text-property (point) 'mime-view-entity)))
3948 (narrow-to-region (point) next)
3949 ;; Kludge. We have to count true number, but for now,
3950 ;; part number is here only to achieve `last'.
3951 (gnus-treat-article nil 1
3952 (if (eq entity last-entity)
3955 (goto-char (point-max)))
3956 (setq entity (get-text-property next 'mime-view-entity))))))
3959 (defun gnus-article-prepare-display ()
3960 "Make the current buffer look like a nice article."
3961 (let ((gnus-article-buffer (current-buffer))
3963 (unless (eq major-mode 'gnus-article-mode)
3964 (gnus-article-mode))
3965 (setq buffer-read-only nil
3966 gnus-button-marker-list nil
3967 gnus-article-wash-types nil
3968 gnus-article-image-alist nil)
3971 (static-if (featurep 'xemacs)
3972 (map-extents (lambda (extent maparg) (delete-extent extent)))
3973 (let ((lists (overlay-lists)))
3974 (dolist (overlay (nconc (car lists) (cdr lists)))
3975 (delete-overlay overlay)))))
3976 (gnus-run-hooks 'gnus-tmp-internal-hook))
3977 (set-buffer gnus-original-article-buffer)
3979 (setq mime-message-structure gnus-current-headers)
3980 (mime-buffer-entity-set-buffer-internal mime-message-structure
3981 gnus-original-article-buffer)
3982 (mime-entity-set-representation-type-internal mime-message-structure
3983 'mime-buffer-entity)
3984 (luna-send mime-message-structure 'initialize-instance
3985 mime-message-structure)
3987 (let (mime-display-header-hook mime-display-text/plain-hook)
3988 (funcall gnus-article-display-method-for-mime))
3989 (funcall gnus-article-display-method-for-traditional))
3990 ;; Call the treatment functions.
3991 (let ((inhibit-read-only t))
3995 (gnus-article-prepare-mime-display)
3996 (narrow-to-region (goto-char (point-min))
3997 (if (search-forward "\n\n" nil t)
4000 (gnus-treat-article 'head)
4001 (put-text-property (point-min) (point-max) 'article-treated-header t)
4002 (goto-char (point-max))
4004 (narrow-to-region (point) (point-max))
4005 (gnus-treat-article nil))
4006 (put-text-property (point-min) (point-max) 'read-only nil)))
4007 (gnus-run-hooks 'gnus-article-prepare-hook))
4009 (defun gnus-article-decode-article-as-default-mime-charset ()
4010 "Decode an article as `default-mime-charset'. It won't work if the
4011 value of the variable `gnus-show-mime' is non-nil."
4012 (unless gnus-show-mime
4013 (set (make-local-variable 'default-mime-charset)
4014 (with-current-buffer gnus-summary-buffer
4015 default-mime-charset))
4016 (decode-mime-charset-region (point-min) (point-max)
4017 default-mime-charset)))
4020 ;;; Gnus MIME viewing functions
4023 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4024 "Format of the MIME buttons.
4026 Valid specifiers include:
4028 %T MIME type, along with additional info
4029 %n The `name' parameter
4030 %d The description, if any
4031 %l The length of the encoded part
4032 %p The part identifier number
4033 %e Dots if the part isn't displayed
4035 General format specifiers can also be used. See Info node
4036 `(gnus)Formatting Variables'.")
4038 (defvar gnus-mime-button-line-format-alist
4039 '((?t gnus-tmp-type ?s)
4040 (?T gnus-tmp-type-long ?s)
4041 (?n gnus-tmp-name ?s)
4042 (?d gnus-tmp-description ?s)
4044 (?l gnus-tmp-length ?d)
4045 (?e gnus-tmp-dots ?s)))
4047 (defvar gnus-mime-button-commands
4048 '((gnus-article-press-button "\r" "Toggle Display")
4049 (gnus-mime-view-part "v" "View Interactively...")
4050 (gnus-mime-view-part-as-type "t" "View As Type...")
4051 (gnus-mime-view-part-as-charset "C" "View As charset...")
4052 (gnus-mime-save-part "o" "Save...")
4053 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4054 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4055 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4056 (gnus-mime-view-part-internally "E" "View Internally")
4057 (gnus-mime-view-part-externally "e" "View Externally")
4058 (gnus-mime-print-part "p" "Print")
4059 (gnus-mime-pipe-part "|" "Pipe To Command...")
4060 (gnus-mime-action-on-part "." "Take action on the part")))
4062 (defun gnus-article-mime-part-status ()
4063 (with-current-buffer gnus-article-buffer
4064 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4067 (setq children (mime-entity-children entity))
4068 (setq children (length children)))
4071 (format " (%d parts)" children))
4074 (defvar gnus-mime-button-map
4075 (let ((map (make-sparse-keymap)))
4076 (unless (>= (string-to-number emacs-version) 21)
4077 ;; XEmacs doesn't care.
4078 (set-keymap-parent map gnus-article-mode-map))
4079 (define-key map gnus-mouse-2 'gnus-article-push-button)
4080 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4081 (dolist (c gnus-mime-button-commands)
4082 (define-key map (cadr c) (car c)))
4085 (defun gnus-mime-button-menu (event)
4086 "Construct a context-sensitive menu of MIME commands."
4088 (save-window-excursion
4089 (let ((pos (event-start event)))
4090 (select-window (posn-window pos))
4091 (goto-char (posn-point pos))
4092 (gnus-article-check-buffer)
4093 (let ((response (x-popup-menu
4095 ("" ,@(mapcar (lambda (c)
4096 (cons (caddr c) (car c)))
4097 gnus-mime-button-commands))))))
4099 (call-interactively response))))))
4101 (defun gnus-mime-view-all-parts (&optional handles)
4102 "View all the MIME parts."
4104 (save-current-buffer
4105 (set-buffer gnus-article-buffer)
4106 (let ((handles (or handles gnus-article-mime-handles))
4107 (mail-parse-charset gnus-newsgroup-charset)
4108 (mail-parse-ignored-charsets
4109 (with-current-buffer gnus-summary-buffer
4110 gnus-newsgroup-ignored-charsets)))
4112 (mm-remove-parts handles)
4113 (goto-char (point-min))
4114 (or (search-forward "\n\n") (goto-char (point-max)))
4115 (let (buffer-read-only)
4116 (delete-region (point) (point-max))
4117 (mm-display-parts handles))))))
4119 (defun gnus-mime-save-part-and-strip ()
4120 "Save the MIME part under point then replace it with an external body."
4122 (gnus-article-check-buffer)
4123 (let* ((data (get-text-property (point) 'gnus-data))
4125 (handles gnus-article-mime-handles))
4126 (if (mm-multiple-handles gnus-article-mime-handles)
4127 (error "This function is not implemented"))
4128 (setq file (and data (mm-save-part data)))
4130 (with-current-buffer (mm-handle-buffer data)
4132 (insert "Content-Type: " (mm-handle-media-type data))
4133 (mml-insert-parameter-string (cdr (mm-handle-type data))
4136 (insert "Content-ID: " (message-make-message-id) "\n")
4137 (insert "Content-Transfer-Encoding: binary\n")
4140 (cdr (mm-make-handle nil
4141 `("message/external-body"
4142 (access-type . "LOCAL-FILE")
4144 (set-buffer gnus-summary-buffer)
4145 (gnus-article-edit-article
4148 (let ((mail-parse-charset (or gnus-article-charset
4149 ',gnus-newsgroup-charset))
4150 (mail-parse-ignored-charsets
4151 (or gnus-article-ignored-charsets
4152 ',gnus-newsgroup-ignored-charsets))
4153 (mbl mml-buffer-list))
4154 (setq mml-buffer-list nil)
4155 (insert-buffer gnus-original-article-buffer)
4156 (mime-to-mml ',handles)
4157 (setq gnus-article-mime-handles nil)
4158 (let ((mbl1 mml-buffer-list))
4159 (setq mml-buffer-list mbl)
4160 (set (make-local-variable 'mml-buffer-list) mbl1))
4161 ;; LOCAL argument of add-hook differs between GNU Emacs
4162 ;; and XEmacs. make-local-hook makes sure they are local.
4163 (make-local-hook 'kill-buffer-hook)
4164 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4165 `(lambda (no-highlight)
4166 (let ((mail-parse-charset (or gnus-article-charset
4167 ',gnus-newsgroup-charset))
4168 (message-options message-options)
4169 (message-options-set-recipient)
4170 (mail-parse-ignored-charsets
4171 (or gnus-article-ignored-charsets
4172 ',gnus-newsgroup-ignored-charsets)))
4174 (mml-destroy-buffers)
4175 (remove-hook 'kill-buffer-hook
4176 'mml-destroy-buffers t)
4177 (kill-local-variable 'mml-buffer-list))
4178 (gnus-summary-edit-article-done
4179 ,(or (mail-header-references gnus-current-headers) "")
4180 ,(gnus-group-read-only-p)
4181 ,gnus-summary-buffer no-highlight))))))
4183 (defun gnus-mime-save-part ()
4184 "Save the MIME part under point."
4186 (gnus-article-check-buffer)
4187 (let ((data (get-text-property (point) 'gnus-data)))
4189 (mm-save-part data))))
4191 (defun gnus-mime-pipe-part ()
4192 "Pipe the MIME part under point to a process."
4194 (gnus-article-check-buffer)
4195 (let ((data (get-text-property (point) 'gnus-data)))
4197 (mm-pipe-part data))))
4199 (defun gnus-mime-view-part ()
4200 "Interactively choose a viewing method for the MIME part under point."
4202 (gnus-article-check-buffer)
4203 (let ((data (get-text-property (point) 'gnus-data)))
4205 (setq gnus-article-mime-handles
4207 gnus-article-mime-handles (setq data (copy-sequence data))))
4208 (mm-interactively-view-part data))))
4210 (defun gnus-mime-view-part-as-type-internal ()
4211 (gnus-article-check-buffer)
4212 (let* ((name (mail-content-type-get
4213 (mm-handle-type (get-text-property (point) 'gnus-data))
4215 (def-type (and name (mm-default-file-encoding name))))
4216 (and def-type (cons def-type 0))))
4218 (defun gnus-mime-view-part-as-type (&optional mime-type)
4219 "Choose a MIME media type, and view the part as such."
4222 (setq mime-type (completing-read
4223 "View as MIME type: "
4224 (mapcar #'list (mailcap-mime-types))
4226 (gnus-mime-view-part-as-type-internal))))
4227 (gnus-article-check-buffer)
4228 (let ((handle (get-text-property (point) 'gnus-data)))
4231 (mm-make-handle (mm-handle-buffer handle)
4232 (cons mime-type (cdr (mm-handle-type handle)))
4233 (mm-handle-encoding handle)
4234 (mm-handle-undisplayer handle)
4235 (mm-handle-disposition handle)
4236 (mm-handle-description handle)
4238 (mm-handle-id handle)))
4239 (setq gnus-article-mime-handles
4240 (mm-merge-handles gnus-article-mime-handles handle))
4241 (gnus-mm-display-part handle))))
4243 (defun gnus-mime-copy-part (&optional handle)
4244 "Put the MIME part under point into a new buffer."
4246 (gnus-article-check-buffer)
4247 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4248 (contents (and handle (mm-get-part handle)))
4250 (file-name-nondirectory
4252 (mail-content-type-get (mm-handle-type handle) 'name)
4253 (mail-content-type-get (mm-handle-type handle)
4256 (buffer (and base (generate-new-buffer base))))
4258 (switch-to-buffer buffer)
4260 ;; We do it this way to make `normal-mode' set the appropriate mode.
4263 (setq buffer-file-name (expand-file-name base))
4265 (setq buffer-file-name nil))
4266 (goto-char (point-min)))))
4268 (defun gnus-mime-print-part (&optional handle filename)
4269 "Print the MIME part under point."
4270 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4271 (gnus-article-check-buffer)
4272 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4273 (contents (and handle (mm-get-part handle)))
4274 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4275 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4280 (with-temp-file file
4282 (call-process shell-file-name nil
4283 (generate-new-buffer " *mm*")
4285 shell-command-switch
4287 printer file (mm-handle-type handle))))
4291 (gnus-print-buffer))
4292 (ps-despool filename)))))
4294 (defun gnus-mime-inline-part (&optional handle arg)
4295 "Insert the MIME part under point into the current buffer."
4296 (interactive (list nil current-prefix-arg))
4297 (gnus-article-check-buffer)
4298 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4303 (if (and (not arg) (mm-handle-undisplayer handle))
4304 (mm-remove-part handle)
4305 (setq contents (mm-get-part handle))
4308 (setq charset (or (mail-content-type-get
4309 (mm-handle-type handle) 'charset)
4310 gnus-newsgroup-charset)))
4312 (if (mm-handle-undisplayer handle)
4313 (mm-remove-part handle))
4316 gnus-summary-show-article-charset-alist))
4317 (mm-read-coding-system "Charset: ")))))
4319 (mm-insert-inline handle
4321 (setq charset (mm-charset-to-coding-system
4323 (not (eq charset 'ascii)))
4324 (mm-decode-coding-string contents charset)
4328 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4329 "Insert the MIME part under point into the current buffer using the
4331 (interactive (list nil current-prefix-arg))
4332 (gnus-article-check-buffer)
4333 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4338 (if (mm-handle-undisplayer handle)
4339 (mm-remove-part handle))
4340 (let ((gnus-newsgroup-charset
4342 gnus-summary-show-article-charset-alist))
4343 (mm-read-coding-system "Charset: ")))
4344 (gnus-newsgroup-ignored-charsets 'gnus-all))
4345 (gnus-article-press-button)))))
4347 (defun gnus-mime-view-part-externally (&optional handle)
4348 "View the MIME part under point with an external viewer."
4350 (gnus-article-check-buffer)
4351 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4352 (mm-user-display-methods nil)
4353 (mm-inlined-types nil)
4354 (mail-parse-charset gnus-newsgroup-charset)
4355 (mail-parse-ignored-charsets
4356 (save-excursion (set-buffer gnus-summary-buffer)
4357 gnus-newsgroup-ignored-charsets)))
4359 (if (mm-handle-undisplayer handle)
4360 (mm-remove-part handle)
4361 (mm-display-part handle)))))
4363 (defun gnus-mime-view-part-internally (&optional handle)
4364 "View the MIME part under point with an internal viewer.
4365 If no internal viewer is available, use an external viewer."
4367 (gnus-article-check-buffer)
4368 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4369 (mm-inlined-types '(".*"))
4370 (mm-inline-large-images t)
4371 (mail-parse-charset gnus-newsgroup-charset)
4372 (mail-parse-ignored-charsets
4373 (save-excursion (set-buffer gnus-summary-buffer)
4374 gnus-newsgroup-ignored-charsets)))
4376 (if (mm-handle-undisplayer handle)
4377 (mm-remove-part handle)
4378 (mm-display-part handle)))))
4380 (defun gnus-mime-action-on-part (&optional action)
4381 "Do something with the MIME attachment at \(point\)."
4383 (list (completing-read "Action: " gnus-mime-action-alist)))
4384 (gnus-article-check-buffer)
4385 (let ((action-pair (assoc action gnus-mime-action-alist)))
4387 (funcall (cdr action-pair)))))
4389 (defun gnus-article-part-wrapper (n function)
4390 (save-current-buffer
4391 (set-buffer gnus-article-buffer)
4392 (when (> n (length gnus-article-mime-handle-alist))
4393 (error "No such part"))
4394 (gnus-article-goto-part n)
4395 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4396 (funcall function handle))))
4398 (defun gnus-article-pipe-part (n)
4399 "Pipe MIME part N, which is the numerical prefix."
4401 (gnus-article-part-wrapper n 'mm-pipe-part))
4403 (defun gnus-article-save-part (n)
4404 "Save MIME part N, which is the numerical prefix."
4406 (gnus-article-part-wrapper n 'mm-save-part))
4408 (defun gnus-article-interactively-view-part (n)
4409 "View MIME part N interactively, which is the numerical prefix."
4411 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4413 (defun gnus-article-copy-part (n)
4414 "Copy MIME part N, which is the numerical prefix."
4416 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4418 (defun gnus-article-view-part-as-charset (n)
4419 "Copy MIME part N, which is the numerical prefix."
4421 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4423 (defun gnus-article-view-part-externally (n)
4424 "View MIME part N externally, which is the numerical prefix."
4426 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4428 (defun gnus-article-inline-part (n)
4429 "Inline MIME part N, which is the numerical prefix."
4431 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4433 (defun gnus-article-mime-match-handle-first (condition)
4435 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4436 (while (setq ihandle (pop alist))
4438 ((functionp condition)
4439 (funcall condition (cdr ihandle)))
4440 ((eq condition 'undisplayed)
4441 (not (or (mm-handle-undisplayer (cdr ihandle))
4442 (equal (mm-handle-media-type (cdr ihandle))
4443 "multipart/alternative"))))
4444 ((eq condition 'undisplayed-alternative)
4445 (not (mm-handle-undisplayer (cdr ihandle))))
4447 (gnus-article-goto-part (car ihandle))
4448 (or (not n) (< (car ihandle) n)))
4449 (setq n (car ihandle))))
4453 (defun gnus-article-view-part (&optional n)
4454 "View MIME part N, which is the numerical prefix."
4456 (save-current-buffer
4457 (set-buffer gnus-article-buffer)
4458 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4459 gnus-article-mime-match-handle-function)))
4460 (when (> n (length gnus-article-mime-handle-alist))
4461 (error "No such part"))
4462 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4463 (when (gnus-article-goto-part n)
4464 (if (equal (car handle) "multipart/alternative")
4465 (gnus-article-press-button)
4466 (when (eq (gnus-mm-display-part handle) 'internal)
4467 (gnus-set-window-start)))))))
4469 (defsubst gnus-article-mime-total-parts ()
4470 (if (bufferp (car gnus-article-mime-handles))
4472 (1- (length gnus-article-mime-handles))))
4474 (defun gnus-mm-display-part (handle)
4475 "Display HANDLE and fix MIME button."
4476 (let ((id (get-text-property (point) 'gnus-part))
4481 (let ((window (selected-window))
4482 (mail-parse-charset gnus-newsgroup-charset)
4483 (mail-parse-ignored-charsets
4484 (if (gnus-buffer-live-p gnus-summary-buffer)
4486 (set-buffer gnus-summary-buffer)
4487 gnus-newsgroup-ignored-charsets)
4491 (let ((win (gnus-get-buffer-window (current-buffer) t))
4494 (select-window win))
4497 (if (mm-handle-displayed-p handle)
4498 ;; This will remove the part.
4499 (mm-display-part handle)
4501 (narrow-to-region (point)
4502 (if (eobp) (point) (1+ (point))))
4503 (mm-display-part handle)
4504 ;; We narrow to the part itself and
4505 ;; then call the treatment functions.
4506 (goto-char (point-min))
4508 (narrow-to-region (point) (point-max))
4511 (gnus-article-mime-total-parts)
4512 (mm-handle-media-type handle)))))
4513 (if (window-live-p window)
4514 (select-window window)))))
4516 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4517 (gnus-insert-mime-button
4518 handle id (list (mm-handle-displayed-p handle)))
4519 (goto-char point))))
4521 (defun gnus-article-goto-part (n)
4522 "Go to MIME part N."
4523 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4525 (goto-char point))))
4527 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4528 (let ((gnus-tmp-name
4529 (or (mail-content-type-get (mm-handle-type handle) 'name)
4530 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4531 (mail-content-type-get (mm-handle-type handle) 'url)
4533 (gnus-tmp-type (mm-handle-media-type handle))
4534 (gnus-tmp-description
4535 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4538 (if (if displayed (car displayed)
4539 (mm-handle-displayed-p handle))
4541 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4543 gnus-tmp-type-long b e)
4544 (when (string-match ".*/" gnus-tmp-name)
4545 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4546 (setq gnus-tmp-type-long (concat gnus-tmp-type
4547 (and (not (equal gnus-tmp-name ""))
4548 (concat "; " gnus-tmp-name))))
4549 (unless (equal gnus-tmp-description "")
4550 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4555 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4556 `(,@(gnus-local-map-property gnus-mime-button-map)
4557 gnus-callback gnus-mm-display-part
4558 gnus-part ,gnus-tmp-id
4559 article-type annotation
4562 (widget-convert-button
4565 :action 'gnus-widget-press-button
4566 :button-keymap gnus-mime-button-map
4568 (lambda (widget/window &optional overlay pos)
4569 ;; Needed to properly clear the message due to a bug in
4570 ;; wid-edit (XEmacs only).
4571 (if (boundp 'help-echo-owns-message)
4572 (setq help-echo-owns-message t))
4574 "%S: %s the MIME part; %S: more options"
4575 (aref gnus-mouse-2 0)
4576 ;; XEmacs will get a single widget arg; Emacs 21 will get
4577 ;; window, overlay, position.
4578 (if (mm-handle-displayed-p
4580 (with-current-buffer (gnus-overlay-buffer overlay)
4581 (widget-get (widget-at (gnus-overlay-start overlay))
4583 (widget-get widget/window :mime-handle)))
4585 (aref gnus-down-mouse-3 0))))))
4587 (defun gnus-widget-press-button (elems el)
4588 (goto-char (widget-get elems :from))
4589 (gnus-article-press-button))
4591 (defvar gnus-displaying-mime nil)
4593 (defun gnus-display-mime (&optional ihandles)
4594 "Display the MIME parts."
4596 (save-selected-window
4597 (let ((window (get-buffer-window gnus-article-buffer))
4600 (select-window window)
4601 ;; We have to do this since selecting the window
4602 ;; may change the point. So we set the window point.
4603 (set-window-point window point)))
4604 (let* ((handles (or ihandles (mm-dissect-buffer
4605 nil gnus-article-loose-mime)
4607 buffer-read-only handle name type b e display)
4608 (when (and (not ihandles)
4609 (not gnus-displaying-mime))
4610 ;; Top-level call; we clean up.
4611 (when gnus-article-mime-handles
4612 (mm-destroy-parts gnus-article-mime-handles)
4613 (setq gnus-article-mime-handle-alist nil));; A trick.
4614 (setq gnus-article-mime-handles handles)
4615 ;; We allow users to glean info from the handles.
4616 (when gnus-article-mime-part-function
4617 (gnus-mime-part-function handles)))
4619 (or (not (stringp (car handles)))
4622 (when (and (not ihandles)
4623 (not gnus-displaying-mime))
4624 ;; Clean up for mime parts.
4626 (delete-region (point) (point-max)))
4627 (let ((gnus-displaying-mime t))
4628 (gnus-mime-display-part handles)))
4631 (narrow-to-region (point) (point-max))
4632 (gnus-treat-article nil 1 1)
4635 ;; Highlight the headers.
4639 (narrow-to-region (point-min) (point))
4640 (gnus-treat-article 'head))))))))
4642 (defvar gnus-mime-display-multipart-as-mixed nil)
4643 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4644 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4646 (defun gnus-mime-display-part (handle)
4649 ((not (stringp (car handle)))
4650 (gnus-mime-display-single handle))
4651 ;; User-defined multipart
4652 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4653 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4655 ;; multipart/alternative
4656 ((and (equal (car handle) "multipart/alternative")
4657 (not (or gnus-mime-display-multipart-as-mixed
4658 gnus-mime-display-multipart-alternative-as-mixed)))
4659 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4660 (push (cons id handle) gnus-article-mime-handle-alist)
4661 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4662 ;; multipart/related
4663 ((and (equal (car handle) "multipart/related")
4664 (not (or gnus-mime-display-multipart-as-mixed
4665 gnus-mime-display-multipart-related-as-mixed)))
4666 ;;;!!!We should find the start part, but we just default
4667 ;;;!!!to the first part.
4668 ;;(gnus-mime-display-part (cadr handle))
4669 ;;;!!! Most multipart/related is an HTML message plus images.
4670 ;;;!!! Unfortunately we are unable to let W3 display those
4671 ;;;!!! included images, so we just display it as a mixed multipart.
4672 ;;(gnus-mime-display-mixed (cdr handle))
4673 ;;;!!! No, w3 can display everything just fine.
4674 (gnus-mime-display-part (cadr handle)))
4675 ((equal (car handle) "multipart/signed")
4676 (gnus-add-wash-type 'signed)
4677 (gnus-mime-display-security handle))
4678 ((equal (car handle) "multipart/encrypted")
4679 (gnus-add-wash-type 'encrypted)
4680 (gnus-mime-display-security handle))
4681 ;; Other multiparts are handled like multipart/mixed.
4683 (gnus-mime-display-mixed (cdr handle)))))
4685 (defun gnus-mime-part-function (handles)
4686 (if (stringp (car handles))
4687 (mapcar 'gnus-mime-part-function (cdr handles))
4688 (funcall gnus-article-mime-part-function handles)))
4690 (defun gnus-mime-display-mixed (handles)
4691 (mapcar 'gnus-mime-display-part handles))
4693 (defun gnus-mime-display-single (handle)
4694 (let ((type (mm-handle-media-type handle))
4695 (ignored gnus-ignored-mime-types)
4702 (when (string-match (pop ignored) type)
4703 (throw 'ignored nil)))
4704 (if (and (setq not-attachment
4705 (and (not (mm-inline-override-p handle))
4706 (or (not (mm-handle-disposition handle))
4707 (equal (car (mm-handle-disposition handle))
4709 (mm-attachment-override-p handle))))
4710 (mm-automatic-display-p handle)
4712 (mm-inlinable-p handle)
4713 (mm-inlined-p handle))
4714 (mm-automatic-external-display-p type)))
4716 (when (equal (mm-handle-media-supertype handle) "text")
4718 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4720 (push (cons id handle) gnus-article-mime-handle-alist)
4721 (when (or (not display)
4722 (not (gnus-unbuttonized-mime-type-p type)))
4723 ;(gnus-article-insert-newline)
4724 (gnus-insert-mime-button
4725 handle id (list (or display (and not-attachment text))))
4726 (gnus-article-insert-newline)
4727 ;(gnus-article-insert-newline)
4728 ;; Remember modify the number of forward lines.
4736 (let ((mail-parse-charset gnus-newsgroup-charset)
4737 (mail-parse-ignored-charsets
4738 (save-excursion (condition-case ()
4739 (set-buffer gnus-summary-buffer)
4741 gnus-newsgroup-ignored-charsets)))
4742 (mm-display-part handle t))
4743 (goto-char (point-max)))
4744 ((and text not-attachment)
4748 (gnus-article-insert-newline)
4749 (mm-insert-inline handle (mm-get-part handle))
4750 (goto-char (point-max))))
4754 (narrow-to-region beg (point))
4757 (gnus-article-mime-total-parts)
4758 (mm-handle-media-type handle)))))))))
4760 (defun gnus-unbuttonized-mime-type-p (type)
4761 "Say whether TYPE is to be unbuttonized."
4762 (unless gnus-inhibit-mime-unbuttonizing
4764 (let ((types gnus-unbuttonized-mime-types))
4766 (when (string-match (pop types) type)
4767 (throw 'found t)))))
4769 (let ((types gnus-buttonized-mime-types))
4771 (when (string-match (pop types) type)
4772 (throw 'found t)))))))))
4774 (defun gnus-article-insert-newline ()
4775 "Insert a newline, but mark it as undeletable."
4776 (gnus-put-text-property
4777 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4779 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4780 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4783 handle buffer-read-only from props begend not-pref)
4784 (save-window-excursion
4787 (narrow-to-region (car ibegend)
4790 (goto-char (car ibegend))
4793 (delete-region (point-min) (point-max))
4794 (mm-remove-parts handles))
4795 (setq begend (list (point-marker)))
4797 (unless (setq not-pref (cadr (member preferred ihandles)))
4798 (setq not-pref (car ihandles)))
4801 (not (gnus-unbuttonized-mime-type-p
4802 "multipart/alternative")))
4803 (gnus-add-text-properties
4806 (insert (format "%d. " id))
4810 (unless ,(not ibegend)
4811 (setq gnus-article-mime-handle-alist
4812 ',gnus-article-mime-handle-alist))
4813 (gnus-mime-display-alternative
4814 ',ihandles ',not-pref ',begend ,id))
4815 ,@(gnus-local-map-property gnus-mime-button-map)
4816 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4817 face ,gnus-article-button-face
4820 (widget-convert-button 'link from (point)
4821 :action 'gnus-widget-press-button
4822 :button-keymap gnus-widget-button-keymap)
4824 (while (setq handle (pop handles))
4825 (gnus-add-text-properties
4828 (insert (format "(%c) %-18s"
4829 (if (equal handle preferred) ?* ? )
4830 (mm-handle-media-type handle)))
4834 (unless ,(not ibegend)
4835 (setq gnus-article-mime-handle-alist
4836 ',gnus-article-mime-handle-alist))
4837 (gnus-mime-display-alternative
4838 ',ihandles ',handle ',begend ,id))
4839 ,@(gnus-local-map-property gnus-mime-button-map)
4840 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4841 face ,gnus-article-button-face
4844 (widget-convert-button 'link from (point)
4845 :action 'gnus-widget-press-button
4846 :button-keymap gnus-widget-button-keymap)
4850 (if (stringp (car preferred))
4851 (gnus-display-mime preferred)
4852 (let ((mail-parse-charset gnus-newsgroup-charset)
4853 (mail-parse-ignored-charsets
4854 (save-excursion (set-buffer gnus-summary-buffer)
4855 gnus-newsgroup-ignored-charsets)))
4856 (mm-display-part preferred)
4860 (narrow-to-region (car begend) (point-max))
4862 nil (length gnus-article-mime-handle-alist)
4863 (gnus-article-mime-total-parts)
4864 (mm-handle-media-type handle))))))
4865 (goto-char (point-max))
4866 (setcdr begend (point-marker)))))
4868 (goto-char point))))
4870 (defconst gnus-article-wash-status-strings
4871 (let ((alist '((cite "c" "Possible hidden citation text"
4872 " " "All citation text visible")
4873 (headers "h" "Hidden headers"
4874 " " "All headers visible.")
4875 (pgp "p" "Encrypted or signed message status hidden"
4876 " " "No hidden encryption nor digital signature status")
4877 (signature "s" "Signature has been hidden"
4878 " " "Signature is visible")
4879 (overstrike "o" "Overstrike (^H) characters applied"
4880 " " "No overstrike characters applied")
4881 (gnus-show-mime "m" "Mime processing is activated"
4882 " " "Mime processing is not activated")
4883 (emphasis "e" "/*_Emphasis_*/ characters applied"
4884 " " "No /*_emphasis_*/ characters applied")))
4886 (dolist (entry alist result)
4887 (let ((key (nth 0 entry))
4888 (on (copy-sequence (nth 1 entry)))
4889 (on-help (nth 2 entry))
4890 (off (copy-sequence (nth 3 entry)))
4891 (off-help (nth 4 entry)))
4892 (put-text-property 0 1 'help-echo on-help on)
4893 (put-text-property 0 1 'help-echo off-help off)
4894 (push (list key on off) result))))
4895 "Alist of strings describing wash status in the mode line.
4896 Each entry has the form (KEY ON OF), where the KEY is a symbol
4897 representing the particular washing function, ON is the string to use
4898 in the article mode line when the washing function is active, and OFF
4899 is the string to use when it is inactive.")
4901 (defun gnus-article-wash-status-entry (key value)
4902 (let ((entry (assoc key gnus-article-wash-status-strings)))
4903 (if value (nth 1 entry) (nth 2 entry))))
4905 (defun gnus-article-wash-status ()
4906 "Return a string which display status of article washing."
4908 (set-buffer gnus-article-buffer)
4909 (let ((cite (memq 'cite gnus-article-wash-types))
4910 (headers (memq 'headers gnus-article-wash-types))
4911 (boring (memq 'boring-headers gnus-article-wash-types))
4912 (pgp (memq 'pgp gnus-article-wash-types))
4913 (pem (memq 'pem gnus-article-wash-types))
4914 (signed (memq 'signed gnus-article-wash-types))
4915 (encrypted (memq 'encrypted gnus-article-wash-types))
4916 (signature (memq 'signature gnus-article-wash-types))
4917 (overstrike (memq 'overstrike gnus-article-wash-types))
4918 (emphasis (memq 'emphasis gnus-article-wash-types)))
4920 (gnus-article-wash-status-entry 'cite cite)
4921 (gnus-article-wash-status-entry 'headers (or headers boring))
4922 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4923 (gnus-article-wash-status-entry 'signature signature)
4924 (gnus-article-wash-status-entry 'overstrike overstrike)
4925 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4926 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4928 (defun gnus-add-wash-type (type)
4929 "Add a washing of TYPE to the current status."
4930 (add-to-list 'gnus-article-wash-types type))
4932 (defun gnus-delete-wash-type (type)
4933 "Add a washing of TYPE to the current status."
4934 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4936 (defun gnus-add-image (category image)
4937 "Add IMAGE of CATEGORY to the list of displayed images."
4938 (let ((entry (assq category gnus-article-image-alist)))
4940 (setq entry (list category))
4941 (push entry gnus-article-image-alist))
4942 (nconc entry (list image))))
4944 (defun gnus-delete-images (category)
4945 "Delete all images in CATEGORY."
4946 (let ((entry (assq category gnus-article-image-alist)))
4947 (dolist (image (cdr entry))
4948 (gnus-remove-image image))
4949 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4950 (gnus-delete-wash-type category)))
4952 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4954 (defun gnus-article-maybe-hide-headers ()
4955 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4956 Provided for backwards compatibility."
4957 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4958 (not (save-excursion (set-buffer gnus-summary-buffer)
4959 gnus-have-all-headers)))
4960 (not gnus-inhibit-hiding))
4961 (gnus-article-hide-headers)))
4965 (defun gnus-output-to-file (file-name)
4966 "Append the current article to a file named FILE-NAME."
4967 (let ((artbuf (current-buffer)))
4969 (insert-buffer-substring artbuf)
4970 ;; Append newline at end of the buffer as separator, and then
4972 (goto-char (point-max))
4974 (let ((file-name-coding-system nnmail-pathname-coding-system)
4975 (pathname-coding-system nnmail-pathname-coding-system))
4976 (write-region-as-binary (point-min) (point-max) file-name 'append))
4979 (defun gnus-narrow-to-page (&optional arg)
4980 "Narrow the article buffer to a page.
4981 If given a numerical ARG, move forward ARG pages."
4983 (setq arg (if arg (prefix-numeric-value arg) 0))
4985 (set-buffer gnus-article-buffer)
4986 (goto-char (point-min))
4988 ;; Remove any old next/prev buttons.
4989 (when (gnus-visual-p 'page-marker)
4990 (let ((buffer-read-only nil))
4991 (gnus-remove-text-with-property 'gnus-prev)
4992 (gnus-remove-text-with-property 'gnus-next)))
4995 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4997 (re-search-forward page-delimiter nil 'move arg)))
4998 (goto-char (match-end 0)))
5001 (if (re-search-forward page-delimiter nil 'move)
5004 (when (and (gnus-visual-p 'page-marker)
5005 (not (= (point-min) 1)))
5007 (goto-char (point-min))
5008 (gnus-insert-prev-page-button)))
5009 (when (and (gnus-visual-p 'page-marker)
5010 (< (+ (point-max) 2) (buffer-size)))
5012 (goto-char (point-max))
5013 (gnus-insert-next-page-button)))))
5015 ;; Article mode commands
5017 (defun gnus-article-goto-next-page ()
5018 "Show the next page of the article."
5020 (when (gnus-article-next-page)
5021 (goto-char (point-min))
5022 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5024 (defun gnus-article-goto-prev-page ()
5025 "Show the next page of the article."
5027 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5028 (gnus-article-prev-page nil)))
5030 (defun gnus-article-next-page (&optional lines)
5031 "Show the next page of the current article.
5032 If end of article, return non-nil. Otherwise return nil.
5033 Argument LINES specifies lines to be scrolled up."
5035 (let ((start (window-start))
5036 end-of-buffer end-of-page)
5038 (move-to-window-line -1)
5039 (if (<= (point) start)
5042 (setq start (point)))
5045 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5046 (and (pos-visible-in-window-p)
5047 (setq end-of-buffer t)))
5049 (setq end-of-page t)))
5051 (move-to-window-line lines)
5052 (unless (search-backward "\n\n" nil t)
5053 (setq start (point)))))
5054 (cond (end-of-buffer t)
5056 (gnus-narrow-to-page 1)
5060 (set-window-start (selected-window) start)
5061 (let (window-pixel-scroll-increment)
5065 (defun gnus-article-prev-page (&optional lines)
5066 "Show previous page of current article.
5067 Argument LINES specifies lines to be scrolled down."
5069 (let (beginning-of-buffer beginning-of-page)
5071 (move-to-window-line 0)
5072 (cond ((eq 1 (point))
5073 (setq beginning-of-buffer t))
5075 (setq beginning-of-page t))))
5076 (cond (beginning-of-buffer)
5078 (gnus-narrow-to-page -1))
5081 (let (window-pixel-scroll-increment)
5082 (scroll-down lines))
5083 (beginning-of-buffer
5084 (goto-char (point-min))))))))
5086 (defun gnus-article-refer-article ()
5087 "Read article specified by message-id around point."
5089 (let ((point (point)))
5090 (search-forward ">" nil t) ;Move point to end of "<....>".
5091 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5092 (let ((message-id (match-string 1)))
5094 (set-buffer gnus-summary-buffer)
5095 (gnus-summary-refer-article message-id))
5097 (error "No references around point"))))
5099 (defun gnus-article-show-summary ()
5100 "Reconfigure windows to show summary buffer."
5102 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5103 (error "There is no summary buffer for this article buffer")
5104 (gnus-article-set-globals)
5105 (gnus-configure-windows 'article)
5106 (gnus-summary-goto-subject gnus-current-article)
5107 (gnus-summary-position-point)))
5109 (defun gnus-article-describe-briefly ()
5110 "Describe article mode commands briefly."
5112 (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")))
5114 (defun gnus-article-summary-command ()
5115 "Execute the last keystroke in the summary buffer."
5117 (let ((obuf (current-buffer))
5118 (owin (current-window-configuration))
5120 (switch-to-buffer gnus-article-current-summary 'norecord)
5121 (setq func (lookup-key (current-local-map) (this-command-keys)))
5122 (call-interactively func)
5124 (set-window-configuration owin)
5125 (set-window-point (get-buffer-window (current-buffer)) (point))))
5127 (defun gnus-article-summary-command-nosave ()
5128 "Execute the last keystroke in the summary buffer."
5131 (pop-to-buffer gnus-article-current-summary 'norecord)
5132 (setq func (lookup-key (current-local-map) (this-command-keys)))
5133 (call-interactively func)))
5135 (defun gnus-article-check-buffer ()
5136 "Beep if not in an article buffer."
5137 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5138 (error "Command invoked outside of a Gnus article buffer")))
5140 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5141 "Read a summary buffer key sequence and execute it from the article buffer."
5143 (gnus-article-check-buffer)
5145 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5146 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5147 "=" "^" "\M-^" "|"))
5153 '("n" "Gn" "p" "Gp"))
5156 (set-buffer gnus-article-current-summary)
5157 (let (gnus-pick-mode)
5158 (push (or key last-command-event) unread-command-events)
5159 (setq keys (static-if (featurep 'xemacs)
5160 (events-to-keys (read-key-sequence nil))
5161 (read-key-sequence nil)))))
5164 (if (or (member keys nosaves)
5165 (member keys nosave-but-article)
5166 (member keys nosave-in-article))
5168 (save-window-excursion
5169 (pop-to-buffer gnus-article-current-summary 'norecord)
5170 ;; We disable the pick minor mode commands.
5171 (let (gnus-pick-mode)
5172 (setq func (lookup-key (current-local-map) keys))))
5176 (unless (member keys nosave-in-article)
5177 (set-buffer gnus-article-current-summary))
5178 (call-interactively func)
5179 (setq new-sum-point (point)))
5180 (when (member keys nosave-but-article)
5181 (pop-to-buffer gnus-article-buffer 'norecord)))
5182 ;; These commands should restore window configuration.
5183 (let ((obuf (current-buffer))
5184 (owin (current-window-configuration))
5186 (summary gnus-article-current-summary)
5187 func in-buffer selected)
5188 (if not-restore-window
5189 (pop-to-buffer summary 'norecord)
5190 (switch-to-buffer summary 'norecord))
5191 (setq in-buffer (current-buffer))
5192 ;; We disable the pick minor mode commands.
5193 (if (and (setq func (let (gnus-pick-mode)
5194 (lookup-key (current-local-map) keys)))
5197 (call-interactively func)
5198 (setq new-sum-point (point))
5199 (when (eq in-buffer (current-buffer))
5200 (setq selected (gnus-summary-select-article))
5202 (unless not-restore-window
5203 (set-window-configuration owin))
5204 (when (eq selected 'old)
5206 (set-window-start (get-buffer-window (current-buffer))
5208 (set-window-point (get-buffer-window (current-buffer))
5210 (let ((win (get-buffer-window gnus-article-current-summary)))
5212 (set-window-point win new-sum-point)))) )
5213 (switch-to-buffer gnus-article-buffer)
5216 (defun gnus-article-describe-key (key)
5217 "Display documentation of the function invoked by KEY. KEY is a string."
5218 (interactive "kDescribe key: ")
5219 (gnus-article-check-buffer)
5220 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5222 (set-buffer gnus-article-current-summary)
5223 (let (gnus-pick-mode)
5224 (if (featurep 'xemacs)
5226 (push (elt key 0) unread-command-events)
5227 (setq key (events-to-keys
5228 (read-key-sequence "Describe key: "))))
5229 (setq unread-command-events
5231 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5233 (setq key (read-key-sequence "Describe key: "))))
5235 (describe-key key)))
5237 (defun gnus-article-describe-key-briefly (key &optional insert)
5238 "Display documentation of the function invoked by KEY. KEY is a string."
5239 (interactive "kDescribe key: \nP")
5240 (gnus-article-check-buffer)
5241 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5243 (set-buffer gnus-article-current-summary)
5244 (let (gnus-pick-mode)
5245 (if (featurep 'xemacs)
5247 (push (elt key 0) unread-command-events)
5248 (setq key (events-to-keys
5249 (read-key-sequence "Describe key: "))))
5250 (setq unread-command-events
5252 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5254 (setq key (read-key-sequence "Describe key: "))))
5255 (describe-key-briefly key insert))
5256 (describe-key-briefly key insert)))
5258 (defun gnus-article-reply-with-original (&optional wide)
5259 "Start composing a reply mail to the current message.
5260 The text in the region will be yanked. If the region isn't active,
5261 the entire article will be yanked."
5263 (let ((article (cdr gnus-article-current)) cont)
5265 (with-current-buffer gnus-summary-buffer
5266 (gnus-summary-reply (list (list article)) wide))
5267 (setq cont (buffer-substring (point) (mark t)))
5268 ;; Deactivate active regions.
5269 (when (and (boundp 'transient-mark-mode)
5270 transient-mark-mode)
5271 (setq mark-active nil))
5272 (with-current-buffer gnus-summary-buffer
5274 (list (list article cont)) wide)))))
5276 (defun gnus-article-followup-with-original ()
5277 "Compose a followup to the current article.
5278 The text in the region will be yanked. If the region isn't active,
5279 the entire article will be yanked."
5281 (let ((article (cdr gnus-article-current)) cont)
5283 (with-current-buffer gnus-summary-buffer
5284 (gnus-summary-followup (list (list article))))
5285 (setq cont (buffer-substring (point) (mark t)))
5286 ;; Deactivate active regions.
5287 (when (and (boundp 'transient-mark-mode)
5288 transient-mark-mode)
5289 (setq mark-active nil))
5290 (with-current-buffer gnus-summary-buffer
5291 (gnus-summary-followup
5292 (list (list article cont)))))))
5294 (defun gnus-article-hide (&optional arg force)
5295 "Hide all the gruft in the current article.
5296 This means that PGP stuff, signatures, cited text and (some)
5297 headers will be hidden.
5298 If given a prefix, show the hidden text instead."
5299 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5300 (gnus-article-hide-headers arg)
5301 (gnus-article-hide-list-identifiers arg)
5302 (gnus-article-hide-pgp arg)
5303 (gnus-article-hide-citation-maybe arg force)
5304 (gnus-article-hide-signature arg))
5306 (defun gnus-article-maybe-highlight ()
5307 "Do some article highlighting if article highlighting is requested."
5308 (when (gnus-visual-p 'article-highlight 'highlight)
5309 (gnus-article-highlight-some)))
5311 (defun gnus-check-group-server ()
5312 ;; Make sure the connection to the server is alive.
5313 (unless (gnus-server-opened
5314 (gnus-find-method-for-group gnus-newsgroup-name))
5315 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5316 (gnus-request-group gnus-newsgroup-name t)))
5319 (autoload 'nneething-get-file-name "nneething"))
5321 (defun gnus-request-article-this-buffer (article group)
5322 "Get an article and insert it into this buffer."
5323 (let (do-update-line sparse-header)
5327 (gnus-kill-all-overlays)
5328 (setq group (or group gnus-newsgroup-name))
5330 ;; Using `gnus-request-article' directly will insert the article into
5331 ;; `nntp-server-buffer' - so we'll save some time by not having to
5332 ;; copy it from the server buffer into the article buffer.
5334 ;; We only request an article by message-id when we do not have the
5335 ;; headers for it, so we'll have to get those.
5336 (when (stringp article)
5337 (gnus-read-header article))
5339 ;; If the article number is negative, that means that this article
5340 ;; doesn't belong in this newsgroup (possibly), so we find its
5341 ;; message-id and request it by id instead of number.
5342 (when (and (numberp article)
5344 (get-buffer gnus-summary-buffer)
5345 (gnus-buffer-exists-p gnus-summary-buffer))
5347 (set-buffer gnus-summary-buffer)
5348 (let ((header (gnus-summary-article-header article)))
5351 ((memq article gnus-newsgroup-sparse)
5352 ;; This is a sparse gap article.
5353 (setq do-update-line article)
5354 (setq article (mail-header-id header))
5355 (setq sparse-header (gnus-read-header article))
5356 (setq gnus-newsgroup-sparse
5357 (delq article gnus-newsgroup-sparse)))
5359 ;; It's a real article.
5360 (setq article (mail-header-id header)))
5362 ;; It is an extracted pseudo-article.
5363 (setq article 'pseudo)
5364 (gnus-request-pseudo-article header))))
5366 (let ((method (gnus-find-method-for-group
5367 gnus-newsgroup-name)))
5368 (when (and (eq (car method) 'nneething)
5370 (let ((dir (nneething-get-file-name
5371 (mail-header-id header))))
5372 (when (and (stringp dir)
5373 (file-directory-p dir))
5374 (setq article 'nneething)
5375 (gnus-group-enter-directory dir))))))))
5378 ;; Refuse to select canceled articles.
5379 ((and (numberp article)
5381 (get-buffer gnus-summary-buffer)
5382 (gnus-buffer-exists-p gnus-summary-buffer)
5383 (eq (cdr (save-excursion
5384 (set-buffer gnus-summary-buffer)
5385 (assq article gnus-newsgroup-reads)))
5386 gnus-canceled-mark))
5388 ;; We first check `gnus-original-article-buffer'.
5389 ((and (get-buffer gnus-original-article-buffer)
5392 (set-buffer gnus-original-article-buffer)
5393 (and (equal (car gnus-original-article) group)
5394 (eq (cdr gnus-original-article) article))))
5395 (insert-buffer-substring gnus-original-article-buffer)
5397 ;; Check the backlog.
5398 ((and gnus-keep-backlog
5399 (gnus-backlog-request-article group article (current-buffer)))
5401 ;; Check asynchronous pre-fetch.
5402 ((gnus-async-request-fetched-article group article (current-buffer))
5403 (gnus-async-prefetch-next group article gnus-summary-buffer)
5404 (when (and (numberp article) gnus-keep-backlog)
5405 (gnus-backlog-enter-article group article (current-buffer)))
5408 ((and gnus-use-cache
5410 (gnus-cache-request-article article group))
5412 ;; Check the agent cache.
5413 ((and gnus-agent gnus-agent-cache gnus-plugged
5415 (gnus-agent-request-article article group))
5417 ;; Get the article and put into the article buffer.
5418 ((or (stringp article)
5420 (let ((gnus-override-method gnus-override-method)
5421 (methods (and (stringp article)
5422 gnus-refer-article-method))
5423 (backend (car (gnus-find-method-for-group
5424 gnus-newsgroup-name)))
5426 (buffer-read-only nil))
5427 (if (or (not (listp methods))
5428 (and (symbolp (car methods))
5429 (assq (car methods) nnoo-definition-alist)))
5430 (setq methods (list methods)))
5431 (when (and (null gnus-override-method)
5433 (setq gnus-override-method (pop methods)))
5435 (when (eq gnus-override-method 'current)
5436 (setq gnus-override-method
5437 (with-current-buffer gnus-summary-buffer
5438 gnus-current-select-method)))
5440 (gnus-kill-all-overlays)
5441 (let ((gnus-newsgroup-name group))
5442 (gnus-check-group-server))
5444 ((gnus-request-article article group (current-buffer))
5445 (when (numberp article)
5446 (gnus-async-prefetch-next group article
5447 gnus-summary-buffer)
5448 (when gnus-keep-backlog
5449 (gnus-backlog-enter-article
5450 group article (current-buffer))))
5451 (setq result 'article))
5453 (setq gnus-override-method (pop methods)))
5454 ((not (string-match "^400 "
5455 (nnheader-get-report backend)))
5456 ;; If we get 400 server disconnect, reconnect and
5457 ;; retry; otherwise, assume the article has expired.
5458 (setq result 'done))))
5459 (and (eq result 'article) 'article)))
5463 ;; Associate this article with the current summary buffer.
5464 (setq gnus-article-current-summary gnus-summary-buffer)
5466 ;; Take the article from the original article buffer
5467 ;; and place it in the buffer it's supposed to be in.
5468 (when (and (get-buffer gnus-article-buffer)
5469 (equal (buffer-name (current-buffer))
5470 (buffer-name (get-buffer gnus-article-buffer))))
5472 (if (get-buffer gnus-original-article-buffer)
5473 (set-buffer gnus-original-article-buffer)
5474 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5475 (buffer-disable-undo)
5476 (setq major-mode 'gnus-original-article-mode)
5477 (setq buffer-read-only t))
5478 (let (buffer-read-only)
5480 (insert-buffer-substring gnus-article-buffer))
5481 (setq gnus-original-article (cons group article)))
5484 (run-hooks 'gnus-article-decode-hook)
5485 ;; Mark article as decoded or not.
5486 (setq gnus-article-decoded-p gnus-article-decode-hook))
5488 ;; Update sparse articles.
5489 (when (and do-update-line
5490 (or (numberp article)
5492 (let ((buf (current-buffer)))
5493 (set-buffer gnus-summary-buffer)
5494 (gnus-summary-update-article do-update-line sparse-header)
5495 (gnus-summary-goto-subject do-update-line nil t)
5496 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5498 (set-buffer buf))))))
5504 (defcustom gnus-article-edit-mode-hook nil
5505 "Hook run in article edit mode buffers."
5506 :group 'gnus-article-various
5509 (defcustom gnus-article-edit-article-setup-function
5510 'gnus-article-mime-edit-article-setup
5511 "Function called to setup an editing article buffer."
5512 :group 'gnus-article-various
5515 (defvar gnus-article-edit-done-function nil)
5517 (defvar gnus-article-edit-mode-map nil)
5519 ;; Should we be using derived.el for this?
5520 (unless gnus-article-edit-mode-map
5521 (setq gnus-article-edit-mode-map (make-keymap))
5522 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5524 (gnus-define-keys gnus-article-edit-mode-map
5525 "\C-c?" describe-mode
5526 "\C-c\C-c" gnus-article-edit-done
5527 "\C-c\C-k" gnus-article-edit-exit
5528 "\C-c\C-f\C-t" message-goto-to
5529 "\C-c\C-f\C-o" message-goto-from
5530 "\C-c\C-f\C-b" message-goto-bcc
5531 ;;"\C-c\C-f\C-w" message-goto-fcc
5532 "\C-c\C-f\C-c" message-goto-cc
5533 "\C-c\C-f\C-s" message-goto-subject
5534 "\C-c\C-f\C-r" message-goto-reply-to
5535 "\C-c\C-f\C-n" message-goto-newsgroups
5536 "\C-c\C-f\C-d" message-goto-distribution
5537 "\C-c\C-f\C-f" message-goto-followup-to
5538 "\C-c\C-f\C-m" message-goto-mail-followup-to
5539 "\C-c\C-f\C-k" message-goto-keywords
5540 "\C-c\C-f\C-u" message-goto-summary
5541 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5542 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5543 "\C-c\C-b" message-goto-body
5544 "\C-c\C-i" message-goto-signature
5546 "\C-c\C-t" message-insert-to
5547 "\C-c\C-n" message-insert-newsgroups
5548 "\C-c\C-o" message-sort-headers
5549 "\C-c\C-e" message-elide-region
5550 "\C-c\C-v" message-delete-not-region
5551 "\C-c\C-z" message-kill-to-signature
5552 "\M-\r" message-newline-and-reformat
5553 "\C-c\C-a" mml-attach-file
5554 "\C-a" message-beginning-of-line
5556 "\M-;" comment-region)
5558 (gnus-define-keys (gnus-article-edit-wash-map
5559 "\C-c\C-w" gnus-article-edit-mode-map)
5560 "f" gnus-article-edit-full-stops))
5563 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5565 ["Fetch To" message-insert-to t]
5566 ["Fetch Newsgroups" message-insert-newsgroups t]
5568 ["To" message-goto-to t]
5569 ["From" message-goto-from t]
5570 ["Subject" message-goto-subject t]
5571 ["Cc" message-goto-cc t]
5572 ["Reply-To" message-goto-reply-to t]
5573 ["Summary" message-goto-summary t]
5574 ["Keywords" message-goto-keywords t]
5575 ["Newsgroups" message-goto-newsgroups t]
5576 ["Followup-To" message-goto-followup-to t]
5577 ["Mail-Followup-To" message-goto-mail-followup-to t]
5578 ["Distribution" message-goto-distribution t]
5579 ["Body" message-goto-body t]
5580 ["Signature" message-goto-signature t]))
5582 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5583 "Major mode for editing articles.
5584 This is an extended text-mode.
5586 \\{gnus-article-edit-mode-map}"
5587 (make-local-variable 'gnus-article-edit-done-function)
5588 (make-local-variable 'gnus-prev-winconf)
5589 (set (make-local-variable 'font-lock-defaults)
5590 '(message-font-lock-keywords t))
5591 (set (make-local-variable 'mail-header-separator) "")
5592 (easy-menu-add message-mode-field-menu message-mode-map)
5593 (setq buffer-read-only nil)
5594 (buffer-enable-undo)
5597 (defun gnus-article-edit (&optional force)
5598 "Edit the current article.
5599 This will have permanent effect only in mail groups.
5600 If FORCE is non-nil, allow editing of articles even in read-only
5603 (when (and (not force)
5604 (gnus-group-read-only-p))
5605 (error "The current newsgroup does not support article editing"))
5606 (gnus-article-date-original)
5607 (gnus-article-edit-article
5609 `(lambda (no-highlight)
5611 (gnus-summary-edit-article-done
5612 ,(or (mail-header-references gnus-current-headers) "")
5613 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5615 (defun gnus-article-edit-article (start-func exit-func)
5616 "Start editing the contents of the current article buffer."
5617 (let ((winconf (current-window-configuration)))
5618 (set-buffer gnus-article-buffer)
5619 (gnus-article-edit-mode)
5620 (funcall start-func)
5621 (set-buffer-modified-p nil)
5622 (gnus-configure-windows 'edit-article)
5623 (setq gnus-article-edit-done-function exit-func)
5624 (setq gnus-prev-winconf winconf)
5625 (when gnus-article-edit-article-setup-function
5626 (funcall gnus-article-edit-article-setup-function))
5627 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5629 (defun gnus-article-edit-done (&optional arg)
5630 "Update the article edits and exit."
5632 (let ((func gnus-article-edit-done-function)
5633 (buf (current-buffer))
5634 (start (window-start))
5636 (winconf gnus-prev-winconf))
5637 (remove-hook 'gnus-article-mode-hook
5638 'gnus-article-mime-edit-article-unwind)
5639 (widen) ;; Widen it in case that users narrowed the buffer.
5642 ;; The cache and backlog have to be flushed somewhat.
5643 (when gnus-keep-backlog
5644 (gnus-backlog-remove-article
5645 (car gnus-article-current) (cdr gnus-article-current)))
5646 ;; Flush original article as well.
5648 (when (get-buffer gnus-original-article-buffer)
5649 (set-buffer gnus-original-article-buffer)
5650 (setq gnus-original-article nil)))
5651 (when gnus-use-cache
5652 (gnus-cache-update-article
5653 (car gnus-article-current) (cdr gnus-article-current)))
5654 ;; We remove all text props from the article buffer.
5655 (kill-all-local-variables)
5656 (gnus-set-text-properties (point-min) (point-max) nil)
5658 (set-window-configuration winconf)
5660 (set-window-start (get-buffer-window buf) start)
5661 (set-window-point (get-buffer-window buf) (point))))
5663 (defun gnus-article-edit-exit ()
5664 "Exit the article editing without updating."
5666 (when (or (not (buffer-modified-p))
5667 (yes-or-no-p "Article modified; kill anyway? "))
5668 (let ((curbuf (current-buffer))
5670 (window-start (window-start)))
5672 (if (gnus-buffer-live-p gnus-original-article-buffer)
5673 (insert-buffer-substring gnus-original-article-buffer))
5674 (let ((winconf gnus-prev-winconf))
5675 (kill-all-local-variables)
5677 (set-window-configuration winconf)
5678 ;; Tippy-toe some to make sure that point remains where it was.
5679 (save-current-buffer
5681 (set-window-start (get-buffer-window (current-buffer)) window-start)
5684 (defun gnus-article-edit-full-stops ()
5685 "Interactively repair spacing at end of sentences."
5688 (goto-char (point-min))
5689 (search-forward-regexp "^$" nil t)
5690 (let ((case-fold-search nil))
5691 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5694 ;;; Article editing with MIME-Edit
5697 (defcustom gnus-article-mime-edit-article-setup-hook nil
5698 "Hook run after setting up a MIME editing article buffer."
5699 :group 'gnus-article-various
5702 (defun gnus-article-mime-edit-article-unwind ()
5703 "Unwind `gnus-article-buffer' if article editing was given up."
5704 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5705 (when (featurep 'font-lock)
5706 (setq font-lock-defaults nil)
5707 (font-lock-mode -1))
5708 (when mime-edit-mode-flag
5709 (mime-edit-exit 'nomime 'no-error)
5712 (defun gnus-article-mime-edit-article-setup ()
5713 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5714 after replacing with the original article."
5715 (setq gnus-show-mime t)
5716 (setq gnus-article-edit-done-function
5717 `(lambda (&rest args)
5718 (when mime-edit-mode-flag
5719 (let (mime-edit-insert-user-agent-field)
5722 (goto-char (point-min))
5723 (let (case-fold-search)
5724 (when (re-search-forward
5725 (format "^%s$" (regexp-quote mail-header-separator))
5727 (replace-match "")))
5728 (apply ,gnus-article-edit-done-function args)
5731 (buffer-substring-no-properties (point-min) (point-max))
5732 (set-buffer (get-buffer-create gnus-original-article-buffer))
5734 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5735 (set-buffer gnus-article-buffer)
5736 (gnus-article-prepare-display)))
5737 (substitute-key-definition 'gnus-article-edit-done
5738 'gnus-article-mime-edit-done
5739 gnus-article-edit-mode-map)
5740 (substitute-key-definition 'gnus-article-edit-exit
5741 'gnus-article-mime-edit-exit
5742 gnus-article-edit-mode-map)
5744 (insert-buffer-substring gnus-original-article-buffer)
5745 (unless (member (with-current-buffer gnus-summary-buffer
5746 gnus-newsgroup-name)
5747 '("nndraft:delayed" "nndraft:drafts"))
5748 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5749 (fset 'mime-edit-decode-single-part-in-buffer
5750 (lambda (&rest args)
5751 (if (let ((content-type (car args)))
5752 (and (eq 'message (mime-content-type-primary-type
5754 (eq 'rfc822 (mime-content-type-subtype
5756 (setcar (cdr args) 'not-decode-text))
5760 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
5761 (when (featurep 'font-lock)
5762 (set (make-local-variable 'font-lock-defaults)
5763 '(message-font-lock-keywords t))
5764 (font-lock-set-defaults)
5765 (turn-on-font-lock))
5766 (set-buffer-modified-p nil)
5767 (delete-other-windows)
5768 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5769 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5771 (defun gnus-article-mime-edit-done (&optional arg)
5772 "Update the article MIME edits and exit."
5774 (when (featurep 'font-lock)
5775 (setq font-lock-defaults nil)
5776 (font-lock-mode -1))
5777 (let ((inhibit-read-only t))
5778 (gnus-article-edit-done arg)))
5780 (defun gnus-article-mime-edit-exit ()
5781 "Exit the article MIME editing without updating."
5783 (when (or (not (buffer-modified-p))
5784 (yes-or-no-p "Article modified; kill anyway? "))
5785 (when (featurep 'font-lock)
5786 (setq font-lock-defaults nil)
5787 (font-lock-mode -1))
5788 (when mime-edit-mode-flag
5789 (let (mime-edit-insert-user-agent-field)
5792 (goto-char (point-min))
5793 (let (case-fold-search)
5794 (when (re-search-forward
5795 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5796 (replace-match "")))
5797 (let ((winconf gnus-prev-winconf))
5799 (buffer-substring-no-properties (point-min) (point-max))
5800 (set-buffer (get-buffer-create gnus-original-article-buffer))
5802 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5803 (set-buffer gnus-article-buffer)
5804 (gnus-article-prepare-display)
5805 (set-window-configuration winconf))))
5808 ;;; Article highlights
5811 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5813 ;;; Internal Variables:
5815 (defcustom gnus-button-url-regexp
5816 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5817 "\\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:]]\\)"
5818 "\\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\\)\\)")
5819 "Regular expression that matches URLs."
5820 :group 'gnus-article-buttons
5823 (defcustom gnus-button-man-handler 'manual-entry
5824 "Function to use for displaying man pages.
5825 The function must take at least one argument with a string naming the
5827 :type '(choice (function-item :tag "Man" manual-entry)
5828 (function-item :tag "Woman" woman)
5829 (function :tag "Other"))
5830 :group 'gnus-article-buttons)
5832 (defcustom gnus-button-prefer-mid-or-mail 'guess
5833 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5834 Strings like this can be either a message ID or a mail address. If the
5835 variable is set to the symbol `ask', query the user what do do. If it is the
5836 symbol `guess', Gnus will do a guess and query the user what do do if it is
5837 ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume
5838 that the string is a message ID or a mail address, respectivly. See the
5839 variable `gnus-button-guessed-mid-regexp' for details concerning the
5841 ;; FIXME: doc-string could/should be improved.
5842 :group 'gnus-article-buttons
5843 :type '(choice (const ask)
5848 (defcustom gnus-button-guessed-mid-regexp
5850 "^<?\\(slrn\\|Pine\\.\\)"
5851 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5852 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5853 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5854 "Regular expression that matches message IDs and not mail addresses."
5855 ;; TODO: Incorporate more matches from
5856 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5857 ;; Perl-REs to Elisp-REs.
5858 :group 'gnus-article-buttons
5861 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5862 (let* ((pref gnus-button-prefer-mid-or-mail)
5863 (url-mid (concat "news" ":" mid-or-mail))
5864 (url-mailto (concat "mailto" ":" mid-or-mail)))
5865 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5866 ;; If it looks like a MID (well known readers or servers) use 'mid,
5867 ;; otherwise 'ask the user.
5868 (if (eq pref 'guess)
5869 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5873 (save-window-excursion
5874 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5877 (cond ((eq pref 'mid)
5878 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5879 (gnus-button-handle-news url-mid))
5881 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5882 (gnus-url-mailto url-mailto)))))
5884 (defun gnus-button-handle-custom (url)
5885 "Follow a Custom URL."
5886 (customize-apropos (gnus-url-unhex-string url)))
5888 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5890 (defun gnus-button-handle-describe-function (url)
5891 "Call describe-function when pushing the corresponding URL button."
5894 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5896 (defun gnus-button-handle-describe-variable (url)
5897 "Call describe-variable when pushing the corresponding URL button."
5900 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5902 ;; FIXME: Is is possible to implement this? Else it should be removed here
5903 ;; and in `gnus-button-alist'.
5904 (defun gnus-button-handle-describe-key (url)
5905 "Call describe-key when pushing the corresponding URL button."
5906 (error "not implemented"))
5908 (defun gnus-button-handle-apropos (url)
5909 "Call apropos when pushing the corresponding URL button."
5910 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5912 (defun gnus-button-handle-apropos-command (url)
5913 "Call apropos when pushing the corresponding URL button."
5915 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5917 (defun gnus-button-handle-apropos-variable (url)
5918 "Call apropos when pushing the corresponding URL button."
5920 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5921 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5923 (defcustom gnus-button-man-level 5
5924 "*Integer that says how many man-related buttons Gnus will show.
5925 The higher the number, the more buttons will appear and the more false
5926 positves are possible. Note that you can set this variable local to
5927 specifific groups. Setting it higher in Unix groups is probably a good idea.
5928 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5929 how to set variables in specific groups."
5930 :group 'gnus-article-buttons
5931 :link '(custom-manual "(gnus)Group Parameters")
5934 (defcustom gnus-button-emacs-level 5
5935 "*Integer that says how many emacs-related buttons Gnus will show.
5936 The higher the number, the more buttons will appear and the more false
5937 positves are possible. Note that you can set this variable local to
5938 specifific groups. Setting it higher in Emacs or Gnus related groups is
5939 probably a good idea.See Info node `(gnus)Group Parameters' and the variable
5940 `gnus-parameters' on how to set variables in specific groups."
5941 :group 'gnus-article-buttons
5942 :link '(custom-manual "(gnus)Group Parameters")
5945 (defcustom gnus-button-mail-level 5
5946 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5947 The higher the number, the more buttons will appear and the more false
5948 positves are possible."
5949 :group 'gnus-article-buttons
5952 (defcustom gnus-button-alist
5953 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5954 0 t gnus-button-handle-news 3)
5955 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5956 gnus-button-handle-news 2)
5957 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5959 gnus-button-fetch-group 4)
5960 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5961 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5962 t gnus-button-message-id 3)
5963 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5964 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5965 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5967 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5968 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5970 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5971 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5972 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5973 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5974 ;; Emacs help commands
5975 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5976 ;; regexp doesn't match arguments containing ` '.
5977 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5978 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5979 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5980 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5981 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5982 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5983 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5984 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5985 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5986 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5987 ;; this regexp needs to be fixed!
5988 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5989 ;; This is how URLs _should_ be embedded in text...
5990 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5992 (gnus-button-url-regexp 0 t browse-url 0)
5994 ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0
5995 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5996 gnus-button-handle-man 1)
5997 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5998 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0
5999 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6000 gnus-button-handle-man 1)
6001 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv)
6002 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0
6003 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6004 ;; MID or mail: To avoid too many false positives we don't try to catch
6005 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6006 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6007 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6008 ;; so that non-ambiguous entries (see above) match first.
6009 ("\\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"
6010 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6011 "*Alist of regexps matching buttons in article bodies.
6013 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6014 REGEXP: is the string matching text around the button (can also be lisp
6015 expression evaluating to a string),
6016 BUTTON: is the number of the regexp grouping actually matching the button,
6017 FORM: is a lisp expression which must eval to true for the button to
6019 CALLBACK: is the function to call when the user push this button, and each
6020 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6022 CALLBACK can also be a variable, in that case the value of that
6023 variable it the real callback function."
6024 :group 'gnus-article-buttons
6025 :type '(repeat (list (choice regexp variable)
6026 (integer :tag "Button")
6028 (function :tag "Callback")
6031 (integer :tag "Regexp group")))))
6033 (defcustom gnus-header-button-alist
6034 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6035 0 t gnus-button-message-id 0)
6036 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6037 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6038 0 t gnus-button-mailto 0)
6039 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6040 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6041 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6042 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6043 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6044 gnus-button-message-id 3))
6045 "*Alist of headers and regexps to match buttons in article heads.
6047 This alist is very similar to `gnus-button-alist', except that each
6048 alist has an additional HEADER element first in each entry:
6050 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6052 HEADER is a regexp to match a header. For a fuller explanation, see
6053 `gnus-button-alist'."
6054 :group 'gnus-article-buttons
6055 :group 'gnus-article-headers
6056 :type '(repeat (list (regexp :tag "Header")
6058 (integer :tag "Button")
6060 (function :tag "Callback")
6063 (integer :tag "Regexp group")))))
6065 (defvar gnus-button-regexp nil)
6066 (defvar gnus-button-marker-list nil)
6067 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6069 (defvar gnus-button-last nil)
6070 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6074 (defun gnus-article-push-button (event)
6075 "Check text under the mouse pointer for a callback function.
6076 If the text under the mouse pointer has a `gnus-callback' property,
6077 call it with the value of the `gnus-data' text property."
6079 (set-buffer (window-buffer (posn-window (event-start event))))
6080 (let* ((pos (posn-point (event-start event)))
6081 (data (get-text-property pos 'gnus-data))
6082 (fun (get-text-property pos 'gnus-callback)))
6085 (funcall fun data))))
6087 (defun gnus-article-press-button ()
6088 "Check text at point for a callback function.
6089 If the text at point has a `gnus-callback' property,
6090 call it with the value of the `gnus-data' text property."
6092 (let* ((data (get-text-property (point) 'gnus-data))
6093 (fun (get-text-property (point) 'gnus-callback)))
6095 (funcall fun data))))
6097 (defun gnus-article-prev-button (n)
6098 "Move point to N buttons backward.
6099 If N is negative, move forward instead."
6101 (gnus-article-next-button (- n)))
6103 (defun gnus-article-next-button (n)
6104 "Move point to N buttons forward.
6105 If N is negative, move backward instead."
6107 (let ((function (if (< n 0) 'previous-single-property-change
6108 'next-single-property-change))
6109 (inhibit-point-motion-hooks t)
6111 (limit (if (< n 0) (point-min) (point-max))))
6113 (while (and (not (= limit (point)))
6115 ;; Skip past the current button.
6116 (when (get-text-property (point) 'gnus-callback)
6117 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6118 ;; Go to the next (or previous) button.
6119 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6120 ;; Put point at the start of the button.
6121 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6122 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6123 ;; Skip past intangible buttons.
6124 (when (get-text-property (point) 'intangible)
6128 (gnus-message 5 "No more buttons"))
6131 (defun gnus-article-highlight (&optional force)
6132 "Highlight current article.
6133 This function calls `gnus-article-highlight-headers',
6134 `gnus-article-highlight-citation',
6135 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6136 do the highlighting. See the documentation for those functions."
6137 (interactive (list 'force))
6138 (gnus-article-highlight-headers)
6139 (gnus-article-highlight-citation force)
6140 (gnus-article-highlight-signature)
6141 (gnus-article-add-buttons force)
6142 (gnus-article-add-buttons-to-head))
6144 (defun gnus-article-highlight-some (&optional force)
6145 "Highlight current article.
6146 This function calls `gnus-article-highlight-headers',
6147 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6148 do the highlighting. See the documentation for those functions."
6149 (interactive (list 'force))
6150 (gnus-article-highlight-headers)
6151 (gnus-article-highlight-signature)
6152 (gnus-article-add-buttons))
6154 (defun gnus-article-highlight-headers ()
6155 "Highlight article headers as specified by `gnus-header-face-alist'."
6158 (set-buffer gnus-article-buffer)
6160 (let ((alist gnus-header-face-alist)
6161 (buffer-read-only nil)
6162 (case-fold-search t)
6163 (inhibit-point-motion-hooks t)
6164 entry regexp header-face field-face from hpoints fpoints)
6165 (article-narrow-to-head)
6166 (while (setq entry (pop alist))
6167 (goto-char (point-min))
6168 (setq regexp (concat "^\\("
6169 (if (string-equal "" (nth 0 entry))
6173 header-face (nth 1 entry)
6174 field-face (nth 2 entry))
6175 (while (and (re-search-forward regexp nil t)
6179 (unless (search-forward ":" nil t)
6181 (when (and header-face
6182 (not (memq (point) hpoints)))
6183 (push (point) hpoints)
6184 (gnus-put-text-property from (point) 'face header-face))
6185 (when (and field-face
6186 (not (memq (setq from (point)) fpoints)))
6188 (if (re-search-forward "^[^ \t]" nil t)
6190 (goto-char (point-max)))
6191 (gnus-put-text-property from (point) 'face field-face))))))))
6193 (defun gnus-article-highlight-signature ()
6194 "Highlight the signature in an article.
6195 It does this by highlighting everything after
6196 `gnus-signature-separator' using `gnus-signature-face'."
6198 (when gnus-signature-face
6200 (set-buffer gnus-article-buffer)
6201 (let ((buffer-read-only nil)
6202 (inhibit-point-motion-hooks t))
6204 (when (gnus-article-narrow-to-signature)
6205 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6206 'face gnus-signature-face)))))))
6208 (defun gnus-article-buttonize-signature ()
6209 "Add button to the signature."
6212 (set-buffer gnus-article-buffer)
6213 (let ((buffer-read-only nil)
6214 (inhibit-point-motion-hooks t))
6215 (when (gnus-article-search-signature)
6216 (gnus-article-add-button (match-beginning 0) (match-end 0)
6217 'gnus-signature-toggle
6218 (set-marker (make-marker)
6219 (1+ (match-end 0))))))))
6221 (defun gnus-button-in-region-p (b e prop)
6222 "Say whether PROP exists in the region."
6223 (text-property-not-all b e prop nil))
6225 (defun gnus-article-add-buttons (&optional force)
6226 "Find external references in the article and make buttons of them.
6227 \"External references\" are things like Message-IDs and URLs, as
6228 specified by `gnus-button-alist'."
6229 (interactive (list 'force))
6231 (set-buffer gnus-article-buffer)
6232 (let ((buffer-read-only nil)
6233 (inhibit-point-motion-hooks t)
6234 (case-fold-search t)
6235 (alist gnus-button-alist)
6237 ;; Remove all old markers.
6238 (let (marker entry new-list)
6239 (while (setq marker (pop gnus-button-marker-list))
6240 (if (or (< marker (point-min)) (>= marker (point-max)))
6241 (push marker new-list)
6243 (when (setq entry (gnus-button-entry))
6244 (put-text-property (match-beginning (nth 1 entry))
6245 (match-end (nth 1 entry))
6246 'gnus-callback nil))
6247 (set-marker marker nil)))
6248 (setq gnus-button-marker-list new-list))
6249 ;; We skip the headers.
6252 (while (setq entry (pop alist))
6253 (setq regexp (eval (car entry)))
6255 (while (re-search-forward regexp nil t)
6256 (let* ((start (and entry (match-beginning (nth 1 entry))))
6257 (end (and entry (match-end (nth 1 entry))))
6258 (from (match-beginning 0)))
6259 (when (and (or (eq t (nth 2 entry))
6260 (eval (nth 2 entry)))
6261 (not (gnus-button-in-region-p
6262 start end 'gnus-callback)))
6263 ;; That optional form returned non-nil, so we add the
6265 (gnus-article-add-button
6266 start end 'gnus-button-push
6267 (car (push (set-marker (make-marker) from)
6268 gnus-button-marker-list))))))))))
6270 ;; Add buttons to the head of an article.
6271 (defun gnus-article-add-buttons-to-head ()
6272 "Add buttons to the head of the article."
6275 (set-buffer gnus-article-buffer)
6277 (let ((buffer-read-only nil)
6278 (inhibit-point-motion-hooks t)
6279 (case-fold-search t)
6280 (alist gnus-header-button-alist)
6282 (article-narrow-to-head)
6284 ;; Each alist entry.
6285 (setq entry (car alist)
6287 (goto-char (point-min))
6288 (while (re-search-forward (car entry) nil t)
6289 ;; Each header matching the entry.
6290 (setq beg (match-beginning 0))
6291 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6292 (match-beginning 0))
6295 (while (re-search-forward (eval (nth 1 entry)) end t)
6296 ;; Each match within a header.
6297 (let* ((entry (cdr entry))
6298 (start (match-beginning (nth 1 entry)))
6299 (end (match-end (nth 1 entry)))
6300 (form (nth 2 entry)))
6301 (goto-char (match-end 0))
6303 (gnus-article-add-button
6304 start end (nth 3 entry)
6305 (buffer-substring (match-beginning (nth 4 entry))
6306 (match-end (nth 4 entry)))))))
6307 (goto-char end)))))))
6309 ;;; External functions:
6311 (defun gnus-article-add-button (from to fun &optional data)
6312 "Create a button between FROM and TO with callback FUN and data DATA."
6313 (when gnus-article-button-face
6314 (gnus-overlay-put (gnus-make-overlay from to)
6315 'face gnus-article-button-face))
6316 (gnus-add-text-properties
6318 (nconc (and gnus-article-mouse-face
6319 (list gnus-mouse-face-prop gnus-article-mouse-face))
6320 (list 'gnus-callback fun)
6321 (and data (list 'gnus-data data))))
6322 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6323 ;; Quote `:button-keymap' for Mule 2.3
6324 ;; but it won't work.
6325 ':button-keymap gnus-widget-button-keymap))
6327 ;;; Internal functions:
6329 (defun gnus-article-set-globals ()
6331 (set-buffer gnus-summary-buffer)
6332 (gnus-set-global-variables)))
6334 (defun gnus-signature-toggle (end)
6336 (set-buffer gnus-article-buffer)
6337 (let ((buffer-read-only nil)
6338 (inhibit-point-motion-hooks t)
6339 (limit (next-single-property-change end 'mime-view-entity
6341 (if (text-property-any end limit 'article-type 'signature)
6343 (gnus-delete-wash-type 'signature)
6344 (gnus-remove-text-properties-when
6345 'article-type 'signature end limit
6346 (cons 'article-type (cons 'signature
6347 gnus-hidden-properties))))
6348 (gnus-add-wash-type 'signature)
6349 (gnus-add-text-properties-when
6350 'article-type nil end limit
6351 (cons 'article-type (cons 'signature
6352 gnus-hidden-properties)))))
6353 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6354 (gnus-set-mode-line 'article))))
6356 (defun gnus-button-entry ()
6357 ;; Return the first entry in `gnus-button-alist' matching this place.
6358 (let ((alist gnus-button-alist)
6361 (setq entry (pop alist))
6362 (if (looking-at (eval (car entry)))
6367 (defun gnus-button-push (marker)
6368 ;; Push button starting at MARKER.
6371 (let* ((entry (gnus-button-entry))
6372 (inhibit-point-motion-hooks t)
6374 (args (mapcar (lambda (group)
6375 (let ((string (match-string group)))
6376 (gnus-set-text-properties
6377 0 (length string) nil string)
6384 (fboundp (symbol-value fun)))
6385 (apply (symbol-value fun) args))
6387 (gnus-message 1 "You must define `%S' to use this button"
6388 (cons fun args)))))))
6390 (defun gnus-parse-news-url (url)
6391 (let (scheme server group message-id articles)
6394 (goto-char (point-min))
6395 (when (looking-at "\\([A-Za-z]+\\):")
6396 (setq scheme (match-string 1))
6397 (goto-char (match-end 0)))
6398 (when (looking-at "//\\([^/]+\\)/")
6399 (setq server (match-string 1))
6400 (goto-char (match-end 0)))
6403 ((looking-at "\\(.*@.*\\)")
6404 (setq message-id (match-string 1)))
6405 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6406 (setq group (match-string 1)
6407 articles (split-string (match-string 2) "-")))
6408 ((looking-at "\\([^/]+\\)/?")
6409 (setq group (match-string 1)))
6411 (error "Unknown news URL syntax"))))
6412 (list scheme server group message-id articles)))
6414 (defun gnus-button-handle-news (url)
6416 (destructuring-bind (scheme server group message-id articles)
6417 (gnus-parse-news-url url)
6421 (set-buffer gnus-summary-buffer)
6423 (let ((gnus-refer-article-method (list (list 'nntp server))))
6424 (gnus-summary-refer-article message-id))
6425 (gnus-summary-refer-article message-id))))
6427 (gnus-button-fetch-group url)))))
6429 (defun gnus-button-handle-man (url)
6431 (funcall gnus-button-man-handler url))
6433 (defun gnus-button-handle-info (url)
6434 "Fetch an info URL."
6436 "^\\([^:/]+\\)?/\\(.*\\)"
6438 (gnus-info-find-node
6439 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6442 (gnus-url-unhex-string (match-string 2 url))))
6443 (error "Can't parse %s" url)))
6445 (defun gnus-button-message-id (message-id)
6448 (set-buffer gnus-summary-buffer)
6449 (gnus-summary-refer-article message-id)))
6451 (defun gnus-button-fetch-group (address)
6452 "Fetch GROUP specified by ADDRESS."
6453 (if (not (string-match "[:/]" address))
6454 ;; This is just a simple group url.
6455 (gnus-group-read-ephemeral-group address gnus-select-method)
6458 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6460 (error "Can't parse %s" address)
6461 (gnus-group-read-ephemeral-group
6462 (match-string 4 address)
6463 `(nntp ,(match-string 1 address)
6464 (nntp-address ,(match-string 1 address))
6465 (nntp-port-number ,(if (match-end 3)
6466 (match-string 3 address)
6469 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6471 (defun gnus-url-parse-query-string (query &optional downcase)
6472 (let (retval pairs cur key val)
6473 (setq pairs (split-string query "&"))
6475 (setq cur (car pairs)
6477 (if (not (string-match "=" cur))
6479 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6480 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6482 (setq key (downcase key)))
6483 (setq cur (assoc key retval))
6485 (setcdr cur (cons val (cdr cur)))
6486 (setq retval (cons (list key val) retval)))))
6489 (defun gnus-url-mailto (url)
6490 ;; Send mail to someone
6491 (when (string-match "mailto:/*\\(.*\\)" url)
6492 (setq url (substring url (match-beginning 1) nil)))
6493 (let (to args subject func)
6494 (if (string-match (regexp-quote "?") url)
6495 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6496 args (gnus-url-parse-query-string
6497 (substring url (match-end 0) nil) t))
6498 (setq to (gnus-url-unhex-string url)))
6499 (setq args (cons (list "to" to) args)
6500 subject (cdr-safe (assoc "subject" args)))
6503 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6506 (message-position-on-field (caar args)))
6507 (insert (mapconcat 'identity (cdar args) ", "))
6508 (setq args (cdr args)))
6511 (message-goto-subject))))
6513 (defun gnus-button-embedded-url (address)
6514 "Activate ADDRESS with `browse-url'."
6515 (browse-url (gnus-strip-whitespace address)))
6517 ;;; Next/prev buttons in the article buffer.
6519 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6520 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6522 (defvar gnus-prev-page-map
6523 (let ((map (make-sparse-keymap)))
6524 (unless (>= emacs-major-version 21)
6525 ;; XEmacs doesn't care.
6526 (set-keymap-parent map gnus-article-mode-map))
6527 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6528 (define-key map "\r" 'gnus-button-prev-page)
6531 (defun gnus-insert-prev-page-button ()
6533 (buffer-read-only nil)
6534 (situation (get-text-property (point-min) 'mime-view-situation)))
6536 gnus-prev-page-line-format nil
6537 `(,@(gnus-local-map-property gnus-prev-page-map)
6539 gnus-callback gnus-article-button-prev-page
6540 article-type annotation
6541 mime-view-situation ,situation))
6542 (widget-convert-button
6544 :action 'gnus-button-prev-page
6545 :button-keymap gnus-prev-page-map)))
6547 (defvar gnus-next-page-map
6548 (let ((map (make-sparse-keymap)))
6549 (unless (>= emacs-major-version 21)
6550 ;; XEmacs doesn't care.
6551 (set-keymap-parent map gnus-article-mode-map))
6552 (define-key map gnus-mouse-2 'gnus-button-next-page)
6553 (define-key map "\r" 'gnus-button-next-page)
6556 (defun gnus-button-next-page (&optional args more-args)
6557 "Go to the next page."
6559 (let ((win (selected-window)))
6560 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6561 (gnus-article-next-page)
6562 (select-window win)))
6564 (defun gnus-button-prev-page (&optional args more-args)
6565 "Go to the prev page."
6567 (let ((win (selected-window)))
6568 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6569 (gnus-article-prev-page)
6570 (select-window win)))
6572 (defun gnus-insert-next-page-button ()
6574 (buffer-read-only nil)
6575 (situation (get-text-property (point-min) 'mime-view-situation)))
6576 (gnus-eval-format gnus-next-page-line-format nil
6577 `(,@(gnus-local-map-property gnus-next-page-map)
6579 gnus-callback gnus-article-button-next-page
6580 article-type annotation
6581 mime-view-situation ,situation))
6582 (widget-convert-button
6584 :action 'gnus-button-next-page
6585 :button-keymap gnus-next-page-map)))
6587 (defun gnus-article-button-next-page (arg)
6588 "Go to the next page."
6590 (let ((win (selected-window)))
6591 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6592 (gnus-article-next-page)
6593 (select-window win)))
6595 (defun gnus-article-button-prev-page (arg)
6596 "Go to the prev page."
6598 (let ((win (selected-window)))
6599 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6600 (gnus-article-prev-page)
6601 (select-window win)))
6603 (defvar gnus-decode-header-methods
6604 '(mail-decode-encoded-word-region)
6605 "List of methods used to decode headers.
6607 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6608 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6609 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6610 whose names match REGEXP.
6613 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6614 mail-decode-encoded-word-region
6615 (\"chinese\" . rfc1843-decode-region))
6618 (defvar gnus-decode-header-methods-cache nil)
6620 (defun gnus-multi-decode-header (start end)
6621 "Apply the functions from `gnus-encoded-word-methods' that match."
6622 (unless (and gnus-decode-header-methods-cache
6623 (eq gnus-newsgroup-name
6624 (car gnus-decode-header-methods-cache)))
6625 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6628 (nconc gnus-decode-header-methods-cache (list x))
6629 (if (and gnus-newsgroup-name
6630 (string-match (car x) gnus-newsgroup-name))
6631 (nconc gnus-decode-header-methods-cache
6633 gnus-decode-header-methods))
6634 (let ((xlist gnus-decode-header-methods-cache))
6637 (narrow-to-region start end)
6639 (funcall (pop xlist) (point-min) (point-max))))))
6642 ;;; Treatment top-level handling.
6645 (defun gnus-treat-article (condition &optional part-number total-parts type)
6646 (let ((length (- (point-max) (point-min)))
6647 (alist gnus-treatment-function-alist)
6648 (article-goto-body-goes-to-point-min-p t)
6652 (let ((list gnus-article-treat-types))
6654 (when (string-match (pop list) type)
6655 (throw 'found t)))))))
6656 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6657 (entity (static-unless (featurep 'xemacs)
6658 (when (eq 'head condition)
6659 (get-text-property (point-min) 'mime-view-entity))))
6660 val elem buttonized)
6661 (gnus-run-hooks 'gnus-part-display-hook)
6662 (unless gnus-inhibit-treatment
6663 (while (setq elem (pop alist))
6666 (if (gnus-buffer-live-p gnus-summary-buffer)
6667 (set-buffer gnus-summary-buffer))
6668 (symbol-value (car elem))))
6669 (when (and (or (consp val)
6671 (gnus-treat-predicate val)
6672 (or (not (get (car elem) 'highlight))
6674 (when (and (not buttonized)
6676 '(gnus-treat-hide-signature
6677 gnus-treat-highlight-signature)))
6678 (gnus-article-buttonize-signature)
6679 (setq buttonized t))
6681 (funcall (cadr elem)))))
6682 ;; FSF Emacsen does not inherit the existing text properties
6683 ;; in the new text, so we should do it for `mime-view-entity'.
6684 (static-unless (featurep 'xemacs)
6686 (put-text-property (point-min) (point-max)
6687 'mime-view-entity entity))))))
6689 ;; Dynamic variables.
6691 (defvar part-number)
6692 (defvar total-parts)
6697 (defun gnus-treat-predicate (val)
6702 (stringp (car val)))
6703 (apply 'gnus-or (mapcar `(lambda (s)
6704 (string-match s ,(or gnus-newsgroup-name "")))
6707 (let ((pred (pop val)))
6710 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6712 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6714 (not (gnus-treat-predicate (car val))))
6716 (equal (car val) type))
6718 (error "%S is not a valid predicate" pred)))))
6728 (eq part-number total-parts))
6732 (error "%S is not a valid value" val))))
6734 (defun gnus-article-encrypt-body (protocol &optional n)
6735 "Encrypt the article body."
6738 (or gnus-article-encrypt-protocol
6739 (completing-read "Encrypt protocol: "
6740 gnus-article-encrypt-protocol-alist
6742 current-prefix-arg))
6743 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6745 (error (format "Can't find the encrypt protocol %s" protocol)))
6746 (if (member gnus-newsgroup-name '("nndraft:delayed"
6749 (error "Can't encrypt the article in group %s"
6750 gnus-newsgroup-name))
6751 (gnus-summary-iterate n
6753 (set-buffer gnus-summary-buffer)
6754 (let ((mail-parse-charset gnus-newsgroup-charset)
6755 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6756 (summary-buffer gnus-summary-buffer)
6758 (gnus-set-global-variables)
6759 (when (gnus-group-read-only-p)
6760 (error "The current newsgroup does not support article encrypt"))
6761 (gnus-summary-show-article t)
6763 (or (mail-header-references gnus-current-headers) ""))
6764 (set-buffer gnus-article-buffer)
6765 (let* ((buffer-read-only nil)
6767 (mapcar (lambda (field)
6768 (and (save-restriction
6769 (message-narrow-to-head)
6770 (goto-char (point-min))
6771 (search-forward field nil t))
6773 (message-narrow-to-field)
6774 (buffer-substring (point-min) (point-max))
6775 (delete-region (point-min) (point-max))
6777 '("Content-Type:" "Content-Transfer-Encoding:"
6778 "Content-Disposition:"))))
6779 (message-narrow-to-head)
6780 (message-remove-header "MIME-Version")
6781 (goto-char (point-max))
6782 (setq point (point))
6783 (insert (apply 'concat headers))
6785 (narrow-to-region point (point-max))
6786 (let ((message-options message-options))
6787 (message-options-set 'message-sender user-mail-address)
6788 (message-options-set 'message-recipients user-mail-address)
6789 (message-options-set 'message-sign-encrypt 'not)
6791 (goto-char (point-min))
6792 (insert "MIME-Version: 1.0\n")
6794 (gnus-summary-edit-article-done
6795 references nil summary-buffer t))
6796 (when gnus-keep-backlog
6797 (gnus-backlog-remove-article
6798 (car gnus-article-current) (cdr gnus-article-current)))
6800 (when (get-buffer gnus-original-article-buffer)
6801 (set-buffer gnus-original-article-buffer)
6802 (setq gnus-original-article nil)))
6803 (when gnus-use-cache
6804 (gnus-cache-update-article
6805 (car gnus-article-current) (cdr gnus-article-current))))))))
6807 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6808 "The following specs can be used:
6809 %t The security MIME type
6812 %D Details if button is pressed")
6814 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6815 "The following specs can be used:
6816 %t The security MIME type
6819 %D Details if button is pressed")
6821 (defvar gnus-mime-security-button-line-format-alist
6822 '((?t gnus-tmp-type ?s)
6823 (?i gnus-tmp-info ?s)
6824 (?d gnus-tmp-details ?s)
6825 (?D gnus-tmp-pressed-details ?s)))
6827 (defvar gnus-mime-security-button-map
6828 (let ((map (make-sparse-keymap)))
6829 (unless (>= (string-to-number emacs-version) 21)
6830 (set-keymap-parent map gnus-article-mode-map))
6831 (define-key map gnus-mouse-2 'gnus-article-push-button)
6832 (define-key map "\r" 'gnus-article-press-button)
6835 (defvar gnus-mime-security-details-buffer nil)
6837 (defvar gnus-mime-security-button-pressed nil)
6839 (defvar gnus-mime-security-show-details-inline t
6840 "If non-nil, show details in the article buffer.")
6842 (defun gnus-mime-security-verify-or-decrypt (handle)
6843 (mm-remove-parts (cdr handle))
6844 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6845 point buffer-read-only)
6847 (goto-char (car region)))
6849 (narrow-to-region (point) (point))
6850 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6851 (let* ((mm-verify-option 'known)
6852 (mm-decrypt-option 'known)
6853 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6854 (unless (eq nparts (cdr handle))
6855 (mm-destroy-parts (cdr handle))
6856 (setcdr handle nparts))))
6857 (setq point (point))
6858 (gnus-mime-display-security handle)
6859 (goto-char (point-max)))
6861 (delete-region (point) (cdr region))
6862 (set-marker (car region) nil)
6863 (set-marker (cdr region) nil))
6866 (defun gnus-mime-security-show-details (handle)
6867 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6869 (if gnus-mime-security-show-details-inline
6870 (let ((gnus-mime-security-button-pressed t)
6871 (gnus-mime-security-button-line-format
6872 (get-text-property (point) 'gnus-line-format))
6875 (while (eq (get-text-property (point) 'gnus-line-format)
6876 gnus-mime-security-button-line-format)
6880 (narrow-to-region (point) (point))
6881 (gnus-insert-mime-security-button handle))
6882 (delete-region (point)
6883 (or (text-property-not-all
6886 gnus-mime-security-button-line-format)
6888 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6889 (with-current-buffer gnus-mime-security-details-buffer
6892 (setq gnus-mime-security-details-buffer
6893 (gnus-get-buffer-create "*MIME Security Details*")))
6894 (with-current-buffer gnus-mime-security-details-buffer
6896 (goto-char (point-min)))
6897 (pop-to-buffer gnus-mime-security-details-buffer))
6898 (gnus-message 5 "No details."))))
6900 (defun gnus-mime-security-press-button (handle)
6901 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6902 (gnus-mime-security-show-details handle)
6903 (gnus-mime-security-verify-or-decrypt handle)))
6905 (defun gnus-insert-mime-security-button (handle &optional displayed)
6906 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6909 (or (nth 2 (assoc protocol mm-verify-function-alist))
6910 (nth 2 (assoc protocol mm-decrypt-function-alist))
6912 (if (equal (car handle) "multipart/signed")
6913 " Signed" " Encrypted")
6916 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6919 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6920 gnus-tmp-pressed-details
6922 (setq gnus-tmp-details
6923 (if gnus-tmp-details
6924 (concat "\n" gnus-tmp-details) ""))
6925 (setq gnus-tmp-pressed-details
6926 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6931 gnus-mime-security-button-line-format
6932 gnus-mime-security-button-line-format-alist
6933 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6934 gnus-callback gnus-mime-security-press-button
6935 gnus-line-format ,gnus-mime-security-button-line-format
6936 article-type annotation
6939 (widget-convert-button
6942 :action 'gnus-widget-press-button
6943 :button-keymap gnus-mime-security-button-map
6945 (lambda (widget/window &optional overlay pos)
6946 ;; Needed to properly clear the message due to a bug in
6947 ;; wid-edit (XEmacs only).
6948 (if (boundp 'help-echo-owns-message)
6949 (setq help-echo-owns-message t))
6952 (aref gnus-mouse-2 0))))))
6954 (defun gnus-mime-display-security (handle)
6956 (narrow-to-region (point) (point))
6957 (unless (gnus-unbuttonized-mime-type-p (car handle))
6958 (gnus-insert-mime-security-button handle))
6959 (gnus-mime-display-mixed (cdr handle))
6962 (unless (gnus-unbuttonized-mime-type-p (car handle))
6963 (let ((gnus-mime-security-button-line-format
6964 gnus-mime-security-button-end-line-format))
6965 (gnus-insert-mime-security-button handle)))
6966 (mm-set-handle-multipart-parameter
6968 (cons (set-marker (make-marker) (point-min))
6969 (set-marker (make-marker) (point-max))))))
6975 (defun gnus-article-header-presentation-method (entity situation)
6976 (mime-insert-header entity)
6977 (article-decode-group-name))
6979 (set-alist 'mime-header-presentation-method-alist
6980 'gnus-original-article-mode
6981 #'gnus-article-header-presentation-method)
6983 (defun gnus-mime-preview-quitting-method ()
6984 (mime-preview-kill-buffer)
6985 (delete-other-windows)
6986 (gnus-article-show-summary)
6987 (gnus-summary-select-article gnus-show-all-headers t))
6989 (set-alist 'mime-preview-quitting-method-alist
6990 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6992 (set-alist 'mime-preview-following-method-alist
6993 'gnus-original-article-mode #'gnus-following-method)
6995 (set-alist 'mime-preview-over-to-previous-method-alist
6996 'gnus-original-article-mode
6998 (if (> (point-min) 1)
6999 (gnus-article-prev-page)
7000 (gnus-article-read-summary-keys
7001 nil (gnus-character-to-event ?P)))))
7003 (set-alist 'mime-preview-over-to-next-method-alist
7004 'gnus-original-article-mode'
7006 (if (< (point-max) (buffer-size))
7007 (gnus-article-next-page)
7008 (gnus-article-read-summary-keys
7009 nil (gnus-character-to-event ?N)))))
7019 (run-hooks 'gnus-art-load-hook)
7021 ;;; gnus-art.el ends here