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."
2296 (narrow-to-region (point) (point-max))
2297 (let ((w3m-safe-url-regexp "\\`cid:")
2298 (w3m-display-inline-images mm-inline-text-html-with-images))
2299 (w3m-region (point-min) (point-max)))
2300 (when mm-inline-text-html-with-w3m-keymap
2301 (add-text-properties
2302 (point-min) (point-max)
2303 (append '(mm-inline-text-html-with-w3m t)
2304 (gnus-local-map-property mm-w3m-mode-map))))))
2306 (defun article-hide-list-identifiers ()
2307 "Remove list identifies from the Subject header.
2308 The `gnus-list-identifiers' variable specifies what to do."
2310 (let ((inhibit-point-motion-hooks t)
2311 (regexp (if (consp gnus-list-identifiers)
2312 (mapconcat 'identity gnus-list-identifiers " *\\|")
2313 gnus-list-identifiers))
2318 (article-narrow-to-head)
2319 (goto-char (point-min))
2320 (while (re-search-forward
2321 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2323 (delete-region (match-beginning 2) (match-end 0))
2324 (beginning-of-line))
2325 (when (re-search-forward
2326 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2327 (delete-region (match-beginning 1) (match-end 1))))))))
2329 (defun article-hide-pgp ()
2330 "Remove any PGP headers and signatures in the current article."
2334 (let ((inhibit-point-motion-hooks t)
2335 buffer-read-only beg end)
2337 ;; Hide the "header".
2338 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2339 (gnus-add-wash-type 'pgp)
2340 (delete-region (match-beginning 0) (match-end 0))
2341 ;; Remove armor headers (rfc2440 6.2)
2342 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2345 ;; Hide the actual signature.
2346 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2347 (setq end (1+ (match-beginning 0)))
2350 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2352 ;; Perhaps we shouldn't hide to the end of the buffer
2353 ;; if there is no end to the signature?
2355 ;; Hide "- " PGP quotation markers.
2357 (narrow-to-region beg end)
2358 (goto-char (point-min))
2359 (while (re-search-forward "^- " nil t)
2361 (match-beginning 0) (match-end 0)))
2363 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2365 (defun article-hide-pem (&optional arg)
2366 "Toggle hiding of any PEM headers and signatures in the current article.
2367 If given a negative prefix, always show; if given a positive prefix,
2369 (interactive (gnus-article-hidden-arg))
2370 (unless (gnus-article-check-hidden-text 'pem arg)
2372 (let (buffer-read-only end)
2373 (goto-char (point-min))
2374 ;; Hide the horrendously ugly "header".
2375 (when (and (search-forward
2376 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2378 (setq end (1+ (match-beginning 0))))
2379 (gnus-add-wash-type 'pem)
2380 (gnus-article-hide-text-type
2382 (if (search-forward "\n\n" nil t)
2386 ;; Hide the trailer as well
2387 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2389 (gnus-article-hide-text-type
2390 (match-beginning 0) (match-end 0) 'pem)))))))
2392 (defun article-strip-banner ()
2393 "Strip the banner specified by the `banner' group parameter."
2397 (let ((inhibit-point-motion-hooks t)
2398 (banner (gnus-parameter-banner gnus-newsgroup-name))
2399 (gnus-signature-limit nil)
2400 buffer-read-only beg end)
2404 ((eq banner 'signature)
2405 (when (gnus-article-narrow-to-signature)
2408 (delete-region (point) (point-max))))
2410 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2411 (while (re-search-forward banner nil t)
2412 (delete-region (match-beginning 0) (match-end 0)))))
2414 (while (re-search-forward banner nil t)
2415 (delete-region (match-beginning 0) (match-end 0))))))))))
2417 (defun article-babel ()
2418 "Translate article using an online translation service."
2422 (set-buffer gnus-article-buffer)
2423 (when (article-goto-body)
2424 (let* ((buffer-read-only nil)
2427 (orig (buffer-substring start end))
2428 (trans (babel-as-string orig)))
2430 (narrow-to-region start end)
2431 (delete-region start end)
2434 (defun article-hide-signature (&optional arg)
2435 "Hide the signature in the current article.
2436 If given a negative prefix, always show; if given a positive prefix,
2438 (interactive (gnus-article-hidden-arg))
2444 (article-goto-body))
2445 (goto-char (point-min)))
2446 (unless (gnus-article-check-hidden-text 'signature arg)
2447 (let ((buffer-read-only nil)
2449 (while (setq button (text-property-any button (point-max)
2451 'gnus-signature-toggle))
2452 (setq button (text-property-not-all button (point-max)
2454 'gnus-signature-toggle))
2455 (when (and button (not (eobp)))
2456 (gnus-article-hide-text-type
2458 (next-single-property-change (1+ button) 'mime-view-entity
2461 (gnus-set-mode-line 'article))
2463 (defun article-strip-headers-in-body ()
2464 "Strip offensive headers from bodies."
2468 (let ((case-fold-search t))
2469 (when (looking-at "x-no-archive:")
2470 (gnus-delete-line)))))
2472 (defun article-strip-leading-blank-lines ()
2473 "Remove all blank lines from the beginning of the article."
2476 (let ((inhibit-point-motion-hooks t)
2478 (when (article-goto-body)
2479 (while (and (not (eobp))
2480 (looking-at "[ \t]*$"))
2481 (gnus-delete-line))))))
2483 (defun article-narrow-to-head ()
2484 "Narrow the buffer to the head of the message.
2485 Point is left at the beginning of the narrowed-to region."
2487 (goto-char (point-min))
2488 (if (search-forward "\n\n" nil 1)
2491 (goto-char (point-min)))
2493 (defun article-goto-body ()
2494 "Place point at the start of the body."
2495 (goto-char (point-min))
2497 ;; This variable is only bound when dealing with separate
2499 (article-goto-body-goes-to-point-min-p
2501 ((search-forward "\n\n" nil t)
2504 (goto-char (point-max))
2507 (defun article-strip-multiple-blank-lines ()
2508 "Replace consecutive blank lines with one empty line."
2511 (let ((inhibit-point-motion-hooks t)
2513 ;; First make all blank lines empty.
2515 (while (re-search-forward "^[ \t]+$" nil t)
2516 (unless (gnus-annotation-in-region-p
2517 (match-beginning 0) (match-end 0))
2518 (replace-match "" nil t)))
2519 ;; Then replace multiple empty lines with a single empty line.
2521 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2522 (unless (gnus-annotation-in-region-p
2523 (match-beginning 0) (match-end 0))
2524 (delete-region (match-beginning 1) (match-end 1)))))))
2526 (defun article-strip-leading-space ()
2527 "Remove all white space from the beginning of the lines in the article."
2530 (let ((inhibit-point-motion-hooks t)
2533 (while (re-search-forward "^[ \t]+" nil t)
2534 (replace-match "" t t)))))
2536 (defun article-strip-trailing-space ()
2537 "Remove all white space from the end of the lines in the article."
2540 (let ((inhibit-point-motion-hooks t)
2543 (while (re-search-forward "[ \t]+$" nil t)
2544 (replace-match "" t t)))))
2546 (defun article-strip-blank-lines ()
2547 "Strip leading, trailing and multiple blank lines."
2549 (article-strip-leading-blank-lines)
2550 (article-remove-trailing-blank-lines)
2551 (article-strip-multiple-blank-lines))
2553 (defun article-strip-all-blank-lines ()
2554 "Strip all blank lines."
2557 (let ((inhibit-point-motion-hooks t)
2560 (while (re-search-forward "^[ \t]*\n" nil t)
2561 (replace-match "" t t)))))
2563 (defun gnus-article-narrow-to-signature ()
2564 "Narrow to the signature; return t if a signature is found, else nil."
2565 (let ((inhibit-point-motion-hooks t))
2566 (when (gnus-article-search-signature)
2568 ;; Check whether we have some limits to what we consider
2569 ;; to be a signature.
2570 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2571 (list gnus-signature-limit)))
2573 (while (setq limit (pop limits))
2574 (if (or (and (integerp limit)
2575 (< (- (point-max) (point)) limit))
2577 (< (count-lines (point) (point-max)) limit))
2578 (and (gnus-functionp limit)
2580 (and (stringp limit)
2581 (not (re-search-forward limit nil t))))
2582 () ; This limit did not succeed.
2586 (narrow-to-region (point) (point-max))
2589 (defun gnus-article-search-signature ()
2590 "Search the current buffer for the signature separator.
2591 Put point at the beginning of the signature separator."
2592 (let ((cur (point)))
2593 (goto-char (point-max))
2594 (if (if (stringp gnus-signature-separator)
2595 (re-search-backward gnus-signature-separator nil t)
2596 (let ((seps gnus-signature-separator))
2598 (not (re-search-backward (car seps) nil t)))
2605 (defun gnus-article-hidden-arg ()
2606 "Return the current prefix arg as a number, or 0 if no prefix."
2607 (list (if current-prefix-arg
2608 (prefix-numeric-value current-prefix-arg)
2611 (defun gnus-article-check-hidden-text (type arg)
2612 "Return nil if hiding is necessary.
2613 Arg can be nil or a number. nil and positive means hide, negative
2614 means show, 0 means toggle."
2617 (let ((hide (gnus-article-hidden-text-p type)))
2623 (gnus-article-show-hidden-text type)
2626 (if (eq hide 'hidden)
2628 (gnus-article-show-hidden-text type)
2632 (defun gnus-article-hidden-text-p (type)
2633 "Say whether the current buffer contains hidden text of type TYPE."
2634 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2636 (not (get-text-property pos 'invisible))
2637 (not (get-text-property pos 'dummy-invisible)))
2639 (text-property-any (1+ pos) (point-max) 'article-type type)))
2644 (defun gnus-article-show-hidden-text (type &optional dummy)
2645 "Show all hidden text of type TYPE.
2646 Originally it is hide instead of DUMMY."
2647 (let ((buffer-read-only nil)
2648 (inhibit-point-motion-hooks t))
2649 (gnus-remove-text-properties-when
2651 (point-min) (point-max)
2652 (cons 'article-type (cons type
2653 gnus-hidden-properties)))
2654 (gnus-delete-wash-type type)))
2656 (defconst article-time-units
2657 `((year . ,(* 365.25 24 60 60))
2658 (week . ,(* 7 24 60 60))
2659 (day . ,(* 24 60 60))
2663 "Mapping from time units to seconds.")
2665 (defun article-date-ut (&optional type highlight header)
2666 "Convert DATE date to universal time in the current article.
2667 If TYPE is `local', convert to local time; if it is `lapsed', output
2668 how much time has lapsed since DATE. For `lapsed', the value of
2669 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2670 should replace the \"Date:\" one, or should be added below it."
2671 (interactive (list 'ut t))
2672 (let* ((header (or header
2673 (and (eq 1 (point-min))
2674 (mail-header-date (save-excursion
2675 (set-buffer gnus-summary-buffer)
2676 gnus-current-headers)))
2677 (message-fetch-field "date")
2679 (date (if (vectorp header) (mail-header-date header)
2681 (inhibit-point-motion-hooks t)
2682 bface eface date-pos)
2683 (when (and date (not (string= date "")))
2686 (article-narrow-to-head)
2687 (when (or (and (eq type 'lapsed)
2688 gnus-article-date-lapsed-new-header
2689 ;; Attempt to get the face of X-Sent first.
2690 (re-search-forward "^X-Sent:[ \t]" nil t))
2691 (re-search-forward "^Date:[ \t]" nil t)
2692 ;; If Date is missing, try again for X-Sent.
2693 (re-search-forward "^X-Sent:[ \t]" nil t))
2694 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2695 date (or (get-text-property (gnus-point-at-bol)
2698 eface (get-text-property (1- (gnus-point-at-eol))
2700 (let ((buffer-read-only nil))
2701 ;; Delete any old X-Sent headers.
2702 (when (setq date-pos
2703 (text-property-any (point-min) (point-max)
2704 'article-date-lapsed t))
2705 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2706 (delete-region (match-beginning 0)
2707 (progn (forward-line 1) (point))))
2708 (goto-char (point-min))
2709 ;; Delete any old Date headers.
2710 (while (re-search-forward "^Date:[ \t]" nil t)
2712 (setq date-pos (match-beginning 0)))
2713 (unless (and (eq type 'lapsed)
2714 gnus-article-date-lapsed-new-header)
2715 (delete-region (match-beginning 0)
2716 (progn (message-next-header) (point)))))
2719 (goto-char date-pos)
2721 ;; Possibly, Date has been deleted.
2723 (when (and (eq type 'lapsed)
2724 gnus-article-date-lapsed-new-header
2725 (looking-at "Date:"))
2727 (goto-char (point-min)))
2728 (insert (article-make-date-line date type))
2729 (when (eq type 'lapsed)
2730 (put-text-property (gnus-point-at-bol) (point)
2731 'article-date-lapsed t))
2735 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2736 (put-text-property (match-beginning 1) (1+ (match-end 1))
2737 'original-date date)
2738 (put-text-property (match-beginning 1) (1+ (match-end 1))
2740 (put-text-property (match-beginning 2) (match-end 2)
2743 (defun article-make-date-line (date type)
2744 "Return a DATE line of TYPE."
2745 (unless (memq type '(local ut original user iso8601 lapsed english))
2746 (error "Unknown conversion type: %s" type))
2748 (let ((time (date-to-time date)))
2750 ;; Convert to the local timezone.
2752 (let ((tz (car (current-time-zone time))))
2753 (format "Date: %s %s%02d%02d" (current-time-string time)
2754 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2755 (/ (% (abs tz) 3600) 60))))
2756 ;; Convert to Universal Time.
2759 (current-time-string
2760 (let* ((e (parse-time-string date))
2761 (tm (apply 'encode-time e))
2763 (ls (- (cadr tm) (car (current-time-zone time)))))
2764 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2765 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2768 ;; Get the original date from the article.
2769 ((eq type 'original)
2770 (concat "Date: " (if (string-match "\n+$" date)
2771 (substring date 0 (match-beginning 0))
2773 ;; Let the user define the format.
2775 (if (gnus-functionp gnus-article-time-format)
2776 (funcall gnus-article-time-format time)
2779 (format-time-string gnus-article-time-format time))))
2782 (let ((tz (car (current-time-zone time))))
2785 (format-time-string "%Y%m%dT%H%M%S" time)
2786 (format "%s%02d%02d"
2787 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2788 (/ (% (abs tz) 3600) 60)))))
2789 ;; Do an X-Sent lapsed format.
2791 ;; If the date is seriously mangled, the timezone functions are
2792 ;; liable to bug out, so we ignore all errors.
2793 (let* ((now (current-time))
2794 (real-time (subtract-time now time))
2795 (real-sec (and real-time
2796 (+ (* (float (car real-time)) 65536)
2798 (sec (and real-time (abs real-sec)))
2808 ;; This is a bit convoluted, but basically we go
2809 ;; through the time units for years, weeks, etc,
2810 ;; and divide things to see whether that results
2811 ;; in positive answers.
2814 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2815 ;; The (remaining) seconds are too few to
2816 ;; be divided into this time unit.
2818 ;; It's big enough, so we output it.
2819 (setq sec (- sec (* num (cdr unit))))
2821 (concat (if prev ", " "") (int-to-string
2823 " " (symbol-name (car unit))
2824 (if (> num 1) "s" ""))
2826 article-time-units "")
2827 ;; If dates are odd, then it might appear like the
2828 ;; article was sent in the future.
2831 " in the future"))))))
2832 ;; Display the date in proper English
2834 (let ((dtime (decode-time time)))
2837 (number-to-string (nth 3 dtime))
2838 (let ((digit (% (nth 3 dtime) 10)))
2840 ((memq (nth 3 dtime) '(11 12 13)) "th")
2846 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2848 (number-to-string (nth 5 dtime))
2850 (format "%02d" (nth 2 dtime))
2852 (format "%02d" (nth 1 dtime)))))))
2854 (format "Date: %s (from Oort)" date))))
2856 (defun article-date-local (&optional highlight)
2857 "Convert the current article date to the local timezone."
2858 (interactive (list t))
2859 (article-date-ut 'local highlight))
2861 (defun article-date-english (&optional highlight)
2862 "Convert the current article date to something that is proper English."
2863 (interactive (list t))
2864 (article-date-ut 'english highlight))
2866 (defun article-date-original (&optional highlight)
2867 "Convert the current article date to what it was originally.
2868 This is only useful if you have used some other date conversion
2869 function and want to see what the date was before converting."
2870 (interactive (list t))
2871 (article-date-ut 'original highlight))
2873 (defun article-date-lapsed (&optional highlight)
2874 "Convert the current article date to time lapsed since it was sent."
2875 (interactive (list t))
2876 (article-date-ut 'lapsed highlight))
2878 (defun article-update-date-lapsed ()
2879 "Function to be run from a timer to update the lapsed time line."
2880 (let (deactivate-mark)
2885 (set-buffer (window-buffer w))
2886 (when (eq major-mode 'gnus-article-mode)
2887 (goto-char (point-min))
2888 (when (re-search-forward "^X-Sent:" nil t)
2889 (article-date-lapsed t))))
2892 (defun gnus-start-date-timer (&optional n)
2893 "Start a timer to update the X-Sent header in the article buffers.
2894 The numerical prefix says how frequently (in seconds) the function
2899 (gnus-stop-date-timer)
2900 (setq article-lapsed-timer
2901 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2903 (defun gnus-stop-date-timer ()
2904 "Stop the X-Sent timer."
2906 (when article-lapsed-timer
2907 (nnheader-cancel-timer article-lapsed-timer)
2908 (setq article-lapsed-timer nil)))
2910 (defun article-date-user (&optional highlight)
2911 "Convert the current article date to the user-defined format.
2912 This format is defined by the `gnus-article-time-format' variable."
2913 (interactive (list t))
2914 (article-date-ut 'user highlight))
2916 (defun article-date-iso8601 (&optional highlight)
2917 "Convert the current article date to ISO8601."
2918 (interactive (list t))
2919 (article-date-ut 'iso8601 highlight))
2921 ;; (defun article-show-all ()
2922 ;; "Show all hidden text in the article buffer."
2926 ;; (let ((buffer-read-only nil))
2927 ;; (gnus-article-unhide-text (point-min) (point-max))
2928 ;; (gnus-remove-text-with-property 'gnus-prev)
2929 ;; (gnus-remove-text-with-property 'gnus-next))))
2931 (defun article-show-all-headers ()
2932 "Show all hidden headers in the article buffer."
2937 (article-narrow-to-head)
2938 (let ((buffer-read-only nil))
2939 (gnus-article-unhide-text (point-min) (point-max))))))
2941 (defun article-remove-leading-whitespace ()
2942 "Remove excessive whitespace from all headers."
2946 (let ((buffer-read-only nil))
2947 (article-narrow-to-head)
2948 (goto-char (point-min))
2949 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2950 (delete-region (match-beginning 1) (match-end 1)))))))
2952 (defun article-emphasize (&optional arg)
2953 "Emphasize text according to `gnus-emphasis-alist'."
2954 (interactive (gnus-article-hidden-arg))
2955 (unless (gnus-article-check-hidden-text 'emphasis arg)
2959 (with-current-buffer gnus-summary-buffer
2960 gnus-article-emphasis-alist)
2962 gnus-emphasis-alist))
2963 (buffer-read-only nil)
2964 (props (append '(article-type emphasis)
2965 gnus-hidden-properties))
2966 regexp elem beg invisible visible face)
2969 (while (setq elem (pop alist))
2971 (setq regexp (car elem)
2972 invisible (nth 1 elem)
2973 visible (nth 2 elem)
2975 (while (re-search-forward regexp nil t)
2976 (when (and (match-beginning visible) (match-beginning invisible))
2977 (gnus-article-hide-text
2978 (match-beginning invisible) (match-end invisible) props)
2979 (gnus-article-unhide-text-type
2980 (match-beginning visible) (match-end visible) 'emphasis)
2981 (gnus-put-overlay-excluding-newlines
2982 (match-beginning visible) (match-end visible) 'face face)
2983 (gnus-add-wash-type 'emphasis)
2984 (goto-char (match-end invisible)))))))))
2986 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2987 "Setup newsgroup emphasis alist."
2988 (unless gnus-article-emphasis-alist
2989 (let ((name (and gnus-newsgroup-name
2990 (gnus-group-real-name gnus-newsgroup-name))))
2991 (make-local-variable 'gnus-article-emphasis-alist)
2992 (setq gnus-article-emphasis-alist
2994 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2995 (while (setq elem (pop alist))
2996 (when (and name (string-match (car elem) name))
2998 highlight (copy-sequence (cdr elem)))))
3000 (copy-sequence highlight-words)
3001 (if gnus-newsgroup-name
3002 (copy-sequence (gnus-group-find-parameter
3003 gnus-newsgroup-name 'highlight-words t)))
3004 gnus-emphasis-alist)))))
3007 (defvar gnus-summary-article-menu)
3008 (defvar gnus-summary-post-menu))
3010 ;;; Saving functions.
3012 (defun gnus-article-save (save-buffer file &optional num)
3013 "Save the currently selected article."
3014 (unless gnus-save-all-headers
3015 ;; Remove headers according to `gnus-saved-headers'.
3016 (let ((gnus-visible-headers
3017 (or gnus-saved-headers gnus-visible-headers))
3018 (gnus-article-buffer save-buffer))
3020 (set-buffer save-buffer)
3021 (article-hide-headers 1 t))))
3022 (save-window-excursion
3023 (if (not gnus-default-article-saver)
3024 (error "No default saver is defined")
3025 ;; !!! Magic! The saving functions all save
3026 ;; `gnus-save-article-buffer' (or so they think), but we
3027 ;; bind that variable to our save-buffer.
3028 (set-buffer gnus-article-buffer)
3029 (let* ((gnus-save-article-buffer save-buffer)
3032 ((not gnus-prompt-before-saving) 'default)
3033 ((eq gnus-prompt-before-saving 'always) nil)
3035 (gnus-number-of-articles-to-be-saved
3036 (when (eq gnus-prompt-before-saving t)
3038 (set-buffer gnus-article-current-summary)
3039 (funcall gnus-default-article-saver filename)))))
3041 (defun gnus-read-save-file-name (prompt &optional filename
3042 function group headers variable)
3044 (funcall function group headers (symbol-value variable)))
3049 ((eq filename 'default)
3055 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3058 (if (and gnus-number-of-articles-to-be-saved
3059 (> gnus-number-of-articles-to-be-saved 1))
3060 (format "these %d articles"
3061 gnus-number-of-articles-to-be-saved)
3064 ;; Let the split methods have their say.
3066 ;; No split name was found.
3069 (concat prompt " (default "
3070 (file-name-nondirectory default-name) ") ")
3071 (file-name-directory default-name)
3073 ;; A single group name is returned.
3074 ((stringp split-name)
3076 (funcall function split-name headers
3077 (symbol-value variable)))
3079 (concat prompt " (default "
3080 (file-name-nondirectory default-name) ") ")
3081 (file-name-directory default-name)
3083 ;; A single split name was found
3084 ((= 1 (length split-name))
3085 (let* ((name (expand-file-name
3087 gnus-article-save-directory))
3088 (dir (cond ((file-directory-p name)
3089 (file-name-as-directory name))
3090 ((file-exists-p name) name)
3091 (t gnus-article-save-directory))))
3093 (concat prompt " (default " name ") ")
3095 ;; A list of splits was found.
3097 (setq split-name (nreverse split-name))
3099 (let ((file-name-history
3100 (nconc split-name file-name-history)))
3104 (concat prompt " (`M-p' for defaults) ")
3105 gnus-article-save-directory
3107 gnus-article-save-directory)))
3108 (car (push result file-name-history)))))))
3109 ;; Create the directory.
3110 (gnus-make-directory (file-name-directory file))
3111 ;; If we have read a directory, we append the default file name.
3112 (when (file-directory-p file)
3113 (setq file (expand-file-name (file-name-nondirectory
3115 (file-name-as-directory file))))
3116 ;; Possibly translate some characters.
3117 (nnheader-translate-file-chars file))))))
3118 (gnus-make-directory (file-name-directory result))
3119 (set variable result)))
3121 (defun gnus-article-archive-name (group)
3122 "Return the first instance of an \"Archive-name\" in the current buffer."
3123 (let ((case-fold-search t))
3124 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3125 (nnheader-concat gnus-article-save-directory
3126 (match-string 1)))))
3128 (defun gnus-article-nndoc-name (group)
3129 "If GROUP is an nndoc group, return the name of the parent group."
3130 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3131 (gnus-group-get-parameter group 'save-article-group)))
3133 (defun gnus-summary-save-in-rmail (&optional filename)
3134 "Append this article to Rmail file.
3135 Optional argument FILENAME specifies file name.
3136 Directory to save to is default to `gnus-article-save-directory'."
3137 (setq filename (gnus-read-save-file-name
3138 "Save %s in rmail file:" filename
3139 gnus-rmail-save-name gnus-newsgroup-name
3140 gnus-current-headers 'gnus-newsgroup-last-rmail))
3141 (gnus-eval-in-buffer-window gnus-save-article-buffer
3145 (gnus-output-to-rmail filename))))
3148 (defun gnus-summary-save-in-mail (&optional filename)
3149 "Append this article to Unix mail file.
3150 Optional argument FILENAME specifies file name.
3151 Directory to save to is default to `gnus-article-save-directory'."
3152 (setq filename (gnus-read-save-file-name
3153 "Save %s in Unix mail file:" filename
3154 gnus-mail-save-name gnus-newsgroup-name
3155 gnus-current-headers 'gnus-newsgroup-last-mail))
3156 (gnus-eval-in-buffer-window gnus-save-article-buffer
3160 (if (and (file-readable-p filename)
3161 (mail-file-babyl-p filename))
3162 (rmail-output-to-rmail-file filename t)
3163 (gnus-output-to-mail filename)))))
3166 (defun gnus-summary-save-in-file (&optional filename overwrite)
3167 "Append this article to file.
3168 Optional argument FILENAME specifies file name.
3169 Directory to save to is default to `gnus-article-save-directory'."
3170 (setq filename (gnus-read-save-file-name
3171 "Save %s in file:" filename
3172 gnus-file-save-name gnus-newsgroup-name
3173 gnus-current-headers 'gnus-newsgroup-last-file))
3174 (gnus-eval-in-buffer-window gnus-save-article-buffer
3178 (when (and overwrite
3179 (file-exists-p filename))
3180 (delete-file filename))
3181 (gnus-output-to-file filename))))
3184 (defun gnus-summary-write-to-file (&optional filename)
3185 "Write this article to a file, overwriting it if the file exists.
3186 Optional argument FILENAME specifies file name.
3187 The directory to save in defaults to `gnus-article-save-directory'."
3188 (gnus-summary-save-in-file nil t))
3190 (defun gnus-summary-save-body-in-file (&optional filename)
3191 "Append this article body to a file.
3192 Optional argument FILENAME specifies file name.
3193 The directory to save in defaults to `gnus-article-save-directory'."
3194 (setq filename (gnus-read-save-file-name
3195 "Save %s body in file:" filename
3196 gnus-file-save-name gnus-newsgroup-name
3197 gnus-current-headers 'gnus-newsgroup-last-file))
3198 (gnus-eval-in-buffer-window gnus-save-article-buffer
3202 (when (article-goto-body)
3203 (narrow-to-region (point) (point-max)))
3204 (gnus-output-to-file filename))))
3207 (defun gnus-summary-save-in-pipe (&optional command)
3208 "Pipe this article to subprocess."
3210 (cond ((and (eq command 'default)
3211 gnus-last-shell-command)
3212 gnus-last-shell-command)
3217 "Shell command on %s: "
3218 (if (and gnus-number-of-articles-to-be-saved
3219 (> gnus-number-of-articles-to-be-saved 1))
3220 (format "these %d articles"
3221 gnus-number-of-articles-to-be-saved)
3223 gnus-last-shell-command))))
3224 (when (string-equal command "")
3225 (if gnus-last-shell-command
3226 (setq command gnus-last-shell-command)
3227 (error "A command is required")))
3228 (gnus-eval-in-buffer-window gnus-article-buffer
3231 (shell-command-on-region (point-min) (point-max) command nil)))
3232 (setq gnus-last-shell-command command))
3234 (defun gnus-summary-pipe-to-muttprint (&optional command)
3235 "Pipe this article to muttprint."
3236 (setq command (read-string
3237 "Print using command: " gnus-summary-muttprint-program
3238 nil gnus-summary-muttprint-program))
3239 (gnus-summary-save-in-pipe command))
3241 ;;; Article file names when saving.
3243 (defun gnus-capitalize-newsgroup (newsgroup)
3244 "Capitalize NEWSGROUP name."
3245 (when (not (zerop (length newsgroup)))
3246 (concat (char-to-string (upcase (aref newsgroup 0)))
3247 (substring newsgroup 1))))
3249 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3250 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3251 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3252 Otherwise, it is like ~/News/news/group/num."
3255 (concat (if (gnus-use-long-file-name 'not-save)
3256 (gnus-capitalize-newsgroup newsgroup)
3257 (gnus-newsgroup-directory-form newsgroup))
3258 "/" (int-to-string (mail-header-number headers)))
3259 gnus-article-save-directory)))
3261 (string-equal (file-name-directory default)
3262 (file-name-directory last-file))
3263 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3265 (or last-file default))))
3267 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3268 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3269 If variable `gnus-use-long-file-name' is non-nil, it is
3270 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3273 (concat (if (gnus-use-long-file-name 'not-save)
3275 (gnus-newsgroup-directory-form newsgroup))
3276 "/" (int-to-string (mail-header-number headers)))
3277 gnus-article-save-directory)))
3279 (string-equal (file-name-directory default)
3280 (file-name-directory last-file))
3281 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3283 (or last-file default))))
3285 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3286 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3287 If variable `gnus-use-long-file-name' is non-nil, it is
3288 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3291 (if (gnus-use-long-file-name 'not-save)
3294 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3296 gnus-article-save-directory)))
3298 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3299 "Generate file name from sender."
3300 (let ((from (mail-header-from headers)))
3302 (if (and from (string-match "\\([^ <]+\\)@" from))
3303 (match-string 1 from)
3305 gnus-article-save-directory)))
3307 (defun article-verify-x-pgp-sig ()
3310 (if (gnus-buffer-live-p gnus-original-article-buffer)
3311 (let ((sig (with-current-buffer gnus-original-article-buffer
3312 (gnus-fetch-field "X-PGP-Sig")))
3316 (mml2015-clear-verify-function))
3318 (insert-buffer gnus-original-article-buffer)
3319 (setq items (split-string sig))
3320 (message-narrow-to-head)
3321 (let ((inhibit-point-motion-hooks t)
3322 (case-fold-search t))
3323 ;; Don't verify multiple headers.
3324 (setq headers (mapconcat (lambda (header)
3326 (mail-fetch-field header) "\n"))
3327 (split-string (nth 1 items) ",") "")))
3328 (delete-region (point-min) (point-max))
3329 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3330 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3335 (if (looking-at "^-")
3338 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3339 (insert "Version: " (car items) "\n\n")
3340 (insert (mapconcat 'identity (cddr items) "\n"))
3341 (insert "\n-----END PGP SIGNATURE-----\n")
3342 (let ((mm-security-handle (list (format "multipart/signed"))))
3343 (mml2015-clean-buffer)
3344 (let ((coding-system-for-write (or gnus-newsgroup-charset
3346 (funcall (mml2015-clear-verify-function)))
3348 (or (mm-handle-multipart-ctl-parameter
3349 mm-security-handle 'gnus-details)
3350 (mm-handle-multipart-ctl-parameter
3351 mm-security-handle 'gnus-info)))))
3353 (let (buffer-read-only bface eface)
3355 (message-narrow-to-head)
3356 (goto-char (point-max))
3358 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3359 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3360 (message-remove-header "X-Gnus-PGP-Verify")
3361 (if (re-search-forward "^X-PGP-Sig:" nil t)
3363 (goto-char (point-max)))
3364 (narrow-to-region (point) (point))
3365 (insert "X-Gnus-PGP-Verify: " info "\n")
3366 (goto-char (point-min))
3369 (if (not (looking-at "^[ \t]"))
3373 (goto-char (point-min))
3374 (when (looking-at "\\([^:]+\\): *")
3375 (put-text-property (match-beginning 1) (1+ (match-end 1))
3377 (put-text-property (match-end 0) (point-max)
3378 'face eface)))))))))
3380 (defun article-verify-cancel-lock ()
3381 "Verify Cancel-Lock header."
3383 (if (gnus-buffer-live-p gnus-original-article-buffer)
3384 (canlock-verify gnus-original-article-buffer)))
3391 (setq afunc (car func)
3394 gfunc (intern (format "gnus-%s" func))))
3396 (when (fboundp afunc)
3397 `(lambda (&optional interactive &rest args)
3398 ,(documentation afunc t)
3399 (interactive (list t))
3401 (set-buffer gnus-article-buffer)
3403 (call-interactively ',afunc)
3404 (apply ',afunc args))))))))
3405 '(article-hide-headers
3406 article-verify-x-pgp-sig
3407 article-verify-cancel-lock
3408 article-hide-boring-headers
3409 article-toggle-headers
3410 article-treat-overstrike
3411 article-fill-long-lines
3412 article-capitalize-sentences
3414 article-remove-leading-whitespace
3415 article-display-x-face
3416 article-de-quoted-unreadable
3417 article-de-base64-unreadable
3420 article-hide-list-identifiers
3422 article-strip-banner
3425 article-hide-signature
3426 article-strip-headers-in-body
3427 article-remove-trailing-blank-lines
3428 article-strip-leading-blank-lines
3429 article-strip-multiple-blank-lines
3430 article-strip-leading-space
3431 article-strip-trailing-space
3432 article-strip-blank-lines
3433 article-strip-all-blank-lines
3435 article-date-english
3436 article-date-iso8601
3437 article-date-original
3439 article-decode-mime-words
3440 article-decode-charset
3441 article-decode-encoded-words
3445 article-treat-dumbquotes
3446 article-normalize-headers
3447 (article-show-all-headers . gnus-article-show-all-headers)
3448 ;; (article-show-all . gnus-article-show-all)
3452 ;;; Gnus article mode
3455 (put 'gnus-article-mode 'mode-class 'special)
3457 (gnus-define-keys gnus-article-mode-map
3458 " " gnus-article-goto-next-page
3459 "\177" gnus-article-goto-prev-page
3460 [delete] gnus-article-goto-prev-page
3461 [backspace] gnus-article-goto-prev-page
3462 "\C-c^" gnus-article-refer-article
3463 "h" gnus-article-show-summary
3464 "s" gnus-article-show-summary
3465 "\C-c\C-m" gnus-article-mail
3466 "?" gnus-article-describe-briefly
3467 "e" gnus-summary-edit-article
3468 "<" beginning-of-buffer
3470 "\C-c\C-i" gnus-info-find-node
3472 "R" gnus-article-reply-with-original
3473 "F" gnus-article-followup-with-original
3474 "\C-hk" gnus-article-describe-key
3475 "\C-hc" gnus-article-describe-key-briefly
3477 "\C-d" gnus-article-read-summary-keys
3478 "\M-*" gnus-article-read-summary-keys
3479 "\M-#" gnus-article-read-summary-keys
3480 "\M-^" gnus-article-read-summary-keys
3481 "\M-g" gnus-article-read-summary-keys)
3483 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3487 (push (char-to-string key) keys)
3489 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3490 (setq key (car elem))
3491 (when (and (> (length key) 0)
3492 (not (eq 'menu-bar (aref key 0)))
3493 (symbolp (lookup-key gnus-summary-mode-map key)))
3496 (unless (lookup-key gnus-article-mode-map key)
3497 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3499 (defun gnus-article-make-menu-bar ()
3500 (unless (boundp 'gnus-article-commands-menu)
3501 (gnus-summary-make-menu-bar))
3502 (gnus-turn-off-edit-menu 'article)
3503 (unless (boundp 'gnus-article-article-menu)
3505 gnus-article-article-menu gnus-article-mode-map ""
3507 ["Scroll forwards" gnus-article-goto-next-page t]
3508 ["Scroll backwards" gnus-article-goto-prev-page t]
3509 ["Show summary" gnus-article-show-summary t]
3510 ["Fetch Message-ID at point" gnus-article-refer-article t]
3511 ["Mail to address at point" gnus-article-mail t]
3512 ["Send a bug report" gnus-bug t]))
3515 gnus-article-treatment-menu gnus-article-mode-map ""
3516 ;; Fixme: this should use :active (and maybe :visible).
3518 ["Hide headers" gnus-article-toggle-headers t]
3519 ["Hide signature" gnus-article-hide-signature t]
3520 ["Hide citation" gnus-article-hide-citation t]
3521 ["Treat overstrike" gnus-article-treat-overstrike t]
3522 ["Remove carriage return" gnus-article-remove-cr t]
3523 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3524 ["Treat html" gnus-article-wash-html t]
3525 ["Decode HZ" gnus-article-decode-HZ t]))
3527 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3529 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3531 (gnus-run-hooks 'gnus-article-menu-hook)))
3533 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3536 (defun gnus-article-mode ()
3537 "Major mode for displaying an article.
3539 All normal editing commands are switched off.
3541 The following commands are available in addition to all summary mode
3543 \\<gnus-article-mode-map>
3544 \\[gnus-article-next-page]\t Scroll the article one page forwards
3545 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3546 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3547 \\[gnus-article-show-summary]\t Display the summary buffer
3548 \\[gnus-article-mail]\t Send a reply to the address near point
3549 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3550 \\[gnus-info-find-node]\t Go to the Gnus info node"
3552 (gnus-simplify-mode-line)
3553 (setq mode-name "Article")
3554 (setq major-mode 'gnus-article-mode)
3555 (make-local-variable 'minor-mode-alist)
3556 (unless (assq 'gnus-show-mime minor-mode-alist)
3557 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3558 (use-local-map gnus-article-mode-map)
3559 (when (gnus-visual-p 'article-menu 'menu)
3560 (gnus-article-make-menu-bar))
3561 (gnus-update-format-specifications nil 'article-mode)
3562 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3563 (make-local-variable 'gnus-page-broken)
3564 (make-local-variable 'gnus-button-marker-list)
3565 (make-local-variable 'gnus-article-current-summary)
3566 (make-local-variable 'gnus-article-mime-handles)
3567 (make-local-variable 'gnus-article-decoded-p)
3568 (make-local-variable 'gnus-article-mime-handle-alist)
3569 (make-local-variable 'gnus-article-wash-types)
3570 (make-local-variable 'gnus-article-image-alist)
3571 (make-local-variable 'gnus-article-charset)
3572 (make-local-variable 'gnus-article-ignored-charsets)
3573 (gnus-set-default-directory)
3574 (buffer-disable-undo)
3575 (setq buffer-read-only t)
3576 (set-syntax-table gnus-article-mode-syntax-table)
3577 (gnus-run-hooks 'gnus-article-mode-hook))
3579 (defun gnus-article-setup-buffer ()
3580 "Initialize the article buffer."
3581 (let* ((name (if gnus-single-article-buffer "*Article*"
3582 (concat "*Article " gnus-newsgroup-name "*")))
3584 (progn (string-match "\\*Article" name)
3585 (concat " *Original Article"
3586 (substring name (match-end 0))))))
3587 (setq gnus-article-buffer name)
3588 (setq gnus-original-article-buffer original)
3589 (setq gnus-article-mime-handle-alist nil)
3590 ;; This might be a variable local to the summary buffer.
3591 (unless gnus-single-article-buffer
3593 (set-buffer gnus-summary-buffer)
3594 (setq gnus-article-buffer name)
3595 (setq gnus-original-article-buffer original)
3596 (gnus-set-global-variables)))
3597 (gnus-article-setup-highlight-words)
3598 ;; Init original article buffer.
3600 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3601 (set-buffer-multibyte t)
3602 (setq major-mode 'gnus-original-article-mode)
3603 (make-local-variable 'gnus-original-article))
3604 (if (get-buffer name)
3607 (buffer-disable-undo)
3608 (setq buffer-read-only t)
3609 (unless (eq major-mode 'gnus-article-mode)
3610 (gnus-article-mode))
3613 (set-buffer (gnus-get-buffer-create name))
3615 (make-local-variable 'gnus-summary-buffer)
3616 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3617 (current-buffer)))))
3619 ;; Set article window start at LINE, where LINE is the number of lines
3620 ;; from the head of the article.
3621 (defun gnus-article-set-window-start (&optional line)
3623 (gnus-get-buffer-window gnus-article-buffer t)
3625 (set-buffer gnus-article-buffer)
3626 (goto-char (point-min))
3629 (gnus-message 6 "Moved to bookmark")
3630 (search-forward "\n\n" nil t)
3634 ;;; @@ article filters
3637 (defun gnus-article-display-mime-message ()
3638 "Article display method for MIME message."
3639 ;; called from `gnus-original-article-buffer'.
3640 (let (charset all-headers)
3641 (with-current-buffer gnus-summary-buffer
3642 (setq charset default-mime-charset
3643 all-headers gnus-have-all-headers))
3644 (make-local-variable 'default-mime-charset)
3645 (setq default-mime-charset charset)
3646 (with-current-buffer (get-buffer-create gnus-article-buffer)
3647 (make-local-variable 'default-mime-charset)
3648 (setq default-mime-charset charset))
3649 (mime-display-message mime-message-structure
3650 gnus-article-buffer nil gnus-article-mode-map)
3652 (gnus-article-hide-headers nil -1)))
3653 (run-hooks 'gnus-mime-article-prepare-hook))
3655 (defun gnus-article-display-traditional-message ()
3656 "Article display method for traditional message."
3657 (set-buffer gnus-article-buffer)
3658 (let (buffer-read-only)
3660 (set-buffer-multibyte nil)
3661 (insert-buffer-substring gnus-original-article-buffer)
3662 (set-buffer-multibyte t)))
3664 (defun gnus-article-make-full-mail-header (&optional number charset)
3665 "Create a new mail header structure in a raw article buffer."
3666 (unless (and number charset)
3667 (save-current-buffer
3668 (set-buffer gnus-summary-buffer)
3670 (setq number (or (cdr gnus-article-current) 0)))
3672 (setq charset (or default-mime-charset 'x-ctext)))))
3673 (goto-char (point-min))
3674 (let ((header-end (if (search-forward "\n\n" nil t)
3676 (goto-char (point-max))))
3677 (chars (- (point-max) (point)))
3678 (lines (count-lines (point) (point-max)))
3679 (default-mime-charset charset)
3681 (narrow-to-region (point-min) header-end)
3682 (setq xref (std11-fetch-field "xref"))
3684 (make-full-mail-header
3686 (std11-fetch-field "subject")
3687 (std11-fetch-field "from")
3688 (std11-fetch-field "date")
3689 (std11-fetch-field "message-id")
3690 (std11-fetch-field "references")
3693 (when xref (concat "Xref: " xref)))
3696 (defun gnus-article-prepare (article &optional all-headers header)
3697 "Prepare ARTICLE in article mode buffer.
3698 ARTICLE should either be an article number or a Message-ID.
3699 If ARTICLE is an id, HEADER should be the article headers.
3700 If ALL-HEADERS is non-nil, no headers are hidden."
3702 ;; Make sure we start in a summary buffer.
3703 (unless (eq major-mode 'gnus-summary-mode)
3704 (set-buffer gnus-summary-buffer))
3705 (setq gnus-summary-buffer (current-buffer))
3706 (let* ((gnus-article (if header (mail-header-number header) article))
3707 (summary-buffer (current-buffer))
3708 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3709 (group gnus-newsgroup-name)
3712 (gnus-article-setup-buffer)
3713 (set-buffer gnus-article-buffer)
3714 ;; Deactivate active regions.
3715 (when (and (boundp 'transient-mark-mode)
3716 transient-mark-mode)
3717 (setq mark-active nil))
3718 (if (not (setq result (let ((buffer-read-only nil))
3719 (gnus-request-article-this-buffer
3721 ;; There is no such article.
3723 (when (and (numberp article)
3724 (not (memq article gnus-newsgroup-sparse)))
3725 (setq gnus-article-current
3726 (cons gnus-newsgroup-name article))
3727 (set-buffer gnus-summary-buffer)
3728 (setq gnus-current-article article)
3729 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3731 (gnus-summary-set-agent-mark article)
3732 (message "Message marked for downloading"))
3733 (gnus-summary-mark-article article gnus-canceled-mark)
3734 (unless (memq article gnus-newsgroup-sparse)
3735 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3736 (if (or (eq result 'pseudo)
3737 (eq result 'nneething))
3740 (set-buffer summary-buffer)
3741 (push article gnus-newsgroup-history)
3742 (setq gnus-last-article gnus-current-article
3743 gnus-current-article 0
3744 gnus-current-headers nil
3745 gnus-article-current nil)
3746 (if (eq result 'nneething)
3747 (gnus-configure-windows 'summary)
3748 (gnus-configure-windows 'article))
3749 (gnus-set-global-variables))
3750 (let ((gnus-article-mime-handle-alist-1
3751 gnus-article-mime-handle-alist))
3752 (gnus-set-mode-line 'article)))
3753 ;; The result from the `request' was an actual article -
3754 ;; or at least some text that is now displayed in the
3756 (when (and (numberp article)
3757 (not (eq article gnus-current-article)))
3758 ;; Seems like a new article has been selected.
3759 ;; `gnus-current-article' must be an article number.
3761 (set-buffer summary-buffer)
3762 (push article gnus-newsgroup-history)
3763 (setq gnus-last-article gnus-current-article
3764 gnus-current-article article
3765 gnus-current-headers
3766 (gnus-summary-article-header gnus-current-article)
3767 gnus-article-current
3768 (cons gnus-newsgroup-name gnus-current-article))
3769 (unless (vectorp gnus-current-headers)
3770 (setq gnus-current-headers nil))
3771 (gnus-summary-goto-subject gnus-current-article)
3772 (when (gnus-summary-show-thread)
3773 ;; If the summary buffer really was folded, the
3774 ;; previous goto may not actually have gone to
3775 ;; the right article, but the thread root instead.
3777 (gnus-summary-goto-subject gnus-current-article))
3778 (gnus-run-hooks 'gnus-mark-article-hook)
3779 (gnus-set-mode-line 'summary)
3780 (when (gnus-visual-p 'article-highlight 'highlight)
3781 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3782 ;; Set the global newsgroup variables here.
3783 (gnus-set-global-variables)
3784 (setq gnus-have-all-headers
3785 (or all-headers gnus-show-all-headers))))
3787 (gnus-configure-windows 'article))
3788 (when (or (numberp article)
3790 (gnus-article-prepare-display)
3792 (goto-char (point-min))
3793 (setq gnus-page-broken
3794 (when gnus-break-pages
3795 (gnus-narrow-to-page)
3797 (let ((gnus-article-mime-handle-alist-1
3798 gnus-article-mime-handle-alist))
3799 (gnus-set-mode-line 'article))
3801 (set-window-point (get-buffer-window (current-buffer)) (point))
3802 (gnus-configure-windows 'article)
3805 (defun gnus-article-prepare-mime-display (&optional number)
3806 (goto-char (point-min))
3807 (when (re-search-forward "^[^\t ]+:" nil t)
3808 (goto-char (match-beginning 0)))
3809 (let ((entity (if (eq 1 (point-min))
3810 (get-text-property 1 'mime-view-entity)
3811 (get-text-property (point) 'mime-view-entity)))
3812 last-entity child-entity next type)
3813 (setq child-entity (mime-entity-children entity))
3815 (setq last-entity (nth (1- (length child-entity))
3817 (setq last-entity entity))
3819 (narrow-to-region (point)
3820 (if (search-forward "\n\n" nil t)
3823 (gnus-treat-article 'head)
3824 (put-text-property (point-min) (point-max) 'article-treated-header t)
3825 (goto-char (point-max)))
3826 (while (and (not (eobp)) entity)
3827 (setq next (set-marker
3829 (next-single-property-change (point) 'mime-view-entity
3831 (let ((types (mime-entity-content-type entity)))
3832 (while (eq 'multipart (mime-content-type-primary-type types))
3833 (setq entity (car (mime-entity-children entity))
3834 types (mime-entity-content-type entity)))
3836 (setq type (format "%s/%s"
3837 (mime-content-type-primary-type types)
3838 (mime-content-type-subtype types)))))
3839 (if (string-equal type "message/rfc822")
3842 (let ((children (mime-entity-children entity))
3845 (setq last-children (nth (1- (length children)) children))
3848 (not (eq last-children
3849 (get-text-property next 'mime-view-entity)))
3851 (next-single-property-change next
3853 nil (point-max)))))))
3854 (setq next (next-single-property-change next 'mime-view-entity
3857 (narrow-to-region (point) next)
3858 (gnus-article-prepare-mime-display)
3859 (goto-char (point-max)))
3860 (setq entity (get-text-property (point) 'mime-view-entity)))
3862 (narrow-to-region (point) next)
3863 ;; Kludge. We have to count true number, but for now,
3864 ;; part number is here only to achieve `last'.
3865 (gnus-treat-article nil 1
3866 (if (eq entity last-entity)
3869 (goto-char (point-max)))
3870 (setq entity (get-text-property next 'mime-view-entity))))))
3873 (defun gnus-article-prepare-display ()
3874 "Make the current buffer look like a nice article."
3875 (let ((gnus-article-buffer (current-buffer))
3877 (unless (eq major-mode 'gnus-article-mode)
3878 (gnus-article-mode))
3879 (setq buffer-read-only nil
3880 gnus-button-marker-list nil
3881 gnus-article-wash-types nil
3882 gnus-article-image-alist nil)
3885 (static-if (featurep 'xemacs)
3886 (map-extents (lambda (extent maparg) (delete-extent extent)))
3887 (let ((lists (overlay-lists)))
3888 (dolist (overlay (nconc (car lists) (cdr lists)))
3889 (delete-overlay overlay)))))
3890 (gnus-run-hooks 'gnus-tmp-internal-hook))
3891 (set-buffer gnus-original-article-buffer)
3893 (setq mime-message-structure gnus-current-headers)
3894 (mime-buffer-entity-set-buffer-internal mime-message-structure
3895 gnus-original-article-buffer)
3896 (mime-entity-set-representation-type-internal mime-message-structure
3897 'mime-buffer-entity)
3898 (luna-send mime-message-structure 'initialize-instance
3899 mime-message-structure)
3901 (let (mime-display-header-hook mime-display-text/plain-hook)
3902 (funcall gnus-article-display-method-for-mime))
3903 (funcall gnus-article-display-method-for-traditional))
3904 ;; Call the treatment functions.
3905 (let ((inhibit-read-only t))
3909 (gnus-article-prepare-mime-display)
3910 (narrow-to-region (goto-char (point-min))
3911 (if (search-forward "\n\n" nil t)
3914 (gnus-treat-article 'head)
3915 (put-text-property (point-min) (point-max) 'article-treated-header t)
3916 (goto-char (point-max))
3918 (narrow-to-region (point) (point-max))
3919 (gnus-treat-article nil))
3920 (put-text-property (point-min) (point-max) 'read-only nil)))
3921 (gnus-run-hooks 'gnus-article-prepare-hook))
3923 (defun gnus-article-decode-article-as-default-mime-charset ()
3924 "Decode an article as `default-mime-charset'. It won't work if the
3925 value of the variable `gnus-show-mime' is non-nil."
3926 (unless gnus-show-mime
3927 (set (make-local-variable 'default-mime-charset)
3928 (with-current-buffer gnus-summary-buffer
3929 default-mime-charset))
3930 (decode-mime-charset-region (point-min) (point-max)
3931 default-mime-charset)))
3934 ;;; Gnus MIME viewing functions
3937 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3938 "Format of the MIME buttons.
3940 Valid specifiers include:
3942 %T MIME type, along with additional info
3943 %n The `name' parameter
3944 %d The description, if any
3945 %l The length of the encoded part
3946 %p The part identifier number
3947 %e Dots if the part isn't displayed
3949 General format specifiers can also be used. See
3950 (gnus)Formatting Variables.")
3952 (defvar gnus-mime-button-line-format-alist
3953 '((?t gnus-tmp-type ?s)
3954 (?T gnus-tmp-type-long ?s)
3955 (?n gnus-tmp-name ?s)
3956 (?d gnus-tmp-description ?s)
3958 (?l gnus-tmp-length ?d)
3959 (?e gnus-tmp-dots ?s)))
3961 (defvar gnus-mime-button-commands
3962 '((gnus-article-press-button "\r" "Toggle Display")
3963 (gnus-mime-view-part "v" "View Interactively...")
3964 (gnus-mime-view-part-as-type "t" "View As Type...")
3965 (gnus-mime-view-part-as-charset "C" "View As charset...")
3966 (gnus-mime-save-part "o" "Save...")
3967 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3968 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3969 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3970 (gnus-mime-internalize-part "E" "View Internally")
3971 (gnus-mime-externalize-part "e" "View Externally")
3972 (gnus-mime-print-part "p" "Print")
3973 (gnus-mime-pipe-part "|" "Pipe To Command...")
3974 (gnus-mime-action-on-part "." "Take action on the part")))
3976 (defun gnus-article-mime-part-status ()
3977 (with-current-buffer gnus-article-buffer
3978 (let ((entity (get-text-property (point-min) 'mime-view-entity))
3981 (setq children (mime-entity-children entity))
3982 (setq children (length children)))
3985 (format " (%d parts)" children))
3988 (defvar gnus-mime-button-map
3989 (let ((map (make-sparse-keymap)))
3990 (unless (>= (string-to-number emacs-version) 21)
3991 ;; XEmacs doesn't care.
3992 (set-keymap-parent map gnus-article-mode-map))
3993 (define-key map gnus-mouse-2 'gnus-article-push-button)
3994 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3995 (dolist (c gnus-mime-button-commands)
3996 (define-key map (cadr c) (car c)))
3999 (defun gnus-mime-button-menu (event)
4000 "Construct a context-sensitive menu of MIME commands."
4002 (save-window-excursion
4003 (let ((pos (event-start event)))
4004 (select-window (posn-window pos))
4005 (goto-char (posn-point pos))
4006 (gnus-article-check-buffer)
4007 (let ((response (x-popup-menu
4009 ("" ,@(mapcar (lambda (c)
4010 (cons (caddr c) (car c)))
4011 gnus-mime-button-commands))))))
4013 (call-interactively response))))))
4015 (defun gnus-mime-view-all-parts (&optional handles)
4016 "View all the MIME parts."
4018 (save-current-buffer
4019 (set-buffer gnus-article-buffer)
4020 (let ((handles (or handles gnus-article-mime-handles))
4021 (mail-parse-charset gnus-newsgroup-charset)
4022 (mail-parse-ignored-charsets
4023 (with-current-buffer gnus-summary-buffer
4024 gnus-newsgroup-ignored-charsets)))
4026 (mm-remove-parts handles)
4027 (goto-char (point-min))
4028 (or (search-forward "\n\n") (goto-char (point-max)))
4029 (let (buffer-read-only)
4030 (delete-region (point) (point-max))
4031 (mm-display-parts handles))))))
4033 (defun gnus-mime-save-part-and-strip ()
4034 "Save the MIME part under point then replace it with an external body."
4036 (gnus-article-check-buffer)
4037 (let* ((data (get-text-property (point) 'gnus-data))
4039 (handles gnus-article-mime-handles))
4040 (if (mm-multiple-handles gnus-article-mime-handles)
4041 (error "This function is not implemented"))
4042 (setq file (and data (mm-save-part data)))
4044 (with-current-buffer (mm-handle-buffer data)
4046 (insert "Content-Type: " (mm-handle-media-type data))
4047 (mml-insert-parameter-string (cdr (mm-handle-type data))
4050 (insert "Content-ID: " (message-make-message-id) "\n")
4051 (insert "Content-Transfer-Encoding: binary\n")
4054 (cdr (mm-make-handle nil
4055 `("message/external-body"
4056 (access-type . "LOCAL-FILE")
4058 (set-buffer gnus-summary-buffer)
4059 (gnus-article-edit-article
4062 (let ((mail-parse-charset (or gnus-article-charset
4063 ',gnus-newsgroup-charset))
4064 (mail-parse-ignored-charsets
4065 (or gnus-article-ignored-charsets
4066 ',gnus-newsgroup-ignored-charsets))
4067 (mbl mml-buffer-list))
4068 (setq mml-buffer-list nil)
4069 (insert-buffer gnus-original-article-buffer)
4070 (mime-to-mml ',handles)
4071 (setq gnus-article-mime-handles nil)
4072 (let ((mbl1 mml-buffer-list))
4073 (setq mml-buffer-list mbl)
4074 (set (make-local-variable 'mml-buffer-list) mbl1))
4075 ;; LOCAL argument of add-hook differs between GNU Emacs
4076 ;; and XEmacs. make-local-hook makes sure they are local.
4077 (make-local-hook 'kill-buffer-hook)
4078 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4079 `(lambda (no-highlight)
4080 (let ((mail-parse-charset (or gnus-article-charset
4081 ',gnus-newsgroup-charset))
4082 (message-options message-options)
4083 (message-options-set-recipient)
4084 (mail-parse-ignored-charsets
4085 (or gnus-article-ignored-charsets
4086 ',gnus-newsgroup-ignored-charsets)))
4088 (mml-destroy-buffers)
4089 (remove-hook 'kill-buffer-hook
4090 'mml-destroy-buffers t)
4091 (kill-local-variable 'mml-buffer-list))
4092 (gnus-summary-edit-article-done
4093 ,(or (mail-header-references gnus-current-headers) "")
4094 ,(gnus-group-read-only-p)
4095 ,gnus-summary-buffer no-highlight))))))
4097 (defun gnus-mime-save-part ()
4098 "Save the MIME part under point."
4100 (gnus-article-check-buffer)
4101 (let ((data (get-text-property (point) 'gnus-data)))
4103 (mm-save-part data))))
4105 (defun gnus-mime-pipe-part ()
4106 "Pipe the MIME part under point to a process."
4108 (gnus-article-check-buffer)
4109 (let ((data (get-text-property (point) 'gnus-data)))
4111 (mm-pipe-part data))))
4113 (defun gnus-mime-view-part ()
4114 "Interactively choose a viewing method for the MIME part under point."
4116 (gnus-article-check-buffer)
4117 (let ((data (get-text-property (point) 'gnus-data)))
4119 (setq gnus-article-mime-handles
4121 gnus-article-mime-handles (setq data (copy-sequence data))))
4122 (mm-interactively-view-part data))))
4124 (defun gnus-mime-view-part-as-type-internal ()
4125 (gnus-article-check-buffer)
4126 (let* ((name (mail-content-type-get
4127 (mm-handle-type (get-text-property (point) 'gnus-data))
4129 (def-type (and name (mm-default-file-encoding name))))
4130 (and def-type (cons def-type 0))))
4132 (defun gnus-mime-view-part-as-type (&optional mime-type)
4133 "Choose a MIME media type, and view the part as such."
4136 (setq mime-type (completing-read
4137 "View as MIME type: "
4138 (mapcar #'list (mailcap-mime-types))
4140 (gnus-mime-view-part-as-type-internal))))
4141 (gnus-article-check-buffer)
4142 (let ((handle (get-text-property (point) 'gnus-data)))
4145 (mm-make-handle (mm-handle-buffer handle)
4146 (cons mime-type (cdr (mm-handle-type handle)))
4147 (mm-handle-encoding handle)
4148 (mm-handle-undisplayer handle)
4149 (mm-handle-disposition handle)
4150 (mm-handle-description handle)
4152 (mm-handle-id handle)))
4153 (setq gnus-article-mime-handles
4154 (mm-merge-handles gnus-article-mime-handles handle))
4155 (gnus-mm-display-part handle))))
4157 (defun gnus-mime-copy-part (&optional handle)
4158 "Put the MIME part under point into a new buffer."
4160 (gnus-article-check-buffer)
4161 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4162 (contents (and handle (mm-get-part handle)))
4164 (file-name-nondirectory
4166 (mail-content-type-get (mm-handle-type handle) 'name)
4167 (mail-content-type-get (mm-handle-type handle)
4170 (buffer (and base (generate-new-buffer base))))
4172 (switch-to-buffer buffer)
4174 ;; We do it this way to make `normal-mode' set the appropriate mode.
4177 (setq buffer-file-name (expand-file-name base))
4179 (setq buffer-file-name nil))
4180 (goto-char (point-min)))))
4182 (defun gnus-mime-print-part (&optional handle)
4183 "Print the MIME part under point."
4185 (gnus-article-check-buffer)
4186 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4187 (contents (and handle (mm-get-part handle)))
4188 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
4189 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4194 (with-temp-file file
4196 (call-process shell-file-name nil
4197 (generate-new-buffer " *mm*")
4199 shell-command-switch
4201 printer file (mm-handle-type handle))))
4205 (gnus-print-buffer))))))
4207 (defun gnus-mime-inline-part (&optional handle arg)
4208 "Insert the MIME part under point into the current buffer."
4209 (interactive (list nil current-prefix-arg))
4210 (gnus-article-check-buffer)
4211 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4216 (if (and (not arg) (mm-handle-undisplayer handle))
4217 (mm-remove-part handle)
4218 (setq contents (mm-get-part handle))
4221 (setq charset (or (mail-content-type-get
4222 (mm-handle-type handle) 'charset)
4223 gnus-newsgroup-charset)))
4225 (if (mm-handle-undisplayer handle)
4226 (mm-remove-part handle))
4229 gnus-summary-show-article-charset-alist))
4230 (mm-read-coding-system "Charset: ")))))
4232 (mm-insert-inline handle
4234 (setq charset (mm-charset-to-coding-system
4236 (not (eq charset 'ascii)))
4237 (mm-decode-coding-string contents charset)
4241 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4242 "Insert the MIME part under point into the current buffer using the
4244 (interactive (list nil current-prefix-arg))
4245 (gnus-article-check-buffer)
4246 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4251 (if (mm-handle-undisplayer handle)
4252 (mm-remove-part handle))
4253 (let ((gnus-newsgroup-charset
4255 gnus-summary-show-article-charset-alist))
4256 (mm-read-coding-system "Charset: ")))
4257 (gnus-newsgroup-ignored-charsets 'gnus-all))
4258 (gnus-article-press-button)))))
4260 (defun gnus-mime-externalize-part (&optional handle)
4261 "View the MIME part under point with an external viewer."
4263 (gnus-article-check-buffer)
4264 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4265 (mm-user-display-methods nil)
4266 (mm-inlined-types nil)
4267 (mail-parse-charset gnus-newsgroup-charset)
4268 (mail-parse-ignored-charsets
4269 (save-excursion (set-buffer gnus-summary-buffer)
4270 gnus-newsgroup-ignored-charsets)))
4272 (if (mm-handle-undisplayer handle)
4273 (mm-remove-part handle)
4274 (mm-display-part handle)))))
4276 (defun gnus-mime-internalize-part (&optional handle)
4277 "View the MIME part under point with an internal viewer.
4278 If no internal viewer is available, use an external viewer."
4280 (gnus-article-check-buffer)
4281 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4282 (mm-inlined-types '(".*"))
4283 (mm-inline-large-images t)
4284 (mail-parse-charset gnus-newsgroup-charset)
4285 (mail-parse-ignored-charsets
4286 (save-excursion (set-buffer gnus-summary-buffer)
4287 gnus-newsgroup-ignored-charsets)))
4289 (if (mm-handle-undisplayer handle)
4290 (mm-remove-part handle)
4291 (mm-display-part handle)))))
4293 (defun gnus-mime-action-on-part (&optional action)
4294 "Do something with the MIME attachment at \(point\)."
4296 (list (completing-read "Action: " gnus-mime-action-alist)))
4297 (gnus-article-check-buffer)
4298 (let ((action-pair (assoc action gnus-mime-action-alist)))
4300 (funcall (cdr action-pair)))))
4302 (defun gnus-article-part-wrapper (n function)
4303 (save-current-buffer
4304 (set-buffer gnus-article-buffer)
4305 (when (> n (length gnus-article-mime-handle-alist))
4306 (error "No such part"))
4307 (gnus-article-goto-part n)
4308 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4309 (funcall function handle))))
4311 (defun gnus-article-pipe-part (n)
4312 "Pipe MIME part N, which is the numerical prefix."
4314 (gnus-article-part-wrapper n 'mm-pipe-part))
4316 (defun gnus-article-save-part (n)
4317 "Save MIME part N, which is the numerical prefix."
4319 (gnus-article-part-wrapper n 'mm-save-part))
4321 (defun gnus-article-interactively-view-part (n)
4322 "View MIME part N interactively, which is the numerical prefix."
4324 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4326 (defun gnus-article-copy-part (n)
4327 "Copy MIME part N, which is the numerical prefix."
4329 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4331 (defun gnus-article-view-part-as-charset (n)
4332 "Copy MIME part N, which is the numerical prefix."
4334 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4336 (defun gnus-article-externalize-part (n)
4337 "View MIME part N externally, which is the numerical prefix."
4339 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
4341 (defun gnus-article-inline-part (n)
4342 "Inline MIME part N, which is the numerical prefix."
4344 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4346 (defun gnus-article-mime-match-handle-first (condition)
4348 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4349 (while (setq ihandle (pop alist))
4351 ((functionp condition)
4352 (funcall condition (cdr ihandle)))
4353 ((eq condition 'undisplayed)
4354 (not (or (mm-handle-undisplayer (cdr ihandle))
4355 (equal (mm-handle-media-type (cdr ihandle))
4356 "multipart/alternative"))))
4357 ((eq condition 'undisplayed-alternative)
4358 (not (mm-handle-undisplayer (cdr ihandle))))
4360 (gnus-article-goto-part (car ihandle))
4361 (or (not n) (< (car ihandle) n)))
4362 (setq n (car ihandle))))
4366 (defun gnus-article-view-part (&optional n)
4367 "View MIME part N, which is the numerical prefix."
4369 (save-current-buffer
4370 (set-buffer gnus-article-buffer)
4371 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4372 gnus-article-mime-match-handle-function)))
4373 (when (> n (length gnus-article-mime-handle-alist))
4374 (error "No such part"))
4375 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4376 (when (gnus-article-goto-part n)
4377 (if (equal (car handle) "multipart/alternative")
4378 (gnus-article-press-button)
4379 (when (eq (gnus-mm-display-part handle) 'internal)
4380 (gnus-set-window-start)))))))
4382 (defsubst gnus-article-mime-total-parts ()
4383 (if (bufferp (car gnus-article-mime-handles))
4385 (1- (length gnus-article-mime-handles))))
4387 (defun gnus-mm-display-part (handle)
4388 "Display HANDLE and fix MIME button."
4389 (let ((id (get-text-property (point) 'gnus-part))
4394 (let ((window (selected-window))
4395 (mail-parse-charset gnus-newsgroup-charset)
4396 (mail-parse-ignored-charsets
4397 (if (gnus-buffer-live-p gnus-summary-buffer)
4399 (set-buffer gnus-summary-buffer)
4400 gnus-newsgroup-ignored-charsets)
4404 (let ((win (gnus-get-buffer-window (current-buffer) t))
4407 (select-window win))
4410 (if (mm-handle-displayed-p handle)
4411 ;; This will remove the part.
4412 (mm-display-part handle)
4414 (narrow-to-region (point)
4415 (if (eobp) (point) (1+ (point))))
4416 (mm-display-part handle)
4417 ;; We narrow to the part itself and
4418 ;; then call the treatment functions.
4419 (goto-char (point-min))
4421 (narrow-to-region (point) (point-max))
4424 (gnus-article-mime-total-parts)
4425 (mm-handle-media-type handle)))))
4426 (if (window-live-p window)
4427 (select-window window)))))
4429 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4430 (gnus-insert-mime-button
4431 handle id (list (mm-handle-displayed-p handle)))
4432 (goto-char point))))
4434 (defun gnus-article-goto-part (n)
4435 "Go to MIME part N."
4436 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4438 (goto-char point))))
4440 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4441 (let ((gnus-tmp-name
4442 (or (mail-content-type-get (mm-handle-type handle) 'name)
4443 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4444 (mail-content-type-get (mm-handle-type handle) 'url)
4446 (gnus-tmp-type (mm-handle-media-type handle))
4447 (gnus-tmp-description
4448 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4451 (if (if displayed (car displayed)
4452 (mm-handle-displayed-p handle))
4454 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4456 gnus-tmp-type-long b e)
4457 (when (string-match ".*/" gnus-tmp-name)
4458 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4459 (setq gnus-tmp-type-long (concat gnus-tmp-type
4460 (and (not (equal gnus-tmp-name ""))
4461 (concat "; " gnus-tmp-name))))
4462 (unless (equal gnus-tmp-description "")
4463 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4468 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4469 `(,@(gnus-local-map-property gnus-mime-button-map)
4470 gnus-callback gnus-mm-display-part
4471 gnus-part ,gnus-tmp-id
4472 article-type annotation
4475 (widget-convert-button
4478 :action 'gnus-widget-press-button
4479 :button-keymap gnus-mime-button-map
4481 (lambda (widget/window &optional overlay pos)
4482 ;; Needed to properly clear the message due to a bug in
4483 ;; wid-edit (XEmacs only).
4484 (if (boundp 'help-echo-owns-message)
4485 (setq help-echo-owns-message t))
4487 "%S: %s the MIME part; %S: more options"
4488 (aref gnus-mouse-2 0)
4489 ;; XEmacs will get a single widget arg; Emacs 21 will get
4490 ;; window, overlay, position.
4491 (if (mm-handle-displayed-p
4493 (with-current-buffer (gnus-overlay-buffer overlay)
4494 (widget-get (widget-at (gnus-overlay-start overlay))
4496 (widget-get widget/window :mime-handle)))
4498 (aref gnus-down-mouse-3 0))))))
4500 (defun gnus-widget-press-button (elems el)
4501 (goto-char (widget-get elems :from))
4502 (gnus-article-press-button))
4504 (defvar gnus-displaying-mime nil)
4506 (defun gnus-display-mime (&optional ihandles)
4507 "Display the MIME parts."
4509 (save-selected-window
4510 (let ((window (get-buffer-window gnus-article-buffer))
4513 (select-window window)
4514 ;; We have to do this since selecting the window
4515 ;; may change the point. So we set the window point.
4516 (set-window-point window point)))
4517 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4518 buffer-read-only handle name type b e display)
4519 (when (and (not ihandles)
4520 (not gnus-displaying-mime))
4521 ;; Top-level call; we clean up.
4522 (when gnus-article-mime-handles
4523 (mm-destroy-parts gnus-article-mime-handles)
4524 (setq gnus-article-mime-handle-alist nil));; A trick.
4525 (setq gnus-article-mime-handles handles)
4526 ;; We allow users to glean info from the handles.
4527 (when gnus-article-mime-part-function
4528 (gnus-mime-part-function handles)))
4530 (or (not (stringp (car handles)))
4533 (when (and (not ihandles)
4534 (not gnus-displaying-mime))
4535 ;; Clean up for mime parts.
4537 (delete-region (point) (point-max)))
4538 (let ((gnus-displaying-mime t))
4539 (gnus-mime-display-part handles)))
4542 (narrow-to-region (point) (point-max))
4543 (gnus-treat-article nil 1 1)
4546 ;; Highlight the headers.
4550 (narrow-to-region (point-min) (point))
4551 (gnus-treat-article 'head))))))))
4553 (defvar gnus-mime-display-multipart-as-mixed nil)
4554 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4555 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4557 (defun gnus-mime-display-part (handle)
4560 ((not (stringp (car handle)))
4561 (gnus-mime-display-single handle))
4562 ;; User-defined multipart
4563 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4564 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4566 ;; multipart/alternative
4567 ((and (equal (car handle) "multipart/alternative")
4568 (not (or gnus-mime-display-multipart-as-mixed
4569 gnus-mime-display-multipart-alternative-as-mixed)))
4570 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4571 (push (cons id handle) gnus-article-mime-handle-alist)
4572 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4573 ;; multipart/related
4574 ((and (equal (car handle) "multipart/related")
4575 (not (or gnus-mime-display-multipart-as-mixed
4576 gnus-mime-display-multipart-related-as-mixed)))
4577 ;;;!!!We should find the start part, but we just default
4578 ;;;!!!to the first part.
4579 ;;(gnus-mime-display-part (cadr handle))
4580 ;;;!!! Most multipart/related is an HTML message plus images.
4581 ;;;!!! Unfortunately we are unable to let W3 display those
4582 ;;;!!! included images, so we just display it as a mixed multipart.
4583 ;;(gnus-mime-display-mixed (cdr handle))
4584 ;;;!!! No, w3 can display everything just fine.
4585 (gnus-mime-display-part (cadr handle)))
4586 ((equal (car handle) "multipart/signed")
4587 (gnus-add-wash-type 'signed)
4588 (gnus-mime-display-security handle))
4589 ((equal (car handle) "multipart/encrypted")
4590 (gnus-add-wash-type 'encrypted)
4591 (gnus-mime-display-security handle))
4592 ;; Other multiparts are handled like multipart/mixed.
4594 (gnus-mime-display-mixed (cdr handle)))))
4596 (defun gnus-mime-part-function (handles)
4597 (if (stringp (car handles))
4598 (mapcar 'gnus-mime-part-function (cdr handles))
4599 (funcall gnus-article-mime-part-function handles)))
4601 (defun gnus-mime-display-mixed (handles)
4602 (mapcar 'gnus-mime-display-part handles))
4604 (defun gnus-mime-display-single (handle)
4605 (let ((type (mm-handle-media-type handle))
4606 (ignored gnus-ignored-mime-types)
4613 (when (string-match (pop ignored) type)
4614 (throw 'ignored nil)))
4615 (if (and (setq not-attachment
4616 (and (not (mm-inline-override-p handle))
4617 (or (not (mm-handle-disposition handle))
4618 (equal (car (mm-handle-disposition handle))
4620 (mm-attachment-override-p handle))))
4621 (mm-automatic-display-p handle)
4623 (mm-inlinable-p handle)
4624 (mm-inlined-p handle))
4625 (mm-automatic-external-display-p type)))
4627 (when (equal (mm-handle-media-supertype handle) "text")
4629 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4631 (push (cons id handle) gnus-article-mime-handle-alist)
4632 (when (or (not display)
4633 (not (gnus-unbuttonized-mime-type-p type)))
4634 ;(gnus-article-insert-newline)
4635 (gnus-insert-mime-button
4636 handle id (list (or display (and not-attachment text))))
4637 (gnus-article-insert-newline)
4638 ;(gnus-article-insert-newline)
4639 ;; Remember modify the number of forward lines.
4647 (let ((mail-parse-charset gnus-newsgroup-charset)
4648 (mail-parse-ignored-charsets
4649 (save-excursion (condition-case ()
4650 (set-buffer gnus-summary-buffer)
4652 gnus-newsgroup-ignored-charsets)))
4653 (mm-display-part handle t))
4654 (goto-char (point-max)))
4655 ((and text not-attachment)
4659 (gnus-article-insert-newline)
4660 (mm-insert-inline handle (mm-get-part handle))
4661 (goto-char (point-max))))
4665 (narrow-to-region beg (point))
4668 (gnus-article-mime-total-parts)
4669 (mm-handle-media-type handle)))))))))
4671 (defun gnus-unbuttonized-mime-type-p (type)
4672 "Say whether TYPE is to be unbuttonized."
4673 (unless gnus-inhibit-mime-unbuttonizing
4675 (let ((types gnus-unbuttonized-mime-types))
4677 (when (string-match (pop types) type)
4678 (throw 'found t)))))
4680 (let ((types gnus-buttonized-mime-types))
4682 (when (string-match (pop types) type)
4683 (throw 'found t)))))))))
4685 (defun gnus-article-insert-newline ()
4686 "Insert a newline, but mark it as undeletable."
4687 (gnus-put-text-property
4688 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4690 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4691 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4694 handle buffer-read-only from props begend not-pref)
4695 (save-window-excursion
4698 (narrow-to-region (car ibegend)
4701 (goto-char (car ibegend))
4704 (delete-region (point-min) (point-max))
4705 (mm-remove-parts handles))
4706 (setq begend (list (point-marker)))
4708 (unless (setq not-pref (cadr (member preferred ihandles)))
4709 (setq not-pref (car ihandles)))
4712 (not (gnus-unbuttonized-mime-type-p
4713 "multipart/alternative")))
4714 (gnus-add-text-properties
4717 (insert (format "%d. " id))
4721 (unless ,(not ibegend)
4722 (setq gnus-article-mime-handle-alist
4723 ',gnus-article-mime-handle-alist))
4724 (gnus-mime-display-alternative
4725 ',ihandles ',not-pref ',begend ,id))
4726 ,@(gnus-local-map-property gnus-mime-button-map)
4727 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4728 face ,gnus-article-button-face
4731 (widget-convert-button 'link from (point)
4732 :action 'gnus-widget-press-button
4733 :button-keymap gnus-widget-button-keymap)
4735 (while (setq handle (pop handles))
4736 (gnus-add-text-properties
4739 (insert (format "(%c) %-18s"
4740 (if (equal handle preferred) ?* ? )
4741 (mm-handle-media-type handle)))
4745 (unless ,(not ibegend)
4746 (setq gnus-article-mime-handle-alist
4747 ',gnus-article-mime-handle-alist))
4748 (gnus-mime-display-alternative
4749 ',ihandles ',handle ',begend ,id))
4750 ,@(gnus-local-map-property gnus-mime-button-map)
4751 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4752 face ,gnus-article-button-face
4755 (widget-convert-button 'link from (point)
4756 :action 'gnus-widget-press-button
4757 :button-keymap gnus-widget-button-keymap)
4761 (if (stringp (car preferred))
4762 (gnus-display-mime preferred)
4763 (let ((mail-parse-charset gnus-newsgroup-charset)
4764 (mail-parse-ignored-charsets
4765 (save-excursion (set-buffer gnus-summary-buffer)
4766 gnus-newsgroup-ignored-charsets)))
4767 (mm-display-part preferred)
4771 (narrow-to-region (car begend) (point-max))
4773 nil (length gnus-article-mime-handle-alist)
4774 (gnus-article-mime-total-parts)
4775 (mm-handle-media-type handle))))))
4776 (goto-char (point-max))
4777 (setcdr begend (point-marker)))))
4779 (goto-char point))))
4781 (defconst gnus-article-wash-status-strings
4782 (let ((alist '((cite "c" "Possible hidden citation text"
4783 " " "All citation text visible")
4784 (headers "h" "Hidden headers"
4785 " " "All headers visible.")
4786 (pgp "p" "Encrypted or signed message status hidden"
4787 " " "No hidden encryption nor digital signature status")
4788 (signature "s" "Signature has been hidden"
4789 " " "Signature is visible")
4790 (overstrike "o" "Overstrike (^H) characters applied"
4791 " " "No overstrike characters applied")
4792 (gnus-show-mime "m" "Mime processing is activated"
4793 " " "Mime processing is not activated")
4794 (emphasis "e" "/*_Emphasis_*/ characters applied"
4795 " " "No /*_emphasis_*/ characters applied")))
4797 (dolist (entry alist result)
4798 (let ((key (nth 0 entry))
4799 (on (copy-sequence (nth 1 entry)))
4800 (on-help (nth 2 entry))
4801 (off (copy-sequence (nth 3 entry)))
4802 (off-help (nth 4 entry)))
4803 (put-text-property 0 1 'help-echo on-help on)
4804 (put-text-property 0 1 'help-echo off-help off)
4805 (push (list key on off) result))))
4806 "Alist of strings describing wash status in the mode line.
4807 Each entry has the form (KEY ON OF), where the KEY is a symbol
4808 representing the particular washing function, ON is the string to use
4809 in the article mode line when the washing function is active, and OFF
4810 is the string to use when it is inactive.")
4812 (defun gnus-article-wash-status-entry (key value)
4813 (let ((entry (assoc key gnus-article-wash-status-strings)))
4814 (if value (nth 1 entry) (nth 2 entry))))
4816 (defun gnus-article-wash-status ()
4817 "Return a string which display status of article washing."
4819 (set-buffer gnus-article-buffer)
4820 (let ((cite (memq 'cite gnus-article-wash-types))
4821 (headers (memq 'headers gnus-article-wash-types))
4822 (boring (memq 'boring-headers gnus-article-wash-types))
4823 (pgp (memq 'pgp gnus-article-wash-types))
4824 (pem (memq 'pem gnus-article-wash-types))
4825 (signed (memq 'signed gnus-article-wash-types))
4826 (encrypted (memq 'encrypted gnus-article-wash-types))
4827 (signature (memq 'signature gnus-article-wash-types))
4828 (overstrike (memq 'overstrike gnus-article-wash-types))
4829 (emphasis (memq 'emphasis gnus-article-wash-types)))
4831 (gnus-article-wash-status-entry 'cite cite)
4832 (gnus-article-wash-status-entry 'headers (or headers boring))
4833 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4834 (gnus-article-wash-status-entry 'signature signature)
4835 (gnus-article-wash-status-entry 'overstrike overstrike)
4836 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4837 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4839 (defun gnus-add-wash-type (type)
4840 "Add a washing of TYPE to the current status."
4841 (add-to-list 'gnus-article-wash-types type))
4843 (defun gnus-delete-wash-type (type)
4844 "Add a washing of TYPE to the current status."
4845 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4847 (defun gnus-add-image (category image)
4848 "Add IMAGE of CATEGORY to the list of displayed images."
4849 (let ((entry (assq category gnus-article-image-alist)))
4851 (setq entry (list category))
4852 (push entry gnus-article-image-alist))
4853 (nconc entry (list image))))
4855 (defun gnus-delete-images (category)
4856 "Delete all images in CATEGORY."
4857 (let ((entry (assq category gnus-article-image-alist)))
4858 (dolist (image (cdr entry))
4859 (gnus-remove-image image))
4860 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4861 (gnus-delete-wash-type category)))
4863 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4865 (defun gnus-article-maybe-hide-headers ()
4866 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4867 Provided for backwards compatibility."
4868 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4869 (not (save-excursion (set-buffer gnus-summary-buffer)
4870 gnus-have-all-headers)))
4871 (not gnus-inhibit-hiding))
4872 (gnus-article-hide-headers)))
4876 (defun gnus-output-to-file (file-name)
4877 "Append the current article to a file named FILE-NAME."
4878 (let ((artbuf (current-buffer)))
4880 (insert-buffer-substring artbuf)
4881 ;; Append newline at end of the buffer as separator, and then
4883 (goto-char (point-max))
4885 (let ((file-name-coding-system nnmail-pathname-coding-system)
4886 (pathname-coding-system nnmail-pathname-coding-system))
4887 (write-region-as-binary (point-min) (point-max) file-name 'append))
4890 (defun gnus-narrow-to-page (&optional arg)
4891 "Narrow the article buffer to a page.
4892 If given a numerical ARG, move forward ARG pages."
4894 (setq arg (if arg (prefix-numeric-value arg) 0))
4896 (set-buffer gnus-article-buffer)
4897 (goto-char (point-min))
4899 ;; Remove any old next/prev buttons.
4900 (when (gnus-visual-p 'page-marker)
4901 (let ((buffer-read-only nil))
4902 (gnus-remove-text-with-property 'gnus-prev)
4903 (gnus-remove-text-with-property 'gnus-next)))
4906 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4908 (re-search-forward page-delimiter nil 'move arg)))
4909 (goto-char (match-end 0)))
4912 (if (re-search-forward page-delimiter nil 'move)
4915 (when (and (gnus-visual-p 'page-marker)
4916 (not (= (point-min) 1)))
4918 (goto-char (point-min))
4919 (gnus-insert-prev-page-button)))
4920 (when (and (gnus-visual-p 'page-marker)
4921 (< (+ (point-max) 2) (buffer-size)))
4923 (goto-char (point-max))
4924 (gnus-insert-next-page-button)))))
4926 ;; Article mode commands
4928 (defun gnus-article-goto-next-page ()
4929 "Show the next page of the article."
4931 (when (gnus-article-next-page)
4932 (goto-char (point-min))
4933 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4935 (defun gnus-article-goto-prev-page ()
4936 "Show the next page of the article."
4938 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4939 (gnus-article-prev-page nil)))
4941 (defun gnus-article-next-page (&optional lines)
4942 "Show the next page of the current article.
4943 If end of article, return non-nil. Otherwise return nil.
4944 Argument LINES specifies lines to be scrolled up."
4946 (let ((start (window-start))
4947 end-of-buffer end-of-page)
4949 (move-to-window-line -1)
4950 (if (<= (point) start)
4953 (setq start (point)))
4956 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4957 (and (pos-visible-in-window-p)
4958 (setq end-of-buffer t)))
4960 (setq end-of-page t)))
4962 (move-to-window-line lines)
4963 (unless (search-backward "\n\n" nil t)
4964 (setq start (point)))))
4965 (cond (end-of-buffer t)
4967 (gnus-narrow-to-page 1)
4971 (set-window-start (selected-window) start)
4972 (let (window-pixel-scroll-increment)
4976 (defun gnus-article-prev-page (&optional lines)
4977 "Show previous page of current article.
4978 Argument LINES specifies lines to be scrolled down."
4980 (let (beginning-of-buffer beginning-of-page)
4982 (move-to-window-line 0)
4983 (cond ((eq 1 (point))
4984 (setq beginning-of-buffer t))
4986 (setq beginning-of-page t))))
4987 (cond (beginning-of-buffer)
4989 (gnus-narrow-to-page -1))
4992 (let (window-pixel-scroll-increment)
4993 (scroll-down lines))
4994 (beginning-of-buffer
4995 (goto-char (point-min))))))))
4997 (defun gnus-article-refer-article ()
4998 "Read article specified by message-id around point."
5000 (let ((point (point)))
5001 (search-forward ">" nil t) ;Move point to end of "<....>".
5002 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5003 (let ((message-id (match-string 1)))
5005 (set-buffer gnus-summary-buffer)
5006 (gnus-summary-refer-article message-id))
5008 (error "No references around point"))))
5010 (defun gnus-article-show-summary ()
5011 "Reconfigure windows to show summary buffer."
5013 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5014 (error "There is no summary buffer for this article buffer")
5015 (gnus-article-set-globals)
5016 (gnus-configure-windows 'article)
5017 (gnus-summary-goto-subject gnus-current-article)
5018 (gnus-summary-position-point)))
5020 (defun gnus-article-describe-briefly ()
5021 "Describe article mode commands briefly."
5023 (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")))
5025 (defun gnus-article-summary-command ()
5026 "Execute the last keystroke in the summary buffer."
5028 (let ((obuf (current-buffer))
5029 (owin (current-window-configuration))
5031 (switch-to-buffer gnus-article-current-summary 'norecord)
5032 (setq func (lookup-key (current-local-map) (this-command-keys)))
5033 (call-interactively func)
5035 (set-window-configuration owin)
5036 (set-window-point (get-buffer-window (current-buffer)) (point))))
5038 (defun gnus-article-summary-command-nosave ()
5039 "Execute the last keystroke in the summary buffer."
5042 (pop-to-buffer gnus-article-current-summary 'norecord)
5043 (setq func (lookup-key (current-local-map) (this-command-keys)))
5044 (call-interactively func)))
5046 (defun gnus-article-check-buffer ()
5047 "Beep if not in an article buffer."
5048 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5049 (error "Command invoked outside of a Gnus article buffer")))
5051 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5052 "Read a summary buffer key sequence and execute it from the article buffer."
5054 (gnus-article-check-buffer)
5056 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5057 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5058 "=" "^" "\M-^" "|"))
5064 '("n" "Gn" "p" "Gp"))
5067 (set-buffer gnus-article-current-summary)
5068 (let (gnus-pick-mode)
5069 (push (or key last-command-event) unread-command-events)
5070 (setq keys (static-if (featurep 'xemacs)
5071 (events-to-keys (read-key-sequence nil))
5072 (read-key-sequence nil)))))
5075 (if (or (member keys nosaves)
5076 (member keys nosave-but-article)
5077 (member keys nosave-in-article))
5079 (save-window-excursion
5080 (pop-to-buffer gnus-article-current-summary 'norecord)
5081 ;; We disable the pick minor mode commands.
5082 (let (gnus-pick-mode)
5083 (setq func (lookup-key (current-local-map) keys))))
5087 (unless (member keys nosave-in-article)
5088 (set-buffer gnus-article-current-summary))
5089 (call-interactively func)
5090 (setq new-sum-point (point)))
5091 (when (member keys nosave-but-article)
5092 (pop-to-buffer gnus-article-buffer 'norecord)))
5093 ;; These commands should restore window configuration.
5094 (let ((obuf (current-buffer))
5095 (owin (current-window-configuration))
5097 (summary gnus-article-current-summary)
5098 func in-buffer selected)
5099 (if not-restore-window
5100 (pop-to-buffer summary 'norecord)
5101 (switch-to-buffer summary 'norecord))
5102 (setq in-buffer (current-buffer))
5103 ;; We disable the pick minor mode commands.
5104 (if (and (setq func (let (gnus-pick-mode)
5105 (lookup-key (current-local-map) keys)))
5108 (call-interactively func)
5109 (setq new-sum-point (point))
5110 (when (eq in-buffer (current-buffer))
5111 (setq selected (gnus-summary-select-article))
5113 (unless not-restore-window
5114 (set-window-configuration owin))
5115 (when (eq selected 'old)
5117 (set-window-start (get-buffer-window (current-buffer))
5119 (set-window-point (get-buffer-window (current-buffer))
5121 (let ((win (get-buffer-window gnus-article-current-summary)))
5123 (set-window-point win new-sum-point)))) )
5124 (switch-to-buffer gnus-article-buffer)
5127 (defun gnus-article-describe-key (key)
5128 "Display documentation of the function invoked by KEY. KEY is a string."
5129 (interactive "kDescribe key: ")
5130 (gnus-article-check-buffer)
5131 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5133 (set-buffer gnus-article-current-summary)
5134 (let (gnus-pick-mode)
5135 (if (featurep 'xemacs)
5137 (push (elt key 0) unread-command-events)
5138 (setq key (events-to-keys
5139 (read-key-sequence "Describe key: "))))
5140 (setq unread-command-events
5142 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5144 (setq key (read-key-sequence "Describe key: "))))
5146 (describe-key key)))
5148 (defun gnus-article-describe-key-briefly (key &optional insert)
5149 "Display documentation of the function invoked by KEY. KEY is a string."
5150 (interactive "kDescribe key: \nP")
5151 (gnus-article-check-buffer)
5152 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5154 (set-buffer gnus-article-current-summary)
5155 (let (gnus-pick-mode)
5156 (if (featurep 'xemacs)
5158 (push (elt key 0) unread-command-events)
5159 (setq key (events-to-keys
5160 (read-key-sequence "Describe key: "))))
5161 (setq unread-command-events
5163 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5165 (setq key (read-key-sequence "Describe key: "))))
5166 (describe-key-briefly key insert))
5167 (describe-key-briefly key insert)))
5169 (defun gnus-article-reply-with-original (&optional wide)
5170 "Start composing a reply mail to the current message.
5171 The text in the region will be yanked. If the region isn't active,
5172 the entire article will be yanked."
5174 (let ((article (cdr gnus-article-current)) cont)
5176 (gnus-summary-reply (list (list article)) wide)
5177 (setq cont (buffer-substring (point) (mark)))
5178 ;; Deactivate active regions.
5179 (when (and (boundp 'transient-mark-mode)
5180 transient-mark-mode)
5181 (setq mark-active nil))
5183 (list (list article cont)) wide))))
5185 (defun gnus-article-followup-with-original ()
5186 "Compose a followup to the current article.
5187 The text in the region will be yanked. If the region isn't active,
5188 the entire article will be yanked."
5190 (let ((article (cdr gnus-article-current))
5193 (gnus-summary-followup (list (list article)))
5194 (setq cont (buffer-substring (point) (mark)))
5195 ;; Deactivate active regions.
5196 (when (and (boundp 'transient-mark-mode)
5197 transient-mark-mode)
5198 (setq mark-active nil))
5199 (gnus-summary-followup
5200 (list (list article cont))))))
5202 (defun gnus-article-hide (&optional arg force)
5203 "Hide all the gruft in the current article.
5204 This means that PGP stuff, signatures, cited text and (some)
5205 headers will be hidden.
5206 If given a prefix, show the hidden text instead."
5207 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5208 (gnus-article-hide-headers arg)
5209 (gnus-article-hide-list-identifiers arg)
5210 (gnus-article-hide-pgp arg)
5211 (gnus-article-hide-citation-maybe arg force)
5212 (gnus-article-hide-signature arg))
5214 (defun gnus-article-maybe-highlight ()
5215 "Do some article highlighting if article highlighting is requested."
5216 (when (gnus-visual-p 'article-highlight 'highlight)
5217 (gnus-article-highlight-some)))
5219 (defun gnus-check-group-server ()
5220 ;; Make sure the connection to the server is alive.
5221 (unless (gnus-server-opened
5222 (gnus-find-method-for-group gnus-newsgroup-name))
5223 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5224 (gnus-request-group gnus-newsgroup-name t)))
5227 (autoload 'nneething-get-file-name "nneething"))
5229 (defun gnus-request-article-this-buffer (article group)
5230 "Get an article and insert it into this buffer.
5231 T-gnus change: Insert an article into `gnus-original-article-buffer'."
5232 (let (do-update-line sparse-header)
5233 ;; The current buffer is `gnus-article-buffer'.
5237 (gnus-kill-all-overlays)
5238 (setq group (or group gnus-newsgroup-name))
5240 ;; Using `gnus-request-article' directly will insert the article into
5241 ;; `nntp-server-buffer' - so we'll save some time by not having to
5242 ;; copy it from the server buffer into the article buffer.
5244 ;; We only request an article by message-id when we do not have the
5245 ;; headers for it, so we'll have to get those.
5246 (when (stringp article)
5247 (gnus-read-header article))
5249 ;; If the article number is negative, that means that this article
5250 ;; doesn't belong in this newsgroup (possibly), so we find its
5251 ;; message-id and request it by id instead of number.
5252 (when (and (numberp article)
5254 (get-buffer gnus-summary-buffer)
5255 (gnus-buffer-exists-p gnus-summary-buffer))
5257 (set-buffer gnus-summary-buffer)
5258 (let ((header (gnus-summary-article-header article)))
5261 ((memq article gnus-newsgroup-sparse)
5262 ;; This is a sparse gap article.
5263 (setq do-update-line article)
5264 (setq article (mail-header-id header))
5265 (setq sparse-header (gnus-read-header article))
5266 (setq gnus-newsgroup-sparse
5267 (delq article gnus-newsgroup-sparse)))
5269 ;; It's a real article.
5270 (setq article (mail-header-id header)))
5272 ;; It is an extracted pseudo-article.
5273 (setq article 'pseudo)
5274 (gnus-request-pseudo-article header))))
5276 (let ((method (gnus-find-method-for-group
5277 gnus-newsgroup-name)))
5278 (when (and (eq (car method) 'nneething)
5280 (let ((dir (nneething-get-file-name
5281 (mail-header-id header))))
5282 (when (and (stringp dir)
5283 (file-directory-p dir))
5284 (setq article 'nneething)
5285 (gnus-group-enter-directory dir))))))))
5286 (setq gnus-original-article (cons group article))
5288 ;; The current buffer is `gnus-original-article-buffer'.
5289 (if (get-buffer gnus-original-article-buffer)
5290 (set-buffer gnus-original-article-buffer)
5291 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5292 (set-buffer-multibyte nil)
5293 (buffer-disable-undo)
5294 (setq major-mode 'gnus-original-article-mode)
5295 (setq buffer-read-only nil))
5298 ;; Refuse to select canceled articles.
5299 ((and (numberp article)
5301 (get-buffer gnus-summary-buffer)
5302 (gnus-buffer-exists-p gnus-summary-buffer)
5303 (eq (cdr (save-excursion
5304 (set-buffer gnus-summary-buffer)
5305 (assq article gnus-newsgroup-reads)))
5306 gnus-canceled-mark))
5308 ;; Check the backlog.
5309 ((and gnus-keep-backlog
5310 (gnus-backlog-request-article group article (current-buffer)))
5312 ;; Check asynchronous pre-fetch.
5313 ((gnus-async-request-fetched-article group article (current-buffer))
5314 (gnus-async-prefetch-next group article gnus-summary-buffer)
5315 (when (and (numberp article) gnus-keep-backlog)
5316 (gnus-backlog-enter-article group article (current-buffer)))
5319 ((and gnus-use-cache
5321 (gnus-cache-request-article article group))
5323 ;; Check the agent cache.
5324 ((and gnus-agent gnus-agent-cache gnus-plugged
5326 (gnus-agent-request-article article group))
5328 ;; Get the article and put into the article buffer.
5329 ((or (stringp article)
5331 (let ((gnus-override-method gnus-override-method)
5332 (methods (and (stringp article)
5333 gnus-refer-article-method))
5335 (buffer-read-only nil))
5336 (if (or (not (listp methods))
5337 (and (symbolp (car methods))
5338 (assq (car methods) nnoo-definition-alist)))
5339 (setq methods (list methods)))
5340 (when (and (null gnus-override-method)
5342 (setq gnus-override-method (pop methods)))
5344 (when (eq gnus-override-method 'current)
5345 (setq gnus-override-method
5346 (with-current-buffer gnus-summary-buffer
5347 gnus-current-select-method)))
5349 (gnus-kill-all-overlays)
5350 (let ((gnus-newsgroup-name group))
5351 (gnus-check-group-server))
5352 (when (gnus-request-article article group (current-buffer))
5353 (when (numberp article)
5354 (gnus-async-prefetch-next group article
5355 gnus-summary-buffer)
5356 (when gnus-keep-backlog
5357 (gnus-backlog-enter-article
5358 group article (current-buffer))))
5359 (setq result 'article))
5362 (setq gnus-override-method (pop methods))
5363 (setq result 'done))))
5364 (and (eq result 'article) 'article)))
5368 ;; Associate this article with the current summary buffer.
5369 (setq gnus-article-current-summary gnus-summary-buffer)
5371 ;; Copy the requested article from `gnus-original-article-buffer'.
5372 (unless (equal (buffer-name (current-buffer))
5373 (buffer-name (get-buffer gnus-original-article-buffer)))
5374 (insert-buffer gnus-original-article-buffer))
5377 (run-hooks 'gnus-article-decode-hook)
5378 ;; Mark article as decoded or not.
5379 (setq gnus-article-decoded-p gnus-article-decode-hook)
5381 ;; Update sparse articles.
5382 (when (and do-update-line
5383 (or (numberp article)
5385 (let ((buf (current-buffer)))
5386 (set-buffer gnus-summary-buffer)
5387 (gnus-summary-update-article do-update-line sparse-header)
5388 (gnus-summary-goto-subject do-update-line nil t)
5389 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5391 (set-buffer buf))))))
5397 (defcustom gnus-article-edit-mode-hook nil
5398 "Hook run in article edit mode buffers."
5399 :group 'gnus-article-various
5402 (defcustom gnus-article-edit-article-setup-function
5403 'gnus-article-mime-edit-article-setup
5404 "Function called to setup an editing article buffer."
5405 :group 'gnus-article-various
5408 (defvar gnus-article-edit-done-function nil)
5410 (defvar gnus-article-edit-mode-map nil)
5412 ;; Should we be using derived.el for this?
5413 (unless gnus-article-edit-mode-map
5414 (setq gnus-article-edit-mode-map (make-sparse-keymap))
5415 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5417 (gnus-define-keys gnus-article-edit-mode-map
5418 "\C-c\C-c" gnus-article-edit-done
5419 "\C-c\C-k" gnus-article-edit-exit)
5421 (gnus-define-keys (gnus-article-edit-wash-map
5422 "\C-c\C-w" gnus-article-edit-mode-map)
5423 "f" gnus-article-edit-full-stops))
5425 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5426 "Major mode for editing articles.
5427 This is an extended text-mode.
5429 \\{gnus-article-edit-mode-map}"
5430 (make-local-variable 'gnus-article-edit-done-function)
5431 (make-local-variable 'gnus-prev-winconf)
5432 (set (make-local-variable 'font-lock-defaults)
5433 '(message-font-lock-keywords t))
5434 (setq buffer-read-only nil)
5435 (buffer-enable-undo)
5438 (defun gnus-article-edit (&optional force)
5439 "Edit the current article.
5440 This will have permanent effect only in mail groups.
5441 If FORCE is non-nil, allow editing of articles even in read-only
5444 (when (and (not force)
5445 (gnus-group-read-only-p))
5446 (error "The current newsgroup does not support article editing"))
5447 (gnus-article-date-original)
5448 (gnus-article-edit-article
5450 `(lambda (no-highlight)
5452 (gnus-summary-edit-article-done
5453 ,(or (mail-header-references gnus-current-headers) "")
5454 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5456 (defun gnus-article-edit-article (start-func exit-func)
5457 "Start editing the contents of the current article buffer."
5458 (let ((winconf (current-window-configuration)))
5459 (set-buffer gnus-article-buffer)
5460 (gnus-article-edit-mode)
5461 (funcall start-func)
5462 (set-buffer-modified-p nil)
5463 (gnus-configure-windows 'edit-article)
5464 (setq gnus-article-edit-done-function exit-func)
5465 (setq gnus-prev-winconf winconf)
5466 (when gnus-article-edit-article-setup-function
5467 (funcall gnus-article-edit-article-setup-function))
5468 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5470 (defun gnus-article-edit-done (&optional arg)
5471 "Update the article edits and exit."
5473 (let ((func gnus-article-edit-done-function)
5474 (buf (current-buffer))
5475 (start (window-start)))
5476 (remove-hook 'gnus-article-mode-hook
5477 'gnus-article-mime-edit-article-unwind)
5478 ;; We remove all text props from the article buffer.
5480 (buffer-substring-no-properties (point-min) (point-max)))
5484 (let ((winconf gnus-prev-winconf))
5486 (set-window-configuration winconf)
5487 ;; Tippy-toe some to make sure that point remains where it was.
5488 (save-current-buffer
5490 (set-window-start (get-buffer-window (current-buffer)) start)
5494 (let ((buffer-read-only nil))
5496 ;; The cache and backlog have to be flushed somewhat.
5497 (when gnus-keep-backlog
5498 (gnus-backlog-remove-article
5499 (car gnus-article-current) (cdr gnus-article-current)))
5500 ;; Flush original article as well.
5502 (when (get-buffer gnus-original-article-buffer)
5503 (set-buffer gnus-original-article-buffer)
5504 (setq gnus-original-article nil)))
5505 (when gnus-use-cache
5506 (gnus-cache-update-article
5507 (car gnus-article-current) (cdr gnus-article-current))))
5509 (set-window-start (get-buffer-window buf) start)
5510 (set-window-point (get-buffer-window buf) (point))))
5512 (defun gnus-article-edit-exit ()
5513 "Exit the article editing without updating."
5515 (when (or (not (buffer-modified-p))
5516 (yes-or-no-p "Article modified; kill anyway? "))
5517 (let ((curbuf (current-buffer))
5519 (window-start (window-start)))
5521 (if (gnus-buffer-live-p gnus-original-article-buffer)
5522 (insert-buffer gnus-original-article-buffer))
5523 (let ((winconf gnus-prev-winconf))
5525 (set-window-configuration winconf)
5526 ;; Tippy-toe some to make sure that point remains where it was.
5527 (save-current-buffer
5529 (set-window-start (get-buffer-window (current-buffer)) window-start)
5532 (defun gnus-article-edit-full-stops ()
5533 "Interactively repair spacing at end of sentences."
5536 (goto-char (point-min))
5537 (search-forward-regexp "^$" nil t)
5538 (let ((case-fold-search nil))
5539 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5542 ;;; Article editing with MIME-Edit
5545 (defcustom gnus-article-mime-edit-article-setup-hook nil
5546 "Hook run after setting up a MIME editing article buffer."
5547 :group 'gnus-article-various
5550 (defun gnus-article-mime-edit-article-unwind ()
5551 "Unwind `gnus-article-buffer' if article editing was given up."
5552 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5553 (when (featurep 'font-lock)
5554 (setq font-lock-defaults nil)
5555 (font-lock-mode -1))
5556 (when mime-edit-mode-flag
5557 (mime-edit-exit 'nomime 'no-error)
5560 (defun gnus-article-mime-edit-article-setup ()
5561 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5562 after replacing with the original article."
5563 (setq gnus-show-mime t)
5564 (setq gnus-article-edit-done-function
5565 `(lambda (&rest args)
5566 (when mime-edit-mode-flag
5567 (let (mime-edit-insert-user-agent-field)
5570 (goto-char (point-min))
5571 (let (case-fold-search)
5572 (when (re-search-forward
5573 (format "^%s$" (regexp-quote mail-header-separator))
5575 (replace-match "")))
5576 (apply ,gnus-article-edit-done-function args)
5579 (buffer-substring-no-properties (point-min) (point-max))
5580 (set-buffer (get-buffer-create gnus-original-article-buffer))
5582 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5583 (set-buffer gnus-article-buffer)
5584 (gnus-article-prepare-display)))
5585 (substitute-key-definition 'gnus-article-edit-done
5586 'gnus-article-mime-edit-done
5587 gnus-article-edit-mode-map)
5588 (substitute-key-definition 'gnus-article-edit-exit
5589 'gnus-article-mime-edit-exit
5590 gnus-article-edit-mode-map)
5592 (insert-buffer gnus-original-article-buffer)
5593 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5594 (fset 'mime-edit-decode-single-part-in-buffer
5595 (lambda (&rest args)
5596 (if (let ((content-type (car args)))
5597 (and (eq 'message (mime-content-type-primary-type
5599 (eq 'rfc822 (mime-content-type-subtype content-type))))
5600 (setcar (cdr args) 'not-decode-text))
5604 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5605 (when (featurep 'font-lock)
5606 (set (make-local-variable 'font-lock-defaults)
5607 '(message-font-lock-keywords t))
5608 (font-lock-set-defaults)
5609 (turn-on-font-lock))
5610 (set-buffer-modified-p nil)
5611 (delete-other-windows)
5612 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5613 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5615 (defun gnus-article-mime-edit-done (&optional arg)
5616 "Update the article MIME edits and exit."
5618 (when (featurep 'font-lock)
5619 (setq font-lock-defaults nil)
5620 (font-lock-mode -1))
5621 (gnus-article-edit-done arg))
5623 (defun gnus-article-mime-edit-exit ()
5624 "Exit the article MIME editing without updating."
5626 (when (or (not (buffer-modified-p))
5627 (yes-or-no-p "Article modified; kill anyway? "))
5628 (when (featurep 'font-lock)
5629 (setq font-lock-defaults nil)
5630 (font-lock-mode -1))
5631 (when mime-edit-mode-flag
5632 (let (mime-edit-insert-user-agent-field)
5635 (goto-char (point-min))
5636 (let (case-fold-search)
5637 (when (re-search-forward
5638 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5639 (replace-match "")))
5640 (let ((winconf gnus-prev-winconf))
5642 (buffer-substring-no-properties (point-min) (point-max))
5643 (set-buffer (get-buffer-create gnus-original-article-buffer))
5645 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5646 (set-buffer gnus-article-buffer)
5647 (gnus-article-prepare-display)
5648 (set-window-configuration winconf))))
5651 ;;; Article highlights
5654 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5656 ;;; Internal Variables:
5658 (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\\)\\)"
5659 "Regular expression that matches URLs."
5660 :group 'gnus-article-buttons
5663 (defcustom gnus-button-alist
5664 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5665 0 t gnus-button-handle-news 3)
5666 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5667 gnus-button-handle-news 2)
5668 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5670 gnus-button-fetch-group 4)
5671 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5672 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5673 t gnus-button-message-id 3)
5674 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5675 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5676 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5678 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5679 gnus-button-handle-info 2)
5680 ;; This is how URLs _should_ be embedded in text...
5681 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5683 (,gnus-button-url-regexp 0 t browse-url 0))
5684 "*Alist of regexps matching buttons in article bodies.
5686 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5687 REGEXP: is the string matching text around the button,
5688 BUTTON: is the number of the regexp grouping actually matching the button,
5689 FORM: is a lisp expression which must eval to true for the button to
5691 CALLBACK: is the function to call when the user push this button, and each
5692 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5694 CALLBACK can also be a variable, in that case the value of that
5695 variable it the real callback function."
5696 :group 'gnus-article-buttons
5697 :type '(repeat (list regexp
5698 (integer :tag "Button")
5700 (function :tag "Callback")
5703 (integer :tag "Regexp group")))))
5705 (defcustom gnus-header-button-alist
5706 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5707 0 t gnus-button-message-id 0)
5708 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5709 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5710 0 t gnus-button-mailto 0)
5711 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5712 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5713 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5714 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5715 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5716 gnus-button-message-id 3))
5717 "*Alist of headers and regexps to match buttons in article heads.
5719 This alist is very similar to `gnus-button-alist', except that each
5720 alist has an additional HEADER element first in each entry:
5722 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5724 HEADER is a regexp to match a header. For a fuller explanation, see
5725 `gnus-button-alist'."
5726 :group 'gnus-article-buttons
5727 :group 'gnus-article-headers
5728 :type '(repeat (list (regexp :tag "Header")
5730 (integer :tag "Button")
5732 (function :tag "Callback")
5735 (integer :tag "Regexp group")))))
5737 (defvar gnus-button-regexp nil)
5738 (defvar gnus-button-marker-list nil)
5739 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5741 (defvar gnus-button-last nil)
5742 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5746 (defun gnus-article-push-button (event)
5747 "Check text under the mouse pointer for a callback function.
5748 If the text under the mouse pointer has a `gnus-callback' property,
5749 call it with the value of the `gnus-data' text property."
5751 (set-buffer (window-buffer (posn-window (event-start event))))
5752 (let* ((pos (posn-point (event-start event)))
5753 (data (get-text-property pos 'gnus-data))
5754 (fun (get-text-property pos 'gnus-callback)))
5757 (funcall fun data))))
5759 (defun gnus-article-press-button ()
5760 "Check text at point for a callback function.
5761 If the text at point has a `gnus-callback' property,
5762 call it with the value of the `gnus-data' text property."
5764 (let* ((data (get-text-property (point) 'gnus-data))
5765 (fun (get-text-property (point) 'gnus-callback)))
5767 (funcall fun data))))
5769 (defun gnus-article-prev-button (n)
5770 "Move point to N buttons backward.
5771 If N is negative, move forward instead."
5773 (gnus-article-next-button (- n)))
5775 (defun gnus-article-next-button (n)
5776 "Move point to N buttons forward.
5777 If N is negative, move backward instead."
5779 (let ((function (if (< n 0) 'previous-single-property-change
5780 'next-single-property-change))
5781 (inhibit-point-motion-hooks t)
5783 (limit (if (< n 0) (point-min) (point-max))))
5785 (while (and (not (= limit (point)))
5787 ;; Skip past the current button.
5788 (when (get-text-property (point) 'gnus-callback)
5789 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5790 ;; Go to the next (or previous) button.
5791 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5792 ;; Put point at the start of the button.
5793 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5794 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5795 ;; Skip past intangible buttons.
5796 (when (get-text-property (point) 'intangible)
5800 (gnus-message 5 "No more buttons"))
5803 (defun gnus-article-highlight (&optional force)
5804 "Highlight current article.
5805 This function calls `gnus-article-highlight-headers',
5806 `gnus-article-highlight-citation',
5807 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5808 do the highlighting. See the documentation for those functions."
5809 (interactive (list 'force))
5810 (gnus-article-highlight-headers)
5811 (gnus-article-highlight-citation force)
5812 (gnus-article-highlight-signature)
5813 (gnus-article-add-buttons force)
5814 (gnus-article-add-buttons-to-head))
5816 (defun gnus-article-highlight-some (&optional force)
5817 "Highlight current article.
5818 This function calls `gnus-article-highlight-headers',
5819 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5820 do the highlighting. See the documentation for those functions."
5821 (interactive (list 'force))
5822 (gnus-article-highlight-headers)
5823 (gnus-article-highlight-signature)
5824 (gnus-article-add-buttons))
5826 (defun gnus-article-highlight-headers ()
5827 "Highlight article headers as specified by `gnus-header-face-alist'."
5830 (set-buffer gnus-article-buffer)
5832 (let ((alist gnus-header-face-alist)
5833 (buffer-read-only nil)
5834 (case-fold-search t)
5835 (inhibit-point-motion-hooks t)
5836 entry regexp header-face field-face from hpoints fpoints)
5837 (article-narrow-to-head)
5838 (while (setq entry (pop alist))
5839 (goto-char (point-min))
5840 (setq regexp (concat "^\\("
5841 (if (string-equal "" (nth 0 entry))
5845 header-face (nth 1 entry)
5846 field-face (nth 2 entry))
5847 (while (and (re-search-forward regexp nil t)
5851 (unless (search-forward ":" nil t)
5853 (when (and header-face
5854 (not (memq (point) hpoints)))
5855 (push (point) hpoints)
5856 (gnus-put-text-property from (point) 'face header-face))
5857 (when (and field-face
5858 (not (memq (setq from (point)) fpoints)))
5860 (if (re-search-forward "^[^ \t]" nil t)
5862 (goto-char (point-max)))
5863 (gnus-put-text-property from (point) 'face field-face))))))))
5865 (defun gnus-article-highlight-signature ()
5866 "Highlight the signature in an article.
5867 It does this by highlighting everything after
5868 `gnus-signature-separator' using `gnus-signature-face'."
5870 (when gnus-signature-face
5872 (set-buffer gnus-article-buffer)
5873 (let ((buffer-read-only nil)
5874 (inhibit-point-motion-hooks t))
5876 (when (gnus-article-narrow-to-signature)
5877 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5878 'face gnus-signature-face)))))))
5880 (defun gnus-article-buttonize-signature ()
5881 "Add button to the signature."
5884 (set-buffer gnus-article-buffer)
5885 (let ((buffer-read-only nil)
5886 (inhibit-point-motion-hooks t))
5887 (when (gnus-article-search-signature)
5888 (gnus-article-add-button (match-beginning 0) (match-end 0)
5889 'gnus-signature-toggle
5890 (set-marker (make-marker)
5891 (1+ (match-end 0))))))))
5893 (defun gnus-button-in-region-p (b e prop)
5894 "Say whether PROP exists in the region."
5895 (text-property-not-all b e prop nil))
5897 (defun gnus-article-add-buttons (&optional force)
5898 "Find external references in the article and make buttons of them.
5899 \"External references\" are things like Message-IDs and URLs, as
5900 specified by `gnus-button-alist'."
5901 (interactive (list 'force))
5903 (set-buffer gnus-article-buffer)
5904 (let ((buffer-read-only nil)
5905 (inhibit-point-motion-hooks t)
5906 (case-fold-search t)
5907 (alist gnus-button-alist)
5909 ;; Remove all old markers.
5910 (let (marker entry new-list)
5911 (while (setq marker (pop gnus-button-marker-list))
5912 (if (or (< marker (point-min)) (>= marker (point-max)))
5913 (push marker new-list)
5915 (when (setq entry (gnus-button-entry))
5916 (put-text-property (match-beginning (nth 1 entry))
5917 (match-end (nth 1 entry))
5918 'gnus-callback nil))
5919 (set-marker marker nil)))
5920 (setq gnus-button-marker-list new-list))
5921 ;; We skip the headers.
5924 (while (setq entry (pop alist))
5925 (setq regexp (car entry))
5927 (while (re-search-forward regexp nil t)
5928 (let* ((start (and entry (match-beginning (nth 1 entry))))
5929 (end (and entry (match-end (nth 1 entry))))
5930 (from (match-beginning 0)))
5931 (when (and (or (eq t (nth 2 entry))
5932 (eval (nth 2 entry)))
5933 (not (gnus-button-in-region-p
5934 start end 'gnus-callback)))
5935 ;; That optional form returned non-nil, so we add the
5937 (gnus-article-add-button
5938 start end 'gnus-button-push
5939 (car (push (set-marker (make-marker) from)
5940 gnus-button-marker-list))))))))))
5942 ;; Add buttons to the head of an article.
5943 (defun gnus-article-add-buttons-to-head ()
5944 "Add buttons to the head of the article."
5947 (set-buffer gnus-article-buffer)
5949 (let ((buffer-read-only nil)
5950 (inhibit-point-motion-hooks t)
5951 (case-fold-search t)
5952 (alist gnus-header-button-alist)
5954 (article-narrow-to-head)
5956 ;; Each alist entry.
5957 (setq entry (car alist)
5959 (goto-char (point-min))
5960 (while (re-search-forward (car entry) nil t)
5961 ;; Each header matching the entry.
5962 (setq beg (match-beginning 0))
5963 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5964 (match-beginning 0))
5967 (while (re-search-forward (nth 1 entry) end t)
5968 ;; Each match within a header.
5969 (let* ((entry (cdr entry))
5970 (start (match-beginning (nth 1 entry)))
5971 (end (match-end (nth 1 entry)))
5972 (form (nth 2 entry)))
5973 (goto-char (match-end 0))
5975 (gnus-article-add-button
5976 start end (nth 3 entry)
5977 (buffer-substring (match-beginning (nth 4 entry))
5978 (match-end (nth 4 entry)))))))
5979 (goto-char end)))))))
5981 ;;; External functions:
5983 (defun gnus-article-add-button (from to fun &optional data)
5984 "Create a button between FROM and TO with callback FUN and data DATA."
5985 (when gnus-article-button-face
5986 (gnus-overlay-put (gnus-make-overlay from to)
5987 'face gnus-article-button-face))
5988 (gnus-add-text-properties
5990 (nconc (and gnus-article-mouse-face
5991 (list gnus-mouse-face-prop gnus-article-mouse-face))
5992 (list 'gnus-callback fun)
5993 (and data (list 'gnus-data data))))
5994 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5995 ;; Quote `:button-keymap' for Mule 2.3
5996 ;; but it won't work.
5997 ':button-keymap gnus-widget-button-keymap))
5999 ;;; Internal functions:
6001 (defun gnus-article-set-globals ()
6003 (set-buffer gnus-summary-buffer)
6004 (gnus-set-global-variables)))
6006 (defun gnus-signature-toggle (end)
6008 (set-buffer gnus-article-buffer)
6009 (let ((buffer-read-only nil)
6010 (inhibit-point-motion-hooks t)
6011 (limit (next-single-property-change end 'mime-view-entity
6013 (if (text-property-any end limit 'article-type 'signature)
6015 (gnus-delete-wash-type 'signature)
6016 (gnus-remove-text-properties-when
6017 'article-type 'signature end limit
6018 (cons 'article-type (cons 'signature
6019 gnus-hidden-properties))))
6020 (gnus-add-wash-type 'signature)
6021 (gnus-add-text-properties-when
6022 'article-type nil end limit
6023 (cons 'article-type (cons 'signature
6024 gnus-hidden-properties)))))
6025 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6026 (gnus-set-mode-line 'article))))
6028 (defun gnus-button-entry ()
6029 ;; Return the first entry in `gnus-button-alist' matching this place.
6030 (let ((alist gnus-button-alist)
6033 (setq entry (pop alist))
6034 (if (looking-at (car entry))
6039 (defun gnus-button-push (marker)
6040 ;; Push button starting at MARKER.
6043 (let* ((entry (gnus-button-entry))
6044 (inhibit-point-motion-hooks t)
6046 (args (mapcar (lambda (group)
6047 (let ((string (match-string group)))
6048 (gnus-set-text-properties
6049 0 (length string) nil string)
6056 (fboundp (symbol-value fun)))
6057 (apply (symbol-value fun) args))
6059 (gnus-message 1 "You must define `%S' to use this button"
6060 (cons fun args)))))))
6062 (defun gnus-parse-news-url (url)
6063 (let (scheme server group message-id articles)
6066 (goto-char (point-min))
6067 (when (looking-at "\\([A-Za-z]+\\):")
6068 (setq scheme (match-string 1))
6069 (goto-char (match-end 0)))
6070 (when (looking-at "//\\([^/]+\\)/")
6071 (setq server (match-string 1))
6072 (goto-char (match-end 0)))
6075 ((looking-at "\\(.*@.*\\)")
6076 (setq message-id (match-string 1)))
6077 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6078 (setq group (match-string 1)
6079 articles (split-string (match-string 2) "-")))
6080 ((looking-at "\\([^/]+\\)/?")
6081 (setq group (match-string 1)))
6083 (error "Unknown news URL syntax"))))
6084 (list scheme server group message-id articles)))
6086 (defun gnus-button-handle-news (url)
6088 (destructuring-bind (scheme server group message-id articles)
6089 (gnus-parse-news-url url)
6093 (set-buffer gnus-summary-buffer)
6095 (let ((gnus-refer-article-method (list (list 'nntp server))))
6096 (gnus-summary-refer-article message-id))
6097 (gnus-summary-refer-article message-id))))
6099 (gnus-button-fetch-group url)))))
6101 (defun gnus-button-handle-info (url)
6102 "Fetch an info URL."
6104 "^\\([^:/]+\\)?/\\(.*\\)"
6106 (gnus-info-find-node
6107 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6110 (gnus-url-unhex-string (match-string 2 url))))
6111 (error "Can't parse %s" url)))
6113 (defun gnus-button-message-id (message-id)
6116 (set-buffer gnus-summary-buffer)
6117 (gnus-summary-refer-article message-id)))
6119 (defun gnus-button-fetch-group (address)
6120 "Fetch GROUP specified by ADDRESS."
6121 (if (not (string-match "[:/]" address))
6122 ;; This is just a simple group url.
6123 (gnus-group-read-ephemeral-group address gnus-select-method)
6126 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6128 (error "Can't parse %s" address)
6129 (gnus-group-read-ephemeral-group
6130 (match-string 4 address)
6131 `(nntp ,(match-string 1 address)
6132 (nntp-address ,(match-string 1 address))
6133 (nntp-port-number ,(if (match-end 3)
6134 (match-string 3 address)
6137 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6139 (defun gnus-url-parse-query-string (query &optional downcase)
6140 (let (retval pairs cur key val)
6141 (setq pairs (split-string query "&"))
6143 (setq cur (car pairs)
6145 (if (not (string-match "=" cur))
6147 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6148 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6150 (setq key (downcase key)))
6151 (setq cur (assoc key retval))
6153 (setcdr cur (cons val (cdr cur)))
6154 (setq retval (cons (list key val) retval)))))
6157 (defun gnus-url-mailto (url)
6158 ;; Send mail to someone
6159 (when (string-match "mailto:/*\\(.*\\)" url)
6160 (setq url (substring url (match-beginning 1) nil)))
6161 (let (to args subject func)
6162 (if (string-match (regexp-quote "?") url)
6163 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6164 args (gnus-url-parse-query-string
6165 (substring url (match-end 0) nil) t))
6166 (setq to (gnus-url-unhex-string url)))
6167 (setq args (cons (list "to" to) args)
6168 subject (cdr-safe (assoc "subject" args)))
6171 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6174 (message-position-on-field (caar args)))
6175 (insert (mapconcat 'identity (cdar args) ", "))
6176 (setq args (cdr args)))
6179 (message-goto-subject))))
6181 (defun gnus-button-embedded-url (address)
6182 "Activate ADDRESS with `browse-url'."
6183 (browse-url (gnus-strip-whitespace address)))
6185 ;;; Next/prev buttons in the article buffer.
6187 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6188 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6190 (defvar gnus-prev-page-map
6191 (let ((map (make-sparse-keymap)))
6192 (unless (>= emacs-major-version 21)
6193 ;; XEmacs doesn't care.
6194 (set-keymap-parent map gnus-article-mode-map))
6195 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6196 (define-key map "\r" 'gnus-button-prev-page)
6199 (defun gnus-insert-prev-page-button ()
6201 (buffer-read-only nil)
6202 (situation (get-text-property (point-min) 'mime-view-situation)))
6204 gnus-prev-page-line-format nil
6205 `(,@(gnus-local-map-property gnus-prev-page-map)
6207 gnus-callback gnus-article-button-prev-page
6208 article-type annotation
6209 mime-view-situation ,situation))
6210 (widget-convert-button
6212 :action 'gnus-button-prev-page
6213 :button-keymap gnus-prev-page-map)))
6215 (defvar gnus-next-page-map
6216 (let ((map (make-sparse-keymap)))
6217 (unless (>= emacs-major-version 21)
6218 ;; XEmacs doesn't care.
6219 (set-keymap-parent map gnus-article-mode-map))
6220 (define-key map gnus-mouse-2 'gnus-button-next-page)
6221 (define-key map "\r" 'gnus-button-next-page)
6224 (defun gnus-button-next-page (&optional args more-args)
6225 "Go to the next page."
6227 (let ((win (selected-window)))
6228 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6229 (gnus-article-next-page)
6230 (select-window win)))
6232 (defun gnus-button-prev-page (&optional args more-args)
6233 "Go to the prev page."
6235 (let ((win (selected-window)))
6236 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6237 (gnus-article-prev-page)
6238 (select-window win)))
6240 (defun gnus-insert-next-page-button ()
6242 (buffer-read-only nil)
6243 (situation (get-text-property (point-min) 'mime-view-situation)))
6244 (gnus-eval-format gnus-next-page-line-format nil
6245 `(,@(gnus-local-map-property gnus-next-page-map)
6247 gnus-callback gnus-article-button-next-page
6248 article-type annotation
6249 mime-view-situation ,situation))
6250 (widget-convert-button
6252 :action 'gnus-button-next-page
6253 :button-keymap gnus-next-page-map)))
6255 (defun gnus-article-button-next-page (arg)
6256 "Go to the next page."
6258 (let ((win (selected-window)))
6259 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6260 (gnus-article-next-page)
6261 (select-window win)))
6263 (defun gnus-article-button-prev-page (arg)
6264 "Go to the prev page."
6266 (let ((win (selected-window)))
6267 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6268 (gnus-article-prev-page)
6269 (select-window win)))
6271 (defvar gnus-decode-header-methods
6272 '(mail-decode-encoded-word-region)
6273 "List of methods used to decode headers.
6275 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6276 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6277 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6278 whose names match REGEXP.
6281 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6282 mail-decode-encoded-word-region
6283 (\"chinese\" . rfc1843-decode-region))
6286 (defvar gnus-decode-header-methods-cache nil)
6288 (defun gnus-multi-decode-header (start end)
6289 "Apply the functions from `gnus-encoded-word-methods' that match."
6290 (unless (and gnus-decode-header-methods-cache
6291 (eq gnus-newsgroup-name
6292 (car gnus-decode-header-methods-cache)))
6293 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6296 (nconc gnus-decode-header-methods-cache (list x))
6297 (if (and gnus-newsgroup-name
6298 (string-match (car x) gnus-newsgroup-name))
6299 (nconc gnus-decode-header-methods-cache
6301 gnus-decode-header-methods))
6302 (let ((xlist gnus-decode-header-methods-cache))
6305 (narrow-to-region start end)
6307 (funcall (pop xlist) (point-min) (point-max))))))
6310 ;;; Treatment top-level handling.
6313 (defun gnus-treat-article (condition &optional part-number total-parts type)
6314 (let ((length (- (point-max) (point-min)))
6315 (alist gnus-treatment-function-alist)
6316 (article-goto-body-goes-to-point-min-p t)
6320 (let ((list gnus-article-treat-types))
6322 (when (string-match (pop list) type)
6323 (throw 'found t)))))))
6324 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6325 (entity (static-unless (featurep 'xemacs)
6326 (when (eq 'head condition)
6327 (get-text-property (point-min) 'mime-view-entity))))
6328 val elem buttonized)
6329 (gnus-run-hooks 'gnus-part-display-hook)
6330 (unless gnus-inhibit-treatment
6331 (while (setq elem (pop alist))
6334 (if (gnus-buffer-live-p gnus-summary-buffer)
6335 (set-buffer gnus-summary-buffer))
6336 (symbol-value (car elem))))
6337 (when (and (or (consp val)
6339 (gnus-treat-predicate val)
6340 (or (not (get (car elem) 'highlight))
6342 (when (and (not buttonized)
6344 '(gnus-treat-hide-signature
6345 gnus-treat-highlight-signature)))
6346 (gnus-article-buttonize-signature)
6347 (setq buttonized t))
6349 (funcall (cadr elem)))))
6350 ;; FSF Emacsen does not inherit the existing text properties
6351 ;; in the new text, so we should do it for `mime-view-entity'.
6352 (static-unless (featurep 'xemacs)
6354 (put-text-property (point-min) (point-max)
6355 'mime-view-entity entity))))))
6357 ;; Dynamic variables.
6359 (defvar part-number)
6360 (defvar total-parts)
6365 (defun gnus-treat-predicate (val)
6370 (stringp (car val)))
6371 (apply 'gnus-or (mapcar `(lambda (s)
6372 (string-match s ,(or gnus-newsgroup-name "")))
6375 (let ((pred (pop val)))
6378 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6380 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6382 (not (gnus-treat-predicate (car val))))
6384 (equal (car val) type))
6386 (error "%S is not a valid predicate" pred)))))
6396 (eq part-number total-parts))
6400 (error "%S is not a valid value" val))))
6402 (defun gnus-article-encrypt-body (protocol &optional n)
6403 "Encrypt the article body."
6406 (or gnus-article-encrypt-protocol
6407 (completing-read "Encrypt protocol: "
6408 gnus-article-encrypt-protocol-alist
6410 current-prefix-arg))
6411 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6413 (error (format "Can't find the encrypt protocol %s" protocol)))
6414 (if (equal gnus-newsgroup-name "nndraft:drafts")
6415 (error "Can't encrypt the article in group nndraft:drafts"))
6416 (if (equal gnus-newsgroup-name "nndraft:queue")
6417 (error "Don't encrypt the article in group nndraft:queue"))
6418 (gnus-summary-iterate n
6420 (set-buffer gnus-summary-buffer)
6421 (let ((mail-parse-charset gnus-newsgroup-charset)
6422 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6423 (summary-buffer gnus-summary-buffer)
6425 (gnus-set-global-variables)
6426 (when (gnus-group-read-only-p)
6427 (error "The current newsgroup does not support article encrypt"))
6428 (gnus-summary-show-article t)
6430 (or (mail-header-references gnus-current-headers) ""))
6431 (set-buffer gnus-article-buffer)
6432 (let* ((buffer-read-only nil)
6434 (mapcar (lambda (field)
6435 (and (save-restriction
6436 (message-narrow-to-head)
6437 (goto-char (point-min))
6438 (search-forward field nil t))
6440 (message-narrow-to-field)
6441 (buffer-substring (point-min) (point-max))
6442 (delete-region (point-min) (point-max))
6444 '("Content-Type:" "Content-Transfer-Encoding:"
6445 "Content-Disposition:"))))
6446 (message-narrow-to-head)
6447 (message-remove-header "MIME-Version")
6448 (goto-char (point-max))
6449 (setq point (point))
6450 (insert (apply 'concat headers))
6452 (narrow-to-region point (point-max))
6453 (let ((message-options message-options))
6454 (message-options-set 'message-sender user-mail-address)
6455 (message-options-set 'message-recipients user-mail-address)
6456 (message-options-set 'message-sign-encrypt 'not)
6458 (goto-char (point-min))
6459 (insert "MIME-Version: 1.0\n")
6461 (gnus-summary-edit-article-done
6462 references nil summary-buffer t))
6463 (when gnus-keep-backlog
6464 (gnus-backlog-remove-article
6465 (car gnus-article-current) (cdr gnus-article-current)))
6467 (when (get-buffer gnus-original-article-buffer)
6468 (set-buffer gnus-original-article-buffer)
6469 (setq gnus-original-article nil)))
6470 (when gnus-use-cache
6471 (gnus-cache-update-article
6472 (car gnus-article-current) (cdr gnus-article-current))))))))
6474 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6475 "The following specs can be used:
6476 %t The security MIME type
6479 %D Details if button is pressed")
6481 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6482 "The following specs can be used:
6483 %t The security MIME type
6486 %D Details if button is pressed")
6488 (defvar gnus-mime-security-button-line-format-alist
6489 '((?t gnus-tmp-type ?s)
6490 (?i gnus-tmp-info ?s)
6491 (?d gnus-tmp-details ?s)
6492 (?D gnus-tmp-pressed-details ?s)))
6494 (defvar gnus-mime-security-button-map
6495 (let ((map (make-sparse-keymap)))
6496 (unless (>= (string-to-number emacs-version) 21)
6497 (set-keymap-parent map gnus-article-mode-map))
6498 (define-key map gnus-mouse-2 'gnus-article-push-button)
6499 (define-key map "\r" 'gnus-article-press-button)
6502 (defvar gnus-mime-security-details-buffer nil)
6504 (defvar gnus-mime-security-button-pressed nil)
6506 (defvar gnus-mime-security-show-details-inline t
6507 "If non-nil, show details in the article buffer.")
6509 (defun gnus-mime-security-verify-or-decrypt (handle)
6510 (mm-remove-parts (cdr handle))
6511 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6512 point buffer-read-only)
6514 (goto-char (car region)))
6516 (narrow-to-region (point) (point))
6517 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6518 (let* ((mm-verify-option 'known)
6519 (mm-decrypt-option 'known)
6520 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6521 (unless (eq nparts (cdr handle))
6522 (mm-destroy-parts (cdr handle))
6523 (setcdr handle nparts))))
6524 (setq point (point))
6525 (gnus-mime-display-security handle)
6526 (goto-char (point-max)))
6528 (delete-region (point) (cdr region))
6529 (set-marker (car region) nil)
6530 (set-marker (cdr region) nil))
6533 (defun gnus-mime-security-show-details (handle)
6534 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6536 (if gnus-mime-security-show-details-inline
6537 (let ((gnus-mime-security-button-pressed t)
6538 (gnus-mime-security-button-line-format
6539 (get-text-property (point) 'gnus-line-format))
6542 (while (eq (get-text-property (point) 'gnus-line-format)
6543 gnus-mime-security-button-line-format)
6547 (narrow-to-region (point) (point))
6548 (gnus-insert-mime-security-button handle))
6549 (delete-region (point)
6550 (or (text-property-not-all
6553 gnus-mime-security-button-line-format)
6555 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6556 (with-current-buffer gnus-mime-security-details-buffer
6559 (setq gnus-mime-security-details-buffer
6560 (gnus-get-buffer-create "*MIME Security Details*")))
6561 (with-current-buffer gnus-mime-security-details-buffer
6563 (goto-char (point-min)))
6564 (pop-to-buffer gnus-mime-security-details-buffer))
6565 (gnus-message 5 "No details."))))
6567 (defun gnus-mime-security-press-button (handle)
6568 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6569 (gnus-mime-security-show-details handle)
6570 (gnus-mime-security-verify-or-decrypt handle)))
6572 (defun gnus-insert-mime-security-button (handle &optional displayed)
6573 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6576 (or (nth 2 (assoc protocol mm-verify-function-alist))
6577 (nth 2 (assoc protocol mm-decrypt-function-alist))
6579 (if (equal (car handle) "multipart/signed")
6580 " Signed" " Encrypted")
6583 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6586 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6587 gnus-tmp-pressed-details
6589 (setq gnus-tmp-details
6590 (if gnus-tmp-details
6591 (concat "\n" gnus-tmp-details) ""))
6592 (setq gnus-tmp-pressed-details
6593 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6598 gnus-mime-security-button-line-format
6599 gnus-mime-security-button-line-format-alist
6600 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6601 gnus-callback gnus-mime-security-press-button
6602 gnus-line-format ,gnus-mime-security-button-line-format
6603 article-type annotation
6606 (widget-convert-button
6609 :action 'gnus-widget-press-button
6610 :button-keymap gnus-mime-security-button-map
6612 (lambda (widget/window &optional overlay pos)
6613 ;; Needed to properly clear the message due to a bug in
6614 ;; wid-edit (XEmacs only).
6615 (if (boundp 'help-echo-owns-message)
6616 (setq help-echo-owns-message t))
6619 (aref gnus-mouse-2 0))))))
6621 (defun gnus-mime-display-security (handle)
6623 (narrow-to-region (point) (point))
6624 (unless (gnus-unbuttonized-mime-type-p (car handle))
6625 (gnus-insert-mime-security-button handle))
6626 (gnus-mime-display-mixed (cdr handle))
6629 (unless (gnus-unbuttonized-mime-type-p (car handle))
6630 (let ((gnus-mime-security-button-line-format
6631 gnus-mime-security-button-end-line-format))
6632 (gnus-insert-mime-security-button handle)))
6633 (mm-set-handle-multipart-parameter
6635 (cons (set-marker (make-marker) (point-min))
6636 (set-marker (make-marker) (point-max))))))
6642 (defun gnus-article-header-presentation-method (entity situation)
6643 (mime-insert-header entity)
6644 (article-decode-group-name))
6646 (set-alist 'mime-header-presentation-method-alist
6647 'gnus-original-article-mode
6648 #'gnus-article-header-presentation-method)
6650 (defun gnus-mime-preview-quitting-method ()
6651 (mime-preview-kill-buffer)
6652 (delete-other-windows)
6653 (gnus-article-show-summary)
6654 (gnus-summary-select-article gnus-show-all-headers t))
6656 (set-alist 'mime-preview-quitting-method-alist
6657 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6659 (set-alist 'mime-preview-following-method-alist
6660 'gnus-original-article-mode #'gnus-following-method)
6662 (set-alist 'mime-preview-over-to-previous-method-alist
6663 'gnus-original-article-mode
6665 (if (> (point-min) 1)
6666 (gnus-article-prev-page)
6667 (gnus-article-read-summary-keys
6668 nil (gnus-character-to-event ?P)))))
6670 (set-alist 'mime-preview-over-to-next-method-alist
6671 'gnus-original-article-mode'
6673 (if (< (point-max) (buffer-size))
6674 (gnus-article-next-page)
6675 (gnus-article-read-summary-keys
6676 nil (gnus-character-to-event ?N)))))
6686 (run-hooks 'gnus-art-load-hook)
6688 ;;; gnus-art.el ends here