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)
1464 "Syntax table used in article mode buffers.
1465 Initialized from `text-mode-syntax-table.")
1467 (defvar gnus-save-article-buffer nil)
1469 (defvar gnus-article-mode-line-format-alist
1470 (nconc '((?w (gnus-article-wash-status) ?s)
1471 (?m (gnus-article-mime-part-status) ?s))
1472 gnus-summary-mode-line-format-alist))
1474 (defvar gnus-number-of-articles-to-be-saved nil)
1476 (defvar gnus-inhibit-hiding nil)
1478 ;;; Macros for dealing with the article buffer.
1480 (defmacro gnus-with-article-headers (&rest forms)
1482 (set-buffer gnus-article-buffer)
1484 (let ((buffer-read-only nil)
1485 (inhibit-point-motion-hooks t)
1486 (case-fold-search t))
1487 (article-narrow-to-head)
1490 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1491 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1493 (defmacro gnus-with-article-buffer (&rest forms)
1495 (set-buffer gnus-article-buffer)
1496 (let ((buffer-read-only nil))
1499 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1500 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1502 (defun gnus-article-goto-header (header)
1503 "Go to HEADER, which is a regular expression."
1504 (re-search-forward (concat "^\\(" header "\\):") nil t))
1506 (defsubst gnus-article-hide-text (b e props)
1507 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1508 (gnus-add-text-properties-when 'article-type nil b e props)
1509 (when (memq 'intangible props)
1511 (max (1- b) (point-min))
1512 b 'intangible (cddr (memq 'intangible props)))))
1514 (defsubst gnus-article-unhide-text (b e)
1515 "Remove hidden text properties from region between B and E."
1516 (remove-text-properties b e gnus-hidden-properties)
1517 (when (memq 'intangible gnus-hidden-properties)
1518 (put-text-property (max (1- b) (point-min))
1519 b 'intangible nil)))
1521 (defun gnus-article-hide-text-type (b e type)
1522 "Hide text of TYPE between B and E."
1523 (gnus-add-wash-type type)
1524 (gnus-article-hide-text
1525 b e (cons 'article-type (cons type gnus-hidden-properties))))
1527 (defun gnus-article-unhide-text-type (b e type)
1528 "Unhide text of TYPE between B and E."
1529 (gnus-delete-wash-type type)
1530 (remove-text-properties
1531 b e (cons 'article-type (cons type gnus-hidden-properties)))
1532 (when (memq 'intangible gnus-hidden-properties)
1533 (put-text-property (max (1- b) (point-min))
1534 b 'intangible nil)))
1536 (defun gnus-article-hide-text-of-type (type)
1537 "Hide text of TYPE in the current buffer."
1539 (let ((b (point-min))
1541 (while (setq b (text-property-any b e 'article-type type))
1542 (add-text-properties b (incf b) gnus-hidden-properties)))))
1544 (defun gnus-article-delete-text-of-type (type)
1545 "Delete text of TYPE in the current buffer."
1547 (let ((b (point-min)))
1548 (while (setq b (text-property-any b (point-max) 'article-type type))
1550 b (or (text-property-not-all b (point-max) 'article-type type)
1553 (defun gnus-article-delete-invisible-text ()
1554 "Delete all invisible text in the current buffer."
1556 (let ((b (point-min)))
1557 (while (setq b (text-property-any b (point-max) 'invisible t))
1559 b (or (text-property-not-all b (point-max) 'invisible t)
1562 (defun gnus-article-text-type-exists-p (type)
1563 "Say whether any text of type TYPE exists in the buffer."
1564 (text-property-any (point-min) (point-max) 'article-type type))
1566 (defsubst gnus-article-header-rank ()
1567 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1568 (let ((list gnus-sorted-header-list)
1571 (when (looking-at (car list))
1573 (setq list (cdr list))
1577 (defun article-hide-headers (&optional arg delete)
1578 "Hide unwanted headers and possibly sort them as well."
1579 (interactive (gnus-article-hidden-arg))
1580 ;; Lars said that this function might be inhibited.
1581 (if (gnus-article-check-hidden-text 'headers arg)
1583 ;; Show boring headers as well.
1584 (gnus-article-show-hidden-text 'boring-headers)
1585 (when (eq 1 (point-min))
1586 (set-window-start (get-buffer-window (current-buffer)) 1)))
1587 (unless gnus-inhibit-hiding
1590 (let ((inhibit-read-only t)
1591 (case-fold-search t)
1592 (max (1+ (length gnus-sorted-header-list)))
1593 (ignored (when (not gnus-visible-headers)
1594 (cond ((stringp gnus-ignored-headers)
1595 gnus-ignored-headers)
1596 ((listp gnus-ignored-headers)
1597 (mapconcat 'identity gnus-ignored-headers
1600 (cond ((stringp gnus-visible-headers)
1601 gnus-visible-headers)
1602 ((and gnus-visible-headers
1603 (listp gnus-visible-headers))
1604 (mapconcat 'identity gnus-visible-headers "\\|"))))
1605 (inhibit-point-motion-hooks t)
1607 ;; First we narrow to just the headers.
1608 (article-narrow-to-head)
1609 ;; Hide any "From " lines at the beginning of (mail) articles.
1610 (while (looking-at "From ")
1614 (delete-region (point-min) (point))
1615 (gnus-article-hide-text (point-min) (point)
1616 (nconc (list 'article-type 'headers)
1617 gnus-hidden-properties))))
1618 ;; Then treat the rest of the header lines.
1619 ;; Then we use the two regular expressions
1620 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1621 ;; select which header lines is to remain visible in the
1623 (while (re-search-forward "^[^ \t:]*:" nil t)
1625 ;; Mark the rank of the header.
1627 (point) (1+ (point)) 'message-rank
1628 (if (or (and visible (looking-at visible))
1630 (not (looking-at ignored))))
1631 (gnus-article-header-rank)
1634 (message-sort-headers-1)
1635 (when (setq beg (text-property-any
1636 (point-min) (point-max) 'message-rank (+ 2 max)))
1637 ;; We delete or make invisible the unwanted headers.
1638 (gnus-add-wash-type 'headers)
1641 (add-text-properties
1642 (point-min) (+ 5 (point-min))
1643 '(article-type headers dummy-invisible t))
1644 (delete-region beg (point-max)))
1645 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1647 (defun article-hide-boring-headers (&optional arg)
1648 "Toggle hiding of headers that aren't very interesting.
1649 If given a negative prefix, always show; if given a positive prefix,
1651 (interactive (gnus-article-hidden-arg))
1652 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1653 (not gnus-show-all-headers))
1656 (let ((buffer-read-only nil)
1657 (list gnus-boring-article-headers)
1658 (inhibit-point-motion-hooks t)
1660 (article-narrow-to-head)
1662 (setq elem (pop list))
1663 (goto-char (point-min))
1665 ;; Hide empty headers.
1667 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1669 (gnus-article-hide-text-type
1670 (progn (beginning-of-line) (point))
1673 (if (re-search-forward "^[^ \t]" nil t)
1677 ;; Hide boring Newsgroups header.
1678 ((eq elem 'newsgroups)
1679 (when (gnus-string-equal
1680 (gnus-fetch-field "newsgroups")
1681 (gnus-group-real-name
1682 (if (boundp 'gnus-newsgroup-name)
1685 (gnus-article-hide-header "newsgroups")))
1686 ((eq elem 'to-address)
1687 (let ((to (message-fetch-field "to"))
1689 (gnus-parameter-to-address
1690 (if (boundp 'gnus-newsgroup-name)
1691 gnus-newsgroup-name ""))))
1692 (when (and to to-address
1695 ;; only one address in To
1696 (nth 1 (mail-extract-address-components to))
1698 (gnus-article-hide-header "to"))))
1699 ((eq elem 'followup-to)
1700 (when (gnus-string-equal
1701 (message-fetch-field "followup-to")
1702 (message-fetch-field "newsgroups"))
1703 (gnus-article-hide-header "followup-to")))
1704 ((eq elem 'reply-to)
1705 (let ((from (message-fetch-field "from"))
1706 (reply-to (message-fetch-field "reply-to")))
1711 (nth 1 (mail-extract-address-components from))
1712 (nth 1 (mail-extract-address-components reply-to)))))
1713 (gnus-article-hide-header "reply-to"))))
1715 (let ((date (message-fetch-field "date")))
1717 (< (days-between (current-time-string) date)
1719 (gnus-article-hide-header "date"))))
1721 (let ((to (message-fetch-field "to"))
1722 (cc (message-fetch-field "cc")))
1723 (when (> (length to) 1024)
1724 (gnus-article-hide-header "to"))
1725 (when (> (length cc) 1024)
1726 (gnus-article-hide-header "cc"))))
1730 (goto-char (point-min))
1731 (while (re-search-forward "^to:" nil t)
1732 (setq to-count (1+ to-count)))
1733 (when (> to-count 1)
1734 (while (> to-count 0)
1735 (goto-char (point-min))
1737 (re-search-forward "^to:" nil nil to-count)
1739 (narrow-to-region (point) (point-max))
1740 (gnus-article-hide-header "to"))
1741 (setq to-count (1- to-count))))
1742 (goto-char (point-min))
1743 (while (re-search-forward "^cc:" nil t)
1744 (setq cc-count (1+ cc-count)))
1745 (when (> cc-count 1)
1746 (while (> cc-count 0)
1747 (goto-char (point-min))
1749 (re-search-forward "^cc:" nil nil cc-count)
1751 (narrow-to-region (point) (point-max))
1752 (gnus-article-hide-header "cc"))
1753 (setq cc-count (1- cc-count)))))))))))))
1755 (defun gnus-article-hide-header (header)
1757 (goto-char (point-min))
1758 (when (re-search-forward (concat "^" header ":") nil t)
1759 (gnus-article-hide-text-type
1760 (progn (beginning-of-line) (point))
1763 (if (re-search-forward "^[^ \t]" nil t)
1768 (defvar gnus-article-normalized-header-length 40
1769 "Length of normalized headers.")
1771 (defun article-normalize-headers ()
1772 "Make all header lines 40 characters long."
1774 (let ((buffer-read-only nil)
1778 (article-narrow-to-head)
1781 ((< (setq column (- (gnus-point-at-eol) (point)))
1782 gnus-article-normalized-header-length)
1784 (insert (make-string
1785 (- gnus-article-normalized-header-length column)
1787 ((> column gnus-article-normalized-header-length)
1788 (gnus-put-text-property
1790 (forward-char gnus-article-normalized-header-length)
1797 (forward-line 1))))))
1799 (defun article-treat-dumbquotes ()
1800 "Translate M****s*** sm*rtq**t*s into proper text.
1801 Note that this function guesses whether a character is a sm*rtq**t* or
1802 not, so it should only be used interactively.
1804 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1805 in an attempt to provide more quoting characters. If you see
1806 something like \\222 or \\264 where you're expecting some kind of
1807 apostrophe or quotation mark, then try this wash."
1809 (article-translate-strings gnus-article-dumbquotes-map))
1811 (defun article-translate-characters (from to)
1812 "Translate all characters in the body of the article according to FROM and TO.
1813 FROM is a string of characters to translate from; to is a string of
1814 characters to translate to."
1816 (when (article-goto-body)
1817 (let ((buffer-read-only nil)
1818 (x (make-string 225 ?x))
1820 (while (< (incf i) (length x))
1823 (while (< i (length from))
1824 (aset x (aref from i) (aref to i))
1826 (translate-region (point) (point-max) x)))))
1828 (defun article-translate-strings (map)
1829 "Translate all string in the body of the article according to MAP.
1830 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1832 (when (article-goto-body)
1833 (let ((buffer-read-only nil)
1835 (while (setq elem (pop map))
1837 (while (search-forward (car elem) nil t)
1838 (replace-match (cadr elem)))))))))
1840 (defun article-treat-overstrike ()
1841 "Translate overstrikes into bold text."
1844 (when (article-goto-body)
1845 (let ((buffer-read-only nil))
1846 (while (search-forward "\b" nil t)
1847 (let ((next (char-after))
1851 previous (char-after))
1855 ;; We do the boldification/underlining by hiding the
1856 ;; overstrikes and putting the proper text property
1860 (gnus-article-hide-text-type start (point) 'overstrike)
1861 (put-text-property (point) end 'face 'bold))
1863 (gnus-article-hide-text-type
1864 (1- (point)) (1+ (point)) 'overstrike)
1866 start (1- (point)) 'face 'underline))
1868 (gnus-article-hide-text-type start (point) 'overstrike)
1870 (point) end 'face 'underline)))))))))
1872 (defun gnus-article-treat-unfold-headers ()
1873 "Unfold folded message headers.
1874 Only the headers that fit into the current window width will be
1877 (gnus-with-article-headers
1881 (mail-header-narrow-to-field)
1882 (let ((header (buffer-substring (point-min) (point-max))))
1885 (goto-char (point-min))
1886 (while (re-search-forward "\n[\t ]" nil t)
1887 (replace-match " " t t)))
1888 (setq length (- (point-max) (point-min) 1)))
1889 (when (< length (window-width))
1890 (while (re-search-forward "\n[\t ]" nil t)
1891 (replace-match " " t t)))
1892 (goto-char (point-max)))))))
1894 (defun gnus-article-treat-fold-headers ()
1895 "Fold message headers."
1897 (gnus-with-article-headers
1900 (mail-header-narrow-to-field)
1901 (mail-header-fold-field)
1902 (goto-char (point-max))))))
1904 (defun gnus-treat-smiley ()
1905 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1907 (unless (featurep 'xemacs)
1908 (when (and (>= emacs-major-version 21)
1909 (not gnus-article-should-use-smiley-mule)
1910 gnus-article-smiley-mule-loaded-p)
1911 (load "smiley" nil t)
1912 (setq gnus-article-smiley-mule-loaded-p nil))
1913 (when (and gnus-article-should-use-smiley-mule
1914 (not gnus-article-smiley-mule-loaded-p))
1915 (load "smiley-mule" nil t)
1916 (setq gnus-article-smiley-mule-loaded-p t)))
1917 (gnus-with-article-buffer
1918 (if (memq 'smiley gnus-article-wash-types)
1919 (gnus-delete-images 'smiley)
1921 (let ((images (smiley-region (point) (point-max))))
1923 (gnus-add-wash-type 'smiley)
1924 (dolist (image images)
1925 (gnus-add-image 'smiley image)))))))
1927 (defun gnus-article-remove-images ()
1928 "Remove all images from the article buffer."
1930 (gnus-with-article-buffer
1931 (dolist (elem gnus-article-image-alist)
1932 (gnus-delete-images (car elem)))))
1934 (defun gnus-article-treat-fold-newsgroups ()
1935 "Unfold folded message headers.
1936 Only the headers that fit into the current window width will be
1939 (gnus-with-article-headers
1940 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1942 (mail-header-narrow-to-field)
1943 (while (re-search-forward ", *" nil t)
1944 (replace-match ", " t t))
1945 (mail-header-fold-field)
1946 (goto-char (point-max))))))
1948 (defun gnus-article-treat-body-boundary ()
1949 "Place a boundary line at the end of the headers."
1951 (when (and gnus-body-boundary-delimiter
1952 (> (length gnus-body-boundary-delimiter) 0))
1953 (gnus-with-article-headers
1954 (goto-char (point-max))
1955 (let ((start (point)))
1956 (insert "X-Boundary: ")
1957 (gnus-add-text-properties start (point) '(invisible t intangible t))
1959 (while (>= (1- (window-width)) (length str))
1960 (setq str (concat str gnus-body-boundary-delimiter)))
1961 (substring str 0 (1- (window-width))))
1963 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1965 (defun article-fill-long-lines ()
1966 "Fill lines that are wider than the window width."
1969 (let ((buffer-read-only nil)
1970 (width (window-width (get-buffer-window (current-buffer)))))
1973 (let ((adaptive-fill-mode nil)) ;Why? -sm
1976 (when (>= (current-column) (min fill-column width))
1977 (narrow-to-region (min (1+ (point)) (point-max))
1978 (gnus-point-at-bol))
1979 (let ((goback (point-marker)))
1980 (fill-paragraph nil)
1981 (goto-char (marker-position goback)))
1983 (forward-line 1)))))))
1985 (defun article-capitalize-sentences ()
1986 "Capitalize the first word in each sentence."
1989 (let ((buffer-read-only nil)
1990 (paragraph-start "^[\n\^L]"))
1994 (forward-sentence)))))
1996 (defun article-remove-cr ()
1997 "Remove trailing CRs and then translate remaining CRs into LFs."
2000 (let ((buffer-read-only nil))
2001 (goto-char (point-min))
2002 (while (re-search-forward "\r+$" nil t)
2003 (replace-match "" t t))
2004 (goto-char (point-min))
2005 (while (search-forward "\r" nil t)
2006 (replace-match "\n" t t)))))
2008 (defun article-remove-trailing-blank-lines ()
2009 "Remove all trailing blank lines from the article."
2012 (let ((buffer-read-only nil))
2013 (goto-char (point-max))
2017 (while (and (not (bobp))
2018 (looking-at "^[ \t]*$")
2019 (not (gnus-annotation-in-region-p
2020 (point) (gnus-point-at-eol))))
2025 (defun article-display-x-face (&optional force)
2026 "Look for an X-Face header and display it if present."
2027 (interactive (list 'force))
2028 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2029 (gnus-with-article-headers
2030 ;; Delete the old process, if any.
2031 (when (process-status "article-x-face")
2032 (delete-process "article-x-face"))
2033 (if (memq 'xface gnus-article-wash-types)
2034 ;; We have already displayed X-Faces, so we remove them
2036 (gnus-delete-images 'xface)
2038 (let (x-faces from face grey)
2040 (when (and wash-face-p
2042 (goto-char (point-min))
2043 (not (re-search-forward
2044 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2045 (gnus-buffer-live-p gnus-original-article-buffer))
2046 ;; If type `W f', use gnus-original-article-buffer,
2047 ;; otherwise use the current buffer because displaying
2048 ;; RFC822 parts calls this function too.
2049 (set-buffer gnus-original-article-buffer))
2051 (mail-narrow-to-head)
2052 (if gnus-treat-display-grey-xface
2054 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2055 (if (match-beginning 2)
2058 (push (cons (- (string-to-number (match-string 2)))
2059 (mail-header-field-value))
2061 (push (cons 0 (mail-header-field-value)) x-faces)))
2062 (dolist (x-face (prog1
2064 (sort x-faces 'car-less-than-car)
2066 (setq x-faces nil)))
2067 (push (cdr x-face) x-faces)))
2068 (while (gnus-article-goto-header "X-Face")
2069 (push (mail-header-field-value) x-faces)))
2070 (setq from (message-fetch-field "from"))))
2072 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2075 (setq image (gnus-create-image xpm 'xpm t))
2076 (gnus-article-goto-header "from")
2078 (insert "From: [no `from' set]\n")
2080 (gnus-add-wash-type 'xface)
2081 (gnus-add-image 'xface image)
2082 (gnus-put-image image)))
2083 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2084 ;; single external face.
2085 (when (stringp gnus-article-x-face-command)
2086 (setq x-faces (list (car x-faces))))
2087 (while (and (setq face (pop x-faces))
2088 gnus-article-x-face-command
2090 ;; Check whether this face is censored.
2091 (not gnus-article-x-face-too-ugly)
2092 (and gnus-article-x-face-too-ugly from
2093 (not (string-match gnus-article-x-face-too-ugly
2095 ;; We display the face.
2096 (if (symbolp gnus-article-x-face-command)
2097 ;; The command is a lisp function, so we call it.
2098 (if (gnus-functionp gnus-article-x-face-command)
2099 (funcall gnus-article-x-face-command face)
2100 (error "%s is not a function" gnus-article-x-face-command))
2101 ;; The command is a string, so we interpret the command
2102 ;; as a, well, command, and fork it off.
2103 (let ((process-connection-type nil))
2104 (process-kill-without-query
2106 "article-x-face" nil shell-file-name shell-command-switch
2107 gnus-article-x-face-command))
2110 (process-send-region "article-x-face"
2111 (point-min) (point-max)))
2112 (process-send-eof "article-x-face"))))))))))
2114 (defun article-decode-mime-words ()
2115 "Decode all MIME-encoded words in the article."
2118 (set-buffer gnus-article-buffer)
2119 (let ((inhibit-point-motion-hooks t)
2121 (mail-parse-charset gnus-newsgroup-charset)
2122 (mail-parse-ignored-charsets
2123 (save-excursion (set-buffer gnus-summary-buffer)
2124 gnus-newsgroup-ignored-charsets)))
2125 (mail-decode-encoded-word-region (point-min) (point-max)))))
2127 (defun article-decode-charset (&optional prompt)
2128 "Decode charset-encoded text in the article.
2129 If PROMPT (the prefix), prompt for a coding system to use."
2131 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2133 (mail-parse-charset gnus-newsgroup-charset)
2134 (mail-parse-ignored-charsets
2135 (save-excursion (condition-case nil
2136 (set-buffer gnus-summary-buffer)
2138 gnus-newsgroup-ignored-charsets))
2139 ct cte ctl charset format)
2142 (article-narrow-to-head)
2143 (setq ct (message-fetch-field "Content-Type" t)
2144 cte (message-fetch-field "Content-Transfer-Encoding" t)
2145 ctl (and ct (ignore-errors
2146 (mail-header-parse-content-type ct)))
2149 (mm-read-coding-system "Charset to decode: "))
2151 (mail-content-type-get ctl 'charset)))
2152 format (and ctl (mail-content-type-get ctl 'format)))
2154 (setq cte (mail-header-strip cte)))
2155 (if (and ctl (not (string-match "/" (car ctl))))
2157 (goto-char (point-max)))
2160 (narrow-to-region (point) (point-max))
2161 (when (and (eq mail-parse-charset 'gnus-decoded)
2162 (eq (mm-body-7-or-8) '8bit))
2163 ;; The text code could have been decoded.
2164 (setq charset mail-parse-charset))
2165 (when (and (or (not ctl)
2166 (equal (car ctl) "text/plain"))
2167 (not format)) ;; article with format will decode later.
2169 charset (and cte (intern (downcase
2170 (gnus-strip-whitespace cte))))
2173 (defun article-decode-encoded-words ()
2174 "Remove encoded-word encoding from headers."
2175 (let (buffer-read-only)
2176 (let ((charset (save-excursion
2177 (set-buffer gnus-summary-buffer)
2178 default-mime-charset)))
2179 (mime-decode-header-in-buffer charset))))
2181 (defun article-decode-group-name ()
2182 "Decode group names in `Newsgroups:'."
2183 (let ((inhibit-point-motion-hooks t)
2185 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2186 (when (and (or gnus-group-name-charset-method-alist
2187 gnus-group-name-charset-group-alist)
2188 (gnus-buffer-live-p gnus-original-article-buffer))
2189 (when (nnmail-fetch-field "Newsgroups")
2190 (nnheader-replace-header "Newsgroups"
2191 (gnus-decode-newsgroups
2192 (with-current-buffer
2193 gnus-original-article-buffer
2194 (nnmail-fetch-field "Newsgroups"))
2195 gnus-newsgroup-name method)))
2196 (when (nnmail-fetch-field "Followup-To")
2197 (nnheader-replace-header "Followup-To"
2198 (gnus-decode-newsgroups
2199 (with-current-buffer
2200 gnus-original-article-buffer
2201 (nnmail-fetch-field "Followup-To"))
2202 gnus-newsgroup-name method))))))
2204 (defun article-de-quoted-unreadable (&optional force read-charset)
2205 "Translate a quoted-printable-encoded article.
2206 If FORCE, decode the article whether it is marked as quoted-printable
2208 If READ-CHARSET, ask for a coding system."
2209 (interactive (list 'force current-prefix-arg))
2211 (let ((buffer-read-only nil) type charset)
2212 (if (gnus-buffer-live-p gnus-original-article-buffer)
2213 (with-current-buffer gnus-original-article-buffer
2215 (gnus-fetch-field "content-transfer-encoding"))
2216 (let* ((ct (gnus-fetch-field "content-type"))
2219 (mail-header-parse-content-type ct)))))
2220 (setq charset (and ctl
2221 (mail-content-type-get ctl 'charset)))
2222 (if (stringp charset)
2223 (setq charset (intern (downcase charset)))))))
2225 (setq charset (mm-read-coding-system "Charset: " charset)))
2227 (setq charset gnus-newsgroup-charset))
2229 (and type (let ((case-fold-search t))
2230 (string-match "quoted-printable" type))))
2232 (quoted-printable-decode-region
2233 (point) (point-max) (mm-charset-to-coding-system charset))))))
2235 (defun article-de-base64-unreadable (&optional force read-charset)
2236 "Translate a base64 article.
2237 If FORCE, decode the article whether it is marked as base64 not.
2238 If READ-CHARSET, ask for a coding system."
2239 (interactive (list 'force current-prefix-arg))
2241 (let ((buffer-read-only nil) type charset)
2242 (if (gnus-buffer-live-p gnus-original-article-buffer)
2243 (with-current-buffer gnus-original-article-buffer
2245 (gnus-fetch-field "content-transfer-encoding"))
2246 (let* ((ct (gnus-fetch-field "content-type"))
2249 (mail-header-parse-content-type ct)))))
2250 (setq charset (and ctl
2251 (mail-content-type-get ctl 'charset)))
2252 (if (stringp charset)
2253 (setq charset (intern (downcase charset)))))))
2255 (setq charset (mm-read-coding-system "Charset: " charset)))
2257 (setq charset gnus-newsgroup-charset))
2259 (and type (let ((case-fold-search t))
2260 (string-match "base64" type))))
2263 (narrow-to-region (point) (point-max))
2264 (base64-decode-region (point-min) (point-max))
2265 (mm-decode-coding-region
2266 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2271 (defun article-decode-HZ ()
2272 "Translate a HZ-encoded article."
2276 (let ((buffer-read-only nil))
2277 (rfc1843-decode-region (point-min) (point-max)))))
2279 (defun article-unsplit-urls ()
2280 "Remove the newlines that some other mailers insert into URLs."
2283 (let ((buffer-read-only nil))
2284 (goto-char (point-min))
2285 (while (re-search-forward
2286 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2287 (replace-match "\\1\\3" t)))
2288 (when (and gnus-display-mime-function (interactive-p))
2289 (funcall gnus-display-mime-function))))
2292 (defun article-wash-html (&optional read-charset)
2293 "Format an html article.
2294 If READ-CHARSET, ask for a coding system."
2297 (let ((buffer-read-only nil)
2299 (if (gnus-buffer-live-p gnus-original-article-buffer)
2300 (with-current-buffer gnus-original-article-buffer
2301 (let* ((ct (gnus-fetch-field "content-type"))
2304 (mail-header-parse-content-type ct)))))
2305 (setq charset (and ctl
2306 (mail-content-type-get ctl 'charset)))
2307 (if (stringp charset)
2308 (setq charset (intern (downcase charset)))))))
2310 (setq charset (mm-read-coding-system "Charset: " charset)))
2312 (setq charset gnus-newsgroup-charset))
2314 (save-window-excursion
2316 (narrow-to-region (point) (point-max))
2317 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2318 (entry (assq func mm-text-html-washer-alist)))
2320 (setq func (cdr entry)))
2322 ((gnus-functionp func)
2325 (apply (car func) (cdr func))))))))))
2327 (defun gnus-article-wash-html-with-w3 ()
2328 "Wash the current buffer with w3."
2330 (let ((w3-strict-width (window-width))
2331 (url-standalone-mode t)
2332 (url-gateway-unplugged t)
2333 (w3-honor-stylesheets nil))
2335 (w3-region (point-min) (point-max))
2338 (defun gnus-article-wash-html-with-w3m ()
2339 "Wash the current buffer with emacs-w3m."
2342 (narrow-to-region (point) (point-max))
2343 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2346 (w3m-display-inline-images mm-inline-text-html-with-images)
2347 w3m-force-redisplay)
2348 (w3m-region (point-min) (point-max)))
2349 (when mm-inline-text-html-with-w3m-keymap
2350 (add-text-properties
2351 (point-min) (point-max)
2352 (append '(mm-inline-text-html-with-w3m t)
2353 (gnus-local-map-property mm-w3m-mode-map))))))
2355 (defun article-hide-list-identifiers ()
2356 "Remove list identifies from the Subject header.
2357 The `gnus-list-identifiers' variable specifies what to do."
2359 (let ((inhibit-point-motion-hooks t)
2360 (regexp (if (consp gnus-list-identifiers)
2361 (mapconcat 'identity gnus-list-identifiers " *\\|")
2362 gnus-list-identifiers))
2367 (article-narrow-to-head)
2368 (goto-char (point-min))
2369 (while (re-search-forward
2370 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2372 (delete-region (match-beginning 2) (match-end 0))
2373 (beginning-of-line))
2374 (when (re-search-forward
2375 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2376 (delete-region (match-beginning 1) (match-end 1))))))))
2378 (defun article-hide-pgp ()
2379 "Remove any PGP headers and signatures in the current article."
2383 (let ((inhibit-point-motion-hooks t)
2384 buffer-read-only beg end)
2386 ;; Hide the "header".
2387 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2388 (gnus-add-wash-type 'pgp)
2389 (delete-region (match-beginning 0) (match-end 0))
2390 ;; Remove armor headers (rfc2440 6.2)
2391 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2394 ;; Hide the actual signature.
2395 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2396 (setq end (1+ (match-beginning 0)))
2399 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2401 ;; Perhaps we shouldn't hide to the end of the buffer
2402 ;; if there is no end to the signature?
2404 ;; Hide "- " PGP quotation markers.
2406 (narrow-to-region beg end)
2407 (goto-char (point-min))
2408 (while (re-search-forward "^- " nil t)
2410 (match-beginning 0) (match-end 0)))
2412 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2414 (defun article-hide-pem (&optional arg)
2415 "Toggle hiding of any PEM headers and signatures in the current article.
2416 If given a negative prefix, always show; if given a positive prefix,
2418 (interactive (gnus-article-hidden-arg))
2419 (unless (gnus-article-check-hidden-text 'pem arg)
2421 (let (buffer-read-only end)
2422 (goto-char (point-min))
2423 ;; Hide the horrendously ugly "header".
2424 (when (and (search-forward
2425 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2427 (setq end (1+ (match-beginning 0))))
2428 (gnus-add-wash-type 'pem)
2429 (gnus-article-hide-text-type
2431 (if (search-forward "\n\n" nil t)
2435 ;; Hide the trailer as well
2436 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2438 (gnus-article-hide-text-type
2439 (match-beginning 0) (match-end 0) 'pem)))))))
2441 (defun article-strip-banner ()
2442 "Strip the banner specified by the `banner' group parameter."
2446 (let ((inhibit-point-motion-hooks t)
2447 (banner (gnus-parameter-banner gnus-newsgroup-name))
2448 (gnus-signature-limit nil)
2449 buffer-read-only beg end)
2450 (when (and gnus-article-address-banner-alist
2453 (let ((from (save-restriction
2455 (article-narrow-to-head)
2456 (mail-fetch-field "from"))))
2459 (caar (mail-header-parse-addresses from))))
2461 (dolist (pair gnus-article-address-banner-alist)
2462 (when (string-match (car pair) from)
2463 (throw 'found (cdr pair)))))))))
2467 ((eq banner 'signature)
2468 (when (gnus-article-narrow-to-signature)
2471 (delete-region (point) (point-max))))
2473 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2474 (while (re-search-forward banner nil t)
2475 (delete-region (match-beginning 0) (match-end 0)))))
2477 (while (re-search-forward banner nil t)
2478 (delete-region (match-beginning 0) (match-end 0))))))))))
2480 (defun article-babel ()
2481 "Translate article using an online translation service."
2485 (set-buffer gnus-article-buffer)
2486 (when (article-goto-body)
2487 (let* ((buffer-read-only nil)
2490 (orig (buffer-substring start end))
2491 (trans (babel-as-string orig)))
2493 (narrow-to-region start end)
2494 (delete-region start end)
2497 (defun article-hide-signature (&optional arg)
2498 "Hide the signature in the current article.
2499 If given a negative prefix, always show; if given a positive prefix,
2501 (interactive (gnus-article-hidden-arg))
2507 (article-goto-body))
2508 (goto-char (point-min)))
2509 (unless (gnus-article-check-hidden-text 'signature arg)
2510 (let ((buffer-read-only nil)
2512 (while (setq button (text-property-any button (point-max)
2514 'gnus-signature-toggle))
2515 (setq button (text-property-not-all button (point-max)
2517 'gnus-signature-toggle))
2518 (when (and button (not (eobp)))
2519 (gnus-article-hide-text-type
2521 (next-single-property-change (1+ button) 'mime-view-entity
2524 (gnus-set-mode-line 'article))
2526 (defun article-strip-headers-in-body ()
2527 "Strip offensive headers from bodies."
2531 (let ((case-fold-search t))
2532 (when (looking-at "x-no-archive:")
2533 (gnus-delete-line)))))
2535 (defun article-strip-leading-blank-lines ()
2536 "Remove all blank lines from the beginning of the article."
2539 (let ((inhibit-point-motion-hooks t)
2541 (when (article-goto-body)
2542 (while (and (not (eobp))
2543 (looking-at "[ \t]*$"))
2544 (gnus-delete-line))))))
2546 (defun article-narrow-to-head ()
2547 "Narrow the buffer to the head of the message.
2548 Point is left at the beginning of the narrowed-to region."
2550 (goto-char (point-min))
2551 (if (search-forward "\n\n" nil 1)
2554 (goto-char (point-min)))
2556 (defun article-goto-body ()
2557 "Place point at the start of the body."
2558 (goto-char (point-min))
2560 ;; This variable is only bound when dealing with separate
2562 (article-goto-body-goes-to-point-min-p
2564 ((search-forward "\n\n" nil t)
2567 (goto-char (point-max))
2570 (defun article-strip-multiple-blank-lines ()
2571 "Replace consecutive blank lines with one empty line."
2574 (let ((inhibit-point-motion-hooks t)
2576 ;; First make all blank lines empty.
2578 (while (re-search-forward "^[ \t]+$" nil t)
2579 (unless (gnus-annotation-in-region-p
2580 (match-beginning 0) (match-end 0))
2581 (replace-match "" nil t)))
2582 ;; Then replace multiple empty lines with a single empty line.
2584 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2585 (unless (gnus-annotation-in-region-p
2586 (match-beginning 0) (match-end 0))
2587 (delete-region (match-beginning 1) (match-end 1)))))))
2589 (defun article-strip-leading-space ()
2590 "Remove all white space from the beginning of the lines in the article."
2593 (let ((inhibit-point-motion-hooks t)
2596 (while (re-search-forward "^[ \t]+" nil t)
2597 (replace-match "" t t)))))
2599 (defun article-strip-trailing-space ()
2600 "Remove all white space from the end of the lines in the article."
2603 (let ((inhibit-point-motion-hooks t)
2606 (while (re-search-forward "[ \t]+$" nil t)
2607 (replace-match "" t t)))))
2609 (defun article-strip-blank-lines ()
2610 "Strip leading, trailing and multiple blank lines."
2612 (article-strip-leading-blank-lines)
2613 (article-remove-trailing-blank-lines)
2614 (article-strip-multiple-blank-lines))
2616 (defun article-strip-all-blank-lines ()
2617 "Strip all blank lines."
2620 (let ((inhibit-point-motion-hooks t)
2623 (while (re-search-forward "^[ \t]*\n" nil t)
2624 (replace-match "" t t)))))
2626 (defun gnus-article-narrow-to-signature ()
2627 "Narrow to the signature; return t if a signature is found, else nil."
2628 (let ((inhibit-point-motion-hooks t))
2629 (when (gnus-article-search-signature)
2631 ;; Check whether we have some limits to what we consider
2632 ;; to be a signature.
2633 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2634 (list gnus-signature-limit)))
2636 (while (setq limit (pop limits))
2637 (if (or (and (integerp limit)
2638 (< (- (point-max) (point)) limit))
2640 (< (count-lines (point) (point-max)) limit))
2641 (and (gnus-functionp limit)
2643 (and (stringp limit)
2644 (not (re-search-forward limit nil t))))
2645 () ; This limit did not succeed.
2649 (narrow-to-region (point) (point-max))
2652 (defun gnus-article-search-signature ()
2653 "Search the current buffer for the signature separator.
2654 Put point at the beginning of the signature separator."
2655 (let ((cur (point)))
2656 (goto-char (point-max))
2657 (if (if (stringp gnus-signature-separator)
2658 (re-search-backward gnus-signature-separator nil t)
2659 (let ((seps gnus-signature-separator))
2661 (not (re-search-backward (car seps) nil t)))
2668 (defun gnus-article-hidden-arg ()
2669 "Return the current prefix arg as a number, or 0 if no prefix."
2670 (list (if current-prefix-arg
2671 (prefix-numeric-value current-prefix-arg)
2674 (defun gnus-article-check-hidden-text (type arg)
2675 "Return nil if hiding is necessary.
2676 Arg can be nil or a number. nil and positive means hide, negative
2677 means show, 0 means toggle."
2680 (let ((hide (gnus-article-hidden-text-p type)))
2686 (gnus-article-show-hidden-text type)
2689 (if (eq hide 'hidden)
2691 (gnus-article-show-hidden-text type)
2695 (defun gnus-article-hidden-text-p (type)
2696 "Say whether the current buffer contains hidden text of type TYPE."
2697 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2699 (not (get-text-property pos 'invisible))
2700 (not (get-text-property pos 'dummy-invisible)))
2702 (text-property-any (1+ pos) (point-max) 'article-type type)))
2707 (defun gnus-article-show-hidden-text (type &optional dummy)
2708 "Show all hidden text of type TYPE.
2709 Originally it is hide instead of DUMMY."
2710 (let ((buffer-read-only nil)
2711 (inhibit-point-motion-hooks t))
2712 (gnus-remove-text-properties-when
2714 (point-min) (point-max)
2715 (cons 'article-type (cons type
2716 gnus-hidden-properties)))
2717 (gnus-delete-wash-type type)))
2719 (defconst article-time-units
2720 `((year . ,(* 365.25 24 60 60))
2721 (week . ,(* 7 24 60 60))
2722 (day . ,(* 24 60 60))
2726 "Mapping from time units to seconds.")
2728 (defun article-date-ut (&optional type highlight header)
2729 "Convert DATE date to universal time in the current article.
2730 If TYPE is `local', convert to local time; if it is `lapsed', output
2731 how much time has lapsed since DATE. For `lapsed', the value of
2732 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2733 should replace the \"Date:\" one, or should be added below it."
2734 (interactive (list 'ut t))
2735 (let* ((header (or header
2736 (and (eq 1 (point-min))
2737 (mail-header-date (save-excursion
2738 (set-buffer gnus-summary-buffer)
2739 gnus-current-headers)))
2740 (message-fetch-field "date")
2742 (date (if (vectorp header) (mail-header-date header)
2744 (inhibit-point-motion-hooks t)
2745 bface eface date-pos)
2746 (when (and date (not (string= date "")))
2749 (article-narrow-to-head)
2750 (when (or (and (eq type 'lapsed)
2751 gnus-article-date-lapsed-new-header
2752 ;; Attempt to get the face of X-Sent first.
2753 (re-search-forward "^X-Sent:[ \t]" nil t))
2754 (re-search-forward "^Date:[ \t]" nil t)
2755 ;; If Date is missing, try again for X-Sent.
2756 (re-search-forward "^X-Sent:[ \t]" nil t))
2757 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2758 date (or (get-text-property (gnus-point-at-bol)
2761 eface (get-text-property (1- (gnus-point-at-eol))
2763 (let ((buffer-read-only nil))
2764 ;; Delete any old X-Sent headers.
2765 (when (setq date-pos
2766 (text-property-any (point-min) (point-max)
2767 'article-date-lapsed t))
2768 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2769 (delete-region (match-beginning 0)
2770 (progn (forward-line 1) (point))))
2771 (goto-char (point-min))
2772 ;; Delete any old Date headers.
2773 (while (re-search-forward "^Date:[ \t]" nil t)
2775 (setq date-pos (match-beginning 0)))
2776 (unless (and (eq type 'lapsed)
2777 gnus-article-date-lapsed-new-header)
2778 (delete-region (match-beginning 0)
2779 (progn (message-next-header) (point)))))
2782 (goto-char date-pos)
2784 ;; Possibly, Date has been deleted.
2786 (when (and (eq type 'lapsed)
2787 gnus-article-date-lapsed-new-header
2788 (looking-at "Date:"))
2790 (goto-char (point-min)))
2791 (insert (article-make-date-line date type))
2792 (when (eq type 'lapsed)
2793 (put-text-property (gnus-point-at-bol) (point)
2794 'article-date-lapsed t))
2798 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2799 (put-text-property (match-beginning 1) (1+ (match-end 1))
2800 'original-date date)
2801 (put-text-property (match-beginning 1) (1+ (match-end 1))
2803 (put-text-property (match-beginning 2) (match-end 2)
2806 (defun article-make-date-line (date type)
2807 "Return a DATE line of TYPE."
2808 (unless (memq type '(local ut original user iso8601 lapsed english))
2809 (error "Unknown conversion type: %s" type))
2811 (let ((time (date-to-time date)))
2813 ;; Convert to the local timezone.
2815 (let ((tz (car (current-time-zone time))))
2816 (format "Date: %s %s%02d%02d" (current-time-string time)
2817 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2818 (/ (% (abs tz) 3600) 60))))
2819 ;; Convert to Universal Time.
2822 (current-time-string
2823 (let* ((e (parse-time-string date))
2824 (tm (apply 'encode-time e))
2826 (ls (- (cadr tm) (car (current-time-zone time)))))
2827 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2828 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2831 ;; Get the original date from the article.
2832 ((eq type 'original)
2833 (concat "Date: " (if (string-match "\n+$" date)
2834 (substring date 0 (match-beginning 0))
2836 ;; Let the user define the format.
2838 (let ((format (or (condition-case nil
2839 (with-current-buffer gnus-summary-buffer
2840 gnus-article-time-format)
2842 gnus-article-time-format)))
2843 (if (gnus-functionp format)
2844 (funcall format time)
2845 (concat "Date: " (format-time-string format time)))))
2848 (let ((tz (car (current-time-zone time))))
2851 (format-time-string "%Y%m%dT%H%M%S" time)
2852 (format "%s%02d%02d"
2853 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2854 (/ (% (abs tz) 3600) 60)))))
2855 ;; Do an X-Sent lapsed format.
2857 ;; If the date is seriously mangled, the timezone functions are
2858 ;; liable to bug out, so we ignore all errors.
2859 (let* ((now (current-time))
2860 (real-time (subtract-time now time))
2861 (real-sec (and real-time
2862 (+ (* (float (car real-time)) 65536)
2864 (sec (and real-time (abs real-sec)))
2874 ;; This is a bit convoluted, but basically we go
2875 ;; through the time units for years, weeks, etc,
2876 ;; and divide things to see whether that results
2877 ;; in positive answers.
2880 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2881 ;; The (remaining) seconds are too few to
2882 ;; be divided into this time unit.
2884 ;; It's big enough, so we output it.
2885 (setq sec (- sec (* num (cdr unit))))
2887 (concat (if prev ", " "") (int-to-string
2889 " " (symbol-name (car unit))
2890 (if (> num 1) "s" ""))
2892 article-time-units "")
2893 ;; If dates are odd, then it might appear like the
2894 ;; article was sent in the future.
2897 " in the future"))))))
2898 ;; Display the date in proper English
2900 (let ((dtime (decode-time time)))
2903 (number-to-string (nth 3 dtime))
2904 (let ((digit (% (nth 3 dtime) 10)))
2906 ((memq (nth 3 dtime) '(11 12 13)) "th")
2912 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2914 (number-to-string (nth 5 dtime))
2916 (format "%02d" (nth 2 dtime))
2918 (format "%02d" (nth 1 dtime)))))))
2920 (format "Date: %s (from T-gnus)" date))))
2922 (defun article-date-local (&optional highlight)
2923 "Convert the current article date to the local timezone."
2924 (interactive (list t))
2925 (article-date-ut 'local highlight))
2927 (defun article-date-english (&optional highlight)
2928 "Convert the current article date to something that is proper English."
2929 (interactive (list t))
2930 (article-date-ut 'english highlight))
2932 (defun article-date-original (&optional highlight)
2933 "Convert the current article date to what it was originally.
2934 This is only useful if you have used some other date conversion
2935 function and want to see what the date was before converting."
2936 (interactive (list t))
2937 (article-date-ut 'original highlight))
2939 (defun article-date-lapsed (&optional highlight)
2940 "Convert the current article date to time lapsed since it was sent."
2941 (interactive (list t))
2942 (article-date-ut 'lapsed highlight))
2944 (defun article-update-date-lapsed ()
2945 "Function to be run from a timer to update the lapsed time line."
2946 (let (deactivate-mark)
2951 (set-buffer (window-buffer w))
2952 (when (eq major-mode 'gnus-article-mode)
2953 (goto-char (point-min))
2954 (when (re-search-forward "^X-Sent:" nil t)
2955 (article-date-lapsed t))))
2958 (defun gnus-start-date-timer (&optional n)
2959 "Start a timer to update the X-Sent header in the article buffers.
2960 The numerical prefix says how frequently (in seconds) the function
2965 (gnus-stop-date-timer)
2966 (setq article-lapsed-timer
2967 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2969 (defun gnus-stop-date-timer ()
2970 "Stop the X-Sent timer."
2972 (when article-lapsed-timer
2973 (nnheader-cancel-timer article-lapsed-timer)
2974 (setq article-lapsed-timer nil)))
2976 (defun article-date-user (&optional highlight)
2977 "Convert the current article date to the user-defined format.
2978 This format is defined by the `gnus-article-time-format' variable."
2979 (interactive (list t))
2980 (article-date-ut 'user highlight))
2982 (defun article-date-iso8601 (&optional highlight)
2983 "Convert the current article date to ISO8601."
2984 (interactive (list t))
2985 (article-date-ut 'iso8601 highlight))
2987 ;; (defun article-show-all ()
2988 ;; "Show all hidden text in the article buffer."
2992 ;; (let ((buffer-read-only nil))
2993 ;; (gnus-article-unhide-text (point-min) (point-max))
2994 ;; (gnus-remove-text-with-property 'gnus-prev)
2995 ;; (gnus-remove-text-with-property 'gnus-next))))
2997 (defun article-show-all-headers ()
2998 "Show all hidden headers in the article buffer."
3003 (article-narrow-to-head)
3004 (let ((buffer-read-only nil))
3005 (gnus-article-unhide-text (point-min) (point-max))))))
3007 (defun article-remove-leading-whitespace ()
3008 "Remove excessive whitespace from all headers."
3012 (let ((buffer-read-only nil))
3013 (article-narrow-to-head)
3014 (goto-char (point-min))
3015 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3016 (delete-region (match-beginning 1) (match-end 1)))))))
3018 (defun article-emphasize (&optional arg)
3019 "Emphasize text according to `gnus-emphasis-alist'."
3020 (interactive (gnus-article-hidden-arg))
3021 (unless (gnus-article-check-hidden-text 'emphasis arg)
3025 (with-current-buffer gnus-summary-buffer
3026 gnus-article-emphasis-alist)
3028 gnus-emphasis-alist))
3029 (buffer-read-only nil)
3030 (props (append '(article-type emphasis)
3031 gnus-hidden-properties))
3032 regexp elem beg invisible visible face)
3035 (while (setq elem (pop alist))
3037 (setq regexp (car elem)
3038 invisible (nth 1 elem)
3039 visible (nth 2 elem)
3041 (while (re-search-forward regexp nil t)
3042 (when (and (match-beginning visible) (match-beginning invisible))
3043 (gnus-article-hide-text
3044 (match-beginning invisible) (match-end invisible) props)
3045 (gnus-article-unhide-text-type
3046 (match-beginning visible) (match-end visible) 'emphasis)
3047 (gnus-put-overlay-excluding-newlines
3048 (match-beginning visible) (match-end visible) 'face face)
3049 (gnus-add-wash-type 'emphasis)
3050 (goto-char (match-end invisible)))))))))
3052 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3053 "Setup newsgroup emphasis alist."
3054 (unless gnus-article-emphasis-alist
3055 (let ((name (and gnus-newsgroup-name
3056 (gnus-group-real-name gnus-newsgroup-name))))
3057 (make-local-variable 'gnus-article-emphasis-alist)
3058 (setq gnus-article-emphasis-alist
3060 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3061 (while (setq elem (pop alist))
3062 (when (and name (string-match (car elem) name))
3064 highlight (copy-sequence (cdr elem)))))
3066 (copy-sequence highlight-words)
3067 (if gnus-newsgroup-name
3068 (copy-sequence (gnus-group-find-parameter
3069 gnus-newsgroup-name 'highlight-words t)))
3070 gnus-emphasis-alist)))))
3073 (defvar gnus-summary-article-menu)
3074 (defvar gnus-summary-post-menu))
3076 ;;; Saving functions.
3078 (defun gnus-article-save (save-buffer file &optional num)
3079 "Save the currently selected article."
3080 (unless gnus-save-all-headers
3081 ;; Remove headers according to `gnus-saved-headers'.
3082 (let ((gnus-visible-headers
3083 (or gnus-saved-headers gnus-visible-headers))
3084 (gnus-article-buffer save-buffer))
3086 (set-buffer save-buffer)
3087 (article-hide-headers 1 t))))
3088 (save-window-excursion
3089 (if (not gnus-default-article-saver)
3090 (error "No default saver is defined")
3091 ;; !!! Magic! The saving functions all save
3092 ;; `gnus-save-article-buffer' (or so they think), but we
3093 ;; bind that variable to our save-buffer.
3094 (set-buffer gnus-article-buffer)
3095 (let* ((gnus-save-article-buffer save-buffer)
3098 ((not gnus-prompt-before-saving) 'default)
3099 ((eq gnus-prompt-before-saving 'always) nil)
3101 (gnus-number-of-articles-to-be-saved
3102 (when (eq gnus-prompt-before-saving t)
3104 (set-buffer gnus-article-current-summary)
3105 (funcall gnus-default-article-saver filename)))))
3107 (defun gnus-read-save-file-name (prompt &optional filename
3108 function group headers variable)
3110 (funcall function group headers (symbol-value variable)))
3115 ((eq filename 'default)
3121 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3124 (if (and gnus-number-of-articles-to-be-saved
3125 (> gnus-number-of-articles-to-be-saved 1))
3126 (format "these %d articles"
3127 gnus-number-of-articles-to-be-saved)
3130 ;; Let the split methods have their say.
3132 ;; No split name was found.
3135 (concat prompt " (default "
3136 (file-name-nondirectory default-name) ") ")
3137 (file-name-directory default-name)
3139 ;; A single group name is returned.
3140 ((stringp split-name)
3142 (funcall function split-name headers
3143 (symbol-value variable)))
3145 (concat prompt " (default "
3146 (file-name-nondirectory default-name) ") ")
3147 (file-name-directory default-name)
3149 ;; A single split name was found
3150 ((= 1 (length split-name))
3151 (let* ((name (expand-file-name
3153 gnus-article-save-directory))
3154 (dir (cond ((file-directory-p name)
3155 (file-name-as-directory name))
3156 ((file-exists-p name) name)
3157 (t gnus-article-save-directory))))
3159 (concat prompt " (default " name ") ")
3161 ;; A list of splits was found.
3163 (setq split-name (nreverse split-name))
3165 (let ((file-name-history
3166 (nconc split-name file-name-history)))
3170 (concat prompt " (`M-p' for defaults) ")
3171 gnus-article-save-directory
3173 gnus-article-save-directory)))
3174 (car (push result file-name-history)))))))
3175 ;; Create the directory.
3176 (gnus-make-directory (file-name-directory file))
3177 ;; If we have read a directory, we append the default file name.
3178 (when (file-directory-p file)
3179 (setq file (expand-file-name (file-name-nondirectory
3181 (file-name-as-directory file))))
3182 ;; Possibly translate some characters.
3183 (nnheader-translate-file-chars file))))))
3184 (gnus-make-directory (file-name-directory result))
3185 (set variable result)))
3187 (defun gnus-article-archive-name (group)
3188 "Return the first instance of an \"Archive-name\" in the current buffer."
3189 (let ((case-fold-search t))
3190 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3191 (nnheader-concat gnus-article-save-directory
3192 (match-string 1)))))
3194 (defun gnus-article-nndoc-name (group)
3195 "If GROUP is an nndoc group, return the name of the parent group."
3196 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3197 (gnus-group-get-parameter group 'save-article-group)))
3199 (defun gnus-summary-save-in-rmail (&optional filename)
3200 "Append this article to Rmail file.
3201 Optional argument FILENAME specifies file name.
3202 Directory to save to is default to `gnus-article-save-directory'."
3203 (setq filename (gnus-read-save-file-name
3204 "Save %s in rmail file:" filename
3205 gnus-rmail-save-name gnus-newsgroup-name
3206 gnus-current-headers 'gnus-newsgroup-last-rmail))
3207 (gnus-eval-in-buffer-window gnus-save-article-buffer
3211 (gnus-output-to-rmail filename))))
3214 (defun gnus-summary-save-in-mail (&optional filename)
3215 "Append this article to Unix mail file.
3216 Optional argument FILENAME specifies file name.
3217 Directory to save to is default to `gnus-article-save-directory'."
3218 (setq filename (gnus-read-save-file-name
3219 "Save %s in Unix mail file:" filename
3220 gnus-mail-save-name gnus-newsgroup-name
3221 gnus-current-headers 'gnus-newsgroup-last-mail))
3222 (gnus-eval-in-buffer-window gnus-save-article-buffer
3226 (if (and (file-readable-p filename)
3227 (mail-file-babyl-p filename))
3228 (rmail-output-to-rmail-file filename t)
3229 (gnus-output-to-mail filename)))))
3232 (defun gnus-summary-save-in-file (&optional filename overwrite)
3233 "Append this article to file.
3234 Optional argument FILENAME specifies file name.
3235 Directory to save to is default to `gnus-article-save-directory'."
3236 (setq filename (gnus-read-save-file-name
3237 "Save %s in file:" filename
3238 gnus-file-save-name gnus-newsgroup-name
3239 gnus-current-headers 'gnus-newsgroup-last-file))
3240 (gnus-eval-in-buffer-window gnus-save-article-buffer
3244 (when (and overwrite
3245 (file-exists-p filename))
3246 (delete-file filename))
3247 (gnus-output-to-file filename))))
3250 (defun gnus-summary-write-to-file (&optional filename)
3251 "Write this article to a file, overwriting it if the file exists.
3252 Optional argument FILENAME specifies file name.
3253 The directory to save in defaults to `gnus-article-save-directory'."
3254 (gnus-summary-save-in-file nil t))
3256 (defun gnus-summary-save-body-in-file (&optional filename)
3257 "Append this article body to a file.
3258 Optional argument FILENAME specifies file name.
3259 The directory to save in defaults to `gnus-article-save-directory'."
3260 (setq filename (gnus-read-save-file-name
3261 "Save %s body in file:" filename
3262 gnus-file-save-name gnus-newsgroup-name
3263 gnus-current-headers 'gnus-newsgroup-last-file))
3264 (gnus-eval-in-buffer-window gnus-save-article-buffer
3268 (when (article-goto-body)
3269 (narrow-to-region (point) (point-max)))
3270 (gnus-output-to-file filename))))
3273 (defun gnus-summary-save-in-pipe (&optional command)
3274 "Pipe this article to subprocess."
3276 (cond ((and (eq command 'default)
3277 gnus-last-shell-command)
3278 gnus-last-shell-command)
3283 "Shell command on %s: "
3284 (if (and gnus-number-of-articles-to-be-saved
3285 (> gnus-number-of-articles-to-be-saved 1))
3286 (format "these %d articles"
3287 gnus-number-of-articles-to-be-saved)
3289 gnus-last-shell-command))))
3290 (when (string-equal command "")
3291 (if gnus-last-shell-command
3292 (setq command gnus-last-shell-command)
3293 (error "A command is required")))
3294 (gnus-eval-in-buffer-window gnus-article-buffer
3297 (shell-command-on-region (point-min) (point-max) command nil)))
3298 (setq gnus-last-shell-command command))
3300 (defun gnus-summary-pipe-to-muttprint (&optional command)
3301 "Pipe this article to muttprint."
3302 (setq command (read-string
3303 "Print using command: " gnus-summary-muttprint-program
3304 nil gnus-summary-muttprint-program))
3305 (gnus-summary-save-in-pipe command))
3307 ;;; Article file names when saving.
3309 (defun gnus-capitalize-newsgroup (newsgroup)
3310 "Capitalize NEWSGROUP name."
3311 (when (not (zerop (length newsgroup)))
3312 (concat (char-to-string (upcase (aref newsgroup 0)))
3313 (substring newsgroup 1))))
3315 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3316 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3317 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3318 Otherwise, it is like ~/News/news/group/num."
3321 (concat (if (gnus-use-long-file-name 'not-save)
3322 (gnus-capitalize-newsgroup newsgroup)
3323 (gnus-newsgroup-directory-form newsgroup))
3324 "/" (int-to-string (mail-header-number headers)))
3325 gnus-article-save-directory)))
3327 (string-equal (file-name-directory default)
3328 (file-name-directory last-file))
3329 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3331 (or last-file default))))
3333 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3334 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3335 If variable `gnus-use-long-file-name' is non-nil, it is
3336 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3339 (concat (if (gnus-use-long-file-name 'not-save)
3341 (gnus-newsgroup-directory-form newsgroup))
3342 "/" (int-to-string (mail-header-number headers)))
3343 gnus-article-save-directory)))
3345 (string-equal (file-name-directory default)
3346 (file-name-directory last-file))
3347 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3349 (or last-file default))))
3351 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3352 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3353 If variable `gnus-use-long-file-name' is non-nil, it is
3354 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3357 (if (gnus-use-long-file-name 'not-save)
3360 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3362 gnus-article-save-directory)))
3364 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3365 "Generate file name from sender."
3366 (let ((from (mail-header-from headers)))
3368 (if (and from (string-match "\\([^ <]+\\)@" from))
3369 (match-string 1 from)
3371 gnus-article-save-directory)))
3373 (defun article-verify-x-pgp-sig ()
3376 (if (gnus-buffer-live-p gnus-original-article-buffer)
3377 (let ((sig (with-current-buffer gnus-original-article-buffer
3378 (gnus-fetch-field "X-PGP-Sig")))
3382 (mml2015-clear-verify-function))
3384 (insert-buffer-substring gnus-original-article-buffer)
3385 (setq items (split-string sig))
3386 (message-narrow-to-head)
3387 (let ((inhibit-point-motion-hooks t)
3388 (case-fold-search t))
3389 ;; Don't verify multiple headers.
3390 (setq headers (mapconcat (lambda (header)
3392 (mail-fetch-field header) "\n"))
3393 (split-string (nth 1 items) ",") "")))
3394 (delete-region (point-min) (point-max))
3395 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3396 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3401 (if (looking-at "^-")
3404 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3405 (insert "Version: " (car items) "\n\n")
3406 (insert (mapconcat 'identity (cddr items) "\n"))
3407 (insert "\n-----END PGP SIGNATURE-----\n")
3408 (let ((mm-security-handle (list (format "multipart/signed"))))
3409 (mml2015-clean-buffer)
3410 (let ((coding-system-for-write (or gnus-newsgroup-charset
3412 (funcall (mml2015-clear-verify-function)))
3414 (or (mm-handle-multipart-ctl-parameter
3415 mm-security-handle 'gnus-details)
3416 (mm-handle-multipart-ctl-parameter
3417 mm-security-handle 'gnus-info)))))
3419 (let (buffer-read-only bface eface)
3421 (message-narrow-to-head)
3422 (goto-char (point-max))
3424 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3425 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3426 (message-remove-header "X-Gnus-PGP-Verify")
3427 (if (re-search-forward "^X-PGP-Sig:" nil t)
3429 (goto-char (point-max)))
3430 (narrow-to-region (point) (point))
3431 (insert "X-Gnus-PGP-Verify: " info "\n")
3432 (goto-char (point-min))
3435 (if (not (looking-at "^[ \t]"))
3439 (goto-char (point-min))
3440 (when (looking-at "\\([^:]+\\): *")
3441 (put-text-property (match-beginning 1) (1+ (match-end 1))
3443 (put-text-property (match-end 0) (point-max)
3444 'face eface)))))))))
3446 (defun article-verify-cancel-lock ()
3447 "Verify Cancel-Lock header."
3449 (if (gnus-buffer-live-p gnus-original-article-buffer)
3450 (canlock-verify gnus-original-article-buffer)))
3452 (defun article-monafy ()
3453 "Display body part with mona font."
3455 (unless (if (featurep 'xemacs)
3456 (find-face 'gnus-mona-face)
3457 (facep 'gnus-mona-face))
3458 (require 'navi2ch-mona)
3459 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3461 (let ((buffer-read-only nil))
3464 (gnus-make-overlay (point) (point-max))
3465 'face 'gnus-mona-face))))
3472 (setq afunc (car func)
3475 gfunc (intern (format "gnus-%s" func))))
3477 (when (fboundp afunc)
3478 `(lambda (&optional interactive &rest args)
3479 ,(documentation afunc t)
3480 (interactive (list t))
3482 (set-buffer gnus-article-buffer)
3484 (call-interactively ',afunc)
3485 (apply ',afunc args))))))))
3486 '(article-hide-headers
3487 article-verify-x-pgp-sig
3488 article-verify-cancel-lock
3490 article-hide-boring-headers
3491 article-treat-overstrike
3492 article-fill-long-lines
3493 article-capitalize-sentences
3495 article-remove-leading-whitespace
3496 article-display-x-face
3497 article-de-quoted-unreadable
3498 article-de-base64-unreadable
3501 article-unsplit-urls
3502 article-hide-list-identifiers
3504 article-strip-banner
3507 article-hide-signature
3508 article-strip-headers-in-body
3509 article-remove-trailing-blank-lines
3510 article-strip-leading-blank-lines
3511 article-strip-multiple-blank-lines
3512 article-strip-leading-space
3513 article-strip-trailing-space
3514 article-strip-blank-lines
3515 article-strip-all-blank-lines
3517 article-date-english
3518 article-date-iso8601
3519 article-date-original
3521 article-decode-mime-words
3522 article-decode-charset
3523 article-decode-encoded-words
3527 article-treat-dumbquotes
3528 article-normalize-headers
3529 (article-show-all-headers . gnus-article-show-all-headers)
3530 ;; (article-show-all . gnus-article-show-all)
3534 ;;; Gnus article mode
3537 (put 'gnus-article-mode 'mode-class 'special)
3539 (gnus-define-keys gnus-article-mode-map
3540 " " gnus-article-goto-next-page
3541 "\177" gnus-article-goto-prev-page
3542 [delete] gnus-article-goto-prev-page
3543 [backspace] gnus-article-goto-prev-page
3544 "\C-c^" gnus-article-refer-article
3545 "h" gnus-article-show-summary
3546 "s" gnus-article-show-summary
3547 "\C-c\C-m" gnus-article-mail
3548 "?" gnus-article-describe-briefly
3549 "e" gnus-summary-edit-article
3550 "<" beginning-of-buffer
3552 "\C-c\C-i" gnus-info-find-node
3554 "R" gnus-article-reply-with-original
3555 "F" gnus-article-followup-with-original
3556 "\C-hk" gnus-article-describe-key
3557 "\C-hc" gnus-article-describe-key-briefly
3559 "\C-d" gnus-article-read-summary-keys
3560 "\M-*" gnus-article-read-summary-keys
3561 "\M-#" gnus-article-read-summary-keys
3562 "\M-^" gnus-article-read-summary-keys
3563 "\M-g" gnus-article-read-summary-keys)
3565 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3569 (push (char-to-string key) keys)
3571 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3572 (setq key (car elem))
3573 (when (and (> (length key) 0)
3574 (not (eq 'menu-bar (aref key 0)))
3575 (symbolp (lookup-key gnus-summary-mode-map key)))
3578 (unless (lookup-key gnus-article-mode-map key)
3579 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3581 (defun gnus-article-make-menu-bar ()
3582 (unless (boundp 'gnus-article-commands-menu)
3583 (gnus-summary-make-menu-bar))
3584 (gnus-turn-off-edit-menu 'article)
3585 (unless (boundp 'gnus-article-article-menu)
3587 gnus-article-article-menu gnus-article-mode-map ""
3589 ["Scroll forwards" gnus-article-goto-next-page t]
3590 ["Scroll backwards" gnus-article-goto-prev-page t]
3591 ["Show summary" gnus-article-show-summary t]
3592 ["Fetch Message-ID at point" gnus-article-refer-article t]
3593 ["Mail to address at point" gnus-article-mail t]
3594 ["Send a bug report" gnus-bug t]))
3597 gnus-article-treatment-menu gnus-article-mode-map ""
3598 ;; Fixme: this should use :active (and maybe :visible).
3600 ["Hide headers" gnus-article-hide-headers t]
3601 ["Hide signature" gnus-article-hide-signature t]
3602 ["Hide citation" gnus-article-hide-citation t]
3603 ["Treat overstrike" gnus-article-treat-overstrike t]
3604 ["Remove carriage return" gnus-article-remove-cr t]
3605 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3606 ["Treat html" gnus-article-wash-html t]
3607 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3608 ["Decode HZ" gnus-article-decode-HZ t]))
3610 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3612 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3614 (gnus-run-hooks 'gnus-article-menu-hook)))
3616 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3619 (defun gnus-article-mode ()
3620 "Major mode for displaying an article.
3622 All normal editing commands are switched off.
3624 The following commands are available in addition to all summary mode
3626 \\<gnus-article-mode-map>
3627 \\[gnus-article-next-page]\t Scroll the article one page forwards
3628 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3629 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3630 \\[gnus-article-show-summary]\t Display the summary buffer
3631 \\[gnus-article-mail]\t Send a reply to the address near point
3632 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3633 \\[gnus-info-find-node]\t Go to the Gnus info node"
3635 (gnus-simplify-mode-line)
3636 (setq mode-name "Article")
3637 (setq major-mode 'gnus-article-mode)
3638 (make-local-variable 'minor-mode-alist)
3639 (unless (assq 'gnus-show-mime minor-mode-alist)
3640 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3641 (use-local-map gnus-article-mode-map)
3642 (when (gnus-visual-p 'article-menu 'menu)
3643 (gnus-article-make-menu-bar))
3644 (gnus-update-format-specifications nil 'article-mode)
3645 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3646 (make-local-variable 'gnus-page-broken)
3647 (make-local-variable 'gnus-button-marker-list)
3648 (make-local-variable 'gnus-article-current-summary)
3649 (make-local-variable 'gnus-article-mime-handles)
3650 (make-local-variable 'gnus-article-decoded-p)
3651 (make-local-variable 'gnus-article-mime-handle-alist)
3652 (make-local-variable 'gnus-article-wash-types)
3653 (make-local-variable 'gnus-article-image-alist)
3654 (make-local-variable 'gnus-article-charset)
3655 (make-local-variable 'gnus-article-ignored-charsets)
3656 (gnus-set-default-directory)
3657 (buffer-disable-undo)
3658 (setq buffer-read-only t)
3659 (set-syntax-table gnus-article-mode-syntax-table)
3660 (gnus-run-hooks 'gnus-article-mode-hook))
3662 (defun gnus-article-setup-buffer ()
3663 "Initialize the article buffer."
3664 (let* ((name (if gnus-single-article-buffer "*Article*"
3665 (concat "*Article " gnus-newsgroup-name "*")))
3667 (progn (string-match "\\*Article" name)
3668 (concat " *Original Article"
3669 (substring name (match-end 0))))))
3670 (setq gnus-article-buffer name)
3671 (setq gnus-original-article-buffer original)
3672 (setq gnus-article-mime-handle-alist nil)
3673 ;; This might be a variable local to the summary buffer.
3674 (unless gnus-single-article-buffer
3676 (set-buffer gnus-summary-buffer)
3677 (setq gnus-article-buffer name)
3678 (setq gnus-original-article-buffer original)
3679 (gnus-set-global-variables)))
3680 (gnus-article-setup-highlight-words)
3681 ;; Init original article buffer.
3683 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3684 (set-buffer-multibyte t)
3685 (setq major-mode 'gnus-original-article-mode)
3686 (make-local-variable 'gnus-original-article))
3687 (if (get-buffer name)
3690 (buffer-disable-undo)
3691 (setq buffer-read-only t)
3692 (unless (eq major-mode 'gnus-article-mode)
3693 (gnus-article-mode))
3696 (set-buffer (gnus-get-buffer-create name))
3698 (make-local-variable 'gnus-summary-buffer)
3699 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3700 (current-buffer)))))
3702 ;; Set article window start at LINE, where LINE is the number of lines
3703 ;; from the head of the article.
3704 (defun gnus-article-set-window-start (&optional line)
3706 (gnus-get-buffer-window gnus-article-buffer t)
3708 (set-buffer gnus-article-buffer)
3709 (goto-char (point-min))
3712 (gnus-message 6 "Moved to bookmark")
3713 (search-forward "\n\n" nil t)
3717 ;;; @@ article filters
3720 (defun gnus-article-display-mime-message ()
3721 "Article display method for MIME message."
3722 ;; called from `gnus-original-article-buffer'.
3723 (let (charset all-headers)
3724 (with-current-buffer gnus-summary-buffer
3725 (setq charset default-mime-charset
3726 all-headers gnus-have-all-headers))
3727 (make-local-variable 'default-mime-charset)
3728 (setq default-mime-charset charset)
3729 (with-current-buffer (get-buffer-create gnus-article-buffer)
3730 (make-local-variable 'default-mime-charset)
3731 (setq default-mime-charset charset))
3732 (mime-display-message mime-message-structure
3733 gnus-article-buffer nil gnus-article-mode-map)
3735 (gnus-article-hide-headers nil -1)))
3736 (run-hooks 'gnus-mime-article-prepare-hook))
3738 (defun gnus-article-display-traditional-message ()
3739 "Article display method for traditional message."
3740 (set-buffer gnus-article-buffer)
3741 (let (buffer-read-only)
3743 (insert-buffer-substring gnus-original-article-buffer)))
3745 (defun gnus-article-make-full-mail-header (&optional number charset)
3746 "Create a new mail header structure in a raw article buffer."
3747 (unless (and number charset)
3748 (save-current-buffer
3749 (set-buffer gnus-summary-buffer)
3751 (setq number (or (cdr gnus-article-current) 0)))
3753 (setq charset (or default-mime-charset 'x-ctext)))))
3754 (goto-char (point-min))
3755 (let ((header-end (if (search-forward "\n\n" nil t)
3757 (goto-char (point-max))))
3758 (chars (- (point-max) (point)))
3759 (lines (count-lines (point) (point-max)))
3760 (default-mime-charset charset)
3762 (narrow-to-region (point-min) header-end)
3763 (setq xref (std11-fetch-field "xref"))
3765 (make-full-mail-header
3767 (std11-fetch-field "subject")
3768 (std11-fetch-field "from")
3769 (std11-fetch-field "date")
3770 (std11-fetch-field "message-id")
3771 (std11-fetch-field "references")
3774 (when xref (concat "Xref: " xref)))
3777 (defun gnus-article-prepare (article &optional all-headers header)
3778 "Prepare ARTICLE in article mode buffer.
3779 ARTICLE should either be an article number or a Message-ID.
3780 If ARTICLE is an id, HEADER should be the article headers.
3781 If ALL-HEADERS is non-nil, no headers are hidden."
3783 ;; Make sure we start in a summary buffer.
3784 (unless (eq major-mode 'gnus-summary-mode)
3785 (set-buffer gnus-summary-buffer))
3786 (setq gnus-summary-buffer (current-buffer))
3787 (let* ((gnus-article (if header (mail-header-number header) article))
3788 (summary-buffer (current-buffer))
3789 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3790 (group gnus-newsgroup-name)
3793 (gnus-article-setup-buffer)
3794 (set-buffer gnus-article-buffer)
3795 ;; Deactivate active regions.
3796 (when (and (boundp 'transient-mark-mode)
3797 transient-mark-mode)
3798 (setq mark-active nil))
3799 (if (not (setq result (let ((buffer-read-only nil))
3800 (gnus-request-article-this-buffer
3802 ;; There is no such article.
3804 (when (and (numberp article)
3805 (not (memq article gnus-newsgroup-sparse)))
3806 (setq gnus-article-current
3807 (cons gnus-newsgroup-name article))
3808 (set-buffer gnus-summary-buffer)
3809 (setq gnus-current-article article)
3810 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3812 (gnus-summary-set-agent-mark article)
3813 (message "Message marked for downloading"))
3814 (gnus-summary-mark-article article gnus-canceled-mark)
3815 (unless (memq article gnus-newsgroup-sparse)
3816 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3817 (if (or (eq result 'pseudo)
3818 (eq result 'nneething))
3821 (set-buffer summary-buffer)
3822 (push article gnus-newsgroup-history)
3823 (setq gnus-last-article gnus-current-article
3824 gnus-current-article 0
3825 gnus-current-headers nil
3826 gnus-article-current nil)
3827 (if (eq result 'nneething)
3828 (gnus-configure-windows 'summary)
3829 (gnus-configure-windows 'article))
3830 (gnus-set-global-variables))
3831 (let ((gnus-article-mime-handle-alist-1
3832 gnus-article-mime-handle-alist))
3833 (gnus-set-mode-line 'article)))
3834 ;; The result from the `request' was an actual article -
3835 ;; or at least some text that is now displayed in the
3837 (when (and (numberp article)
3838 (not (eq article gnus-current-article)))
3839 ;; Seems like a new article has been selected.
3840 ;; `gnus-current-article' must be an article number.
3842 (set-buffer summary-buffer)
3843 (push article gnus-newsgroup-history)
3844 (setq gnus-last-article gnus-current-article
3845 gnus-current-article article
3846 gnus-current-headers
3847 (gnus-summary-article-header gnus-current-article)
3848 gnus-article-current
3849 (cons gnus-newsgroup-name gnus-current-article))
3850 (unless (vectorp gnus-current-headers)
3851 (setq gnus-current-headers nil))
3852 (gnus-summary-goto-subject gnus-current-article)
3853 (when (gnus-summary-show-thread)
3854 ;; If the summary buffer really was folded, the
3855 ;; previous goto may not actually have gone to
3856 ;; the right article, but the thread root instead.
3858 (gnus-summary-goto-subject gnus-current-article))
3859 (gnus-run-hooks 'gnus-mark-article-hook)
3860 (gnus-set-mode-line 'summary)
3861 (when (gnus-visual-p 'article-highlight 'highlight)
3862 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3863 ;; Set the global newsgroup variables here.
3864 (gnus-set-global-variables)
3865 (setq gnus-have-all-headers
3866 (or all-headers gnus-show-all-headers))))
3868 (gnus-configure-windows 'article))
3869 (when (or (numberp article)
3871 (gnus-article-prepare-display)
3873 (goto-char (point-min))
3874 (setq gnus-page-broken
3875 (when gnus-break-pages
3876 (gnus-narrow-to-page)
3878 (let ((gnus-article-mime-handle-alist-1
3879 gnus-article-mime-handle-alist))
3880 (gnus-set-mode-line 'article))
3884 (set-window-point (get-buffer-window (current-buffer)) (point))
3885 (gnus-configure-windows 'article)
3888 (defun gnus-article-prepare-mime-display (&optional number)
3889 (goto-char (point-min))
3890 (when (re-search-forward "^[^\t ]+:" nil t)
3891 (goto-char (match-beginning 0)))
3892 (let ((entity (if (eq 1 (point-min))
3893 (get-text-property 1 'mime-view-entity)
3894 (get-text-property (point) 'mime-view-entity)))
3895 last-entity child-entity next type)
3896 (setq child-entity (mime-entity-children entity))
3898 (setq last-entity (nth (1- (length child-entity))
3900 (setq last-entity entity))
3902 (narrow-to-region (point)
3903 (if (search-forward "\n\n" nil t)
3906 (gnus-treat-article 'head)
3907 (put-text-property (point-min) (point-max) 'article-treated-header t)
3908 (goto-char (point-max)))
3909 (while (and (not (eobp)) entity)
3910 (setq next (set-marker
3912 (next-single-property-change (point) 'mime-view-entity
3914 (let ((types (mime-entity-content-type entity)))
3915 (while (eq 'multipart (mime-content-type-primary-type types))
3916 (setq entity (car (mime-entity-children entity))
3917 types (mime-entity-content-type entity)))
3919 (setq type (format "%s/%s"
3920 (mime-content-type-primary-type types)
3921 (mime-content-type-subtype types)))))
3922 (if (string-equal type "message/rfc822")
3925 (let ((children (mime-entity-children entity))
3928 (setq last-children (nth (1- (length children)) children))
3931 (not (eq last-children
3932 (get-text-property next 'mime-view-entity)))
3934 (next-single-property-change next
3936 nil (point-max)))))))
3937 (setq next (next-single-property-change next 'mime-view-entity
3940 (narrow-to-region (point) next)
3941 (gnus-article-prepare-mime-display)
3942 (goto-char (point-max)))
3943 (setq entity (get-text-property (point) 'mime-view-entity)))
3945 (narrow-to-region (point) next)
3946 ;; Kludge. We have to count true number, but for now,
3947 ;; part number is here only to achieve `last'.
3948 (gnus-treat-article nil 1
3949 (if (eq entity last-entity)
3952 (goto-char (point-max)))
3953 (setq entity (get-text-property next 'mime-view-entity))))))
3956 (defun gnus-article-prepare-display ()
3957 "Make the current buffer look like a nice article."
3958 (let ((gnus-article-buffer (current-buffer))
3960 (unless (eq major-mode 'gnus-article-mode)
3961 (gnus-article-mode))
3962 (setq buffer-read-only nil
3963 gnus-button-marker-list nil
3964 gnus-article-wash-types nil
3965 gnus-article-image-alist nil)
3968 (static-if (featurep 'xemacs)
3969 (map-extents (lambda (extent maparg) (delete-extent extent)))
3970 (let ((lists (overlay-lists)))
3971 (dolist (overlay (nconc (car lists) (cdr lists)))
3972 (delete-overlay overlay)))))
3973 (gnus-run-hooks 'gnus-tmp-internal-hook))
3974 (set-buffer gnus-original-article-buffer)
3976 (setq mime-message-structure gnus-current-headers)
3977 (mime-buffer-entity-set-buffer-internal mime-message-structure
3978 gnus-original-article-buffer)
3979 (mime-entity-set-representation-type-internal mime-message-structure
3980 'mime-buffer-entity)
3981 (luna-send mime-message-structure 'initialize-instance
3982 mime-message-structure)
3984 (let (mime-display-header-hook mime-display-text/plain-hook)
3985 (funcall gnus-article-display-method-for-mime))
3986 (funcall gnus-article-display-method-for-traditional))
3987 ;; Call the treatment functions.
3988 (let ((inhibit-read-only t))
3992 (gnus-article-prepare-mime-display)
3993 (narrow-to-region (goto-char (point-min))
3994 (if (search-forward "\n\n" nil t)
3997 (gnus-treat-article 'head)
3998 (put-text-property (point-min) (point-max) 'article-treated-header t)
3999 (goto-char (point-max))
4001 (narrow-to-region (point) (point-max))
4002 (gnus-treat-article nil))
4003 (put-text-property (point-min) (point-max) 'read-only nil)))
4004 (gnus-run-hooks 'gnus-article-prepare-hook))
4006 (defun gnus-article-decode-article-as-default-mime-charset ()
4007 "Decode an article as `default-mime-charset'. It won't work if the
4008 value of the variable `gnus-show-mime' is non-nil."
4009 (unless gnus-show-mime
4010 (set (make-local-variable 'default-mime-charset)
4011 (with-current-buffer gnus-summary-buffer
4012 default-mime-charset))
4013 (decode-mime-charset-region (point-min) (point-max)
4014 default-mime-charset)))
4017 ;;; Gnus MIME viewing functions
4020 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4021 "Format of the MIME buttons.
4023 Valid specifiers include:
4025 %T MIME type, along with additional info
4026 %n The `name' parameter
4027 %d The description, if any
4028 %l The length of the encoded part
4029 %p The part identifier number
4030 %e Dots if the part isn't displayed
4032 General format specifiers can also be used. See Info node
4033 `(gnus)Formatting Variables'.")
4035 (defvar gnus-mime-button-line-format-alist
4036 '((?t gnus-tmp-type ?s)
4037 (?T gnus-tmp-type-long ?s)
4038 (?n gnus-tmp-name ?s)
4039 (?d gnus-tmp-description ?s)
4041 (?l gnus-tmp-length ?d)
4042 (?e gnus-tmp-dots ?s)))
4044 (defvar gnus-mime-button-commands
4045 '((gnus-article-press-button "\r" "Toggle Display")
4046 (gnus-mime-view-part "v" "View Interactively...")
4047 (gnus-mime-view-part-as-type "t" "View As Type...")
4048 (gnus-mime-view-part-as-charset "C" "View As charset...")
4049 (gnus-mime-save-part "o" "Save...")
4050 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4051 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4052 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4053 (gnus-mime-view-part-internally "E" "View Internally")
4054 (gnus-mime-view-part-externally "e" "View Externally")
4055 (gnus-mime-print-part "p" "Print")
4056 (gnus-mime-pipe-part "|" "Pipe To Command...")
4057 (gnus-mime-action-on-part "." "Take action on the part")))
4059 (defun gnus-article-mime-part-status ()
4060 (with-current-buffer gnus-article-buffer
4061 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4064 (setq children (mime-entity-children entity))
4065 (setq children (length children)))
4068 (format " (%d parts)" children))
4071 (defvar gnus-mime-button-map
4072 (let ((map (make-sparse-keymap)))
4073 (unless (>= (string-to-number emacs-version) 21)
4074 ;; XEmacs doesn't care.
4075 (set-keymap-parent map gnus-article-mode-map))
4076 (define-key map gnus-mouse-2 'gnus-article-push-button)
4077 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4078 (dolist (c gnus-mime-button-commands)
4079 (define-key map (cadr c) (car c)))
4082 (defun gnus-mime-button-menu (event)
4083 "Construct a context-sensitive menu of MIME commands."
4085 (save-window-excursion
4086 (let ((pos (event-start event)))
4087 (select-window (posn-window pos))
4088 (goto-char (posn-point pos))
4089 (gnus-article-check-buffer)
4090 (let ((response (x-popup-menu
4092 ("" ,@(mapcar (lambda (c)
4093 (cons (caddr c) (car c)))
4094 gnus-mime-button-commands))))))
4096 (call-interactively response))))))
4098 (defun gnus-mime-view-all-parts (&optional handles)
4099 "View all the MIME parts."
4101 (save-current-buffer
4102 (set-buffer gnus-article-buffer)
4103 (let ((handles (or handles gnus-article-mime-handles))
4104 (mail-parse-charset gnus-newsgroup-charset)
4105 (mail-parse-ignored-charsets
4106 (with-current-buffer gnus-summary-buffer
4107 gnus-newsgroup-ignored-charsets)))
4109 (mm-remove-parts handles)
4110 (goto-char (point-min))
4111 (or (search-forward "\n\n") (goto-char (point-max)))
4112 (let (buffer-read-only)
4113 (delete-region (point) (point-max))
4114 (mm-display-parts handles))))))
4116 (defun gnus-mime-save-part-and-strip ()
4117 "Save the MIME part under point then replace it with an external body."
4119 (gnus-article-check-buffer)
4120 (let* ((data (get-text-property (point) 'gnus-data))
4122 (handles gnus-article-mime-handles))
4123 (if (mm-multiple-handles gnus-article-mime-handles)
4124 (error "This function is not implemented"))
4125 (setq file (and data (mm-save-part data)))
4127 (with-current-buffer (mm-handle-buffer data)
4129 (insert "Content-Type: " (mm-handle-media-type data))
4130 (mml-insert-parameter-string (cdr (mm-handle-type data))
4133 (insert "Content-ID: " (message-make-message-id) "\n")
4134 (insert "Content-Transfer-Encoding: binary\n")
4137 (cdr (mm-make-handle nil
4138 `("message/external-body"
4139 (access-type . "LOCAL-FILE")
4141 (set-buffer gnus-summary-buffer)
4142 (gnus-article-edit-article
4145 (let ((mail-parse-charset (or gnus-article-charset
4146 ',gnus-newsgroup-charset))
4147 (mail-parse-ignored-charsets
4148 (or gnus-article-ignored-charsets
4149 ',gnus-newsgroup-ignored-charsets))
4150 (mbl mml-buffer-list))
4151 (setq mml-buffer-list nil)
4152 (insert-buffer gnus-original-article-buffer)
4153 (mime-to-mml ',handles)
4154 (setq gnus-article-mime-handles nil)
4155 (let ((mbl1 mml-buffer-list))
4156 (setq mml-buffer-list mbl)
4157 (set (make-local-variable 'mml-buffer-list) mbl1))
4158 ;; LOCAL argument of add-hook differs between GNU Emacs
4159 ;; and XEmacs. make-local-hook makes sure they are local.
4160 (make-local-hook 'kill-buffer-hook)
4161 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4162 `(lambda (no-highlight)
4163 (let ((mail-parse-charset (or gnus-article-charset
4164 ',gnus-newsgroup-charset))
4165 (message-options message-options)
4166 (message-options-set-recipient)
4167 (mail-parse-ignored-charsets
4168 (or gnus-article-ignored-charsets
4169 ',gnus-newsgroup-ignored-charsets)))
4171 (mml-destroy-buffers)
4172 (remove-hook 'kill-buffer-hook
4173 'mml-destroy-buffers t)
4174 (kill-local-variable 'mml-buffer-list))
4175 (gnus-summary-edit-article-done
4176 ,(or (mail-header-references gnus-current-headers) "")
4177 ,(gnus-group-read-only-p)
4178 ,gnus-summary-buffer no-highlight))))))
4180 (defun gnus-mime-save-part ()
4181 "Save the MIME part under point."
4183 (gnus-article-check-buffer)
4184 (let ((data (get-text-property (point) 'gnus-data)))
4186 (mm-save-part data))))
4188 (defun gnus-mime-pipe-part ()
4189 "Pipe the MIME part under point to a process."
4191 (gnus-article-check-buffer)
4192 (let ((data (get-text-property (point) 'gnus-data)))
4194 (mm-pipe-part data))))
4196 (defun gnus-mime-view-part ()
4197 "Interactively choose a viewing method for the MIME part under point."
4199 (gnus-article-check-buffer)
4200 (let ((data (get-text-property (point) 'gnus-data)))
4202 (setq gnus-article-mime-handles
4204 gnus-article-mime-handles (setq data (copy-sequence data))))
4205 (mm-interactively-view-part data))))
4207 (defun gnus-mime-view-part-as-type-internal ()
4208 (gnus-article-check-buffer)
4209 (let* ((name (mail-content-type-get
4210 (mm-handle-type (get-text-property (point) 'gnus-data))
4212 (def-type (and name (mm-default-file-encoding name))))
4213 (and def-type (cons def-type 0))))
4215 (defun gnus-mime-view-part-as-type (&optional mime-type)
4216 "Choose a MIME media type, and view the part as such."
4219 (setq mime-type (completing-read
4220 "View as MIME type: "
4221 (mapcar #'list (mailcap-mime-types))
4223 (gnus-mime-view-part-as-type-internal))))
4224 (gnus-article-check-buffer)
4225 (let ((handle (get-text-property (point) 'gnus-data)))
4228 (mm-make-handle (mm-handle-buffer handle)
4229 (cons mime-type (cdr (mm-handle-type handle)))
4230 (mm-handle-encoding handle)
4231 (mm-handle-undisplayer handle)
4232 (mm-handle-disposition handle)
4233 (mm-handle-description handle)
4235 (mm-handle-id handle)))
4236 (setq gnus-article-mime-handles
4237 (mm-merge-handles gnus-article-mime-handles handle))
4238 (gnus-mm-display-part handle))))
4240 (defun gnus-mime-copy-part (&optional handle)
4241 "Put the MIME part under point into a new buffer."
4243 (gnus-article-check-buffer)
4244 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4245 (contents (and handle (mm-get-part handle)))
4247 (file-name-nondirectory
4249 (mail-content-type-get (mm-handle-type handle) 'name)
4250 (mail-content-type-get (mm-handle-type handle)
4253 (buffer (and base (generate-new-buffer base))))
4255 (switch-to-buffer buffer)
4257 ;; We do it this way to make `normal-mode' set the appropriate mode.
4260 (setq buffer-file-name (expand-file-name base))
4262 (setq buffer-file-name nil))
4263 (goto-char (point-min)))))
4265 (defun gnus-mime-print-part (&optional handle filename)
4266 "Print the MIME part under point."
4267 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4268 (gnus-article-check-buffer)
4269 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4270 (contents (and handle (mm-get-part handle)))
4271 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4272 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4277 (with-temp-file file
4279 (call-process shell-file-name nil
4280 (generate-new-buffer " *mm*")
4282 shell-command-switch
4284 printer file (mm-handle-type handle))))
4288 (gnus-print-buffer))
4289 (ps-despool filename)))))
4291 (defun gnus-mime-inline-part (&optional handle arg)
4292 "Insert the MIME part under point into the current buffer."
4293 (interactive (list nil current-prefix-arg))
4294 (gnus-article-check-buffer)
4295 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4300 (if (and (not arg) (mm-handle-undisplayer handle))
4301 (mm-remove-part handle)
4302 (setq contents (mm-get-part handle))
4305 (setq charset (or (mail-content-type-get
4306 (mm-handle-type handle) 'charset)
4307 gnus-newsgroup-charset)))
4309 (if (mm-handle-undisplayer handle)
4310 (mm-remove-part handle))
4313 gnus-summary-show-article-charset-alist))
4314 (mm-read-coding-system "Charset: ")))))
4316 (mm-insert-inline handle
4318 (setq charset (mm-charset-to-coding-system
4320 (not (eq charset 'ascii)))
4321 (mm-decode-coding-string contents charset)
4325 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4326 "Insert the MIME part under point into the current buffer using the
4328 (interactive (list nil current-prefix-arg))
4329 (gnus-article-check-buffer)
4330 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4335 (if (mm-handle-undisplayer handle)
4336 (mm-remove-part handle))
4337 (let ((gnus-newsgroup-charset
4339 gnus-summary-show-article-charset-alist))
4340 (mm-read-coding-system "Charset: ")))
4341 (gnus-newsgroup-ignored-charsets 'gnus-all))
4342 (gnus-article-press-button)))))
4344 (defun gnus-mime-view-part-externally (&optional handle)
4345 "View the MIME part under point with an external viewer."
4347 (gnus-article-check-buffer)
4348 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4349 (mm-user-display-methods nil)
4350 (mm-inlined-types nil)
4351 (mail-parse-charset gnus-newsgroup-charset)
4352 (mail-parse-ignored-charsets
4353 (save-excursion (set-buffer gnus-summary-buffer)
4354 gnus-newsgroup-ignored-charsets)))
4356 (if (mm-handle-undisplayer handle)
4357 (mm-remove-part handle)
4358 (mm-display-part handle)))))
4360 (defun gnus-mime-view-part-internally (&optional handle)
4361 "View the MIME part under point with an internal viewer.
4362 If no internal viewer is available, use an external viewer."
4364 (gnus-article-check-buffer)
4365 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4366 (mm-inlined-types '(".*"))
4367 (mm-inline-large-images t)
4368 (mail-parse-charset gnus-newsgroup-charset)
4369 (mail-parse-ignored-charsets
4370 (save-excursion (set-buffer gnus-summary-buffer)
4371 gnus-newsgroup-ignored-charsets)))
4373 (if (mm-handle-undisplayer handle)
4374 (mm-remove-part handle)
4375 (mm-display-part handle)))))
4377 (defun gnus-mime-action-on-part (&optional action)
4378 "Do something with the MIME attachment at \(point\)."
4380 (list (completing-read "Action: " gnus-mime-action-alist)))
4381 (gnus-article-check-buffer)
4382 (let ((action-pair (assoc action gnus-mime-action-alist)))
4384 (funcall (cdr action-pair)))))
4386 (defun gnus-article-part-wrapper (n function)
4387 (save-current-buffer
4388 (set-buffer gnus-article-buffer)
4389 (when (> n (length gnus-article-mime-handle-alist))
4390 (error "No such part"))
4391 (gnus-article-goto-part n)
4392 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4393 (funcall function handle))))
4395 (defun gnus-article-pipe-part (n)
4396 "Pipe MIME part N, which is the numerical prefix."
4398 (gnus-article-part-wrapper n 'mm-pipe-part))
4400 (defun gnus-article-save-part (n)
4401 "Save MIME part N, which is the numerical prefix."
4403 (gnus-article-part-wrapper n 'mm-save-part))
4405 (defun gnus-article-interactively-view-part (n)
4406 "View MIME part N interactively, which is the numerical prefix."
4408 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4410 (defun gnus-article-copy-part (n)
4411 "Copy MIME part N, which is the numerical prefix."
4413 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4415 (defun gnus-article-view-part-as-charset (n)
4416 "Copy MIME part N, which is the numerical prefix."
4418 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4420 (defun gnus-article-view-part-externally (n)
4421 "View MIME part N externally, which is the numerical prefix."
4423 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4425 (defun gnus-article-inline-part (n)
4426 "Inline MIME part N, which is the numerical prefix."
4428 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4430 (defun gnus-article-mime-match-handle-first (condition)
4432 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4433 (while (setq ihandle (pop alist))
4435 ((functionp condition)
4436 (funcall condition (cdr ihandle)))
4437 ((eq condition 'undisplayed)
4438 (not (or (mm-handle-undisplayer (cdr ihandle))
4439 (equal (mm-handle-media-type (cdr ihandle))
4440 "multipart/alternative"))))
4441 ((eq condition 'undisplayed-alternative)
4442 (not (mm-handle-undisplayer (cdr ihandle))))
4444 (gnus-article-goto-part (car ihandle))
4445 (or (not n) (< (car ihandle) n)))
4446 (setq n (car ihandle))))
4450 (defun gnus-article-view-part (&optional n)
4451 "View MIME part N, which is the numerical prefix."
4453 (save-current-buffer
4454 (set-buffer gnus-article-buffer)
4455 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4456 gnus-article-mime-match-handle-function)))
4457 (when (> n (length gnus-article-mime-handle-alist))
4458 (error "No such part"))
4459 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4460 (when (gnus-article-goto-part n)
4461 (if (equal (car handle) "multipart/alternative")
4462 (gnus-article-press-button)
4463 (when (eq (gnus-mm-display-part handle) 'internal)
4464 (gnus-set-window-start)))))))
4466 (defsubst gnus-article-mime-total-parts ()
4467 (if (bufferp (car gnus-article-mime-handles))
4469 (1- (length gnus-article-mime-handles))))
4471 (defun gnus-mm-display-part (handle)
4472 "Display HANDLE and fix MIME button."
4473 (let ((id (get-text-property (point) 'gnus-part))
4478 (let ((window (selected-window))
4479 (mail-parse-charset gnus-newsgroup-charset)
4480 (mail-parse-ignored-charsets
4481 (if (gnus-buffer-live-p gnus-summary-buffer)
4483 (set-buffer gnus-summary-buffer)
4484 gnus-newsgroup-ignored-charsets)
4488 (let ((win (gnus-get-buffer-window (current-buffer) t))
4491 (select-window win))
4494 (if (mm-handle-displayed-p handle)
4495 ;; This will remove the part.
4496 (mm-display-part handle)
4498 (narrow-to-region (point)
4499 (if (eobp) (point) (1+ (point))))
4500 (mm-display-part handle)
4501 ;; We narrow to the part itself and
4502 ;; then call the treatment functions.
4503 (goto-char (point-min))
4505 (narrow-to-region (point) (point-max))
4508 (gnus-article-mime-total-parts)
4509 (mm-handle-media-type handle)))))
4510 (if (window-live-p window)
4511 (select-window window)))))
4513 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4514 (gnus-insert-mime-button
4515 handle id (list (mm-handle-displayed-p handle)))
4516 (goto-char point))))
4518 (defun gnus-article-goto-part (n)
4519 "Go to MIME part N."
4520 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4522 (goto-char point))))
4524 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4525 (let ((gnus-tmp-name
4526 (or (mail-content-type-get (mm-handle-type handle) 'name)
4527 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4528 (mail-content-type-get (mm-handle-type handle) 'url)
4530 (gnus-tmp-type (mm-handle-media-type handle))
4531 (gnus-tmp-description
4532 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4535 (if (if displayed (car displayed)
4536 (mm-handle-displayed-p handle))
4538 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4540 gnus-tmp-type-long b e)
4541 (when (string-match ".*/" gnus-tmp-name)
4542 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4543 (setq gnus-tmp-type-long (concat gnus-tmp-type
4544 (and (not (equal gnus-tmp-name ""))
4545 (concat "; " gnus-tmp-name))))
4546 (unless (equal gnus-tmp-description "")
4547 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4552 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4553 `(,@(gnus-local-map-property gnus-mime-button-map)
4554 gnus-callback gnus-mm-display-part
4555 gnus-part ,gnus-tmp-id
4556 article-type annotation
4559 (widget-convert-button
4562 :action 'gnus-widget-press-button
4563 :button-keymap gnus-mime-button-map
4565 (lambda (widget/window &optional overlay pos)
4566 ;; Needed to properly clear the message due to a bug in
4567 ;; wid-edit (XEmacs only).
4568 (if (boundp 'help-echo-owns-message)
4569 (setq help-echo-owns-message t))
4571 "%S: %s the MIME part; %S: more options"
4572 (aref gnus-mouse-2 0)
4573 ;; XEmacs will get a single widget arg; Emacs 21 will get
4574 ;; window, overlay, position.
4575 (if (mm-handle-displayed-p
4577 (with-current-buffer (gnus-overlay-buffer overlay)
4578 (widget-get (widget-at (gnus-overlay-start overlay))
4580 (widget-get widget/window :mime-handle)))
4582 (aref gnus-down-mouse-3 0))))))
4584 (defun gnus-widget-press-button (elems el)
4585 (goto-char (widget-get elems :from))
4586 (gnus-article-press-button))
4588 (defvar gnus-displaying-mime nil)
4590 (defun gnus-display-mime (&optional ihandles)
4591 "Display the MIME parts."
4593 (save-selected-window
4594 (let ((window (get-buffer-window gnus-article-buffer))
4597 (select-window window)
4598 ;; We have to do this since selecting the window
4599 ;; may change the point. So we set the window point.
4600 (set-window-point window point)))
4601 (let* ((handles (or ihandles (mm-dissect-buffer
4602 nil gnus-article-loose-mime)
4604 buffer-read-only handle name type b e display)
4605 (when (and (not ihandles)
4606 (not gnus-displaying-mime))
4607 ;; Top-level call; we clean up.
4608 (when gnus-article-mime-handles
4609 (mm-destroy-parts gnus-article-mime-handles)
4610 (setq gnus-article-mime-handle-alist nil));; A trick.
4611 (setq gnus-article-mime-handles handles)
4612 ;; We allow users to glean info from the handles.
4613 (when gnus-article-mime-part-function
4614 (gnus-mime-part-function handles)))
4616 (or (not (stringp (car handles)))
4619 (when (and (not ihandles)
4620 (not gnus-displaying-mime))
4621 ;; Clean up for mime parts.
4623 (delete-region (point) (point-max)))
4624 (let ((gnus-displaying-mime t))
4625 (gnus-mime-display-part handles)))
4628 (narrow-to-region (point) (point-max))
4629 (gnus-treat-article nil 1 1)
4632 ;; Highlight the headers.
4636 (narrow-to-region (point-min) (point))
4637 (gnus-treat-article 'head))))))))
4639 (defvar gnus-mime-display-multipart-as-mixed nil)
4640 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4641 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4643 (defun gnus-mime-display-part (handle)
4646 ((not (stringp (car handle)))
4647 (gnus-mime-display-single handle))
4648 ;; User-defined multipart
4649 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4650 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4652 ;; multipart/alternative
4653 ((and (equal (car handle) "multipart/alternative")
4654 (not (or gnus-mime-display-multipart-as-mixed
4655 gnus-mime-display-multipart-alternative-as-mixed)))
4656 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4657 (push (cons id handle) gnus-article-mime-handle-alist)
4658 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4659 ;; multipart/related
4660 ((and (equal (car handle) "multipart/related")
4661 (not (or gnus-mime-display-multipart-as-mixed
4662 gnus-mime-display-multipart-related-as-mixed)))
4663 ;;;!!!We should find the start part, but we just default
4664 ;;;!!!to the first part.
4665 ;;(gnus-mime-display-part (cadr handle))
4666 ;;;!!! Most multipart/related is an HTML message plus images.
4667 ;;;!!! Unfortunately we are unable to let W3 display those
4668 ;;;!!! included images, so we just display it as a mixed multipart.
4669 ;;(gnus-mime-display-mixed (cdr handle))
4670 ;;;!!! No, w3 can display everything just fine.
4671 (gnus-mime-display-part (cadr handle)))
4672 ((equal (car handle) "multipart/signed")
4673 (gnus-add-wash-type 'signed)
4674 (gnus-mime-display-security handle))
4675 ((equal (car handle) "multipart/encrypted")
4676 (gnus-add-wash-type 'encrypted)
4677 (gnus-mime-display-security handle))
4678 ;; Other multiparts are handled like multipart/mixed.
4680 (gnus-mime-display-mixed (cdr handle)))))
4682 (defun gnus-mime-part-function (handles)
4683 (if (stringp (car handles))
4684 (mapcar 'gnus-mime-part-function (cdr handles))
4685 (funcall gnus-article-mime-part-function handles)))
4687 (defun gnus-mime-display-mixed (handles)
4688 (mapcar 'gnus-mime-display-part handles))
4690 (defun gnus-mime-display-single (handle)
4691 (let ((type (mm-handle-media-type handle))
4692 (ignored gnus-ignored-mime-types)
4699 (when (string-match (pop ignored) type)
4700 (throw 'ignored nil)))
4701 (if (and (setq not-attachment
4702 (and (not (mm-inline-override-p handle))
4703 (or (not (mm-handle-disposition handle))
4704 (equal (car (mm-handle-disposition handle))
4706 (mm-attachment-override-p handle))))
4707 (mm-automatic-display-p handle)
4709 (mm-inlinable-p handle)
4710 (mm-inlined-p handle))
4711 (mm-automatic-external-display-p type)))
4713 (when (equal (mm-handle-media-supertype handle) "text")
4715 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4717 (push (cons id handle) gnus-article-mime-handle-alist)
4718 (when (or (not display)
4719 (not (gnus-unbuttonized-mime-type-p type)))
4720 ;(gnus-article-insert-newline)
4721 (gnus-insert-mime-button
4722 handle id (list (or display (and not-attachment text))))
4723 (gnus-article-insert-newline)
4724 ;(gnus-article-insert-newline)
4725 ;; Remember modify the number of forward lines.
4733 (let ((mail-parse-charset gnus-newsgroup-charset)
4734 (mail-parse-ignored-charsets
4735 (save-excursion (condition-case ()
4736 (set-buffer gnus-summary-buffer)
4738 gnus-newsgroup-ignored-charsets)))
4739 (mm-display-part handle t))
4740 (goto-char (point-max)))
4741 ((and text not-attachment)
4745 (gnus-article-insert-newline)
4746 (mm-insert-inline handle (mm-get-part handle))
4747 (goto-char (point-max))))
4751 (narrow-to-region beg (point))
4754 (gnus-article-mime-total-parts)
4755 (mm-handle-media-type handle)))))))))
4757 (defun gnus-unbuttonized-mime-type-p (type)
4758 "Say whether TYPE is to be unbuttonized."
4759 (unless gnus-inhibit-mime-unbuttonizing
4761 (let ((types gnus-unbuttonized-mime-types))
4763 (when (string-match (pop types) type)
4764 (throw 'found t)))))
4766 (let ((types gnus-buttonized-mime-types))
4768 (when (string-match (pop types) type)
4769 (throw 'found t)))))))))
4771 (defun gnus-article-insert-newline ()
4772 "Insert a newline, but mark it as undeletable."
4773 (gnus-put-text-property
4774 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4776 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4777 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4780 handle buffer-read-only from props begend not-pref)
4781 (save-window-excursion
4784 (narrow-to-region (car ibegend)
4787 (goto-char (car ibegend))
4790 (delete-region (point-min) (point-max))
4791 (mm-remove-parts handles))
4792 (setq begend (list (point-marker)))
4794 (unless (setq not-pref (cadr (member preferred ihandles)))
4795 (setq not-pref (car ihandles)))
4798 (not (gnus-unbuttonized-mime-type-p
4799 "multipart/alternative")))
4800 (gnus-add-text-properties
4803 (insert (format "%d. " id))
4807 (unless ,(not ibegend)
4808 (setq gnus-article-mime-handle-alist
4809 ',gnus-article-mime-handle-alist))
4810 (gnus-mime-display-alternative
4811 ',ihandles ',not-pref ',begend ,id))
4812 ,@(gnus-local-map-property gnus-mime-button-map)
4813 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4814 face ,gnus-article-button-face
4817 (widget-convert-button 'link from (point)
4818 :action 'gnus-widget-press-button
4819 :button-keymap gnus-widget-button-keymap)
4821 (while (setq handle (pop handles))
4822 (gnus-add-text-properties
4825 (insert (format "(%c) %-18s"
4826 (if (equal handle preferred) ?* ? )
4827 (mm-handle-media-type handle)))
4831 (unless ,(not ibegend)
4832 (setq gnus-article-mime-handle-alist
4833 ',gnus-article-mime-handle-alist))
4834 (gnus-mime-display-alternative
4835 ',ihandles ',handle ',begend ,id))
4836 ,@(gnus-local-map-property gnus-mime-button-map)
4837 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4838 face ,gnus-article-button-face
4841 (widget-convert-button 'link from (point)
4842 :action 'gnus-widget-press-button
4843 :button-keymap gnus-widget-button-keymap)
4847 (if (stringp (car preferred))
4848 (gnus-display-mime preferred)
4849 (let ((mail-parse-charset gnus-newsgroup-charset)
4850 (mail-parse-ignored-charsets
4851 (save-excursion (set-buffer gnus-summary-buffer)
4852 gnus-newsgroup-ignored-charsets)))
4853 (mm-display-part preferred)
4857 (narrow-to-region (car begend) (point-max))
4859 nil (length gnus-article-mime-handle-alist)
4860 (gnus-article-mime-total-parts)
4861 (mm-handle-media-type handle))))))
4862 (goto-char (point-max))
4863 (setcdr begend (point-marker)))))
4865 (goto-char point))))
4867 (defconst gnus-article-wash-status-strings
4868 (let ((alist '((cite "c" "Possible hidden citation text"
4869 " " "All citation text visible")
4870 (headers "h" "Hidden headers"
4871 " " "All headers visible.")
4872 (pgp "p" "Encrypted or signed message status hidden"
4873 " " "No hidden encryption nor digital signature status")
4874 (signature "s" "Signature has been hidden"
4875 " " "Signature is visible")
4876 (overstrike "o" "Overstrike (^H) characters applied"
4877 " " "No overstrike characters applied")
4878 (gnus-show-mime "m" "Mime processing is activated"
4879 " " "Mime processing is not activated")
4880 (emphasis "e" "/*_Emphasis_*/ characters applied"
4881 " " "No /*_emphasis_*/ characters applied")))
4883 (dolist (entry alist result)
4884 (let ((key (nth 0 entry))
4885 (on (copy-sequence (nth 1 entry)))
4886 (on-help (nth 2 entry))
4887 (off (copy-sequence (nth 3 entry)))
4888 (off-help (nth 4 entry)))
4889 (put-text-property 0 1 'help-echo on-help on)
4890 (put-text-property 0 1 'help-echo off-help off)
4891 (push (list key on off) result))))
4892 "Alist of strings describing wash status in the mode line.
4893 Each entry has the form (KEY ON OF), where the KEY is a symbol
4894 representing the particular washing function, ON is the string to use
4895 in the article mode line when the washing function is active, and OFF
4896 is the string to use when it is inactive.")
4898 (defun gnus-article-wash-status-entry (key value)
4899 (let ((entry (assoc key gnus-article-wash-status-strings)))
4900 (if value (nth 1 entry) (nth 2 entry))))
4902 (defun gnus-article-wash-status ()
4903 "Return a string which display status of article washing."
4905 (set-buffer gnus-article-buffer)
4906 (let ((cite (memq 'cite gnus-article-wash-types))
4907 (headers (memq 'headers gnus-article-wash-types))
4908 (boring (memq 'boring-headers gnus-article-wash-types))
4909 (pgp (memq 'pgp gnus-article-wash-types))
4910 (pem (memq 'pem gnus-article-wash-types))
4911 (signed (memq 'signed gnus-article-wash-types))
4912 (encrypted (memq 'encrypted gnus-article-wash-types))
4913 (signature (memq 'signature gnus-article-wash-types))
4914 (overstrike (memq 'overstrike gnus-article-wash-types))
4915 (emphasis (memq 'emphasis gnus-article-wash-types)))
4917 (gnus-article-wash-status-entry 'cite cite)
4918 (gnus-article-wash-status-entry 'headers (or headers boring))
4919 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4920 (gnus-article-wash-status-entry 'signature signature)
4921 (gnus-article-wash-status-entry 'overstrike overstrike)
4922 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4923 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4925 (defun gnus-add-wash-type (type)
4926 "Add a washing of TYPE to the current status."
4927 (add-to-list 'gnus-article-wash-types type))
4929 (defun gnus-delete-wash-type (type)
4930 "Add a washing of TYPE to the current status."
4931 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4933 (defun gnus-add-image (category image)
4934 "Add IMAGE of CATEGORY to the list of displayed images."
4935 (let ((entry (assq category gnus-article-image-alist)))
4937 (setq entry (list category))
4938 (push entry gnus-article-image-alist))
4939 (nconc entry (list image))))
4941 (defun gnus-delete-images (category)
4942 "Delete all images in CATEGORY."
4943 (let ((entry (assq category gnus-article-image-alist)))
4944 (dolist (image (cdr entry))
4945 (gnus-remove-image image))
4946 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4947 (gnus-delete-wash-type category)))
4949 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4951 (defun gnus-article-maybe-hide-headers ()
4952 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4953 Provided for backwards compatibility."
4954 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4955 (not (save-excursion (set-buffer gnus-summary-buffer)
4956 gnus-have-all-headers)))
4957 (not gnus-inhibit-hiding))
4958 (gnus-article-hide-headers)))
4962 (defun gnus-output-to-file (file-name)
4963 "Append the current article to a file named FILE-NAME."
4964 (let ((artbuf (current-buffer)))
4966 (insert-buffer-substring artbuf)
4967 ;; Append newline at end of the buffer as separator, and then
4969 (goto-char (point-max))
4971 (let ((file-name-coding-system nnmail-pathname-coding-system)
4972 (pathname-coding-system nnmail-pathname-coding-system))
4973 (write-region-as-binary (point-min) (point-max) file-name 'append))
4976 (defun gnus-narrow-to-page (&optional arg)
4977 "Narrow the article buffer to a page.
4978 If given a numerical ARG, move forward ARG pages."
4980 (setq arg (if arg (prefix-numeric-value arg) 0))
4982 (set-buffer gnus-article-buffer)
4983 (goto-char (point-min))
4985 ;; Remove any old next/prev buttons.
4986 (when (gnus-visual-p 'page-marker)
4987 (let ((buffer-read-only nil))
4988 (gnus-remove-text-with-property 'gnus-prev)
4989 (gnus-remove-text-with-property 'gnus-next)))
4992 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4994 (re-search-forward page-delimiter nil 'move arg)))
4995 (goto-char (match-end 0)))
4998 (if (re-search-forward page-delimiter nil 'move)
5001 (when (and (gnus-visual-p 'page-marker)
5002 (not (= (point-min) 1)))
5004 (goto-char (point-min))
5005 (gnus-insert-prev-page-button)))
5006 (when (and (gnus-visual-p 'page-marker)
5007 (< (+ (point-max) 2) (buffer-size)))
5009 (goto-char (point-max))
5010 (gnus-insert-next-page-button)))))
5012 ;; Article mode commands
5014 (defun gnus-article-goto-next-page ()
5015 "Show the next page of the article."
5017 (when (gnus-article-next-page)
5018 (goto-char (point-min))
5019 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5021 (defun gnus-article-goto-prev-page ()
5022 "Show the next page of the article."
5024 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5025 (gnus-article-prev-page nil)))
5027 (defun gnus-article-next-page (&optional lines)
5028 "Show the next page of the current article.
5029 If end of article, return non-nil. Otherwise return nil.
5030 Argument LINES specifies lines to be scrolled up."
5032 (let ((start (window-start))
5033 end-of-buffer end-of-page)
5035 (move-to-window-line -1)
5036 (if (<= (point) start)
5039 (setq start (point)))
5042 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5043 (and (pos-visible-in-window-p)
5044 (setq end-of-buffer t)))
5046 (setq end-of-page t)))
5048 (move-to-window-line lines)
5049 (unless (search-backward "\n\n" nil t)
5050 (setq start (point)))))
5051 (cond (end-of-buffer t)
5053 (gnus-narrow-to-page 1)
5057 (set-window-start (selected-window) start)
5058 (let (window-pixel-scroll-increment)
5062 (defun gnus-article-prev-page (&optional lines)
5063 "Show previous page of current article.
5064 Argument LINES specifies lines to be scrolled down."
5066 (let (beginning-of-buffer beginning-of-page)
5068 (move-to-window-line 0)
5069 (cond ((eq 1 (point))
5070 (setq beginning-of-buffer t))
5072 (setq beginning-of-page t))))
5073 (cond (beginning-of-buffer)
5075 (gnus-narrow-to-page -1))
5078 (let (window-pixel-scroll-increment)
5079 (scroll-down lines))
5080 (beginning-of-buffer
5081 (goto-char (point-min))))))))
5083 (defun gnus-article-refer-article ()
5084 "Read article specified by message-id around point."
5086 (let ((point (point)))
5087 (search-forward ">" nil t) ;Move point to end of "<....>".
5088 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5089 (let ((message-id (match-string 1)))
5091 (set-buffer gnus-summary-buffer)
5092 (gnus-summary-refer-article message-id))
5094 (error "No references around point"))))
5096 (defun gnus-article-show-summary ()
5097 "Reconfigure windows to show summary buffer."
5099 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5100 (error "There is no summary buffer for this article buffer")
5101 (gnus-article-set-globals)
5102 (gnus-configure-windows 'article)
5103 (gnus-summary-goto-subject gnus-current-article)
5104 (gnus-summary-position-point)))
5106 (defun gnus-article-describe-briefly ()
5107 "Describe article mode commands briefly."
5109 (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")))
5111 (defun gnus-article-summary-command ()
5112 "Execute the last keystroke in the summary buffer."
5114 (let ((obuf (current-buffer))
5115 (owin (current-window-configuration))
5117 (switch-to-buffer gnus-article-current-summary 'norecord)
5118 (setq func (lookup-key (current-local-map) (this-command-keys)))
5119 (call-interactively func)
5121 (set-window-configuration owin)
5122 (set-window-point (get-buffer-window (current-buffer)) (point))))
5124 (defun gnus-article-summary-command-nosave ()
5125 "Execute the last keystroke in the summary buffer."
5128 (pop-to-buffer gnus-article-current-summary 'norecord)
5129 (setq func (lookup-key (current-local-map) (this-command-keys)))
5130 (call-interactively func)))
5132 (defun gnus-article-check-buffer ()
5133 "Beep if not in an article buffer."
5134 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5135 (error "Command invoked outside of a Gnus article buffer")))
5137 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5138 "Read a summary buffer key sequence and execute it from the article buffer."
5140 (gnus-article-check-buffer)
5142 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5143 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5144 "=" "^" "\M-^" "|"))
5150 '("n" "Gn" "p" "Gp"))
5153 (set-buffer gnus-article-current-summary)
5154 (let (gnus-pick-mode)
5155 (push (or key last-command-event) unread-command-events)
5156 (setq keys (static-if (featurep 'xemacs)
5157 (events-to-keys (read-key-sequence nil))
5158 (read-key-sequence nil)))))
5161 (if (or (member keys nosaves)
5162 (member keys nosave-but-article)
5163 (member keys nosave-in-article))
5165 (save-window-excursion
5166 (pop-to-buffer gnus-article-current-summary 'norecord)
5167 ;; We disable the pick minor mode commands.
5168 (let (gnus-pick-mode)
5169 (setq func (lookup-key (current-local-map) keys))))
5173 (unless (member keys nosave-in-article)
5174 (set-buffer gnus-article-current-summary))
5175 (call-interactively func)
5176 (setq new-sum-point (point)))
5177 (when (member keys nosave-but-article)
5178 (pop-to-buffer gnus-article-buffer 'norecord)))
5179 ;; These commands should restore window configuration.
5180 (let ((obuf (current-buffer))
5181 (owin (current-window-configuration))
5183 (summary gnus-article-current-summary)
5184 func in-buffer selected)
5185 (if not-restore-window
5186 (pop-to-buffer summary 'norecord)
5187 (switch-to-buffer summary 'norecord))
5188 (setq in-buffer (current-buffer))
5189 ;; We disable the pick minor mode commands.
5190 (if (and (setq func (let (gnus-pick-mode)
5191 (lookup-key (current-local-map) keys)))
5194 (call-interactively func)
5195 (setq new-sum-point (point))
5196 (when (eq in-buffer (current-buffer))
5197 (setq selected (gnus-summary-select-article))
5199 (unless not-restore-window
5200 (set-window-configuration owin))
5201 (when (eq selected 'old)
5203 (set-window-start (get-buffer-window (current-buffer))
5205 (set-window-point (get-buffer-window (current-buffer))
5207 (let ((win (get-buffer-window gnus-article-current-summary)))
5209 (set-window-point win new-sum-point)))) )
5210 (switch-to-buffer gnus-article-buffer)
5213 (defun gnus-article-describe-key (key)
5214 "Display documentation of the function invoked by KEY. KEY is a string."
5215 (interactive "kDescribe key: ")
5216 (gnus-article-check-buffer)
5217 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5219 (set-buffer gnus-article-current-summary)
5220 (let (gnus-pick-mode)
5221 (if (featurep 'xemacs)
5223 (push (elt key 0) unread-command-events)
5224 (setq key (events-to-keys
5225 (read-key-sequence "Describe key: "))))
5226 (setq unread-command-events
5228 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5230 (setq key (read-key-sequence "Describe key: "))))
5232 (describe-key key)))
5234 (defun gnus-article-describe-key-briefly (key &optional insert)
5235 "Display documentation of the function invoked by KEY. KEY is a string."
5236 (interactive "kDescribe key: \nP")
5237 (gnus-article-check-buffer)
5238 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5240 (set-buffer gnus-article-current-summary)
5241 (let (gnus-pick-mode)
5242 (if (featurep 'xemacs)
5244 (push (elt key 0) unread-command-events)
5245 (setq key (events-to-keys
5246 (read-key-sequence "Describe key: "))))
5247 (setq unread-command-events
5249 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5251 (setq key (read-key-sequence "Describe key: "))))
5252 (describe-key-briefly key insert))
5253 (describe-key-briefly key insert)))
5255 (defun gnus-article-reply-with-original (&optional wide)
5256 "Start composing a reply mail to the current message.
5257 The text in the region will be yanked. If the region isn't active,
5258 the entire article will be yanked."
5260 (let ((article (cdr gnus-article-current)) cont)
5262 (with-current-buffer gnus-summary-buffer
5263 (gnus-summary-reply (list (list article)) wide))
5264 (setq cont (buffer-substring (point) (mark t)))
5265 ;; Deactivate active regions.
5266 (when (and (boundp 'transient-mark-mode)
5267 transient-mark-mode)
5268 (setq mark-active nil))
5269 (with-current-buffer gnus-summary-buffer
5271 (list (list article cont)) wide)))))
5273 (defun gnus-article-followup-with-original ()
5274 "Compose a followup to the current article.
5275 The text in the region will be yanked. If the region isn't active,
5276 the entire article will be yanked."
5278 (let ((article (cdr gnus-article-current)) cont)
5280 (with-current-buffer gnus-summary-buffer
5281 (gnus-summary-followup (list (list article))))
5282 (setq cont (buffer-substring (point) (mark t)))
5283 ;; Deactivate active regions.
5284 (when (and (boundp 'transient-mark-mode)
5285 transient-mark-mode)
5286 (setq mark-active nil))
5287 (with-current-buffer gnus-summary-buffer
5288 (gnus-summary-followup
5289 (list (list article cont)))))))
5291 (defun gnus-article-hide (&optional arg force)
5292 "Hide all the gruft in the current article.
5293 This means that PGP stuff, signatures, cited text and (some)
5294 headers will be hidden.
5295 If given a prefix, show the hidden text instead."
5296 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5297 (gnus-article-hide-headers arg)
5298 (gnus-article-hide-list-identifiers arg)
5299 (gnus-article-hide-pgp arg)
5300 (gnus-article-hide-citation-maybe arg force)
5301 (gnus-article-hide-signature arg))
5303 (defun gnus-article-maybe-highlight ()
5304 "Do some article highlighting if article highlighting is requested."
5305 (when (gnus-visual-p 'article-highlight 'highlight)
5306 (gnus-article-highlight-some)))
5308 (defun gnus-check-group-server ()
5309 ;; Make sure the connection to the server is alive.
5310 (unless (gnus-server-opened
5311 (gnus-find-method-for-group gnus-newsgroup-name))
5312 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5313 (gnus-request-group gnus-newsgroup-name t)))
5316 (autoload 'nneething-get-file-name "nneething"))
5318 (defun gnus-request-article-this-buffer (article group)
5319 "Get an article and insert it into this buffer."
5320 (let (do-update-line sparse-header)
5324 (gnus-kill-all-overlays)
5325 (setq group (or group gnus-newsgroup-name))
5327 ;; Using `gnus-request-article' directly will insert the article into
5328 ;; `nntp-server-buffer' - so we'll save some time by not having to
5329 ;; copy it from the server buffer into the article buffer.
5331 ;; We only request an article by message-id when we do not have the
5332 ;; headers for it, so we'll have to get those.
5333 (when (stringp article)
5334 (gnus-read-header article))
5336 ;; If the article number is negative, that means that this article
5337 ;; doesn't belong in this newsgroup (possibly), so we find its
5338 ;; message-id and request it by id instead of number.
5339 (when (and (numberp article)
5341 (get-buffer gnus-summary-buffer)
5342 (gnus-buffer-exists-p gnus-summary-buffer))
5344 (set-buffer gnus-summary-buffer)
5345 (let ((header (gnus-summary-article-header article)))
5348 ((memq article gnus-newsgroup-sparse)
5349 ;; This is a sparse gap article.
5350 (setq do-update-line article)
5351 (setq article (mail-header-id header))
5352 (setq sparse-header (gnus-read-header article))
5353 (setq gnus-newsgroup-sparse
5354 (delq article gnus-newsgroup-sparse)))
5356 ;; It's a real article.
5357 (setq article (mail-header-id header)))
5359 ;; It is an extracted pseudo-article.
5360 (setq article 'pseudo)
5361 (gnus-request-pseudo-article header))))
5363 (let ((method (gnus-find-method-for-group
5364 gnus-newsgroup-name)))
5365 (when (and (eq (car method) 'nneething)
5367 (let ((dir (nneething-get-file-name
5368 (mail-header-id header))))
5369 (when (and (stringp dir)
5370 (file-directory-p dir))
5371 (setq article 'nneething)
5372 (gnus-group-enter-directory dir))))))))
5375 ;; Refuse to select canceled articles.
5376 ((and (numberp article)
5378 (get-buffer gnus-summary-buffer)
5379 (gnus-buffer-exists-p gnus-summary-buffer)
5380 (eq (cdr (save-excursion
5381 (set-buffer gnus-summary-buffer)
5382 (assq article gnus-newsgroup-reads)))
5383 gnus-canceled-mark))
5385 ;; We first check `gnus-original-article-buffer'.
5386 ((and (get-buffer gnus-original-article-buffer)
5389 (set-buffer gnus-original-article-buffer)
5390 (and (equal (car gnus-original-article) group)
5391 (eq (cdr gnus-original-article) article))))
5392 (insert-buffer-substring gnus-original-article-buffer)
5394 ;; Check the backlog.
5395 ((and gnus-keep-backlog
5396 (gnus-backlog-request-article group article (current-buffer)))
5398 ;; Check asynchronous pre-fetch.
5399 ((gnus-async-request-fetched-article group article (current-buffer))
5400 (gnus-async-prefetch-next group article gnus-summary-buffer)
5401 (when (and (numberp article) gnus-keep-backlog)
5402 (gnus-backlog-enter-article group article (current-buffer)))
5405 ((and gnus-use-cache
5407 (gnus-cache-request-article article group))
5409 ;; Check the agent cache.
5410 ((and gnus-agent gnus-agent-cache gnus-plugged
5412 (gnus-agent-request-article article group))
5414 ;; Get the article and put into the article buffer.
5415 ((or (stringp article)
5417 (let ((gnus-override-method gnus-override-method)
5418 (methods (and (stringp article)
5419 gnus-refer-article-method))
5420 (backend (car (gnus-find-method-for-group
5421 gnus-newsgroup-name)))
5423 (buffer-read-only nil))
5424 (if (or (not (listp methods))
5425 (and (symbolp (car methods))
5426 (assq (car methods) nnoo-definition-alist)))
5427 (setq methods (list methods)))
5428 (when (and (null gnus-override-method)
5430 (setq gnus-override-method (pop methods)))
5432 (when (eq gnus-override-method 'current)
5433 (setq gnus-override-method
5434 (with-current-buffer gnus-summary-buffer
5435 gnus-current-select-method)))
5437 (gnus-kill-all-overlays)
5438 (let ((gnus-newsgroup-name group))
5439 (gnus-check-group-server))
5441 ((gnus-request-article article group (current-buffer))
5442 (when (numberp article)
5443 (gnus-async-prefetch-next group article
5444 gnus-summary-buffer)
5445 (when gnus-keep-backlog
5446 (gnus-backlog-enter-article
5447 group article (current-buffer))))
5448 (setq result 'article))
5450 (setq gnus-override-method (pop methods)))
5451 ((not (string-match "^400 "
5452 (nnheader-get-report backend)))
5453 ;; If we get 400 server disconnect, reconnect and
5454 ;; retry; otherwise, assume the article has expired.
5455 (setq result 'done))))
5456 (and (eq result 'article) 'article)))
5460 ;; Associate this article with the current summary buffer.
5461 (setq gnus-article-current-summary gnus-summary-buffer)
5463 ;; Take the article from the original article buffer
5464 ;; and place it in the buffer it's supposed to be in.
5465 (when (and (get-buffer gnus-article-buffer)
5466 (equal (buffer-name (current-buffer))
5467 (buffer-name (get-buffer gnus-article-buffer))))
5469 (if (get-buffer gnus-original-article-buffer)
5470 (set-buffer gnus-original-article-buffer)
5471 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5472 (buffer-disable-undo)
5473 (setq major-mode 'gnus-original-article-mode)
5474 (setq buffer-read-only t))
5475 (let (buffer-read-only)
5477 (insert-buffer-substring gnus-article-buffer))
5478 (setq gnus-original-article (cons group article)))
5481 (run-hooks 'gnus-article-decode-hook)
5482 ;; Mark article as decoded or not.
5483 (setq gnus-article-decoded-p gnus-article-decode-hook))
5485 ;; Update sparse articles.
5486 (when (and do-update-line
5487 (or (numberp article)
5489 (let ((buf (current-buffer)))
5490 (set-buffer gnus-summary-buffer)
5491 (gnus-summary-update-article do-update-line sparse-header)
5492 (gnus-summary-goto-subject do-update-line nil t)
5493 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5495 (set-buffer buf))))))
5501 (defcustom gnus-article-edit-mode-hook nil
5502 "Hook run in article edit mode buffers."
5503 :group 'gnus-article-various
5506 (defcustom gnus-article-edit-article-setup-function
5507 'gnus-article-mime-edit-article-setup
5508 "Function called to setup an editing article buffer."
5509 :group 'gnus-article-various
5512 (defvar gnus-article-edit-done-function nil)
5514 (defvar gnus-article-edit-mode-map nil)
5516 ;; Should we be using derived.el for this?
5517 (unless gnus-article-edit-mode-map
5518 (setq gnus-article-edit-mode-map (make-keymap))
5519 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5521 (gnus-define-keys gnus-article-edit-mode-map
5522 "\C-c?" describe-mode
5523 "\C-c\C-c" gnus-article-edit-done
5524 "\C-c\C-k" gnus-article-edit-exit
5525 "\C-c\C-f\C-t" message-goto-to
5526 "\C-c\C-f\C-o" message-goto-from
5527 "\C-c\C-f\C-b" message-goto-bcc
5528 ;;"\C-c\C-f\C-w" message-goto-fcc
5529 "\C-c\C-f\C-c" message-goto-cc
5530 "\C-c\C-f\C-s" message-goto-subject
5531 "\C-c\C-f\C-r" message-goto-reply-to
5532 "\C-c\C-f\C-n" message-goto-newsgroups
5533 "\C-c\C-f\C-d" message-goto-distribution
5534 "\C-c\C-f\C-f" message-goto-followup-to
5535 "\C-c\C-f\C-m" message-goto-mail-followup-to
5536 "\C-c\C-f\C-k" message-goto-keywords
5537 "\C-c\C-f\C-u" message-goto-summary
5538 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5539 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5540 "\C-c\C-b" message-goto-body
5541 "\C-c\C-i" message-goto-signature
5543 "\C-c\C-t" message-insert-to
5544 "\C-c\C-n" message-insert-newsgroups
5545 "\C-c\C-o" message-sort-headers
5546 "\C-c\C-e" message-elide-region
5547 "\C-c\C-v" message-delete-not-region
5548 "\C-c\C-z" message-kill-to-signature
5549 "\M-\r" message-newline-and-reformat
5550 "\C-c\C-a" mml-attach-file
5551 "\C-a" message-beginning-of-line
5553 "\M-;" comment-region)
5555 (gnus-define-keys (gnus-article-edit-wash-map
5556 "\C-c\C-w" gnus-article-edit-mode-map)
5557 "f" gnus-article-edit-full-stops))
5560 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5562 ["Fetch To" message-insert-to t]
5563 ["Fetch Newsgroups" message-insert-newsgroups t]
5565 ["To" message-goto-to t]
5566 ["From" message-goto-from t]
5567 ["Subject" message-goto-subject t]
5568 ["Cc" message-goto-cc t]
5569 ["Reply-To" message-goto-reply-to t]
5570 ["Summary" message-goto-summary t]
5571 ["Keywords" message-goto-keywords t]
5572 ["Newsgroups" message-goto-newsgroups t]
5573 ["Followup-To" message-goto-followup-to t]
5574 ["Mail-Followup-To" message-goto-mail-followup-to t]
5575 ["Distribution" message-goto-distribution t]
5576 ["Body" message-goto-body t]
5577 ["Signature" message-goto-signature t]))
5579 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5580 "Major mode for editing articles.
5581 This is an extended text-mode.
5583 \\{gnus-article-edit-mode-map}"
5584 (make-local-variable 'gnus-article-edit-done-function)
5585 (make-local-variable 'gnus-prev-winconf)
5586 (set (make-local-variable 'font-lock-defaults)
5587 '(message-font-lock-keywords t))
5588 (set (make-local-variable 'mail-header-separator) "")
5589 (easy-menu-add message-mode-field-menu message-mode-map)
5590 (setq buffer-read-only nil)
5591 (buffer-enable-undo)
5594 (defun gnus-article-edit (&optional force)
5595 "Edit the current article.
5596 This will have permanent effect only in mail groups.
5597 If FORCE is non-nil, allow editing of articles even in read-only
5600 (when (and (not force)
5601 (gnus-group-read-only-p))
5602 (error "The current newsgroup does not support article editing"))
5603 (gnus-article-date-original)
5604 (gnus-article-edit-article
5606 `(lambda (no-highlight)
5608 (gnus-summary-edit-article-done
5609 ,(or (mail-header-references gnus-current-headers) "")
5610 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5612 (defun gnus-article-edit-article (start-func exit-func)
5613 "Start editing the contents of the current article buffer."
5614 (let ((winconf (current-window-configuration)))
5615 (set-buffer gnus-article-buffer)
5616 (gnus-article-edit-mode)
5617 (funcall start-func)
5618 (set-buffer-modified-p nil)
5619 (gnus-configure-windows 'edit-article)
5620 (setq gnus-article-edit-done-function exit-func)
5621 (setq gnus-prev-winconf winconf)
5622 (when gnus-article-edit-article-setup-function
5623 (funcall gnus-article-edit-article-setup-function))
5624 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5626 (defun gnus-article-edit-done (&optional arg)
5627 "Update the article edits and exit."
5629 (let ((func gnus-article-edit-done-function)
5630 (buf (current-buffer))
5631 (start (window-start))
5633 (winconf gnus-prev-winconf))
5634 (remove-hook 'gnus-article-mode-hook
5635 'gnus-article-mime-edit-article-unwind)
5636 (widen) ;; Widen it in case that users narrowed the buffer.
5639 ;; The cache and backlog have to be flushed somewhat.
5640 (when gnus-keep-backlog
5641 (gnus-backlog-remove-article
5642 (car gnus-article-current) (cdr gnus-article-current)))
5643 ;; Flush original article as well.
5645 (when (get-buffer gnus-original-article-buffer)
5646 (set-buffer gnus-original-article-buffer)
5647 (setq gnus-original-article nil)))
5648 (when gnus-use-cache
5649 (gnus-cache-update-article
5650 (car gnus-article-current) (cdr gnus-article-current)))
5651 ;; We remove all text props from the article buffer.
5652 (kill-all-local-variables)
5653 (gnus-set-text-properties (point-min) (point-max) nil)
5655 (set-window-configuration winconf)
5657 (set-window-start (get-buffer-window buf) start)
5658 (set-window-point (get-buffer-window buf) (point))))
5660 (defun gnus-article-edit-exit ()
5661 "Exit the article editing without updating."
5663 (when (or (not (buffer-modified-p))
5664 (yes-or-no-p "Article modified; kill anyway? "))
5665 (let ((curbuf (current-buffer))
5667 (window-start (window-start)))
5669 (if (gnus-buffer-live-p gnus-original-article-buffer)
5670 (insert-buffer-substring gnus-original-article-buffer))
5671 (let ((winconf gnus-prev-winconf))
5673 (set-window-configuration winconf)
5674 ;; Tippy-toe some to make sure that point remains where it was.
5675 (save-current-buffer
5677 (set-window-start (get-buffer-window (current-buffer)) window-start)
5680 (defun gnus-article-edit-full-stops ()
5681 "Interactively repair spacing at end of sentences."
5684 (goto-char (point-min))
5685 (search-forward-regexp "^$" nil t)
5686 (let ((case-fold-search nil))
5687 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5690 ;;; Article editing with MIME-Edit
5693 (defcustom gnus-article-mime-edit-article-setup-hook nil
5694 "Hook run after setting up a MIME editing article buffer."
5695 :group 'gnus-article-various
5698 (defun gnus-article-mime-edit-article-unwind ()
5699 "Unwind `gnus-article-buffer' if article editing was given up."
5700 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5701 (when (featurep 'font-lock)
5702 (setq font-lock-defaults nil)
5703 (font-lock-mode -1))
5704 (when mime-edit-mode-flag
5705 (mime-edit-exit 'nomime 'no-error)
5708 (defun gnus-article-mime-edit-article-setup ()
5709 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5710 after replacing with the original article."
5711 (setq gnus-show-mime t)
5712 (setq gnus-article-edit-done-function
5713 `(lambda (&rest args)
5714 (when mime-edit-mode-flag
5715 (let (mime-edit-insert-user-agent-field)
5718 (goto-char (point-min))
5719 (let (case-fold-search)
5720 (when (re-search-forward
5721 (format "^%s$" (regexp-quote mail-header-separator))
5723 (replace-match "")))
5724 (apply ,gnus-article-edit-done-function args)
5727 (buffer-substring-no-properties (point-min) (point-max))
5728 (set-buffer (get-buffer-create gnus-original-article-buffer))
5730 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5731 (set-buffer gnus-article-buffer)
5732 (gnus-article-prepare-display)))
5733 (substitute-key-definition 'gnus-article-edit-done
5734 'gnus-article-mime-edit-done
5735 gnus-article-edit-mode-map)
5736 (substitute-key-definition 'gnus-article-edit-exit
5737 'gnus-article-mime-edit-exit
5738 gnus-article-edit-mode-map)
5740 (insert-buffer-substring gnus-original-article-buffer)
5741 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5742 (fset 'mime-edit-decode-single-part-in-buffer
5743 (lambda (&rest args)
5744 (if (let ((content-type (car args)))
5745 (and (eq 'message (mime-content-type-primary-type
5747 (eq 'rfc822 (mime-content-type-subtype content-type))))
5748 (setcar (cdr args) 'not-decode-text))
5752 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5753 (when (featurep 'font-lock)
5754 (set (make-local-variable 'font-lock-defaults)
5755 '(message-font-lock-keywords t))
5756 (font-lock-set-defaults)
5757 (turn-on-font-lock))
5758 (set-buffer-modified-p nil)
5759 (delete-other-windows)
5760 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5761 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5763 (defun gnus-article-mime-edit-done (&optional arg)
5764 "Update the article MIME edits and exit."
5766 (when (featurep 'font-lock)
5767 (setq font-lock-defaults nil)
5768 (font-lock-mode -1))
5769 (gnus-article-edit-done arg))
5771 (defun gnus-article-mime-edit-exit ()
5772 "Exit the article MIME editing without updating."
5774 (when (or (not (buffer-modified-p))
5775 (yes-or-no-p "Article modified; kill anyway? "))
5776 (when (featurep 'font-lock)
5777 (setq font-lock-defaults nil)
5778 (font-lock-mode -1))
5779 (when mime-edit-mode-flag
5780 (let (mime-edit-insert-user-agent-field)
5783 (goto-char (point-min))
5784 (let (case-fold-search)
5785 (when (re-search-forward
5786 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5787 (replace-match "")))
5788 (let ((winconf gnus-prev-winconf))
5790 (buffer-substring-no-properties (point-min) (point-max))
5791 (set-buffer (get-buffer-create gnus-original-article-buffer))
5793 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5794 (set-buffer gnus-article-buffer)
5795 (gnus-article-prepare-display)
5796 (set-window-configuration winconf))))
5799 ;;; Article highlights
5802 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5804 ;;; Internal Variables:
5806 (defcustom gnus-button-url-regexp
5807 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5808 "\\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:]]\\)"
5809 "\\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\\)\\)")
5810 "Regular expression that matches URLs."
5811 :group 'gnus-article-buttons
5814 (defcustom gnus-button-man-handler 'man
5815 "Function to use for displaying man pages.
5816 The function must take at least one argument with a string naming the
5818 :type '(choice (function-item :tag "Man" man)
5819 (function-item :tag "Woman" woman)
5820 (function :tag "Other"))
5821 :group 'gnus-article-buttons)
5823 (defcustom gnus-button-prefer-mid-or-mail 'guess
5824 "What to do when the button on a string as \"foo123@bar.com\" is pushed.
5825 Strings like this can be either a message ID or a mail address. If the
5826 variable is set to the symbol `ask', query the user what do do. If it is the
5827 symbol `guess', Gnus will do a guess and query the user what do do if it is
5828 ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume
5829 that the string is a message ID or a mail address, respectivly. See the
5830 variable `gnus-button-guessed-mid-regexp' for details concerning the
5832 ;; FIXME: doc-string could/should be improved.
5833 :group 'gnus-article-buttons
5834 :type '(choice (const ask)
5839 (defcustom gnus-button-guessed-mid-regexp
5841 "^<?\\(slrn\\|Pine\\.\\)"
5842 "\\|\\.fsf@\\|\\.fsf_-_@\\|\\.ln@"
5843 "\\|@4ax\\.com\\|@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de"
5844 "\\|^<?.*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*[0-9].*@")
5845 "Regular expression that matches message IDs and not mail addresses."
5846 ;; TODO: Incorporate more matches from
5847 ;; <URL:http://piology.org/perl/id-or-mail.pl.html>. I.e. translate the
5848 ;; Perl-REs to Elisp-REs.
5849 :group 'gnus-article-buttons
5852 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5853 (let* ((pref gnus-button-prefer-mid-or-mail)
5854 (url-mid (concat "news" ":" mid-or-mail))
5855 (url-mailto (concat "mailto" ":" mid-or-mail)))
5856 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5857 ;; If it looks like a MID (well known readers or servers) use 'mid,
5858 ;; otherwise 'ask the user.
5859 (if (eq pref 'guess)
5860 (if (string-match gnus-button-guessed-mid-regexp mid-or-mail)
5864 (save-window-excursion
5865 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5868 (cond ((eq pref 'mid)
5869 (gnus-message 9 "calling `gnus-button-handle-news' %s" url-mid)
5870 (gnus-button-handle-news url-mid))
5872 (gnus-message 9 "calling `gnus-url-mailto' %s" url-mailto)
5873 (gnus-url-mailto url-mailto)))))
5875 (defun gnus-button-handle-custom (url)
5876 "Follow a Custom URL."
5877 (customize-apropos (gnus-url-unhex-string url)))
5879 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5881 (defun gnus-button-handle-describe-function (url)
5882 "Call describe-function when pushing the corresponding URL button."
5885 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5887 (defun gnus-button-handle-describe-variable (url)
5888 "Call describe-variable when pushing the corresponding URL button."
5891 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5893 ;; FIXME: Is is possible to implement this? Else it should be removed here
5894 ;; and in `gnus-button-alist'.
5895 (defun gnus-button-handle-describe-key (url)
5896 "Call describe-key when pushing the corresponding URL button."
5897 (error "not implemented"))
5899 (defun gnus-button-handle-apropos (url)
5900 "Call apropos when pushing the corresponding URL button."
5901 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5903 (defun gnus-button-handle-apropos-command (url)
5904 "Call apropos when pushing the corresponding URL button."
5906 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5908 (defun gnus-button-handle-apropos-variable (url)
5909 "Call apropos when pushing the corresponding URL button."
5911 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5912 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5914 (defcustom gnus-button-man-level 5
5915 "*Integer that says how many man-related buttons Gnus will show.
5916 The higher the number, the more buttons will appear and the more false
5917 positves are possible. Note that you can set this variable local to
5918 specifific groups. Setting it higher in Unix groups is probably a good idea.
5919 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5920 how to set variables in specific groups."
5921 :group 'gnus-article-buttons
5922 :link '(custom-manual "(gnus)Group Parameters")
5925 (defcustom gnus-button-emacs-level 5
5926 "*Integer that says how many emacs-related buttons Gnus will show.
5927 The higher the number, the more buttons will appear and the more false
5928 positves are possible. Note that you can set this variable local to
5929 specifific groups. Setting it higher in Emacs or Gnus related groups is
5930 probably a good idea.See Info node `(gnus)Group Parameters' and the variable
5931 `gnus-parameters' on how to set variables in specific groups."
5932 :group 'gnus-article-buttons
5933 :link '(custom-manual "(gnus)Group Parameters")
5936 (defcustom gnus-button-mail-level 5
5937 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5938 The higher the number, the more buttons will appear and the more false
5939 positves are possible."
5940 :group 'gnus-article-buttons
5943 (defcustom gnus-button-alist
5944 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5945 0 t gnus-button-handle-news 3)
5946 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5947 gnus-button-handle-news 2)
5948 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5950 gnus-button-fetch-group 4)
5951 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5952 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5953 t gnus-button-message-id 3)
5954 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5955 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5956 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5958 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5959 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5961 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5962 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5963 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5964 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5965 ;; Emacs help commands
5966 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5967 ;; regexp doesn't match arguments containing ` '.
5968 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5969 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5970 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5971 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5972 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5973 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5974 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5975 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5976 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5977 ("\\W\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0
5978 ;; this regexp needs to be fixed!
5979 (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2)
5980 ;; This is how URLs _should_ be embedded in text...
5981 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5983 (gnus-button-url-regexp 0 t browse-url 0)
5985 ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0
5986 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5987 gnus-button-handle-man 1)
5988 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5989 ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0
5990 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5991 gnus-button-handle-man 1)
5992 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv)
5993 ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0
5994 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5995 ;; MID or mail: To avoid too many false positives we don't try to catch
5996 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5997 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5998 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5999 ;; so that non-ambiguous entries (see above) match first.
6000 ("\\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"
6001 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6002 "*Alist of regexps matching buttons in article bodies.
6004 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6005 REGEXP: is the string matching text around the button (can also be lisp
6006 expression evaluating to a string),
6007 BUTTON: is the number of the regexp grouping actually matching the button,
6008 FORM: is a lisp expression which must eval to true for the button to
6010 CALLBACK: is the function to call when the user push this button, and each
6011 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6013 CALLBACK can also be a variable, in that case the value of that
6014 variable it the real callback function."
6015 :group 'gnus-article-buttons
6016 :type '(repeat (list (choice regexp variable)
6017 (integer :tag "Button")
6019 (function :tag "Callback")
6022 (integer :tag "Regexp group")))))
6024 (defcustom gnus-header-button-alist
6025 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6026 0 t gnus-button-message-id 0)
6027 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6028 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6029 0 t gnus-button-mailto 0)
6030 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6031 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6032 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6033 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6034 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6035 gnus-button-message-id 3))
6036 "*Alist of headers and regexps to match buttons in article heads.
6038 This alist is very similar to `gnus-button-alist', except that each
6039 alist has an additional HEADER element first in each entry:
6041 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6043 HEADER is a regexp to match a header. For a fuller explanation, see
6044 `gnus-button-alist'."
6045 :group 'gnus-article-buttons
6046 :group 'gnus-article-headers
6047 :type '(repeat (list (regexp :tag "Header")
6049 (integer :tag "Button")
6051 (function :tag "Callback")
6054 (integer :tag "Regexp group")))))
6056 (defvar gnus-button-regexp nil)
6057 (defvar gnus-button-marker-list nil)
6058 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6060 (defvar gnus-button-last nil)
6061 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6065 (defun gnus-article-push-button (event)
6066 "Check text under the mouse pointer for a callback function.
6067 If the text under the mouse pointer has a `gnus-callback' property,
6068 call it with the value of the `gnus-data' text property."
6070 (set-buffer (window-buffer (posn-window (event-start event))))
6071 (let* ((pos (posn-point (event-start event)))
6072 (data (get-text-property pos 'gnus-data))
6073 (fun (get-text-property pos 'gnus-callback)))
6076 (funcall fun data))))
6078 (defun gnus-article-press-button ()
6079 "Check text at point for a callback function.
6080 If the text at point has a `gnus-callback' property,
6081 call it with the value of the `gnus-data' text property."
6083 (let* ((data (get-text-property (point) 'gnus-data))
6084 (fun (get-text-property (point) 'gnus-callback)))
6086 (funcall fun data))))
6088 (defun gnus-article-prev-button (n)
6089 "Move point to N buttons backward.
6090 If N is negative, move forward instead."
6092 (gnus-article-next-button (- n)))
6094 (defun gnus-article-next-button (n)
6095 "Move point to N buttons forward.
6096 If N is negative, move backward instead."
6098 (let ((function (if (< n 0) 'previous-single-property-change
6099 'next-single-property-change))
6100 (inhibit-point-motion-hooks t)
6102 (limit (if (< n 0) (point-min) (point-max))))
6104 (while (and (not (= limit (point)))
6106 ;; Skip past the current button.
6107 (when (get-text-property (point) 'gnus-callback)
6108 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6109 ;; Go to the next (or previous) button.
6110 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6111 ;; Put point at the start of the button.
6112 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6113 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6114 ;; Skip past intangible buttons.
6115 (when (get-text-property (point) 'intangible)
6119 (gnus-message 5 "No more buttons"))
6122 (defun gnus-article-highlight (&optional force)
6123 "Highlight current article.
6124 This function calls `gnus-article-highlight-headers',
6125 `gnus-article-highlight-citation',
6126 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6127 do the highlighting. See the documentation for those functions."
6128 (interactive (list 'force))
6129 (gnus-article-highlight-headers)
6130 (gnus-article-highlight-citation force)
6131 (gnus-article-highlight-signature)
6132 (gnus-article-add-buttons force)
6133 (gnus-article-add-buttons-to-head))
6135 (defun gnus-article-highlight-some (&optional force)
6136 "Highlight current article.
6137 This function calls `gnus-article-highlight-headers',
6138 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6139 do the highlighting. See the documentation for those functions."
6140 (interactive (list 'force))
6141 (gnus-article-highlight-headers)
6142 (gnus-article-highlight-signature)
6143 (gnus-article-add-buttons))
6145 (defun gnus-article-highlight-headers ()
6146 "Highlight article headers as specified by `gnus-header-face-alist'."
6149 (set-buffer gnus-article-buffer)
6151 (let ((alist gnus-header-face-alist)
6152 (buffer-read-only nil)
6153 (case-fold-search t)
6154 (inhibit-point-motion-hooks t)
6155 entry regexp header-face field-face from hpoints fpoints)
6156 (article-narrow-to-head)
6157 (while (setq entry (pop alist))
6158 (goto-char (point-min))
6159 (setq regexp (concat "^\\("
6160 (if (string-equal "" (nth 0 entry))
6164 header-face (nth 1 entry)
6165 field-face (nth 2 entry))
6166 (while (and (re-search-forward regexp nil t)
6170 (unless (search-forward ":" nil t)
6172 (when (and header-face
6173 (not (memq (point) hpoints)))
6174 (push (point) hpoints)
6175 (gnus-put-text-property from (point) 'face header-face))
6176 (when (and field-face
6177 (not (memq (setq from (point)) fpoints)))
6179 (if (re-search-forward "^[^ \t]" nil t)
6181 (goto-char (point-max)))
6182 (gnus-put-text-property from (point) 'face field-face))))))))
6184 (defun gnus-article-highlight-signature ()
6185 "Highlight the signature in an article.
6186 It does this by highlighting everything after
6187 `gnus-signature-separator' using `gnus-signature-face'."
6189 (when gnus-signature-face
6191 (set-buffer gnus-article-buffer)
6192 (let ((buffer-read-only nil)
6193 (inhibit-point-motion-hooks t))
6195 (when (gnus-article-narrow-to-signature)
6196 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6197 'face gnus-signature-face)))))))
6199 (defun gnus-article-buttonize-signature ()
6200 "Add button to the signature."
6203 (set-buffer gnus-article-buffer)
6204 (let ((buffer-read-only nil)
6205 (inhibit-point-motion-hooks t))
6206 (when (gnus-article-search-signature)
6207 (gnus-article-add-button (match-beginning 0) (match-end 0)
6208 'gnus-signature-toggle
6209 (set-marker (make-marker)
6210 (1+ (match-end 0))))))))
6212 (defun gnus-button-in-region-p (b e prop)
6213 "Say whether PROP exists in the region."
6214 (text-property-not-all b e prop nil))
6216 (defun gnus-article-add-buttons (&optional force)
6217 "Find external references in the article and make buttons of them.
6218 \"External references\" are things like Message-IDs and URLs, as
6219 specified by `gnus-button-alist'."
6220 (interactive (list 'force))
6222 (set-buffer gnus-article-buffer)
6223 (let ((buffer-read-only nil)
6224 (inhibit-point-motion-hooks t)
6225 (case-fold-search t)
6226 (alist gnus-button-alist)
6228 ;; Remove all old markers.
6229 (let (marker entry new-list)
6230 (while (setq marker (pop gnus-button-marker-list))
6231 (if (or (< marker (point-min)) (>= marker (point-max)))
6232 (push marker new-list)
6234 (when (setq entry (gnus-button-entry))
6235 (put-text-property (match-beginning (nth 1 entry))
6236 (match-end (nth 1 entry))
6237 'gnus-callback nil))
6238 (set-marker marker nil)))
6239 (setq gnus-button-marker-list new-list))
6240 ;; We skip the headers.
6243 (while (setq entry (pop alist))
6244 (setq regexp (eval (car entry)))
6246 (while (re-search-forward regexp nil t)
6247 (let* ((start (and entry (match-beginning (nth 1 entry))))
6248 (end (and entry (match-end (nth 1 entry))))
6249 (from (match-beginning 0)))
6250 (when (and (or (eq t (nth 2 entry))
6251 (eval (nth 2 entry)))
6252 (not (gnus-button-in-region-p
6253 start end 'gnus-callback)))
6254 ;; That optional form returned non-nil, so we add the
6256 (gnus-article-add-button
6257 start end 'gnus-button-push
6258 (car (push (set-marker (make-marker) from)
6259 gnus-button-marker-list))))))))))
6261 ;; Add buttons to the head of an article.
6262 (defun gnus-article-add-buttons-to-head ()
6263 "Add buttons to the head of the article."
6266 (set-buffer gnus-article-buffer)
6268 (let ((buffer-read-only nil)
6269 (inhibit-point-motion-hooks t)
6270 (case-fold-search t)
6271 (alist gnus-header-button-alist)
6273 (article-narrow-to-head)
6275 ;; Each alist entry.
6276 (setq entry (car alist)
6278 (goto-char (point-min))
6279 (while (re-search-forward (car entry) nil t)
6280 ;; Each header matching the entry.
6281 (setq beg (match-beginning 0))
6282 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6283 (match-beginning 0))
6286 (while (re-search-forward (eval (nth 1 entry)) end t)
6287 ;; Each match within a header.
6288 (let* ((entry (cdr entry))
6289 (start (match-beginning (nth 1 entry)))
6290 (end (match-end (nth 1 entry)))
6291 (form (nth 2 entry)))
6292 (goto-char (match-end 0))
6294 (gnus-article-add-button
6295 start end (nth 3 entry)
6296 (buffer-substring (match-beginning (nth 4 entry))
6297 (match-end (nth 4 entry)))))))
6298 (goto-char end)))))))
6300 ;;; External functions:
6302 (defun gnus-article-add-button (from to fun &optional data)
6303 "Create a button between FROM and TO with callback FUN and data DATA."
6304 (when gnus-article-button-face
6305 (gnus-overlay-put (gnus-make-overlay from to)
6306 'face gnus-article-button-face))
6307 (gnus-add-text-properties
6309 (nconc (and gnus-article-mouse-face
6310 (list gnus-mouse-face-prop gnus-article-mouse-face))
6311 (list 'gnus-callback fun)
6312 (and data (list 'gnus-data data))))
6313 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6314 ;; Quote `:button-keymap' for Mule 2.3
6315 ;; but it won't work.
6316 ':button-keymap gnus-widget-button-keymap))
6318 ;;; Internal functions:
6320 (defun gnus-article-set-globals ()
6322 (set-buffer gnus-summary-buffer)
6323 (gnus-set-global-variables)))
6325 (defun gnus-signature-toggle (end)
6327 (set-buffer gnus-article-buffer)
6328 (let ((buffer-read-only nil)
6329 (inhibit-point-motion-hooks t)
6330 (limit (next-single-property-change end 'mime-view-entity
6332 (if (text-property-any end limit 'article-type 'signature)
6334 (gnus-delete-wash-type 'signature)
6335 (gnus-remove-text-properties-when
6336 'article-type 'signature end limit
6337 (cons 'article-type (cons 'signature
6338 gnus-hidden-properties))))
6339 (gnus-add-wash-type 'signature)
6340 (gnus-add-text-properties-when
6341 'article-type nil end limit
6342 (cons 'article-type (cons 'signature
6343 gnus-hidden-properties)))))
6344 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6345 (gnus-set-mode-line 'article))))
6347 (defun gnus-button-entry ()
6348 ;; Return the first entry in `gnus-button-alist' matching this place.
6349 (let ((alist gnus-button-alist)
6352 (setq entry (pop alist))
6353 (if (looking-at (eval (car entry)))
6358 (defun gnus-button-push (marker)
6359 ;; Push button starting at MARKER.
6362 (let* ((entry (gnus-button-entry))
6363 (inhibit-point-motion-hooks t)
6365 (args (mapcar (lambda (group)
6366 (let ((string (match-string group)))
6367 (gnus-set-text-properties
6368 0 (length string) nil string)
6375 (fboundp (symbol-value fun)))
6376 (apply (symbol-value fun) args))
6378 (gnus-message 1 "You must define `%S' to use this button"
6379 (cons fun args)))))))
6381 (defun gnus-parse-news-url (url)
6382 (let (scheme server group message-id articles)
6385 (goto-char (point-min))
6386 (when (looking-at "\\([A-Za-z]+\\):")
6387 (setq scheme (match-string 1))
6388 (goto-char (match-end 0)))
6389 (when (looking-at "//\\([^/]+\\)/")
6390 (setq server (match-string 1))
6391 (goto-char (match-end 0)))
6394 ((looking-at "\\(.*@.*\\)")
6395 (setq message-id (match-string 1)))
6396 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6397 (setq group (match-string 1)
6398 articles (split-string (match-string 2) "-")))
6399 ((looking-at "\\([^/]+\\)/?")
6400 (setq group (match-string 1)))
6402 (error "Unknown news URL syntax"))))
6403 (list scheme server group message-id articles)))
6405 (defun gnus-button-handle-news (url)
6407 (destructuring-bind (scheme server group message-id articles)
6408 (gnus-parse-news-url url)
6412 (set-buffer gnus-summary-buffer)
6414 (let ((gnus-refer-article-method (list (list 'nntp server))))
6415 (gnus-summary-refer-article message-id))
6416 (gnus-summary-refer-article message-id))))
6418 (gnus-button-fetch-group url)))))
6420 (defun gnus-button-handle-man (url)
6422 (funcall gnus-button-man-handler url))
6424 (defun gnus-button-handle-info (url)
6425 "Fetch an info URL."
6427 "^\\([^:/]+\\)?/\\(.*\\)"
6429 (gnus-info-find-node
6430 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6433 (gnus-url-unhex-string (match-string 2 url))))
6434 (error "Can't parse %s" url)))
6436 (defun gnus-button-message-id (message-id)
6439 (set-buffer gnus-summary-buffer)
6440 (gnus-summary-refer-article message-id)))
6442 (defun gnus-button-fetch-group (address)
6443 "Fetch GROUP specified by ADDRESS."
6444 (if (not (string-match "[:/]" address))
6445 ;; This is just a simple group url.
6446 (gnus-group-read-ephemeral-group address gnus-select-method)
6449 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6451 (error "Can't parse %s" address)
6452 (gnus-group-read-ephemeral-group
6453 (match-string 4 address)
6454 `(nntp ,(match-string 1 address)
6455 (nntp-address ,(match-string 1 address))
6456 (nntp-port-number ,(if (match-end 3)
6457 (match-string 3 address)
6460 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6462 (defun gnus-url-parse-query-string (query &optional downcase)
6463 (let (retval pairs cur key val)
6464 (setq pairs (split-string query "&"))
6466 (setq cur (car pairs)
6468 (if (not (string-match "=" cur))
6470 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6471 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6473 (setq key (downcase key)))
6474 (setq cur (assoc key retval))
6476 (setcdr cur (cons val (cdr cur)))
6477 (setq retval (cons (list key val) retval)))))
6480 (defun gnus-url-mailto (url)
6481 ;; Send mail to someone
6482 (when (string-match "mailto:/*\\(.*\\)" url)
6483 (setq url (substring url (match-beginning 1) nil)))
6484 (let (to args subject func)
6485 (if (string-match (regexp-quote "?") url)
6486 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6487 args (gnus-url-parse-query-string
6488 (substring url (match-end 0) nil) t))
6489 (setq to (gnus-url-unhex-string url)))
6490 (setq args (cons (list "to" to) args)
6491 subject (cdr-safe (assoc "subject" args)))
6494 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6497 (message-position-on-field (caar args)))
6498 (insert (mapconcat 'identity (cdar args) ", "))
6499 (setq args (cdr args)))
6502 (message-goto-subject))))
6504 (defun gnus-button-embedded-url (address)
6505 "Activate ADDRESS with `browse-url'."
6506 (browse-url (gnus-strip-whitespace address)))
6508 ;;; Next/prev buttons in the article buffer.
6510 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6511 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6513 (defvar gnus-prev-page-map
6514 (let ((map (make-sparse-keymap)))
6515 (unless (>= emacs-major-version 21)
6516 ;; XEmacs doesn't care.
6517 (set-keymap-parent map gnus-article-mode-map))
6518 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6519 (define-key map "\r" 'gnus-button-prev-page)
6522 (defun gnus-insert-prev-page-button ()
6524 (buffer-read-only nil)
6525 (situation (get-text-property (point-min) 'mime-view-situation)))
6527 gnus-prev-page-line-format nil
6528 `(,@(gnus-local-map-property gnus-prev-page-map)
6530 gnus-callback gnus-article-button-prev-page
6531 article-type annotation
6532 mime-view-situation ,situation))
6533 (widget-convert-button
6535 :action 'gnus-button-prev-page
6536 :button-keymap gnus-prev-page-map)))
6538 (defvar gnus-next-page-map
6539 (let ((map (make-sparse-keymap)))
6540 (unless (>= emacs-major-version 21)
6541 ;; XEmacs doesn't care.
6542 (set-keymap-parent map gnus-article-mode-map))
6543 (define-key map gnus-mouse-2 'gnus-button-next-page)
6544 (define-key map "\r" 'gnus-button-next-page)
6547 (defun gnus-button-next-page (&optional args more-args)
6548 "Go to the next page."
6550 (let ((win (selected-window)))
6551 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6552 (gnus-article-next-page)
6553 (select-window win)))
6555 (defun gnus-button-prev-page (&optional args more-args)
6556 "Go to the prev page."
6558 (let ((win (selected-window)))
6559 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6560 (gnus-article-prev-page)
6561 (select-window win)))
6563 (defun gnus-insert-next-page-button ()
6565 (buffer-read-only nil)
6566 (situation (get-text-property (point-min) 'mime-view-situation)))
6567 (gnus-eval-format gnus-next-page-line-format nil
6568 `(,@(gnus-local-map-property gnus-next-page-map)
6570 gnus-callback gnus-article-button-next-page
6571 article-type annotation
6572 mime-view-situation ,situation))
6573 (widget-convert-button
6575 :action 'gnus-button-next-page
6576 :button-keymap gnus-next-page-map)))
6578 (defun gnus-article-button-next-page (arg)
6579 "Go to the next page."
6581 (let ((win (selected-window)))
6582 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6583 (gnus-article-next-page)
6584 (select-window win)))
6586 (defun gnus-article-button-prev-page (arg)
6587 "Go to the prev page."
6589 (let ((win (selected-window)))
6590 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6591 (gnus-article-prev-page)
6592 (select-window win)))
6594 (defvar gnus-decode-header-methods
6595 '(mail-decode-encoded-word-region)
6596 "List of methods used to decode headers.
6598 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6599 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6600 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6601 whose names match REGEXP.
6604 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6605 mail-decode-encoded-word-region
6606 (\"chinese\" . rfc1843-decode-region))
6609 (defvar gnus-decode-header-methods-cache nil)
6611 (defun gnus-multi-decode-header (start end)
6612 "Apply the functions from `gnus-encoded-word-methods' that match."
6613 (unless (and gnus-decode-header-methods-cache
6614 (eq gnus-newsgroup-name
6615 (car gnus-decode-header-methods-cache)))
6616 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6619 (nconc gnus-decode-header-methods-cache (list x))
6620 (if (and gnus-newsgroup-name
6621 (string-match (car x) gnus-newsgroup-name))
6622 (nconc gnus-decode-header-methods-cache
6624 gnus-decode-header-methods))
6625 (let ((xlist gnus-decode-header-methods-cache))
6628 (narrow-to-region start end)
6630 (funcall (pop xlist) (point-min) (point-max))))))
6633 ;;; Treatment top-level handling.
6636 (defun gnus-treat-article (condition &optional part-number total-parts type)
6637 (let ((length (- (point-max) (point-min)))
6638 (alist gnus-treatment-function-alist)
6639 (article-goto-body-goes-to-point-min-p t)
6643 (let ((list gnus-article-treat-types))
6645 (when (string-match (pop list) type)
6646 (throw 'found t)))))))
6647 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6648 (entity (static-unless (featurep 'xemacs)
6649 (when (eq 'head condition)
6650 (get-text-property (point-min) 'mime-view-entity))))
6651 val elem buttonized)
6652 (gnus-run-hooks 'gnus-part-display-hook)
6653 (unless gnus-inhibit-treatment
6654 (while (setq elem (pop alist))
6657 (if (gnus-buffer-live-p gnus-summary-buffer)
6658 (set-buffer gnus-summary-buffer))
6659 (symbol-value (car elem))))
6660 (when (and (or (consp val)
6662 (gnus-treat-predicate val)
6663 (or (not (get (car elem) 'highlight))
6665 (when (and (not buttonized)
6667 '(gnus-treat-hide-signature
6668 gnus-treat-highlight-signature)))
6669 (gnus-article-buttonize-signature)
6670 (setq buttonized t))
6672 (funcall (cadr elem)))))
6673 ;; FSF Emacsen does not inherit the existing text properties
6674 ;; in the new text, so we should do it for `mime-view-entity'.
6675 (static-unless (featurep 'xemacs)
6677 (put-text-property (point-min) (point-max)
6678 'mime-view-entity entity))))))
6680 ;; Dynamic variables.
6682 (defvar part-number)
6683 (defvar total-parts)
6688 (defun gnus-treat-predicate (val)
6693 (stringp (car val)))
6694 (apply 'gnus-or (mapcar `(lambda (s)
6695 (string-match s ,(or gnus-newsgroup-name "")))
6698 (let ((pred (pop val)))
6701 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6703 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6705 (not (gnus-treat-predicate (car val))))
6707 (equal (car val) type))
6709 (error "%S is not a valid predicate" pred)))))
6719 (eq part-number total-parts))
6723 (error "%S is not a valid value" val))))
6725 (defun gnus-article-encrypt-body (protocol &optional n)
6726 "Encrypt the article body."
6729 (or gnus-article-encrypt-protocol
6730 (completing-read "Encrypt protocol: "
6731 gnus-article-encrypt-protocol-alist
6733 current-prefix-arg))
6734 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6736 (error (format "Can't find the encrypt protocol %s" protocol)))
6737 (if (equal gnus-newsgroup-name "nndraft:drafts")
6738 (error "Can't encrypt the article in group nndraft:drafts"))
6739 (if (equal gnus-newsgroup-name "nndraft:queue")
6740 (error "Don't encrypt the article in group nndraft:queue"))
6741 (gnus-summary-iterate n
6743 (set-buffer gnus-summary-buffer)
6744 (let ((mail-parse-charset gnus-newsgroup-charset)
6745 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6746 (summary-buffer gnus-summary-buffer)
6748 (gnus-set-global-variables)
6749 (when (gnus-group-read-only-p)
6750 (error "The current newsgroup does not support article encrypt"))
6751 (gnus-summary-show-article t)
6753 (or (mail-header-references gnus-current-headers) ""))
6754 (set-buffer gnus-article-buffer)
6755 (let* ((buffer-read-only nil)
6757 (mapcar (lambda (field)
6758 (and (save-restriction
6759 (message-narrow-to-head)
6760 (goto-char (point-min))
6761 (search-forward field nil t))
6763 (message-narrow-to-field)
6764 (buffer-substring (point-min) (point-max))
6765 (delete-region (point-min) (point-max))
6767 '("Content-Type:" "Content-Transfer-Encoding:"
6768 "Content-Disposition:"))))
6769 (message-narrow-to-head)
6770 (message-remove-header "MIME-Version")
6771 (goto-char (point-max))
6772 (setq point (point))
6773 (insert (apply 'concat headers))
6775 (narrow-to-region point (point-max))
6776 (let ((message-options message-options))
6777 (message-options-set 'message-sender user-mail-address)
6778 (message-options-set 'message-recipients user-mail-address)
6779 (message-options-set 'message-sign-encrypt 'not)
6781 (goto-char (point-min))
6782 (insert "MIME-Version: 1.0\n")
6784 (gnus-summary-edit-article-done
6785 references nil summary-buffer t))
6786 (when gnus-keep-backlog
6787 (gnus-backlog-remove-article
6788 (car gnus-article-current) (cdr gnus-article-current)))
6790 (when (get-buffer gnus-original-article-buffer)
6791 (set-buffer gnus-original-article-buffer)
6792 (setq gnus-original-article nil)))
6793 (when gnus-use-cache
6794 (gnus-cache-update-article
6795 (car gnus-article-current) (cdr gnus-article-current))))))))
6797 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6798 "The following specs can be used:
6799 %t The security MIME type
6802 %D Details if button is pressed")
6804 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6805 "The following specs can be used:
6806 %t The security MIME type
6809 %D Details if button is pressed")
6811 (defvar gnus-mime-security-button-line-format-alist
6812 '((?t gnus-tmp-type ?s)
6813 (?i gnus-tmp-info ?s)
6814 (?d gnus-tmp-details ?s)
6815 (?D gnus-tmp-pressed-details ?s)))
6817 (defvar gnus-mime-security-button-map
6818 (let ((map (make-sparse-keymap)))
6819 (unless (>= (string-to-number emacs-version) 21)
6820 (set-keymap-parent map gnus-article-mode-map))
6821 (define-key map gnus-mouse-2 'gnus-article-push-button)
6822 (define-key map "\r" 'gnus-article-press-button)
6825 (defvar gnus-mime-security-details-buffer nil)
6827 (defvar gnus-mime-security-button-pressed nil)
6829 (defvar gnus-mime-security-show-details-inline t
6830 "If non-nil, show details in the article buffer.")
6832 (defun gnus-mime-security-verify-or-decrypt (handle)
6833 (mm-remove-parts (cdr handle))
6834 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6835 point buffer-read-only)
6837 (goto-char (car region)))
6839 (narrow-to-region (point) (point))
6840 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6841 (let* ((mm-verify-option 'known)
6842 (mm-decrypt-option 'known)
6843 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6844 (unless (eq nparts (cdr handle))
6845 (mm-destroy-parts (cdr handle))
6846 (setcdr handle nparts))))
6847 (setq point (point))
6848 (gnus-mime-display-security handle)
6849 (goto-char (point-max)))
6851 (delete-region (point) (cdr region))
6852 (set-marker (car region) nil)
6853 (set-marker (cdr region) nil))
6856 (defun gnus-mime-security-show-details (handle)
6857 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6859 (if gnus-mime-security-show-details-inline
6860 (let ((gnus-mime-security-button-pressed t)
6861 (gnus-mime-security-button-line-format
6862 (get-text-property (point) 'gnus-line-format))
6865 (while (eq (get-text-property (point) 'gnus-line-format)
6866 gnus-mime-security-button-line-format)
6870 (narrow-to-region (point) (point))
6871 (gnus-insert-mime-security-button handle))
6872 (delete-region (point)
6873 (or (text-property-not-all
6876 gnus-mime-security-button-line-format)
6878 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6879 (with-current-buffer gnus-mime-security-details-buffer
6882 (setq gnus-mime-security-details-buffer
6883 (gnus-get-buffer-create "*MIME Security Details*")))
6884 (with-current-buffer gnus-mime-security-details-buffer
6886 (goto-char (point-min)))
6887 (pop-to-buffer gnus-mime-security-details-buffer))
6888 (gnus-message 5 "No details."))))
6890 (defun gnus-mime-security-press-button (handle)
6891 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6892 (gnus-mime-security-show-details handle)
6893 (gnus-mime-security-verify-or-decrypt handle)))
6895 (defun gnus-insert-mime-security-button (handle &optional displayed)
6896 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6899 (or (nth 2 (assoc protocol mm-verify-function-alist))
6900 (nth 2 (assoc protocol mm-decrypt-function-alist))
6902 (if (equal (car handle) "multipart/signed")
6903 " Signed" " Encrypted")
6906 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6909 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6910 gnus-tmp-pressed-details
6912 (setq gnus-tmp-details
6913 (if gnus-tmp-details
6914 (concat "\n" gnus-tmp-details) ""))
6915 (setq gnus-tmp-pressed-details
6916 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6921 gnus-mime-security-button-line-format
6922 gnus-mime-security-button-line-format-alist
6923 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6924 gnus-callback gnus-mime-security-press-button
6925 gnus-line-format ,gnus-mime-security-button-line-format
6926 article-type annotation
6929 (widget-convert-button
6932 :action 'gnus-widget-press-button
6933 :button-keymap gnus-mime-security-button-map
6935 (lambda (widget/window &optional overlay pos)
6936 ;; Needed to properly clear the message due to a bug in
6937 ;; wid-edit (XEmacs only).
6938 (if (boundp 'help-echo-owns-message)
6939 (setq help-echo-owns-message t))
6942 (aref gnus-mouse-2 0))))))
6944 (defun gnus-mime-display-security (handle)
6946 (narrow-to-region (point) (point))
6947 (unless (gnus-unbuttonized-mime-type-p (car handle))
6948 (gnus-insert-mime-security-button handle))
6949 (gnus-mime-display-mixed (cdr handle))
6952 (unless (gnus-unbuttonized-mime-type-p (car handle))
6953 (let ((gnus-mime-security-button-line-format
6954 gnus-mime-security-button-end-line-format))
6955 (gnus-insert-mime-security-button handle)))
6956 (mm-set-handle-multipart-parameter
6958 (cons (set-marker (make-marker) (point-min))
6959 (set-marker (make-marker) (point-max))))))
6965 (defun gnus-article-header-presentation-method (entity situation)
6966 (mime-insert-header entity)
6967 (article-decode-group-name))
6969 (set-alist 'mime-header-presentation-method-alist
6970 'gnus-original-article-mode
6971 #'gnus-article-header-presentation-method)
6973 (defun gnus-mime-preview-quitting-method ()
6974 (mime-preview-kill-buffer)
6975 (delete-other-windows)
6976 (gnus-article-show-summary)
6977 (gnus-summary-select-article gnus-show-all-headers t))
6979 (set-alist 'mime-preview-quitting-method-alist
6980 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6982 (set-alist 'mime-preview-following-method-alist
6983 'gnus-original-article-mode #'gnus-following-method)
6985 (set-alist 'mime-preview-over-to-previous-method-alist
6986 'gnus-original-article-mode
6988 (if (> (point-min) 1)
6989 (gnus-article-prev-page)
6990 (gnus-article-read-summary-keys
6991 nil (gnus-character-to-event ?P)))))
6993 (set-alist 'mime-preview-over-to-next-method-alist
6994 'gnus-original-article-mode'
6996 (if (< (point-max) (buffer-size))
6997 (gnus-article-next-page)
6998 (gnus-article-read-summary-keys
6999 nil (gnus-character-to-event ?N)))))
7009 (run-hooks 'gnus-art-load-hook)
7011 ;;; gnus-art.el ends here