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.
53 (autoload 'gnus-msg-mail "gnus-msg" nil t)
54 (autoload 'gnus-button-mailto "gnus-msg")
55 (autoload 'gnus-button-reply "gnus-msg" nil t)
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)The Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
119 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
120 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
121 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
122 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
123 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
124 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
125 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
126 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
127 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
128 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
129 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
130 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
131 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
132 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
133 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
134 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
135 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
136 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
137 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
138 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
139 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
140 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
141 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
142 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
143 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
144 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
145 "^X-Received:" "^Content-length:" "X-precedence:"
146 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
147 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
148 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
149 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
150 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
151 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
152 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
153 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
154 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
156 "*All headers that start with this regexp will be hidden.
157 This variable can also be a list of regexps of headers to be ignored.
158 If `gnus-visible-headers' is non-nil, this variable will be ignored."
159 :type '(choice :custom-show nil
162 :group 'gnus-article-hiding)
164 (defcustom gnus-visible-headers
165 "^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:"
166 "*All headers that do not match this regexp will be hidden.
167 This variable can also be a list of regexp of headers to remain visible.
168 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
169 :type '(repeat :value-to-internal (lambda (widget value)
170 (custom-split-regexp-maybe value))
171 :match (lambda (widget value)
173 (widget-editable-list-match widget value)))
175 :group 'gnus-article-hiding)
177 (defcustom gnus-sorted-header-list
178 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
179 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
180 "*This variable is a list of regular expressions.
181 If it is non-nil, headers that match the regular expressions will
182 be placed first in the article buffer in the sequence specified by
184 :type '(repeat regexp)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
188 "Headers that are only to be displayed if they have interesting data.
189 Possible values in this list are:
191 'empty Headers with no content.
192 'newsgroups Newsgroup identical to Gnus group.
193 'to-address To identical to To-address.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "Followup-to identical to Newsgroups." followup-to)
203 (const :tag "Reply-to identical to From." reply-to)
204 (const :tag "Date less than four days old." date)
205 (const :tag "To and/or Cc longer than 1024 characters." long-to)
206 (const :tag "Multiple To and/or Cc headers." many-to))
207 :group 'gnus-article-hiding)
209 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
210 "Regexp matching signature separator.
211 This can also be a list of regexps. In that case, it will be checked
212 from head to tail looking for a separator. Searches will be done from
213 the end of the buffer."
214 :type '(repeat string)
215 :group 'gnus-article-signature)
217 (defcustom gnus-signature-limit nil
218 "Provide a limit to what is considered a signature.
219 If it is a number, no signature may not be longer (in characters) than
220 that number. If it is a floating point number, no signature may be
221 longer (in lines) than that number. If it is a function, the function
222 will be called without any parameters, and if it returns nil, there is
223 no signature in the buffer. If it is a string, it will be used as a
224 regexp. If it matches, the text in question is not a signature."
225 :type '(choice (integer :value 200)
227 (function :value fun)
228 (regexp :value ".*"))
229 :group 'gnus-article-signature)
231 (defcustom gnus-hidden-properties '(invisible t intangible t)
232 "Property list to use for hiding text."
234 :group 'gnus-article-hiding)
236 ;; Fixme: This isn't the right thing for mixed graphical and and
237 ;; non-graphical frames in a session.
238 (defcustom gnus-article-x-face-command
241 (if (or (gnus-image-type-available-p 'xface)
242 (gnus-image-type-available-p 'pbm))
243 'gnus-display-x-face-in-from
244 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
245 ((and (fboundp 'image-type-available-p)
246 (module-installed-p 'x-face-e21))
247 'x-face-decode-message-header)
248 ((gnus-image-type-available-p 'pbm)
249 'gnus-display-x-face-in-from)
251 (module-installed-p 'x-face-mule))
252 'x-face-mule-gnus-article-display-x-face)
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
256 "*String or function to be executed to display an X-Face header.
257 If it is a string, the command will be executed in a sub-shell
258 asynchronously. The compressed face will be piped to this command."
260 ,@(let (x-face-e21 x-face-mule)
261 (if (featurep 'xemacs)
263 (setq x-face-e21 (module-installed-p 'x-face-e21)
264 x-face-mule (module-installed-p 'x-face-mule)))
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 '(function-item gnus-display-x-face-in-from))
272 (fboundp 'image-type-available-p))
274 :tag "x-face-decode-message-header (x-face-e21)"
275 x-face-decode-message-header))
278 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-emphasis-alist
319 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
324 ("_/" "/_" underline-italic)
325 ("_\\*" "\\*_" underline-bold)
326 ("\\*/" "/\\*" bold-italic)
327 ("_\\*/" "/\\*_" underline-bold-italic))))
331 (format format (car spec) (car (cdr spec)))
332 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
334 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
335 2 3 gnus-emphasis-underline)))
336 "*Alist that says how to fontify certain phrases.
337 Each item looks like this:
339 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
341 The first element is a regular expression to be matched. The second
342 is a number that says what regular expression grouping used to find
343 the entire emphasized word. The third is a number that says what
344 regexp grouping should be displayed and highlighted. The fourth
345 is the face used for highlighting."
346 :type '(repeat (list :value ("" 0 0 default)
348 (integer :tag "Match group")
349 (integer :tag "Emphasize group")
351 :group 'gnus-article-emphasis)
353 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
354 "A regexp to describe whitespace which should not be emphasized.
355 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
356 The former avoids underlining of leading and trailing whitespace,
357 and the latter avoids underlining any whitespace at all."
359 :group 'gnus-article-emphasis
362 (defface gnus-emphasis-bold '((t (:bold t)))
363 "Face used for displaying strong emphasized text (*word*)."
364 :group 'gnus-article-emphasis)
366 (defface gnus-emphasis-italic '((t (:italic t)))
367 "Face used for displaying italic emphasized text (/word/)."
368 :group 'gnus-article-emphasis)
370 (defface gnus-emphasis-underline '((t (:underline t)))
371 "Face used for displaying underlined emphasized text (_word_)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
375 "Face used for displaying underlined bold emphasized text (_*word*_)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
379 "Face used for displaying underlined italic emphasized text (_/word/_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
383 "Face used for displaying bold italic emphasized text (/*word*/)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-bold-italic
387 '((t (:bold t :italic t :underline t)))
388 "Face used for displaying underlined bold italic emphasized text.
389 Esample: (_/*word*/_)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-highlight-words
393 '((t (:background "black" :foreground "yellow")))
394 "Face used for displaying highlighted words."
395 :group 'gnus-article-emphasis)
397 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
398 "Format for display of Date headers in article bodies.
399 See `format-time-string' for the possible values.
401 The variable can also be function, which should return a complete Date
402 header. The function is called with one argument, the time, which can
403 be fed to `format-time-string'."
404 :type '(choice string symbol)
405 :link '(custom-manual "(gnus)Article Date")
406 :group 'gnus-article-washing)
409 (autoload 'mail-extract-address-components "mail-extr"))
411 (defcustom gnus-save-all-headers t
412 "*If non-nil, don't remove any headers before saving."
413 :group 'gnus-article-saving
416 (defcustom gnus-prompt-before-saving 'always
417 "*This variable says how much prompting is to be done when saving articles.
418 If it is nil, no prompting will be done, and the articles will be
419 saved to the default files. If this variable is `always', each and
420 every article that is saved will be preceded by a prompt, even when
421 saving large batches of articles. If this variable is neither nil not
422 `always', there the user will be prompted once for a file name for
423 each invocation of the saving commands."
424 :group 'gnus-article-saving
425 :type '(choice (item always)
426 (item :tag "never" nil)
427 (sexp :tag "once" :format "%t\n" :value t)))
429 (defcustom gnus-saved-headers gnus-visible-headers
430 "Headers to keep if `gnus-save-all-headers' is nil.
431 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
432 If that variable is nil, however, all headers that match this regexp
433 will be kept while the rest will be deleted before saving."
434 :group 'gnus-article-saving
437 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
438 "A function to save articles in your favourite format.
439 The function must be interactively callable (in other words, it must
440 be an Emacs command).
442 Gnus provides the following functions:
444 * gnus-summary-save-in-rmail (Rmail format)
445 * gnus-summary-save-in-mail (Unix mail format)
446 * gnus-summary-save-in-folder (MH folder)
447 * gnus-summary-save-in-file (article format)
448 * gnus-summary-save-body-in-file (article body)
449 * gnus-summary-save-in-vm (use VM's folder format)
450 * gnus-summary-write-to-file (article format -- overwrite)."
451 :group 'gnus-article-saving
452 :type '(radio (function-item gnus-summary-save-in-rmail)
453 (function-item gnus-summary-save-in-mail)
454 (function-item gnus-summary-save-in-folder)
455 (function-item gnus-summary-save-in-file)
456 (function-item gnus-summary-save-body-in-file)
457 (function-item gnus-summary-save-in-vm)
458 (function-item gnus-summary-write-to-file)))
460 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
461 "A function generating a file name to save articles in Rmail format.
462 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
463 :group 'gnus-article-saving
466 (defcustom gnus-mail-save-name 'gnus-plain-save-name
467 "A function generating a file name to save articles in Unix mail format.
468 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
469 :group 'gnus-article-saving
472 (defcustom gnus-folder-save-name 'gnus-folder-save-name
473 "A function generating a file name to save articles in MH folder.
474 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
475 :group 'gnus-article-saving
478 (defcustom gnus-file-save-name 'gnus-numeric-save-name
479 "A function generating a file name to save articles in article format.
480 The function is called with NEWSGROUP, HEADERS, and optional
482 :group 'gnus-article-saving
485 (defcustom gnus-split-methods
486 '((gnus-article-archive-name)
487 (gnus-article-nndoc-name))
488 "*Variable used to suggest where articles are to be saved.
489 For instance, if you would like to save articles related to Gnus in
490 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
491 you could set this variable to something like:
493 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
494 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
496 This variable is an alist where the where the key is the match and the
497 value is a list of possible files to save in if the match is non-nil.
499 If the match is a string, it is used as a regexp match on the
500 article. If the match is a symbol, that symbol will be funcalled
501 from the buffer of the article to be saved with the newsgroup as the
502 parameter. If it is a list, it will be evaled in the same buffer.
504 If this form or function returns a string, this string will be used as
505 a possible file name; and if it returns a non-nil list, that list will
506 be used as possible file names."
507 :group 'gnus-article-saving
508 :type '(repeat (choice (list :value (fun) function)
509 (cons :value ("" "") regexp (repeat string))
512 (defcustom gnus-article-display-method-for-mime
513 'gnus-article-display-mime-message
514 "Function to display a MIME message.
515 The function is called from the article buffer."
516 :group 'gnus-article-mime
519 (defcustom gnus-article-display-method-for-traditional
520 'gnus-article-display-traditional-message
521 "*Function to display a traditional message.
522 The function is called from the article buffer."
523 :group 'gnus-article-mime
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (defcustom gnus-article-hide-pgp-hook nil
567 "*A hook called after successfully hiding a PGP signature."
569 :group 'gnus-article-various)
571 (defcustom gnus-article-button-face 'bold
572 "Face used for highlighting buttons in the article buffer.
574 An article button is a piece of text that you can activate by pressing
575 `RET' or `mouse-2' above it."
577 :group 'gnus-article-buttons)
579 (defcustom gnus-article-mouse-face 'highlight
580 "Face used for mouse highlighting in the article buffer.
582 Article buttons will be displayed in this face when the cursor is
585 :group 'gnus-article-buttons)
587 (defcustom gnus-signature-face 'gnus-signature-face
588 "Face used for highlighting a signature in the article buffer.
589 Obsolete; use the face `gnus-signature-face' for customizations instead."
591 :group 'gnus-article-highlight
592 :group 'gnus-article-signature)
594 (defface gnus-signature-face
597 "Face used for highlighting a signature in the article buffer."
598 :group 'gnus-article-highlight
599 :group 'gnus-article-signature)
601 (defface gnus-header-from-face
604 (:foreground "spring green"))
607 (:foreground "red3"))
610 "Face used for displaying from headers."
611 :group 'gnus-article-headers
612 :group 'gnus-article-highlight)
614 (defface gnus-header-subject-face
617 (:foreground "SeaGreen3"))
620 (:foreground "red4"))
622 (:bold t :italic t)))
623 "Face used for displaying subject headers."
624 :group 'gnus-article-headers
625 :group 'gnus-article-highlight)
627 (defface gnus-header-newsgroups-face
630 (:foreground "yellow" :italic t))
633 (:foreground "MidnightBlue" :italic t))
636 "Face used for displaying newsgroups headers."
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
662 "Face used for displaying header content."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defcustom gnus-header-face-alist
667 '(("From" nil gnus-header-from-face)
668 ("Subject" nil gnus-header-subject-face)
669 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
670 ("" gnus-header-name-face gnus-header-content-face))
671 "*Controls highlighting of article header.
673 An alist of the form (HEADER NAME CONTENT).
675 HEADER is a regular expression which should match the name of an
676 header header and NAME and CONTENT are either face names or nil.
678 The name of each header field will be displayed using the face
679 specified by the first element in the list where HEADER match the
680 header name and NAME is non-nil. Similarly, the content will be
681 displayed by the first non-nil matching CONTENT face."
682 :group 'gnus-article-headers
683 :group 'gnus-article-highlight
684 :type '(repeat (list (regexp :tag "Header")
686 (item :tag "skip" nil)
687 (face :value default))
688 (choice :tag "Content"
689 (item :tag "skip" nil)
690 (face :value default)))))
692 (defcustom gnus-article-decode-hook nil
693 "*Hook run to decode charsets in articles."
694 :group 'gnus-article-headers
697 (defcustom gnus-display-mime-function 'gnus-display-mime
698 "Function to display MIME articles."
699 :group 'gnus-article-mime
702 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
703 "Function used to decode headers.")
705 (defvar gnus-article-dumbquotes-map
724 "Table for MS-to-Latin1 translation.")
726 (defcustom gnus-ignored-mime-types nil
727 "List of MIME types that should be ignored by Gnus."
729 :group 'gnus-article-mime
730 :type '(repeat regexp))
732 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
733 "List of MIME types that should not be given buttons when rendered inline.
734 See also `gnus-buttonized-mime-types' which may override this variable."
736 :group 'gnus-article-mime
737 :type '(repeat regexp))
739 (defcustom gnus-buttonized-mime-types nil
740 "List of MIME types that should be given buttons when rendered inline.
741 If set, this variable overrides `gnus-unbuttonized-mime-types'.
742 To see e.g. security buttons you could set this to
743 `(\"multipart/signed\")'."
745 :group 'gnus-article-mime
746 :type '(repeat regexp))
748 (defcustom gnus-body-boundary-delimiter "_"
749 "String used to delimit header and body.
750 This variable is used by `gnus-article-treat-body-boundary' which can
751 be controlled by `gnus-treat-body-boundary'."
752 :group 'gnus-article-various
753 :type '(choice (item :tag "None" :value nil)
756 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
757 "*Defines the location of the faces database.
758 For information on obtaining this database of pretty pictures, please
759 see http://www.cs.indiana.edu/picons/ftp/index.html"
763 (defun gnus-picons-installed-p ()
764 "Say whether picons are installed on your machine."
765 (let ((installed nil))
766 (dolist (database gnus-picon-databases)
767 (when (file-exists-p database)
771 (defcustom gnus-article-mime-part-function nil
772 "Function called with a MIME handle as the argument.
773 This is meant for people who want to do something automatic based
774 on parts -- for instance, adding Vcard info to a database."
775 :group 'gnus-article-mime
778 (defcustom gnus-mime-multipart-functions nil
779 "An alist of MIME types to functions to display them."
781 :group 'gnus-article-mime
784 (defcustom gnus-article-date-lapsed-new-header nil
785 "Whether the X-Sent and Date headers can coexist.
786 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
787 either replace the old \"Date:\" header (if this variable is nil), or
788 be added below it (otherwise)."
790 :group 'gnus-article-headers
793 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
794 "Function called with a MIME handle as the argument.
795 This is meant for people who want to view first matched part.
796 For `undisplayed-alternative' (default), the first undisplayed
797 part or alternative part is used. For `undisplayed', the first
798 undisplayed part is used. For a function, the first part which
799 the function return `t' is used. For `nil', the first part is
802 :group 'gnus-article-mime
804 (item :tag "first" :value nil)
805 (item :tag "undisplayed" :value undisplayed)
806 (item :tag "undisplayed or alternative"
807 :value undisplayed-alternative)
810 (defcustom gnus-mime-action-alist
811 '(("save to file" . gnus-mime-save-part)
812 ("save and strip" . gnus-mime-save-part-and-strip)
813 ("display as text" . gnus-mime-inline-part)
814 ("view the part" . gnus-mime-view-part)
815 ("pipe to command" . gnus-mime-pipe-part)
816 ("toggle display" . gnus-article-press-button)
817 ("toggle display" . gnus-article-view-part-as-charset)
818 ("view as type" . gnus-mime-view-part-as-type)
819 ("internalize type" . gnus-mime-internalize-part)
820 ("externalize type" . gnus-mime-externalize-part))
821 "An alist of actions that run on the MIME attachment."
822 :group 'gnus-article-mime
823 :type '(repeat (cons (string :tag "name")
826 (defcustom gnus-mime-action-alist
827 '(("save to file" . gnus-mime-save-part)
828 ("display as text" . gnus-mime-inline-part)
829 ("view the part" . gnus-mime-view-part)
830 ("pipe to command" . gnus-mime-pipe-part)
831 ("toggle display" . gnus-article-press-button)
832 ("view as type" . gnus-mime-view-part-as-type)
833 ("internalize type" . gnus-mime-internalize-part)
834 ("externalize type" . gnus-mime-externalize-part))
835 "An alist of actions that run on the MIME attachment."
837 :group 'gnus-article-mime
838 :type '(repeat (cons (string :tag "name")
842 ;;; The treatment variables
845 (defvar gnus-part-display-hook nil
846 "Hook called on parts that are to receive treatment.")
848 (defvar gnus-article-treat-custom
849 '(choice (const :tag "Off" nil)
851 (const :tag "Header" head)
852 (const :tag "Last" last)
853 (const :tag "Mime" mime)
854 (integer :tag "Less")
855 (repeat :tag "Groups" regexp)
856 (sexp :tag "Predicate")))
858 (defvar gnus-article-treat-head-custom
859 '(choice (const :tag "Off" nil)
860 (const :tag "Header" head)))
862 (defvar gnus-article-treat-types '("text/plain")
865 (defvar gnus-inhibit-treatment nil
866 "Whether to inhibit treatment.")
868 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
869 "Highlight the signature.
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles'."
872 :group 'gnus-article-treat
873 :type gnus-article-treat-custom)
874 (put 'gnus-treat-highlight-signature 'highlight t)
876 (defcustom gnus-treat-buttonize 100000
878 Valid values are nil, t, `head', `last', an integer or a predicate.
879 See Info node `(gnus)Customizing Articles'."
880 :group 'gnus-article-treat
881 :type gnus-article-treat-custom)
882 (put 'gnus-treat-buttonize 'highlight t)
884 (defcustom gnus-treat-buttonize-head 'head
885 "Add buttons to the head.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See Info node `(gnus)Customizing Articles' for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-head-custom)
890 (put 'gnus-treat-buttonize-head 'highlight t)
892 (defcustom gnus-treat-emphasize
893 (and (or window-system
895 (>= (string-to-number emacs-version) 21))
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
902 (put 'gnus-treat-emphasize 'highlight t)
904 (defcustom gnus-treat-strip-cr nil
905 "Remove carriage returns.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See Info node `(gnus)Customizing Articles' for details."
908 :group 'gnus-article-treat
909 :type gnus-article-treat-custom)
911 (defcustom gnus-treat-leading-whitespace nil
912 "Remove leading whitespace in headers.
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
918 (defcustom gnus-treat-hide-headers 'head
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See Info node `(gnus)Customizing Articles' for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-head-custom)
925 (defcustom gnus-treat-hide-boring-headers nil
926 "Hide boring headers.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-head-custom)
932 (defcustom gnus-treat-hide-signature nil
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See Info node `(gnus)Customizing Articles' for details."
936 :group 'gnus-article-treat
937 :type gnus-article-treat-custom)
939 (defcustom gnus-treat-fill-article nil
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 :type gnus-article-treat-custom)
946 (defcustom gnus-treat-hide-citation nil
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
950 :group 'gnus-article-treat
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-hide-citation-maybe nil
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-strip-list-identifiers 'head
961 "Strip list identifiers from `gnus-list-identifiers`.
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-strip-pgp t
969 "Strip PGP signatures.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
972 :group 'gnus-article-treat
973 :type gnus-article-treat-custom)
975 (defcustom gnus-treat-strip-pem nil
976 "Strip PEM signatures.
977 Valid values are nil, t, `head', `last', an integer or a predicate.
978 See Info node `(gnus)Customizing Articles' for details."
979 :group 'gnus-article-treat
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-strip-banner t
983 "Strip banners from articles.
984 The banner to be stripped is specified in the `banner' group parameter.
985 Valid values are nil, t, `head', `last', an integer or a predicate.
986 See Info node `(gnus)Customizing Articles' for details."
987 :group 'gnus-article-treat
988 :type gnus-article-treat-custom)
990 (defcustom gnus-treat-highlight-headers 'head
991 "Highlight the headers.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-head-custom)
996 (put 'gnus-treat-highlight-headers 'highlight t)
998 (defcustom gnus-treat-highlight-citation t
999 "Highlight cited text.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-highlight-citation 'highlight t)
1006 (defcustom gnus-treat-date-ut nil
1007 "Display the Date in UT (GMT).
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :type gnus-article-treat-head-custom)
1013 (defcustom gnus-treat-date-local nil
1014 "Display the Date in the local timezone.
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group 'gnus-article-treat
1018 :type gnus-article-treat-head-custom)
1020 (defcustom gnus-treat-date-english nil
1021 "Display the Date in a format that can be read aloud in English.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :type gnus-article-treat-head-custom)
1027 (defcustom gnus-treat-date-lapsed nil
1028 "Display the Date header in a way that says how much time has elapsed.
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1031 :group 'gnus-article-treat
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-original nil
1035 "Display the date in the original timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :type gnus-article-treat-head-custom)
1041 (defcustom gnus-treat-date-iso8601 nil
1042 "Display the date in the ISO8601 format.
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-head-custom)
1049 (defcustom gnus-treat-date-user-defined nil
1050 "Display the date in a user-defined format.
1051 The format is defined by the `gnus-article-time-format' variable.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-head-custom)
1057 (defcustom gnus-treat-strip-headers-in-body t
1058 "Strip the X-No-Archive header line from the beginning of the body.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :type gnus-article-treat-custom)
1065 (defcustom gnus-treat-strip-trailing-blank-lines nil
1066 "Strip trailing blank lines.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :type gnus-article-treat-custom)
1072 (defcustom gnus-treat-strip-leading-blank-lines nil
1073 "Strip leading blank lines.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :type gnus-article-treat-custom)
1079 (defcustom gnus-treat-strip-multiple-blank-lines nil
1080 "Strip multiple blank lines.
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 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-unfold-headers 'head
1087 "Unfold folded header lines.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-fold-headers nil
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :type gnus-article-treat-custom)
1100 (defcustom gnus-treat-fold-newsgroups 'head
1101 "Fold the Newsgroups and Followup-To headers.
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-overstrike t
1108 "Treat overstrike highlighting.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :type gnus-article-treat-custom)
1113 (put 'gnus-treat-overstrike 'highlight t)
1115 (defcustom gnus-treat-display-xface
1116 (and (or (and (fboundp 'image-type-available-p)
1117 (image-type-available-p 'xbm)
1118 (string-match "^0x" (shell-command-to-string "uncompface")))
1119 (and (featurep 'xemacs)
1121 (eq 'x-face-mule-gnus-article-display-x-face
1122 gnus-article-x-face-command))
1124 "Display X-Face headers.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' and Info node
1127 `(gnus)X-Face' for details."
1128 :group 'gnus-article-treat
1130 :type gnus-article-treat-head-custom)
1131 (put 'gnus-treat-display-xface 'highlight t)
1133 (defcustom gnus-article-should-use-smiley-mule
1134 (not (or (featurep 'xemacs)
1135 (gnus-image-type-available-p 'xpm)
1136 (gnus-image-type-available-p 'pbm)))
1137 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1138 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1139 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1140 even if you are using Emacs 21+. It has no effect on XEmacs."
1141 :group 'gnus-article-various
1143 :get (lambda (symbol)
1144 (and (default-value symbol)
1145 (not (featurep 'xemacs))
1146 (module-installed-p 'smiley-mule)
1148 :set (lambda (symbol value)
1149 (set-default symbol (and value
1150 (not (featurep 'xemacs))
1151 (module-installed-p 'smiley-mule)
1154 (defvar gnus-article-smiley-mule-loaded-p nil
1155 "Internal variable used to say whether `smiley-mule' is loaded (whether
1156 smiley functions are not overridden by `smiley').")
1158 (defcustom gnus-treat-display-smileys
1159 (if (or (and (featurep 'xemacs)
1161 (gnus-image-type-available-p 'xpm)
1162 (gnus-image-type-available-p 'pbm)
1163 (and (not (featurep 'xemacs))
1165 (module-installed-p 'smiley-mule)))
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' and Info node
1171 `(gnus)Smileys' for details."
1172 :group 'gnus-article-treat
1174 :type gnus-article-treat-custom)
1175 (put 'gnus-treat-display-smileys 'highlight t)
1177 (defcustom gnus-treat-from-picon
1178 (if (and (gnus-image-type-available-p 'xpm)
1179 (gnus-picons-installed-p))
1181 "Display picons in the From header.
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)Picons' for details."
1185 :group 'gnus-article-treat
1186 :type gnus-article-treat-head-custom)
1187 (put 'gnus-treat-from-picon 'highlight t)
1189 (defcustom gnus-treat-mail-picon
1190 (if (and (gnus-image-type-available-p 'xpm)
1191 (gnus-picons-installed-p))
1193 "Display picons in To and Cc headers.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' and Info node
1196 `(gnus)Picons' for details."
1197 :group 'gnus-article-treat
1198 :type gnus-article-treat-head-custom)
1199 (put 'gnus-treat-mail-picon 'highlight t)
1201 (defcustom gnus-treat-newsgroups-picon
1202 (if (and (gnus-image-type-available-p 'xpm)
1203 (gnus-picons-installed-p))
1205 "Display picons in the Newsgroups and Followup-To headers.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' and Info node
1208 `(gnus)Picons' for details."
1209 :group 'gnus-article-treat
1210 :type gnus-article-treat-head-custom)
1211 (put 'gnus-treat-newsgroups-picon 'highlight t)
1213 (defcustom gnus-treat-body-boundary
1214 (if (or gnus-treat-newsgroups-picon
1215 gnus-treat-mail-picon
1216 gnus-treat-from-picon)
1218 "Draw a boundary at the end of the headers.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' for details."
1222 :group 'gnus-article-treat
1223 :type gnus-article-treat-custom)
1225 (defcustom gnus-treat-capitalize-sentences nil
1226 "Capitalize sentence-starting words.
1227 Valid values are nil, t, `head', `last', an integer or a predicate.
1228 See Info node `(gnus)Customizing Articles' for details."
1230 :group 'gnus-article-treat
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-fill-long-lines nil
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1237 :group 'gnus-article-treat
1238 :type gnus-article-treat-custom)
1240 (defcustom gnus-treat-play-sounds nil
1242 Valid values are nil, t, `head', `last', an integer or a predicate.
1243 See Info node `(gnus)Customizing Articles' for details."
1245 :group 'gnus-article-treat
1246 :type gnus-article-treat-custom)
1248 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1249 "Decode an article as `default-mime-charset'. For instance, if you want to
1250 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1251 you could set this variable to something like: nil for don't decode, t for
1252 decode the body, '(or header t) for the whole article, etc."
1253 :group 'gnus-article-treat
1254 :type '(radio (const :tag "Off" nil)
1255 (const :tag "Decode body" t)
1256 (const :tag "Decode all" (or head t))))
1258 (defcustom gnus-treat-translate nil
1259 "Translate articles from one language to another.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' for details."
1263 :group 'gnus-article-treat
1264 :type gnus-article-treat-custom)
1266 (defcustom gnus-treat-x-pgp-sig nil
1268 To automatically treat X-PGP-Sig, set it to head.
1269 Valid values are nil, t, `head', `last', an integer or a predicate.
1270 See Info node `(gnus)Customizing Articles' for details."
1271 :group 'gnus-article-treat
1272 :group 'mime-security
1273 :type gnus-article-treat-custom)
1275 (defvar gnus-article-encrypt-protocol-alist
1276 '(("PGP" . mml2015-self-encrypt)))
1278 ;; Set to nil if more than one protocol added to
1279 ;; gnus-article-encrypt-protocol-alist.
1280 (defcustom gnus-article-encrypt-protocol "PGP"
1281 "The protocol used for encrypt articles.
1282 It is a string, such as \"PGP\". If nil, ask user."
1284 :group 'mime-security)
1286 (defcustom gnus-article-wash-function
1287 (cond ((locate-library "w3")
1288 'gnus-article-wash-html-with-w3)
1289 ((locate-library "w3m")
1290 'gnus-article-wash-html-with-w3m))
1291 "Function used for converting HTML into text."
1292 :type '(radio (function-item gnus-article-wash-html-with-w3)
1293 (function-item gnus-article-wash-html-with-w3m))
1294 :group 'gnus-article)
1296 ;;; Internal variables
1298 (defvar gnus-english-month-names
1299 '("January" "February" "March" "April" "May" "June" "July" "August"
1300 "September" "October" "November" "December"))
1302 (defvar article-goto-body-goes-to-point-min-p nil)
1303 (defvar gnus-article-wash-types nil)
1304 (defvar gnus-article-emphasis-alist nil)
1305 (defvar gnus-article-image-alist nil)
1307 (defvar gnus-article-mime-handle-alist-1 nil)
1308 (defvar gnus-treatment-function-alist
1309 '((gnus-treat-decode-article-as-default-mime-charset
1310 gnus-article-decode-article-as-default-mime-charset)
1311 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1312 (gnus-treat-strip-banner gnus-article-strip-banner)
1313 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1314 (gnus-treat-buttonize gnus-article-add-buttons)
1315 (gnus-treat-fill-article gnus-article-fill-cited-article)
1316 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1317 (gnus-treat-strip-cr gnus-article-remove-cr)
1318 (gnus-treat-date-ut gnus-article-date-ut)
1319 (gnus-treat-date-local gnus-article-date-local)
1320 (gnus-treat-date-english gnus-article-date-english)
1321 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1322 (gnus-treat-date-original gnus-article-date-original)
1323 (gnus-treat-date-user-defined gnus-article-date-user)
1324 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1325 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1326 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1327 (gnus-treat-hide-signature gnus-article-hide-signature)
1328 (gnus-treat-hide-citation gnus-article-hide-citation)
1329 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1330 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1331 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1332 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1333 (gnus-treat-strip-pem gnus-article-hide-pem)
1334 (gnus-treat-from-picon gnus-treat-from-picon)
1335 (gnus-treat-mail-picon gnus-treat-mail-picon)
1336 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1337 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1338 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1339 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1340 (gnus-treat-strip-trailing-blank-lines
1341 gnus-article-remove-trailing-blank-lines)
1342 (gnus-treat-strip-leading-blank-lines
1343 gnus-article-strip-leading-blank-lines)
1344 (gnus-treat-strip-multiple-blank-lines
1345 gnus-article-strip-multiple-blank-lines)
1346 (gnus-treat-overstrike gnus-article-treat-overstrike)
1347 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1348 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1349 ;; Displaying X-Face should be done after unfolding headers
1350 ;; to protect bitmap lines.
1351 (gnus-treat-display-xface gnus-article-display-x-face)
1352 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1353 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1354 (gnus-treat-display-smileys gnus-treat-smiley)
1355 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1356 (gnus-treat-emphasize gnus-article-emphasize)
1357 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1358 (gnus-treat-play-sounds gnus-earcon-display)))
1360 (defvar gnus-article-mime-handle-alist nil)
1361 (defvar article-lapsed-timer nil)
1362 (defvar gnus-article-current-summary nil)
1364 (defvar gnus-article-mode-syntax-table
1365 (let ((table (copy-syntax-table text-mode-syntax-table)))
1366 ;; This causes the citation match run O(2^n).
1367 ;; (modify-syntax-entry ?- "w" table)
1368 (modify-syntax-entry ?> ")" table)
1369 (modify-syntax-entry ?< "(" table)
1371 "Syntax table used in article mode buffers.
1372 Initialized from `text-mode-syntax-table.")
1374 (defvar gnus-save-article-buffer nil)
1376 (defvar gnus-article-mode-line-format-alist
1377 (nconc '((?w (gnus-article-wash-status) ?s)
1378 (?m (gnus-article-mime-part-status) ?s))
1379 gnus-summary-mode-line-format-alist))
1381 (defvar gnus-number-of-articles-to-be-saved nil)
1383 (defvar gnus-inhibit-hiding nil)
1385 ;;; Macros for dealing with the article buffer.
1387 (defmacro gnus-with-article-headers (&rest forms)
1389 (set-buffer gnus-article-buffer)
1391 (let ((buffer-read-only nil)
1392 (inhibit-point-motion-hooks t)
1393 (case-fold-search t))
1394 (article-narrow-to-head)
1397 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1398 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1400 (defmacro gnus-with-article-buffer (&rest forms)
1402 (set-buffer gnus-article-buffer)
1403 (let ((buffer-read-only nil))
1406 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1407 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1409 (defun gnus-article-goto-header (header)
1410 "Go to HEADER, which is a regular expression."
1411 (re-search-forward (concat "^\\(" header "\\):") nil t))
1413 (defsubst gnus-article-hide-text (b e props)
1414 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1415 (gnus-add-text-properties-when 'article-type nil b e props)
1416 (when (memq 'intangible props)
1418 (max (1- b) (point-min))
1419 b 'intangible (cddr (memq 'intangible props)))))
1421 (defsubst gnus-article-unhide-text (b e)
1422 "Remove hidden text properties from region between B and E."
1423 (remove-text-properties b e gnus-hidden-properties)
1424 (when (memq 'intangible gnus-hidden-properties)
1425 (put-text-property (max (1- b) (point-min))
1426 b 'intangible nil)))
1428 (defun gnus-article-hide-text-type (b e type)
1429 "Hide text of TYPE between B and E."
1430 (gnus-add-wash-type type)
1431 (gnus-article-hide-text
1432 b e (cons 'article-type (cons type gnus-hidden-properties))))
1434 (defun gnus-article-unhide-text-type (b e type)
1435 "Unhide text of TYPE between B and E."
1436 (gnus-delete-wash-type type)
1437 (remove-text-properties
1438 b e (cons 'article-type (cons type gnus-hidden-properties)))
1439 (when (memq 'intangible gnus-hidden-properties)
1440 (put-text-property (max (1- b) (point-min))
1441 b 'intangible nil)))
1443 (defun gnus-article-hide-text-of-type (type)
1444 "Hide text of TYPE in the current buffer."
1446 (let ((b (point-min))
1448 (while (setq b (text-property-any b e 'article-type type))
1449 (add-text-properties b (incf b) gnus-hidden-properties)))))
1451 (defun gnus-article-delete-text-of-type (type)
1452 "Delete text of TYPE in the current buffer."
1454 (let ((b (point-min)))
1455 (while (setq b (text-property-any b (point-max) 'article-type type))
1457 b (or (text-property-not-all b (point-max) 'article-type type)
1460 (defun gnus-article-delete-invisible-text ()
1461 "Delete all invisible text in the current buffer."
1463 (let ((b (point-min)))
1464 (while (setq b (text-property-any b (point-max) 'invisible t))
1466 b (or (text-property-not-all b (point-max) 'invisible t)
1469 (defun gnus-article-text-type-exists-p (type)
1470 "Say whether any text of type TYPE exists in the buffer."
1471 (text-property-any (point-min) (point-max) 'article-type type))
1473 (defsubst gnus-article-header-rank ()
1474 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1475 (let ((list gnus-sorted-header-list)
1478 (when (looking-at (car list))
1480 (setq list (cdr list))
1484 (defun article-hide-headers (&optional arg delete)
1485 "Hide unwanted headers and possibly sort them as well."
1486 (interactive (gnus-article-hidden-arg))
1487 ;; Lars said that this function might be inhibited.
1488 (if (gnus-article-check-hidden-text 'headers arg)
1490 ;; Show boring headers as well.
1491 (gnus-article-show-hidden-text 'boring-headers)
1492 (when (eq 1 (point-min))
1493 (set-window-start (get-buffer-window (current-buffer)) 1)))
1494 (unless gnus-inhibit-hiding
1497 (let ((inhibit-read-only t)
1498 (case-fold-search t)
1499 (max (1+ (length gnus-sorted-header-list)))
1500 (ignored (when (not gnus-visible-headers)
1501 (cond ((stringp gnus-ignored-headers)
1502 gnus-ignored-headers)
1503 ((listp gnus-ignored-headers)
1504 (mapconcat 'identity gnus-ignored-headers
1507 (cond ((stringp gnus-visible-headers)
1508 gnus-visible-headers)
1509 ((and gnus-visible-headers
1510 (listp gnus-visible-headers))
1511 (mapconcat 'identity gnus-visible-headers "\\|"))))
1512 (inhibit-point-motion-hooks t)
1514 ;; First we narrow to just the headers.
1515 (article-narrow-to-head)
1516 ;; Hide any "From " lines at the beginning of (mail) articles.
1517 (while (looking-at "From ")
1521 (delete-region (point-min) (point))
1522 (gnus-article-hide-text (point-min) (point)
1523 (nconc (list 'article-type 'headers)
1524 gnus-hidden-properties))))
1525 ;; Then treat the rest of the header lines.
1526 ;; Then we use the two regular expressions
1527 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1528 ;; select which header lines is to remain visible in the
1530 (while (re-search-forward "^[^ \t:]*:" nil t)
1532 ;; Mark the rank of the header.
1534 (point) (1+ (point)) 'message-rank
1535 (if (or (and visible (looking-at visible))
1537 (not (looking-at ignored))))
1538 (gnus-article-header-rank)
1541 (message-sort-headers-1)
1542 (when (setq beg (text-property-any
1543 (point-min) (point-max) 'message-rank (+ 2 max)))
1544 ;; We delete or make invisible the unwanted headers.
1545 (gnus-add-wash-type 'headers)
1548 (add-text-properties
1549 (point-min) (+ 5 (point-min))
1550 '(article-type headers dummy-invisible t))
1551 (delete-region beg (point-max)))
1552 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1554 (defun article-hide-boring-headers (&optional arg)
1555 "Toggle hiding of headers that aren't very interesting.
1556 If given a negative prefix, always show; if given a positive prefix,
1558 (interactive (gnus-article-hidden-arg))
1559 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1560 (not gnus-show-all-headers))
1563 (let ((buffer-read-only nil)
1564 (list gnus-boring-article-headers)
1565 (inhibit-point-motion-hooks t)
1567 (article-narrow-to-head)
1569 (setq elem (pop list))
1570 (goto-char (point-min))
1572 ;; Hide empty headers.
1574 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1576 (gnus-article-hide-text-type
1577 (progn (beginning-of-line) (point))
1580 (if (re-search-forward "^[^ \t]" nil t)
1584 ;; Hide boring Newsgroups header.
1585 ((eq elem 'newsgroups)
1586 (when (gnus-string-equal
1587 (gnus-fetch-field "newsgroups")
1588 (gnus-group-real-name
1589 (if (boundp 'gnus-newsgroup-name)
1592 (gnus-article-hide-header "newsgroups")))
1593 ((eq elem 'to-address)
1594 (let ((to (message-fetch-field "to"))
1596 (gnus-parameter-to-address
1597 (if (boundp 'gnus-newsgroup-name)
1598 gnus-newsgroup-name ""))))
1599 (when (and to to-address
1602 ;; only one address in To
1603 (nth 1 (mail-extract-address-components to))
1605 (gnus-article-hide-header "to"))))
1606 ((eq elem 'followup-to)
1607 (when (gnus-string-equal
1608 (message-fetch-field "followup-to")
1609 (message-fetch-field "newsgroups"))
1610 (gnus-article-hide-header "followup-to")))
1611 ((eq elem 'reply-to)
1612 (let ((from (message-fetch-field "from"))
1613 (reply-to (message-fetch-field "reply-to")))
1618 (nth 1 (mail-extract-address-components from))
1619 (nth 1 (mail-extract-address-components reply-to)))))
1620 (gnus-article-hide-header "reply-to"))))
1622 (let ((date (message-fetch-field "date")))
1624 (< (days-between (current-time-string) date)
1626 (gnus-article-hide-header "date"))))
1628 (let ((to (message-fetch-field "to"))
1629 (cc (message-fetch-field "cc")))
1630 (when (> (length to) 1024)
1631 (gnus-article-hide-header "to"))
1632 (when (> (length cc) 1024)
1633 (gnus-article-hide-header "cc"))))
1637 (goto-char (point-min))
1638 (while (re-search-forward "^to:" nil t)
1639 (setq to-count (1+ to-count)))
1640 (when (> to-count 1)
1641 (while (> to-count 0)
1642 (goto-char (point-min))
1644 (re-search-forward "^to:" nil nil to-count)
1646 (narrow-to-region (point) (point-max))
1647 (gnus-article-hide-header "to"))
1648 (setq to-count (1- to-count))))
1649 (goto-char (point-min))
1650 (while (re-search-forward "^cc:" nil t)
1651 (setq cc-count (1+ cc-count)))
1652 (when (> cc-count 1)
1653 (while (> cc-count 0)
1654 (goto-char (point-min))
1656 (re-search-forward "^cc:" nil nil cc-count)
1658 (narrow-to-region (point) (point-max))
1659 (gnus-article-hide-header "cc"))
1660 (setq cc-count (1- cc-count)))))))))))))
1662 (defun gnus-article-hide-header (header)
1664 (goto-char (point-min))
1665 (when (re-search-forward (concat "^" header ":") nil t)
1666 (gnus-article-hide-text-type
1667 (progn (beginning-of-line) (point))
1670 (if (re-search-forward "^[^ \t]" nil t)
1675 (defun article-toggle-headers (&optional arg)
1676 "Toggle hiding of headers. If given a negative prefix, always show;
1677 if given a positive prefix, always hide."
1678 (interactive (gnus-article-hidden-arg))
1679 (let ((force (when (numberp arg)
1680 (cond ((> arg 0) 'always-hide)
1681 ((< arg 0) 'always-show))))
1682 (window (get-buffer-window gnus-article-buffer))
1683 (header-end (point-min))
1684 header-start field-end field-start
1685 (inhibit-point-motion-hooks t)
1686 (inhibit-read-only t))
1689 (while (and (setq header-start
1690 (text-property-any header-end (point-max)
1691 'article-treated-header t))
1693 (text-property-not-all header-start (point-max)
1694 'article-treated-header t)))
1695 (setq field-end header-start)
1697 (;; Hide exposed invisible fields.
1698 (and (not (eq 'always-show force))
1700 (text-property-any field-end header-end
1701 'exposed-invisible-field t)))
1702 (while (and field-start
1703 (setq field-end (text-property-not-all
1704 field-start header-end
1705 'exposed-invisible-field t)))
1706 (add-text-properties field-start field-end gnus-hidden-properties)
1707 (setq field-start (text-property-any field-end header-end
1708 'exposed-invisible-field t)))
1709 (put-text-property header-start header-end
1710 'exposed-invisible-field nil))
1711 (;; Expose invisible fields.
1712 (and (not (eq 'always-hide force))
1714 (text-property-any field-end header-end 'invisible t)))
1715 (while (and field-start
1716 (setq field-end (text-property-not-all
1717 field-start header-end
1719 ;; If the invisible text is not terminated with newline, we
1720 ;; won't expose it. Because it may be created by x-face-mule.
1721 ;; BTW, XEmacs sometimes fail in putting an invisible text
1722 ;; property with `gnus-article-hide-text' (really?). In that
1723 ;; case, the invisible text might be started from the middle of
1724 ;; a line, so we will expose the sort of thing.
1725 (when (or (not (or (eq header-start field-start)
1726 (eq ?\n (char-before field-start))))
1727 (eq ?\n (char-before field-end))
1728 ;; Expose a boundary line anyway.
1731 (buffer-substring (max (- field-end 13) header-start)
1733 (remove-text-properties field-start field-end
1734 gnus-hidden-properties)
1735 (put-text-property field-start field-end
1736 'exposed-invisible-field t))
1737 (setq field-start (text-property-any field-end header-end
1740 (not (eq 'always-show force))
1741 (narrow-to-region header-start header-end)
1742 (article-hide-headers)
1743 ;; Re-display X-Face image under XEmacs.
1744 (when (and (featurep 'xemacs)
1745 (gnus-functionp gnus-article-x-face-command))
1746 (let ((func (cadr (assq 'gnus-treat-display-xface
1747 gnus-treatment-function-alist)))
1749 (when (and (not gnus-inhibit-treatment)
1751 (gnus-treat-predicate gnus-treat-display-xface))
1753 (put-text-property header-start header-end 'read-only nil))))
1756 (goto-char (point-min))
1758 (set-window-start window (point-min))))))
1760 (defvar gnus-article-normalized-header-length 40
1761 "Length of normalized headers.")
1763 (defun article-normalize-headers ()
1764 "Make all header lines 40 characters long."
1766 (let ((buffer-read-only nil)
1770 (article-narrow-to-head)
1773 ((< (setq column (- (gnus-point-at-eol) (point)))
1774 gnus-article-normalized-header-length)
1776 (insert (make-string
1777 (- gnus-article-normalized-header-length column)
1779 ((> column gnus-article-normalized-header-length)
1780 (gnus-put-text-property
1782 (forward-char gnus-article-normalized-header-length)
1789 (forward-line 1))))))
1791 (defun article-treat-dumbquotes ()
1792 "Translate M****s*** sm*rtq**t*s into proper text.
1793 Note that this function guesses whether a character is a sm*rtq**t* or
1794 not, so it should only be used interactively.
1796 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1797 in an attempt to provide more quoting characters. If you see
1798 something like \\222 or \\264 where you're expecting some kind of
1799 apostrophe or quotation mark, then try this wash."
1801 (article-translate-strings gnus-article-dumbquotes-map))
1803 (defun article-translate-characters (from to)
1804 "Translate all characters in the body of the article according to FROM and TO.
1805 FROM is a string of characters to translate from; to is a string of
1806 characters to translate to."
1808 (when (article-goto-body)
1809 (let ((buffer-read-only nil)
1810 (x (make-string 225 ?x))
1812 (while (< (incf i) (length x))
1815 (while (< i (length from))
1816 (aset x (aref from i) (aref to i))
1818 (translate-region (point) (point-max) x)))))
1820 (defun article-translate-strings (map)
1821 "Translate all string in the body of the article according to MAP.
1822 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1824 (when (article-goto-body)
1825 (let ((buffer-read-only nil)
1827 (while (setq elem (pop map))
1829 (while (search-forward (car elem) nil t)
1830 (replace-match (cadr elem)))))))))
1832 (defun article-treat-overstrike ()
1833 "Translate overstrikes into bold text."
1836 (when (article-goto-body)
1837 (let ((buffer-read-only nil))
1838 (while (search-forward "\b" nil t)
1839 (let ((next (char-after))
1843 previous (char-after))
1847 ;; We do the boldification/underlining by hiding the
1848 ;; overstrikes and putting the proper text property
1852 (gnus-article-hide-text-type start (point) 'overstrike)
1853 (put-text-property (point) end 'face 'bold))
1855 (gnus-article-hide-text-type
1856 (1- (point)) (1+ (point)) 'overstrike)
1858 start (1- (point)) 'face 'underline))
1860 (gnus-article-hide-text-type start (point) 'overstrike)
1862 (point) end 'face 'underline)))))))))
1864 (defun gnus-article-treat-unfold-headers ()
1865 "Unfold folded message headers.
1866 Only the headers that fit into the current window width will be
1869 (gnus-with-article-headers
1873 (mail-header-narrow-to-field)
1874 (let ((header (buffer-substring (point-min) (point-max))))
1877 (goto-char (point-min))
1878 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1879 (replace-match " " t t)))
1880 (setq length (- (point-max) (point-min) 1)))
1881 (when (< length (window-width))
1882 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1883 (replace-match " " t t)))
1884 (goto-char (point-max)))))))
1886 (defun gnus-article-treat-fold-headers ()
1887 "Fold message headers."
1889 (gnus-with-article-headers
1892 (mail-header-narrow-to-field)
1893 (mail-header-fold-field)
1894 (goto-char (point-max))))))
1896 (defun gnus-treat-smiley ()
1897 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1899 (unless (featurep 'xemacs)
1900 (when (and (>= emacs-major-version 21)
1901 (not gnus-article-should-use-smiley-mule)
1902 gnus-article-smiley-mule-loaded-p)
1903 (load "smiley" nil t)
1904 (setq gnus-article-smiley-mule-loaded-p nil))
1905 (when (and gnus-article-should-use-smiley-mule
1906 (not gnus-article-smiley-mule-loaded-p))
1907 (load "smiley-mule" nil t)
1908 (setq gnus-article-smiley-mule-loaded-p t)))
1909 (gnus-with-article-buffer
1910 (if (memq 'smiley gnus-article-wash-types)
1911 (gnus-delete-images 'smiley)
1913 (let ((images (smiley-region (point) (point-max))))
1915 (gnus-add-wash-type 'smiley)
1916 (dolist (image images)
1917 (gnus-add-image 'smiley image)))))))
1919 (defun gnus-article-remove-images ()
1920 "Remove all images from the article buffer."
1922 (gnus-with-article-buffer
1923 (dolist (elem gnus-article-image-alist)
1924 (gnus-delete-images (car elem)))))
1926 (defun gnus-article-treat-fold-newsgroups ()
1927 "Unfold folded message headers.
1928 Only the headers that fit into the current window width will be
1931 (gnus-with-article-headers
1932 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1934 (mail-header-narrow-to-field)
1935 (while (re-search-forward ", *" nil t)
1936 (replace-match ", " t t))
1937 (mail-header-fold-field)
1938 (goto-char (point-max))))))
1940 (defun gnus-article-treat-body-boundary ()
1941 "Place a boundary line at the end of the headers."
1943 (when (and gnus-body-boundary-delimiter
1944 (> (length gnus-body-boundary-delimiter) 0))
1945 (gnus-with-article-headers
1946 (goto-char (point-max))
1947 (let ((start (point)))
1948 (insert "X-Boundary: ")
1949 (gnus-add-text-properties start (point) '(invisible t intangible t))
1951 (while (>= (1- (window-width)) (length str))
1952 (setq str (concat str gnus-body-boundary-delimiter)))
1953 (substring str 0 (1- (window-width))))
1956 (defun article-fill-long-lines ()
1957 "Fill lines that are wider than the window width."
1960 (let ((buffer-read-only nil)
1961 (width (window-width (get-buffer-window (current-buffer)))))
1964 (let ((adaptive-fill-mode nil)) ;Why? -sm
1967 (when (>= (current-column) (min fill-column width))
1968 (narrow-to-region (point) (gnus-point-at-bol))
1969 (fill-paragraph nil)
1970 (goto-char (point-max))
1972 (forward-line 1)))))))
1974 (defun article-capitalize-sentences ()
1975 "Capitalize the first word in each sentence."
1978 (let ((buffer-read-only nil)
1979 (paragraph-start "^[\n\^L]"))
1983 (forward-sentence)))))
1985 (defun article-remove-cr ()
1986 "Remove trailing CRs and then translate remaining CRs into LFs."
1989 (let ((buffer-read-only nil))
1990 (goto-char (point-min))
1991 (while (re-search-forward "\r+$" nil t)
1992 (replace-match "" t t))
1993 (goto-char (point-min))
1994 (while (search-forward "\r" nil t)
1995 (replace-match "\n" t t)))))
1997 (defun article-remove-trailing-blank-lines ()
1998 "Remove all trailing blank lines from the article."
2001 (let ((buffer-read-only nil))
2002 (goto-char (point-max))
2006 (while (and (not (bobp))
2007 (looking-at "^[ \t]*$")
2008 (not (gnus-annotation-in-region-p
2009 (point) (gnus-point-at-eol))))
2014 (defun article-display-x-face (&optional force)
2015 "Look for an X-Face header and display it if present."
2016 (interactive (list 'force))
2017 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2018 (gnus-with-article-headers
2019 ;; Delete the old process, if any.
2020 (when (process-status "article-x-face")
2021 (delete-process "article-x-face"))
2022 (if (memq 'xface gnus-article-wash-types)
2023 ;; We have already displayed X-Faces, so we remove them
2025 (gnus-delete-images 'xface)
2027 (let (x-faces from face grey)
2029 (when (and wash-face-p
2031 (goto-char (point-min))
2032 (not (re-search-forward
2033 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2034 (gnus-buffer-live-p gnus-original-article-buffer))
2035 ;; If type `W f', use gnus-original-article-buffer,
2036 ;; otherwise use the current buffer because displaying
2037 ;; RFC822 parts calls this function too.
2038 (set-buffer gnus-original-article-buffer))
2040 (mail-narrow-to-head)
2041 (while (gnus-article-goto-header "x-face\\(-[0-9]+\\)?")
2042 (when (match-beginning 2)
2044 (push (mail-header-field-value) x-faces))
2045 (setq from (message-fetch-field "from"))))
2047 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2050 (setq image (gnus-create-image xpm 'xpm t))
2051 (gnus-article-goto-header "from")
2053 (insert "From: [no `from' set]\n")
2055 (gnus-add-wash-type 'xface)
2056 (gnus-add-image 'xface image)
2057 (gnus-put-image image)))
2058 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2059 ;; single external face.
2060 (when (stringp gnus-article-x-face-command)
2061 (setq x-faces (list (car x-faces))))
2062 (while (and (setq face (pop x-faces))
2063 gnus-article-x-face-command
2065 ;; Check whether this face is censored.
2066 (not gnus-article-x-face-too-ugly)
2067 (and gnus-article-x-face-too-ugly from
2068 (not (string-match gnus-article-x-face-too-ugly
2070 ;; We display the face.
2071 (if (symbolp gnus-article-x-face-command)
2072 ;; The command is a lisp function, so we call it.
2073 (if (gnus-functionp gnus-article-x-face-command)
2074 (funcall gnus-article-x-face-command face)
2075 (error "%s is not a function" gnus-article-x-face-command))
2076 ;; The command is a string, so we interpret the command
2077 ;; as a, well, command, and fork it off.
2078 (let ((process-connection-type nil))
2079 (process-kill-without-query
2081 "article-x-face" nil shell-file-name shell-command-switch
2082 gnus-article-x-face-command))
2085 (process-send-region "article-x-face"
2086 (point-min) (point-max)))
2087 (process-send-eof "article-x-face"))))))))))
2089 (defun article-decode-mime-words ()
2090 "Decode all MIME-encoded words in the article."
2093 (set-buffer gnus-article-buffer)
2094 (let ((inhibit-point-motion-hooks t)
2096 (mail-parse-charset gnus-newsgroup-charset)
2097 (mail-parse-ignored-charsets
2098 (save-excursion (set-buffer gnus-summary-buffer)
2099 gnus-newsgroup-ignored-charsets)))
2100 (mail-decode-encoded-word-region (point-min) (point-max)))))
2102 (defun article-decode-charset (&optional prompt)
2103 "Decode charset-encoded text in the article.
2104 If PROMPT (the prefix), prompt for a coding system to use."
2106 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2108 (mail-parse-charset gnus-newsgroup-charset)
2109 (mail-parse-ignored-charsets
2110 (save-excursion (condition-case nil
2111 (set-buffer gnus-summary-buffer)
2113 gnus-newsgroup-ignored-charsets))
2114 ct cte ctl charset format)
2117 (article-narrow-to-head)
2118 (setq ct (message-fetch-field "Content-Type" t)
2119 cte (message-fetch-field "Content-Transfer-Encoding" t)
2120 ctl (and ct (ignore-errors
2121 (mail-header-parse-content-type ct)))
2124 (mm-read-coding-system "Charset to decode: "))
2126 (mail-content-type-get ctl 'charset)))
2127 format (and ctl (mail-content-type-get ctl 'format)))
2129 (setq cte (mail-header-strip cte)))
2130 (if (and ctl (not (string-match "/" (car ctl))))
2132 (goto-char (point-max)))
2135 (narrow-to-region (point) (point-max))
2136 (when (and (eq mail-parse-charset 'gnus-decoded)
2137 (eq (mm-body-7-or-8) '8bit))
2138 ;; The text code could have been decoded.
2139 (setq charset mail-parse-charset))
2140 (when (and (or (not ctl)
2141 (equal (car ctl) "text/plain"))
2142 (not format)) ;; article with format will decode later.
2144 charset (and cte (intern (downcase
2145 (gnus-strip-whitespace cte))))
2148 (defun article-decode-encoded-words ()
2149 "Remove encoded-word encoding from headers."
2150 (let (buffer-read-only)
2151 (let ((charset (save-excursion
2152 (set-buffer gnus-summary-buffer)
2153 default-mime-charset)))
2154 (mime-decode-header-in-buffer charset))))
2156 (defun article-decode-group-name ()
2157 "Decode group names in `Newsgroups:'."
2158 (let ((inhibit-point-motion-hooks t)
2160 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2161 (when (and (or gnus-group-name-charset-method-alist
2162 gnus-group-name-charset-group-alist)
2163 (gnus-buffer-live-p gnus-original-article-buffer))
2164 (when (nnmail-fetch-field "Newsgroups")
2165 (nnheader-replace-header "Newsgroups"
2166 (gnus-decode-newsgroups
2167 (with-current-buffer
2168 gnus-original-article-buffer
2169 (nnmail-fetch-field "Newsgroups"))
2170 gnus-newsgroup-name method)))
2171 (when (nnmail-fetch-field "Followup-To")
2172 (nnheader-replace-header "Followup-To"
2173 (gnus-decode-newsgroups
2174 (with-current-buffer
2175 gnus-original-article-buffer
2176 (nnmail-fetch-field "Followup-To"))
2177 gnus-newsgroup-name method))))))
2179 (defun article-de-quoted-unreadable (&optional force read-charset)
2180 "Translate a quoted-printable-encoded article.
2181 If FORCE, decode the article whether it is marked as quoted-printable
2183 If READ-CHARSET, ask for a coding system."
2184 (interactive (list 'force current-prefix-arg))
2186 (let ((buffer-read-only nil) type charset)
2187 (if (gnus-buffer-live-p gnus-original-article-buffer)
2188 (with-current-buffer gnus-original-article-buffer
2190 (gnus-fetch-field "content-transfer-encoding"))
2191 (let* ((ct (gnus-fetch-field "content-type"))
2194 (mail-header-parse-content-type ct)))))
2195 (setq charset (and ctl
2196 (mail-content-type-get ctl 'charset)))
2197 (if (stringp charset)
2198 (setq charset (intern (downcase charset)))))))
2200 (setq charset (mm-read-coding-system "Charset: " charset)))
2202 (setq charset gnus-newsgroup-charset))
2204 (and type (let ((case-fold-search t))
2205 (string-match "quoted-printable" type))))
2207 (quoted-printable-decode-region
2208 (point) (point-max) (mm-charset-to-coding-system charset))))))
2210 (defun article-de-base64-unreadable (&optional force read-charset)
2211 "Translate a base64 article.
2212 If FORCE, decode the article whether it is marked as base64 not.
2213 If READ-CHARSET, ask for a coding system."
2214 (interactive (list 'force current-prefix-arg))
2216 (let ((buffer-read-only nil) type charset)
2217 (if (gnus-buffer-live-p gnus-original-article-buffer)
2218 (with-current-buffer gnus-original-article-buffer
2220 (gnus-fetch-field "content-transfer-encoding"))
2221 (let* ((ct (gnus-fetch-field "content-type"))
2224 (mail-header-parse-content-type ct)))))
2225 (setq charset (and ctl
2226 (mail-content-type-get ctl 'charset)))
2227 (if (stringp charset)
2228 (setq charset (intern (downcase charset)))))))
2230 (setq charset (mm-read-coding-system "Charset: " charset)))
2232 (setq charset gnus-newsgroup-charset))
2234 (and type (let ((case-fold-search t))
2235 (string-match "base64" type))))
2238 (narrow-to-region (point) (point-max))
2239 (base64-decode-region (point-min) (point-max))
2240 (mm-decode-coding-region
2241 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2246 (defun article-decode-HZ ()
2247 "Translate a HZ-encoded article."
2251 (let ((buffer-read-only nil))
2252 (rfc1843-decode-region (point-min) (point-max)))))
2254 (defun article-wash-html (&optional read-charset)
2255 "Format an html article.
2256 If READ-CHARSET, ask for a coding system."
2259 (let ((buffer-read-only nil)
2261 (if (gnus-buffer-live-p gnus-original-article-buffer)
2262 (with-current-buffer gnus-original-article-buffer
2263 (let* ((ct (gnus-fetch-field "content-type"))
2266 (mail-header-parse-content-type ct)))))
2267 (setq charset (and ctl
2268 (mail-content-type-get ctl 'charset)))
2269 (if (stringp charset)
2270 (setq charset (intern (downcase charset)))))))
2272 (setq charset (mm-read-coding-system "Charset: " charset)))
2274 (setq charset gnus-newsgroup-charset))
2276 (save-window-excursion
2278 (narrow-to-region (point) (point-max))
2279 (funcall gnus-article-wash-function))))))
2281 (defun gnus-article-wash-html-with-w3 ()
2282 "Wash the current buffer with w3."
2284 (let ((w3-strict-width (window-width))
2285 (url-standalone-mode t)
2286 (w3-honor-stylesheets nil)
2287 (w3-delay-image-loads t))
2289 (w3-region (point-min) (point-max))
2292 (defun gnus-article-wash-html-with-w3m ()
2293 "Wash the current buffer with emacs-w3m."
2295 (let ((w3m-safe-url-regexp "\\`cid:")
2296 (w3m-display-inline-images mm-inline-text-html-with-images))
2297 (w3m-region (point) (point-max)))
2298 (setq mm-w3m-minor-mode t))
2300 (defun article-hide-list-identifiers ()
2301 "Remove list identifies from the Subject header.
2302 The `gnus-list-identifiers' variable specifies what to do."
2304 (let ((inhibit-point-motion-hooks t)
2305 (regexp (if (consp gnus-list-identifiers)
2306 (mapconcat 'identity gnus-list-identifiers " *\\|")
2307 gnus-list-identifiers))
2312 (article-narrow-to-head)
2313 (goto-char (point-min))
2314 (while (re-search-forward
2315 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2317 (delete-region (match-beginning 2) (match-end 0))
2318 (beginning-of-line))
2319 (when (re-search-forward
2320 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2321 (delete-region (match-beginning 1) (match-end 1))))))))
2323 (defun article-hide-pgp ()
2324 "Remove any PGP headers and signatures in the current article."
2328 (let ((inhibit-point-motion-hooks t)
2329 buffer-read-only beg end)
2331 ;; Hide the "header".
2332 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2333 (gnus-add-wash-type 'pgp)
2334 (delete-region (match-beginning 0) (match-end 0))
2335 ;; Remove armor headers (rfc2440 6.2)
2336 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2339 ;; Hide the actual signature.
2340 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2341 (setq end (1+ (match-beginning 0)))
2344 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2346 ;; Perhaps we shouldn't hide to the end of the buffer
2347 ;; if there is no end to the signature?
2349 ;; Hide "- " PGP quotation markers.
2351 (narrow-to-region beg end)
2352 (goto-char (point-min))
2353 (while (re-search-forward "^- " nil t)
2355 (match-beginning 0) (match-end 0)))
2357 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2359 (defun article-hide-pem (&optional arg)
2360 "Toggle hiding of any PEM headers and signatures in the current article.
2361 If given a negative prefix, always show; if given a positive prefix,
2363 (interactive (gnus-article-hidden-arg))
2364 (unless (gnus-article-check-hidden-text 'pem arg)
2366 (let (buffer-read-only end)
2367 (goto-char (point-min))
2368 ;; Hide the horrendously ugly "header".
2369 (when (and (search-forward
2370 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2372 (setq end (1+ (match-beginning 0))))
2373 (gnus-add-wash-type 'pem)
2374 (gnus-article-hide-text-type
2376 (if (search-forward "\n\n" nil t)
2380 ;; Hide the trailer as well
2381 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2383 (gnus-article-hide-text-type
2384 (match-beginning 0) (match-end 0) 'pem)))))))
2386 (defun article-strip-banner ()
2387 "Strip the banner specified by the `banner' group parameter."
2391 (let ((inhibit-point-motion-hooks t)
2392 (banner (gnus-parameter-banner gnus-newsgroup-name))
2393 (gnus-signature-limit nil)
2394 buffer-read-only beg end)
2398 ((eq banner 'signature)
2399 (when (gnus-article-narrow-to-signature)
2402 (delete-region (point) (point-max))))
2404 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2405 (while (re-search-forward banner nil t)
2406 (delete-region (match-beginning 0) (match-end 0)))))
2408 (while (re-search-forward banner nil t)
2409 (delete-region (match-beginning 0) (match-end 0))))))))))
2411 (defun article-babel ()
2412 "Translate article using an online translation service."
2416 (set-buffer gnus-article-buffer)
2417 (when (article-goto-body)
2418 (let* ((buffer-read-only nil)
2421 (orig (buffer-substring start end))
2422 (trans (babel-as-string orig)))
2424 (narrow-to-region start end)
2425 (delete-region start end)
2428 (defun article-hide-signature (&optional arg)
2429 "Hide the signature in the current article.
2430 If given a negative prefix, always show; if given a positive prefix,
2432 (interactive (gnus-article-hidden-arg))
2438 (article-goto-body))
2439 (goto-char (point-min)))
2440 (unless (gnus-article-check-hidden-text 'signature arg)
2441 (let ((buffer-read-only nil)
2443 (while (setq button (text-property-any button (point-max)
2445 'gnus-signature-toggle))
2446 (setq button (text-property-not-all button (point-max)
2448 'gnus-signature-toggle))
2449 (when (and button (not (eobp)))
2450 (gnus-article-hide-text-type
2452 (next-single-property-change (1+ button) 'mime-view-entity
2455 (gnus-set-mode-line 'article))
2457 (defun article-strip-headers-in-body ()
2458 "Strip offensive headers from bodies."
2462 (let ((case-fold-search t))
2463 (when (looking-at "x-no-archive:")
2464 (gnus-delete-line)))))
2466 (defun article-strip-leading-blank-lines ()
2467 "Remove all blank lines from the beginning of the article."
2470 (let ((inhibit-point-motion-hooks t)
2472 (when (article-goto-body)
2473 (while (and (not (eobp))
2474 (looking-at "[ \t]*$"))
2475 (gnus-delete-line))))))
2477 (defun article-narrow-to-head ()
2478 "Narrow the buffer to the head of the message.
2479 Point is left at the beginning of the narrowed-to region."
2481 (goto-char (point-min))
2482 (if (search-forward "\n\n" nil 1)
2485 (goto-char (point-min)))
2487 (defun article-goto-body ()
2488 "Place point at the start of the body."
2489 (goto-char (point-min))
2491 ;; This variable is only bound when dealing with separate
2493 (article-goto-body-goes-to-point-min-p
2495 ((search-forward "\n\n" nil t)
2498 (goto-char (point-max))
2501 (defun article-strip-multiple-blank-lines ()
2502 "Replace consecutive blank lines with one empty line."
2505 (let ((inhibit-point-motion-hooks t)
2507 ;; First make all blank lines empty.
2509 (while (re-search-forward "^[ \t]+$" nil t)
2510 (unless (gnus-annotation-in-region-p
2511 (match-beginning 0) (match-end 0))
2512 (replace-match "" nil t)))
2513 ;; Then replace multiple empty lines with a single empty line.
2515 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2516 (unless (gnus-annotation-in-region-p
2517 (match-beginning 0) (match-end 0))
2518 (delete-region (match-beginning 1) (match-end 1)))))))
2520 (defun article-strip-leading-space ()
2521 "Remove all white space from the beginning of the lines in the article."
2524 (let ((inhibit-point-motion-hooks t)
2527 (while (re-search-forward "^[ \t]+" nil t)
2528 (replace-match "" t t)))))
2530 (defun article-strip-trailing-space ()
2531 "Remove all white space from the end of the lines in the article."
2534 (let ((inhibit-point-motion-hooks t)
2537 (while (re-search-forward "[ \t]+$" nil t)
2538 (replace-match "" t t)))))
2540 (defun article-strip-blank-lines ()
2541 "Strip leading, trailing and multiple blank lines."
2543 (article-strip-leading-blank-lines)
2544 (article-remove-trailing-blank-lines)
2545 (article-strip-multiple-blank-lines))
2547 (defun article-strip-all-blank-lines ()
2548 "Strip all blank lines."
2551 (let ((inhibit-point-motion-hooks t)
2554 (while (re-search-forward "^[ \t]*\n" nil t)
2555 (replace-match "" t t)))))
2557 (defun gnus-article-narrow-to-signature ()
2558 "Narrow to the signature; return t if a signature is found, else nil."
2559 (let ((inhibit-point-motion-hooks t))
2560 (when (gnus-article-search-signature)
2562 ;; Check whether we have some limits to what we consider
2563 ;; to be a signature.
2564 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2565 (list gnus-signature-limit)))
2567 (while (setq limit (pop limits))
2568 (if (or (and (integerp limit)
2569 (< (- (point-max) (point)) limit))
2571 (< (count-lines (point) (point-max)) limit))
2572 (and (gnus-functionp limit)
2574 (and (stringp limit)
2575 (not (re-search-forward limit nil t))))
2576 () ; This limit did not succeed.
2580 (narrow-to-region (point) (point-max))
2583 (defun gnus-article-search-signature ()
2584 "Search the current buffer for the signature separator.
2585 Put point at the beginning of the signature separator."
2586 (let ((cur (point)))
2587 (goto-char (point-max))
2588 (if (if (stringp gnus-signature-separator)
2589 (re-search-backward gnus-signature-separator nil t)
2590 (let ((seps gnus-signature-separator))
2592 (not (re-search-backward (car seps) nil t)))
2599 (defun gnus-article-hidden-arg ()
2600 "Return the current prefix arg as a number, or 0 if no prefix."
2601 (list (if current-prefix-arg
2602 (prefix-numeric-value current-prefix-arg)
2605 (defun gnus-article-check-hidden-text (type arg)
2606 "Return nil if hiding is necessary.
2607 Arg can be nil or a number. nil and positive means hide, negative
2608 means show, 0 means toggle."
2611 (let ((hide (gnus-article-hidden-text-p type)))
2617 (gnus-article-show-hidden-text type)
2620 (if (eq hide 'hidden)
2622 (gnus-article-show-hidden-text type)
2626 (defun gnus-article-hidden-text-p (type)
2627 "Say whether the current buffer contains hidden text of type TYPE."
2628 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2630 (not (get-text-property pos 'invisible))
2631 (not (get-text-property pos 'dummy-invisible)))
2633 (text-property-any (1+ pos) (point-max) 'article-type type)))
2638 (defun gnus-article-show-hidden-text (type &optional dummy)
2639 "Show all hidden text of type TYPE.
2640 Originally it is hide instead of DUMMY."
2641 (let ((buffer-read-only nil)
2642 (inhibit-point-motion-hooks t))
2643 (gnus-remove-text-properties-when
2645 (point-min) (point-max)
2646 (cons 'article-type (cons type
2647 gnus-hidden-properties)))
2648 (gnus-delete-wash-type type)))
2650 (defconst article-time-units
2651 `((year . ,(* 365.25 24 60 60))
2652 (week . ,(* 7 24 60 60))
2653 (day . ,(* 24 60 60))
2657 "Mapping from time units to seconds.")
2659 (defun article-date-ut (&optional type highlight header)
2660 "Convert DATE date to universal time in the current article.
2661 If TYPE is `local', convert to local time; if it is `lapsed', output
2662 how much time has lapsed since DATE. For `lapsed', the value of
2663 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2664 should replace the \"Date:\" one, or should be added below it."
2665 (interactive (list 'ut t))
2666 (let* ((header (or header
2667 (and (eq 1 (point-min))
2668 (mail-header-date (save-excursion
2669 (set-buffer gnus-summary-buffer)
2670 gnus-current-headers)))
2671 (message-fetch-field "date")
2673 (date (if (vectorp header) (mail-header-date header)
2675 (inhibit-point-motion-hooks t)
2676 bface eface date-pos)
2677 (when (and date (not (string= date "")))
2680 (article-narrow-to-head)
2681 (when (or (and (eq type 'lapsed)
2682 gnus-article-date-lapsed-new-header
2683 ;; Attempt to get the face of X-Sent first.
2684 (re-search-forward "^X-Sent:[ \t]" nil t))
2685 (re-search-forward "^Date:[ \t]" nil t)
2686 ;; If Date is missing, try again for X-Sent.
2687 (re-search-forward "^X-Sent:[ \t]" nil t))
2688 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2689 date (or (get-text-property (gnus-point-at-bol)
2692 eface (get-text-property (1- (gnus-point-at-eol))
2694 (let ((buffer-read-only nil))
2695 ;; Delete any old X-Sent headers.
2696 (when (setq date-pos
2697 (text-property-any (point-min) (point-max)
2698 'article-date-lapsed t))
2699 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2700 (delete-region (match-beginning 0)
2701 (progn (forward-line 1) (point))))
2702 (goto-char (point-min))
2703 ;; Delete any old Date headers.
2704 (while (re-search-forward "^Date:[ \t]" nil t)
2706 (setq date-pos (match-beginning 0)))
2707 (unless (and (eq type 'lapsed)
2708 gnus-article-date-lapsed-new-header)
2709 (delete-region (match-beginning 0)
2710 (progn (message-next-header) (point)))))
2713 (goto-char date-pos)
2715 ;; Possibly, Date has been deleted.
2717 (when (and (eq type 'lapsed)
2718 gnus-article-date-lapsed-new-header
2719 (looking-at "Date:"))
2721 (goto-char (point-min)))
2722 (insert (article-make-date-line date type))
2723 (when (eq type 'lapsed)
2724 (put-text-property (gnus-point-at-bol) (point)
2725 'article-date-lapsed t))
2729 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2730 (put-text-property (match-beginning 1) (1+ (match-end 1))
2731 'original-date date)
2732 (put-text-property (match-beginning 1) (1+ (match-end 1))
2734 (put-text-property (match-beginning 2) (match-end 2)
2737 (defun article-make-date-line (date type)
2738 "Return a DATE line of TYPE."
2739 (unless (memq type '(local ut original user iso8601 lapsed english))
2740 (error "Unknown conversion type: %s" type))
2742 (let ((time (date-to-time date)))
2744 ;; Convert to the local timezone.
2746 (let ((tz (car (current-time-zone time))))
2747 (format "Date: %s %s%02d%02d" (current-time-string time)
2748 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2749 (/ (% (abs tz) 3600) 60))))
2750 ;; Convert to Universal Time.
2753 (current-time-string
2754 (let* ((e (parse-time-string date))
2755 (tm (apply 'encode-time e))
2757 (ls (- (cadr tm) (car (current-time-zone time)))))
2758 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2759 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2762 ;; Get the original date from the article.
2763 ((eq type 'original)
2764 (concat "Date: " (if (string-match "\n+$" date)
2765 (substring date 0 (match-beginning 0))
2767 ;; Let the user define the format.
2769 (if (gnus-functionp gnus-article-time-format)
2770 (funcall gnus-article-time-format time)
2773 (format-time-string gnus-article-time-format time))))
2776 (let ((tz (car (current-time-zone time))))
2779 (format-time-string "%Y%m%dT%H%M%S" time)
2780 (format "%s%02d%02d"
2781 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2782 (/ (% (abs tz) 3600) 60)))))
2783 ;; Do an X-Sent lapsed format.
2785 ;; If the date is seriously mangled, the timezone functions are
2786 ;; liable to bug out, so we ignore all errors.
2787 (let* ((now (current-time))
2788 (real-time (subtract-time now time))
2789 (real-sec (and real-time
2790 (+ (* (float (car real-time)) 65536)
2792 (sec (and real-time (abs real-sec)))
2802 ;; This is a bit convoluted, but basically we go
2803 ;; through the time units for years, weeks, etc,
2804 ;; and divide things to see whether that results
2805 ;; in positive answers.
2808 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2809 ;; The (remaining) seconds are too few to
2810 ;; be divided into this time unit.
2812 ;; It's big enough, so we output it.
2813 (setq sec (- sec (* num (cdr unit))))
2815 (concat (if prev ", " "") (int-to-string
2817 " " (symbol-name (car unit))
2818 (if (> num 1) "s" ""))
2820 article-time-units "")
2821 ;; If dates are odd, then it might appear like the
2822 ;; article was sent in the future.
2825 " in the future"))))))
2826 ;; Display the date in proper English
2828 (let ((dtime (decode-time time)))
2831 (number-to-string (nth 3 dtime))
2832 (let ((digit (% (nth 3 dtime) 10)))
2834 ((memq (nth 3 dtime) '(11 12 13)) "th")
2840 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2842 (number-to-string (nth 5 dtime))
2844 (format "%02d" (nth 2 dtime))
2846 (format "%02d" (nth 1 dtime)))))))
2848 (format "Date: %s (from Oort)" date))))
2850 (defun article-date-local (&optional highlight)
2851 "Convert the current article date to the local timezone."
2852 (interactive (list t))
2853 (article-date-ut 'local highlight))
2855 (defun article-date-english (&optional highlight)
2856 "Convert the current article date to something that is proper English."
2857 (interactive (list t))
2858 (article-date-ut 'english highlight))
2860 (defun article-date-original (&optional highlight)
2861 "Convert the current article date to what it was originally.
2862 This is only useful if you have used some other date conversion
2863 function and want to see what the date was before converting."
2864 (interactive (list t))
2865 (article-date-ut 'original highlight))
2867 (defun article-date-lapsed (&optional highlight)
2868 "Convert the current article date to time lapsed since it was sent."
2869 (interactive (list t))
2870 (article-date-ut 'lapsed highlight))
2872 (defun article-update-date-lapsed ()
2873 "Function to be run from a timer to update the lapsed time line."
2874 (let (deactivate-mark)
2879 (set-buffer (window-buffer w))
2880 (when (eq major-mode 'gnus-article-mode)
2881 (goto-char (point-min))
2882 (when (re-search-forward "^X-Sent:" nil t)
2883 (article-date-lapsed t))))
2886 (defun gnus-start-date-timer (&optional n)
2887 "Start a timer to update the X-Sent header in the article buffers.
2888 The numerical prefix says how frequently (in seconds) the function
2893 (gnus-stop-date-timer)
2894 (setq article-lapsed-timer
2895 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2897 (defun gnus-stop-date-timer ()
2898 "Stop the X-Sent timer."
2900 (when article-lapsed-timer
2901 (nnheader-cancel-timer article-lapsed-timer)
2902 (setq article-lapsed-timer nil)))
2904 (defun article-date-user (&optional highlight)
2905 "Convert the current article date to the user-defined format.
2906 This format is defined by the `gnus-article-time-format' variable."
2907 (interactive (list t))
2908 (article-date-ut 'user highlight))
2910 (defun article-date-iso8601 (&optional highlight)
2911 "Convert the current article date to ISO8601."
2912 (interactive (list t))
2913 (article-date-ut 'iso8601 highlight))
2915 ;; (defun article-show-all ()
2916 ;; "Show all hidden text in the article buffer."
2920 ;; (let ((buffer-read-only nil))
2921 ;; (gnus-article-unhide-text (point-min) (point-max))
2922 ;; (gnus-remove-text-with-property 'gnus-prev)
2923 ;; (gnus-remove-text-with-property 'gnus-next))))
2925 (defun article-show-all-headers ()
2926 "Show all hidden headers in the article buffer."
2931 (article-narrow-to-head)
2932 (let ((buffer-read-only nil))
2933 (gnus-article-unhide-text (point-min) (point-max))))))
2935 (defun article-remove-leading-whitespace ()
2936 "Remove excessive whitespace from all headers."
2940 (let ((buffer-read-only nil))
2941 (article-narrow-to-head)
2942 (goto-char (point-min))
2943 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2944 (delete-region (match-beginning 1) (match-end 1)))))))
2946 (defun article-emphasize (&optional arg)
2947 "Emphasize text according to `gnus-emphasis-alist'."
2948 (interactive (gnus-article-hidden-arg))
2949 (unless (gnus-article-check-hidden-text 'emphasis arg)
2953 (with-current-buffer gnus-summary-buffer
2954 gnus-article-emphasis-alist)
2956 gnus-emphasis-alist))
2957 (buffer-read-only nil)
2958 (props (append '(article-type emphasis)
2959 gnus-hidden-properties))
2960 regexp elem beg invisible visible face)
2963 (while (setq elem (pop alist))
2965 (setq regexp (car elem)
2966 invisible (nth 1 elem)
2967 visible (nth 2 elem)
2969 (while (re-search-forward regexp nil t)
2970 (when (and (match-beginning visible) (match-beginning invisible))
2971 (gnus-article-hide-text
2972 (match-beginning invisible) (match-end invisible) props)
2973 (gnus-article-unhide-text-type
2974 (match-beginning visible) (match-end visible) 'emphasis)
2975 (gnus-put-overlay-excluding-newlines
2976 (match-beginning visible) (match-end visible) 'face face)
2977 (gnus-add-wash-type 'emphasis)
2978 (goto-char (match-end invisible)))))))))
2980 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2981 "Setup newsgroup emphasis alist."
2982 (unless gnus-article-emphasis-alist
2983 (let ((name (and gnus-newsgroup-name
2984 (gnus-group-real-name gnus-newsgroup-name))))
2985 (make-local-variable 'gnus-article-emphasis-alist)
2986 (setq gnus-article-emphasis-alist
2988 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2989 (while (setq elem (pop alist))
2990 (when (and name (string-match (car elem) name))
2992 highlight (copy-sequence (cdr elem)))))
2994 (copy-sequence highlight-words)
2995 (if gnus-newsgroup-name
2996 (copy-sequence (gnus-group-find-parameter
2997 gnus-newsgroup-name 'highlight-words t)))
2998 gnus-emphasis-alist)))))
3001 (defvar gnus-summary-article-menu)
3002 (defvar gnus-summary-post-menu))
3004 ;;; Saving functions.
3006 (defun gnus-article-save (save-buffer file &optional num)
3007 "Save the currently selected article."
3008 (unless gnus-save-all-headers
3009 ;; Remove headers according to `gnus-saved-headers'.
3010 (let ((gnus-visible-headers
3011 (or gnus-saved-headers gnus-visible-headers))
3012 (gnus-article-buffer save-buffer))
3014 (set-buffer save-buffer)
3015 (article-hide-headers 1 t))))
3016 (save-window-excursion
3017 (if (not gnus-default-article-saver)
3018 (error "No default saver is defined")
3019 ;; !!! Magic! The saving functions all save
3020 ;; `gnus-save-article-buffer' (or so they think), but we
3021 ;; bind that variable to our save-buffer.
3022 (set-buffer gnus-article-buffer)
3023 (let* ((gnus-save-article-buffer save-buffer)
3026 ((not gnus-prompt-before-saving) 'default)
3027 ((eq gnus-prompt-before-saving 'always) nil)
3029 (gnus-number-of-articles-to-be-saved
3030 (when (eq gnus-prompt-before-saving t)
3032 (set-buffer gnus-article-current-summary)
3033 (funcall gnus-default-article-saver filename)))))
3035 (defun gnus-read-save-file-name (prompt &optional filename
3036 function group headers variable)
3038 (funcall function group headers (symbol-value variable)))
3043 ((eq filename 'default)
3049 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3052 (if (and gnus-number-of-articles-to-be-saved
3053 (> gnus-number-of-articles-to-be-saved 1))
3054 (format "these %d articles"
3055 gnus-number-of-articles-to-be-saved)
3058 ;; Let the split methods have their say.
3060 ;; No split name was found.
3063 (concat prompt " (default "
3064 (file-name-nondirectory default-name) ") ")
3065 (file-name-directory default-name)
3067 ;; A single group name is returned.
3068 ((stringp split-name)
3070 (funcall function split-name headers
3071 (symbol-value variable)))
3073 (concat prompt " (default "
3074 (file-name-nondirectory default-name) ") ")
3075 (file-name-directory default-name)
3077 ;; A single split name was found
3078 ((= 1 (length split-name))
3079 (let* ((name (expand-file-name
3081 gnus-article-save-directory))
3082 (dir (cond ((file-directory-p name)
3083 (file-name-as-directory name))
3084 ((file-exists-p name) name)
3085 (t gnus-article-save-directory))))
3087 (concat prompt " (default " name ") ")
3089 ;; A list of splits was found.
3091 (setq split-name (nreverse split-name))
3093 (let ((file-name-history
3094 (nconc split-name file-name-history)))
3098 (concat prompt " (`M-p' for defaults) ")
3099 gnus-article-save-directory
3101 gnus-article-save-directory)))
3102 (car (push result file-name-history)))))))
3103 ;; Create the directory.
3104 (gnus-make-directory (file-name-directory file))
3105 ;; If we have read a directory, we append the default file name.
3106 (when (file-directory-p file)
3107 (setq file (expand-file-name (file-name-nondirectory
3109 (file-name-as-directory file))))
3110 ;; Possibly translate some characters.
3111 (nnheader-translate-file-chars file))))))
3112 (gnus-make-directory (file-name-directory result))
3113 (set variable result)))
3115 (defun gnus-article-archive-name (group)
3116 "Return the first instance of an \"Archive-name\" in the current buffer."
3117 (let ((case-fold-search t))
3118 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3119 (nnheader-concat gnus-article-save-directory
3120 (match-string 1)))))
3122 (defun gnus-article-nndoc-name (group)
3123 "If GROUP is an nndoc group, return the name of the parent group."
3124 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3125 (gnus-group-get-parameter group 'save-article-group)))
3127 (defun gnus-summary-save-in-rmail (&optional filename)
3128 "Append this article to Rmail file.
3129 Optional argument FILENAME specifies file name.
3130 Directory to save to is default to `gnus-article-save-directory'."
3131 (setq filename (gnus-read-save-file-name
3132 "Save %s in rmail file:" filename
3133 gnus-rmail-save-name gnus-newsgroup-name
3134 gnus-current-headers 'gnus-newsgroup-last-rmail))
3135 (gnus-eval-in-buffer-window gnus-save-article-buffer
3139 (gnus-output-to-rmail filename))))
3142 (defun gnus-summary-save-in-mail (&optional filename)
3143 "Append this article to Unix mail file.
3144 Optional argument FILENAME specifies file name.
3145 Directory to save to is default to `gnus-article-save-directory'."
3146 (setq filename (gnus-read-save-file-name
3147 "Save %s in Unix mail file:" filename
3148 gnus-mail-save-name gnus-newsgroup-name
3149 gnus-current-headers 'gnus-newsgroup-last-mail))
3150 (gnus-eval-in-buffer-window gnus-save-article-buffer
3154 (if (and (file-readable-p filename)
3155 (mail-file-babyl-p filename))
3156 (rmail-output-to-rmail-file filename t)
3157 (gnus-output-to-mail filename)))))
3160 (defun gnus-summary-save-in-file (&optional filename overwrite)
3161 "Append this article to file.
3162 Optional argument FILENAME specifies file name.
3163 Directory to save to is default to `gnus-article-save-directory'."
3164 (setq filename (gnus-read-save-file-name
3165 "Save %s in file:" filename
3166 gnus-file-save-name gnus-newsgroup-name
3167 gnus-current-headers 'gnus-newsgroup-last-file))
3168 (gnus-eval-in-buffer-window gnus-save-article-buffer
3172 (when (and overwrite
3173 (file-exists-p filename))
3174 (delete-file filename))
3175 (gnus-output-to-file filename))))
3178 (defun gnus-summary-write-to-file (&optional filename)
3179 "Write this article to a file, overwriting it if the file exists.
3180 Optional argument FILENAME specifies file name.
3181 The directory to save in defaults to `gnus-article-save-directory'."
3182 (gnus-summary-save-in-file nil t))
3184 (defun gnus-summary-save-body-in-file (&optional filename)
3185 "Append this article body to a file.
3186 Optional argument FILENAME specifies file name.
3187 The directory to save in defaults to `gnus-article-save-directory'."
3188 (setq filename (gnus-read-save-file-name
3189 "Save %s body in file:" filename
3190 gnus-file-save-name gnus-newsgroup-name
3191 gnus-current-headers 'gnus-newsgroup-last-file))
3192 (gnus-eval-in-buffer-window gnus-save-article-buffer
3196 (when (article-goto-body)
3197 (narrow-to-region (point) (point-max)))
3198 (gnus-output-to-file filename))))
3201 (defun gnus-summary-save-in-pipe (&optional command)
3202 "Pipe this article to subprocess."
3204 (cond ((and (eq command 'default)
3205 gnus-last-shell-command)
3206 gnus-last-shell-command)
3211 "Shell command on %s: "
3212 (if (and gnus-number-of-articles-to-be-saved
3213 (> gnus-number-of-articles-to-be-saved 1))
3214 (format "these %d articles"
3215 gnus-number-of-articles-to-be-saved)
3217 gnus-last-shell-command))))
3218 (when (string-equal command "")
3219 (if gnus-last-shell-command
3220 (setq command gnus-last-shell-command)
3221 (error "A command is required")))
3222 (gnus-eval-in-buffer-window gnus-article-buffer
3225 (shell-command-on-region (point-min) (point-max) command nil)))
3226 (setq gnus-last-shell-command command))
3228 (defun gnus-summary-pipe-to-muttprint (&optional command)
3229 "Pipe this article to muttprint."
3230 (setq command (read-string
3231 "Print using command: " gnus-summary-muttprint-program
3232 nil gnus-summary-muttprint-program))
3233 (gnus-summary-save-in-pipe command))
3235 ;;; Article file names when saving.
3237 (defun gnus-capitalize-newsgroup (newsgroup)
3238 "Capitalize NEWSGROUP name."
3239 (when (not (zerop (length newsgroup)))
3240 (concat (char-to-string (upcase (aref newsgroup 0)))
3241 (substring newsgroup 1))))
3243 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3244 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3245 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3246 Otherwise, it is like ~/News/news/group/num."
3249 (concat (if (gnus-use-long-file-name 'not-save)
3250 (gnus-capitalize-newsgroup newsgroup)
3251 (gnus-newsgroup-directory-form newsgroup))
3252 "/" (int-to-string (mail-header-number headers)))
3253 gnus-article-save-directory)))
3255 (string-equal (file-name-directory default)
3256 (file-name-directory last-file))
3257 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3259 (or last-file default))))
3261 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3262 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3263 If variable `gnus-use-long-file-name' is non-nil, it is
3264 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3267 (concat (if (gnus-use-long-file-name 'not-save)
3269 (gnus-newsgroup-directory-form newsgroup))
3270 "/" (int-to-string (mail-header-number headers)))
3271 gnus-article-save-directory)))
3273 (string-equal (file-name-directory default)
3274 (file-name-directory last-file))
3275 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3277 (or last-file default))))
3279 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3280 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3281 If variable `gnus-use-long-file-name' is non-nil, it is
3282 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3285 (if (gnus-use-long-file-name 'not-save)
3288 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3290 gnus-article-save-directory)))
3292 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3293 "Generate file name from sender."
3294 (let ((from (mail-header-from headers)))
3296 (if (and from (string-match "\\([^ <]+\\)@" from))
3297 (match-string 1 from)
3299 gnus-article-save-directory)))
3301 (defun article-verify-x-pgp-sig ()
3304 (if (gnus-buffer-live-p gnus-original-article-buffer)
3305 (let ((sig (with-current-buffer gnus-original-article-buffer
3306 (gnus-fetch-field "X-PGP-Sig")))
3310 (mml2015-clear-verify-function))
3312 (insert-buffer gnus-original-article-buffer)
3313 (setq items (split-string sig))
3314 (message-narrow-to-head)
3315 (let ((inhibit-point-motion-hooks t)
3316 (case-fold-search t))
3317 ;; Don't verify multiple headers.
3318 (setq headers (mapconcat (lambda (header)
3320 (mail-fetch-field header) "\n"))
3321 (split-string (nth 1 items) ",") "")))
3322 (delete-region (point-min) (point-max))
3323 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3324 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3329 (if (looking-at "^-")
3332 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3333 (insert "Version: " (car items) "\n\n")
3334 (insert (mapconcat 'identity (cddr items) "\n"))
3335 (insert "\n-----END PGP SIGNATURE-----\n")
3336 (let ((mm-security-handle (list (format "multipart/signed"))))
3337 (mml2015-clean-buffer)
3338 (let ((coding-system-for-write (or gnus-newsgroup-charset
3340 (funcall (mml2015-clear-verify-function)))
3342 (or (mm-handle-multipart-ctl-parameter
3343 mm-security-handle 'gnus-details)
3344 (mm-handle-multipart-ctl-parameter
3345 mm-security-handle 'gnus-info)))))
3347 (let (buffer-read-only bface eface)
3349 (message-narrow-to-head)
3350 (goto-char (point-max))
3352 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3353 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3354 (message-remove-header "X-Gnus-PGP-Verify")
3355 (if (re-search-forward "^X-PGP-Sig:" nil t)
3357 (goto-char (point-max)))
3358 (narrow-to-region (point) (point))
3359 (insert "X-Gnus-PGP-Verify: " info "\n")
3360 (goto-char (point-min))
3363 (if (not (looking-at "^[ \t]"))
3367 (goto-char (point-min))
3368 (when (looking-at "\\([^:]+\\): *")
3369 (put-text-property (match-beginning 1) (1+ (match-end 1))
3371 (put-text-property (match-end 0) (point-max)
3372 'face eface)))))))))
3374 (defun article-verify-cancel-lock ()
3375 "Verify Cancel-Lock header."
3377 (if (gnus-buffer-live-p gnus-original-article-buffer)
3378 (canlock-verify gnus-original-article-buffer)))
3385 (setq afunc (car func)
3388 gfunc (intern (format "gnus-%s" func))))
3390 (when (fboundp afunc)
3391 `(lambda (&optional interactive &rest args)
3392 ,(documentation afunc t)
3393 (interactive (list t))
3395 (set-buffer gnus-article-buffer)
3397 (call-interactively ',afunc)
3398 (apply ',afunc args))))))))
3399 '(article-hide-headers
3400 article-verify-x-pgp-sig
3401 article-verify-cancel-lock
3402 article-hide-boring-headers
3403 article-toggle-headers
3404 article-treat-overstrike
3405 article-fill-long-lines
3406 article-capitalize-sentences
3408 article-remove-leading-whitespace
3409 article-display-x-face
3410 article-de-quoted-unreadable
3411 article-de-base64-unreadable
3414 article-hide-list-identifiers
3416 article-strip-banner
3419 article-hide-signature
3420 article-strip-headers-in-body
3421 article-remove-trailing-blank-lines
3422 article-strip-leading-blank-lines
3423 article-strip-multiple-blank-lines
3424 article-strip-leading-space
3425 article-strip-trailing-space
3426 article-strip-blank-lines
3427 article-strip-all-blank-lines
3429 article-date-english
3430 article-date-iso8601
3431 article-date-original
3433 article-decode-mime-words
3434 article-decode-charset
3435 article-decode-encoded-words
3439 article-treat-dumbquotes
3440 article-normalize-headers
3441 (article-show-all-headers . gnus-article-show-all-headers)
3442 ;; (article-show-all . gnus-article-show-all)
3446 ;;; Gnus article mode
3449 (put 'gnus-article-mode 'mode-class 'special)
3451 (gnus-define-keys gnus-article-mode-map
3452 " " gnus-article-goto-next-page
3453 "\177" gnus-article-goto-prev-page
3454 [delete] gnus-article-goto-prev-page
3455 [backspace] gnus-article-goto-prev-page
3456 "\C-c^" gnus-article-refer-article
3457 "h" gnus-article-show-summary
3458 "s" gnus-article-show-summary
3459 "\C-c\C-m" gnus-article-mail
3460 "?" gnus-article-describe-briefly
3461 "e" gnus-summary-edit-article
3462 "<" beginning-of-buffer
3464 "\C-c\C-i" gnus-info-find-node
3466 "R" gnus-article-reply-with-original
3467 "F" gnus-article-followup-with-original
3468 "\C-hk" gnus-article-describe-key
3469 "\C-hc" gnus-article-describe-key-briefly
3471 "\C-d" gnus-article-read-summary-keys
3472 "\M-*" gnus-article-read-summary-keys
3473 "\M-#" gnus-article-read-summary-keys
3474 "\M-^" gnus-article-read-summary-keys
3475 "\M-g" gnus-article-read-summary-keys)
3477 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3481 (push (char-to-string key) keys)
3483 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3484 (setq key (car elem))
3485 (when (and (> (length key) 0)
3486 (not (eq 'menu-bar (aref key 0)))
3487 (symbolp (lookup-key gnus-summary-mode-map key)))
3490 (unless (lookup-key gnus-article-mode-map key)
3491 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3493 (defun gnus-article-make-menu-bar ()
3494 (unless (boundp 'gnus-article-commands-menu)
3495 (gnus-summary-make-menu-bar))
3496 (gnus-turn-off-edit-menu 'article)
3497 (unless (boundp 'gnus-article-article-menu)
3499 gnus-article-article-menu gnus-article-mode-map ""
3501 ["Scroll forwards" gnus-article-goto-next-page t]
3502 ["Scroll backwards" gnus-article-goto-prev-page t]
3503 ["Show summary" gnus-article-show-summary t]
3504 ["Fetch Message-ID at point" gnus-article-refer-article t]
3505 ["Mail to address at point" gnus-article-mail t]
3506 ["Send a bug report" gnus-bug t]))
3509 gnus-article-treatment-menu gnus-article-mode-map ""
3510 ;; Fixme: this should use :active (and maybe :visible).
3512 ["Hide headers" gnus-article-toggle-headers t]
3513 ["Hide signature" gnus-article-hide-signature t]
3514 ["Hide citation" gnus-article-hide-citation t]
3515 ["Treat overstrike" gnus-article-treat-overstrike t]
3516 ["Remove carriage return" gnus-article-remove-cr t]
3517 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3518 ["Treat html" gnus-article-wash-html t]
3519 ["Decode HZ" gnus-article-decode-HZ t]))
3521 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3523 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3525 (gnus-run-hooks 'gnus-article-menu-hook)))
3527 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3530 (defun gnus-article-mode ()
3531 "Major mode for displaying an article.
3533 All normal editing commands are switched off.
3535 The following commands are available in addition to all summary mode
3537 \\<gnus-article-mode-map>
3538 \\[gnus-article-next-page]\t Scroll the article one page forwards
3539 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3540 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3541 \\[gnus-article-show-summary]\t Display the summary buffer
3542 \\[gnus-article-mail]\t Send a reply to the address near point
3543 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3544 \\[gnus-info-find-node]\t Go to the Gnus info node"
3546 (gnus-simplify-mode-line)
3547 (setq mode-name "Article")
3548 (setq major-mode 'gnus-article-mode)
3549 (make-local-variable 'minor-mode-alist)
3550 (unless (assq 'gnus-show-mime minor-mode-alist)
3551 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3552 (use-local-map gnus-article-mode-map)
3553 (when (gnus-visual-p 'article-menu 'menu)
3554 (gnus-article-make-menu-bar))
3555 (gnus-update-format-specifications nil 'article-mode)
3556 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3557 (make-local-variable 'gnus-page-broken)
3558 (make-local-variable 'gnus-button-marker-list)
3559 (make-local-variable 'gnus-article-current-summary)
3560 (make-local-variable 'gnus-article-mime-handles)
3561 (make-local-variable 'gnus-article-decoded-p)
3562 (make-local-variable 'gnus-article-mime-handle-alist)
3563 (make-local-variable 'gnus-article-wash-types)
3564 (make-local-variable 'gnus-article-image-alist)
3565 (make-local-variable 'gnus-article-charset)
3566 (make-local-variable 'gnus-article-ignored-charsets)
3567 (gnus-set-default-directory)
3568 (buffer-disable-undo)
3569 (setq buffer-read-only t)
3570 (set-syntax-table gnus-article-mode-syntax-table)
3571 (gnus-run-hooks 'gnus-article-mode-hook))
3573 (defun gnus-article-setup-buffer ()
3574 "Initialize the article buffer."
3575 (let* ((name (if gnus-single-article-buffer "*Article*"
3576 (concat "*Article " gnus-newsgroup-name "*")))
3578 (progn (string-match "\\*Article" name)
3579 (concat " *Original Article"
3580 (substring name (match-end 0))))))
3581 (setq gnus-article-buffer name)
3582 (setq gnus-original-article-buffer original)
3583 (setq gnus-article-mime-handle-alist nil)
3584 ;; This might be a variable local to the summary buffer.
3585 (unless gnus-single-article-buffer
3587 (set-buffer gnus-summary-buffer)
3588 (setq gnus-article-buffer name)
3589 (setq gnus-original-article-buffer original)
3590 (gnus-set-global-variables)))
3591 (gnus-article-setup-highlight-words)
3592 ;; Init original article buffer.
3594 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3595 (set-buffer-multibyte nil)
3596 (setq major-mode 'gnus-original-article-mode)
3597 (make-local-variable 'gnus-original-article))
3598 (if (get-buffer name)
3601 (buffer-disable-undo)
3602 (setq buffer-read-only t)
3603 (unless (eq major-mode 'gnus-article-mode)
3604 (gnus-article-mode))
3607 (set-buffer (gnus-get-buffer-create name))
3609 (make-local-variable 'gnus-summary-buffer)
3610 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3611 (current-buffer)))))
3613 ;; Set article window start at LINE, where LINE is the number of lines
3614 ;; from the head of the article.
3615 (defun gnus-article-set-window-start (&optional line)
3617 (gnus-get-buffer-window gnus-article-buffer t)
3619 (set-buffer gnus-article-buffer)
3620 (goto-char (point-min))
3623 (gnus-message 6 "Moved to bookmark")
3624 (search-forward "\n\n" nil t)
3628 ;;; @@ article filters
3631 (defun gnus-article-display-mime-message ()
3632 "Article display method for MIME message."
3633 ;; called from `gnus-original-article-buffer'.
3634 (let (charset all-headers)
3635 (with-current-buffer gnus-summary-buffer
3636 (setq charset default-mime-charset
3637 all-headers gnus-have-all-headers))
3638 (make-local-variable 'default-mime-charset)
3639 (setq default-mime-charset charset)
3640 (with-current-buffer (get-buffer-create gnus-article-buffer)
3641 (make-local-variable 'default-mime-charset)
3642 (setq default-mime-charset charset))
3643 (mime-display-message mime-message-structure
3644 gnus-article-buffer nil gnus-article-mode-map)
3646 (gnus-article-hide-headers nil -1)))
3647 (run-hooks 'gnus-mime-article-prepare-hook))
3649 (defun gnus-article-display-traditional-message ()
3650 "Article display method for traditional message."
3651 (set-buffer gnus-article-buffer)
3652 (let (buffer-read-only)
3654 (set-buffer-multibyte nil)
3655 (insert-buffer-substring gnus-original-article-buffer)
3656 (set-buffer-multibyte t)))
3658 (defun gnus-article-make-full-mail-header (&optional number charset)
3659 "Create a new mail header structure in a raw article buffer."
3660 (unless (and number charset)
3661 (save-current-buffer
3662 (set-buffer gnus-summary-buffer)
3664 (setq number (or (cdr gnus-article-current) 0)))
3666 (setq charset (or default-mime-charset 'x-ctext)))))
3667 (goto-char (point-min))
3668 (let ((header-end (if (search-forward "\n\n" nil t)
3670 (goto-char (point-max))))
3671 (chars (- (point-max) (point)))
3672 (lines (count-lines (point) (point-max)))
3673 (default-mime-charset charset)
3675 (narrow-to-region (point-min) header-end)
3676 (setq xref (std11-fetch-field "xref"))
3678 (make-full-mail-header
3680 (std11-fetch-field "subject")
3681 (std11-fetch-field "from")
3682 (std11-fetch-field "date")
3683 (std11-fetch-field "message-id")
3684 (std11-fetch-field "references")
3687 (when xref (concat "Xref: " xref)))
3690 (defun gnus-article-prepare (article &optional all-headers header)
3691 "Prepare ARTICLE in article mode buffer.
3692 ARTICLE should either be an article number or a Message-ID.
3693 If ARTICLE is an id, HEADER should be the article headers.
3694 If ALL-HEADERS is non-nil, no headers are hidden."
3696 ;; Make sure we start in a summary buffer.
3697 (unless (eq major-mode 'gnus-summary-mode)
3698 (set-buffer gnus-summary-buffer))
3699 (setq gnus-summary-buffer (current-buffer))
3700 (let* ((gnus-article (if header (mail-header-number header) article))
3701 (summary-buffer (current-buffer))
3702 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3703 (group gnus-newsgroup-name)
3706 (gnus-article-setup-buffer)
3707 (set-buffer gnus-article-buffer)
3708 ;; Deactivate active regions.
3709 (when (and (boundp 'transient-mark-mode)
3710 transient-mark-mode)
3711 (setq mark-active nil))
3712 (if (not (setq result (let ((buffer-read-only nil))
3713 (gnus-request-article-this-buffer
3715 ;; There is no such article.
3717 (when (and (numberp article)
3718 (not (memq article gnus-newsgroup-sparse)))
3719 (setq gnus-article-current
3720 (cons gnus-newsgroup-name article))
3721 (set-buffer gnus-summary-buffer)
3722 (setq gnus-current-article article)
3723 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3725 (gnus-summary-set-agent-mark article)
3726 (message "Message marked for downloading"))
3727 (gnus-summary-mark-article article gnus-canceled-mark)
3728 (unless (memq article gnus-newsgroup-sparse)
3729 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3730 (if (or (eq result 'pseudo)
3731 (eq result 'nneething))
3734 (set-buffer summary-buffer)
3735 (push article gnus-newsgroup-history)
3736 (setq gnus-last-article gnus-current-article
3737 gnus-current-article 0
3738 gnus-current-headers nil
3739 gnus-article-current nil)
3740 (if (eq result 'nneething)
3741 (gnus-configure-windows 'summary)
3742 (gnus-configure-windows 'article))
3743 (gnus-set-global-variables))
3744 (let ((gnus-article-mime-handle-alist-1
3745 gnus-article-mime-handle-alist))
3746 (gnus-set-mode-line 'article)))
3747 ;; The result from the `request' was an actual article -
3748 ;; or at least some text that is now displayed in the
3750 (when (and (numberp article)
3751 (not (eq article gnus-current-article)))
3752 ;; Seems like a new article has been selected.
3753 ;; `gnus-current-article' must be an article number.
3755 (set-buffer summary-buffer)
3756 (push article gnus-newsgroup-history)
3757 (setq gnus-last-article gnus-current-article
3758 gnus-current-article article
3759 gnus-current-headers
3760 (gnus-summary-article-header gnus-current-article)
3761 gnus-article-current
3762 (cons gnus-newsgroup-name gnus-current-article))
3763 (unless (vectorp gnus-current-headers)
3764 (setq gnus-current-headers nil))
3765 (gnus-summary-goto-subject gnus-current-article)
3766 (when (gnus-summary-show-thread)
3767 ;; If the summary buffer really was folded, the
3768 ;; previous goto may not actually have gone to
3769 ;; the right article, but the thread root instead.
3771 (gnus-summary-goto-subject gnus-current-article))
3772 (gnus-run-hooks 'gnus-mark-article-hook)
3773 (gnus-set-mode-line 'summary)
3774 (when (gnus-visual-p 'article-highlight 'highlight)
3775 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3776 ;; Set the global newsgroup variables here.
3777 (gnus-set-global-variables)
3778 (setq gnus-have-all-headers
3779 (or all-headers gnus-show-all-headers))))
3781 (gnus-configure-windows 'article))
3782 (when (or (numberp article)
3784 (gnus-article-prepare-display)
3786 (goto-char (point-min))
3787 (setq gnus-page-broken
3788 (when gnus-break-pages
3789 (gnus-narrow-to-page)
3791 (let ((gnus-article-mime-handle-alist-1
3792 gnus-article-mime-handle-alist))
3793 (gnus-set-mode-line 'article))
3795 (set-window-point (get-buffer-window (current-buffer)) (point))
3796 (gnus-configure-windows 'article)
3799 (defun gnus-article-prepare-mime-display (&optional number)
3800 (goto-char (point-min))
3801 (when (re-search-forward "^[^\t ]+:" nil t)
3802 (goto-char (match-beginning 0)))
3803 (let ((entity (if (eq 1 (point-min))
3804 (get-text-property 1 'mime-view-entity)
3805 (get-text-property (point) 'mime-view-entity)))
3806 last-entity child-entity next type)
3807 (setq child-entity (mime-entity-children entity))
3809 (setq last-entity (nth (1- (length child-entity))
3811 (setq last-entity entity))
3813 (narrow-to-region (point)
3814 (if (search-forward "\n\n" nil t)
3817 (gnus-treat-article 'head)
3818 (put-text-property (point-min) (point-max) 'article-treated-header t)
3819 (goto-char (point-max)))
3820 (while (and (not (eobp)) entity)
3821 (setq next (set-marker
3823 (next-single-property-change (point) 'mime-view-entity
3825 (let ((types (mime-entity-content-type entity)))
3826 (while (eq 'multipart (mime-content-type-primary-type types))
3827 (setq entity (car (mime-entity-children entity))
3828 types (mime-entity-content-type entity)))
3830 (setq type (format "%s/%s"
3831 (mime-content-type-primary-type types)
3832 (mime-content-type-subtype types)))))
3833 (if (string-equal type "message/rfc822")
3836 (let ((children (mime-entity-children entity))
3839 (setq last-children (nth (1- (length children)) children))
3842 (not (eq last-children
3843 (get-text-property next 'mime-view-entity)))
3845 (next-single-property-change next
3847 nil (point-max)))))))
3848 (setq next (next-single-property-change next 'mime-view-entity
3851 (narrow-to-region (point) next)
3852 (gnus-article-prepare-mime-display)
3853 (goto-char (point-max)))
3854 (setq entity (get-text-property (point) 'mime-view-entity)))
3856 (narrow-to-region (point) next)
3857 ;; Kludge. We have to count true number, but for now,
3858 ;; part number is here only to achieve `last'.
3859 (gnus-treat-article nil 1
3860 (if (eq entity last-entity)
3863 (goto-char (point-max)))
3864 (setq entity (get-text-property next 'mime-view-entity))))))
3867 (defun gnus-article-prepare-display ()
3868 "Make the current buffer look like a nice article."
3869 (let ((gnus-article-buffer (current-buffer))
3871 (unless (eq major-mode 'gnus-article-mode)
3872 (gnus-article-mode))
3873 (setq buffer-read-only nil
3874 gnus-button-marker-list nil
3875 gnus-article-wash-types nil
3876 gnus-article-image-alist nil)
3879 (static-if (featurep 'xemacs)
3880 (map-extents (lambda (extent maparg) (delete-extent extent)))
3881 (let ((lists (overlay-lists)))
3882 (dolist (overlay (nconc (car lists) (cdr lists)))
3883 (delete-overlay overlay)))))
3884 (gnus-run-hooks 'gnus-tmp-internal-hook))
3885 (set-buffer gnus-original-article-buffer)
3887 (setq mime-message-structure gnus-current-headers)
3888 (mime-buffer-entity-set-buffer-internal mime-message-structure
3889 gnus-original-article-buffer)
3890 (mime-entity-set-representation-type-internal mime-message-structure
3891 'mime-buffer-entity)
3892 (luna-send mime-message-structure 'initialize-instance
3893 mime-message-structure)
3895 (let (mime-display-header-hook mime-display-text/plain-hook)
3896 (funcall gnus-article-display-method-for-mime))
3897 (funcall gnus-article-display-method-for-traditional))
3898 ;; Call the treatment functions.
3899 (let ((inhibit-read-only t))
3903 (gnus-article-prepare-mime-display)
3904 (narrow-to-region (goto-char (point-min))
3905 (if (search-forward "\n\n" nil t)
3908 (gnus-treat-article 'head)
3909 (put-text-property (point-min) (point-max) 'article-treated-header t)
3910 (goto-char (point-max))
3912 (narrow-to-region (point) (point-max))
3913 (gnus-treat-article nil))
3914 (put-text-property (point-min) (point-max) 'read-only nil)))
3915 (gnus-run-hooks 'gnus-article-prepare-hook))
3917 (defun gnus-article-decode-article-as-default-mime-charset ()
3918 "Decode an article as `default-mime-charset'. It won't work if the
3919 value of the variable `gnus-show-mime' is non-nil."
3920 (unless gnus-show-mime
3921 (set (make-local-variable 'default-mime-charset)
3922 (with-current-buffer gnus-summary-buffer
3923 default-mime-charset))
3924 (decode-mime-charset-region (point-min) (point-max)
3925 default-mime-charset)))
3928 ;;; Gnus MIME viewing functions
3931 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3932 "Format of the MIME buttons.
3934 Valid specifiers include:
3936 %T MIME type, along with additional info
3937 %n The `name' parameter
3938 %d The description, if any
3939 %l The length of the encoded part
3940 %p The part identifier number
3941 %e Dots if the part isn't displayed
3943 General format specifiers can also be used. See
3944 (gnus)Formatting Variables.")
3946 (defvar gnus-mime-button-line-format-alist
3947 '((?t gnus-tmp-type ?s)
3948 (?T gnus-tmp-type-long ?s)
3949 (?n gnus-tmp-name ?s)
3950 (?d gnus-tmp-description ?s)
3952 (?l gnus-tmp-length ?d)
3953 (?e gnus-tmp-dots ?s)))
3955 (defvar gnus-mime-button-commands
3956 '((gnus-article-press-button "\r" "Toggle Display")
3957 (gnus-mime-view-part "v" "View Interactively...")
3958 (gnus-mime-view-part-as-type "t" "View As Type...")
3959 (gnus-mime-view-part-as-charset "C" "View As charset...")
3960 (gnus-mime-save-part "o" "Save...")
3961 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3962 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3963 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3964 (gnus-mime-internalize-part "E" "View Internally")
3965 (gnus-mime-externalize-part "e" "View Externally")
3966 (gnus-mime-print-part "p" "Print")
3967 (gnus-mime-pipe-part "|" "Pipe To Command...")
3968 (gnus-mime-action-on-part "." "Take action on the part")))
3970 (defun gnus-article-mime-part-status ()
3971 (with-current-buffer gnus-article-buffer
3972 (let ((entity (get-text-property (point-min) 'mime-view-entity))
3975 (setq children (mime-entity-children entity))
3976 (setq children (length children)))
3979 (format " (%d parts)" children))
3982 (defvar gnus-mime-button-map
3983 (let ((map (make-sparse-keymap)))
3984 (unless (>= (string-to-number emacs-version) 21)
3985 ;; XEmacs doesn't care.
3986 (set-keymap-parent map gnus-article-mode-map))
3987 (define-key map gnus-mouse-2 'gnus-article-push-button)
3988 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3989 (dolist (c gnus-mime-button-commands)
3990 (define-key map (cadr c) (car c)))
3993 (defun gnus-mime-button-menu (event)
3994 "Construct a context-sensitive menu of MIME commands."
3996 (save-window-excursion
3997 (let ((pos (event-start event)))
3998 (select-window (posn-window pos))
3999 (goto-char (posn-point pos))
4000 (gnus-article-check-buffer)
4001 (let ((response (x-popup-menu
4003 ("" ,@(mapcar (lambda (c)
4004 (cons (caddr c) (car c)))
4005 gnus-mime-button-commands))))))
4007 (call-interactively response))))))
4009 (defun gnus-mime-view-all-parts (&optional handles)
4010 "View all the MIME parts."
4012 (save-current-buffer
4013 (set-buffer gnus-article-buffer)
4014 (let ((handles (or handles gnus-article-mime-handles))
4015 (mail-parse-charset gnus-newsgroup-charset)
4016 (mail-parse-ignored-charsets
4017 (with-current-buffer gnus-summary-buffer
4018 gnus-newsgroup-ignored-charsets)))
4020 (mm-remove-parts handles)
4021 (goto-char (point-min))
4022 (or (search-forward "\n\n") (goto-char (point-max)))
4023 (let (buffer-read-only)
4024 (delete-region (point) (point-max))
4025 (mm-display-parts handles))))))
4027 (defun gnus-mime-save-part-and-strip ()
4028 "Save the MIME part under point then replace it with an external body."
4030 (gnus-article-check-buffer)
4031 (let* ((data (get-text-property (point) 'gnus-data))
4033 (handles gnus-article-mime-handles))
4034 (if (mm-multiple-handles gnus-article-mime-handles)
4035 (error "This function is not implemented"))
4036 (setq file (and data (mm-save-part data)))
4038 (with-current-buffer (mm-handle-buffer data)
4040 (insert "Content-Type: " (mm-handle-media-type data))
4041 (mml-insert-parameter-string (cdr (mm-handle-type data))
4044 (insert "Content-ID: " (message-make-message-id) "\n")
4045 (insert "Content-Transfer-Encoding: binary\n")
4048 (cdr (mm-make-handle nil
4049 `("message/external-body"
4050 (access-type . "LOCAL-FILE")
4052 (set-buffer gnus-summary-buffer)
4053 (gnus-article-edit-article
4056 (let ((mail-parse-charset (or gnus-article-charset
4057 ',gnus-newsgroup-charset))
4058 (mail-parse-ignored-charsets
4059 (or gnus-article-ignored-charsets
4060 ',gnus-newsgroup-ignored-charsets))
4061 (mbl mml-buffer-list))
4062 (setq mml-buffer-list nil)
4063 (insert-buffer gnus-original-article-buffer)
4064 (mime-to-mml ',handles)
4065 (setq gnus-article-mime-handles nil)
4066 (let ((mbl1 mml-buffer-list))
4067 (setq mml-buffer-list mbl)
4068 (set (make-local-variable 'mml-buffer-list) mbl1))
4069 ;; LOCAL argument of add-hook differs between GNU Emacs
4070 ;; and XEmacs. make-local-hook makes sure they are local.
4071 (make-local-hook 'kill-buffer-hook)
4072 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4073 `(lambda (no-highlight)
4074 (let ((mail-parse-charset (or gnus-article-charset
4075 ',gnus-newsgroup-charset))
4076 (message-options message-options)
4077 (message-options-set-recipient)
4078 (mail-parse-ignored-charsets
4079 (or gnus-article-ignored-charsets
4080 ',gnus-newsgroup-ignored-charsets)))
4082 (mml-destroy-buffers)
4083 (remove-hook 'kill-buffer-hook
4084 'mml-destroy-buffers t)
4085 (kill-local-variable 'mml-buffer-list))
4086 (gnus-summary-edit-article-done
4087 ,(or (mail-header-references gnus-current-headers) "")
4088 ,(gnus-group-read-only-p)
4089 ,gnus-summary-buffer no-highlight))))))
4091 (defun gnus-mime-save-part ()
4092 "Save the MIME part under point."
4094 (gnus-article-check-buffer)
4095 (let ((data (get-text-property (point) 'gnus-data)))
4097 (mm-save-part data))))
4099 (defun gnus-mime-pipe-part ()
4100 "Pipe the MIME part under point to a process."
4102 (gnus-article-check-buffer)
4103 (let ((data (get-text-property (point) 'gnus-data)))
4105 (mm-pipe-part data))))
4107 (defun gnus-mime-view-part ()
4108 "Interactively choose a viewing method for the MIME part under point."
4110 (gnus-article-check-buffer)
4111 (let ((data (get-text-property (point) 'gnus-data)))
4113 (setq gnus-article-mime-handles
4115 gnus-article-mime-handles (setq data (copy-sequence data))))
4116 (mm-interactively-view-part data))))
4118 (defun gnus-mime-view-part-as-type-internal ()
4119 (gnus-article-check-buffer)
4120 (let* ((name (mail-content-type-get
4121 (mm-handle-type (get-text-property (point) 'gnus-data))
4123 (def-type (and name (mm-default-file-encoding name))))
4124 (and def-type (cons def-type 0))))
4126 (defun gnus-mime-view-part-as-type (&optional mime-type)
4127 "Choose a MIME media type, and view the part as such."
4130 (setq mime-type (completing-read
4131 "View as MIME type: "
4132 (mapcar #'list (mailcap-mime-types))
4134 (gnus-mime-view-part-as-type-internal))))
4135 (gnus-article-check-buffer)
4136 (let ((handle (get-text-property (point) 'gnus-data)))
4139 (mm-make-handle (mm-handle-buffer handle)
4140 (cons mime-type (cdr (mm-handle-type handle)))
4141 (mm-handle-encoding handle)
4142 (mm-handle-undisplayer handle)
4143 (mm-handle-disposition handle)
4144 (mm-handle-description handle)
4146 (mm-handle-id handle)))
4147 (setq gnus-article-mime-handles
4148 (mm-merge-handles gnus-article-mime-handles handle))
4149 (gnus-mm-display-part handle))))
4151 (defun gnus-mime-copy-part (&optional handle)
4152 "Put the MIME part under point into a new buffer."
4154 (gnus-article-check-buffer)
4155 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4156 (contents (and handle (mm-get-part handle)))
4158 (file-name-nondirectory
4160 (mail-content-type-get (mm-handle-type handle) 'name)
4161 (mail-content-type-get (mm-handle-type handle)
4164 (buffer (and base (generate-new-buffer base))))
4166 (switch-to-buffer buffer)
4168 ;; We do it this way to make `normal-mode' set the appropriate mode.
4171 (setq buffer-file-name (expand-file-name base))
4173 (setq buffer-file-name nil))
4174 (goto-char (point-min)))))
4176 (defun gnus-mime-print-part (&optional handle)
4177 "Print the MIME part under point."
4179 (gnus-article-check-buffer)
4180 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4181 (contents (and handle (mm-get-part handle)))
4182 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
4183 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4188 (with-temp-file file
4190 (call-process shell-file-name nil
4191 (generate-new-buffer " *mm*")
4193 shell-command-switch
4195 printer file (mm-handle-type handle))))
4199 (gnus-print-buffer))))))
4201 (defun gnus-mime-inline-part (&optional handle arg)
4202 "Insert the MIME part under point into the current buffer."
4203 (interactive (list nil current-prefix-arg))
4204 (gnus-article-check-buffer)
4205 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4210 (if (and (not arg) (mm-handle-undisplayer handle))
4211 (mm-remove-part handle)
4212 (setq contents (mm-get-part handle))
4215 (setq charset (or (mail-content-type-get
4216 (mm-handle-type handle) 'charset)
4217 gnus-newsgroup-charset)))
4219 (if (mm-handle-undisplayer handle)
4220 (mm-remove-part handle))
4223 gnus-summary-show-article-charset-alist))
4224 (mm-read-coding-system "Charset: ")))))
4226 (mm-insert-inline handle
4228 (setq charset (mm-charset-to-coding-system
4230 (not (eq charset 'ascii)))
4231 (mm-decode-coding-string contents charset)
4235 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4236 "Insert the MIME part under point into the current buffer using the
4238 (interactive (list nil current-prefix-arg))
4239 (gnus-article-check-buffer)
4240 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4245 (if (mm-handle-undisplayer handle)
4246 (mm-remove-part handle))
4247 (let ((gnus-newsgroup-charset
4249 gnus-summary-show-article-charset-alist))
4250 (mm-read-coding-system "Charset: ")))
4251 (gnus-newsgroup-ignored-charsets 'gnus-all))
4252 (gnus-article-press-button)))))
4254 (defun gnus-mime-externalize-part (&optional handle)
4255 "View the MIME part under point with an external viewer."
4257 (gnus-article-check-buffer)
4258 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4259 (mm-user-display-methods nil)
4260 (mm-inlined-types nil)
4261 (mail-parse-charset gnus-newsgroup-charset)
4262 (mail-parse-ignored-charsets
4263 (save-excursion (set-buffer gnus-summary-buffer)
4264 gnus-newsgroup-ignored-charsets)))
4266 (if (mm-handle-undisplayer handle)
4267 (mm-remove-part handle)
4268 (mm-display-part handle)))))
4270 (defun gnus-mime-internalize-part (&optional handle)
4271 "View the MIME part under point with an internal viewer.
4272 If no internal viewer is available, use an external viewer."
4274 (gnus-article-check-buffer)
4275 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4276 (mm-inlined-types '(".*"))
4277 (mm-inline-large-images t)
4278 (mail-parse-charset gnus-newsgroup-charset)
4279 (mail-parse-ignored-charsets
4280 (save-excursion (set-buffer gnus-summary-buffer)
4281 gnus-newsgroup-ignored-charsets)))
4283 (if (mm-handle-undisplayer handle)
4284 (mm-remove-part handle)
4285 (mm-display-part handle)))))
4287 (defun gnus-mime-action-on-part (&optional action)
4288 "Do something with the MIME attachment at \(point\)."
4290 (list (completing-read "Action: " gnus-mime-action-alist)))
4291 (gnus-article-check-buffer)
4292 (let ((action-pair (assoc action gnus-mime-action-alist)))
4294 (funcall (cdr action-pair)))))
4296 (defun gnus-article-part-wrapper (n function)
4297 (save-current-buffer
4298 (set-buffer gnus-article-buffer)
4299 (when (> n (length gnus-article-mime-handle-alist))
4300 (error "No such part"))
4301 (gnus-article-goto-part n)
4302 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4303 (funcall function handle))))
4305 (defun gnus-article-pipe-part (n)
4306 "Pipe MIME part N, which is the numerical prefix."
4308 (gnus-article-part-wrapper n 'mm-pipe-part))
4310 (defun gnus-article-save-part (n)
4311 "Save MIME part N, which is the numerical prefix."
4313 (gnus-article-part-wrapper n 'mm-save-part))
4315 (defun gnus-article-interactively-view-part (n)
4316 "View MIME part N interactively, which is the numerical prefix."
4318 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4320 (defun gnus-article-copy-part (n)
4321 "Copy MIME part N, which is the numerical prefix."
4323 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4325 (defun gnus-article-view-part-as-charset (n)
4326 "Copy MIME part N, which is the numerical prefix."
4328 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4330 (defun gnus-article-externalize-part (n)
4331 "View MIME part N externally, which is the numerical prefix."
4333 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
4335 (defun gnus-article-inline-part (n)
4336 "Inline MIME part N, which is the numerical prefix."
4338 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4340 (defun gnus-article-mime-match-handle-first (condition)
4342 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4343 (while (setq ihandle (pop alist))
4345 ((functionp condition)
4346 (funcall condition (cdr ihandle)))
4347 ((eq condition 'undisplayed)
4348 (not (or (mm-handle-undisplayer (cdr ihandle))
4349 (equal (mm-handle-media-type (cdr ihandle))
4350 "multipart/alternative"))))
4351 ((eq condition 'undisplayed-alternative)
4352 (not (mm-handle-undisplayer (cdr ihandle))))
4354 (gnus-article-goto-part (car ihandle))
4355 (or (not n) (< (car ihandle) n)))
4356 (setq n (car ihandle))))
4360 (defun gnus-article-view-part (&optional n)
4361 "View MIME part N, which is the numerical prefix."
4363 (save-current-buffer
4364 (set-buffer gnus-article-buffer)
4365 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4366 gnus-article-mime-match-handle-function)))
4367 (when (> n (length gnus-article-mime-handle-alist))
4368 (error "No such part"))
4369 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4370 (when (gnus-article-goto-part n)
4371 (if (equal (car handle) "multipart/alternative")
4372 (gnus-article-press-button)
4373 (when (eq (gnus-mm-display-part handle) 'internal)
4374 (gnus-set-window-start)))))))
4376 (defsubst gnus-article-mime-total-parts ()
4377 (if (bufferp (car gnus-article-mime-handles))
4379 (1- (length gnus-article-mime-handles))))
4381 (defun gnus-mm-display-part (handle)
4382 "Display HANDLE and fix MIME button."
4383 (let ((id (get-text-property (point) 'gnus-part))
4388 (let ((window (selected-window))
4389 (mail-parse-charset gnus-newsgroup-charset)
4390 (mail-parse-ignored-charsets
4391 (if (gnus-buffer-live-p gnus-summary-buffer)
4393 (set-buffer gnus-summary-buffer)
4394 gnus-newsgroup-ignored-charsets)
4398 (let ((win (gnus-get-buffer-window (current-buffer) t))
4401 (select-window win))
4404 (if (mm-handle-displayed-p handle)
4405 ;; This will remove the part.
4406 (mm-display-part handle)
4408 (narrow-to-region (point)
4409 (if (eobp) (point) (1+ (point))))
4410 (mm-display-part handle)
4411 ;; We narrow to the part itself and
4412 ;; then call the treatment functions.
4413 (goto-char (point-min))
4415 (narrow-to-region (point) (point-max))
4418 (gnus-article-mime-total-parts)
4419 (mm-handle-media-type handle)))))
4420 (if (window-live-p window)
4421 (select-window window)))))
4423 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4424 (gnus-insert-mime-button
4425 handle id (list (mm-handle-displayed-p handle)))
4426 (goto-char point))))
4428 (defun gnus-article-goto-part (n)
4429 "Go to MIME part N."
4430 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4432 (goto-char point))))
4434 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4435 (let ((gnus-tmp-name
4436 (or (mail-content-type-get (mm-handle-type handle) 'name)
4437 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4438 (mail-content-type-get (mm-handle-type handle) 'url)
4440 (gnus-tmp-type (mm-handle-media-type handle))
4441 (gnus-tmp-description
4442 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4445 (if (if displayed (car displayed)
4446 (mm-handle-displayed-p handle))
4448 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4450 gnus-tmp-type-long b e)
4451 (when (string-match ".*/" gnus-tmp-name)
4452 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4453 (setq gnus-tmp-type-long (concat gnus-tmp-type
4454 (and (not (equal gnus-tmp-name ""))
4455 (concat "; " gnus-tmp-name))))
4456 (unless (equal gnus-tmp-description "")
4457 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4462 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4463 `(,@(gnus-local-map-property gnus-mime-button-map)
4464 gnus-callback gnus-mm-display-part
4465 gnus-part ,gnus-tmp-id
4466 article-type annotation
4469 (widget-convert-button
4472 :action 'gnus-widget-press-button
4473 :button-keymap gnus-mime-button-map
4475 (lambda (widget/window &optional overlay pos)
4476 ;; Needed to properly clear the message due to a bug in
4477 ;; wid-edit (XEmacs only).
4478 (if (boundp 'help-echo-owns-message)
4479 (setq help-echo-owns-message t))
4481 "%S: %s the MIME part; %S: more options"
4482 (aref gnus-mouse-2 0)
4483 ;; XEmacs will get a single widget arg; Emacs 21 will get
4484 ;; window, overlay, position.
4485 (if (mm-handle-displayed-p
4487 (with-current-buffer (gnus-overlay-buffer overlay)
4488 (widget-get (widget-at (gnus-overlay-start overlay))
4490 (widget-get widget/window :mime-handle)))
4492 (aref gnus-down-mouse-3 0))))))
4494 (defun gnus-widget-press-button (elems el)
4495 (goto-char (widget-get elems :from))
4496 (gnus-article-press-button))
4498 (defvar gnus-displaying-mime nil)
4500 (defun gnus-display-mime (&optional ihandles)
4501 "Display the MIME parts."
4503 (save-selected-window
4504 (let ((window (get-buffer-window gnus-article-buffer))
4507 (select-window window)
4508 ;; We have to do this since selecting the window
4509 ;; may change the point. So we set the window point.
4510 (set-window-point window point)))
4511 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4512 buffer-read-only handle name type b e display)
4513 (when (and (not ihandles)
4514 (not gnus-displaying-mime))
4515 ;; Top-level call; we clean up.
4516 (when gnus-article-mime-handles
4517 (mm-destroy-parts gnus-article-mime-handles)
4518 (setq gnus-article-mime-handle-alist nil));; A trick.
4519 (setq gnus-article-mime-handles handles)
4520 ;; We allow users to glean info from the handles.
4521 (when gnus-article-mime-part-function
4522 (gnus-mime-part-function handles)))
4524 (or (not (stringp (car handles)))
4527 (when (and (not ihandles)
4528 (not gnus-displaying-mime))
4529 ;; Clean up for mime parts.
4531 (delete-region (point) (point-max)))
4532 (let ((gnus-displaying-mime t))
4533 (gnus-mime-display-part handles)))
4536 (narrow-to-region (point) (point-max))
4537 (gnus-treat-article nil 1 1)
4540 ;; Highlight the headers.
4544 (narrow-to-region (point-min) (point))
4545 (gnus-treat-article 'head))))))))
4547 (defvar gnus-mime-display-multipart-as-mixed nil)
4548 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4549 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4551 (defun gnus-mime-display-part (handle)
4554 ((not (stringp (car handle)))
4555 (gnus-mime-display-single handle))
4556 ;; User-defined multipart
4557 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4558 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4560 ;; multipart/alternative
4561 ((and (equal (car handle) "multipart/alternative")
4562 (not (or gnus-mime-display-multipart-as-mixed
4563 gnus-mime-display-multipart-alternative-as-mixed)))
4564 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4565 (push (cons id handle) gnus-article-mime-handle-alist)
4566 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4567 ;; multipart/related
4568 ((and (equal (car handle) "multipart/related")
4569 (not (or gnus-mime-display-multipart-as-mixed
4570 gnus-mime-display-multipart-related-as-mixed)))
4571 ;;;!!!We should find the start part, but we just default
4572 ;;;!!!to the first part.
4573 ;;(gnus-mime-display-part (cadr handle))
4574 ;;;!!! Most multipart/related is an HTML message plus images.
4575 ;;;!!! Unfortunately we are unable to let W3 display those
4576 ;;;!!! included images, so we just display it as a mixed multipart.
4577 ;;(gnus-mime-display-mixed (cdr handle))
4578 ;;;!!! No, w3 can display everything just fine.
4579 (gnus-mime-display-part (cadr handle)))
4580 ((equal (car handle) "multipart/signed")
4581 (gnus-add-wash-type 'signed)
4582 (gnus-mime-display-security handle))
4583 ((equal (car handle) "multipart/encrypted")
4584 (gnus-add-wash-type 'encrypted)
4585 (gnus-mime-display-security handle))
4586 ;; Other multiparts are handled like multipart/mixed.
4588 (gnus-mime-display-mixed (cdr handle)))))
4590 (defun gnus-mime-part-function (handles)
4591 (if (stringp (car handles))
4592 (mapcar 'gnus-mime-part-function (cdr handles))
4593 (funcall gnus-article-mime-part-function handles)))
4595 (defun gnus-mime-display-mixed (handles)
4596 (mapcar 'gnus-mime-display-part handles))
4598 (defun gnus-mime-display-single (handle)
4599 (let ((type (mm-handle-media-type handle))
4600 (ignored gnus-ignored-mime-types)
4607 (when (string-match (pop ignored) type)
4608 (throw 'ignored nil)))
4609 (if (and (setq not-attachment
4610 (and (not (mm-inline-override-p handle))
4611 (or (not (mm-handle-disposition handle))
4612 (equal (car (mm-handle-disposition handle))
4614 (mm-attachment-override-p handle))))
4615 (mm-automatic-display-p handle)
4617 (mm-inlinable-p handle)
4618 (mm-inlined-p handle))
4619 (mm-automatic-external-display-p type)))
4621 (when (equal (mm-handle-media-supertype handle) "text")
4623 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4625 (push (cons id handle) gnus-article-mime-handle-alist)
4626 (when (or (not display)
4627 (not (gnus-unbuttonized-mime-type-p type)))
4628 ;(gnus-article-insert-newline)
4629 (gnus-insert-mime-button
4630 handle id (list (or display (and not-attachment text))))
4631 (gnus-article-insert-newline)
4632 ;(gnus-article-insert-newline)
4633 ;; Remember modify the number of forward lines.
4641 (let ((mail-parse-charset gnus-newsgroup-charset)
4642 (mail-parse-ignored-charsets
4643 (save-excursion (condition-case ()
4644 (set-buffer gnus-summary-buffer)
4646 gnus-newsgroup-ignored-charsets)))
4647 (mm-display-part handle t))
4648 (goto-char (point-max)))
4649 ((and text not-attachment)
4653 (gnus-article-insert-newline)
4654 (mm-insert-inline handle (mm-get-part handle))
4655 (goto-char (point-max))))
4659 (narrow-to-region beg (point))
4662 (gnus-article-mime-total-parts)
4663 (mm-handle-media-type handle)))))))))
4665 (defun gnus-unbuttonized-mime-type-p (type)
4666 "Say whether TYPE is to be unbuttonized."
4667 (unless gnus-inhibit-mime-unbuttonizing
4669 (let ((types gnus-unbuttonized-mime-types))
4671 (when (string-match (pop types) type)
4672 (throw 'found t)))))
4674 (let ((types gnus-buttonized-mime-types))
4676 (when (string-match (pop types) type)
4677 (throw 'found t)))))))))
4679 (defun gnus-article-insert-newline ()
4680 "Insert a newline, but mark it as undeletable."
4681 (gnus-put-text-property
4682 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4684 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4685 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4688 handle buffer-read-only from props begend not-pref)
4689 (save-window-excursion
4692 (narrow-to-region (car ibegend)
4695 (goto-char (car ibegend))
4698 (delete-region (point-min) (point-max))
4699 (mm-remove-parts handles))
4700 (setq begend (list (point-marker)))
4702 (unless (setq not-pref (cadr (member preferred ihandles)))
4703 (setq not-pref (car ihandles)))
4706 (not (gnus-unbuttonized-mime-type-p
4707 "multipart/alternative")))
4708 (gnus-add-text-properties
4711 (insert (format "%d. " id))
4715 (unless ,(not ibegend)
4716 (setq gnus-article-mime-handle-alist
4717 ',gnus-article-mime-handle-alist))
4718 (gnus-mime-display-alternative
4719 ',ihandles ',not-pref ',begend ,id))
4720 ,@(gnus-local-map-property gnus-mime-button-map)
4721 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4722 face ,gnus-article-button-face
4725 (widget-convert-button 'link from (point)
4726 :action 'gnus-widget-press-button
4727 :button-keymap gnus-widget-button-keymap)
4729 (while (setq handle (pop handles))
4730 (gnus-add-text-properties
4733 (insert (format "(%c) %-18s"
4734 (if (equal handle preferred) ?* ? )
4735 (mm-handle-media-type handle)))
4739 (unless ,(not ibegend)
4740 (setq gnus-article-mime-handle-alist
4741 ',gnus-article-mime-handle-alist))
4742 (gnus-mime-display-alternative
4743 ',ihandles ',handle ',begend ,id))
4744 ,@(gnus-local-map-property gnus-mime-button-map)
4745 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4746 face ,gnus-article-button-face
4749 (widget-convert-button 'link from (point)
4750 :action 'gnus-widget-press-button
4751 :button-keymap gnus-widget-button-keymap)
4755 (if (stringp (car preferred))
4756 (gnus-display-mime preferred)
4757 (let ((mail-parse-charset gnus-newsgroup-charset)
4758 (mail-parse-ignored-charsets
4759 (save-excursion (set-buffer gnus-summary-buffer)
4760 gnus-newsgroup-ignored-charsets)))
4761 (mm-display-part preferred)
4765 (narrow-to-region (car begend) (point-max))
4767 nil (length gnus-article-mime-handle-alist)
4768 (gnus-article-mime-total-parts)
4769 (mm-handle-media-type handle))))))
4770 (goto-char (point-max))
4771 (setcdr begend (point-marker)))))
4773 (goto-char point))))
4775 (defconst gnus-article-wash-status-strings
4776 (let ((alist '((cite "c" "Possible hidden citation text"
4777 " " "All citation text visible")
4778 (headers "h" "Hidden headers"
4779 " " "All headers visible.")
4780 (pgp "p" "Encrypted or signed message status hidden"
4781 " " "No hidden encryption nor digital signature status")
4782 (signature "s" "Signature has been hidden"
4783 " " "Signature is visible")
4784 (overstrike "o" "Overstrike (^H) characters applied"
4785 " " "No overstrike characters applied")
4786 (gnus-show-mime "m" "Mime processing is activated"
4787 " " "Mime processing is not activated")
4788 (emphasis "e" "/*_Emphasis_*/ characters applied"
4789 " " "No /*_emphasis_*/ characters applied")))
4791 (dolist (entry alist result)
4792 (let ((key (nth 0 entry))
4793 (on (copy-sequence (nth 1 entry)))
4794 (on-help (nth 2 entry))
4795 (off (copy-sequence (nth 3 entry)))
4796 (off-help (nth 4 entry)))
4797 (put-text-property 0 1 'help-echo on-help on)
4798 (put-text-property 0 1 'help-echo off-help off)
4799 (push (list key on off) result))))
4800 "Alist of strings describing wash status in the mode line.
4801 Each entry has the form (KEY ON OF), where the KEY is a symbol
4802 representing the particular washing function, ON is the string to use
4803 in the article mode line when the washing function is active, and OFF
4804 is the string to use when it is inactive.")
4806 (defun gnus-article-wash-status-entry (key value)
4807 (let ((entry (assoc key gnus-article-wash-status-strings)))
4808 (if value (nth 1 entry) (nth 2 entry))))
4810 (defun gnus-article-wash-status ()
4811 "Return a string which display status of article washing."
4813 (set-buffer gnus-article-buffer)
4814 (let ((cite (memq 'cite gnus-article-wash-types))
4815 (headers (memq 'headers gnus-article-wash-types))
4816 (boring (memq 'boring-headers gnus-article-wash-types))
4817 (pgp (memq 'pgp gnus-article-wash-types))
4818 (pem (memq 'pem gnus-article-wash-types))
4819 (signed (memq 'signed gnus-article-wash-types))
4820 (encrypted (memq 'encrypted gnus-article-wash-types))
4821 (signature (memq 'signature gnus-article-wash-types))
4822 (overstrike (memq 'overstrike gnus-article-wash-types))
4823 (emphasis (memq 'emphasis gnus-article-wash-types)))
4825 (gnus-article-wash-status-entry 'cite cite)
4826 (gnus-article-wash-status-entry 'headers (or headers boring))
4827 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4828 (gnus-article-wash-status-entry 'signature signature)
4829 (gnus-article-wash-status-entry 'overstrike overstrike)
4830 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4831 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4833 (defun gnus-add-wash-type (type)
4834 "Add a washing of TYPE to the current status."
4835 (add-to-list 'gnus-article-wash-types type))
4837 (defun gnus-delete-wash-type (type)
4838 "Add a washing of TYPE to the current status."
4839 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4841 (defun gnus-add-image (category image)
4842 "Add IMAGE of CATEGORY to the list of displayed images."
4843 (let ((entry (assq category gnus-article-image-alist)))
4845 (setq entry (list category))
4846 (push entry gnus-article-image-alist))
4847 (nconc entry (list image))))
4849 (defun gnus-delete-images (category)
4850 "Delete all images in CATEGORY."
4851 (let ((entry (assq category gnus-article-image-alist)))
4852 (dolist (image (cdr entry))
4853 (gnus-remove-image image))
4854 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4855 (gnus-delete-wash-type category)))
4857 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4859 (defun gnus-article-maybe-hide-headers ()
4860 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4861 Provided for backwards compatibility."
4862 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4863 (not (save-excursion (set-buffer gnus-summary-buffer)
4864 gnus-have-all-headers)))
4865 (not gnus-inhibit-hiding))
4866 (gnus-article-hide-headers)))
4870 (defun gnus-output-to-file (file-name)
4871 "Append the current article to a file named FILE-NAME."
4872 (let ((artbuf (current-buffer)))
4874 (insert-buffer-substring artbuf)
4875 ;; Append newline at end of the buffer as separator, and then
4877 (goto-char (point-max))
4879 (let ((file-name-coding-system nnmail-pathname-coding-system)
4880 (pathname-coding-system nnmail-pathname-coding-system))
4881 (write-region-as-binary (point-min) (point-max) file-name 'append))
4884 (defun gnus-narrow-to-page (&optional arg)
4885 "Narrow the article buffer to a page.
4886 If given a numerical ARG, move forward ARG pages."
4888 (setq arg (if arg (prefix-numeric-value arg) 0))
4890 (set-buffer gnus-article-buffer)
4891 (goto-char (point-min))
4893 ;; Remove any old next/prev buttons.
4894 (when (gnus-visual-p 'page-marker)
4895 (let ((buffer-read-only nil))
4896 (gnus-remove-text-with-property 'gnus-prev)
4897 (gnus-remove-text-with-property 'gnus-next)))
4900 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4902 (re-search-forward page-delimiter nil 'move arg)))
4903 (goto-char (match-end 0)))
4906 (if (re-search-forward page-delimiter nil 'move)
4909 (when (and (gnus-visual-p 'page-marker)
4910 (not (= (point-min) 1)))
4912 (goto-char (point-min))
4913 (gnus-insert-prev-page-button)))
4914 (when (and (gnus-visual-p 'page-marker)
4915 (< (+ (point-max) 2) (buffer-size)))
4917 (goto-char (point-max))
4918 (gnus-insert-next-page-button)))))
4920 ;; Article mode commands
4922 (defun gnus-article-goto-next-page ()
4923 "Show the next page of the article."
4925 (when (gnus-article-next-page)
4926 (goto-char (point-min))
4927 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4929 (defun gnus-article-goto-prev-page ()
4930 "Show the next page of the article."
4932 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4933 (gnus-article-prev-page nil)))
4935 (defun gnus-article-next-page (&optional lines)
4936 "Show the next page of the current article.
4937 If end of article, return non-nil. Otherwise return nil.
4938 Argument LINES specifies lines to be scrolled up."
4940 (let ((start (window-start))
4941 end-of-buffer end-of-page)
4943 (move-to-window-line -1)
4944 (if (<= (point) start)
4947 (setq start (point)))
4950 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4951 (and (pos-visible-in-window-p)
4952 (setq end-of-buffer t)))
4954 (setq end-of-page t)))
4956 (move-to-window-line lines)
4957 (unless (search-backward "\n\n" nil t)
4958 (setq start (point)))))
4959 (cond (end-of-buffer t)
4961 (gnus-narrow-to-page 1)
4965 (set-window-start (selected-window) start)
4966 (let (window-pixel-scroll-increment)
4970 (defun gnus-article-prev-page (&optional lines)
4971 "Show previous page of current article.
4972 Argument LINES specifies lines to be scrolled down."
4974 (let (beginning-of-buffer beginning-of-page)
4976 (move-to-window-line 0)
4977 (cond ((eq 1 (point))
4978 (setq beginning-of-buffer t))
4980 (setq beginning-of-page t))))
4981 (cond (beginning-of-buffer)
4983 (gnus-narrow-to-page -1))
4986 (let (window-pixel-scroll-increment)
4987 (scroll-down lines))
4988 (beginning-of-buffer
4989 (goto-char (point-min))))))))
4991 (defun gnus-article-refer-article ()
4992 "Read article specified by message-id around point."
4994 (let ((point (point)))
4995 (search-forward ">" nil t) ;Move point to end of "<....>".
4996 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4997 (let ((message-id (match-string 1)))
4999 (set-buffer gnus-summary-buffer)
5000 (gnus-summary-refer-article message-id))
5002 (error "No references around point"))))
5004 (defun gnus-article-show-summary ()
5005 "Reconfigure windows to show summary buffer."
5007 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5008 (error "There is no summary buffer for this article buffer")
5009 (gnus-article-set-globals)
5010 (gnus-configure-windows 'article)
5011 (gnus-summary-goto-subject gnus-current-article)
5012 (gnus-summary-position-point)))
5014 (defun gnus-article-describe-briefly ()
5015 "Describe article mode commands briefly."
5017 (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")))
5019 (defun gnus-article-summary-command ()
5020 "Execute the last keystroke in the summary buffer."
5022 (let ((obuf (current-buffer))
5023 (owin (current-window-configuration))
5025 (switch-to-buffer gnus-article-current-summary 'norecord)
5026 (setq func (lookup-key (current-local-map) (this-command-keys)))
5027 (call-interactively func)
5029 (set-window-configuration owin)
5030 (set-window-point (get-buffer-window (current-buffer)) (point))))
5032 (defun gnus-article-summary-command-nosave ()
5033 "Execute the last keystroke in the summary buffer."
5036 (pop-to-buffer gnus-article-current-summary 'norecord)
5037 (setq func (lookup-key (current-local-map) (this-command-keys)))
5038 (call-interactively func)))
5040 (defun gnus-article-check-buffer ()
5041 "Beep if not in an article buffer."
5042 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5043 (error "Command invoked outside of a Gnus article buffer")))
5045 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5046 "Read a summary buffer key sequence and execute it from the article buffer."
5048 (gnus-article-check-buffer)
5050 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5051 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5052 "=" "^" "\M-^" "|"))
5058 '("n" "Gn" "p" "Gp"))
5061 (set-buffer gnus-article-current-summary)
5062 (let (gnus-pick-mode)
5063 (push (or key last-command-event) unread-command-events)
5064 (setq keys (static-if (featurep 'xemacs)
5065 (events-to-keys (read-key-sequence nil))
5066 (read-key-sequence nil)))))
5069 (if (or (member keys nosaves)
5070 (member keys nosave-but-article)
5071 (member keys nosave-in-article))
5073 (save-window-excursion
5074 (pop-to-buffer gnus-article-current-summary 'norecord)
5075 ;; We disable the pick minor mode commands.
5076 (let (gnus-pick-mode)
5077 (setq func (lookup-key (current-local-map) keys))))
5081 (unless (member keys nosave-in-article)
5082 (set-buffer gnus-article-current-summary))
5083 (call-interactively func)
5084 (setq new-sum-point (point)))
5085 (when (member keys nosave-but-article)
5086 (pop-to-buffer gnus-article-buffer 'norecord)))
5087 ;; These commands should restore window configuration.
5088 (let ((obuf (current-buffer))
5089 (owin (current-window-configuration))
5091 (summary gnus-article-current-summary)
5092 func in-buffer selected)
5093 (if not-restore-window
5094 (pop-to-buffer summary 'norecord)
5095 (switch-to-buffer summary 'norecord))
5096 (setq in-buffer (current-buffer))
5097 ;; We disable the pick minor mode commands.
5098 (if (and (setq func (let (gnus-pick-mode)
5099 (lookup-key (current-local-map) keys)))
5102 (call-interactively func)
5103 (setq new-sum-point (point))
5104 (when (eq in-buffer (current-buffer))
5105 (setq selected (gnus-summary-select-article))
5107 (unless not-restore-window
5108 (set-window-configuration owin))
5109 (when (eq selected 'old)
5111 (set-window-start (get-buffer-window (current-buffer))
5113 (set-window-point (get-buffer-window (current-buffer))
5115 (let ((win (get-buffer-window gnus-article-current-summary)))
5117 (set-window-point win new-sum-point)))) )
5118 (switch-to-buffer gnus-article-buffer)
5121 (defun gnus-article-describe-key (key)
5122 "Display documentation of the function invoked by KEY. KEY is a string."
5123 (interactive "kDescribe key: ")
5124 (gnus-article-check-buffer)
5125 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5127 (set-buffer gnus-article-current-summary)
5128 (let (gnus-pick-mode)
5129 (if (featurep 'xemacs)
5131 (push (elt key 0) unread-command-events)
5132 (setq key (events-to-keys
5133 (read-key-sequence "Describe key: "))))
5134 (setq unread-command-events
5136 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5138 (setq key (read-key-sequence "Describe key: "))))
5140 (describe-key key)))
5142 (defun gnus-article-describe-key-briefly (key &optional insert)
5143 "Display documentation of the function invoked by KEY. KEY is a string."
5144 (interactive "kDescribe key: \nP")
5145 (gnus-article-check-buffer)
5146 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5148 (set-buffer gnus-article-current-summary)
5149 (let (gnus-pick-mode)
5150 (if (featurep 'xemacs)
5152 (push (elt key 0) unread-command-events)
5153 (setq key (events-to-keys
5154 (read-key-sequence "Describe key: "))))
5155 (setq unread-command-events
5157 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5159 (setq key (read-key-sequence "Describe key: "))))
5160 (describe-key-briefly key insert))
5161 (describe-key-briefly key insert)))
5163 (defun gnus-article-reply-with-original (&optional wide)
5164 "Start composing a reply mail to the current message.
5165 The text in the region will be yanked. If the region isn't active,
5166 the entire article will be yanked."
5168 (let ((article (cdr gnus-article-current)) cont)
5170 (gnus-summary-reply (list (list article)) wide)
5171 (setq cont (buffer-substring (point) (mark)))
5172 ;; Deactivate active regions.
5173 (when (and (boundp 'transient-mark-mode)
5174 transient-mark-mode)
5175 (setq mark-active nil))
5177 (list (list article cont)) wide))))
5179 (defun gnus-article-followup-with-original ()
5180 "Compose a followup to the current article.
5181 The text in the region will be yanked. If the region isn't active,
5182 the entire article will be yanked."
5184 (let ((article (cdr gnus-article-current))
5187 (gnus-summary-followup (list (list article)))
5188 (setq cont (buffer-substring (point) (mark)))
5189 ;; Deactivate active regions.
5190 (when (and (boundp 'transient-mark-mode)
5191 transient-mark-mode)
5192 (setq mark-active nil))
5193 (gnus-summary-followup
5194 (list (list article cont))))))
5196 (defun gnus-article-hide (&optional arg force)
5197 "Hide all the gruft in the current article.
5198 This means that PGP stuff, signatures, cited text and (some)
5199 headers will be hidden.
5200 If given a prefix, show the hidden text instead."
5201 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5202 (gnus-article-hide-headers arg)
5203 (gnus-article-hide-list-identifiers arg)
5204 (gnus-article-hide-pgp arg)
5205 (gnus-article-hide-citation-maybe arg force)
5206 (gnus-article-hide-signature arg))
5208 (defun gnus-article-maybe-highlight ()
5209 "Do some article highlighting if article highlighting is requested."
5210 (when (gnus-visual-p 'article-highlight 'highlight)
5211 (gnus-article-highlight-some)))
5213 (defun gnus-check-group-server ()
5214 ;; Make sure the connection to the server is alive.
5215 (unless (gnus-server-opened
5216 (gnus-find-method-for-group gnus-newsgroup-name))
5217 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5218 (gnus-request-group gnus-newsgroup-name t)))
5221 (autoload 'nneething-get-file-name "nneething"))
5223 (defun gnus-request-article-this-buffer (article group)
5224 "Get an article and insert it into this buffer.
5225 T-gnus change: Insert an article into `gnus-original-article-buffer'."
5226 (let (do-update-line sparse-header)
5227 ;; The current buffer is `gnus-article-buffer'.
5231 (gnus-kill-all-overlays)
5232 (setq group (or group gnus-newsgroup-name))
5234 ;; Using `gnus-request-article' directly will insert the article into
5235 ;; `nntp-server-buffer' - so we'll save some time by not having to
5236 ;; copy it from the server buffer into the article buffer.
5238 ;; We only request an article by message-id when we do not have the
5239 ;; headers for it, so we'll have to get those.
5240 (when (stringp article)
5241 (gnus-read-header article))
5243 ;; If the article number is negative, that means that this article
5244 ;; doesn't belong in this newsgroup (possibly), so we find its
5245 ;; message-id and request it by id instead of number.
5246 (when (and (numberp article)
5248 (get-buffer gnus-summary-buffer)
5249 (gnus-buffer-exists-p gnus-summary-buffer))
5251 (set-buffer gnus-summary-buffer)
5252 (let ((header (gnus-summary-article-header article)))
5255 ((memq article gnus-newsgroup-sparse)
5256 ;; This is a sparse gap article.
5257 (setq do-update-line article)
5258 (setq article (mail-header-id header))
5259 (setq sparse-header (gnus-read-header article))
5260 (setq gnus-newsgroup-sparse
5261 (delq article gnus-newsgroup-sparse)))
5263 ;; It's a real article.
5264 (setq article (mail-header-id header)))
5266 ;; It is an extracted pseudo-article.
5267 (setq article 'pseudo)
5268 (gnus-request-pseudo-article header))))
5270 (let ((method (gnus-find-method-for-group
5271 gnus-newsgroup-name)))
5272 (when (and (eq (car method) 'nneething)
5274 (let ((dir (nneething-get-file-name
5275 (mail-header-id header))))
5276 (when (and (stringp dir)
5277 (file-directory-p dir))
5278 (setq article 'nneething)
5279 (gnus-group-enter-directory dir))))))))
5280 (setq gnus-original-article (cons group article))
5282 ;; The current buffer is `gnus-original-article-buffer'.
5283 (if (get-buffer gnus-original-article-buffer)
5284 (set-buffer gnus-original-article-buffer)
5285 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5286 (set-buffer-multibyte nil)
5287 (buffer-disable-undo)
5288 (setq major-mode 'gnus-original-article-mode)
5289 (setq buffer-read-only nil))
5292 ;; Refuse to select canceled articles.
5293 ((and (numberp article)
5295 (get-buffer gnus-summary-buffer)
5296 (gnus-buffer-exists-p gnus-summary-buffer)
5297 (eq (cdr (save-excursion
5298 (set-buffer gnus-summary-buffer)
5299 (assq article gnus-newsgroup-reads)))
5300 gnus-canceled-mark))
5302 ;; Check the backlog.
5303 ((and gnus-keep-backlog
5304 (gnus-backlog-request-article group article (current-buffer)))
5306 ;; Check asynchronous pre-fetch.
5307 ((gnus-async-request-fetched-article group article (current-buffer))
5308 (gnus-async-prefetch-next group article gnus-summary-buffer)
5309 (when (and (numberp article) gnus-keep-backlog)
5310 (gnus-backlog-enter-article group article (current-buffer)))
5313 ((and gnus-use-cache
5315 (gnus-cache-request-article article group))
5317 ;; Check the agent cache.
5318 ((and gnus-agent gnus-agent-cache gnus-plugged
5320 (gnus-agent-request-article article group))
5322 ;; Get the article and put into the article buffer.
5323 ((or (stringp article)
5325 (let ((gnus-override-method gnus-override-method)
5326 (methods (and (stringp article)
5327 gnus-refer-article-method))
5329 (buffer-read-only nil))
5330 (if (or (not (listp methods))
5331 (and (symbolp (car methods))
5332 (assq (car methods) nnoo-definition-alist)))
5333 (setq methods (list methods)))
5334 (when (and (null gnus-override-method)
5336 (setq gnus-override-method (pop methods)))
5338 (when (eq gnus-override-method 'current)
5339 (setq gnus-override-method
5340 (with-current-buffer gnus-summary-buffer
5341 gnus-current-select-method)))
5343 (gnus-kill-all-overlays)
5344 (let ((gnus-newsgroup-name group))
5345 (gnus-check-group-server))
5346 (when (gnus-request-article article group (current-buffer))
5347 (when (numberp article)
5348 (gnus-async-prefetch-next group article
5349 gnus-summary-buffer)
5350 (when gnus-keep-backlog
5351 (gnus-backlog-enter-article
5352 group article (current-buffer))))
5353 (setq result 'article))
5356 (setq gnus-override-method (pop methods))
5357 (setq result 'done))))
5358 (and (eq result 'article) 'article)))
5362 ;; Associate this article with the current summary buffer.
5363 (setq gnus-article-current-summary gnus-summary-buffer)
5365 ;; Copy the requested article from `gnus-original-article-buffer'.
5366 (unless (equal (buffer-name (current-buffer))
5367 (buffer-name (get-buffer gnus-original-article-buffer)))
5368 (insert-buffer gnus-original-article-buffer))
5371 (run-hooks 'gnus-article-decode-hook)
5372 ;; Mark article as decoded or not.
5373 (setq gnus-article-decoded-p gnus-article-decode-hook)
5375 ;; Update sparse articles.
5376 (when (and do-update-line
5377 (or (numberp article)
5379 (let ((buf (current-buffer)))
5380 (set-buffer gnus-summary-buffer)
5381 (gnus-summary-update-article do-update-line sparse-header)
5382 (gnus-summary-goto-subject do-update-line nil t)
5383 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5385 (set-buffer buf))))))
5391 (defcustom gnus-article-edit-mode-hook nil
5392 "Hook run in article edit mode buffers."
5393 :group 'gnus-article-various
5396 (defcustom gnus-article-edit-article-setup-function
5397 'gnus-article-mime-edit-article-setup
5398 "Function called to setup an editing article buffer."
5399 :group 'gnus-article-various
5402 (defvar gnus-article-edit-done-function nil)
5404 (defvar gnus-article-edit-mode-map nil)
5406 ;; Should we be using derived.el for this?
5407 (unless gnus-article-edit-mode-map
5408 (setq gnus-article-edit-mode-map (make-sparse-keymap))
5409 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5411 (gnus-define-keys gnus-article-edit-mode-map
5412 "\C-c\C-c" gnus-article-edit-done
5413 "\C-c\C-k" gnus-article-edit-exit)
5415 (gnus-define-keys (gnus-article-edit-wash-map
5416 "\C-c\C-w" gnus-article-edit-mode-map)
5417 "f" gnus-article-edit-full-stops))
5419 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5420 "Major mode for editing articles.
5421 This is an extended text-mode.
5423 \\{gnus-article-edit-mode-map}"
5424 (make-local-variable 'gnus-article-edit-done-function)
5425 (make-local-variable 'gnus-prev-winconf)
5426 (set (make-local-variable 'font-lock-defaults)
5427 '(message-font-lock-keywords t))
5428 (setq buffer-read-only nil)
5429 (buffer-enable-undo)
5432 (defun gnus-article-edit (&optional force)
5433 "Edit the current article.
5434 This will have permanent effect only in mail groups.
5435 If FORCE is non-nil, allow editing of articles even in read-only
5438 (when (and (not force)
5439 (gnus-group-read-only-p))
5440 (error "The current newsgroup does not support article editing"))
5441 (gnus-article-date-original)
5442 (gnus-article-edit-article
5444 `(lambda (no-highlight)
5446 (gnus-summary-edit-article-done
5447 ,(or (mail-header-references gnus-current-headers) "")
5448 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5450 (defun gnus-article-edit-article (start-func exit-func)
5451 "Start editing the contents of the current article buffer."
5452 (let ((winconf (current-window-configuration)))
5453 (set-buffer gnus-article-buffer)
5454 (gnus-article-edit-mode)
5455 (funcall start-func)
5456 (set-buffer-modified-p nil)
5457 (gnus-configure-windows 'edit-article)
5458 (setq gnus-article-edit-done-function exit-func)
5459 (setq gnus-prev-winconf winconf)
5460 (when gnus-article-edit-article-setup-function
5461 (funcall gnus-article-edit-article-setup-function))
5462 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5464 (defun gnus-article-edit-done (&optional arg)
5465 "Update the article edits and exit."
5467 (let ((func gnus-article-edit-done-function)
5468 (buf (current-buffer))
5469 (start (window-start)))
5470 (remove-hook 'gnus-article-mode-hook
5471 'gnus-article-mime-edit-article-unwind)
5472 ;; We remove all text props from the article buffer.
5474 (buffer-substring-no-properties (point-min) (point-max)))
5478 (let ((winconf gnus-prev-winconf))
5480 (set-window-configuration winconf)
5481 ;; Tippy-toe some to make sure that point remains where it was.
5482 (save-current-buffer
5484 (set-window-start (get-buffer-window (current-buffer)) start)
5488 (let ((buffer-read-only nil))
5490 ;; The cache and backlog have to be flushed somewhat.
5491 (when gnus-keep-backlog
5492 (gnus-backlog-remove-article
5493 (car gnus-article-current) (cdr gnus-article-current)))
5494 ;; Flush original article as well.
5496 (when (get-buffer gnus-original-article-buffer)
5497 (set-buffer gnus-original-article-buffer)
5498 (setq gnus-original-article nil)))
5499 (when gnus-use-cache
5500 (gnus-cache-update-article
5501 (car gnus-article-current) (cdr gnus-article-current))))
5503 (set-window-start (get-buffer-window buf) start)
5504 (set-window-point (get-buffer-window buf) (point))))
5506 (defun gnus-article-edit-exit ()
5507 "Exit the article editing without updating."
5509 (when (or (not (buffer-modified-p))
5510 (yes-or-no-p "Article modified; kill anyway? "))
5511 (let ((curbuf (current-buffer))
5513 (window-start (window-start)))
5515 (if (gnus-buffer-live-p gnus-original-article-buffer)
5516 (insert-buffer gnus-original-article-buffer))
5517 (let ((winconf gnus-prev-winconf))
5519 (set-window-configuration winconf)
5520 ;; Tippy-toe some to make sure that point remains where it was.
5521 (save-current-buffer
5523 (set-window-start (get-buffer-window (current-buffer)) window-start)
5526 (defun gnus-article-edit-full-stops ()
5527 "Interactively repair spacing at end of sentences."
5530 (goto-char (point-min))
5531 (search-forward-regexp "^$" nil t)
5532 (let ((case-fold-search nil))
5533 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5536 ;;; Article editing with MIME-Edit
5539 (defcustom gnus-article-mime-edit-article-setup-hook nil
5540 "Hook run after setting up a MIME editing article buffer."
5541 :group 'gnus-article-various
5544 (defun gnus-article-mime-edit-article-unwind ()
5545 "Unwind `gnus-article-buffer' if article editing was given up."
5546 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5547 (when (featurep 'font-lock)
5548 (setq font-lock-defaults nil)
5549 (font-lock-mode -1))
5550 (when mime-edit-mode-flag
5551 (mime-edit-exit 'nomime 'no-error)
5554 (defun gnus-article-mime-edit-article-setup ()
5555 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5556 after replacing with the original article."
5557 (setq gnus-show-mime t)
5558 (setq gnus-article-edit-done-function
5559 `(lambda (&rest args)
5560 (when mime-edit-mode-flag
5561 (let (mime-edit-insert-user-agent-field)
5564 (goto-char (point-min))
5565 (let (case-fold-search)
5566 (when (re-search-forward
5567 (format "^%s$" (regexp-quote mail-header-separator))
5569 (replace-match "")))
5570 (apply ,gnus-article-edit-done-function args)
5573 (buffer-substring-no-properties (point-min) (point-max))
5574 (set-buffer (get-buffer-create gnus-original-article-buffer))
5576 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5577 (set-buffer gnus-article-buffer)
5578 (gnus-article-prepare-display)))
5579 (substitute-key-definition 'gnus-article-edit-done
5580 'gnus-article-mime-edit-done
5581 gnus-article-edit-mode-map)
5582 (substitute-key-definition 'gnus-article-edit-exit
5583 'gnus-article-mime-edit-exit
5584 gnus-article-edit-mode-map)
5586 (insert-buffer gnus-original-article-buffer)
5587 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5588 (fset 'mime-edit-decode-single-part-in-buffer
5589 (lambda (&rest args)
5590 (if (let ((content-type (car args)))
5591 (and (eq 'message (mime-content-type-primary-type
5593 (eq 'rfc822 (mime-content-type-subtype content-type))))
5594 (setcar (cdr args) 'not-decode-text))
5598 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5599 (when (featurep 'font-lock)
5600 (set (make-local-variable 'font-lock-defaults)
5601 '(message-font-lock-keywords t))
5602 (font-lock-set-defaults)
5603 (turn-on-font-lock))
5604 (set-buffer-modified-p nil)
5605 (delete-other-windows)
5606 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5607 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5609 (defun gnus-article-mime-edit-done (&optional arg)
5610 "Update the article MIME edits and exit."
5612 (when (featurep 'font-lock)
5613 (setq font-lock-defaults nil)
5614 (font-lock-mode -1))
5615 (gnus-article-edit-done arg))
5617 (defun gnus-article-mime-edit-exit ()
5618 "Exit the article MIME editing without updating."
5620 (when (or (not (buffer-modified-p))
5621 (yes-or-no-p "Article modified; kill anyway? "))
5622 (when (featurep 'font-lock)
5623 (setq font-lock-defaults nil)
5624 (font-lock-mode -1))
5625 (when mime-edit-mode-flag
5626 (let (mime-edit-insert-user-agent-field)
5629 (goto-char (point-min))
5630 (let (case-fold-search)
5631 (when (re-search-forward
5632 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5633 (replace-match "")))
5634 (let ((winconf gnus-prev-winconf))
5636 (buffer-substring-no-properties (point-min) (point-max))
5637 (set-buffer (get-buffer-create gnus-original-article-buffer))
5639 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5640 (set-buffer gnus-article-buffer)
5641 (gnus-article-prepare-display)
5642 (set-window-configuration winconf))))
5645 ;;; Article highlights
5648 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5650 ;;; Internal Variables:
5652 (defcustom gnus-button-url-regexp "\\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\\)\\)"
5653 "Regular expression that matches URLs."
5654 :group 'gnus-article-buttons
5657 (defcustom gnus-button-alist
5658 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5659 0 t gnus-button-handle-news 3)
5660 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5661 gnus-button-handle-news 2)
5662 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5664 gnus-button-fetch-group 4)
5665 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5666 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5667 t gnus-button-message-id 3)
5668 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5669 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5670 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5672 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5673 gnus-button-handle-info 2)
5674 ;; This is how URLs _should_ be embedded in text...
5675 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5677 (,gnus-button-url-regexp 0 t browse-url 0))
5678 "*Alist of regexps matching buttons in article bodies.
5680 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5681 REGEXP: is the string matching text around the button,
5682 BUTTON: is the number of the regexp grouping actually matching the button,
5683 FORM: is a lisp expression which must eval to true for the button to
5685 CALLBACK: is the function to call when the user push this button, and each
5686 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5688 CALLBACK can also be a variable, in that case the value of that
5689 variable it the real callback function."
5690 :group 'gnus-article-buttons
5691 :type '(repeat (list regexp
5692 (integer :tag "Button")
5694 (function :tag "Callback")
5697 (integer :tag "Regexp group")))))
5699 (defcustom gnus-header-button-alist
5700 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5701 0 t gnus-button-message-id 0)
5702 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5703 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5704 0 t gnus-button-mailto 0)
5705 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5706 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5707 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5708 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5709 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5710 gnus-button-message-id 3))
5711 "*Alist of headers and regexps to match buttons in article heads.
5713 This alist is very similar to `gnus-button-alist', except that each
5714 alist has an additional HEADER element first in each entry:
5716 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5718 HEADER is a regexp to match a header. For a fuller explanation, see
5719 `gnus-button-alist'."
5720 :group 'gnus-article-buttons
5721 :group 'gnus-article-headers
5722 :type '(repeat (list (regexp :tag "Header")
5724 (integer :tag "Button")
5726 (function :tag "Callback")
5729 (integer :tag "Regexp group")))))
5731 (defvar gnus-button-regexp nil)
5732 (defvar gnus-button-marker-list nil)
5733 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5735 (defvar gnus-button-last nil)
5736 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5740 (defun gnus-article-push-button (event)
5741 "Check text under the mouse pointer for a callback function.
5742 If the text under the mouse pointer has a `gnus-callback' property,
5743 call it with the value of the `gnus-data' text property."
5745 (set-buffer (window-buffer (posn-window (event-start event))))
5746 (let* ((pos (posn-point (event-start event)))
5747 (data (get-text-property pos 'gnus-data))
5748 (fun (get-text-property pos 'gnus-callback)))
5751 (funcall fun data))))
5753 (defun gnus-article-press-button ()
5754 "Check text at point for a callback function.
5755 If the text at point has a `gnus-callback' property,
5756 call it with the value of the `gnus-data' text property."
5758 (let* ((data (get-text-property (point) 'gnus-data))
5759 (fun (get-text-property (point) 'gnus-callback)))
5761 (funcall fun data))))
5763 (defun gnus-article-prev-button (n)
5764 "Move point to N buttons backward.
5765 If N is negative, move forward instead."
5767 (gnus-article-next-button (- n)))
5769 (defun gnus-article-next-button (n)
5770 "Move point to N buttons forward.
5771 If N is negative, move backward instead."
5773 (let ((function (if (< n 0) 'previous-single-property-change
5774 'next-single-property-change))
5775 (inhibit-point-motion-hooks t)
5777 (limit (if (< n 0) (point-min) (point-max))))
5779 (while (and (not (= limit (point)))
5781 ;; Skip past the current button.
5782 (when (get-text-property (point) 'gnus-callback)
5783 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5784 ;; Go to the next (or previous) button.
5785 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5786 ;; Put point at the start of the button.
5787 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5788 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5789 ;; Skip past intangible buttons.
5790 (when (get-text-property (point) 'intangible)
5794 (gnus-message 5 "No more buttons"))
5797 (defun gnus-article-highlight (&optional force)
5798 "Highlight current article.
5799 This function calls `gnus-article-highlight-headers',
5800 `gnus-article-highlight-citation',
5801 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5802 do the highlighting. See the documentation for those functions."
5803 (interactive (list 'force))
5804 (gnus-article-highlight-headers)
5805 (gnus-article-highlight-citation force)
5806 (gnus-article-highlight-signature)
5807 (gnus-article-add-buttons force)
5808 (gnus-article-add-buttons-to-head))
5810 (defun gnus-article-highlight-some (&optional force)
5811 "Highlight current article.
5812 This function calls `gnus-article-highlight-headers',
5813 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5814 do the highlighting. See the documentation for those functions."
5815 (interactive (list 'force))
5816 (gnus-article-highlight-headers)
5817 (gnus-article-highlight-signature)
5818 (gnus-article-add-buttons))
5820 (defun gnus-article-highlight-headers ()
5821 "Highlight article headers as specified by `gnus-header-face-alist'."
5824 (set-buffer gnus-article-buffer)
5826 (let ((alist gnus-header-face-alist)
5827 (buffer-read-only nil)
5828 (case-fold-search t)
5829 (inhibit-point-motion-hooks t)
5830 entry regexp header-face field-face from hpoints fpoints)
5831 (article-narrow-to-head)
5832 (while (setq entry (pop alist))
5833 (goto-char (point-min))
5834 (setq regexp (concat "^\\("
5835 (if (string-equal "" (nth 0 entry))
5839 header-face (nth 1 entry)
5840 field-face (nth 2 entry))
5841 (while (and (re-search-forward regexp nil t)
5845 (unless (search-forward ":" nil t)
5847 (when (and header-face
5848 (not (memq (point) hpoints)))
5849 (push (point) hpoints)
5850 (gnus-put-text-property from (point) 'face header-face))
5851 (when (and field-face
5852 (not (memq (setq from (point)) fpoints)))
5854 (if (re-search-forward "^[^ \t]" nil t)
5856 (goto-char (point-max)))
5857 (gnus-put-text-property from (point) 'face field-face))))))))
5859 (defun gnus-article-highlight-signature ()
5860 "Highlight the signature in an article.
5861 It does this by highlighting everything after
5862 `gnus-signature-separator' using `gnus-signature-face'."
5864 (when gnus-signature-face
5866 (set-buffer gnus-article-buffer)
5867 (let ((buffer-read-only nil)
5868 (inhibit-point-motion-hooks t))
5870 (when (gnus-article-narrow-to-signature)
5871 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5872 'face gnus-signature-face)))))))
5874 (defun gnus-article-buttonize-signature ()
5875 "Add button to the signature."
5878 (set-buffer gnus-article-buffer)
5879 (let ((buffer-read-only nil)
5880 (inhibit-point-motion-hooks t))
5881 (when (gnus-article-search-signature)
5882 (gnus-article-add-button (match-beginning 0) (match-end 0)
5883 'gnus-signature-toggle
5884 (set-marker (make-marker)
5885 (1+ (match-end 0))))))))
5887 (defun gnus-button-in-region-p (b e prop)
5888 "Say whether PROP exists in the region."
5889 (text-property-not-all b e prop nil))
5891 (defun gnus-article-add-buttons (&optional force)
5892 "Find external references in the article and make buttons of them.
5893 \"External references\" are things like Message-IDs and URLs, as
5894 specified by `gnus-button-alist'."
5895 (interactive (list 'force))
5897 (set-buffer gnus-article-buffer)
5898 (let ((buffer-read-only nil)
5899 (inhibit-point-motion-hooks t)
5900 (case-fold-search t)
5901 (alist gnus-button-alist)
5903 ;; Remove all old markers.
5904 (let (marker entry new-list)
5905 (while (setq marker (pop gnus-button-marker-list))
5906 (if (or (< marker (point-min)) (>= marker (point-max)))
5907 (push marker new-list)
5909 (when (setq entry (gnus-button-entry))
5910 (put-text-property (match-beginning (nth 1 entry))
5911 (match-end (nth 1 entry))
5912 'gnus-callback nil))
5913 (set-marker marker nil)))
5914 (setq gnus-button-marker-list new-list))
5915 ;; We skip the headers.
5918 (while (setq entry (pop alist))
5919 (setq regexp (car entry))
5921 (while (re-search-forward regexp nil t)
5922 (let* ((start (and entry (match-beginning (nth 1 entry))))
5923 (end (and entry (match-end (nth 1 entry))))
5924 (from (match-beginning 0)))
5925 (when (and (or (eq t (nth 2 entry))
5926 (eval (nth 2 entry)))
5927 (not (gnus-button-in-region-p
5928 start end 'gnus-callback)))
5929 ;; That optional form returned non-nil, so we add the
5931 (gnus-article-add-button
5932 start end 'gnus-button-push
5933 (car (push (set-marker (make-marker) from)
5934 gnus-button-marker-list))))))))))
5936 ;; Add buttons to the head of an article.
5937 (defun gnus-article-add-buttons-to-head ()
5938 "Add buttons to the head of the article."
5941 (set-buffer gnus-article-buffer)
5943 (let ((buffer-read-only nil)
5944 (inhibit-point-motion-hooks t)
5945 (case-fold-search t)
5946 (alist gnus-header-button-alist)
5948 (article-narrow-to-head)
5950 ;; Each alist entry.
5951 (setq entry (car alist)
5953 (goto-char (point-min))
5954 (while (re-search-forward (car entry) nil t)
5955 ;; Each header matching the entry.
5956 (setq beg (match-beginning 0))
5957 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5958 (match-beginning 0))
5961 (while (re-search-forward (nth 1 entry) end t)
5962 ;; Each match within a header.
5963 (let* ((entry (cdr entry))
5964 (start (match-beginning (nth 1 entry)))
5965 (end (match-end (nth 1 entry)))
5966 (form (nth 2 entry)))
5967 (goto-char (match-end 0))
5969 (gnus-article-add-button
5970 start end (nth 3 entry)
5971 (buffer-substring (match-beginning (nth 4 entry))
5972 (match-end (nth 4 entry)))))))
5973 (goto-char end)))))))
5975 ;;; External functions:
5977 (defun gnus-article-add-button (from to fun &optional data)
5978 "Create a button between FROM and TO with callback FUN and data DATA."
5979 (when gnus-article-button-face
5980 (gnus-overlay-put (gnus-make-overlay from to)
5981 'face gnus-article-button-face))
5982 (gnus-add-text-properties
5984 (nconc (and gnus-article-mouse-face
5985 (list gnus-mouse-face-prop gnus-article-mouse-face))
5986 (list 'gnus-callback fun)
5987 (and data (list 'gnus-data data))))
5988 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5989 ;; Quote `:button-keymap' for Mule 2.3
5990 ;; but it won't work.
5991 ':button-keymap gnus-widget-button-keymap))
5993 ;;; Internal functions:
5995 (defun gnus-article-set-globals ()
5997 (set-buffer gnus-summary-buffer)
5998 (gnus-set-global-variables)))
6000 (defun gnus-signature-toggle (end)
6002 (set-buffer gnus-article-buffer)
6003 (let ((buffer-read-only nil)
6004 (inhibit-point-motion-hooks t)
6005 (limit (next-single-property-change end 'mime-view-entity
6007 (if (text-property-any end limit 'article-type 'signature)
6009 (gnus-delete-wash-type 'signature)
6010 (gnus-remove-text-properties-when
6011 'article-type 'signature end limit
6012 (cons 'article-type (cons 'signature
6013 gnus-hidden-properties))))
6014 (gnus-add-wash-type 'signature)
6015 (gnus-add-text-properties-when
6016 'article-type nil end limit
6017 (cons 'article-type (cons 'signature
6018 gnus-hidden-properties)))))
6019 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6020 (gnus-set-mode-line 'article))))
6022 (defun gnus-button-entry ()
6023 ;; Return the first entry in `gnus-button-alist' matching this place.
6024 (let ((alist gnus-button-alist)
6027 (setq entry (pop alist))
6028 (if (looking-at (car entry))
6033 (defun gnus-button-push (marker)
6034 ;; Push button starting at MARKER.
6037 (let* ((entry (gnus-button-entry))
6038 (inhibit-point-motion-hooks t)
6040 (args (mapcar (lambda (group)
6041 (let ((string (match-string group)))
6042 (gnus-set-text-properties
6043 0 (length string) nil string)
6050 (fboundp (symbol-value fun)))
6051 (apply (symbol-value fun) args))
6053 (gnus-message 1 "You must define `%S' to use this button"
6054 (cons fun args)))))))
6056 (defun gnus-parse-news-url (url)
6057 (let (scheme server group message-id articles)
6060 (goto-char (point-min))
6061 (when (looking-at "\\([A-Za-z]+\\):")
6062 (setq scheme (match-string 1))
6063 (goto-char (match-end 0)))
6064 (when (looking-at "//\\([^/]+\\)/")
6065 (setq server (match-string 1))
6066 (goto-char (match-end 0)))
6069 ((looking-at "\\(.*@.*\\)")
6070 (setq message-id (match-string 1)))
6071 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6072 (setq group (match-string 1)
6073 articles (split-string (match-string 2) "-")))
6074 ((looking-at "\\([^/]+\\)/?")
6075 (setq group (match-string 1)))
6077 (error "Unknown news URL syntax"))))
6078 (list scheme server group message-id articles)))
6080 (defun gnus-button-handle-news (url)
6082 (destructuring-bind (scheme server group message-id articles)
6083 (gnus-parse-news-url url)
6087 (set-buffer gnus-summary-buffer)
6089 (let ((gnus-refer-article-method (list (list 'nntp server))))
6090 (gnus-summary-refer-article message-id))
6091 (gnus-summary-refer-article message-id))))
6093 (gnus-button-fetch-group url)))))
6095 (defun gnus-button-handle-info (url)
6096 "Fetch an info URL."
6098 "^\\([^:/]+\\)?/\\(.*\\)"
6100 (gnus-info-find-node
6101 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6104 (gnus-url-unhex-string (match-string 2 url))))
6105 (error "Can't parse %s" url)))
6107 (defun gnus-button-message-id (message-id)
6110 (set-buffer gnus-summary-buffer)
6111 (gnus-summary-refer-article message-id)))
6113 (defun gnus-button-fetch-group (address)
6114 "Fetch GROUP specified by ADDRESS."
6115 (if (not (string-match "[:/]" address))
6116 ;; This is just a simple group url.
6117 (gnus-group-read-ephemeral-group address gnus-select-method)
6120 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6122 (error "Can't parse %s" address)
6123 (gnus-group-read-ephemeral-group
6124 (match-string 4 address)
6125 `(nntp ,(match-string 1 address)
6126 (nntp-address ,(match-string 1 address))
6127 (nntp-port-number ,(if (match-end 3)
6128 (match-string 3 address)
6131 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6133 (defun gnus-url-parse-query-string (query &optional downcase)
6134 (let (retval pairs cur key val)
6135 (setq pairs (split-string query "&"))
6137 (setq cur (car pairs)
6139 (if (not (string-match "=" cur))
6141 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6142 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6144 (setq key (downcase key)))
6145 (setq cur (assoc key retval))
6147 (setcdr cur (cons val (cdr cur)))
6148 (setq retval (cons (list key val) retval)))))
6151 (defun gnus-url-mailto (url)
6152 ;; Send mail to someone
6153 (when (string-match "mailto:/*\\(.*\\)" url)
6154 (setq url (substring url (match-beginning 1) nil)))
6155 (let (to args subject func)
6156 (if (string-match (regexp-quote "?") url)
6157 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6158 args (gnus-url-parse-query-string
6159 (substring url (match-end 0) nil) t))
6160 (setq to (gnus-url-unhex-string url)))
6161 (setq args (cons (list "to" to) args)
6162 subject (cdr-safe (assoc "subject" args)))
6165 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6168 (message-position-on-field (caar args)))
6169 (insert (mapconcat 'identity (cdar args) ", "))
6170 (setq args (cdr args)))
6173 (message-goto-subject))))
6175 (defun gnus-button-embedded-url (address)
6176 "Activate ADDRESS with `browse-url'."
6177 (browse-url (gnus-strip-whitespace address)))
6179 ;;; Next/prev buttons in the article buffer.
6181 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6182 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6184 (defvar gnus-prev-page-map
6185 (let ((map (make-sparse-keymap)))
6186 (unless (>= emacs-major-version 21)
6187 ;; XEmacs doesn't care.
6188 (set-keymap-parent map gnus-article-mode-map))
6189 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6190 (define-key map "\r" 'gnus-button-prev-page)
6193 (defun gnus-insert-prev-page-button ()
6195 (buffer-read-only nil)
6196 (situation (get-text-property (point-min) 'mime-view-situation)))
6198 gnus-prev-page-line-format nil
6199 `(,@(gnus-local-map-property gnus-prev-page-map)
6201 gnus-callback gnus-article-button-prev-page
6202 article-type annotation
6203 mime-view-situation ,situation))
6204 (widget-convert-button
6206 :action 'gnus-button-prev-page
6207 :button-keymap gnus-prev-page-map)))
6209 (defvar gnus-next-page-map
6210 (let ((map (make-sparse-keymap)))
6211 (unless (>= emacs-major-version 21)
6212 ;; XEmacs doesn't care.
6213 (set-keymap-parent map gnus-article-mode-map))
6214 (define-key map gnus-mouse-2 'gnus-button-next-page)
6215 (define-key map "\r" 'gnus-button-next-page)
6218 (defun gnus-button-next-page (&optional args more-args)
6219 "Go to the next page."
6221 (let ((win (selected-window)))
6222 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6223 (gnus-article-next-page)
6224 (select-window win)))
6226 (defun gnus-button-prev-page (&optional args more-args)
6227 "Go to the prev page."
6229 (let ((win (selected-window)))
6230 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6231 (gnus-article-prev-page)
6232 (select-window win)))
6234 (defun gnus-insert-next-page-button ()
6236 (buffer-read-only nil)
6237 (situation (get-text-property (point-min) 'mime-view-situation)))
6238 (gnus-eval-format gnus-next-page-line-format nil
6239 `(,@(gnus-local-map-property gnus-next-page-map)
6241 gnus-callback gnus-article-button-next-page
6242 article-type annotation
6243 mime-view-situation ,situation))
6244 (widget-convert-button
6246 :action 'gnus-button-next-page
6247 :button-keymap gnus-next-page-map)))
6249 (defun gnus-article-button-next-page (arg)
6250 "Go to the next page."
6252 (let ((win (selected-window)))
6253 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6254 (gnus-article-next-page)
6255 (select-window win)))
6257 (defun gnus-article-button-prev-page (arg)
6258 "Go to the prev page."
6260 (let ((win (selected-window)))
6261 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6262 (gnus-article-prev-page)
6263 (select-window win)))
6265 (defvar gnus-decode-header-methods
6266 '(mail-decode-encoded-word-region)
6267 "List of methods used to decode headers.
6269 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6270 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6271 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6272 whose names match REGEXP.
6275 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6276 mail-decode-encoded-word-region
6277 (\"chinese\" . rfc1843-decode-region))
6280 (defvar gnus-decode-header-methods-cache nil)
6282 (defun gnus-multi-decode-header (start end)
6283 "Apply the functions from `gnus-encoded-word-methods' that match."
6284 (unless (and gnus-decode-header-methods-cache
6285 (eq gnus-newsgroup-name
6286 (car gnus-decode-header-methods-cache)))
6287 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6290 (nconc gnus-decode-header-methods-cache (list x))
6291 (if (and gnus-newsgroup-name
6292 (string-match (car x) gnus-newsgroup-name))
6293 (nconc gnus-decode-header-methods-cache
6295 gnus-decode-header-methods))
6296 (let ((xlist gnus-decode-header-methods-cache))
6299 (narrow-to-region start end)
6301 (funcall (pop xlist) (point-min) (point-max))))))
6304 ;;; Treatment top-level handling.
6307 (defun gnus-treat-article (condition &optional part-number total-parts type)
6308 (let ((length (- (point-max) (point-min)))
6309 (alist gnus-treatment-function-alist)
6310 (article-goto-body-goes-to-point-min-p t)
6314 (let ((list gnus-article-treat-types))
6316 (when (string-match (pop list) type)
6317 (throw 'found t)))))))
6318 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6319 (entity (static-unless (featurep 'xemacs)
6320 (when (eq 'head condition)
6321 (get-text-property (point-min) 'mime-view-entity))))
6322 val elem buttonized)
6323 (gnus-run-hooks 'gnus-part-display-hook)
6324 (unless gnus-inhibit-treatment
6325 (while (setq elem (pop alist))
6328 (if (gnus-buffer-live-p gnus-summary-buffer)
6329 (set-buffer gnus-summary-buffer))
6330 (symbol-value (car elem))))
6331 (when (and (or (consp val)
6333 (gnus-treat-predicate val)
6334 (or (not (get (car elem) 'highlight))
6336 (when (and (not buttonized)
6338 '(gnus-treat-hide-signature
6339 gnus-treat-highlight-signature)))
6340 (gnus-article-buttonize-signature)
6341 (setq buttonized t))
6343 (funcall (cadr elem)))))
6344 ;; FSF Emacsen does not inherit the existing text properties
6345 ;; in the new text, so we should do it for `mime-view-entity'.
6346 (static-unless (featurep 'xemacs)
6348 (put-text-property (point-min) (point-max)
6349 'mime-view-entity entity))))))
6351 ;; Dynamic variables.
6353 (defvar part-number)
6354 (defvar total-parts)
6359 (defun gnus-treat-predicate (val)
6364 (stringp (car val)))
6365 (apply 'gnus-or (mapcar `(lambda (s)
6366 (string-match s ,(or gnus-newsgroup-name "")))
6369 (let ((pred (pop val)))
6372 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6374 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6376 (not (gnus-treat-predicate (car val))))
6378 (equal (car val) type))
6380 (error "%S is not a valid predicate" pred)))))
6390 (eq part-number total-parts))
6394 (error "%S is not a valid value" val))))
6396 (defun gnus-article-encrypt-body (protocol &optional n)
6397 "Encrypt the article body."
6400 (or gnus-article-encrypt-protocol
6401 (completing-read "Encrypt protocol: "
6402 gnus-article-encrypt-protocol-alist
6404 current-prefix-arg))
6405 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6407 (error (format "Can't find the encrypt protocol %s" protocol)))
6408 (if (equal gnus-newsgroup-name "nndraft:drafts")
6409 (error "Can't encrypt the article in group nndraft:drafts"))
6410 (if (equal gnus-newsgroup-name "nndraft:queue")
6411 (error "Don't encrypt the article in group nndraft:queue"))
6412 (gnus-summary-iterate n
6414 (set-buffer gnus-summary-buffer)
6415 (let ((mail-parse-charset gnus-newsgroup-charset)
6416 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6417 (summary-buffer gnus-summary-buffer)
6419 (gnus-set-global-variables)
6420 (when (gnus-group-read-only-p)
6421 (error "The current newsgroup does not support article encrypt"))
6422 (gnus-summary-show-article t)
6424 (or (mail-header-references gnus-current-headers) ""))
6425 (set-buffer gnus-article-buffer)
6426 (let* ((buffer-read-only nil)
6428 (mapcar (lambda (field)
6429 (and (save-restriction
6430 (message-narrow-to-head)
6431 (goto-char (point-min))
6432 (search-forward field nil t))
6434 (message-narrow-to-field)
6435 (buffer-substring (point-min) (point-max))
6436 (delete-region (point-min) (point-max))
6438 '("Content-Type:" "Content-Transfer-Encoding:"
6439 "Content-Disposition:"))))
6440 (message-narrow-to-head)
6441 (message-remove-header "MIME-Version")
6442 (goto-char (point-max))
6443 (setq point (point))
6444 (insert (apply 'concat headers))
6446 (narrow-to-region point (point-max))
6447 (let ((message-options message-options))
6448 (message-options-set 'message-sender user-mail-address)
6449 (message-options-set 'message-recipients user-mail-address)
6450 (message-options-set 'message-sign-encrypt 'not)
6452 (goto-char (point-min))
6453 (insert "MIME-Version: 1.0\n")
6455 (gnus-summary-edit-article-done
6456 references nil summary-buffer t))
6457 (when gnus-keep-backlog
6458 (gnus-backlog-remove-article
6459 (car gnus-article-current) (cdr gnus-article-current)))
6461 (when (get-buffer gnus-original-article-buffer)
6462 (set-buffer gnus-original-article-buffer)
6463 (setq gnus-original-article nil)))
6464 (when gnus-use-cache
6465 (gnus-cache-update-article
6466 (car gnus-article-current) (cdr gnus-article-current))))))))
6468 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6469 "The following specs can be used:
6470 %t The security MIME type
6473 %D Details if button is pressed")
6475 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6476 "The following specs can be used:
6477 %t The security MIME type
6480 %D Details if button is pressed")
6482 (defvar gnus-mime-security-button-line-format-alist
6483 '((?t gnus-tmp-type ?s)
6484 (?i gnus-tmp-info ?s)
6485 (?d gnus-tmp-details ?s)
6486 (?D gnus-tmp-pressed-details ?s)))
6488 (defvar gnus-mime-security-button-map
6489 (let ((map (make-sparse-keymap)))
6490 (unless (>= (string-to-number emacs-version) 21)
6491 (set-keymap-parent map gnus-article-mode-map))
6492 (define-key map gnus-mouse-2 'gnus-article-push-button)
6493 (define-key map "\r" 'gnus-article-press-button)
6496 (defvar gnus-mime-security-details-buffer nil)
6498 (defvar gnus-mime-security-button-pressed nil)
6500 (defvar gnus-mime-security-show-details-inline t
6501 "If non-nil, show details in the article buffer.")
6503 (defun gnus-mime-security-verify-or-decrypt (handle)
6504 (mm-remove-parts (cdr handle))
6505 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6506 point buffer-read-only)
6508 (goto-char (car region)))
6510 (narrow-to-region (point) (point))
6511 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6512 (let* ((mm-verify-option 'known)
6513 (mm-decrypt-option 'known)
6514 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6515 (unless (eq nparts (cdr handle))
6516 (mm-destroy-parts (cdr handle))
6517 (setcdr handle nparts))))
6518 (setq point (point))
6519 (gnus-mime-display-security handle)
6520 (goto-char (point-max)))
6522 (delete-region (point) (cdr region))
6523 (set-marker (car region) nil)
6524 (set-marker (cdr region) nil))
6527 (defun gnus-mime-security-show-details (handle)
6528 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6530 (if gnus-mime-security-show-details-inline
6531 (let ((gnus-mime-security-button-pressed t)
6532 (gnus-mime-security-button-line-format
6533 (get-text-property (point) 'gnus-line-format))
6536 (while (eq (get-text-property (point) 'gnus-line-format)
6537 gnus-mime-security-button-line-format)
6541 (narrow-to-region (point) (point))
6542 (gnus-insert-mime-security-button handle))
6543 (delete-region (point)
6544 (or (text-property-not-all
6547 gnus-mime-security-button-line-format)
6549 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6550 (with-current-buffer gnus-mime-security-details-buffer
6553 (setq gnus-mime-security-details-buffer
6554 (gnus-get-buffer-create "*MIME Security Details*")))
6555 (with-current-buffer gnus-mime-security-details-buffer
6557 (goto-char (point-min)))
6558 (pop-to-buffer gnus-mime-security-details-buffer))
6559 (gnus-message 5 "No details."))))
6561 (defun gnus-mime-security-press-button (handle)
6562 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6563 (gnus-mime-security-show-details handle)
6564 (gnus-mime-security-verify-or-decrypt handle)))
6566 (defun gnus-insert-mime-security-button (handle &optional displayed)
6567 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6570 (or (nth 2 (assoc protocol mm-verify-function-alist))
6571 (nth 2 (assoc protocol mm-decrypt-function-alist))
6573 (if (equal (car handle) "multipart/signed")
6574 " Signed" " Encrypted")
6577 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6580 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6581 gnus-tmp-pressed-details
6583 (setq gnus-tmp-details
6584 (if gnus-tmp-details
6585 (concat "\n" gnus-tmp-details) ""))
6586 (setq gnus-tmp-pressed-details
6587 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6592 gnus-mime-security-button-line-format
6593 gnus-mime-security-button-line-format-alist
6594 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6595 gnus-callback gnus-mime-security-press-button
6596 gnus-line-format ,gnus-mime-security-button-line-format
6597 article-type annotation
6600 (widget-convert-button
6603 :action 'gnus-widget-press-button
6604 :button-keymap gnus-mime-security-button-map
6606 (lambda (widget/window &optional overlay pos)
6607 ;; Needed to properly clear the message due to a bug in
6608 ;; wid-edit (XEmacs only).
6609 (if (boundp 'help-echo-owns-message)
6610 (setq help-echo-owns-message t))
6613 (aref gnus-mouse-2 0))))))
6615 (defun gnus-mime-display-security (handle)
6617 (narrow-to-region (point) (point))
6618 (unless (gnus-unbuttonized-mime-type-p (car handle))
6619 (gnus-insert-mime-security-button handle))
6620 (gnus-mime-display-mixed (cdr handle))
6623 (unless (gnus-unbuttonized-mime-type-p (car handle))
6624 (let ((gnus-mime-security-button-line-format
6625 gnus-mime-security-button-end-line-format))
6626 (gnus-insert-mime-security-button handle)))
6627 (mm-set-handle-multipart-parameter
6629 (cons (set-marker (make-marker) (point-min))
6630 (set-marker (make-marker) (point-max))))))
6636 (defun gnus-article-header-presentation-method (entity situation)
6637 (mime-insert-header entity)
6638 (article-decode-group-name))
6640 (set-alist 'mime-header-presentation-method-alist
6641 'gnus-original-article-mode
6642 #'gnus-article-header-presentation-method)
6644 (defun gnus-mime-preview-quitting-method ()
6645 (mime-preview-kill-buffer)
6646 (delete-other-windows)
6647 (gnus-article-show-summary)
6648 (gnus-summary-select-article gnus-show-all-headers t))
6650 (set-alist 'mime-preview-quitting-method-alist
6651 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6653 (set-alist 'mime-preview-following-method-alist
6654 'gnus-original-article-mode #'gnus-following-method)
6656 (set-alist 'mime-preview-over-to-previous-method-alist
6657 'gnus-original-article-mode
6659 (if (> (point-min) 1)
6660 (gnus-article-prev-page)
6661 (gnus-article-read-summary-keys
6662 nil (gnus-character-to-event ?P)))))
6664 (set-alist 'mime-preview-over-to-next-method-alist
6665 'gnus-original-article-mode'
6667 (if (< (point-max) (buffer-size))
6668 (gnus-article-next-page)
6669 (gnus-article-read-summary-keys
6670 nil (gnus-character-to-event ?N)))))
6680 (run-hooks 'gnus-art-load-hook)
6682 ;;; gnus-art.el ends here