1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^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:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'xpm))
232 'gnus-xmas-article-display-xface
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'xbm)
235 'gnus-article-display-xface
236 (if gnus-article-compface-xbm
237 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
238 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
240 "*String or function to be executed to display an X-Face header.
241 If it is a string, the command will be executed in a sub-shell
242 asynchronously. The compressed face will be piped to this command."
243 :type `(choice string
245 ,(if (featurep 'xemacs)
246 'gnus-xmas-article-display-xface
247 'gnus-article-display-xface))
250 :group 'gnus-article-washing)
252 (defcustom gnus-article-x-face-too-ugly nil
253 "Regexp matching posters whose face shouldn't be shown automatically."
254 :type '(choice regexp (const nil))
255 :group 'gnus-article-washing)
257 (defcustom gnus-article-banner-alist nil
258 "Banner alist for stripping.
260 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
262 :type '(repeat (cons symbol regexp))
263 :group 'gnus-article-washing)
265 (gnus-define-group-parameter
268 "Alist of regexps (to match group names) and banner."
269 :variable-group gnus-article-washing
271 '(choice :tag "Banner"
273 (const :tag "Remove signature" signature)
274 (symbol :tag "Item in `gnus-article-banner-alist'" none)
276 (const :tag "None" nil))
278 "If non-nil, specify how to remove `banners' from articles.
280 Symbol `signature' means to remove signatures delimited by
281 `gnus-signature-separator'. Any other symbol is used to look up a
282 regular expression to match the banner in `gnus-article-banner-alist'.
283 A string is used as a regular expression to match the banner
286 (defcustom gnus-emphasis-alist
288 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
290 '(("_" "_" underline)
293 ("_/" "/_" underline-italic)
294 ("_\\*" "\\*_" underline-bold)
295 ("\\*/" "/\\*" bold-italic)
296 ("_\\*/" "/\\*_" underline-bold-italic))))
297 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
298 2 3 gnus-emphasis-underline)
302 (format format (car spec) (cadr spec))
303 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
305 "*Alist that says how to fontify certain phrases.
306 Each item looks like this:
308 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
310 The first element is a regular expression to be matched. The second
311 is a number that says what regular expression grouping used to find
312 the entire emphasized word. The third is a number that says what
313 regexp grouping should be displayed and highlighted. The fourth
314 is the face used for highlighting."
315 :type '(repeat (list :value ("" 0 0 default)
317 (integer :tag "Match group")
318 (integer :tag "Emphasize group")
320 :group 'gnus-article-emphasis)
322 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
323 "A regexp to describe whitespace which should not be emphasized.
324 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
325 The former avoids underlining of leading and trailing whitespace,
326 and the latter avoids underlining any whitespace at all."
328 :group 'gnus-article-emphasis
331 (defface gnus-emphasis-bold '((t (:bold t)))
332 "Face used for displaying strong emphasized text (*word*)."
333 :group 'gnus-article-emphasis)
335 (defface gnus-emphasis-italic '((t (:italic t)))
336 "Face used for displaying italic emphasized text (/word/)."
337 :group 'gnus-article-emphasis)
339 (defface gnus-emphasis-underline '((t (:underline t)))
340 "Face used for displaying underlined emphasized text (_word_)."
341 :group 'gnus-article-emphasis)
343 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
344 "Face used for displaying underlined bold emphasized text (_*word*_)."
345 :group 'gnus-article-emphasis)
347 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
348 "Face used for displaying underlined italic emphasized text (_/word/_)."
349 :group 'gnus-article-emphasis)
351 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
352 "Face used for displaying bold italic emphasized text (/*word*/)."
353 :group 'gnus-article-emphasis)
355 (defface gnus-emphasis-underline-bold-italic
356 '((t (:bold t :italic t :underline t)))
357 "Face used for displaying underlined bold italic emphasized text.
358 Esample: (_/*word*/_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-highlight-words
362 '((t (:background "black" :foreground "yellow")))
363 "Face used for displaying highlighted words."
364 :group 'gnus-article-emphasis)
366 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
367 "Format for display of Date headers in article bodies.
368 See `format-time-string' for the possible values.
370 The variable can also be function, which should return a complete Date
371 header. The function is called with one argument, the time, which can
372 be fed to `format-time-string'."
373 :type '(choice string symbol)
374 :link '(custom-manual "(gnus)Article Date")
375 :group 'gnus-article-washing)
378 (autoload 'mail-extract-address-components "mail-extr"))
380 (defcustom gnus-save-all-headers t
381 "*If non-nil, don't remove any headers before saving."
382 :group 'gnus-article-saving
385 (defcustom gnus-prompt-before-saving 'always
386 "*This variable says how much prompting is to be done when saving articles.
387 If it is nil, no prompting will be done, and the articles will be
388 saved to the default files. If this variable is `always', each and
389 every article that is saved will be preceded by a prompt, even when
390 saving large batches of articles. If this variable is neither nil not
391 `always', there the user will be prompted once for a file name for
392 each invocation of the saving commands."
393 :group 'gnus-article-saving
394 :type '(choice (item always)
395 (item :tag "never" nil)
396 (sexp :tag "once" :format "%t\n" :value t)))
398 (defcustom gnus-saved-headers gnus-visible-headers
399 "Headers to keep if `gnus-save-all-headers' is nil.
400 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
401 If that variable is nil, however, all headers that match this regexp
402 will be kept while the rest will be deleted before saving."
403 :group 'gnus-article-saving
406 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
407 "A function to save articles in your favourite format.
408 The function must be interactively callable (in other words, it must
409 be an Emacs command).
411 Gnus provides the following functions:
413 * gnus-summary-save-in-rmail (Rmail format)
414 * gnus-summary-save-in-mail (Unix mail format)
415 * gnus-summary-save-in-folder (MH folder)
416 * gnus-summary-save-in-file (article format)
417 * gnus-summary-save-body-in-file (article body)
418 * gnus-summary-save-in-vm (use VM's folder format)
419 * gnus-summary-write-to-file (article format -- overwrite)."
420 :group 'gnus-article-saving
421 :type '(radio (function-item gnus-summary-save-in-rmail)
422 (function-item gnus-summary-save-in-mail)
423 (function-item gnus-summary-save-in-folder)
424 (function-item gnus-summary-save-in-file)
425 (function-item gnus-summary-save-body-in-file)
426 (function-item gnus-summary-save-in-vm)
427 (function-item gnus-summary-write-to-file)))
429 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
430 "A function generating a file name to save articles in Rmail format.
431 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
432 :group 'gnus-article-saving
435 (defcustom gnus-mail-save-name 'gnus-plain-save-name
436 "A function generating a file name to save articles in Unix mail format.
437 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
438 :group 'gnus-article-saving
441 (defcustom gnus-folder-save-name 'gnus-folder-save-name
442 "A function generating a file name to save articles in MH folder.
443 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
444 :group 'gnus-article-saving
447 (defcustom gnus-file-save-name 'gnus-numeric-save-name
448 "A function generating a file name to save articles in article format.
449 The function is called with NEWSGROUP, HEADERS, and optional
451 :group 'gnus-article-saving
454 (defcustom gnus-split-methods
455 '((gnus-article-archive-name)
456 (gnus-article-nndoc-name))
457 "*Variable used to suggest where articles are to be saved.
458 For instance, if you would like to save articles related to Gnus in
459 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
460 you could set this variable to something like:
462 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
463 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
465 This variable is an alist where the where the key is the match and the
466 value is a list of possible files to save in if the match is non-nil.
468 If the match is a string, it is used as a regexp match on the
469 article. If the match is a symbol, that symbol will be funcalled
470 from the buffer of the article to be saved with the newsgroup as the
471 parameter. If it is a list, it will be evaled in the same buffer.
473 If this form or function returns a string, this string will be used as
474 a possible file name; and if it returns a non-nil list, that list will
475 be used as possible file names."
476 :group 'gnus-article-saving
477 :type '(repeat (choice (list :value (fun) function)
478 (cons :value ("" "") regexp (repeat string))
481 (defcustom gnus-page-delimiter "^\^L"
482 "*Regexp describing what to use as article page delimiters.
483 The default value is \"^\^L\", which is a form linefeed at the
484 beginning of a line."
486 :group 'gnus-article-various)
488 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
489 "*The format specification for the article mode line.
490 See `gnus-summary-mode-line-format' for a closer description.
492 The following additional specs are available:
494 %w The article washing status.
495 %m The number of MIME parts in the article."
497 :group 'gnus-article-various)
499 (defcustom gnus-article-mode-hook nil
500 "*A hook for Gnus article mode."
502 :group 'gnus-article-various)
504 (when (featurep 'xemacs)
505 ;; Extracted from gnus-xmas-define in order to preserve user settings
506 (when (fboundp 'turn-off-scroll-in-place)
507 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
508 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
509 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
511 (defcustom gnus-article-menu-hook nil
512 "*Hook run after the creation of the article mode menu."
514 :group 'gnus-article-various)
516 (defcustom gnus-article-prepare-hook nil
517 "*A hook called after an article has been prepared in the article buffer."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-hide-pgp-hook nil
522 "*A hook called after successfully hiding a PGP signature."
524 :group 'gnus-article-various)
526 (defcustom gnus-article-button-face 'bold
527 "Face used for highlighting buttons in the article buffer.
529 An article button is a piece of text that you can activate by pressing
530 `RET' or `mouse-2' above it."
532 :group 'gnus-article-buttons)
534 (defcustom gnus-article-mouse-face 'highlight
535 "Face used for mouse highlighting in the article buffer.
537 Article buttons will be displayed in this face when the cursor is
540 :group 'gnus-article-buttons)
542 (defcustom gnus-signature-face 'gnus-signature-face
543 "Face used for highlighting a signature in the article buffer.
544 Obsolete; use the face `gnus-signature-face' for customizations instead."
546 :group 'gnus-article-highlight
547 :group 'gnus-article-signature)
549 (defface gnus-signature-face
552 "Face used for highlighting a signature in the article buffer."
553 :group 'gnus-article-highlight
554 :group 'gnus-article-signature)
556 (defface gnus-header-from-face
559 (:foreground "spring green"))
562 (:foreground "red3"))
565 "Face used for displaying from headers."
566 :group 'gnus-article-headers
567 :group 'gnus-article-highlight)
569 (defface gnus-header-subject-face
572 (:foreground "SeaGreen3"))
575 (:foreground "red4"))
577 (:bold t :italic t)))
578 "Face used for displaying subject headers."
579 :group 'gnus-article-headers
580 :group 'gnus-article-highlight)
582 (defface gnus-header-newsgroups-face
585 (:foreground "yellow" :italic t))
588 (:foreground "MidnightBlue" :italic t))
591 "Face used for displaying newsgroups headers."
592 :group 'gnus-article-headers
593 :group 'gnus-article-highlight)
595 (defface gnus-header-name-face
598 (:foreground "SeaGreen"))
601 (:foreground "maroon"))
604 "Face used for displaying header names."
605 :group 'gnus-article-headers
606 :group 'gnus-article-highlight)
608 (defface gnus-header-content-face
611 (:foreground "forest green" :italic t))
614 (:foreground "indianred4" :italic t))
616 (:italic t))) "Face used for displaying header content."
617 :group 'gnus-article-headers
618 :group 'gnus-article-highlight)
620 (defcustom gnus-header-face-alist
621 '(("From" nil gnus-header-from-face)
622 ("Subject" nil gnus-header-subject-face)
623 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
624 ("" gnus-header-name-face gnus-header-content-face))
625 "*Controls highlighting of article header.
627 An alist of the form (HEADER NAME CONTENT).
629 HEADER is a regular expression which should match the name of an
630 header header and NAME and CONTENT are either face names or nil.
632 The name of each header field will be displayed using the face
633 specified by the first element in the list where HEADER match the
634 header name and NAME is non-nil. Similarly, the content will be
635 displayed by the first non-nil matching CONTENT face."
636 :group 'gnus-article-headers
637 :group 'gnus-article-highlight
638 :type '(repeat (list (regexp :tag "Header")
640 (item :tag "skip" nil)
641 (face :value default))
642 (choice :tag "Content"
643 (item :tag "skip" nil)
644 (face :value default)))))
646 (defcustom gnus-article-decode-hook
647 '(article-decode-charset article-decode-encoded-words
648 article-decode-group-name)
649 "*Hook run to decode charsets in articles."
650 :group 'gnus-article-headers
653 (defcustom gnus-display-mime-function 'gnus-display-mime
654 "Function to display MIME articles."
655 :group 'gnus-article-mime
658 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
659 "Function used to decode headers.")
661 (defvar gnus-article-dumbquotes-map
680 "Table for MS-to-Latin1 translation.")
682 (defcustom gnus-ignored-mime-types nil
683 "List of MIME types that should be ignored by Gnus."
685 :group 'gnus-article-mime
686 :type '(repeat regexp))
688 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
689 "List of MIME types that should not be given buttons when rendered inline.
690 See also `gnus-buttonized-mime-types' which may override this variable."
692 :group 'gnus-article-mime
693 :type '(repeat regexp))
695 (defcustom gnus-buttonized-mime-types nil
696 "List of MIME types that should be given buttons when rendered inline.
697 If set, this variable overrides `gnus-unbuttonized-mime-types'.
698 To see e.g. security buttons you could set this to
699 `(\"multipart/signed\")'."
701 :group 'gnus-article-mime
702 :type '(repeat regexp))
704 (defcustom gnus-article-mime-part-function nil
705 "Function called with a MIME handle as the argument.
706 This is meant for people who want to do something automatic based
707 on parts -- for instance, adding Vcard info to a database."
708 :group 'gnus-article-mime
711 (defcustom gnus-mime-multipart-functions nil
712 "An alist of MIME types to functions to display them."
714 :group 'gnus-article-mime
717 (defcustom gnus-article-date-lapsed-new-header nil
718 "Whether the X-Sent and Date headers can coexist.
719 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
720 either replace the old \"Date:\" header (if this variable is nil), or
721 be added below it (otherwise)."
723 :group 'gnus-article-headers
726 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
727 "Function called with a MIME handle as the argument.
728 This is meant for people who want to view first matched part.
729 For `undisplayed-alternative' (default), the first undisplayed
730 part or alternative part is used. For `undisplayed', the first
731 undisplayed part is used. For a function, the first part which
732 the function return `t' is used. For `nil', the first part is
735 :group 'gnus-article-mime
737 (item :tag "first" :value nil)
738 (item :tag "undisplayed" :value undisplayed)
739 (item :tag "undisplayed or alternative"
740 :value undisplayed-alternative)
743 (defcustom gnus-mime-action-alist
744 '(("save to file" . gnus-mime-save-part)
745 ("save and strip" . gnus-mime-save-part-and-strip)
746 ("display as text" . gnus-mime-inline-part)
747 ("view the part" . gnus-mime-view-part)
748 ("pipe to command" . gnus-mime-pipe-part)
749 ("toggle display" . gnus-article-press-button)
750 ("toggle display" . gnus-article-view-part-as-charset)
751 ("view as type" . gnus-mime-view-part-as-type)
752 ("internalize type" . gnus-mime-internalize-part)
753 ("externalize type" . gnus-mime-externalize-part))
754 "An alist of actions that run on the MIME attachment."
755 :group 'gnus-article-mime
756 :type '(repeat (cons (string :tag "name")
759 (defcustom gnus-mime-action-alist
760 '(("save to file" . gnus-mime-save-part)
761 ("display as text" . gnus-mime-inline-part)
762 ("view the part" . gnus-mime-view-part)
763 ("pipe to command" . gnus-mime-pipe-part)
764 ("toggle display" . gnus-article-press-button)
765 ("view as type" . gnus-mime-view-part-as-type)
766 ("internalize type" . gnus-mime-internalize-part)
767 ("externalize type" . gnus-mime-externalize-part))
768 "An alist of actions that run on the MIME attachment."
770 :group 'gnus-article-mime
771 :type '(repeat (cons (string :tag "name")
775 ;;; The treatment variables
778 (defvar gnus-part-display-hook nil
779 "Hook called on parts that are to receive treatment.")
781 (defvar gnus-article-treat-custom
782 '(choice (const :tag "Off" nil)
784 (const :tag "Header" head)
785 (const :tag "Last" last)
786 (integer :tag "Less")
787 (repeat :tag "Groups" regexp)
788 (sexp :tag "Predicate")))
790 (defvar gnus-article-treat-head-custom
791 '(choice (const :tag "Off" nil)
792 (const :tag "Header" head)))
794 (defvar gnus-article-treat-types '("text/plain")
797 (defvar gnus-inhibit-treatment nil
798 "Whether to inhibit treatment.")
800 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
801 "Highlight the signature.
802 Valid values are nil, t, `head', `last', an integer or a predicate.
803 See Info node `(gnus)Customizing Articles'."
804 :group 'gnus-article-treat
805 :type gnus-article-treat-custom)
806 (put 'gnus-treat-highlight-signature 'highlight t)
808 (defcustom gnus-treat-buttonize 100000
810 Valid values are nil, t, `head', `last', an integer or a predicate.
811 See the manual for details."
812 :group 'gnus-article-treat
813 :type gnus-article-treat-custom)
814 (put 'gnus-treat-buttonize 'highlight t)
816 (defcustom gnus-treat-buttonize-head 'head
817 "Add buttons to the head.
818 Valid values are nil, t, `head', `last', an integer or a predicate.
819 See the manual for details."
820 :group 'gnus-article-treat
821 :type gnus-article-treat-head-custom)
822 (put 'gnus-treat-buttonize-head 'highlight t)
824 (defcustom gnus-treat-emphasize
825 (and (or window-system
827 (>= (string-to-number emacs-version) 21))
830 Valid values are nil, t, `head', `last', an integer or a predicate.
831 See the manual for details."
832 :group 'gnus-article-treat
833 :type gnus-article-treat-custom)
834 (put 'gnus-treat-emphasize 'highlight t)
836 (defcustom gnus-treat-strip-cr nil
837 "Remove carriage returns.
838 Valid values are nil, t, `head', `last', an integer or a predicate.
839 See the manual for details."
840 :group 'gnus-article-treat
841 :type gnus-article-treat-custom)
843 (defcustom gnus-treat-leading-whitespace nil
844 "Remove leading whitespace in headers.
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See the manual for details."
847 :group 'gnus-article-treat
848 :type gnus-article-treat-custom)
850 (defcustom gnus-treat-hide-headers 'head
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See the manual for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-head-custom)
857 (defcustom gnus-treat-hide-boring-headers nil
858 "Hide boring headers.
859 Valid values are nil, t, `head', `last', an integer or a predicate.
860 See the manual for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-head-custom)
864 (defcustom gnus-treat-hide-signature nil
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-custom)
871 (defcustom gnus-treat-fill-article nil
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See the manual for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-custom)
878 (defcustom gnus-treat-hide-citation nil
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See the manual for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-custom)
885 (defcustom gnus-treat-hide-citation-maybe nil
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See the manual for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-strip-list-identifiers 'head
893 "Strip list identifiers from `gnus-list-identifiers`.
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See the manual for details."
897 :group 'gnus-article-treat
898 :type gnus-article-treat-custom)
900 (defcustom gnus-treat-strip-pgp t
901 "Strip PGP signatures.
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See the manual for details."
904 :group 'gnus-article-treat
905 :type gnus-article-treat-custom)
907 (defcustom gnus-treat-strip-pem nil
908 "Strip PEM signatures.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See the manual for details."
911 :group 'gnus-article-treat
912 :type gnus-article-treat-custom)
914 (defcustom gnus-treat-strip-banner t
915 "Strip banners from articles.
916 The banner to be stripped is specified in the `banner' group parameter.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See the manual for details."
919 :group 'gnus-article-treat
920 :type gnus-article-treat-custom)
922 (defcustom gnus-treat-highlight-headers 'head
923 "Highlight the headers.
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See the manual for details."
926 :group 'gnus-article-treat
927 :type gnus-article-treat-head-custom)
928 (put 'gnus-treat-highlight-headers 'highlight t)
930 (defcustom gnus-treat-highlight-citation t
931 "Highlight cited text.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See the manual for details."
934 :group 'gnus-article-treat
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-highlight-citation 'highlight t)
938 (defcustom gnus-treat-date-ut nil
939 "Display the Date in UT (GMT).
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See the manual for details."
942 :group 'gnus-article-treat
943 :type gnus-article-treat-head-custom)
945 (defcustom gnus-treat-date-local nil
946 "Display the Date in the local timezone.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See the manual for details."
949 :group 'gnus-article-treat
950 :type gnus-article-treat-head-custom)
952 (defcustom gnus-treat-date-english nil
953 "Display the Date in a format that can be read aloud in English.
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See the manual for details."
956 :group 'gnus-article-treat
957 :type gnus-article-treat-head-custom)
959 (defcustom gnus-treat-date-lapsed nil
960 "Display the Date header in a way that says how much time has elapsed.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See the manual for details."
963 :group 'gnus-article-treat
964 :type gnus-article-treat-head-custom)
966 (defcustom gnus-treat-date-original nil
967 "Display the date in the original timezone.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See the manual for details."
970 :group 'gnus-article-treat
971 :type gnus-article-treat-head-custom)
973 (defcustom gnus-treat-date-iso8601 nil
974 "Display the date in the ISO8601 format.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See the manual for details."
978 :group 'gnus-article-treat
979 :type gnus-article-treat-head-custom)
981 (defcustom gnus-treat-date-user-defined nil
982 "Display the date in a user-defined format.
983 The format is defined by the `gnus-article-time-format' variable.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See the manual for details."
986 :group 'gnus-article-treat
987 :type gnus-article-treat-head-custom)
989 (defcustom gnus-treat-strip-headers-in-body t
990 "Strip the X-No-Archive header line from the beginning of the body.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See the manual for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-strip-trailing-blank-lines nil
998 "Strip trailing blank lines.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See the manual for details."
1001 :group 'gnus-article-treat
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-strip-leading-blank-lines nil
1005 "Strip leading blank lines.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See the manual for details."
1008 :group 'gnus-article-treat
1009 :type gnus-article-treat-custom)
1011 (defcustom gnus-treat-strip-multiple-blank-lines nil
1012 "Strip multiple blank lines.
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See the manual for details."
1015 :group 'gnus-article-treat
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-unfold-headers 'head
1019 "Unfold folded header lines.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See the manual for details."
1022 :group 'gnus-article-treat
1023 :type gnus-article-treat-custom)
1025 (defcustom gnus-treat-fold-headers nil
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See the manual for details."
1029 :group 'gnus-article-treat
1030 :type gnus-article-treat-custom)
1032 (defcustom gnus-treat-fold-newsgroups 'head
1033 "Fold the Newsgroups and Followup-To headers.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See the manual for details."
1036 :group 'gnus-article-treat
1037 :type gnus-article-treat-custom)
1039 (defcustom gnus-treat-overstrike t
1040 "Treat overstrike highlighting.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See the manual for details."
1043 :group 'gnus-article-treat
1044 :type gnus-article-treat-custom)
1045 (put 'gnus-treat-overstrike 'highlight t)
1047 (defcustom gnus-treat-display-xface
1048 (and (or (and (fboundp 'image-type-available-p)
1049 (image-type-available-p 'xbm)
1050 (string-match "^0x" (shell-command-to-string "uncompface")))
1051 (and (featurep 'xemacs)
1054 "Display X-Face headers.
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See the manual for details."
1057 :group 'gnus-article-treat
1059 :type gnus-article-treat-head-custom)
1060 (put 'gnus-treat-display-xface 'highlight t)
1062 (defcustom gnus-treat-display-smileys
1063 (if (or (and (featurep 'xemacs)
1065 (and (fboundp 'image-type-available-p)
1066 (image-type-available-p 'pbm)))
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See the manual for details."
1071 :group 'gnus-article-treat
1073 :type gnus-article-treat-custom)
1074 (put 'gnus-treat-display-smileys 'highlight t)
1076 (defcustom gnus-treat-from-picon
1077 (if (gnus-image-type-available-p 'xpm)
1079 "Display picons in the From header.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See the manual for details."
1082 :group 'gnus-article-treat
1083 :type gnus-article-treat-head-custom)
1084 (put 'gnus-treat-from-picon 'highlight t)
1086 (defcustom gnus-treat-mail-picon
1087 (if (gnus-image-type-available-p 'xpm)
1089 "Display picons in To and Cc headers.
1090 Valid values are nil, t, `head', `last', an integer or a predicate.
1091 See the manual for details."
1092 :group 'gnus-article-treat
1093 :type gnus-article-treat-head-custom)
1094 (put 'gnus-treat-mail-picon 'highlight t)
1096 (defcustom gnus-treat-newsgroups-picon
1097 (if (gnus-image-type-available-p 'xpm)
1099 "Display picons in the Newsgroups and Followup-To headers.
1100 Valid values are nil, t, `head', `last', an integer or a predicate.
1101 See the manual for details."
1102 :group 'gnus-article-treat
1103 :type gnus-article-treat-head-custom)
1104 (put 'gnus-treat-newsgroups-picon 'highlight t)
1106 (defcustom gnus-treat-body-boundary
1107 (if (or gnus-treat-newsgroups-picon
1108 gnus-treat-mail-picon
1109 gnus-treat-from-picon)
1111 "Draw a boundary at the end of the headers.
1112 Valid values are nil, t, `head', `last', an integer or a predicate.
1113 See the manual for details."
1115 :group 'gnus-article-treat
1116 :type gnus-article-treat-custom)
1118 (defcustom gnus-treat-capitalize-sentences nil
1119 "Capitalize sentence-starting words.
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See the manual for details."
1123 :group 'gnus-article-treat
1124 :type gnus-article-treat-custom)
1126 (defcustom gnus-treat-fill-long-lines nil
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See the manual for details."
1130 :group 'gnus-article-treat
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-play-sounds nil
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See the manual for details."
1138 :group 'gnus-article-treat
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-translate nil
1142 "Translate articles from one language to another.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See the manual for details."
1146 :group 'gnus-article-treat
1147 :type gnus-article-treat-custom)
1149 (defcustom gnus-treat-x-pgp-sig nil
1151 To automatically treat X-PGP-Sig, set it to head.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See the manual for details."
1154 :group 'gnus-article-treat
1155 :group 'mime-security
1156 :type gnus-article-treat-custom)
1158 (defvar gnus-article-encrypt-protocol-alist
1159 '(("PGP" . mml2015-self-encrypt)))
1161 ;; Set to nil if more than one protocol added to
1162 ;; gnus-article-encrypt-protocol-alist.
1163 (defcustom gnus-article-encrypt-protocol "PGP"
1164 "The protocol used for encrypt articles.
1165 It is a string, such as \"PGP\". If nil, ask user."
1167 :group 'mime-security)
1169 ;;; Internal variables
1171 (defvar gnus-english-month-names
1172 '("January" "February" "March" "April" "May" "June" "July" "August"
1173 "September" "October" "November" "December"))
1175 (defvar article-goto-body-goes-to-point-min-p nil)
1176 (defvar gnus-article-wash-types nil)
1177 (defvar gnus-article-emphasis-alist nil)
1178 (defvar gnus-article-image-alist nil)
1180 (defvar gnus-article-mime-handle-alist-1 nil)
1181 (defvar gnus-treatment-function-alist
1182 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1183 (gnus-treat-strip-banner gnus-article-strip-banner)
1184 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1185 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1186 (gnus-treat-buttonize gnus-article-add-buttons)
1187 (gnus-treat-fill-article gnus-article-fill-cited-article)
1188 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1189 (gnus-treat-strip-cr gnus-article-remove-cr)
1190 (gnus-treat-date-ut gnus-article-date-ut)
1191 (gnus-treat-date-local gnus-article-date-local)
1192 (gnus-treat-date-english gnus-article-date-english)
1193 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1194 (gnus-treat-date-original gnus-article-date-original)
1195 (gnus-treat-date-user-defined gnus-article-date-user)
1196 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1197 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1198 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1199 (gnus-treat-hide-signature gnus-article-hide-signature)
1200 (gnus-treat-hide-citation gnus-article-hide-citation)
1201 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1202 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1203 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1204 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1205 (gnus-treat-strip-pem gnus-article-hide-pem)
1206 (gnus-treat-from-picon gnus-treat-from-picon)
1207 (gnus-treat-mail-picon gnus-treat-mail-picon)
1208 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1209 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1210 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1211 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1212 (gnus-treat-strip-trailing-blank-lines
1213 gnus-article-remove-trailing-blank-lines)
1214 (gnus-treat-strip-leading-blank-lines
1215 gnus-article-strip-leading-blank-lines)
1216 (gnus-treat-strip-multiple-blank-lines
1217 gnus-article-strip-multiple-blank-lines)
1218 (gnus-treat-overstrike gnus-article-treat-overstrike)
1219 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1220 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1221 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1222 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1223 (gnus-treat-display-smileys gnus-treat-smiley)
1224 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1225 (gnus-treat-emphasize gnus-article-emphasize)
1226 (gnus-treat-display-xface gnus-article-display-x-face)
1227 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1228 (gnus-treat-play-sounds gnus-earcon-display)))
1230 (defvar gnus-article-mime-handle-alist nil)
1231 (defvar article-lapsed-timer nil)
1232 (defvar gnus-article-current-summary nil)
1234 (defvar gnus-article-mode-syntax-table
1235 (let ((table (copy-syntax-table text-mode-syntax-table)))
1236 ;; This causes the citation match run O(2^n).
1237 ;; (modify-syntax-entry ?- "w" table)
1238 (modify-syntax-entry ?> ")" table)
1239 (modify-syntax-entry ?< "(" table)
1241 "Syntax table used in article mode buffers.
1242 Initialized from `text-mode-syntax-table.")
1244 (defvar gnus-save-article-buffer nil)
1246 (defvar gnus-article-mode-line-format-alist
1247 (nconc '((?w (gnus-article-wash-status) ?s)
1248 (?m (gnus-article-mime-part-status) ?s))
1249 gnus-summary-mode-line-format-alist))
1251 (defvar gnus-number-of-articles-to-be-saved nil)
1253 (defvar gnus-inhibit-hiding nil)
1255 ;;; Macros for dealing with the article buffer.
1257 (defmacro gnus-with-article-headers (&rest forms)
1259 (set-buffer gnus-article-buffer)
1261 (let ((buffer-read-only nil)
1262 (inhibit-point-motion-hooks t)
1263 (case-fold-search t))
1264 (article-narrow-to-head)
1267 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1268 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1270 (defmacro gnus-with-article-buffer (&rest forms)
1272 (set-buffer gnus-article-buffer)
1273 (let ((buffer-read-only nil))
1276 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1277 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1279 (defun gnus-article-goto-header (header)
1280 "Go to HEADER, which is a regular expression."
1281 (re-search-forward (concat "^\\(" header "\\):") nil t))
1283 (defsubst gnus-article-hide-text (b e props)
1284 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1285 (gnus-add-text-properties-when 'article-type nil b e props)
1286 (when (memq 'intangible props)
1288 (max (1- b) (point-min))
1289 b 'intangible (cddr (memq 'intangible props)))))
1291 (defsubst gnus-article-unhide-text (b e)
1292 "Remove hidden text properties from region between B and E."
1293 (remove-text-properties b e gnus-hidden-properties)
1294 (when (memq 'intangible gnus-hidden-properties)
1295 (put-text-property (max (1- b) (point-min))
1296 b 'intangible nil)))
1298 (defun gnus-article-hide-text-type (b e type)
1299 "Hide text of TYPE between B and E."
1300 (gnus-add-wash-type type)
1301 (gnus-article-hide-text
1302 b e (cons 'article-type (cons type gnus-hidden-properties))))
1304 (defun gnus-article-unhide-text-type (b e type)
1305 "Unhide text of TYPE between B and E."
1306 (gnus-delete-wash-type type)
1307 (remove-text-properties
1308 b e (cons 'article-type (cons type gnus-hidden-properties)))
1309 (when (memq 'intangible gnus-hidden-properties)
1310 (put-text-property (max (1- b) (point-min))
1311 b 'intangible nil)))
1313 (defun gnus-article-hide-text-of-type (type)
1314 "Hide text of TYPE in the current buffer."
1316 (let ((b (point-min))
1318 (while (setq b (text-property-any b e 'article-type type))
1319 (add-text-properties b (incf b) gnus-hidden-properties)))))
1321 (defun gnus-article-delete-text-of-type (type)
1322 "Delete text of TYPE in the current buffer."
1324 (let ((b (point-min)))
1325 (while (setq b (text-property-any b (point-max) 'article-type type))
1327 b (or (text-property-not-all b (point-max) 'article-type type)
1330 (defun gnus-article-delete-invisible-text ()
1331 "Delete all invisible text in the current buffer."
1333 (let ((b (point-min)))
1334 (while (setq b (text-property-any b (point-max) 'invisible t))
1336 b (or (text-property-not-all b (point-max) 'invisible t)
1339 (defun gnus-article-text-type-exists-p (type)
1340 "Say whether any text of type TYPE exists in the buffer."
1341 (text-property-any (point-min) (point-max) 'article-type type))
1343 (defsubst gnus-article-header-rank ()
1344 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1345 (let ((list gnus-sorted-header-list)
1348 (when (looking-at (car list))
1350 (setq list (cdr list))
1354 (defun article-hide-headers (&optional arg delete)
1355 "Hide unwanted headers and possibly sort them as well."
1357 ;; This function might be inhibited.
1358 (unless gnus-inhibit-hiding
1361 (let ((buffer-read-only nil)
1362 (case-fold-search t)
1363 (max (1+ (length gnus-sorted-header-list)))
1364 (ignored (when (not gnus-visible-headers)
1365 (cond ((stringp gnus-ignored-headers)
1366 gnus-ignored-headers)
1367 ((listp gnus-ignored-headers)
1368 (mapconcat 'identity gnus-ignored-headers
1371 (cond ((stringp gnus-visible-headers)
1372 gnus-visible-headers)
1373 ((and gnus-visible-headers
1374 (listp gnus-visible-headers))
1375 (mapconcat 'identity gnus-visible-headers "\\|"))))
1376 (inhibit-point-motion-hooks t)
1378 ;; First we narrow to just the headers.
1379 (article-narrow-to-head)
1380 ;; Hide any "From " lines at the beginning of (mail) articles.
1381 (while (looking-at "From ")
1384 (delete-region (point-min) (point)))
1385 ;; Then treat the rest of the header lines.
1386 ;; Then we use the two regular expressions
1387 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1388 ;; select which header lines is to remain visible in the
1390 (while (re-search-forward "^[^ \t:]*:" nil t)
1392 ;; Mark the rank of the header.
1394 (point) (1+ (point)) 'message-rank
1395 (if (or (and visible (looking-at visible))
1397 (not (looking-at ignored))))
1398 (gnus-article-header-rank)
1401 (message-sort-headers-1)
1402 (when (setq beg (text-property-any
1403 (point-min) (point-max) 'message-rank (+ 2 max)))
1404 ;; We delete the unwanted headers.
1405 (gnus-add-wash-type 'headers)
1406 (add-text-properties (point-min) (+ 5 (point-min))
1407 '(article-type headers dummy-invisible t))
1408 (delete-region beg (point-max))))))))
1410 (defun article-hide-boring-headers (&optional arg)
1411 "Toggle hiding of headers that aren't very interesting.
1412 If given a negative prefix, always show; if given a positive prefix,
1414 (interactive (gnus-article-hidden-arg))
1415 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1416 (not gnus-show-all-headers))
1419 (let ((buffer-read-only nil)
1420 (list gnus-boring-article-headers)
1421 (inhibit-point-motion-hooks t)
1423 (article-narrow-to-head)
1425 (setq elem (pop list))
1426 (goto-char (point-min))
1428 ;; Hide empty headers.
1430 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1432 (gnus-article-hide-text-type
1433 (progn (beginning-of-line) (point))
1436 (if (re-search-forward "^[^ \t]" nil t)
1440 ;; Hide boring Newsgroups header.
1441 ((eq elem 'newsgroups)
1442 (when (gnus-string-equal
1443 (gnus-fetch-field "newsgroups")
1444 (gnus-group-real-name
1445 (if (boundp 'gnus-newsgroup-name)
1448 (gnus-article-hide-header "newsgroups")))
1449 ((eq elem 'to-address)
1450 (let ((to (message-fetch-field "to"))
1452 (gnus-parameter-to-address
1453 (if (boundp 'gnus-newsgroup-name)
1454 gnus-newsgroup-name ""))))
1455 (when (and to to-address
1458 ;; only one address in To
1459 (nth 1 (mail-extract-address-components to))
1461 (gnus-article-hide-header "to"))))
1462 ((eq elem 'followup-to)
1463 (when (gnus-string-equal
1464 (message-fetch-field "followup-to")
1465 (message-fetch-field "newsgroups"))
1466 (gnus-article-hide-header "followup-to")))
1467 ((eq elem 'reply-to)
1468 (let ((from (message-fetch-field "from"))
1469 (reply-to (message-fetch-field "reply-to")))
1474 (nth 1 (mail-extract-address-components from))
1475 (nth 1 (mail-extract-address-components reply-to)))))
1476 (gnus-article-hide-header "reply-to"))))
1478 (let ((date (message-fetch-field "date")))
1480 (< (days-between (current-time-string) date)
1482 (gnus-article-hide-header "date"))))
1484 (let ((to (message-fetch-field "to"))
1485 (cc (message-fetch-field "cc")))
1486 (when (> (length to) 1024)
1487 (gnus-article-hide-header "to"))
1488 (when (> (length cc) 1024)
1489 (gnus-article-hide-header "cc"))))
1493 (goto-char (point-min))
1494 (while (re-search-forward "^to:" nil t)
1495 (setq to-count (1+ to-count)))
1496 (when (> to-count 1)
1497 (while (> to-count 0)
1498 (goto-char (point-min))
1500 (re-search-forward "^to:" nil nil to-count)
1502 (narrow-to-region (point) (point-max))
1503 (gnus-article-hide-header "to"))
1504 (setq to-count (1- to-count))))
1505 (goto-char (point-min))
1506 (while (re-search-forward "^cc:" nil t)
1507 (setq cc-count (1+ cc-count)))
1508 (when (> cc-count 1)
1509 (while (> cc-count 0)
1510 (goto-char (point-min))
1512 (re-search-forward "^cc:" nil nil cc-count)
1514 (narrow-to-region (point) (point-max))
1515 (gnus-article-hide-header "cc"))
1516 (setq cc-count (1- cc-count)))))))))))))
1518 (defun gnus-article-hide-header (header)
1520 (goto-char (point-min))
1521 (when (re-search-forward (concat "^" header ":") nil t)
1522 (gnus-article-hide-text-type
1523 (progn (beginning-of-line) (point))
1526 (if (re-search-forward "^[^ \t]" nil t)
1531 (defvar gnus-article-normalized-header-length 40
1532 "Length of normalized headers.")
1534 (defun article-normalize-headers ()
1535 "Make all header lines 40 characters long."
1537 (let ((buffer-read-only nil)
1541 (article-narrow-to-head)
1544 ((< (setq column (- (gnus-point-at-eol) (point)))
1545 gnus-article-normalized-header-length)
1547 (insert (make-string
1548 (- gnus-article-normalized-header-length column)
1550 ((> column gnus-article-normalized-header-length)
1551 (gnus-put-text-property
1553 (forward-char gnus-article-normalized-header-length)
1560 (forward-line 1))))))
1562 (defun article-treat-dumbquotes ()
1563 "Translate M****s*** sm*rtq**t*s into proper text.
1564 Note that this function guesses whether a character is a sm*rtq**t* or
1565 not, so it should only be used interactively.
1567 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1568 in an attempt to provide more quoting characters. If you see
1569 something like \\222 or \\264 where you're expecting some kind of
1570 apostrophe or quotation mark, then try this wash."
1572 (article-translate-strings gnus-article-dumbquotes-map))
1574 (defun article-translate-characters (from to)
1575 "Translate all characters in the body of the article according to FROM and TO.
1576 FROM is a string of characters to translate from; to is a string of
1577 characters to translate to."
1579 (when (article-goto-body)
1580 (let ((buffer-read-only nil)
1581 (x (make-string 225 ?x))
1583 (while (< (incf i) (length x))
1586 (while (< i (length from))
1587 (aset x (aref from i) (aref to i))
1589 (translate-region (point) (point-max) x)))))
1591 (defun article-translate-strings (map)
1592 "Translate all string in the body of the article according to MAP.
1593 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1595 (when (article-goto-body)
1596 (let ((buffer-read-only nil)
1598 (while (setq elem (pop map))
1600 (while (search-forward (car elem) nil t)
1601 (replace-match (cadr elem)))))))))
1603 (defun article-treat-overstrike ()
1604 "Translate overstrikes into bold text."
1607 (when (article-goto-body)
1608 (let ((buffer-read-only nil))
1609 (while (search-forward "\b" nil t)
1610 (let ((next (char-after))
1611 (previous (char-after (- (point) 2))))
1612 ;; We do the boldification/underlining by hiding the
1613 ;; overstrikes and putting the proper text property
1617 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1618 (put-text-property (point) (1+ (point)) 'face 'bold))
1620 (gnus-article-hide-text-type
1621 (1- (point)) (1+ (point)) 'overstrike)
1623 (- (point) 2) (1- (point)) 'face 'underline))
1625 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1627 (point) (1+ (point)) 'face 'underline)))))))))
1629 (defun gnus-article-treat-unfold-headers ()
1630 "Unfold folded message headers.
1631 Only the headers that fit into the current window width will be
1634 (gnus-with-article-headers
1638 (mail-header-narrow-to-field)
1639 (let ((header (buffer-substring (point-min) (point-max))))
1642 (goto-char (point-min))
1643 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1644 (replace-match " " t t)))
1645 (setq length (- (point-max) (point-min) 1)))
1646 (when (< length (window-width))
1647 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1648 (replace-match " " t t)))
1649 (goto-char (point-max)))))))
1651 (defun gnus-article-treat-fold-headers ()
1652 "Fold message headers."
1654 (gnus-with-article-headers
1657 (mail-header-narrow-to-field)
1658 (mail-header-fold-field)
1659 (goto-char (point-max))))))
1661 (defun gnus-treat-smiley ()
1662 "Display textual emoticons (\"smileys\") as small graphical icons."
1664 (gnus-with-article-buffer
1665 (if (memq 'smiley gnus-article-wash-types)
1666 (gnus-delete-images 'smiley)
1668 (let ((images (smiley-region (point) (point-max))))
1670 (gnus-add-wash-type 'smiley)
1671 (dolist (image images)
1672 (gnus-add-image 'smiley image)))))))
1674 (defun gnus-article-remove-images ()
1675 "Remove all images from the article buffer."
1677 (gnus-with-article-buffer
1678 (dolist (elem gnus-article-image-alist)
1679 (gnus-delete-images (car elem)))))
1681 (defun gnus-article-treat-fold-newsgroups ()
1682 "Unfold folded message headers.
1683 Only the headers that fit into the current window width will be
1686 (gnus-with-article-headers
1687 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1689 (mail-header-narrow-to-field)
1690 (while (search-forward "," nil t)
1691 (replace-match ", " t t))
1692 (mail-header-fold-field)
1693 (goto-char (point-max))))))
1695 (defun gnus-article-treat-body-boundary ()
1696 "Place a boundary line at the end of the headers."
1698 (gnus-with-article-headers
1699 (goto-char (point-max))
1700 (let ((start (point)))
1701 (insert "X-Boundary: ")
1702 (gnus-add-text-properties start (point) '(invisible t intangible t))
1703 (insert (make-string (1- (window-width)) ?-)
1706 (defun article-fill-long-lines ()
1707 "Fill lines that are wider than the window width."
1710 (let ((buffer-read-only nil)
1711 (width (window-width (get-buffer-window (current-buffer)))))
1714 (let ((adaptive-fill-mode nil)) ;Why? -sm
1717 (when (>= (current-column) (min fill-column width))
1718 (narrow-to-region (point) (gnus-point-at-bol))
1719 (fill-paragraph nil)
1720 (goto-char (point-max))
1722 (forward-line 1)))))))
1724 (defun article-capitalize-sentences ()
1725 "Capitalize the first word in each sentence."
1728 (let ((buffer-read-only nil)
1729 (paragraph-start "^[\n\^L]"))
1733 (forward-sentence)))))
1735 (defun article-remove-cr ()
1736 "Remove trailing CRs and then translate remaining CRs into LFs."
1739 (let ((buffer-read-only nil))
1740 (goto-char (point-min))
1741 (while (re-search-forward "\r+$" nil t)
1742 (replace-match "" t t))
1743 (goto-char (point-min))
1744 (while (search-forward "\r" nil t)
1745 (replace-match "\n" t t)))))
1747 (defun article-remove-trailing-blank-lines ()
1748 "Remove all trailing blank lines from the article."
1751 (let ((buffer-read-only nil))
1752 (goto-char (point-max))
1756 (while (and (not (bobp))
1757 (looking-at "^[ \t]*$")
1758 (not (gnus-annotation-in-region-p
1759 (point) (gnus-point-at-eol))))
1764 (defun article-display-x-face (&optional force)
1765 "Look for an X-Face header and display it if present."
1766 (interactive (list 'force))
1767 (gnus-with-article-headers
1768 ;; Delete the old process, if any.
1769 (when (process-status "article-x-face")
1770 (delete-process "article-x-face"))
1771 (if (memq 'xface gnus-article-wash-types)
1772 ;; We have already displayed X-Faces, so we remove them
1774 (gnus-delete-images 'xface)
1776 (let (x-faces from face)
1778 (set-buffer gnus-original-article-buffer)
1780 (mail-narrow-to-head)
1781 (while (gnus-article-goto-header "x-face")
1782 (push (mail-header-field-value) x-faces))
1783 (setq from (message-fetch-field "from"))))
1784 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1785 ;; single external face.
1786 (when (stringp gnus-article-x-face-command)
1787 (setq x-faces (list (car x-faces))))
1788 (while (and (setq face (pop x-faces))
1789 gnus-article-x-face-command
1791 ;; Check whether this face is censored.
1792 (not gnus-article-x-face-too-ugly)
1793 (and gnus-article-x-face-too-ugly from
1794 (not (string-match gnus-article-x-face-too-ugly
1796 ;; We display the face.
1797 (if (symbolp gnus-article-x-face-command)
1798 ;; The command is a lisp function, so we call it.
1799 (if (gnus-functionp gnus-article-x-face-command)
1800 (funcall gnus-article-x-face-command face)
1801 (error "%s is not a function" gnus-article-x-face-command))
1802 ;; The command is a string, so we interpret the command
1803 ;; as a, well, command, and fork it off.
1804 (let ((process-connection-type nil))
1805 (process-kill-without-query
1807 "article-x-face" nil shell-file-name shell-command-switch
1808 gnus-article-x-face-command))
1811 (process-send-region "article-x-face" (point-min) (point-max)))
1812 (process-send-eof "article-x-face"))))))))
1814 (defun article-decode-mime-words ()
1815 "Decode all MIME-encoded words in the article."
1818 (set-buffer gnus-article-buffer)
1819 (let ((inhibit-point-motion-hooks t)
1821 (mail-parse-charset gnus-newsgroup-charset)
1822 (mail-parse-ignored-charsets
1823 (save-excursion (set-buffer gnus-summary-buffer)
1824 gnus-newsgroup-ignored-charsets)))
1825 (mail-decode-encoded-word-region (point-min) (point-max)))))
1827 (defun article-decode-charset (&optional prompt)
1828 "Decode charset-encoded text in the article.
1829 If PROMPT (the prefix), prompt for a coding system to use."
1831 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1833 (mail-parse-charset gnus-newsgroup-charset)
1834 (mail-parse-ignored-charsets
1835 (save-excursion (condition-case nil
1836 (set-buffer gnus-summary-buffer)
1838 gnus-newsgroup-ignored-charsets))
1839 ct cte ctl charset format)
1842 (article-narrow-to-head)
1843 (setq ct (message-fetch-field "Content-Type" t)
1844 cte (message-fetch-field "Content-Transfer-Encoding" t)
1845 ctl (and ct (ignore-errors
1846 (mail-header-parse-content-type ct)))
1849 (mm-read-coding-system "Charset to decode: "))
1851 (mail-content-type-get ctl 'charset)))
1852 format (and ctl (mail-content-type-get ctl 'format)))
1854 (setq cte (mail-header-strip cte)))
1855 (if (and ctl (not (string-match "/" (car ctl))))
1857 (goto-char (point-max)))
1860 (narrow-to-region (point) (point-max))
1861 (when (and (eq mail-parse-charset 'gnus-decoded)
1862 (eq (mm-body-7-or-8) '8bit))
1863 ;; The text code could have been decoded.
1864 (setq charset mail-parse-charset))
1865 (when (and (or (not ctl)
1866 (equal (car ctl) "text/plain"))
1867 (not format)) ;; article with format will decode later.
1869 charset (and cte (intern (downcase
1870 (gnus-strip-whitespace cte))))
1873 (defun article-decode-encoded-words ()
1874 "Remove encoded-word encoding from headers."
1875 (let ((inhibit-point-motion-hooks t)
1876 (mail-parse-charset gnus-newsgroup-charset)
1877 (mail-parse-ignored-charsets
1878 (save-excursion (condition-case nil
1879 (set-buffer gnus-summary-buffer)
1881 gnus-newsgroup-ignored-charsets))
1884 (article-narrow-to-head)
1885 (funcall gnus-decode-header-function (point-min) (point-max)))))
1887 (defun article-decode-group-name ()
1888 "Decode group names in `Newsgroups:'."
1889 (let ((inhibit-point-motion-hooks t)
1891 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1892 (when (and (or gnus-group-name-charset-method-alist
1893 gnus-group-name-charset-group-alist)
1894 (gnus-buffer-live-p gnus-original-article-buffer))
1895 (when (nnmail-fetch-field "Newsgroups")
1896 (nnheader-replace-header "Newsgroups"
1897 (gnus-decode-newsgroups
1898 (with-current-buffer
1899 gnus-original-article-buffer
1900 (nnmail-fetch-field "Newsgroups"))
1901 gnus-newsgroup-name method)))
1902 (when (nnmail-fetch-field "Followup-To")
1903 (nnheader-replace-header "Followup-To"
1904 (gnus-decode-newsgroups
1905 (with-current-buffer
1906 gnus-original-article-buffer
1907 (nnmail-fetch-field "Followup-To"))
1908 gnus-newsgroup-name method))))))
1910 (defun article-de-quoted-unreadable (&optional force read-charset)
1911 "Translate a quoted-printable-encoded article.
1912 If FORCE, decode the article whether it is marked as quoted-printable
1914 If READ-CHARSET, ask for a coding system."
1915 (interactive (list 'force current-prefix-arg))
1917 (let ((buffer-read-only nil) type charset)
1918 (if (gnus-buffer-live-p gnus-original-article-buffer)
1919 (with-current-buffer gnus-original-article-buffer
1921 (gnus-fetch-field "content-transfer-encoding"))
1922 (let* ((ct (gnus-fetch-field "content-type"))
1925 (mail-header-parse-content-type ct)))))
1926 (setq charset (and ctl
1927 (mail-content-type-get ctl 'charset)))
1928 (if (stringp charset)
1929 (setq charset (intern (downcase charset)))))))
1931 (setq charset (mm-read-coding-system "Charset: " charset)))
1933 (setq charset gnus-newsgroup-charset))
1935 (and type (let ((case-fold-search t))
1936 (string-match "quoted-printable" type))))
1938 (quoted-printable-decode-region
1939 (point) (point-max) (mm-charset-to-coding-system charset))))))
1941 (defun article-de-base64-unreadable (&optional force read-charset)
1942 "Translate a base64 article.
1943 If FORCE, decode the article whether it is marked as base64 not.
1944 If READ-CHARSET, ask for a coding system."
1945 (interactive (list 'force current-prefix-arg))
1947 (let ((buffer-read-only nil) type charset)
1948 (if (gnus-buffer-live-p gnus-original-article-buffer)
1949 (with-current-buffer gnus-original-article-buffer
1951 (gnus-fetch-field "content-transfer-encoding"))
1952 (let* ((ct (gnus-fetch-field "content-type"))
1955 (mail-header-parse-content-type ct)))))
1956 (setq charset (and ctl
1957 (mail-content-type-get ctl 'charset)))
1958 (if (stringp charset)
1959 (setq charset (intern (downcase charset)))))))
1961 (setq charset (mm-read-coding-system "Charset: " charset)))
1963 (setq charset gnus-newsgroup-charset))
1965 (and type (let ((case-fold-search t))
1966 (string-match "base64" type))))
1969 (narrow-to-region (point) (point-max))
1970 (base64-decode-region (point-min) (point-max))
1971 (mm-decode-coding-region
1972 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1977 (defun article-decode-HZ ()
1978 "Translate a HZ-encoded article."
1982 (let ((buffer-read-only nil))
1983 (rfc1843-decode-region (point-min) (point-max)))))
1985 (defun article-wash-html (&optional read-charset)
1986 "Format an html article.
1987 If READ-CHARSET, ask for a coding system."
1990 (let ((buffer-read-only nil)
1992 (if (gnus-buffer-live-p gnus-original-article-buffer)
1993 (with-current-buffer gnus-original-article-buffer
1994 (let* ((ct (gnus-fetch-field "content-type"))
1997 (mail-header-parse-content-type ct)))))
1998 (setq charset (and ctl
1999 (mail-content-type-get ctl 'charset)))
2000 (if (stringp charset)
2001 (setq charset (intern (downcase charset)))))))
2003 (setq charset (mm-read-coding-system "Charset: " charset)))
2005 (setq charset gnus-newsgroup-charset))
2007 (save-window-excursion
2009 (narrow-to-region (point) (point-max))
2011 (let ((w3-strict-width (window-width))
2012 (url-standalone-mode t)
2013 (w3-honor-stylesheets nil)
2014 (w3-delay-image-loads t))
2016 (w3-region (point-min) (point-max))
2019 (defun article-hide-list-identifiers ()
2020 "Remove list identifies from the Subject header.
2021 The `gnus-list-identifiers' variable specifies what to do."
2023 (let ((inhibit-point-motion-hooks t)
2024 (regexp (if (consp gnus-list-identifiers)
2025 (mapconcat 'identity gnus-list-identifiers " *\\|")
2026 gnus-list-identifiers))
2031 (article-narrow-to-head)
2032 (goto-char (point-min))
2033 (while (re-search-forward
2034 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2036 (delete-region (match-beginning 2) (match-end 0))
2037 (beginning-of-line))
2038 (when (re-search-forward
2039 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2040 (delete-region (match-beginning 1) (match-end 1))))))))
2042 (defun article-hide-pgp ()
2043 "Remove any PGP headers and signatures in the current article."
2047 (let ((inhibit-point-motion-hooks t)
2048 buffer-read-only beg end)
2050 ;; Hide the "header".
2051 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2052 (gnus-add-wash-type 'pgp)
2053 (delete-region (match-beginning 0) (match-end 0))
2054 ;; Remove armor headers (rfc2440 6.2)
2055 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2058 ;; Hide the actual signature.
2059 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2060 (setq end (1+ (match-beginning 0)))
2063 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2065 ;; Perhaps we shouldn't hide to the end of the buffer
2066 ;; if there is no end to the signature?
2068 ;; Hide "- " PGP quotation markers.
2070 (narrow-to-region beg end)
2071 (goto-char (point-min))
2072 (while (re-search-forward "^- " nil t)
2074 (match-beginning 0) (match-end 0)))
2076 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2078 (defun article-hide-pem (&optional arg)
2079 "Toggle hiding of any PEM headers and signatures in the current article.
2080 If given a negative prefix, always show; if given a positive prefix,
2082 (interactive (gnus-article-hidden-arg))
2083 (unless (gnus-article-check-hidden-text 'pem arg)
2085 (let (buffer-read-only end)
2086 (goto-char (point-min))
2087 ;; Hide the horrendously ugly "header".
2088 (when (and (search-forward
2089 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2091 (setq end (1+ (match-beginning 0))))
2092 (gnus-add-wash-type 'pem)
2093 (gnus-article-hide-text-type
2095 (if (search-forward "\n\n" nil t)
2099 ;; Hide the trailer as well
2100 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2102 (gnus-article-hide-text-type
2103 (match-beginning 0) (match-end 0) 'pem)))))))
2105 (defun article-strip-banner ()
2106 "Strip the banner specified by the `banner' group parameter."
2110 (let ((inhibit-point-motion-hooks t)
2111 (banner (gnus-parameter-banner gnus-newsgroup-name))
2112 (gnus-signature-limit nil)
2113 buffer-read-only beg end)
2117 ((eq banner 'signature)
2118 (when (gnus-article-narrow-to-signature)
2121 (delete-region (point) (point-max))))
2123 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2124 (while (re-search-forward banner nil t)
2125 (delete-region (match-beginning 0) (match-end 0)))))
2127 (while (re-search-forward banner nil t)
2128 (delete-region (match-beginning 0) (match-end 0))))))))))
2130 (defun article-babel ()
2131 "Translate article using an online translation service."
2135 (set-buffer gnus-article-buffer)
2136 (when (article-goto-body)
2137 (let* ((buffer-read-only nil)
2140 (orig (buffer-substring start end))
2141 (trans (babel-as-string orig)))
2143 (narrow-to-region start end)
2144 (delete-region start end)
2147 (defun article-hide-signature (&optional arg)
2148 "Hide the signature in the current article.
2149 If given a negative prefix, always show; if given a positive prefix,
2151 (interactive (gnus-article-hidden-arg))
2152 (unless (gnus-article-check-hidden-text 'signature arg)
2155 (let ((buffer-read-only nil))
2156 (when (gnus-article-narrow-to-signature)
2157 (gnus-article-hide-text-type
2158 (point-min) (point-max) 'signature))))))
2159 (gnus-set-mode-line 'article))
2161 (defun article-strip-headers-in-body ()
2162 "Strip offensive headers from bodies."
2166 (let ((case-fold-search t))
2167 (when (looking-at "x-no-archive:")
2168 (gnus-delete-line)))))
2170 (defun article-strip-leading-blank-lines ()
2171 "Remove all blank lines from the beginning of the article."
2174 (let ((inhibit-point-motion-hooks t)
2176 (when (article-goto-body)
2177 (while (and (not (eobp))
2178 (looking-at "[ \t]*$"))
2179 (gnus-delete-line))))))
2181 (defun article-narrow-to-head ()
2182 "Narrow the buffer to the head of the message.
2183 Point is left at the beginning of the narrowed-to region."
2185 (goto-char (point-min))
2186 (if (search-forward "\n\n" nil 1)
2189 (goto-char (point-min)))
2191 (defun article-goto-body ()
2192 "Place point at the start of the body."
2193 (goto-char (point-min))
2195 ;; This variable is only bound when dealing with separate
2197 (article-goto-body-goes-to-point-min-p
2199 ((search-forward "\n\n" nil t)
2202 (goto-char (point-max))
2205 (defun article-strip-multiple-blank-lines ()
2206 "Replace consecutive blank lines with one empty line."
2209 (let ((inhibit-point-motion-hooks t)
2211 ;; First make all blank lines empty.
2213 (while (re-search-forward "^[ \t]+$" nil t)
2214 (unless (gnus-annotation-in-region-p
2215 (match-beginning 0) (match-end 0))
2216 (replace-match "" nil t)))
2217 ;; Then replace multiple empty lines with a single empty line.
2219 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2220 (unless (gnus-annotation-in-region-p
2221 (match-beginning 0) (match-end 0))
2222 (delete-region (match-beginning 1) (match-end 1)))))))
2224 (defun article-strip-leading-space ()
2225 "Remove all white space from the beginning of the lines in the article."
2228 (let ((inhibit-point-motion-hooks t)
2231 (while (re-search-forward "^[ \t]+" nil t)
2232 (replace-match "" t t)))))
2234 (defun article-strip-trailing-space ()
2235 "Remove all white space from the end of the lines in the article."
2238 (let ((inhibit-point-motion-hooks t)
2241 (while (re-search-forward "[ \t]+$" nil t)
2242 (replace-match "" t t)))))
2244 (defun article-strip-blank-lines ()
2245 "Strip leading, trailing and multiple blank lines."
2247 (article-strip-leading-blank-lines)
2248 (article-remove-trailing-blank-lines)
2249 (article-strip-multiple-blank-lines))
2251 (defun article-strip-all-blank-lines ()
2252 "Strip all blank lines."
2255 (let ((inhibit-point-motion-hooks t)
2258 (while (re-search-forward "^[ \t]*\n" nil t)
2259 (replace-match "" t t)))))
2261 (defun gnus-article-narrow-to-signature ()
2262 "Narrow to the signature; return t if a signature is found, else nil."
2263 (let ((inhibit-point-motion-hooks t))
2264 (when (gnus-article-search-signature)
2266 ;; Check whether we have some limits to what we consider
2267 ;; to be a signature.
2268 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2269 (list gnus-signature-limit)))
2271 (while (setq limit (pop limits))
2272 (if (or (and (integerp limit)
2273 (< (- (point-max) (point)) limit))
2275 (< (count-lines (point) (point-max)) limit))
2276 (and (gnus-functionp limit)
2278 (and (stringp limit)
2279 (not (re-search-forward limit nil t))))
2280 () ; This limit did not succeed.
2284 (narrow-to-region (point) (point-max))
2287 (defun gnus-article-search-signature ()
2288 "Search the current buffer for the signature separator.
2289 Put point at the beginning of the signature separator."
2290 (let ((cur (point)))
2291 (goto-char (point-max))
2292 (if (if (stringp gnus-signature-separator)
2293 (re-search-backward gnus-signature-separator nil t)
2294 (let ((seps gnus-signature-separator))
2296 (not (re-search-backward (car seps) nil t)))
2303 (defun gnus-article-hidden-arg ()
2304 "Return the current prefix arg as a number, or 0 if no prefix."
2305 (list (if current-prefix-arg
2306 (prefix-numeric-value current-prefix-arg)
2309 (defun gnus-article-check-hidden-text (type arg)
2310 "Return nil if hiding is necessary.
2311 Arg can be nil or a number. nil and positive means hide, negative
2312 means show, 0 means toggle."
2315 (let ((hide (gnus-article-hidden-text-p type)))
2321 (gnus-article-show-hidden-text type)
2324 (if (eq hide 'hidden)
2326 (gnus-article-show-hidden-text type)
2330 (defun gnus-article-hidden-text-p (type)
2331 "Say whether the current buffer contains hidden text of type TYPE."
2332 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2334 (not (get-text-property pos 'invisible))
2335 (not (get-text-property pos 'dummy-invisible)))
2337 (text-property-any (1+ pos) (point-max) 'article-type type)))
2342 (defun gnus-article-show-hidden-text (type &optional dummy)
2343 "Show all hidden text of type TYPE.
2344 Originally it is hide instead of DUMMY."
2345 (let ((buffer-read-only nil)
2346 (inhibit-point-motion-hooks t))
2347 (gnus-remove-text-properties-when
2349 (point-min) (point-max)
2350 (cons 'article-type (cons type
2351 gnus-hidden-properties)))
2352 (gnus-delete-wash-type type)))
2354 (defconst article-time-units
2355 `((year . ,(* 365.25 24 60 60))
2356 (week . ,(* 7 24 60 60))
2357 (day . ,(* 24 60 60))
2361 "Mapping from time units to seconds.")
2363 (defun article-date-ut (&optional type highlight header)
2364 "Convert DATE date to universal time in the current article.
2365 If TYPE is `local', convert to local time; if it is `lapsed', output
2366 how much time has lapsed since DATE. For `lapsed', the value of
2367 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2368 should replace the \"Date:\" one, or should be added below it."
2369 (interactive (list 'ut t))
2370 (let* ((header (or header
2371 (message-fetch-field "date")
2373 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2376 ((not gnus-article-date-lapsed-new-header)
2382 (date (if (vectorp header) (mail-header-date header)
2384 (inhibit-point-motion-hooks t)
2389 (article-narrow-to-head)
2390 (when (re-search-forward tdate-regexp nil t)
2391 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2392 date (or (get-text-property (gnus-point-at-bol)
2395 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2397 (when (and date (not (string= date "")))
2398 (goto-char (point-min))
2399 (let ((buffer-read-only nil))
2400 ;; Delete any old Date headers.
2401 (while (re-search-forward date-regexp nil t)
2403 (delete-region (progn (beginning-of-line) (point))
2404 (progn (forward-line 1) (point)))
2405 (delete-region (progn (beginning-of-line) (point))
2406 (progn (end-of-line) (point)))
2407 (setq pos (point))))
2408 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2410 (if pos (goto-char pos))
2411 (insert (article-make-date-line date (or type 'ut)))
2417 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2418 (put-text-property (match-beginning 1) (1+ (match-end 1))
2419 'original-date date)
2420 (put-text-property (match-beginning 1) (1+ (match-end 1))
2422 (put-text-property (match-beginning 2) (match-end 2)
2425 (defun article-make-date-line (date type)
2426 "Return a DATE line of TYPE."
2427 (unless (memq type '(local ut original user iso8601 lapsed english))
2428 (error "Unknown conversion type: %s" type))
2430 (let ((time (date-to-time date)))
2432 ;; Convert to the local timezone.
2434 (let ((tz (car (current-time-zone time))))
2435 (format "Date: %s %s%02d%02d" (current-time-string time)
2436 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2437 (/ (% (abs tz) 3600) 60))))
2438 ;; Convert to Universal Time.
2441 (current-time-string
2442 (let* ((e (parse-time-string date))
2443 (tm (apply 'encode-time e))
2445 (ls (- (cadr tm) (car (current-time-zone time)))))
2446 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2447 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2450 ;; Get the original date from the article.
2451 ((eq type 'original)
2452 (concat "Date: " (if (string-match "\n+$" date)
2453 (substring date 0 (match-beginning 0))
2455 ;; Let the user define the format.
2457 (if (gnus-functionp gnus-article-time-format)
2458 (funcall gnus-article-time-format time)
2461 (format-time-string gnus-article-time-format time))))
2464 (let ((tz (car (current-time-zone time))))
2467 (format-time-string "%Y%m%dT%H%M%S" time)
2468 (format "%s%02d%02d"
2469 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2470 (/ (% (abs tz) 3600) 60)))))
2471 ;; Do an X-Sent lapsed format.
2473 ;; If the date is seriously mangled, the timezone functions are
2474 ;; liable to bug out, so we ignore all errors.
2475 (let* ((now (current-time))
2476 (real-time (subtract-time now time))
2477 (real-sec (and real-time
2478 (+ (* (float (car real-time)) 65536)
2480 (sec (and real-time (abs real-sec)))
2490 ;; This is a bit convoluted, but basically we go
2491 ;; through the time units for years, weeks, etc,
2492 ;; and divide things to see whether that results
2493 ;; in positive answers.
2496 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2497 ;; The (remaining) seconds are too few to
2498 ;; be divided into this time unit.
2500 ;; It's big enough, so we output it.
2501 (setq sec (- sec (* num (cdr unit))))
2503 (concat (if prev ", " "") (int-to-string
2505 " " (symbol-name (car unit))
2506 (if (> num 1) "s" ""))
2508 article-time-units "")
2509 ;; If dates are odd, then it might appear like the
2510 ;; article was sent in the future.
2513 " in the future"))))))
2514 ;; Display the date in proper English
2516 (let ((dtime (decode-time time)))
2519 (number-to-string (nth 3 dtime))
2520 (let ((digit (% (nth 3 dtime) 10)))
2522 ((memq (nth 3 dtime) '(11 12 13)) "th")
2528 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2530 (number-to-string (nth 5 dtime))
2532 (format "%02d" (nth 2 dtime))
2534 (format "%02d" (nth 1 dtime)))))))
2536 (format "Date: %s (from Oort)" date))))
2538 (defun article-date-local (&optional highlight)
2539 "Convert the current article date to the local timezone."
2540 (interactive (list t))
2541 (article-date-ut 'local highlight))
2543 (defun article-date-english (&optional highlight)
2544 "Convert the current article date to something that is proper English."
2545 (interactive (list t))
2546 (article-date-ut 'english highlight))
2548 (defun article-date-original (&optional highlight)
2549 "Convert the current article date to what it was originally.
2550 This is only useful if you have used some other date conversion
2551 function and want to see what the date was before converting."
2552 (interactive (list t))
2553 (article-date-ut 'original highlight))
2555 (defun article-date-lapsed (&optional highlight)
2556 "Convert the current article date to time lapsed since it was sent."
2557 (interactive (list t))
2558 (article-date-ut 'lapsed highlight))
2560 (defun article-update-date-lapsed ()
2561 "Function to be run from a timer to update the lapsed time line."
2562 (let (deactivate-mark)
2567 (set-buffer (window-buffer w))
2568 (when (eq major-mode 'gnus-article-mode)
2569 (goto-char (point-min))
2570 (when (re-search-forward "^X-Sent:" nil t)
2571 (article-date-lapsed t))))
2574 (defun gnus-start-date-timer (&optional n)
2575 "Start a timer to update the X-Sent header in the article buffers.
2576 The numerical prefix says how frequently (in seconds) the function
2581 (gnus-stop-date-timer)
2582 (setq article-lapsed-timer
2583 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2585 (defun gnus-stop-date-timer ()
2586 "Stop the X-Sent timer."
2588 (when article-lapsed-timer
2589 (nnheader-cancel-timer article-lapsed-timer)
2590 (setq article-lapsed-timer nil)))
2592 (defun article-date-user (&optional highlight)
2593 "Convert the current article date to the user-defined format.
2594 This format is defined by the `gnus-article-time-format' variable."
2595 (interactive (list t))
2596 (article-date-ut 'user highlight))
2598 (defun article-date-iso8601 (&optional highlight)
2599 "Convert the current article date to ISO8601."
2600 (interactive (list t))
2601 (article-date-ut 'iso8601 highlight))
2603 (defun article-show-all ()
2604 "Show all hidden text in the article buffer."
2607 (let ((buffer-read-only nil))
2608 (gnus-article-unhide-text (point-min) (point-max)))))
2610 (defun article-remove-leading-whitespace ()
2611 "Remove excessive whitespace from all headers."
2615 (let ((buffer-read-only nil))
2616 (article-narrow-to-head)
2617 (goto-char (point-min))
2618 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2619 (delete-region (match-beginning 1) (match-end 1)))))))
2621 (defun article-emphasize (&optional arg)
2622 "Emphasize text according to `gnus-emphasis-alist'."
2623 (interactive (gnus-article-hidden-arg))
2624 (unless (gnus-article-check-hidden-text 'emphasis arg)
2628 (with-current-buffer gnus-summary-buffer
2629 gnus-article-emphasis-alist)
2631 gnus-emphasis-alist))
2632 (buffer-read-only nil)
2633 (props (append '(article-type emphasis)
2634 gnus-hidden-properties))
2635 regexp elem beg invisible visible face)
2638 (while (setq elem (pop alist))
2640 (setq regexp (car elem)
2641 invisible (nth 1 elem)
2642 visible (nth 2 elem)
2644 (while (re-search-forward regexp nil t)
2645 (when (and (match-beginning visible) (match-beginning invisible))
2646 (gnus-article-hide-text
2647 (match-beginning invisible) (match-end invisible) props)
2648 (gnus-article-unhide-text-type
2649 (match-beginning visible) (match-end visible) 'emphasis)
2650 (gnus-put-overlay-excluding-newlines
2651 (match-beginning visible) (match-end visible) 'face face)
2652 (gnus-add-wash-type 'emphasis)
2653 (goto-char (match-end invisible)))))))))
2655 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2656 "Setup newsgroup emphasis alist."
2657 (unless gnus-article-emphasis-alist
2658 (let ((name (and gnus-newsgroup-name
2659 (gnus-group-real-name gnus-newsgroup-name))))
2660 (make-local-variable 'gnus-article-emphasis-alist)
2661 (setq gnus-article-emphasis-alist
2663 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2664 (while (setq elem (pop alist))
2665 (when (and name (string-match (car elem) name))
2667 highlight (copy-sequence (cdr elem)))))
2669 (copy-sequence highlight-words)
2670 (if gnus-newsgroup-name
2671 (copy-sequence (gnus-group-find-parameter
2672 gnus-newsgroup-name 'highlight-words t)))
2673 gnus-emphasis-alist)))))
2676 (defvar gnus-summary-article-menu)
2677 (defvar gnus-summary-post-menu))
2679 ;;; Saving functions.
2681 (defun gnus-article-save (save-buffer file &optional num)
2682 "Save the currently selected article."
2683 (unless gnus-save-all-headers
2684 ;; Remove headers according to `gnus-saved-headers'.
2685 (let ((gnus-visible-headers
2686 (or gnus-saved-headers gnus-visible-headers))
2687 (gnus-article-buffer save-buffer))
2689 (set-buffer save-buffer)
2690 (article-hide-headers 1 t))))
2691 (save-window-excursion
2692 (if (not gnus-default-article-saver)
2693 (error "No default saver is defined")
2694 ;; !!! Magic! The saving functions all save
2695 ;; `gnus-save-article-buffer' (or so they think), but we
2696 ;; bind that variable to our save-buffer.
2697 (set-buffer gnus-article-buffer)
2698 (let* ((gnus-save-article-buffer save-buffer)
2701 ((not gnus-prompt-before-saving) 'default)
2702 ((eq gnus-prompt-before-saving 'always) nil)
2704 (gnus-number-of-articles-to-be-saved
2705 (when (eq gnus-prompt-before-saving t)
2707 (set-buffer gnus-article-current-summary)
2708 (funcall gnus-default-article-saver filename)))))
2710 (defun gnus-read-save-file-name (prompt &optional filename
2711 function group headers variable)
2713 (funcall function group headers (symbol-value variable)))
2718 ((eq filename 'default)
2724 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2727 (if (and gnus-number-of-articles-to-be-saved
2728 (> gnus-number-of-articles-to-be-saved 1))
2729 (format "these %d articles"
2730 gnus-number-of-articles-to-be-saved)
2733 ;; Let the split methods have their say.
2735 ;; No split name was found.
2738 (concat prompt " (default "
2739 (file-name-nondirectory default-name) ") ")
2740 (file-name-directory default-name)
2742 ;; A single group name is returned.
2743 ((stringp split-name)
2745 (funcall function split-name headers
2746 (symbol-value variable)))
2748 (concat prompt " (default "
2749 (file-name-nondirectory default-name) ") ")
2750 (file-name-directory default-name)
2752 ;; A single split name was found
2753 ((= 1 (length split-name))
2754 (let* ((name (expand-file-name
2756 gnus-article-save-directory))
2757 (dir (cond ((file-directory-p name)
2758 (file-name-as-directory name))
2759 ((file-exists-p name) name)
2760 (t gnus-article-save-directory))))
2762 (concat prompt " (default " name ") ")
2764 ;; A list of splits was found.
2766 (setq split-name (nreverse split-name))
2768 (let ((file-name-history
2769 (nconc split-name file-name-history)))
2773 (concat prompt " (`M-p' for defaults) ")
2774 gnus-article-save-directory
2776 gnus-article-save-directory)))
2777 (car (push result file-name-history)))))))
2778 ;; Create the directory.
2779 (gnus-make-directory (file-name-directory file))
2780 ;; If we have read a directory, we append the default file name.
2781 (when (file-directory-p file)
2782 (setq file (expand-file-name (file-name-nondirectory
2784 (file-name-as-directory file))))
2785 ;; Possibly translate some characters.
2786 (nnheader-translate-file-chars file))))))
2787 (gnus-make-directory (file-name-directory result))
2788 (set variable result)))
2790 (defun gnus-article-archive-name (group)
2791 "Return the first instance of an \"Archive-name\" in the current buffer."
2792 (let ((case-fold-search t))
2793 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2794 (nnheader-concat gnus-article-save-directory
2795 (match-string 1)))))
2797 (defun gnus-article-nndoc-name (group)
2798 "If GROUP is an nndoc group, return the name of the parent group."
2799 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2800 (gnus-group-get-parameter group 'save-article-group)))
2802 (defun gnus-summary-save-in-rmail (&optional filename)
2803 "Append this article to Rmail file.
2804 Optional argument FILENAME specifies file name.
2805 Directory to save to is default to `gnus-article-save-directory'."
2806 (setq filename (gnus-read-save-file-name
2807 "Save %s in rmail file:" filename
2808 gnus-rmail-save-name gnus-newsgroup-name
2809 gnus-current-headers 'gnus-newsgroup-last-rmail))
2810 (gnus-eval-in-buffer-window gnus-save-article-buffer
2814 (gnus-output-to-rmail filename))))
2817 (defun gnus-summary-save-in-mail (&optional filename)
2818 "Append this article to Unix mail file.
2819 Optional argument FILENAME specifies file name.
2820 Directory to save to is default to `gnus-article-save-directory'."
2821 (setq filename (gnus-read-save-file-name
2822 "Save %s in Unix mail file:" filename
2823 gnus-mail-save-name gnus-newsgroup-name
2824 gnus-current-headers 'gnus-newsgroup-last-mail))
2825 (gnus-eval-in-buffer-window gnus-save-article-buffer
2829 (if (and (file-readable-p filename)
2830 (mail-file-babyl-p filename))
2831 (rmail-output-to-rmail-file filename t)
2832 (gnus-output-to-mail filename)))))
2835 (defun gnus-summary-save-in-file (&optional filename overwrite)
2836 "Append this article to file.
2837 Optional argument FILENAME specifies file name.
2838 Directory to save to is default to `gnus-article-save-directory'."
2839 (setq filename (gnus-read-save-file-name
2840 "Save %s in file:" filename
2841 gnus-file-save-name gnus-newsgroup-name
2842 gnus-current-headers 'gnus-newsgroup-last-file))
2843 (gnus-eval-in-buffer-window gnus-save-article-buffer
2847 (when (and overwrite
2848 (file-exists-p filename))
2849 (delete-file filename))
2850 (gnus-output-to-file filename))))
2853 (defun gnus-summary-write-to-file (&optional filename)
2854 "Write this article to a file, overwriting it if the file exists.
2855 Optional argument FILENAME specifies file name.
2856 The directory to save in defaults to `gnus-article-save-directory'."
2857 (gnus-summary-save-in-file nil t))
2859 (defun gnus-summary-save-body-in-file (&optional filename)
2860 "Append this article body to a file.
2861 Optional argument FILENAME specifies file name.
2862 The directory to save in defaults to `gnus-article-save-directory'."
2863 (setq filename (gnus-read-save-file-name
2864 "Save %s body in file:" filename
2865 gnus-file-save-name gnus-newsgroup-name
2866 gnus-current-headers 'gnus-newsgroup-last-file))
2867 (gnus-eval-in-buffer-window gnus-save-article-buffer
2871 (when (article-goto-body)
2872 (narrow-to-region (point) (point-max)))
2873 (gnus-output-to-file filename))))
2876 (defun gnus-summary-save-in-pipe (&optional command)
2877 "Pipe this article to subprocess."
2879 (cond ((and (eq command 'default)
2880 gnus-last-shell-command)
2881 gnus-last-shell-command)
2886 "Shell command on %s: "
2887 (if (and gnus-number-of-articles-to-be-saved
2888 (> gnus-number-of-articles-to-be-saved 1))
2889 (format "these %d articles"
2890 gnus-number-of-articles-to-be-saved)
2892 gnus-last-shell-command))))
2893 (when (string-equal command "")
2894 (if gnus-last-shell-command
2895 (setq command gnus-last-shell-command)
2896 (error "A command is required")))
2897 (gnus-eval-in-buffer-window gnus-article-buffer
2900 (shell-command-on-region (point-min) (point-max) command nil)))
2901 (setq gnus-last-shell-command command))
2903 (defun gnus-summary-pipe-to-muttprint (&optional command)
2904 "Pipe this article to muttprint."
2905 (setq command (read-string
2906 "Print using command: " gnus-summary-muttprint-program
2907 nil gnus-summary-muttprint-program))
2908 (gnus-summary-save-in-pipe command))
2910 ;;; Article file names when saving.
2912 (defun gnus-capitalize-newsgroup (newsgroup)
2913 "Capitalize NEWSGROUP name."
2914 (when (not (zerop (length newsgroup)))
2915 (concat (char-to-string (upcase (aref newsgroup 0)))
2916 (substring newsgroup 1))))
2918 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2919 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2920 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2921 Otherwise, it is like ~/News/news/group/num."
2924 (concat (if (gnus-use-long-file-name 'not-save)
2925 (gnus-capitalize-newsgroup newsgroup)
2926 (gnus-newsgroup-directory-form newsgroup))
2927 "/" (int-to-string (mail-header-number headers)))
2928 gnus-article-save-directory)))
2930 (string-equal (file-name-directory default)
2931 (file-name-directory last-file))
2932 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2934 (or last-file default))))
2936 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2937 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2938 If variable `gnus-use-long-file-name' is non-nil, it is
2939 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2942 (concat (if (gnus-use-long-file-name 'not-save)
2944 (gnus-newsgroup-directory-form newsgroup))
2945 "/" (int-to-string (mail-header-number headers)))
2946 gnus-article-save-directory)))
2948 (string-equal (file-name-directory default)
2949 (file-name-directory last-file))
2950 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2952 (or last-file default))))
2954 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2955 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2956 If variable `gnus-use-long-file-name' is non-nil, it is
2957 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2960 (if (gnus-use-long-file-name 'not-save)
2963 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2965 gnus-article-save-directory)))
2967 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2968 "Generate file name from sender."
2969 (let ((from (mail-header-from headers)))
2971 (if (and from (string-match "\\([^ <]+\\)@" from))
2972 (match-string 1 from)
2974 gnus-article-save-directory)))
2976 (defun article-verify-x-pgp-sig ()
2979 (if (gnus-buffer-live-p gnus-original-article-buffer)
2980 (let ((sig (with-current-buffer gnus-original-article-buffer
2981 (gnus-fetch-field "X-PGP-Sig")))
2985 (mml2015-clear-verify-function))
2987 (insert-buffer gnus-original-article-buffer)
2988 (setq items (split-string sig))
2989 (message-narrow-to-head)
2990 (let ((inhibit-point-motion-hooks t)
2991 (case-fold-search t))
2992 ;; Don't verify multiple headers.
2993 (setq headers (mapconcat (lambda (header)
2995 (mail-fetch-field header) "\n"))
2996 (split-string (nth 1 items) ",") "")))
2997 (delete-region (point-min) (point-max))
2998 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2999 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3004 (if (looking-at "^-")
3007 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3008 (insert "Version: " (car items) "\n\n")
3009 (insert (mapconcat 'identity (cddr items) "\n"))
3010 (insert "\n-----END PGP SIGNATURE-----\n")
3011 (let ((mm-security-handle (list (format "multipart/signed"))))
3012 (mml2015-clean-buffer)
3013 (let ((coding-system-for-write (or gnus-newsgroup-charset
3015 (funcall (mml2015-clear-verify-function)))
3017 (or (mm-handle-multipart-ctl-parameter
3018 mm-security-handle 'gnus-details)
3019 (mm-handle-multipart-ctl-parameter
3020 mm-security-handle 'gnus-info)))))
3022 (let (buffer-read-only bface eface)
3024 (message-narrow-to-head)
3025 (goto-char (point-max))
3027 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3028 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3029 (message-remove-header "X-Gnus-PGP-Verify")
3030 (if (re-search-forward "^X-PGP-Sig:" nil t)
3032 (goto-char (point-max)))
3033 (narrow-to-region (point) (point))
3034 (insert "X-Gnus-PGP-Verify: " info "\n")
3035 (goto-char (point-min))
3038 (if (not (looking-at "^[ \t]"))
3042 (goto-char (point-min))
3043 (when (looking-at "\\([^:]+\\): *")
3044 (put-text-property (match-beginning 1) (1+ (match-end 1))
3046 (put-text-property (match-end 0) (point-max)
3047 'face eface)))))))))
3049 (defun article-verify-cancel-lock ()
3050 "Verify Cancel-Lock header."
3052 (if (gnus-buffer-live-p gnus-original-article-buffer)
3053 (canlock-verify gnus-original-article-buffer)))
3060 (setq afunc (car func)
3063 gfunc (intern (format "gnus-%s" func))))
3065 (when (fboundp afunc)
3066 `(lambda (&optional interactive &rest args)
3067 ,(documentation afunc t)
3068 (interactive (list t))
3070 (set-buffer gnus-article-buffer)
3072 (call-interactively ',afunc)
3073 (apply ',afunc args))))))))
3074 '(article-hide-headers
3075 article-verify-x-pgp-sig
3076 article-verify-cancel-lock
3077 article-hide-boring-headers
3078 article-treat-overstrike
3079 article-fill-long-lines
3080 article-capitalize-sentences
3082 article-remove-leading-whitespace
3083 article-display-x-face
3084 article-de-quoted-unreadable
3085 article-de-base64-unreadable
3088 article-hide-list-identifiers
3090 article-strip-banner
3093 article-hide-signature
3094 article-strip-headers-in-body
3095 article-remove-trailing-blank-lines
3096 article-strip-leading-blank-lines
3097 article-strip-multiple-blank-lines
3098 article-strip-leading-space
3099 article-strip-trailing-space
3100 article-strip-blank-lines
3101 article-strip-all-blank-lines
3102 article-replace-with-quoted-text
3104 article-date-english
3105 article-date-iso8601
3106 article-date-original
3108 article-decode-mime-words
3109 article-decode-charset
3110 article-decode-encoded-words
3114 article-treat-dumbquotes
3115 article-normalize-headers
3116 (article-show-all . gnus-article-show-all-headers))))
3119 ;;; Gnus article mode
3122 (put 'gnus-article-mode 'mode-class 'special)
3124 (set-keymap-parent gnus-article-mode-map widget-keymap)
3126 (gnus-define-keys gnus-article-mode-map
3127 " " gnus-article-goto-next-page
3128 "\177" gnus-article-goto-prev-page
3129 [delete] gnus-article-goto-prev-page
3130 [backspace] gnus-article-goto-prev-page
3131 "\C-c^" gnus-article-refer-article
3132 "h" gnus-article-show-summary
3133 "s" gnus-article-show-summary
3134 "\C-c\C-m" gnus-article-mail
3135 "?" gnus-article-describe-briefly
3136 "e" gnus-summary-edit-article
3137 "<" beginning-of-buffer
3139 "\C-c\C-i" gnus-info-find-node
3141 "\C-hk" gnus-article-describe-key
3142 "\C-hc" gnus-article-describe-key-briefly
3144 "\C-d" gnus-article-read-summary-keys
3145 "\M-*" gnus-article-read-summary-keys
3146 "\M-#" gnus-article-read-summary-keys
3147 "\M-^" gnus-article-read-summary-keys
3148 "\M-g" gnus-article-read-summary-keys)
3150 (substitute-key-definition
3151 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3153 (defun gnus-article-make-menu-bar ()
3154 (unless (boundp 'gnus-article-commands-menu)
3155 (gnus-summary-make-menu-bar))
3156 (gnus-turn-off-edit-menu 'article)
3157 (unless (boundp 'gnus-article-article-menu)
3159 gnus-article-article-menu gnus-article-mode-map ""
3161 ["Scroll forwards" gnus-article-goto-next-page t]
3162 ["Scroll backwards" gnus-article-goto-prev-page t]
3163 ["Show summary" gnus-article-show-summary t]
3164 ["Fetch Message-ID at point" gnus-article-refer-article t]
3165 ["Mail to address at point" gnus-article-mail t]
3166 ["Send a bug report" gnus-bug t]))
3169 gnus-article-treatment-menu gnus-article-mode-map ""
3170 ;; Fixme: this should use :active (and maybe :visible).
3172 ["Hide headers" gnus-article-hide-headers t]
3173 ["Hide signature" gnus-article-hide-signature t]
3174 ["Hide citation" gnus-article-hide-citation t]
3175 ["Treat overstrike" gnus-article-treat-overstrike t]
3176 ["Remove carriage return" gnus-article-remove-cr t]
3177 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3178 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3179 ["Remove base64" gnus-article-de-base64-unreadable t]
3180 ["Treat html" gnus-article-wash-html t]
3181 ["Decode HZ" gnus-article-decode-HZ t]))
3183 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3185 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3187 (gnus-run-hooks 'gnus-article-menu-hook)))
3189 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3192 (defun gnus-article-mode ()
3193 "Major mode for displaying an article.
3195 All normal editing commands are switched off.
3197 The following commands are available in addition to all summary mode
3199 \\<gnus-article-mode-map>
3200 \\[gnus-article-next-page]\t Scroll the article one page forwards
3201 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3202 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3203 \\[gnus-article-show-summary]\t Display the summary buffer
3204 \\[gnus-article-mail]\t Send a reply to the address near point
3205 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3206 \\[gnus-info-find-node]\t Go to the Gnus info node"
3208 (gnus-simplify-mode-line)
3209 (setq mode-name "Article")
3210 (setq major-mode 'gnus-article-mode)
3211 (make-local-variable 'minor-mode-alist)
3212 (use-local-map gnus-article-mode-map)
3213 (when (gnus-visual-p 'article-menu 'menu)
3214 (gnus-article-make-menu-bar))
3215 (gnus-update-format-specifications nil 'article-mode)
3216 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3217 (make-local-variable 'gnus-page-broken)
3218 (make-local-variable 'gnus-button-marker-list)
3219 (make-local-variable 'gnus-article-current-summary)
3220 (make-local-variable 'gnus-article-mime-handles)
3221 (make-local-variable 'gnus-article-decoded-p)
3222 (make-local-variable 'gnus-article-mime-handle-alist)
3223 (make-local-variable 'gnus-article-wash-types)
3224 (make-local-variable 'gnus-article-image-alist)
3225 (make-local-variable 'gnus-article-charset)
3226 (make-local-variable 'gnus-article-ignored-charsets)
3227 (gnus-set-default-directory)
3228 (buffer-disable-undo)
3229 (setq buffer-read-only t)
3230 (set-syntax-table gnus-article-mode-syntax-table)
3231 (mm-enable-multibyte)
3232 (gnus-run-hooks 'gnus-article-mode-hook))
3234 (defun gnus-article-setup-buffer ()
3235 "Initialize the article buffer."
3236 (let* ((name (if gnus-single-article-buffer "*Article*"
3237 (concat "*Article " gnus-newsgroup-name "*")))
3239 (progn (string-match "\\*Article" name)
3240 (concat " *Original Article"
3241 (substring name (match-end 0))))))
3242 (setq gnus-article-buffer name)
3243 (setq gnus-original-article-buffer original)
3244 (setq gnus-article-mime-handle-alist nil)
3245 ;; This might be a variable local to the summary buffer.
3246 (unless gnus-single-article-buffer
3248 (set-buffer gnus-summary-buffer)
3249 (setq gnus-article-buffer name)
3250 (setq gnus-original-article-buffer original)
3251 (gnus-set-global-variables)))
3252 (gnus-article-setup-highlight-words)
3253 ;; Init original article buffer.
3255 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3256 (mm-enable-multibyte)
3257 (setq major-mode 'gnus-original-article-mode)
3258 (make-local-variable 'gnus-original-article))
3259 (if (get-buffer name)
3262 (when gnus-article-mime-handles
3263 (mm-destroy-parts gnus-article-mime-handles)
3264 (setq gnus-article-mime-handles nil))
3265 ;; Set it to nil in article-buffer!
3266 (setq gnus-article-mime-handle-alist nil)
3267 (buffer-disable-undo)
3268 (setq buffer-read-only t)
3269 (unless (eq major-mode 'gnus-article-mode)
3270 (gnus-article-mode))
3273 (set-buffer (gnus-get-buffer-create name))
3275 (make-local-variable 'gnus-summary-buffer)
3276 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3277 (current-buffer)))))
3279 ;; Set article window start at LINE, where LINE is the number of lines
3280 ;; from the head of the article.
3281 (defun gnus-article-set-window-start (&optional line)
3283 (gnus-get-buffer-window gnus-article-buffer t)
3285 (set-buffer gnus-article-buffer)
3286 (goto-char (point-min))
3289 (gnus-message 6 "Moved to bookmark")
3290 (search-forward "\n\n" nil t)
3294 (defun gnus-article-prepare (article &optional all-headers header)
3295 "Prepare ARTICLE in article mode buffer.
3296 ARTICLE should either be an article number or a Message-ID.
3297 If ARTICLE is an id, HEADER should be the article headers.
3298 If ALL-HEADERS is non-nil, no headers are hidden."
3300 ;; Make sure we start in a summary buffer.
3301 (unless (eq major-mode 'gnus-summary-mode)
3302 (set-buffer gnus-summary-buffer))
3303 (setq gnus-summary-buffer (current-buffer))
3304 (let* ((gnus-article (if header (mail-header-number header) article))
3305 (summary-buffer (current-buffer))
3306 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3307 (group gnus-newsgroup-name)
3310 (gnus-article-setup-buffer)
3311 (set-buffer gnus-article-buffer)
3312 ;; Deactivate active regions.
3313 (when (and (boundp 'transient-mark-mode)
3314 transient-mark-mode)
3315 (setq mark-active nil))
3316 (if (not (setq result (let ((buffer-read-only nil))
3317 (gnus-request-article-this-buffer
3319 ;; There is no such article.
3321 (when (and (numberp article)
3322 (not (memq article gnus-newsgroup-sparse)))
3323 (setq gnus-article-current
3324 (cons gnus-newsgroup-name article))
3325 (set-buffer gnus-summary-buffer)
3326 (setq gnus-current-article article)
3327 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3329 (gnus-summary-set-agent-mark article)
3330 (message "Message marked for downloading"))
3331 (gnus-summary-mark-article article gnus-canceled-mark)
3332 (unless (memq article gnus-newsgroup-sparse)
3333 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3334 (if (or (eq result 'pseudo)
3335 (eq result 'nneething))
3338 (set-buffer summary-buffer)
3339 (push article gnus-newsgroup-history)
3340 (setq gnus-last-article gnus-current-article
3341 gnus-current-article 0
3342 gnus-current-headers nil
3343 gnus-article-current nil)
3344 (if (eq result 'nneething)
3345 (gnus-configure-windows 'summary)
3346 (gnus-configure-windows 'article))
3347 (gnus-set-global-variables))
3348 (let ((gnus-article-mime-handle-alist-1
3349 gnus-article-mime-handle-alist))
3350 (gnus-set-mode-line 'article)))
3351 ;; The result from the `request' was an actual article -
3352 ;; or at least some text that is now displayed in the
3354 (when (and (numberp article)
3355 (not (eq article gnus-current-article)))
3356 ;; Seems like a new article has been selected.
3357 ;; `gnus-current-article' must be an article number.
3359 (set-buffer summary-buffer)
3360 (push article gnus-newsgroup-history)
3361 (setq gnus-last-article gnus-current-article
3362 gnus-current-article article
3363 gnus-current-headers
3364 (gnus-summary-article-header gnus-current-article)
3365 gnus-article-current
3366 (cons gnus-newsgroup-name gnus-current-article))
3367 (unless (vectorp gnus-current-headers)
3368 (setq gnus-current-headers nil))
3369 (gnus-summary-goto-subject gnus-current-article)
3370 (when (gnus-summary-show-thread)
3371 ;; If the summary buffer really was folded, the
3372 ;; previous goto may not actually have gone to
3373 ;; the right article, but the thread root instead.
3375 (gnus-summary-goto-subject gnus-current-article))
3376 (gnus-run-hooks 'gnus-mark-article-hook)
3377 (gnus-set-mode-line 'summary)
3378 (when (gnus-visual-p 'article-highlight 'highlight)
3379 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3380 ;; Set the global newsgroup variables here.
3381 (gnus-set-global-variables)
3382 (setq gnus-have-all-headers
3383 (or all-headers gnus-show-all-headers))))
3385 (gnus-configure-windows 'article))
3386 (when (or (numberp article)
3388 (gnus-article-prepare-display)
3390 (goto-char (point-min))
3391 (setq gnus-page-broken
3392 (when gnus-break-pages
3393 (gnus-narrow-to-page)
3395 (let ((gnus-article-mime-handle-alist-1
3396 gnus-article-mime-handle-alist))
3397 (gnus-set-mode-line 'article))
3399 (set-window-point (get-buffer-window (current-buffer)) (point))
3400 (gnus-configure-windows 'article)
3404 (defun gnus-article-prepare-display ()
3405 "Make the current buffer look like a nice article."
3406 ;; Hooks for getting information from the article.
3407 ;; This hook must be called before being narrowed.
3408 (let ((gnus-article-buffer (current-buffer))
3410 (unless (eq major-mode 'gnus-article-mode)
3411 (gnus-article-mode))
3412 (setq buffer-read-only nil
3413 gnus-article-wash-types nil
3414 gnus-article-image-alist nil)
3415 (gnus-run-hooks 'gnus-tmp-internal-hook)
3416 (when gnus-display-mime-function
3417 (funcall gnus-display-mime-function))
3418 (gnus-run-hooks 'gnus-article-prepare-hook)))
3421 ;;; Gnus MIME viewing functions
3424 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3425 "The following specs can be used:
3427 %T MIME type, along with additional info
3428 %n The `name' parameter
3429 %d The description, if any
3430 %l The length of the encoded part
3431 %p The part identifier number
3432 %e Dots if the part isn't displayed")
3434 (defvar gnus-mime-button-line-format-alist
3435 '((?t gnus-tmp-type ?s)
3436 (?T gnus-tmp-type-long ?s)
3437 (?n gnus-tmp-name ?s)
3438 (?d gnus-tmp-description ?s)
3440 (?l gnus-tmp-length ?d)
3441 (?e gnus-tmp-dots ?s)))
3443 (defvar gnus-mime-button-commands
3444 '((gnus-article-press-button "\r" "Toggle Display")
3445 (gnus-mime-view-part "v" "View Interactively...")
3446 (gnus-mime-view-part-as-type "t" "View As Type...")
3447 (gnus-mime-view-part-as-charset "C" "View As charset...")
3448 (gnus-mime-save-part "o" "Save...")
3449 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3450 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3451 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3452 (gnus-mime-internalize-part "E" "View Internally")
3453 (gnus-mime-externalize-part "e" "View Externally")
3454 (gnus-mime-print-part "p" "Print")
3455 (gnus-mime-pipe-part "|" "Pipe To Command...")
3456 (gnus-mime-action-on-part "." "Take action on the part")))
3458 (defun gnus-article-mime-part-status ()
3459 (if gnus-article-mime-handle-alist-1
3460 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3462 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3465 (defvar gnus-mime-button-map
3466 (let ((map (make-sparse-keymap)))
3467 (unless (>= (string-to-number emacs-version) 21)
3468 ;; XEmacs doesn't care.
3469 (set-keymap-parent map gnus-article-mode-map))
3470 (define-key map gnus-mouse-2 'gnus-article-push-button)
3471 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3472 (dolist (c gnus-mime-button-commands)
3473 (define-key map (cadr c) (car c)))
3476 (defun gnus-mime-button-menu (event)
3477 "Construct a context-sensitive menu of MIME commands."
3479 (save-window-excursion
3480 (let ((pos (event-start event)))
3481 (select-window (posn-window pos))
3482 (goto-char (posn-point pos))
3483 (gnus-article-check-buffer)
3484 (let ((response (x-popup-menu
3486 ("" ,@(mapcar (lambda (c)
3487 (cons (caddr c) (car c)))
3488 gnus-mime-button-commands))))))
3490 (call-interactively response))))))
3492 (defun gnus-mime-view-all-parts (&optional handles)
3493 "View all the MIME parts."
3495 (save-current-buffer
3496 (set-buffer gnus-article-buffer)
3497 (let ((handles (or handles gnus-article-mime-handles))
3498 (mail-parse-charset gnus-newsgroup-charset)
3499 (mail-parse-ignored-charsets
3500 (with-current-buffer gnus-summary-buffer
3501 gnus-newsgroup-ignored-charsets)))
3503 (mm-remove-parts handles)
3504 (goto-char (point-min))
3505 (or (search-forward "\n\n") (goto-char (point-max)))
3506 (let (buffer-read-only)
3507 (delete-region (point) (point-max))
3508 (mm-display-parts handles))))))
3510 (defun gnus-mime-save-part-and-strip ()
3511 "Save the MIME part under point then replace it with an external body."
3513 (gnus-article-check-buffer)
3514 (let* ((data (get-text-property (point) 'gnus-data))
3516 (handles gnus-article-mime-handles))
3517 (if (mm-multiple-handles gnus-article-mime-handles)
3518 (error "This function is not implemented"))
3519 (setq file (and data (mm-save-part data)))
3521 (with-current-buffer (mm-handle-buffer data)
3523 (insert "Content-Type: " (mm-handle-media-type data))
3524 (mml-insert-parameter-string (cdr (mm-handle-type data))
3527 (insert "Content-ID: " (message-make-message-id) "\n")
3528 (insert "Content-Transfer-Encoding: binary\n")
3531 (cdr (mm-make-handle nil
3532 `("message/external-body"
3533 (access-type . "LOCAL-FILE")
3535 (set-buffer gnus-summary-buffer)
3536 (gnus-article-edit-article
3539 (let ((mail-parse-charset (or gnus-article-charset
3540 ',gnus-newsgroup-charset))
3541 (mail-parse-ignored-charsets
3542 (or gnus-article-ignored-charsets
3543 ',gnus-newsgroup-ignored-charsets))
3544 (mbl mml-buffer-list))
3545 (setq mml-buffer-list nil)
3546 (insert-buffer gnus-original-article-buffer)
3547 (mime-to-mml ',handles)
3548 (setq gnus-article-mime-handles nil)
3549 (let ((mbl1 mml-buffer-list))
3550 (setq mml-buffer-list mbl)
3551 (set (make-local-variable 'mml-buffer-list) mbl1))
3552 ;; LOCAL argument of add-hook differs between GNU Emacs
3553 ;; and XEmacs. make-local-hook makes sure they are local.
3554 (make-local-hook 'kill-buffer-hook)
3555 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3556 `(lambda (no-highlight)
3557 (let ((mail-parse-charset (or gnus-article-charset
3558 ',gnus-newsgroup-charset))
3559 (message-options message-options)
3560 (message-options-set-recipient)
3561 (mail-parse-ignored-charsets
3562 (or gnus-article-ignored-charsets
3563 ',gnus-newsgroup-ignored-charsets)))
3565 (mml-destroy-buffers)
3566 (remove-hook 'kill-buffer-hook
3567 'mml-destroy-buffers t)
3568 (kill-local-variable 'mml-buffer-list))
3569 (gnus-summary-edit-article-done
3570 ,(or (mail-header-references gnus-current-headers) "")
3571 ,(gnus-group-read-only-p)
3572 ,gnus-summary-buffer no-highlight))))))
3574 (defun gnus-mime-save-part ()
3575 "Save the MIME part under point."
3577 (gnus-article-check-buffer)
3578 (let ((data (get-text-property (point) 'gnus-data)))
3580 (mm-save-part data))))
3582 (defun gnus-mime-pipe-part ()
3583 "Pipe the MIME part under point to a process."
3585 (gnus-article-check-buffer)
3586 (let ((data (get-text-property (point) 'gnus-data)))
3588 (mm-pipe-part data))))
3590 (defun gnus-mime-view-part ()
3591 "Interactively choose a viewing method for the MIME part under point."
3593 (gnus-article-check-buffer)
3594 (let ((data (get-text-property (point) 'gnus-data)))
3596 (setq gnus-article-mime-handles
3598 gnus-article-mime-handles (setq data (copy-sequence data))))
3599 (mm-interactively-view-part data))))
3601 (defun gnus-mime-view-part-as-type-internal ()
3602 (gnus-article-check-buffer)
3603 (let* ((name (mail-content-type-get
3604 (mm-handle-type (get-text-property (point) 'gnus-data))
3606 (def-type (and name (mm-default-file-encoding name))))
3607 (and def-type (cons def-type 0))))
3609 (defun gnus-mime-view-part-as-type (&optional mime-type)
3610 "Choose a MIME media type, and view the part as such."
3613 (setq mime-type (completing-read
3614 "View as MIME type: "
3615 (mapcar #'list (mailcap-mime-types))
3617 (gnus-mime-view-part-as-type-internal))))
3618 (gnus-article-check-buffer)
3619 (let ((handle (get-text-property (point) 'gnus-data)))
3622 (mm-make-handle (mm-handle-buffer handle)
3623 (cons mime-type (cdr (mm-handle-type handle)))
3624 (mm-handle-encoding handle)
3625 (mm-handle-undisplayer handle)
3626 (mm-handle-disposition handle)
3627 (mm-handle-description handle)
3629 (mm-handle-id handle)))
3630 (setq gnus-article-mime-handles
3631 (mm-merge-handles gnus-article-mime-handles handle))
3632 (gnus-mm-display-part handle))))
3634 (defun gnus-mime-copy-part (&optional handle)
3635 "Put the MIME part under point into a new buffer."
3637 (gnus-article-check-buffer)
3638 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3639 (contents (and handle (mm-get-part handle)))
3641 (file-name-nondirectory
3643 (mail-content-type-get (mm-handle-type handle) 'name)
3644 (mail-content-type-get (mm-handle-type handle)
3647 (buffer (and base (generate-new-buffer base))))
3649 (switch-to-buffer buffer)
3651 ;; We do it this way to make `normal-mode' set the appropriate mode.
3654 (setq buffer-file-name (expand-file-name base))
3656 (setq buffer-file-name nil))
3657 (goto-char (point-min)))))
3659 (defun gnus-mime-print-part (&optional handle)
3660 "Print the MIME part under point."
3662 (gnus-article-check-buffer)
3663 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3664 (contents (and handle (mm-get-part handle)))
3665 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3666 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3671 (with-temp-file file
3673 (call-process shell-file-name nil
3674 (generate-new-buffer " *mm*")
3676 shell-command-switch
3678 printer file (mm-handle-type handle))))
3682 (gnus-print-buffer))))))
3684 (defun gnus-mime-inline-part (&optional handle arg)
3685 "Insert the MIME part under point into the current buffer."
3686 (interactive (list nil current-prefix-arg))
3687 (gnus-article-check-buffer)
3688 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3693 (if (and (not arg) (mm-handle-undisplayer handle))
3694 (mm-remove-part handle)
3695 (setq contents (mm-get-part handle))
3698 (setq charset (or (mail-content-type-get
3699 (mm-handle-type handle) 'charset)
3700 gnus-newsgroup-charset)))
3702 (if (mm-handle-undisplayer handle)
3703 (mm-remove-part handle))
3706 gnus-summary-show-article-charset-alist))
3707 (mm-read-coding-system "Charset: ")))))
3709 (mm-insert-inline handle
3711 (setq charset (mm-charset-to-coding-system
3713 (not (eq charset 'ascii)))
3714 (mm-decode-coding-string contents charset)
3718 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3719 "Insert the MIME part under point into the current buffer using the
3721 (interactive (list nil current-prefix-arg))
3722 (gnus-article-check-buffer)
3723 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3728 (if (mm-handle-undisplayer handle)
3729 (mm-remove-part handle))
3730 (let ((gnus-newsgroup-charset
3732 gnus-summary-show-article-charset-alist))
3733 (mm-read-coding-system "Charset: ")))
3734 (gnus-newsgroup-ignored-charsets 'gnus-all))
3735 (gnus-article-press-button)))))
3737 (defun gnus-mime-externalize-part (&optional handle)
3738 "View the MIME part under point with an external viewer."
3740 (gnus-article-check-buffer)
3741 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3742 (mm-user-display-methods nil)
3743 (mm-inlined-types nil)
3744 (mail-parse-charset gnus-newsgroup-charset)
3745 (mail-parse-ignored-charsets
3746 (save-excursion (set-buffer gnus-summary-buffer)
3747 gnus-newsgroup-ignored-charsets)))
3749 (if (mm-handle-undisplayer handle)
3750 (mm-remove-part handle)
3751 (mm-display-part handle)))))
3753 (defun gnus-mime-internalize-part (&optional handle)
3754 "View the MIME part under point with an internal viewer.
3755 If no internal viewer is available, use an external viewer."
3757 (gnus-article-check-buffer)
3758 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3759 (mm-inlined-types '(".*"))
3760 (mm-inline-large-images t)
3761 (mail-parse-charset gnus-newsgroup-charset)
3762 (mail-parse-ignored-charsets
3763 (save-excursion (set-buffer gnus-summary-buffer)
3764 gnus-newsgroup-ignored-charsets)))
3766 (if (mm-handle-undisplayer handle)
3767 (mm-remove-part handle)
3768 (mm-display-part handle)))))
3770 (defun gnus-mime-action-on-part (&optional action)
3771 "Do something with the MIME attachment at \(point\)."
3773 (list (completing-read "Action: " gnus-mime-action-alist)))
3774 (gnus-article-check-buffer)
3775 (let ((action-pair (assoc action gnus-mime-action-alist)))
3777 (funcall (cdr action-pair)))))
3779 (defun gnus-article-part-wrapper (n function)
3780 (save-current-buffer
3781 (set-buffer gnus-article-buffer)
3782 (when (> n (length gnus-article-mime-handle-alist))
3783 (error "No such part"))
3784 (gnus-article-goto-part n)
3785 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3786 (funcall function handle))))
3788 (defun gnus-article-pipe-part (n)
3789 "Pipe MIME part N, which is the numerical prefix."
3791 (gnus-article-part-wrapper n 'mm-pipe-part))
3793 (defun gnus-article-save-part (n)
3794 "Save MIME part N, which is the numerical prefix."
3796 (gnus-article-part-wrapper n 'mm-save-part))
3798 (defun gnus-article-interactively-view-part (n)
3799 "View MIME part N interactively, which is the numerical prefix."
3801 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3803 (defun gnus-article-copy-part (n)
3804 "Copy MIME part N, which is the numerical prefix."
3806 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3808 (defun gnus-article-view-part-as-charset (n)
3809 "Copy MIME part N, which is the numerical prefix."
3811 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3813 (defun gnus-article-externalize-part (n)
3814 "View MIME part N externally, which is the numerical prefix."
3816 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3818 (defun gnus-article-inline-part (n)
3819 "Inline MIME part N, which is the numerical prefix."
3821 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3823 (defun gnus-article-mime-match-handle-first (condition)
3825 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3826 (while (setq ihandle (pop alist))
3828 ((functionp condition)
3829 (funcall condition (cdr ihandle)))
3830 ((eq condition 'undisplayed)
3831 (not (or (mm-handle-undisplayer (cdr ihandle))
3832 (equal (mm-handle-media-type (cdr ihandle))
3833 "multipart/alternative"))))
3834 ((eq condition 'undisplayed-alternative)
3835 (not (mm-handle-undisplayer (cdr ihandle))))
3837 (gnus-article-goto-part (car ihandle))
3838 (or (not n) (< (car ihandle) n)))
3839 (setq n (car ihandle))))
3843 (defun gnus-article-view-part (&optional n)
3844 "View MIME part N, which is the numerical prefix."
3846 (save-current-buffer
3847 (set-buffer gnus-article-buffer)
3848 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3849 gnus-article-mime-match-handle-function)))
3850 (when (> n (length gnus-article-mime-handle-alist))
3851 (error "No such part"))
3852 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3853 (when (gnus-article-goto-part n)
3854 (if (equal (car handle) "multipart/alternative")
3855 (gnus-article-press-button)
3856 (when (eq (gnus-mm-display-part handle) 'internal)
3857 (gnus-set-window-start)))))))
3859 (defsubst gnus-article-mime-total-parts ()
3860 (if (bufferp (car gnus-article-mime-handles))
3862 (1- (length gnus-article-mime-handles))))
3864 (defun gnus-mm-display-part (handle)
3865 "Display HANDLE and fix MIME button."
3866 (let ((id (get-text-property (point) 'gnus-part))
3871 (let ((window (selected-window))
3872 (mail-parse-charset gnus-newsgroup-charset)
3873 (mail-parse-ignored-charsets
3874 (save-excursion (set-buffer gnus-summary-buffer)
3875 gnus-newsgroup-ignored-charsets)))
3878 (let ((win (gnus-get-buffer-window (current-buffer) t))
3881 (select-window win))
3884 (if (mm-handle-displayed-p handle)
3885 ;; This will remove the part.
3886 (mm-display-part handle)
3888 (narrow-to-region (point)
3889 (if (eobp) (point) (1+ (point))))
3890 (mm-display-part handle)
3891 ;; We narrow to the part itself and
3892 ;; then call the treatment functions.
3893 (goto-char (point-min))
3895 (narrow-to-region (point) (point-max))
3898 (gnus-article-mime-total-parts)
3899 (mm-handle-media-type handle)))))
3900 (if (window-live-p window)
3901 (select-window window)))))
3903 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3904 (gnus-insert-mime-button
3905 handle id (list (mm-handle-displayed-p handle)))
3906 (goto-char point))))
3908 (defun gnus-article-goto-part (n)
3909 "Go to MIME part N."
3910 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3912 (goto-char point))))
3914 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3915 (let ((gnus-tmp-name
3916 (or (mail-content-type-get (mm-handle-type handle) 'name)
3917 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3918 (mail-content-type-get (mm-handle-type handle) 'url)
3920 (gnus-tmp-type (mm-handle-media-type handle))
3921 (gnus-tmp-description
3922 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3925 (if (if displayed (car displayed)
3926 (mm-handle-displayed-p handle))
3928 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3930 gnus-tmp-type-long b e)
3931 (when (string-match ".*/" gnus-tmp-name)
3932 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3933 (setq gnus-tmp-type-long (concat gnus-tmp-type
3934 (and (not (equal gnus-tmp-name ""))
3935 (concat "; " gnus-tmp-name))))
3936 (unless (equal gnus-tmp-description "")
3937 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3942 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3943 `(keymap ,gnus-mime-button-map
3944 ,@(if (>= (string-to-number emacs-version) 21)
3946 (list 'local-map gnus-mime-button-map))
3947 gnus-callback gnus-mm-display-part
3948 gnus-part ,gnus-tmp-id
3949 article-type annotation
3952 (widget-convert-button
3955 :action 'gnus-widget-press-button
3956 :button-keymap gnus-mime-button-map
3958 (lambda (widget/window &optional overlay pos)
3959 ;; Needed to properly clear the message due to a bug in
3960 ;; wid-edit (XEmacs only).
3961 (if (boundp 'help-echo-owns-message)
3962 (setq help-echo-owns-message t))
3964 "%S: %s the MIME part; %S: more options"
3965 (aref gnus-mouse-2 0)
3966 ;; XEmacs will get a single widget arg; Emacs 21 will get
3967 ;; window, overlay, position.
3968 (if (mm-handle-displayed-p
3970 (with-current-buffer (gnus-overlay-buffer overlay)
3971 (widget-get (widget-at (gnus-overlay-start overlay))
3973 (widget-get widget/window :mime-handle)))
3975 (aref gnus-down-mouse-3 0))))))
3977 (defun gnus-widget-press-button (elems el)
3978 (goto-char (widget-get elems :from))
3979 (gnus-article-press-button))
3981 (defvar gnus-displaying-mime nil)
3983 (defun gnus-display-mime (&optional ihandles)
3984 "Display the MIME parts."
3986 (save-selected-window
3987 (let ((window (get-buffer-window gnus-article-buffer))
3990 (select-window window)
3991 ;; We have to do this since selecting the window
3992 ;; may change the point. So we set the window point.
3993 (set-window-point window point)))
3994 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3995 buffer-read-only handle name type b e display)
3996 (when (and (not ihandles)
3997 (not gnus-displaying-mime))
3998 ;; Top-level call; we clean up.
3999 (when gnus-article-mime-handles
4000 (mm-destroy-parts gnus-article-mime-handles)
4001 (setq gnus-article-mime-handle-alist nil));; A trick.
4002 (setq gnus-article-mime-handles handles)
4003 ;; We allow users to glean info from the handles.
4004 (when gnus-article-mime-part-function
4005 (gnus-mime-part-function handles)))
4007 (or (not (stringp (car handles)))
4010 (when (and (not ihandles)
4011 (not gnus-displaying-mime))
4012 ;; Clean up for mime parts.
4014 (delete-region (point) (point-max)))
4015 (let ((gnus-displaying-mime t))
4016 (gnus-mime-display-part handles)))
4019 (narrow-to-region (point) (point-max))
4020 (gnus-treat-article nil 1 1)
4023 ;; Highlight the headers.
4027 (narrow-to-region (point-min) (point))
4028 (gnus-treat-article 'head))))))))
4030 (defvar gnus-mime-display-multipart-as-mixed nil)
4031 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4032 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4034 (defun gnus-mime-display-part (handle)
4037 ((not (stringp (car handle)))
4038 (gnus-mime-display-single handle))
4039 ;; User-defined multipart
4040 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4041 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4043 ;; multipart/alternative
4044 ((and (equal (car handle) "multipart/alternative")
4045 (not (or gnus-mime-display-multipart-as-mixed
4046 gnus-mime-display-multipart-alternative-as-mixed)))
4047 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4048 (push (cons id handle) gnus-article-mime-handle-alist)
4049 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4050 ;; multipart/related
4051 ((and (equal (car handle) "multipart/related")
4052 (not (or gnus-mime-display-multipart-as-mixed
4053 gnus-mime-display-multipart-related-as-mixed)))
4054 ;;;!!!We should find the start part, but we just default
4055 ;;;!!!to the first part.
4056 ;;(gnus-mime-display-part (cadr handle))
4057 ;;;!!! Most multipart/related is an HTML message plus images.
4058 ;;;!!! Unfortunately we are unable to let W3 display those
4059 ;;;!!! included images, so we just display it as a mixed multipart.
4060 ;;(gnus-mime-display-mixed (cdr handle))
4061 ;;;!!! No, w3 can display everything just fine.
4062 (gnus-mime-display-part (cadr handle)))
4063 ((equal (car handle) "multipart/signed")
4064 (gnus-add-wash-type 'signed)
4065 (gnus-mime-display-security handle))
4066 ((equal (car handle) "multipart/encrypted")
4067 (gnus-add-wash-type 'encrypted)
4068 (gnus-mime-display-security handle))
4069 ;; Other multiparts are handled like multipart/mixed.
4071 (gnus-mime-display-mixed (cdr handle)))))
4073 (defun gnus-mime-part-function (handles)
4074 (if (stringp (car handles))
4075 (mapcar 'gnus-mime-part-function (cdr handles))
4076 (funcall gnus-article-mime-part-function handles)))
4078 (defun gnus-mime-display-mixed (handles)
4079 (mapcar 'gnus-mime-display-part handles))
4081 (defun gnus-mime-display-single (handle)
4082 (let ((type (mm-handle-media-type handle))
4083 (ignored gnus-ignored-mime-types)
4090 (when (string-match (pop ignored) type)
4091 (throw 'ignored nil)))
4092 (if (and (setq not-attachment
4093 (and (not (mm-inline-override-p handle))
4094 (or (not (mm-handle-disposition handle))
4095 (equal (car (mm-handle-disposition handle))
4097 (mm-attachment-override-p handle))))
4098 (mm-automatic-display-p handle)
4100 (mm-inlinable-p handle)
4101 (mm-inlined-p handle))
4102 (mm-automatic-external-display-p type)))
4104 (when (equal (mm-handle-media-supertype handle) "text")
4106 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4108 (push (cons id handle) gnus-article-mime-handle-alist)
4109 (when (or (not display)
4110 (not (gnus-unbuttonized-mime-type-p type)))
4111 ;(gnus-article-insert-newline)
4112 (gnus-insert-mime-button
4113 handle id (list (or display (and not-attachment text))))
4114 (gnus-article-insert-newline)
4115 ;(gnus-article-insert-newline)
4116 ;; Remember modify the number of forward lines.
4124 (let ((mail-parse-charset gnus-newsgroup-charset)
4125 (mail-parse-ignored-charsets
4126 (save-excursion (condition-case ()
4127 (set-buffer gnus-summary-buffer)
4129 gnus-newsgroup-ignored-charsets)))
4130 (mm-display-part handle t))
4131 (goto-char (point-max)))
4132 ((and text not-attachment)
4136 (gnus-article-insert-newline)
4137 (mm-insert-inline handle (mm-get-part handle))
4138 (goto-char (point-max))))
4142 (narrow-to-region beg (point))
4145 (gnus-article-mime-total-parts)
4146 (mm-handle-media-type handle)))))))))
4148 (defun gnus-unbuttonized-mime-type-p (type)
4149 "Say whether TYPE is to be unbuttonized."
4150 (unless gnus-inhibit-mime-unbuttonizing
4152 (let ((types gnus-unbuttonized-mime-types))
4154 (when (string-match (pop types) type)
4155 (throw 'found t)))))
4157 (let ((types gnus-buttonized-mime-types))
4159 (when (string-match (pop types) type)
4160 (throw 'found t)))))))))
4162 (defun gnus-article-insert-newline ()
4163 "Insert a newline, but mark it as undeletable."
4164 (gnus-put-text-property
4165 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4167 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4168 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4171 handle buffer-read-only from props begend not-pref)
4172 (save-window-excursion
4175 (narrow-to-region (car ibegend)
4178 (goto-char (car ibegend))
4181 (delete-region (point-min) (point-max))
4182 (mm-remove-parts handles))
4183 (setq begend (list (point-marker)))
4185 (unless (setq not-pref (cadr (member preferred ihandles)))
4186 (setq not-pref (car ihandles)))
4189 (not (gnus-unbuttonized-mime-type-p
4190 "multipart/alternative")))
4191 (gnus-add-text-properties
4194 (insert (format "%d. " id))
4198 (unless ,(not ibegend)
4199 (setq gnus-article-mime-handle-alist
4200 ',gnus-article-mime-handle-alist))
4201 (gnus-mime-display-alternative
4202 ',ihandles ',not-pref ',begend ,id))
4203 ,@(if (>= (string-to-number emacs-version) 21)
4204 nil ;; XEmacs doesn't care
4205 (list 'local-map gnus-mime-button-map))
4206 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4207 face ,gnus-article-button-face
4208 keymap ,gnus-mime-button-map
4211 (widget-convert-button 'link from (point)
4212 :action 'gnus-widget-press-button
4213 :button-keymap gnus-widget-button-keymap)
4215 (while (setq handle (pop handles))
4216 (gnus-add-text-properties
4219 (insert (format "(%c) %-18s"
4220 (if (equal handle preferred) ?* ? )
4221 (mm-handle-media-type handle)))
4225 (unless ,(not ibegend)
4226 (setq gnus-article-mime-handle-alist
4227 ',gnus-article-mime-handle-alist))
4228 (gnus-mime-display-alternative
4229 ',ihandles ',handle ',begend ,id))
4230 ,@(if (>= (string-to-number emacs-version) 21)
4231 nil ;; XEmacs doesn't care
4232 (list 'local-map gnus-mime-button-map))
4233 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4234 face ,gnus-article-button-face
4235 keymap ,gnus-mime-button-map
4238 (widget-convert-button 'link from (point)
4239 :action 'gnus-widget-press-button
4240 :button-keymap gnus-widget-button-keymap)
4244 (if (stringp (car preferred))
4245 (gnus-display-mime preferred)
4246 (let ((mail-parse-charset gnus-newsgroup-charset)
4247 (mail-parse-ignored-charsets
4248 (save-excursion (set-buffer gnus-summary-buffer)
4249 gnus-newsgroup-ignored-charsets)))
4250 (mm-display-part preferred)
4254 (narrow-to-region (car begend) (point-max))
4256 nil (length gnus-article-mime-handle-alist)
4257 (gnus-article-mime-total-parts)
4258 (mm-handle-media-type handle))))))
4259 (goto-char (point-max))
4260 (setcdr begend (point-marker)))))
4262 (goto-char point))))
4264 (defconst gnus-article-wash-status-strings
4265 (let ((alist '((cite "c" "Possible hidden citation text"
4266 " " "All citation text visible")
4267 (headers "h" "Hidden headers"
4268 " " "All headers visible.")
4269 (pgp "p" "Encrypted or signed message status hidden"
4270 " " "No hidden encryption nor digital signature status")
4271 (signature "s" "Signature has been hidden"
4272 " " "Signature is visible")
4273 (overstrike "o" "Overstrike (^H) characters applied"
4274 " " "No overstrike characters applied")
4275 (emphasis "e" "/*_Emphasis_*/ characters applied"
4276 " " "No /*_emphasis_*/ characters applied")))
4278 (dolist (entry alist result)
4279 (let ((key (nth 0 entry))
4280 (on (copy-sequence (nth 1 entry)))
4281 (on-help (nth 2 entry))
4282 (off (copy-sequence (nth 3 entry)))
4283 (off-help (nth 4 entry)))
4284 (put-text-property 0 1 'help-echo on-help on)
4285 (put-text-property 0 1 'help-echo off-help off)
4286 (push (list key on off) result))))
4287 "Alist of strings describing wash status in the mode line.
4288 Each entry has the form (KEY ON OF), where the KEY is a symbol
4289 representing the particular washing function, ON is the string to use
4290 in the article mode line when the washing function is active, and OFF
4291 is the string to use when it is inactive.")
4293 (defun gnus-article-wash-status-entry (key value)
4294 (let ((entry (assoc key gnus-article-wash-status-strings)))
4295 (if value (nth 1 entry) (nth 2 entry))))
4297 (defun gnus-article-wash-status ()
4298 "Return a string which display status of article washing."
4300 (set-buffer gnus-article-buffer)
4301 (let ((cite (memq 'cite gnus-article-wash-types))
4302 (headers (memq 'headers gnus-article-wash-types))
4303 (boring (memq 'boring-headers gnus-article-wash-types))
4304 (pgp (memq 'pgp gnus-article-wash-types))
4305 (pem (memq 'pem gnus-article-wash-types))
4306 (signed (memq 'signed gnus-article-wash-types))
4307 (encrypted (memq 'encrypted gnus-article-wash-types))
4308 (signature (memq 'signature gnus-article-wash-types))
4309 (overstrike (memq 'overstrike gnus-article-wash-types))
4310 (emphasis (memq 'emphasis gnus-article-wash-types)))
4312 (gnus-article-wash-status-entry 'cite cite)
4313 (gnus-article-wash-status-entry 'headers (or headers boring))
4314 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4315 (gnus-article-wash-status-entry 'signature signature)
4316 (gnus-article-wash-status-entry 'overstrike overstrike)
4317 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4319 (defun gnus-add-wash-type (type)
4320 "Add a washing of TYPE to the current status."
4321 (push type gnus-article-wash-types))
4323 (defun gnus-delete-wash-type (type)
4324 "Add a washing of TYPE to the current status."
4325 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4327 (defun gnus-add-image (category image)
4328 "Add IMAGE of CATEGORY to the list of displayed images."
4329 (let ((entry (assq category gnus-article-image-alist)))
4331 (setq entry (list category))
4332 (push entry gnus-article-image-alist))
4333 (nconc entry (list image))))
4335 (defun gnus-delete-images (category)
4336 "Delete all images in CATEGORY."
4337 (let ((entry (assq category gnus-article-image-alist)))
4338 (dolist (image (cdr entry))
4339 (gnus-remove-image image))
4340 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4341 (gnus-delete-wash-type category)))
4343 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4345 (defun gnus-article-maybe-hide-headers ()
4346 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4347 Provided for backwards compatibility."
4348 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4349 (not (save-excursion (set-buffer gnus-summary-buffer)
4350 gnus-have-all-headers)))
4351 (not gnus-inhibit-hiding))
4352 (gnus-article-hide-headers)))
4356 (defun gnus-output-to-file (file-name)
4357 "Append the current article to a file named FILE-NAME."
4358 (let ((artbuf (current-buffer)))
4360 (insert-buffer-substring artbuf)
4361 ;; Append newline at end of the buffer as separator, and then
4363 (goto-char (point-max))
4365 (let ((file-name-coding-system nnmail-pathname-coding-system))
4366 (mm-append-to-file (point-min) (point-max) file-name))
4369 (defun gnus-narrow-to-page (&optional arg)
4370 "Narrow the article buffer to a page.
4371 If given a numerical ARG, move forward ARG pages."
4373 (setq arg (if arg (prefix-numeric-value arg) 0))
4375 (set-buffer gnus-article-buffer)
4376 (goto-char (point-min))
4378 ;; Remove any old next/prev buttons.
4379 (when (gnus-visual-p 'page-marker)
4380 (let ((buffer-read-only nil))
4381 (gnus-remove-text-with-property 'gnus-prev)
4382 (gnus-remove-text-with-property 'gnus-next)))
4385 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4387 (re-search-forward page-delimiter nil 'move arg)))
4388 (goto-char (match-end 0)))
4391 (if (re-search-forward page-delimiter nil 'move)
4394 (when (and (gnus-visual-p 'page-marker)
4395 (not (= (point-min) 1)))
4397 (goto-char (point-min))
4398 (gnus-insert-prev-page-button)))
4399 (when (and (gnus-visual-p 'page-marker)
4400 (< (+ (point-max) 2) (buffer-size)))
4402 (goto-char (point-max))
4403 (gnus-insert-next-page-button)))))
4405 ;; Article mode commands
4407 (defun gnus-article-goto-next-page ()
4408 "Show the next page of the article."
4410 (when (gnus-article-next-page)
4411 (goto-char (point-min))
4412 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4414 (defun gnus-article-goto-prev-page ()
4415 "Show the next page of the article."
4417 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4418 (gnus-article-prev-page nil)))
4420 (defun gnus-article-next-page (&optional lines)
4421 "Show the next page of the current article.
4422 If end of article, return non-nil. Otherwise return nil.
4423 Argument LINES specifies lines to be scrolled up."
4425 (move-to-window-line -1)
4428 (and (pos-visible-in-window-p) ;Not continuation line.
4430 ;; Nothing in this page.
4431 (if (or (not gnus-page-broken)
4434 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4436 (gnus-narrow-to-page 1) ;Go to next page.
4438 ;; More in this page.
4439 (let ((scroll-in-place nil))
4443 ;; Long lines may cause an end-of-buffer error.
4444 (goto-char (point-max)))))
4445 (move-to-window-line 0)
4448 (defun gnus-article-prev-page (&optional lines)
4449 "Show previous page of current article.
4450 Argument LINES specifies lines to be scrolled down."
4452 (move-to-window-line 0)
4453 (if (and gnus-page-broken
4455 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4457 (gnus-narrow-to-page -1) ;Go to previous page.
4458 (goto-char (point-max))
4460 (let ((scroll-in-place nil))
4464 (beginning-of-buffer
4465 (goto-char (point-min))))
4466 (move-to-window-line 0)))))
4468 (defun gnus-article-refer-article ()
4469 "Read article specified by message-id around point."
4471 (let ((point (point)))
4472 (search-forward ">" nil t) ;Move point to end of "<....>".
4473 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4474 (let ((message-id (match-string 1)))
4476 (set-buffer gnus-summary-buffer)
4477 (gnus-summary-refer-article message-id))
4479 (error "No references around point"))))
4481 (defun gnus-article-show-summary ()
4482 "Reconfigure windows to show summary buffer."
4484 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4485 (error "There is no summary buffer for this article buffer")
4486 (gnus-article-set-globals)
4487 (gnus-configure-windows 'article)
4488 (gnus-summary-goto-subject gnus-current-article)
4489 (gnus-summary-position-point)))
4491 (defun gnus-article-describe-briefly ()
4492 "Describe article mode commands briefly."
4494 (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")))
4496 (defun gnus-article-summary-command ()
4497 "Execute the last keystroke in the summary buffer."
4499 (let ((obuf (current-buffer))
4500 (owin (current-window-configuration))
4502 (switch-to-buffer gnus-article-current-summary 'norecord)
4503 (setq func (lookup-key (current-local-map) (this-command-keys)))
4504 (call-interactively func)
4506 (set-window-configuration owin)
4507 (set-window-point (get-buffer-window (current-buffer)) (point))))
4509 (defun gnus-article-summary-command-nosave ()
4510 "Execute the last keystroke in the summary buffer."
4513 (pop-to-buffer gnus-article-current-summary 'norecord)
4514 (setq func (lookup-key (current-local-map) (this-command-keys)))
4515 (call-interactively func)))
4517 (defun gnus-article-check-buffer ()
4518 "Beep if not in an article buffer."
4519 (unless (equal major-mode 'gnus-article-mode)
4520 (error "Command invoked outside of a Gnus article buffer")))
4522 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4523 "Read a summary buffer key sequence and execute it from the article buffer."
4525 (gnus-article-check-buffer)
4527 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4528 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4529 "=" "^" "\M-^" "|"))
4535 '("n" "Gn" "p" "Gp"))
4538 (set-buffer gnus-article-current-summary)
4539 (let (gnus-pick-mode)
4540 (push (or key last-command-event) unread-command-events)
4541 (setq keys (if (featurep 'xemacs)
4542 (events-to-keys (read-key-sequence nil))
4543 (read-key-sequence nil)))))
4547 (if (or (member keys nosaves)
4548 (member keys nosave-but-article)
4549 (member keys nosave-in-article))
4551 (save-window-excursion
4552 (pop-to-buffer gnus-article-current-summary 'norecord)
4553 ;; We disable the pick minor mode commands.
4554 (let (gnus-pick-mode)
4555 (setq func (lookup-key (current-local-map) keys))))
4559 (unless (member keys nosave-in-article)
4560 (set-buffer gnus-article-current-summary))
4561 (call-interactively func)
4562 (setq new-sum-point (point)))
4563 (when (member keys nosave-but-article)
4564 (pop-to-buffer gnus-article-buffer 'norecord)))
4565 ;; These commands should restore window configuration.
4566 (let ((obuf (current-buffer))
4567 (owin (current-window-configuration))
4569 (summary gnus-article-current-summary)
4570 func in-buffer selected)
4571 (if not-restore-window
4572 (pop-to-buffer summary 'norecord)
4573 (switch-to-buffer summary 'norecord))
4574 (setq in-buffer (current-buffer))
4575 ;; We disable the pick minor mode commands.
4576 (if (and (setq func (let (gnus-pick-mode)
4577 (lookup-key (current-local-map) keys)))
4580 (call-interactively func)
4581 (setq new-sum-point (point))
4582 (when (eq in-buffer (current-buffer))
4583 (setq selected (gnus-summary-select-article))
4585 (unless not-restore-window
4586 (set-window-configuration owin))
4587 (when (eq selected 'old)
4589 (set-window-start (get-buffer-window (current-buffer))
4591 (set-window-point (get-buffer-window (current-buffer))
4593 (let ((win (get-buffer-window gnus-article-current-summary)))
4595 (set-window-point win new-sum-point)))) )
4596 (switch-to-buffer gnus-article-buffer)
4599 (defun gnus-article-describe-key (key)
4600 "Display documentation of the function invoked by KEY. KEY is a string."
4601 (interactive "kDescribe key: ")
4602 (gnus-article-check-buffer)
4603 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4605 (set-buffer gnus-article-current-summary)
4606 (let (gnus-pick-mode)
4607 (if (featurep 'xemacs)
4609 (push (elt key 0) unread-command-events)
4610 (setq key (events-to-keys
4611 (read-key-sequence "Describe key: "))))
4612 (setq unread-command-events
4614 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4615 (string-to-list key)))
4616 (setq key (read-key-sequence "Describe key: "))))
4618 (describe-key key)))
4620 (defun gnus-article-describe-key-briefly (key &optional insert)
4621 "Display documentation of the function invoked by KEY. KEY is a string."
4622 (interactive "kDescribe key: \nP")
4623 (gnus-article-check-buffer)
4624 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4626 (set-buffer gnus-article-current-summary)
4627 (let (gnus-pick-mode)
4628 (if (featurep 'xemacs)
4630 (push (elt key 0) unread-command-events)
4631 (setq key (events-to-keys
4632 (read-key-sequence "Describe key: "))))
4633 (setq unread-command-events
4635 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4636 (string-to-list key)))
4637 (setq key (read-key-sequence "Describe key: "))))
4638 (describe-key-briefly key insert))
4639 (describe-key-briefly key insert)))
4641 (defun gnus-article-hide (&optional arg force)
4642 "Hide all the gruft in the current article.
4643 This means that PGP stuff, signatures, cited text and (some)
4644 headers will be hidden.
4645 If given a prefix, show the hidden text instead."
4646 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4647 (gnus-article-hide-headers arg)
4648 (gnus-article-hide-list-identifiers arg)
4649 (gnus-article-hide-pgp arg)
4650 (gnus-article-hide-citation-maybe arg force)
4651 (gnus-article-hide-signature arg))
4653 (defun gnus-article-maybe-highlight ()
4654 "Do some article highlighting if article highlighting is requested."
4655 (when (gnus-visual-p 'article-highlight 'highlight)
4656 (gnus-article-highlight-some)))
4658 (defun gnus-check-group-server ()
4659 ;; Make sure the connection to the server is alive.
4660 (unless (gnus-server-opened
4661 (gnus-find-method-for-group gnus-newsgroup-name))
4662 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4663 (gnus-request-group gnus-newsgroup-name t)))
4665 (defun gnus-request-article-this-buffer (article group)
4666 "Get an article and insert it into this buffer."
4667 (let (do-update-line sparse-header)
4671 (gnus-kill-all-overlays)
4672 (setq group (or group gnus-newsgroup-name))
4674 ;; Using `gnus-request-article' directly will insert the article into
4675 ;; `nntp-server-buffer' - so we'll save some time by not having to
4676 ;; copy it from the server buffer into the article buffer.
4678 ;; We only request an article by message-id when we do not have the
4679 ;; headers for it, so we'll have to get those.
4680 (when (stringp article)
4681 (gnus-read-header article))
4683 ;; If the article number is negative, that means that this article
4684 ;; doesn't belong in this newsgroup (possibly), so we find its
4685 ;; message-id and request it by id instead of number.
4686 (when (and (numberp article)
4688 (get-buffer gnus-summary-buffer)
4689 (gnus-buffer-exists-p gnus-summary-buffer))
4691 (set-buffer gnus-summary-buffer)
4692 (let ((header (gnus-summary-article-header article)))
4695 ((memq article gnus-newsgroup-sparse)
4696 ;; This is a sparse gap article.
4697 (setq do-update-line article)
4698 (setq article (mail-header-id header))
4699 (setq sparse-header (gnus-read-header article))
4700 (setq gnus-newsgroup-sparse
4701 (delq article gnus-newsgroup-sparse)))
4703 ;; It's a real article.
4704 (setq article (mail-header-id header)))
4706 ;; It is an extracted pseudo-article.
4707 (setq article 'pseudo)
4708 (gnus-request-pseudo-article header))))
4710 (let ((method (gnus-find-method-for-group
4711 gnus-newsgroup-name)))
4712 (when (and (eq (car method) 'nneething)
4714 (let ((dir (expand-file-name
4715 (mail-header-subject header)
4716 (file-name-as-directory
4717 (or (cadr (assq 'nneething-address method))
4719 (when (file-directory-p dir)
4720 (setq article 'nneething)
4721 (gnus-group-enter-directory dir))))))))
4724 ;; Refuse to select canceled articles.
4725 ((and (numberp article)
4727 (get-buffer gnus-summary-buffer)
4728 (gnus-buffer-exists-p gnus-summary-buffer)
4729 (eq (cdr (save-excursion
4730 (set-buffer gnus-summary-buffer)
4731 (assq article gnus-newsgroup-reads)))
4732 gnus-canceled-mark))
4734 ;; We first check `gnus-original-article-buffer'.
4735 ((and (get-buffer gnus-original-article-buffer)
4738 (set-buffer gnus-original-article-buffer)
4739 (and (equal (car gnus-original-article) group)
4740 (eq (cdr gnus-original-article) article))))
4741 (insert-buffer-substring gnus-original-article-buffer)
4743 ;; Check the backlog.
4744 ((and gnus-keep-backlog
4745 (gnus-backlog-request-article group article (current-buffer)))
4747 ;; Check asynchronous pre-fetch.
4748 ((gnus-async-request-fetched-article group article (current-buffer))
4749 (gnus-async-prefetch-next group article gnus-summary-buffer)
4750 (when (and (numberp article) gnus-keep-backlog)
4751 (gnus-backlog-enter-article group article (current-buffer)))
4754 ((and gnus-use-cache
4756 (gnus-cache-request-article article group))
4758 ;; Get the article and put into the article buffer.
4759 ((or (stringp article)
4761 (let ((gnus-override-method gnus-override-method)
4762 (methods (and (stringp article)
4763 gnus-refer-article-method))
4765 (buffer-read-only nil))
4766 (if (or (not (listp methods))
4767 (and (symbolp (car methods))
4768 (assq (car methods) nnoo-definition-alist)))
4769 (setq methods (list methods)))
4770 (when (and (null gnus-override-method)
4772 (setq gnus-override-method (pop methods)))
4774 (when (eq gnus-override-method 'current)
4775 (setq gnus-override-method
4776 (with-current-buffer gnus-summary-buffer
4777 gnus-current-select-method)))
4779 (gnus-kill-all-overlays)
4780 (let ((gnus-newsgroup-name group))
4781 (gnus-check-group-server))
4782 (when (gnus-request-article article group (current-buffer))
4783 (when (numberp article)
4784 (gnus-async-prefetch-next group article
4785 gnus-summary-buffer)
4786 (when gnus-keep-backlog
4787 (gnus-backlog-enter-article
4788 group article (current-buffer))))
4789 (setq result 'article))
4792 (setq gnus-override-method (pop methods))
4793 (setq result 'done))))
4794 (and (eq result 'article) 'article)))
4798 ;; Associate this article with the current summary buffer.
4799 (setq gnus-article-current-summary gnus-summary-buffer)
4801 ;; Take the article from the original article buffer
4802 ;; and place it in the buffer it's supposed to be in.
4803 (when (and (get-buffer gnus-article-buffer)
4804 (equal (buffer-name (current-buffer))
4805 (buffer-name (get-buffer gnus-article-buffer))))
4807 (if (get-buffer gnus-original-article-buffer)
4808 (set-buffer gnus-original-article-buffer)
4809 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4810 (buffer-disable-undo)
4811 (setq major-mode 'gnus-original-article-mode)
4812 (setq buffer-read-only t))
4813 (let (buffer-read-only)
4815 (insert-buffer-substring gnus-article-buffer))
4816 (setq gnus-original-article (cons group article)))
4819 (run-hooks 'gnus-article-decode-hook)
4820 ;; Mark article as decoded or not.
4821 (setq gnus-article-decoded-p gnus-article-decode-hook))
4823 ;; Update sparse articles.
4824 (when (and do-update-line
4825 (or (numberp article)
4827 (let ((buf (current-buffer)))
4828 (set-buffer gnus-summary-buffer)
4829 (gnus-summary-update-article do-update-line sparse-header)
4830 (gnus-summary-goto-subject do-update-line nil t)
4831 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4833 (set-buffer buf))))))
4839 (defcustom gnus-article-edit-mode-hook nil
4840 "Hook run in article edit mode buffers."
4841 :group 'gnus-article-various
4844 (defvar gnus-article-edit-done-function nil)
4846 (defvar gnus-article-edit-mode-map nil)
4848 ;; Should we be using derived.el for this?
4849 (unless gnus-article-edit-mode-map
4850 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4851 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4853 (gnus-define-keys gnus-article-edit-mode-map
4854 "\C-c\C-c" gnus-article-edit-done
4855 "\C-c\C-k" gnus-article-edit-exit)
4857 (gnus-define-keys (gnus-article-edit-wash-map
4858 "\C-c\C-w" gnus-article-edit-mode-map)
4859 "f" gnus-article-edit-full-stops))
4861 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4862 "Major mode for editing articles.
4863 This is an extended text-mode.
4865 \\{gnus-article-edit-mode-map}"
4866 (make-local-variable 'gnus-article-edit-done-function)
4867 (make-local-variable 'gnus-prev-winconf)
4868 (set (make-local-variable 'font-lock-defaults)
4869 '(message-font-lock-keywords t))
4870 (setq buffer-read-only nil)
4871 (buffer-enable-undo)
4874 (defun gnus-article-edit (&optional force)
4875 "Edit the current article.
4876 This will have permanent effect only in mail groups.
4877 If FORCE is non-nil, allow editing of articles even in read-only
4880 (when (and (not force)
4881 (gnus-group-read-only-p))
4882 (error "The current newsgroup does not support article editing"))
4883 (gnus-article-date-original)
4884 (gnus-article-edit-article
4886 `(lambda (no-highlight)
4888 (gnus-summary-edit-article-done
4889 ,(or (mail-header-references gnus-current-headers) "")
4890 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4892 (defun gnus-article-edit-article (start-func exit-func)
4893 "Start editing the contents of the current article buffer."
4894 (let ((winconf (current-window-configuration)))
4895 (set-buffer gnus-article-buffer)
4896 (gnus-article-edit-mode)
4897 (funcall start-func)
4898 (set-buffer-modified-p nil)
4899 (gnus-configure-windows 'edit-article)
4900 (setq gnus-article-edit-done-function exit-func)
4901 (setq gnus-prev-winconf winconf)
4902 (gnus-message 6 "C-c C-c to end edits")))
4904 (defun gnus-article-edit-done (&optional arg)
4905 "Update the article edits and exit."
4907 (let ((func gnus-article-edit-done-function)
4908 (buf (current-buffer))
4909 (start (window-start)))
4910 ;; We remove all text props from the article buffer.
4912 (buffer-substring-no-properties (point-min) (point-max)))
4916 (let ((winconf gnus-prev-winconf))
4918 (set-window-configuration winconf)
4919 ;; Tippy-toe some to make sure that point remains where it was.
4920 (save-current-buffer
4922 (set-window-start (get-buffer-window (current-buffer)) start)
4926 (let ((buffer-read-only nil))
4928 ;; The cache and backlog have to be flushed somewhat.
4929 (when gnus-keep-backlog
4930 (gnus-backlog-remove-article
4931 (car gnus-article-current) (cdr gnus-article-current)))
4932 ;; Flush original article as well.
4934 (when (get-buffer gnus-original-article-buffer)
4935 (set-buffer gnus-original-article-buffer)
4936 (setq gnus-original-article nil)))
4937 (when gnus-use-cache
4938 (gnus-cache-update-article
4939 (car gnus-article-current) (cdr gnus-article-current))))
4941 (set-window-start (get-buffer-window buf) start)
4942 (set-window-point (get-buffer-window buf) (point))))
4944 (defun gnus-article-edit-exit ()
4945 "Exit the article editing without updating."
4947 (when (or (not (buffer-modified-p))
4948 (yes-or-no-p "Article modified; kill anyway? "))
4949 (let ((curbuf (current-buffer))
4951 (window-start (window-start)))
4953 (if (gnus-buffer-live-p gnus-original-article-buffer)
4954 (insert-buffer gnus-original-article-buffer))
4955 (let ((winconf gnus-prev-winconf))
4957 (set-window-configuration winconf)
4958 ;; Tippy-toe some to make sure that point remains where it was.
4959 (save-current-buffer
4961 (set-window-start (get-buffer-window (current-buffer)) window-start)
4964 (defun gnus-article-edit-full-stops ()
4965 "Interactively repair spacing at end of sentences."
4968 (goto-char (point-min))
4969 (search-forward-regexp "^$" nil t)
4970 (let ((case-fold-search nil))
4971 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4974 ;;; Article highlights
4977 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4979 ;;; Internal Variables:
4981 (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\\)\\)"
4982 "Regular expression that matches URLs."
4983 :group 'gnus-article-buttons
4986 (defcustom gnus-button-alist
4987 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4988 0 t gnus-button-handle-news 3)
4989 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
4990 gnus-button-handle-news 2)
4991 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4993 gnus-button-fetch-group 4)
4994 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4995 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4996 t gnus-button-message-id 3)
4997 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4998 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
4999 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5001 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5002 gnus-button-handle-info 2)
5003 ;; This is how URLs _should_ be embedded in text...
5004 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5006 (,gnus-button-url-regexp 0 t browse-url 0))
5007 "*Alist of regexps matching buttons in article bodies.
5009 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5010 REGEXP: is the string matching text around the button,
5011 BUTTON: is the number of the regexp grouping actually matching the button,
5012 FORM: is a lisp expression which must eval to true for the button to
5014 CALLBACK: is the function to call when the user push this button, and each
5015 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5017 CALLBACK can also be a variable, in that case the value of that
5018 variable it the real callback function."
5019 :group 'gnus-article-buttons
5020 :type '(repeat (list regexp
5021 (integer :tag "Button")
5023 (function :tag "Callback")
5026 (integer :tag "Regexp group")))))
5028 (defcustom gnus-header-button-alist
5029 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5030 0 t gnus-button-message-id 0)
5031 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5032 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5033 0 t gnus-button-mailto 0)
5034 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5035 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5036 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5037 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5038 gnus-button-message-id 3))
5039 "*Alist of headers and regexps to match buttons in article heads.
5041 This alist is very similar to `gnus-button-alist', except that each
5042 alist has an additional HEADER element first in each entry:
5044 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5046 HEADER is a regexp to match a header. For a fuller explanation, see
5047 `gnus-button-alist'."
5048 :group 'gnus-article-buttons
5049 :group 'gnus-article-headers
5050 :type '(repeat (list (regexp :tag "Header")
5052 (integer :tag "Button")
5054 (function :tag "Callback")
5057 (integer :tag "Regexp group")))))
5059 (defvar gnus-button-regexp nil)
5060 (defvar gnus-button-marker-list nil)
5061 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5063 (defvar gnus-button-last nil)
5064 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5068 (defun gnus-article-push-button (event)
5069 "Check text under the mouse pointer for a callback function.
5070 If the text under the mouse pointer has a `gnus-callback' property,
5071 call it with the value of the `gnus-data' text property."
5073 (set-buffer (window-buffer (posn-window (event-start event))))
5074 (let* ((pos (posn-point (event-start event)))
5075 (data (get-text-property pos 'gnus-data))
5076 (fun (get-text-property pos 'gnus-callback)))
5079 (funcall fun data))))
5081 (defun gnus-article-press-button ()
5082 "Check text at point for a callback function.
5083 If the text at point has a `gnus-callback' property,
5084 call it with the value of the `gnus-data' text property."
5086 (let* ((data (get-text-property (point) 'gnus-data))
5087 (fun (get-text-property (point) 'gnus-callback)))
5089 (funcall fun data))))
5091 (defun gnus-article-highlight (&optional force)
5092 "Highlight current article.
5093 This function calls `gnus-article-highlight-headers',
5094 `gnus-article-highlight-citation',
5095 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5096 do the highlighting. See the documentation for those functions."
5097 (interactive (list 'force))
5098 (gnus-article-highlight-headers)
5099 (gnus-article-highlight-citation force)
5100 (gnus-article-highlight-signature)
5101 (gnus-article-add-buttons force)
5102 (gnus-article-add-buttons-to-head))
5104 (defun gnus-article-highlight-some (&optional force)
5105 "Highlight current article.
5106 This function calls `gnus-article-highlight-headers',
5107 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5108 do the highlighting. See the documentation for those functions."
5109 (interactive (list 'force))
5110 (gnus-article-highlight-headers)
5111 (gnus-article-highlight-signature)
5112 (gnus-article-add-buttons))
5114 (defun gnus-article-highlight-headers ()
5115 "Highlight article headers as specified by `gnus-header-face-alist'."
5118 (set-buffer gnus-article-buffer)
5120 (let ((alist gnus-header-face-alist)
5121 (buffer-read-only nil)
5122 (case-fold-search t)
5123 (inhibit-point-motion-hooks t)
5124 entry regexp header-face field-face from hpoints fpoints)
5125 (article-narrow-to-head)
5126 (while (setq entry (pop alist))
5127 (goto-char (point-min))
5128 (setq regexp (concat "^\\("
5129 (if (string-equal "" (nth 0 entry))
5133 header-face (nth 1 entry)
5134 field-face (nth 2 entry))
5135 (while (and (re-search-forward regexp nil t)
5139 (unless (search-forward ":" nil t)
5141 (when (and header-face
5142 (not (memq (point) hpoints)))
5143 (push (point) hpoints)
5144 (gnus-put-text-property from (point) 'face header-face))
5145 (when (and field-face
5146 (not (memq (setq from (point)) fpoints)))
5148 (if (re-search-forward "^[^ \t]" nil t)
5150 (goto-char (point-max)))
5151 (gnus-put-text-property from (point) 'face field-face))))))))
5153 (defun gnus-article-highlight-signature ()
5154 "Highlight the signature in an article.
5155 It does this by highlighting everything after
5156 `gnus-signature-separator' using `gnus-signature-face'."
5159 (set-buffer gnus-article-buffer)
5160 (let ((buffer-read-only nil)
5161 (inhibit-point-motion-hooks t))
5163 (when (and gnus-signature-face
5164 (gnus-article-narrow-to-signature))
5165 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5166 'face gnus-signature-face)
5168 (gnus-article-search-signature)
5169 (let ((start (match-beginning 0))
5170 (end (set-marker (make-marker) (1+ (match-end 0)))))
5171 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5174 (defun gnus-button-in-region-p (b e prop)
5175 "Say whether PROP exists in the region."
5176 (text-property-not-all b e prop nil))
5178 (defun gnus-article-add-buttons (&optional force)
5179 "Find external references in the article and make buttons of them.
5180 \"External references\" are things like Message-IDs and URLs, as
5181 specified by `gnus-button-alist'."
5182 (interactive (list 'force))
5184 (set-buffer gnus-article-buffer)
5185 (let ((buffer-read-only nil)
5186 (inhibit-point-motion-hooks t)
5187 (case-fold-search t)
5188 (alist gnus-button-alist)
5190 ;; Remove all old markers.
5191 (let (marker entry new-list)
5192 (while (setq marker (pop gnus-button-marker-list))
5193 (if (or (< marker (point-min)) (>= marker (point-max)))
5194 (push marker new-list)
5196 (when (setq entry (gnus-button-entry))
5197 (put-text-property (match-beginning (nth 1 entry))
5198 (match-end (nth 1 entry))
5199 'gnus-callback nil))
5200 (set-marker marker nil)))
5201 (setq gnus-button-marker-list new-list))
5202 ;; We skip the headers.
5205 (while (setq entry (pop alist))
5206 (setq regexp (car entry))
5208 (while (re-search-forward regexp nil t)
5209 (let* ((start (and entry (match-beginning (nth 1 entry))))
5210 (end (and entry (match-end (nth 1 entry))))
5211 (from (match-beginning 0)))
5212 (when (and (or (eq t (nth 2 entry))
5213 (eval (nth 2 entry)))
5214 (not (gnus-button-in-region-p
5215 start end 'gnus-callback)))
5216 ;; That optional form returned non-nil, so we add the
5218 (gnus-article-add-button
5219 start end 'gnus-button-push
5220 (car (push (set-marker (make-marker) from)
5221 gnus-button-marker-list))))))))))
5223 ;; Add buttons to the head of an article.
5224 (defun gnus-article-add-buttons-to-head ()
5225 "Add buttons to the head of the article."
5228 (set-buffer gnus-article-buffer)
5230 (let ((buffer-read-only nil)
5231 (inhibit-point-motion-hooks t)
5232 (case-fold-search t)
5233 (alist gnus-header-button-alist)
5235 (article-narrow-to-head)
5237 ;; Each alist entry.
5238 (setq entry (car alist)
5240 (goto-char (point-min))
5241 (while (re-search-forward (car entry) nil t)
5242 ;; Each header matching the entry.
5243 (setq beg (match-beginning 0))
5244 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5245 (match-beginning 0))
5248 (while (re-search-forward (nth 1 entry) end t)
5249 ;; Each match within a header.
5250 (let* ((entry (cdr entry))
5251 (start (match-beginning (nth 1 entry)))
5252 (end (match-end (nth 1 entry)))
5253 (form (nth 2 entry)))
5254 (goto-char (match-end 0))
5256 (gnus-article-add-button
5257 start end (nth 3 entry)
5258 (buffer-substring (match-beginning (nth 4 entry))
5259 (match-end (nth 4 entry)))))))
5260 (goto-char end)))))))
5262 ;;; External functions:
5264 (defun gnus-article-add-button (from to fun &optional data)
5265 "Create a button between FROM and TO with callback FUN and data DATA."
5266 (when gnus-article-button-face
5267 (gnus-overlay-put (gnus-make-overlay from to)
5268 'face gnus-article-button-face))
5269 (gnus-add-text-properties
5271 (nconc (and gnus-article-mouse-face
5272 (list gnus-mouse-face-prop gnus-article-mouse-face))
5273 (list 'gnus-callback fun)
5274 (and data (list 'gnus-data data))))
5275 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5276 :button-keymap gnus-widget-button-keymap))
5278 ;;; Internal functions:
5280 (defun gnus-article-set-globals ()
5282 (set-buffer gnus-summary-buffer)
5283 (gnus-set-global-variables)))
5285 (defun gnus-signature-toggle (end)
5287 (set-buffer gnus-article-buffer)
5288 (let ((buffer-read-only nil)
5289 (inhibit-point-motion-hooks t))
5290 (if (text-property-any end (point-max) 'article-type 'signature)
5292 (gnus-delete-wash-type 'signature)
5293 (gnus-remove-text-properties-when
5294 'article-type 'signature end (point-max)
5295 (cons 'article-type (cons 'signature
5296 gnus-hidden-properties))))
5297 (gnus-add-wash-type 'signature)
5298 (gnus-add-text-properties-when
5299 'article-type nil end (point-max)
5300 (cons 'article-type (cons 'signature
5301 gnus-hidden-properties)))))
5302 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5303 (gnus-set-mode-line 'article))))
5305 (defun gnus-button-entry ()
5306 ;; Return the first entry in `gnus-button-alist' matching this place.
5307 (let ((alist gnus-button-alist)
5310 (setq entry (pop alist))
5311 (if (looking-at (car entry))
5316 (defun gnus-button-push (marker)
5317 ;; Push button starting at MARKER.
5320 (let* ((entry (gnus-button-entry))
5321 (inhibit-point-motion-hooks t)
5323 (args (mapcar (lambda (group)
5324 (let ((string (match-string group)))
5325 (gnus-set-text-properties
5326 0 (length string) nil string)
5333 (fboundp (symbol-value fun)))
5334 (apply (symbol-value fun) args))
5336 (gnus-message 1 "You must define `%S' to use this button"
5337 (cons fun args)))))))
5339 (defun gnus-parse-news-url (url)
5340 (let (scheme server group message-id articles)
5343 (goto-char (point-min))
5344 (when (looking-at "\\([A-Za-z]+\\):")
5345 (setq scheme (match-string 1))
5346 (goto-char (match-end 0)))
5347 (when (looking-at "//\\([^/]+\\)/")
5348 (setq server (match-string 1))
5349 (goto-char (match-end 0)))
5352 ((looking-at "\\(.*@.*\\)")
5353 (setq message-id (match-string 1)))
5354 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5355 (setq group (match-string 1)
5356 articles (split-string (match-string 2) "-")))
5357 ((looking-at "\\([^/]+\\)/?")
5358 (setq group (match-string 1)))
5360 (error "Unknown news URL syntax"))))
5361 (list scheme server group message-id articles)))
5363 (defun gnus-button-handle-news (url)
5365 (destructuring-bind (scheme server group message-id articles)
5366 (gnus-parse-news-url url)
5370 (set-buffer gnus-summary-buffer)
5372 (let ((gnus-refer-article-method (list (list 'nntp server))))
5373 (gnus-summary-refer-article message-id))
5374 (gnus-summary-refer-article message-id))))
5376 (gnus-button-fetch-group url)))))
5378 (defun gnus-button-handle-info (url)
5379 "Fetch an info URL."
5381 "^\\([^:/]+\\)?/\\(.*\\)"
5383 (gnus-info-find-node
5384 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5387 (gnus-url-unhex-string (match-string 2 url))))
5388 (error "Can't parse %s" url)))
5390 (defun gnus-button-message-id (message-id)
5393 (set-buffer gnus-summary-buffer)
5394 (gnus-summary-refer-article message-id)))
5396 (defun gnus-button-fetch-group (address)
5397 "Fetch GROUP specified by ADDRESS."
5398 (if (not (string-match "[:/]" address))
5399 ;; This is just a simple group url.
5400 (gnus-group-read-ephemeral-group address gnus-select-method)
5403 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5405 (error "Can't parse %s" address)
5406 (gnus-group-read-ephemeral-group
5407 (match-string 4 address)
5408 `(nntp ,(match-string 1 address)
5409 (nntp-address ,(match-string 1 address))
5410 (nntp-port-number ,(if (match-end 3)
5411 (match-string 3 address)
5414 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5416 (defun gnus-url-parse-query-string (query &optional downcase)
5417 (let (retval pairs cur key val)
5418 (setq pairs (split-string query "&"))
5420 (setq cur (car pairs)
5422 (if (not (string-match "=" cur))
5424 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5425 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5427 (setq key (downcase key)))
5428 (setq cur (assoc key retval))
5430 (setcdr cur (cons val (cdr cur)))
5431 (setq retval (cons (list key val) retval)))))
5434 (defun gnus-url-mailto (url)
5435 ;; Send mail to someone
5436 (when (string-match "mailto:/*\\(.*\\)" url)
5437 (setq url (substring url (match-beginning 1) nil)))
5438 (let (to args subject func)
5439 (if (string-match (regexp-quote "?") url)
5440 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5441 args (gnus-url-parse-query-string
5442 (substring url (match-end 0) nil) t))
5443 (setq to (gnus-url-unhex-string url)))
5444 (setq args (cons (list "to" to) args)
5445 subject (cdr-safe (assoc "subject" args)))
5448 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5451 (message-position-on-field (caar args)))
5452 (insert (mapconcat 'identity (cdar args) ", "))
5453 (setq args (cdr args)))
5456 (message-goto-subject))))
5458 (defun gnus-button-embedded-url (address)
5459 "Activate ADDRESS with `browse-url'."
5460 (browse-url (gnus-strip-whitespace address)))
5462 ;;; Next/prev buttons in the article buffer.
5464 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5465 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5467 (defvar gnus-prev-page-map nil)
5468 (unless gnus-prev-page-map
5469 (setq gnus-prev-page-map (make-sparse-keymap))
5470 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5471 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5473 (defun gnus-insert-prev-page-button ()
5474 (let ((buffer-read-only nil))
5476 gnus-prev-page-line-format nil
5477 `(gnus-prev t local-map ,gnus-prev-page-map
5478 gnus-callback gnus-article-button-prev-page
5479 article-type annotation))))
5481 (defvar gnus-next-page-map nil)
5482 (unless gnus-next-page-map
5483 (setq gnus-next-page-map (make-keymap))
5484 (suppress-keymap gnus-prev-page-map)
5485 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5486 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5488 (defun gnus-button-next-page ()
5489 "Go to the next page."
5491 (let ((win (selected-window)))
5492 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5493 (gnus-article-next-page)
5494 (select-window win)))
5496 (defun gnus-button-prev-page ()
5497 "Go to the prev page."
5499 (let ((win (selected-window)))
5500 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5501 (gnus-article-prev-page)
5502 (select-window win)))
5504 (defun gnus-insert-next-page-button ()
5505 (let ((buffer-read-only nil))
5506 (gnus-eval-format gnus-next-page-line-format nil
5508 t local-map ,gnus-next-page-map
5509 gnus-callback gnus-article-button-next-page
5510 article-type annotation))))
5512 (defun gnus-article-button-next-page (arg)
5513 "Go to the next page."
5515 (let ((win (selected-window)))
5516 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5517 (gnus-article-next-page)
5518 (select-window win)))
5520 (defun gnus-article-button-prev-page (arg)
5521 "Go to the prev page."
5523 (let ((win (selected-window)))
5524 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5525 (gnus-article-prev-page)
5526 (select-window win)))
5528 (defvar gnus-decode-header-methods
5529 '(mail-decode-encoded-word-region)
5530 "List of methods used to decode headers.
5532 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5533 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5534 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5535 whose names match REGEXP.
5538 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5539 mail-decode-encoded-word-region
5540 (\"chinese\" . rfc1843-decode-region))
5543 (defvar gnus-decode-header-methods-cache nil)
5545 (defun gnus-multi-decode-header (start end)
5546 "Apply the functions from `gnus-encoded-word-methods' that match."
5547 (unless (and gnus-decode-header-methods-cache
5548 (eq gnus-newsgroup-name
5549 (car gnus-decode-header-methods-cache)))
5550 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5553 (nconc gnus-decode-header-methods-cache (list x))
5554 (if (and gnus-newsgroup-name
5555 (string-match (car x) gnus-newsgroup-name))
5556 (nconc gnus-decode-header-methods-cache
5558 gnus-decode-header-methods))
5559 (let ((xlist gnus-decode-header-methods-cache))
5562 (narrow-to-region start end)
5564 (funcall (pop xlist) (point-min) (point-max))))))
5567 ;;; Treatment top-level handling.
5570 (defun gnus-treat-article (condition &optional part-number total-parts type)
5571 (let ((length (- (point-max) (point-min)))
5572 (alist gnus-treatment-function-alist)
5573 (article-goto-body-goes-to-point-min-p t)
5577 (let ((list gnus-article-treat-types))
5579 (when (string-match (pop list) type)
5580 (throw 'found t)))))))
5581 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5583 (gnus-run-hooks 'gnus-part-display-hook)
5584 (while (setq elem (pop alist))
5587 (if (gnus-buffer-live-p gnus-summary-buffer)
5588 (set-buffer gnus-summary-buffer))
5589 (symbol-value (car elem))))
5590 (when (and (or (consp val)
5592 (gnus-treat-predicate val)
5593 (or (not (get (car elem) 'highlight))
5596 (funcall (cadr elem)))))))
5598 ;; Dynamic variables.
5600 (defvar part-number)
5601 (defvar total-parts)
5606 (defun gnus-treat-predicate (val)
5611 (stringp (car val)))
5612 (apply 'gnus-or (mapcar `(lambda (s)
5613 (string-match s ,(or gnus-newsgroup-name "")))
5616 (let ((pred (pop val)))
5619 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5621 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5623 (not (gnus-treat-predicate (car val))))
5625 (equal (car val) type))
5627 (error "%S is not a valid predicate" pred)))))
5635 (eq part-number total-parts))
5639 (error "%S is not a valid value" val))))
5641 (defun gnus-article-encrypt-body (protocol &optional n)
5642 "Encrypt the article body."
5645 (or gnus-article-encrypt-protocol
5646 (completing-read "Encrypt protocol: "
5647 gnus-article-encrypt-protocol-alist
5649 current-prefix-arg))
5650 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5652 (error (format "Can't find the encrypt protocol %s" protocol)))
5653 (if (equal gnus-newsgroup-name "nndraft:drafts")
5654 (error "Can't encrypt the article in group nndraft:drafts"))
5655 (if (equal gnus-newsgroup-name "nndraft:queue")
5656 (error "Don't encrypt the article in group nndraft:queue"))
5657 (gnus-summary-iterate n
5659 (set-buffer gnus-summary-buffer)
5660 (let ((mail-parse-charset gnus-newsgroup-charset)
5661 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5662 (summary-buffer gnus-summary-buffer)
5664 (gnus-set-global-variables)
5665 (when (gnus-group-read-only-p)
5666 (error "The current newsgroup does not support article encrypt"))
5667 (gnus-summary-show-article t)
5669 (or (mail-header-references gnus-current-headers) ""))
5670 (set-buffer gnus-article-buffer)
5671 (let* ((buffer-read-only nil)
5673 (mapcar (lambda (field)
5674 (and (save-restriction
5675 (message-narrow-to-head)
5676 (goto-char (point-min))
5677 (search-forward field nil t))
5679 (message-narrow-to-field)
5680 (buffer-substring (point-min) (point-max))
5681 (delete-region (point-min) (point-max))
5683 '("Content-Type:" "Content-Transfer-Encoding:"
5684 "Content-Disposition:"))))
5685 (message-narrow-to-head)
5686 (message-remove-header "MIME-Version")
5687 (goto-char (point-max))
5688 (setq point (point))
5689 (insert (apply 'concat headers))
5691 (narrow-to-region point (point-max))
5692 (let ((message-options message-options))
5693 (message-options-set 'message-sender user-mail-address)
5694 (message-options-set 'message-recipients user-mail-address)
5695 (message-options-set 'message-sign-encrypt 'not)
5697 (goto-char (point-min))
5698 (insert "MIME-Version: 1.0\n")
5700 (gnus-summary-edit-article-done
5701 references nil summary-buffer t))
5702 (when gnus-keep-backlog
5703 (gnus-backlog-remove-article
5704 (car gnus-article-current) (cdr gnus-article-current)))
5706 (when (get-buffer gnus-original-article-buffer)
5707 (set-buffer gnus-original-article-buffer)
5708 (setq gnus-original-article nil)))
5709 (when gnus-use-cache
5710 (gnus-cache-update-article
5711 (car gnus-article-current) (cdr gnus-article-current))))))))
5713 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5714 "The following specs can be used:
5715 %t The security MIME type
5718 %D Details if button is pressed")
5720 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5721 "The following specs can be used:
5722 %t The security MIME type
5725 %D Details if button is pressed")
5727 (defvar gnus-mime-security-button-line-format-alist
5728 '((?t gnus-tmp-type ?s)
5729 (?i gnus-tmp-info ?s)
5730 (?d gnus-tmp-details ?s)
5731 (?D gnus-tmp-pressed-details ?s)))
5733 (defvar gnus-mime-security-button-map
5734 (let ((map (make-sparse-keymap)))
5735 (unless (>= (string-to-number emacs-version) 21)
5736 (set-keymap-parent map gnus-article-mode-map))
5737 (define-key map gnus-mouse-2 'gnus-article-push-button)
5738 (define-key map "\r" 'gnus-article-press-button)
5741 (defvar gnus-mime-security-details-buffer nil)
5743 (defvar gnus-mime-security-button-pressed nil)
5745 (defvar gnus-mime-security-show-details-inline t
5746 "If non-nil, show details in the article buffer.")
5748 (defun gnus-mime-security-verify-or-decrypt (handle)
5749 (mm-remove-parts (cdr handle))
5750 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5751 point buffer-read-only)
5753 (goto-char (car region)))
5755 (narrow-to-region (point) (point))
5756 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5757 (let* ((mm-verify-option 'known)
5758 (mm-decrypt-option 'known)
5759 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5760 (unless (eq nparts (cdr handle))
5761 (mm-destroy-parts (cdr handle))
5762 (setcdr handle nparts))))
5763 (setq point (point))
5764 (gnus-mime-display-security handle)
5765 (goto-char (point-max)))
5767 (delete-region (point) (cdr region))
5768 (set-marker (car region) nil)
5769 (set-marker (cdr region) nil))
5772 (defun gnus-mime-security-show-details (handle)
5773 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5775 (if gnus-mime-security-show-details-inline
5776 (let ((gnus-mime-security-button-pressed t)
5777 (gnus-mime-security-button-line-format
5778 (get-text-property (point) 'gnus-line-format))
5781 (while (eq (get-text-property (point) 'gnus-line-format)
5782 gnus-mime-security-button-line-format)
5786 (narrow-to-region (point) (point))
5787 (gnus-insert-mime-security-button handle))
5788 (delete-region (point)
5789 (or (text-property-not-all
5792 gnus-mime-security-button-line-format)
5794 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5795 (with-current-buffer gnus-mime-security-details-buffer
5798 (setq gnus-mime-security-details-buffer
5799 (gnus-get-buffer-create "*MIME Security Details*")))
5800 (with-current-buffer gnus-mime-security-details-buffer
5802 (goto-char (point-min)))
5803 (pop-to-buffer gnus-mime-security-details-buffer))
5804 (gnus-message 5 "No details."))))
5806 (defun gnus-mime-security-press-button (handle)
5807 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5808 (gnus-mime-security-show-details handle)
5809 (gnus-mime-security-verify-or-decrypt handle)))
5811 (defun gnus-insert-mime-security-button (handle &optional displayed)
5812 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5815 (or (nth 2 (assoc protocol mm-verify-function-alist))
5816 (nth 2 (assoc protocol mm-decrypt-function-alist))
5818 (if (equal (car handle) "multipart/signed")
5819 " Signed" " Encrypted")
5822 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5825 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5826 gnus-tmp-pressed-details
5828 (setq gnus-tmp-details
5829 (if gnus-tmp-details
5830 (concat "\n" gnus-tmp-details) ""))
5831 (setq gnus-tmp-pressed-details
5832 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5837 gnus-mime-security-button-line-format
5838 gnus-mime-security-button-line-format-alist
5839 `(keymap ,gnus-mime-security-button-map
5840 ,@(if (>= (string-to-number emacs-version) 21)
5841 nil ;; XEmacs doesn't care
5842 (list 'local-map gnus-mime-security-button-map))
5843 gnus-callback gnus-mime-security-press-button
5844 gnus-line-format ,gnus-mime-security-button-line-format
5845 article-type annotation
5848 (widget-convert-button
5851 :action 'gnus-widget-press-button
5852 :button-keymap gnus-mime-security-button-map
5854 (lambda (widget/window &optional overlay pos)
5855 ;; Needed to properly clear the message due to a bug in
5856 ;; wid-edit (XEmacs only).
5857 (if (boundp 'help-echo-owns-message)
5858 (setq help-echo-owns-message t))
5861 (aref gnus-mouse-2 0))))))
5863 (defun gnus-mime-display-security (handle)
5865 (narrow-to-region (point) (point))
5866 (unless (gnus-unbuttonized-mime-type-p (car handle))
5867 (gnus-insert-mime-security-button handle))
5868 (gnus-mime-display-mixed (cdr handle))
5871 (unless (gnus-unbuttonized-mime-type-p (car handle))
5872 (let ((gnus-mime-security-button-line-format
5873 gnus-mime-security-button-end-line-format))
5874 (gnus-insert-mime-security-button handle)))
5875 (mm-set-handle-multipart-parameter
5877 (cons (set-marker (make-marker) (point-min))
5878 (set-marker (make-marker) (point-max))))))
5884 (run-hooks 'gnus-art-load-hook)
5886 ;;; gnus-art.el ends here