1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
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))
42 (autoload 'gnus-msg-mail "gnus-msg" nil t)
43 (autoload 'gnus-button-mailto "gnus-msg")
44 (autoload 'gnus-button-reply "gnus-msg" nil t)
46 (defgroup gnus-article nil
48 :link '(custom-manual "(gnus)The Article Buffer")
51 (defgroup gnus-article-treat nil
52 "Treating article parts."
53 :link '(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-hiding nil
57 "Hiding article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-highlight nil
62 "Article highlighting."
63 :link '(custom-manual "(gnus)Article Highlighting")
67 (defgroup gnus-article-signature nil
69 :link '(custom-manual "(gnus)Article Signature")
72 (defgroup gnus-article-headers nil
74 :link '(custom-manual "(gnus)Hiding Headers")
77 (defgroup gnus-article-washing nil
78 "Special commands on articles."
79 :link '(custom-manual "(gnus)Article Washing")
82 (defgroup gnus-article-emphasis nil
83 "Fontisizing articles."
84 :link '(custom-manual "(gnus)Article Fontisizing")
87 (defgroup gnus-article-saving nil
89 :link '(custom-manual "(gnus)Saving Articles")
92 (defgroup gnus-article-mime nil
93 "Worshiping the MIME wonder."
94 :link '(custom-manual "(gnus)Using MIME")
97 (defgroup gnus-article-buttons nil
98 "Pushable buttons in the article buffer."
99 :link '(custom-manual "(gnus)Article Buttons")
100 :group 'gnus-article)
102 (defgroup gnus-article-various nil
103 "Other article options."
104 :link '(custom-manual "(gnus)Misc Article")
105 :group 'gnus-article)
107 (defcustom gnus-ignored-headers
108 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
109 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
110 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
111 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
112 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
113 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
114 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
115 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
116 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
117 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
118 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
119 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
120 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
121 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
122 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
123 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
124 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
125 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
126 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
127 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
128 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
129 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
130 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
131 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
132 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
133 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
134 "^X-Received:" "^Content-length:" "X-precedence:"
135 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
136 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "*All headers that start with this regexp will be hidden.
139 This variable can also be a list of regexps of headers to be ignored.
140 If `gnus-visible-headers' is non-nil, this variable will be ignored."
141 :type '(choice :custom-show nil
144 :group 'gnus-article-hiding)
146 (defcustom gnus-visible-headers
147 "^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:"
148 "*All headers that do not match this regexp will be hidden.
149 This variable can also be a list of regexp of headers to remain visible.
150 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
151 :type '(repeat :value-to-internal (lambda (widget value)
152 (custom-split-regexp-maybe value))
153 :match (lambda (widget value)
155 (widget-editable-list-match widget value)))
157 :group 'gnus-article-hiding)
159 (defcustom gnus-sorted-header-list
160 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
161 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
162 "*This variable is a list of regular expressions.
163 If it is non-nil, headers that match the regular expressions will
164 be placed first in the article buffer in the sequence specified by
166 :type '(repeat regexp)
167 :group 'gnus-article-hiding)
169 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
170 "Headers that are only to be displayed if they have interesting data.
171 Possible values in this list are `empty', `newsgroups', `followup-to',
172 `to-address', `reply-to', `date', `long-to', and `many-to'."
173 :type '(set (const :tag "Headers with no content." empty)
174 (const :tag "Newsgroups with only one group." newsgroups)
175 (const :tag "To identical to to-address." to-address)
176 (const :tag "Followup-to identical to newsgroups." followup-to)
177 (const :tag "Reply-to identical to from." reply-to)
178 (const :tag "Date less than four days old." date)
179 (const :tag "Very long To and/or Cc header." long-to)
180 (const :tag "Multiple To and/or Cc headers." many-to))
181 :group 'gnus-article-hiding)
183 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
184 "Regexp matching signature separator.
185 This can also be a list of regexps. In that case, it will be checked
186 from head to tail looking for a separator. Searches will be done from
187 the end of the buffer."
188 :type '(repeat string)
189 :group 'gnus-article-signature)
191 (defcustom gnus-signature-limit nil
192 "Provide a limit to what is considered a signature.
193 If it is a number, no signature may not be longer (in characters) than
194 that number. If it is a floating point number, no signature may be
195 longer (in lines) than that number. If it is a function, the function
196 will be called without any parameters, and if it returns nil, there is
197 no signature in the buffer. If it is a string, it will be used as a
198 regexp. If it matches, the text in question is not a signature."
199 :type '(choice (integer :value 200)
201 (function :value fun)
202 (regexp :value ".*"))
203 :group 'gnus-article-signature)
205 (defcustom gnus-hidden-properties '(invisible t intangible t)
206 "Property list to use for hiding text."
208 :group 'gnus-article-hiding)
210 ;; Fixme: This isn't the right thing for mixed graphical and and
211 ;; non-graphical frames in a session.
212 ;; gnus-xmas.el overrides this for XEmacs.
213 (defcustom gnus-article-x-face-command
214 (if (and (fboundp 'image-type-available-p)
215 (image-type-available-p 'xbm))
216 'gnus-article-display-xface
217 (if gnus-article-compface-xbm
218 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
219 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
221 "*String or function to be executed to display an X-Face header.
222 If it is a string, the command will be executed in a sub-shell
223 asynchronously. The compressed face will be piped to this command."
224 :type '(choice string
225 (function-item gnus-article-display-xface)
227 :group 'gnus-article-washing)
229 (defcustom gnus-article-x-face-too-ugly nil
230 "Regexp matching posters whose face shouldn't be shown automatically."
231 :type '(choice regexp (const nil))
232 :group 'gnus-article-washing)
234 (defcustom gnus-article-banner-alist nil
235 "Banner alist for stripping.
237 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
239 :type '(repeat (cons symbol regexp))
240 :group 'gnus-article-washing)
242 (gnus-define-group-parameter
245 "Alist of regexps (to match group names) and banner."
246 :variable-group gnus-article-washing
248 '(choice :tag "Banner"
250 (const :tag "Remove signature" signature)
251 (symbol :tag "Item in `gnus-article-banner-alist'" none)
253 (const :tag "None" nil))
255 "If non-nil, specify how to remove `banners' from articles.
257 Symbol `signature' means to remove signatures delimited by
258 `gnus-signature-separator'. Any other symbol is used to look up a
259 regular expression to match the banner in `gnus-article-banner-alist'.
260 A string is used as a regular expression to match the banner
263 (defcustom gnus-emphasis-alist
265 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
267 '(("_" "_" underline)
270 ("_/" "/_" underline-italic)
271 ("_\\*" "\\*_" underline-bold)
272 ("\\*/" "/\\*" bold-italic)
273 ("_\\*/" "/\\*_" underline-bold-italic))))
274 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
275 2 3 gnus-emphasis-underline)
279 (format format (car spec) (cadr spec))
280 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
282 "*Alist that says how to fontify certain phrases.
283 Each item looks like this:
285 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
287 The first element is a regular expression to be matched. The second
288 is a number that says what regular expression grouping used to find
289 the entire emphasized word. The third is a number that says what
290 regexp grouping should be displayed and highlighted. The fourth
291 is the face used for highlighting."
292 :type '(repeat (list :value ("" 0 0 default)
294 (integer :tag "Match group")
295 (integer :tag "Emphasize group")
297 :group 'gnus-article-emphasis)
299 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
300 "A regexp to describe whitespace which should not be emphasized.
301 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
302 The former avoids underlining of leading and trailing whitespace,
303 and the latter avoids underlining any whitespace at all."
305 :group 'gnus-article-emphasis
308 (defface gnus-emphasis-bold '((t (:bold t)))
309 "Face used for displaying strong emphasized text (*word*)."
310 :group 'gnus-article-emphasis)
312 (defface gnus-emphasis-italic '((t (:italic t)))
313 "Face used for displaying italic emphasized text (/word/)."
314 :group 'gnus-article-emphasis)
316 (defface gnus-emphasis-underline '((t (:underline t)))
317 "Face used for displaying underlined emphasized text (_word_)."
318 :group 'gnus-article-emphasis)
320 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
321 "Face used for displaying underlined bold emphasized text (_*word*_)."
322 :group 'gnus-article-emphasis)
324 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
325 "Face used for displaying underlined italic emphasized text (_/word/_)."
326 :group 'gnus-article-emphasis)
328 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
329 "Face used for displaying bold italic emphasized text (/*word*/)."
330 :group 'gnus-article-emphasis)
332 (defface gnus-emphasis-underline-bold-italic
333 '((t (:bold t :italic t :underline t)))
334 "Face used for displaying underlined bold italic emphasized text.
335 Esample: (_/*word*/_)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-highlight-words
339 '((t (:background "black" :foreground "yellow")))
340 "Face used for displaying highlighted words."
341 :group 'gnus-article-emphasis)
343 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
344 "Format for display of Date headers in article bodies.
345 See `format-time-string' for the possible values.
347 The variable can also be function, which should return a complete Date
348 header. The function is called with one argument, the time, which can
349 be fed to `format-time-string'."
350 :type '(choice string symbol)
351 :link '(custom-manual "(gnus)Article Date")
352 :group 'gnus-article-washing)
355 (autoload 'mail-extract-address-components "mail-extr"))
357 (defcustom gnus-save-all-headers t
358 "*If non-nil, don't remove any headers before saving."
359 :group 'gnus-article-saving
362 (defcustom gnus-prompt-before-saving 'always
363 "*This variable says how much prompting is to be done when saving articles.
364 If it is nil, no prompting will be done, and the articles will be
365 saved to the default files. If this variable is `always', each and
366 every article that is saved will be preceded by a prompt, even when
367 saving large batches of articles. If this variable is neither nil not
368 `always', there the user will be prompted once for a file name for
369 each invocation of the saving commands."
370 :group 'gnus-article-saving
371 :type '(choice (item always)
372 (item :tag "never" nil)
373 (sexp :tag "once" :format "%t\n" :value t)))
375 (defcustom gnus-saved-headers gnus-visible-headers
376 "Headers to keep if `gnus-save-all-headers' is nil.
377 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
378 If that variable is nil, however, all headers that match this regexp
379 will be kept while the rest will be deleted before saving."
380 :group 'gnus-article-saving
383 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
384 "A function to save articles in your favourite format.
385 The function must be interactively callable (in other words, it must
386 be an Emacs command).
388 Gnus provides the following functions:
390 * gnus-summary-save-in-rmail (Rmail format)
391 * gnus-summary-save-in-mail (Unix mail format)
392 * gnus-summary-save-in-folder (MH folder)
393 * gnus-summary-save-in-file (article format)
394 * gnus-summary-save-in-vm (use VM's folder format)
395 * gnus-summary-write-to-file (article format -- overwrite)."
396 :group 'gnus-article-saving
397 :type '(radio (function-item gnus-summary-save-in-rmail)
398 (function-item gnus-summary-save-in-mail)
399 (function-item gnus-summary-save-in-folder)
400 (function-item gnus-summary-save-in-file)
401 (function-item gnus-summary-save-in-vm)
402 (function-item gnus-summary-write-to-file)))
404 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
405 "A function generating a file name to save articles in Rmail format.
406 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
407 :group 'gnus-article-saving
410 (defcustom gnus-mail-save-name 'gnus-plain-save-name
411 "A function generating a file name to save articles in Unix mail format.
412 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
413 :group 'gnus-article-saving
416 (defcustom gnus-folder-save-name 'gnus-folder-save-name
417 "A function generating a file name to save articles in MH folder.
418 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
419 :group 'gnus-article-saving
422 (defcustom gnus-file-save-name 'gnus-numeric-save-name
423 "A function generating a file name to save articles in article format.
424 The function is called with NEWSGROUP, HEADERS, and optional
426 :group 'gnus-article-saving
429 (defcustom gnus-split-methods
430 '((gnus-article-archive-name)
431 (gnus-article-nndoc-name))
432 "*Variable used to suggest where articles are to be saved.
433 For instance, if you would like to save articles related to Gnus in
434 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
435 you could set this variable to something like:
437 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
438 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
440 This variable is an alist where the where the key is the match and the
441 value is a list of possible files to save in if the match is non-nil.
443 If the match is a string, it is used as a regexp match on the
444 article. If the match is a symbol, that symbol will be funcalled
445 from the buffer of the article to be saved with the newsgroup as the
446 parameter. If it is a list, it will be evaled in the same buffer.
448 If this form or function returns a string, this string will be used as
449 a possible file name; and if it returns a non-nil list, that list will
450 be used as possible file names."
451 :group 'gnus-article-saving
452 :type '(repeat (choice (list :value (fun) function)
453 (cons :value ("" "") regexp (repeat string))
456 (defcustom gnus-page-delimiter "^\^L"
457 "*Regexp describing what to use as article page delimiters.
458 The default value is \"^\^L\", which is a form linefeed at the
459 beginning of a line."
461 :group 'gnus-article-various)
463 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
464 "*The format specification for the article mode line.
465 See `gnus-summary-mode-line-format' for a closer description.
467 The following additional specs are available:
469 %w The article washing status.
470 %m The number of MIME parts in the article."
472 :group 'gnus-article-various)
474 (defcustom gnus-article-mode-hook nil
475 "*A hook for Gnus article mode."
477 :group 'gnus-article-various)
479 (when (featurep 'xemacs)
480 ;; Extracted from gnus-xmas-define in order to preserve user settings
481 (when (fboundp 'turn-off-scroll-in-place)
482 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
483 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
484 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
486 (defcustom gnus-article-menu-hook nil
487 "*Hook run after the creation of the article mode menu."
489 :group 'gnus-article-various)
491 (defcustom gnus-article-prepare-hook nil
492 "*A hook called after an article has been prepared in the article buffer."
494 :group 'gnus-article-various)
496 (defcustom gnus-article-hide-pgp-hook nil
497 "*A hook called after successfully hiding a PGP signature."
499 :group 'gnus-article-various)
501 (defcustom gnus-article-button-face 'bold
502 "Face used for highlighting buttons in the article buffer.
504 An article button is a piece of text that you can activate by pressing
505 `RET' or `mouse-2' above it."
507 :group 'gnus-article-buttons)
509 (defcustom gnus-article-mouse-face 'highlight
510 "Face used for mouse highlighting in the article buffer.
512 Article buttons will be displayed in this face when the cursor is
515 :group 'gnus-article-buttons)
517 (defcustom gnus-signature-face 'gnus-signature-face
518 "Face used for highlighting a signature in the article buffer.
519 Obsolete; use the face `gnus-signature-face' for customizations instead."
521 :group 'gnus-article-highlight
522 :group 'gnus-article-signature)
524 (defface gnus-signature-face
527 "Face used for highlighting a signature in the article buffer."
528 :group 'gnus-article-highlight
529 :group 'gnus-article-signature)
531 (defface gnus-header-from-face
534 (:foreground "spring green"))
537 (:foreground "red3"))
540 "Face used for displaying from headers."
541 :group 'gnus-article-headers
542 :group 'gnus-article-highlight)
544 (defface gnus-header-subject-face
547 (:foreground "SeaGreen3"))
550 (:foreground "red4"))
552 (:bold t :italic t)))
553 "Face used for displaying subject headers."
554 :group 'gnus-article-headers
555 :group 'gnus-article-highlight)
557 (defface gnus-header-newsgroups-face
560 (:foreground "yellow" :italic t))
563 (:foreground "MidnightBlue" :italic t))
566 "Face used for displaying newsgroups headers."
567 :group 'gnus-article-headers
568 :group 'gnus-article-highlight)
570 (defface gnus-header-name-face
573 (:foreground "SeaGreen"))
576 (:foreground "maroon"))
579 "Face used for displaying header names."
580 :group 'gnus-article-headers
581 :group 'gnus-article-highlight)
583 (defface gnus-header-content-face
586 (:foreground "forest green" :italic t))
589 (:foreground "indianred4" :italic t))
591 (:italic t))) "Face used for displaying header content."
592 :group 'gnus-article-headers
593 :group 'gnus-article-highlight)
595 (defcustom gnus-header-face-alist
596 '(("From" nil gnus-header-from-face)
597 ("Subject" nil gnus-header-subject-face)
598 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
599 ("" gnus-header-name-face gnus-header-content-face))
600 "*Controls highlighting of article header.
602 An alist of the form (HEADER NAME CONTENT).
604 HEADER is a regular expression which should match the name of an
605 header header and NAME and CONTENT are either face names or nil.
607 The name of each header field will be displayed using the face
608 specified by the first element in the list where HEADER match the
609 header name and NAME is non-nil. Similarly, the content will be
610 displayed by the first non-nil matching CONTENT face."
611 :group 'gnus-article-headers
612 :group 'gnus-article-highlight
613 :type '(repeat (list (regexp :tag "Header")
615 (item :tag "skip" nil)
616 (face :value default))
617 (choice :tag "Content"
618 (item :tag "skip" nil)
619 (face :value default)))))
621 (defcustom gnus-article-decode-hook
622 '(article-decode-charset article-decode-encoded-words)
623 "*Hook run to decode charsets in articles."
624 :group 'gnus-article-headers
627 (defcustom gnus-display-mime-function 'gnus-display-mime
628 "Function to display MIME articles."
629 :group 'gnus-article-mime
632 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
633 "Function used to decode headers.")
635 (defvar gnus-article-dumbquotes-map
654 "Table for MS-to-Latin1 translation.")
656 (defcustom gnus-ignored-mime-types nil
657 "List of MIME types that should be ignored by Gnus."
659 :group 'gnus-article-mime
660 :type '(repeat regexp))
662 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
663 "List of MIME types that should not be given buttons when rendered inline."
665 :group 'gnus-article-mime
666 :type '(repeat regexp))
668 (defcustom gnus-article-mime-part-function nil
669 "Function called with a MIME handle as the argument.
670 This is meant for people who want to do something automatic based
671 on parts -- for instance, adding Vcard info to a database."
672 :group 'gnus-article-mime
675 (defcustom gnus-mime-multipart-functions nil
676 "An alist of MIME types to functions to display them."
678 :group 'gnus-article-mime
681 (defcustom gnus-article-date-lapsed-new-header nil
682 "Whether the X-Sent and Date headers can coexist.
683 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
684 either replace the old \"Date:\" header (if this variable is nil), or
685 be added below it (otherwise)."
687 :group 'gnus-article-headers
690 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
691 "Function called with a MIME handle as the argument.
692 This is meant for people who want to view first matched part.
693 For `undisplayed-alternative' (default), the first undisplayed
694 part or alternative part is used. For `undisplayed', the first
695 undisplayed part is used. For a function, the first part which
696 the function return `t' is used. For `nil', the first part is
699 :group 'gnus-article-mime
701 (item :tag "first" :value nil)
702 (item :tag "undisplayed" :value undisplayed)
703 (item :tag "undisplayed or alternative"
704 :value undisplayed-alternative)
707 (defcustom gnus-mime-action-alist
708 '(("save to file" . gnus-mime-save-part)
709 ("save and strip" . gnus-mime-save-part-and-strip)
710 ("display as text" . gnus-mime-inline-part)
711 ("view the part" . gnus-mime-view-part)
712 ("pipe to command" . gnus-mime-pipe-part)
713 ("toggle display" . gnus-article-press-button)
714 ("toggle display" . gnus-article-view-part-as-charset)
715 ("view as type" . gnus-mime-view-part-as-type)
716 ("internalize type" . gnus-mime-internalize-part)
717 ("externalize type" . gnus-mime-externalize-part))
718 "An alist of actions that run on the MIME attachment."
719 :group 'gnus-article-mime
720 :type '(repeat (cons (string :tag "name")
723 (defcustom gnus-mime-action-alist
724 '(("save to file" . gnus-mime-save-part)
725 ("display as text" . gnus-mime-inline-part)
726 ("view the part" . gnus-mime-view-part)
727 ("pipe to command" . gnus-mime-pipe-part)
728 ("toggle display" . gnus-article-press-button)
729 ("view as type" . gnus-mime-view-part-as-type)
730 ("internalize type" . gnus-mime-internalize-part)
731 ("externalize type" . gnus-mime-externalize-part))
732 "An alist of actions that run on the MIME attachment."
734 :group 'gnus-article-mime
735 :type '(repeat (cons (string :tag "name")
739 ;;; The treatment variables
742 (defvar gnus-part-display-hook nil
743 "Hook called on parts that are to receive treatment.")
745 (defvar gnus-article-treat-custom
746 '(choice (const :tag "Off" nil)
748 (const :tag "Header" head)
749 (const :tag "Last" last)
750 (integer :tag "Less")
751 (repeat :tag "Groups" regexp)
752 (sexp :tag "Predicate")))
754 (defvar gnus-article-treat-head-custom
755 '(choice (const :tag "Off" nil)
756 (const :tag "Header" head)))
758 (defvar gnus-article-treat-types '("text/plain")
761 (defvar gnus-inhibit-treatment nil
762 "Whether to inhibit treatment.")
764 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
765 "Highlight the signature.
766 Valid values are nil, t, `head', `last', an integer or a predicate.
767 See the manual for details."
768 :group 'gnus-article-treat
769 :type gnus-article-treat-custom)
770 (put 'gnus-treat-highlight-signature 'highlight t)
772 (defcustom gnus-treat-buttonize 100000
774 Valid values are nil, t, `head', `last', an integer or a predicate.
775 See the manual for details."
776 :group 'gnus-article-treat
777 :type gnus-article-treat-custom)
778 (put 'gnus-treat-buttonize 'highlight t)
780 (defcustom gnus-treat-buttonize-head 'head
781 "Add buttons to the head.
782 Valid values are nil, t, `head', `last', an integer or a predicate.
783 See the manual for details."
784 :group 'gnus-article-treat
785 :type gnus-article-treat-head-custom)
786 (put 'gnus-treat-buttonize-head 'highlight t)
788 (defcustom gnus-treat-emphasize
789 (and (or window-system
791 (>= (string-to-number emacs-version) 21))
794 Valid values are nil, t, `head', `last', an integer or a predicate.
795 See the manual for details."
796 :group 'gnus-article-treat
797 :type gnus-article-treat-custom)
798 (put 'gnus-treat-emphasize 'highlight t)
800 (defcustom gnus-treat-strip-cr nil
801 "Remove carriage returns.
802 Valid values are nil, t, `head', `last', an integer or a predicate.
803 See the manual for details."
804 :group 'gnus-article-treat
805 :type gnus-article-treat-custom)
807 (defcustom gnus-treat-hide-headers 'head
809 Valid values are nil, t, `head', `last', an integer or a predicate.
810 See the manual for details."
811 :group 'gnus-article-treat
812 :type gnus-article-treat-head-custom)
814 (defcustom gnus-treat-hide-boring-headers nil
815 "Hide boring headers.
816 Valid values are nil, t, `head', `last', an integer or a predicate.
817 See the manual for details."
818 :group 'gnus-article-treat
819 :type gnus-article-treat-head-custom)
821 (defcustom gnus-treat-hide-signature nil
823 Valid values are nil, t, `head', `last', an integer or a predicate.
824 See the manual for details."
825 :group 'gnus-article-treat
826 :type gnus-article-treat-custom)
828 (defcustom gnus-treat-fill-article nil
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)
835 (defcustom gnus-treat-hide-citation nil
837 Valid values are nil, t, `head', `last', an integer or a predicate.
838 See the manual for details."
839 :group 'gnus-article-treat
840 :type gnus-article-treat-custom)
842 (defcustom gnus-treat-hide-citation-maybe nil
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See the manual for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
849 (defcustom gnus-treat-hide-citation-maybe nil
851 Valid values are nil, t, `head', `last', an integer or a predicate.
852 See the manual for details."
853 :group 'gnus-article-treat
854 :type gnus-article-treat-custom)
856 (defcustom gnus-treat-strip-list-identifiers 'head
857 "Strip list identifiers from `gnus-list-identifiers`.
858 Valid values are nil, t, `head', `last', an integer or a predicate.
859 See the manual for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-custom)
864 (defcustom gnus-treat-strip-pgp t
865 "Strip PGP signatures.
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-strip-pem nil
872 "Strip PEM signatures.
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-strip-banner t
879 "Strip banners from articles.
880 The banner to be stripped is specified in the `banner' group parameter.
881 Valid values are nil, t, `head', `last', an integer or a predicate.
882 See the manual for details."
883 :group 'gnus-article-treat
884 :type gnus-article-treat-custom)
886 (defcustom gnus-treat-highlight-headers 'head
887 "Highlight the headers.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See the manual for details."
890 :group 'gnus-article-treat
891 :type gnus-article-treat-head-custom)
892 (put 'gnus-treat-highlight-headers 'highlight t)
894 (defcustom gnus-treat-highlight-citation t
895 "Highlight cited text.
896 Valid values are nil, t, `head', `last', an integer or a predicate.
897 See the manual for details."
898 :group 'gnus-article-treat
899 :type gnus-article-treat-custom)
900 (put 'gnus-treat-highlight-citation 'highlight t)
902 (defcustom gnus-treat-date-ut nil
903 "Display the Date in UT (GMT).
904 Valid values are nil, t, `head', `last', an integer or a predicate.
905 See the manual for details."
906 :group 'gnus-article-treat
907 :type gnus-article-treat-head-custom)
909 (defcustom gnus-treat-date-local nil
910 "Display the Date in the local timezone.
911 Valid values are nil, t, `head', `last', an integer or a predicate.
912 See the manual for details."
913 :group 'gnus-article-treat
914 :type gnus-article-treat-head-custom)
916 (defcustom gnus-treat-date-english nil
917 "Display the Date in a format that can be read aloud in English.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See the manual for details."
920 :group 'gnus-article-treat
921 :type gnus-article-treat-head-custom)
923 (defcustom gnus-treat-date-lapsed nil
924 "Display the Date header in a way that says how much time has elapsed.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See the manual for details."
927 :group 'gnus-article-treat
928 :type gnus-article-treat-head-custom)
930 (defcustom gnus-treat-date-original nil
931 "Display the date in the original timezone.
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-head-custom)
937 (defcustom gnus-treat-date-iso8601 nil
938 "Display the date in the ISO8601 format.
939 Valid values are nil, t, `head', `last', an integer or a predicate.
940 See the manual for details."
942 :group 'gnus-article-treat
943 :type gnus-article-treat-head-custom)
945 (defcustom gnus-treat-date-user-defined nil
946 "Display the date in a user-defined format.
947 The format is defined by the `gnus-article-time-format' variable.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See the manual for details."
950 :group 'gnus-article-treat
951 :type gnus-article-treat-head-custom)
953 (defcustom gnus-treat-strip-headers-in-body t
954 "Strip the X-No-Archive header line from the beginning of the body.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See the manual for details."
958 :group 'gnus-article-treat
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-strip-trailing-blank-lines nil
962 "Strip trailing blank lines.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See the manual for details."
965 :group 'gnus-article-treat
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-strip-leading-blank-lines nil
969 "Strip leading blank lines.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See the manual for details."
972 :group 'gnus-article-treat
973 :type gnus-article-treat-custom)
975 (defcustom gnus-treat-strip-multiple-blank-lines nil
976 "Strip multiple blank lines.
977 Valid values are nil, t, `head', `last', an integer or a predicate.
978 See the manual for details."
979 :group 'gnus-article-treat
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-overstrike t
983 "Treat overstrike highlighting.
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-custom)
988 (put 'gnus-treat-overstrike 'highlight t)
990 (defcustom gnus-treat-display-xface
991 (and (or (and (fboundp 'image-type-available-p)
992 (image-type-available-p 'xbm)
993 (string-match "^0x" (shell-command-to-string "uncompface")))
994 (and (featurep 'xemacs) (featurep 'xface)))
996 "Display X-Face headers.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See the manual for details."
999 :group 'gnus-article-treat
1000 :type gnus-article-treat-head-custom)
1001 (put 'gnus-treat-display-xface 'highlight t)
1003 (defcustom gnus-treat-display-smileys
1004 (if (or (and (featurep 'xemacs)
1006 (and (fboundp 'image-type-available-p)
1007 (image-type-available-p 'pbm)))
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See the manual for details."
1012 :group 'gnus-article-treat
1013 :type gnus-article-treat-custom)
1014 (put 'gnus-treat-display-smileys 'highlight t)
1016 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1018 Valid values are nil, t, `head', `last', an integer or a predicate.
1019 See the manual for details."
1020 :group 'gnus-article-treat
1021 :type gnus-article-treat-head-custom)
1022 (put 'gnus-treat-display-picons 'highlight t)
1024 (defcustom gnus-treat-capitalize-sentences nil
1025 "Capitalize sentence-starting words.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See the manual for details."
1029 :group 'gnus-article-treat
1030 :type gnus-article-treat-custom)
1032 (defcustom gnus-treat-fill-long-lines nil
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-play-sounds nil
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See the manual for details."
1044 :group 'gnus-article-treat
1045 :type gnus-article-treat-custom)
1047 (defcustom gnus-treat-translate nil
1048 "Translate articles from one language to another.
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 See the manual for details."
1052 :group 'gnus-article-treat
1053 :type gnus-article-treat-custom)
1055 (defcustom gnus-treat-x-pgp-sig nil
1057 To automatically treat X-PGP-Sig, set it to head.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See the manual for details."
1060 :group 'gnus-article-treat
1061 :group 'mime-security
1062 :type gnus-article-treat-custom)
1064 (defvar gnus-article-encrypt-protocol-alist
1065 '(("PGP" . mml2015-self-encrypt)))
1067 ;; Set to nil if more than one protocol added to
1068 ;; gnus-article-encrypt-protocol-alist.
1069 (defcustom gnus-article-encrypt-protocol "PGP"
1070 "The protocol used for encrypt articles.
1071 It is a string, such as \"PGP\". If nil, ask user."
1073 :group 'mime-security)
1075 ;;; Internal variables
1077 (defvar gnus-english-month-names
1078 '("January" "February" "March" "April" "May" "June" "July" "August"
1079 "September" "October" "November" "December"))
1081 (defvar article-goto-body-goes-to-point-min-p nil)
1082 (defvar gnus-article-wash-types nil)
1083 (defvar gnus-article-emphasis-alist nil)
1085 (defvar gnus-article-mime-handle-alist-1 nil)
1086 (defvar gnus-treatment-function-alist
1087 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1088 (gnus-treat-strip-banner gnus-article-strip-banner)
1089 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1090 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1091 (gnus-treat-buttonize gnus-article-add-buttons)
1092 (gnus-treat-fill-article gnus-article-fill-cited-article)
1093 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1094 (gnus-treat-strip-cr gnus-article-remove-cr)
1095 (gnus-treat-emphasize gnus-article-emphasize)
1096 (gnus-treat-display-xface gnus-article-display-x-face)
1097 (gnus-treat-date-ut gnus-article-date-ut)
1098 (gnus-treat-date-local gnus-article-date-local)
1099 (gnus-treat-date-english gnus-article-date-english)
1100 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1101 (gnus-treat-date-original gnus-article-date-original)
1102 (gnus-treat-date-user-defined gnus-article-date-user)
1103 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1104 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1105 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1106 (gnus-treat-hide-signature gnus-article-hide-signature)
1107 (gnus-treat-hide-citation gnus-article-hide-citation)
1108 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1109 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1110 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1111 (gnus-treat-strip-pem gnus-article-hide-pem)
1112 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1113 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1114 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1115 (gnus-treat-strip-trailing-blank-lines
1116 gnus-article-remove-trailing-blank-lines)
1117 (gnus-treat-strip-leading-blank-lines
1118 gnus-article-strip-leading-blank-lines)
1119 (gnus-treat-strip-multiple-blank-lines
1120 gnus-article-strip-multiple-blank-lines)
1121 (gnus-treat-overstrike gnus-article-treat-overstrike)
1122 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1123 (gnus-treat-display-smileys gnus-smiley-display)
1124 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1125 (gnus-treat-display-picons gnus-article-display-picons)
1126 (gnus-treat-play-sounds gnus-earcon-display)))
1128 (defvar gnus-article-mime-handle-alist nil)
1129 (defvar article-lapsed-timer nil)
1130 (defvar gnus-article-current-summary nil)
1132 (defvar gnus-article-mode-syntax-table
1133 (let ((table (copy-syntax-table text-mode-syntax-table)))
1134 ;; This causes the citation match run O(2^n).
1135 ;; (modify-syntax-entry ?- "w" table)
1136 (modify-syntax-entry ?> ")" table)
1137 (modify-syntax-entry ?< "(" table)
1139 "Syntax table used in article mode buffers.
1140 Initialized from `text-mode-syntax-table.")
1142 (defvar gnus-save-article-buffer nil)
1144 (defvar gnus-article-mode-line-format-alist
1145 (nconc '((?w (gnus-article-wash-status) ?s)
1146 (?m (gnus-article-mime-part-status) ?s))
1147 gnus-summary-mode-line-format-alist))
1149 (defvar gnus-number-of-articles-to-be-saved nil)
1151 (defvar gnus-inhibit-hiding nil)
1153 (defsubst gnus-article-hide-text (b e props)
1154 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1155 (gnus-add-text-properties-when 'article-type nil b e props)
1156 (when (memq 'intangible props)
1158 (max (1- b) (point-min))
1159 b 'intangible (cddr (memq 'intangible props)))))
1161 (defsubst gnus-article-unhide-text (b e)
1162 "Remove hidden text properties from region between B and E."
1163 (remove-text-properties b e gnus-hidden-properties)
1164 (when (memq 'intangible gnus-hidden-properties)
1165 (put-text-property (max (1- b) (point-min))
1166 b 'intangible nil)))
1168 (defun gnus-article-hide-text-type (b e type)
1169 "Hide text of TYPE between B and E."
1170 (push type gnus-article-wash-types)
1171 (gnus-article-hide-text
1172 b e (cons 'article-type (cons type gnus-hidden-properties))))
1174 (defun gnus-article-unhide-text-type (b e type)
1175 "Unhide text of TYPE between B and E."
1176 (setq gnus-article-wash-types
1177 (delq type gnus-article-wash-types))
1178 (remove-text-properties
1179 b e (cons 'article-type (cons type gnus-hidden-properties)))
1180 (when (memq 'intangible gnus-hidden-properties)
1181 (put-text-property (max (1- b) (point-min))
1182 b 'intangible nil)))
1184 (defun gnus-article-hide-text-of-type (type)
1185 "Hide text of TYPE in the current buffer."
1187 (let ((b (point-min))
1189 (while (setq b (text-property-any b e 'article-type type))
1190 (add-text-properties b (incf b) gnus-hidden-properties)))))
1192 (defun gnus-article-delete-text-of-type (type)
1193 "Delete text of TYPE in the current buffer."
1195 (let ((b (point-min)))
1196 (while (setq b (text-property-any b (point-max) 'article-type type))
1198 b (or (text-property-not-all b (point-max) 'article-type type)
1201 (defun gnus-article-delete-invisible-text ()
1202 "Delete all invisible text in the current buffer."
1204 (let ((b (point-min)))
1205 (while (setq b (text-property-any b (point-max) 'invisible t))
1207 b (or (text-property-not-all b (point-max) 'invisible t)
1210 (defun gnus-article-text-type-exists-p (type)
1211 "Say whether any text of type TYPE exists in the buffer."
1212 (text-property-any (point-min) (point-max) 'article-type type))
1214 (defsubst gnus-article-header-rank ()
1215 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1216 (let ((list gnus-sorted-header-list)
1219 (when (looking-at (car list))
1221 (setq list (cdr list))
1225 (defun article-hide-headers (&optional arg delete)
1226 "Hide unwanted headers and possibly sort them as well."
1228 ;; This function might be inhibited.
1229 (unless gnus-inhibit-hiding
1232 (let ((buffer-read-only nil)
1233 (case-fold-search t)
1234 (max (1+ (length gnus-sorted-header-list)))
1235 (ignored (when (not gnus-visible-headers)
1236 (cond ((stringp gnus-ignored-headers)
1237 gnus-ignored-headers)
1238 ((listp gnus-ignored-headers)
1239 (mapconcat 'identity gnus-ignored-headers
1242 (cond ((stringp gnus-visible-headers)
1243 gnus-visible-headers)
1244 ((and gnus-visible-headers
1245 (listp gnus-visible-headers))
1246 (mapconcat 'identity gnus-visible-headers "\\|"))))
1247 (inhibit-point-motion-hooks t)
1249 ;; First we narrow to just the headers.
1250 (article-narrow-to-head)
1251 ;; Hide any "From " lines at the beginning of (mail) articles.
1252 (while (looking-at "From ")
1255 (delete-region (point-min) (point)))
1256 ;; Then treat the rest of the header lines.
1257 ;; Then we use the two regular expressions
1258 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1259 ;; select which header lines is to remain visible in the
1261 (while (re-search-forward "^[^ \t]*:" nil t)
1263 ;; Mark the rank of the header.
1265 (point) (1+ (point)) 'message-rank
1266 (if (or (and visible (looking-at visible))
1268 (not (looking-at ignored))))
1269 (gnus-article-header-rank)
1272 (message-sort-headers-1)
1273 (when (setq beg (text-property-any
1274 (point-min) (point-max) 'message-rank (+ 2 max)))
1275 ;; We delete the unwanted headers.
1276 (push 'headers gnus-article-wash-types)
1277 (add-text-properties (point-min) (+ 5 (point-min))
1278 '(article-type headers dummy-invisible t))
1279 (delete-region beg (point-max))))))))
1281 (defun article-hide-boring-headers (&optional arg)
1282 "Toggle hiding of headers that aren't very interesting.
1283 If given a negative prefix, always show; if given a positive prefix,
1285 (interactive (gnus-article-hidden-arg))
1286 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1287 (not gnus-show-all-headers))
1290 (let ((buffer-read-only nil)
1291 (list gnus-boring-article-headers)
1292 (inhibit-point-motion-hooks t)
1294 (article-narrow-to-head)
1296 (setq elem (pop list))
1297 (goto-char (point-min))
1299 ;; Hide empty headers.
1301 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1303 (gnus-article-hide-text-type
1304 (progn (beginning-of-line) (point))
1307 (if (re-search-forward "^[^ \t]" nil t)
1311 ;; Hide boring Newsgroups header.
1312 ((eq elem 'newsgroups)
1313 (when (equal (gnus-fetch-field "newsgroups")
1314 (gnus-group-real-name
1315 (if (boundp 'gnus-newsgroup-name)
1318 (gnus-article-hide-header "newsgroups")))
1319 ((eq elem 'to-address)
1320 (let ((to (message-fetch-field "to"))
1322 (gnus-group-find-parameter
1323 (if (boundp 'gnus-newsgroup-name)
1324 gnus-newsgroup-name "") 'to-address)))
1325 (when (and to to-address
1328 ;; only one address in To
1329 (nth 1 (mail-extract-address-components to))
1331 (gnus-article-hide-header "to"))))
1332 ((eq elem 'followup-to)
1333 (when (equal (message-fetch-field "followup-to")
1334 (message-fetch-field "newsgroups"))
1335 (gnus-article-hide-header "followup-to")))
1336 ((eq elem 'reply-to)
1337 (let ((from (message-fetch-field "from"))
1338 (reply-to (message-fetch-field "reply-to")))
1343 (nth 1 (mail-extract-address-components from))
1344 (nth 1 (mail-extract-address-components reply-to)))))
1345 (gnus-article-hide-header "reply-to"))))
1347 (let ((date (message-fetch-field "date")))
1349 (< (days-between (current-time-string) date)
1351 (gnus-article-hide-header "date"))))
1353 (let ((to (message-fetch-field "to"))
1354 (cc (message-fetch-field "cc")))
1355 (when (> (length to) 1024)
1356 (gnus-article-hide-header "to"))
1357 (when (> (length cc) 1024)
1358 (gnus-article-hide-header "cc"))))
1362 (goto-char (point-min))
1363 (while (re-search-forward "^to:" nil t)
1364 (setq to-count (1+ to-count)))
1365 (when (> to-count 1)
1366 (while (> to-count 0)
1367 (goto-char (point-min))
1369 (re-search-forward "^to:" nil nil to-count)
1371 (narrow-to-region (point) (point-max))
1372 (gnus-article-hide-header "to"))
1373 (setq to-count (1- to-count))))
1374 (goto-char (point-min))
1375 (while (re-search-forward "^cc:" nil t)
1376 (setq cc-count (1+ cc-count)))
1377 (when (> cc-count 1)
1378 (while (> cc-count 0)
1379 (goto-char (point-min))
1381 (re-search-forward "^cc:" nil nil cc-count)
1383 (narrow-to-region (point) (point-max))
1384 (gnus-article-hide-header "cc"))
1385 (setq cc-count (1- cc-count)))))))))))))
1387 (defun gnus-article-hide-header (header)
1389 (goto-char (point-min))
1390 (when (re-search-forward (concat "^" header ":") nil t)
1391 (gnus-article-hide-text-type
1392 (progn (beginning-of-line) (point))
1395 (if (re-search-forward "^[^ \t]" nil t)
1400 (defvar gnus-article-normalized-header-length 40
1401 "Length of normalized headers.")
1403 (defun article-normalize-headers ()
1404 "Make all header lines 40 characters long."
1406 (let ((buffer-read-only nil)
1410 (article-narrow-to-head)
1413 ((< (setq column (- (gnus-point-at-eol) (point)))
1414 gnus-article-normalized-header-length)
1416 (insert (make-string
1417 (- gnus-article-normalized-header-length column)
1419 ((> column gnus-article-normalized-header-length)
1420 (gnus-put-text-property
1422 (forward-char gnus-article-normalized-header-length)
1429 (forward-line 1))))))
1431 (defun article-treat-dumbquotes ()
1432 "Translate M****s*** sm*rtq**t*s into proper text.
1433 Note that this function guesses whether a character is a sm*rtq**t* or
1434 not, so it should only be used interactively.
1436 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1437 in an attempt to provide more quoting characters. If you see
1438 something like \\222 or \\264 where you're expecting some kind of
1439 apostrophe or quotation mark, then try this wash."
1441 (article-translate-strings gnus-article-dumbquotes-map))
1443 (defun article-translate-characters (from to)
1444 "Translate all characters in the body of the article according to FROM and TO.
1445 FROM is a string of characters to translate from; to is a string of
1446 characters to translate to."
1448 (when (article-goto-body)
1449 (let ((buffer-read-only nil)
1450 (x (make-string 225 ?x))
1452 (while (< (incf i) (length x))
1455 (while (< i (length from))
1456 (aset x (aref from i) (aref to i))
1458 (translate-region (point) (point-max) x)))))
1460 (defun article-translate-strings (map)
1461 "Translate all string in the body of the article according to MAP.
1462 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1464 (when (article-goto-body)
1465 (let ((buffer-read-only nil)
1467 (while (setq elem (pop map))
1469 (while (search-forward (car elem) nil t)
1470 (replace-match (cadr elem)))))))))
1472 (defun article-treat-overstrike ()
1473 "Translate overstrikes into bold text."
1476 (when (article-goto-body)
1477 (let ((buffer-read-only nil))
1478 (while (search-forward "\b" nil t)
1479 (let ((next (char-after))
1480 (previous (char-after (- (point) 2))))
1481 ;; We do the boldification/underlining by hiding the
1482 ;; overstrikes and putting the proper text property
1486 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1487 (put-text-property (point) (1+ (point)) 'face 'bold))
1489 (gnus-article-hide-text-type
1490 (1- (point)) (1+ (point)) 'overstrike)
1492 (- (point) 2) (1- (point)) 'face 'underline))
1494 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1496 (point) (1+ (point)) 'face 'underline)))))))))
1498 (defun article-fill-long-lines ()
1499 "Fill lines that are wider than the window width."
1502 (let ((buffer-read-only nil)
1503 (width (window-width (get-buffer-window (current-buffer)))))
1506 (let ((adaptive-fill-mode nil))
1509 (when (>= (current-column) (min fill-column width))
1510 (narrow-to-region (point) (gnus-point-at-bol))
1511 (fill-paragraph nil)
1512 (goto-char (point-max))
1514 (forward-line 1)))))))
1516 (defun article-capitalize-sentences ()
1517 "Capitalize the first word in each sentence."
1520 (let ((buffer-read-only nil)
1521 (paragraph-start "^[\n\^L]"))
1525 (forward-sentence)))))
1527 (defun article-remove-cr ()
1528 "Remove trailing CRs and then translate remaining CRs into LFs."
1531 (let ((buffer-read-only nil))
1532 (goto-char (point-min))
1533 (while (re-search-forward "\r+$" nil t)
1534 (replace-match "" t t))
1535 (goto-char (point-min))
1536 (while (search-forward "\r" nil t)
1537 (replace-match "\n" t t)))))
1539 (defun article-remove-trailing-blank-lines ()
1540 "Remove all trailing blank lines from the article."
1543 (let ((buffer-read-only nil))
1544 (goto-char (point-max))
1548 (while (and (not (bobp))
1549 (looking-at "^[ \t]*$")
1550 (not (gnus-annotation-in-region-p
1551 (point) (gnus-point-at-eol))))
1556 (defun article-display-x-face (&optional force)
1557 "Look for an X-Face header and display it if present."
1558 (interactive (list 'force))
1560 ;; Delete the old process, if any.
1561 (when (process-status "article-x-face")
1562 (delete-process "article-x-face"))
1563 (let ((inhibit-point-motion-hooks t)
1565 (case-fold-search t)
1568 (article-narrow-to-head)
1569 (when (and buffer-read-only ;; When type `W f'
1571 (goto-char (point-min))
1572 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1573 (gnus-buffer-live-p gnus-original-article-buffer))
1574 (with-current-buffer gnus-original-article-buffer
1576 (article-narrow-to-head)
1577 (while (re-search-forward "^X-Face:" nil t)
1583 (1- (re-search-forward
1584 "^\\($\\|[^ \t]\\)" nil t))))))))
1586 (let (point start bface eface buffer-read-only)
1587 (goto-char (point-max))
1589 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1590 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1591 (goto-char (point-max))
1592 (setq point (point))
1595 (while (looking-at "\\([^:]+\\): *")
1596 (put-text-property (match-beginning 1) (1+ (match-end 1))
1598 (setq start (match-end 0))
1600 (while (looking-at "[\t ]")
1602 (put-text-property start (point)
1604 (goto-char (point-min))
1605 (setq from (message-fetch-field "from"))
1606 (goto-char (point-min))
1607 (while (and gnus-article-x-face-command
1610 ;; Check whether this face is censored.
1611 (not gnus-article-x-face-too-ugly)
1612 (and gnus-article-x-face-too-ugly from
1613 (not (string-match gnus-article-x-face-too-ugly
1615 ;; Has to be present.
1616 (re-search-forward "^X-Face:[\t ]*" nil t))
1617 ;; This used to try to do multiple faces (`while' instead of
1618 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1619 ;; work (b) it can crash some versions of Emacs (c) are
1620 ;; multiple faces really something to encourage?
1621 (when (stringp gnus-article-x-face-command)
1623 ;; We now have the area of the buffer where the X-Face is stored.
1626 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1627 ;; We display the face.
1628 (if (symbolp gnus-article-x-face-command)
1629 ;; The command is a lisp function, so we call it.
1630 (if (gnus-functionp gnus-article-x-face-command)
1631 (funcall gnus-article-x-face-command beg end)
1632 (error "%s is not a function" gnus-article-x-face-command))
1633 ;; The command is a string, so we interpret the command
1634 ;; as a, well, command, and fork it off.
1635 (let ((process-connection-type nil))
1636 (process-kill-without-query
1638 "article-x-face" nil shell-file-name shell-command-switch
1639 gnus-article-x-face-command))
1640 (process-send-region "article-x-face" beg end)
1641 (process-send-eof "article-x-face"))))))))))
1643 (defun article-decode-mime-words ()
1644 "Decode all MIME-encoded words in the article."
1647 (set-buffer gnus-article-buffer)
1648 (let ((inhibit-point-motion-hooks t)
1650 (mail-parse-charset gnus-newsgroup-charset)
1651 (mail-parse-ignored-charsets
1652 (save-excursion (set-buffer gnus-summary-buffer)
1653 gnus-newsgroup-ignored-charsets)))
1654 (mail-decode-encoded-word-region (point-min) (point-max)))))
1656 (defun article-decode-charset (&optional prompt)
1657 "Decode charset-encoded text in the article.
1658 If PROMPT (the prefix), prompt for a coding system to use."
1660 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1662 (mail-parse-charset gnus-newsgroup-charset)
1663 (mail-parse-ignored-charsets
1664 (save-excursion (condition-case nil
1665 (set-buffer gnus-summary-buffer)
1667 gnus-newsgroup-ignored-charsets))
1668 ct cte ctl charset format)
1671 (article-narrow-to-head)
1672 (setq ct (message-fetch-field "Content-Type" t)
1673 cte (message-fetch-field "Content-Transfer-Encoding" t)
1674 ctl (and ct (ignore-errors
1675 (mail-header-parse-content-type ct)))
1678 (mm-read-coding-system "Charset to decode: "))
1680 (mail-content-type-get ctl 'charset)))
1681 format (and ctl (mail-content-type-get ctl 'format)))
1683 (setq cte (mail-header-strip cte)))
1684 (if (and ctl (not (string-match "/" (car ctl))))
1686 (goto-char (point-max)))
1689 (narrow-to-region (point) (point-max))
1690 (when (and (eq mail-parse-charset 'gnus-decoded)
1691 (eq (mm-body-7-or-8) '8bit))
1692 ;; The text code could have been decoded.
1693 (setq charset mail-parse-charset))
1694 (when (and (or (not ctl)
1695 (equal (car ctl) "text/plain"))
1696 (not format)) ;; article with format will decode later.
1698 charset (and cte (intern (downcase
1699 (gnus-strip-whitespace cte))))
1702 (defun article-decode-encoded-words ()
1703 "Remove encoded-word encoding from headers."
1704 (let ((inhibit-point-motion-hooks t)
1705 (mail-parse-charset gnus-newsgroup-charset)
1706 (mail-parse-ignored-charsets
1707 (save-excursion (condition-case nil
1708 (set-buffer gnus-summary-buffer)
1710 gnus-newsgroup-ignored-charsets))
1713 (article-narrow-to-head)
1714 (funcall gnus-decode-header-function (point-min) (point-max)))))
1716 (defun article-de-quoted-unreadable (&optional force)
1717 "Translate a quoted-printable-encoded article.
1718 If FORCE, decode the article whether it is marked as quoted-printable
1720 (interactive (list 'force))
1722 (let ((buffer-read-only nil) type charset)
1723 (if (gnus-buffer-live-p gnus-original-article-buffer)
1724 (with-current-buffer gnus-original-article-buffer
1726 (gnus-fetch-field "content-transfer-encoding"))
1727 (let* ((ct (gnus-fetch-field "content-type"))
1730 (mail-header-parse-content-type ct)))))
1731 (setq charset (and ctl
1732 (mail-content-type-get ctl 'charset)))
1733 (if (stringp charset)
1734 (setq charset (intern (downcase charset)))))))
1736 (setq charset gnus-newsgroup-charset))
1738 (and type (let ((case-fold-search t))
1739 (string-match "quoted-printable" type))))
1741 (quoted-printable-decode-region
1742 (point) (point-max) (mm-charset-to-coding-system charset))))))
1744 (defun article-de-base64-unreadable (&optional force)
1745 "Translate a base64 article.
1746 If FORCE, decode the article whether it is marked as base64 not."
1747 (interactive (list 'force))
1749 (let ((buffer-read-only nil) type charset)
1750 (if (gnus-buffer-live-p gnus-original-article-buffer)
1751 (with-current-buffer gnus-original-article-buffer
1753 (gnus-fetch-field "content-transfer-encoding"))
1754 (let* ((ct (gnus-fetch-field "content-type"))
1757 (mail-header-parse-content-type ct)))))
1758 (setq charset (and ctl
1759 (mail-content-type-get ctl 'charset)))
1760 (if (stringp charset)
1761 (setq charset (intern (downcase charset)))))))
1763 (setq charset gnus-newsgroup-charset))
1765 (and type (let ((case-fold-search t))
1766 (string-match "base64" type))))
1769 (narrow-to-region (point) (point-max))
1770 (base64-decode-region (point-min) (point-max))
1771 (mm-decode-coding-region
1772 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1777 (defun article-decode-HZ ()
1778 "Translate a HZ-encoded article."
1782 (let ((buffer-read-only nil))
1783 (rfc1843-decode-region (point-min) (point-max)))))
1785 (defun article-wash-html ()
1786 "Format an html article."
1789 (let ((buffer-read-only nil)
1791 (if (gnus-buffer-live-p gnus-original-article-buffer)
1792 (with-current-buffer gnus-original-article-buffer
1793 (let* ((ct (gnus-fetch-field "content-type"))
1796 (mail-header-parse-content-type ct)))))
1797 (setq charset (and ctl
1798 (mail-content-type-get ctl 'charset)))
1799 (if (stringp charset)
1800 (setq charset (intern (downcase charset)))))))
1802 (setq charset gnus-newsgroup-charset))
1804 (save-window-excursion
1806 (narrow-to-region (point) (point-max))
1808 (let ((w3-strict-width (window-width))
1809 (url-standalone-mode t))
1811 (w3-region (point-min) (point-max))
1814 (defun article-hide-list-identifiers ()
1815 "Remove list identifies from the Subject header.
1816 The `gnus-list-identifiers' variable specifies what to do."
1820 (let ((inhibit-point-motion-hooks t)
1822 (article-narrow-to-head)
1823 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1824 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1826 (goto-char (point-min))
1827 (when (re-search-forward
1828 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1829 " *\\)\\)+\\(Re: +\\)?\\)")
1831 (let ((s (or (match-string 3) (match-string 5))))
1832 (delete-region (match-beginning 1) (match-end 1))
1834 (goto-char (match-beginning 1))
1837 (defun article-hide-pgp ()
1838 "Remove any PGP headers and signatures in the current article."
1842 (let ((inhibit-point-motion-hooks t)
1843 buffer-read-only beg end)
1845 ;; Hide the "header".
1846 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1847 (push 'pgp gnus-article-wash-types)
1848 (delete-region (match-beginning 0) (match-end 0))
1849 ;; Remove armor headers (rfc2440 6.2)
1850 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1853 ;; Hide the actual signature.
1854 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1855 (setq end (1+ (match-beginning 0)))
1858 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1860 ;; Perhaps we shouldn't hide to the end of the buffer
1861 ;; if there is no end to the signature?
1863 ;; Hide "- " PGP quotation markers.
1865 (narrow-to-region beg end)
1866 (goto-char (point-min))
1867 (while (re-search-forward "^- " nil t)
1869 (match-beginning 0) (match-end 0)))
1871 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1873 (defun article-hide-pem (&optional arg)
1874 "Toggle hiding of any PEM headers and signatures in the current article.
1875 If given a negative prefix, always show; if given a positive prefix,
1877 (interactive (gnus-article-hidden-arg))
1878 (unless (gnus-article-check-hidden-text 'pem arg)
1880 (let (buffer-read-only end)
1881 (goto-char (point-min))
1882 ;; Hide the horrendously ugly "header".
1883 (when (and (search-forward
1884 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1886 (setq end (1+ (match-beginning 0))))
1887 (push 'pem gnus-article-wash-types)
1888 (gnus-article-hide-text-type
1890 (if (search-forward "\n\n" nil t)
1894 ;; Hide the trailer as well
1895 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1897 (gnus-article-hide-text-type
1898 (match-beginning 0) (match-end 0) 'pem)))))))
1900 (defun article-strip-banner ()
1901 "Strip the banner specified by the `banner' group parameter."
1905 (let ((inhibit-point-motion-hooks t)
1906 (banner (gnus-parameter-banner gnus-newsgroup-name))
1907 (gnus-signature-limit nil)
1908 buffer-read-only beg end)
1912 ((eq banner 'signature)
1913 (when (gnus-article-narrow-to-signature)
1916 (delete-region (point) (point-max))))
1918 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1919 (while (re-search-forward banner nil t)
1920 (delete-region (match-beginning 0) (match-end 0)))))
1922 (while (re-search-forward banner nil t)
1923 (delete-region (match-beginning 0) (match-end 0))))))))))
1925 (defun article-babel ()
1926 "Translate article using an online translation service."
1930 (set-buffer gnus-article-buffer)
1931 (when (article-goto-body)
1932 (let* ((buffer-read-only nil)
1935 (orig (buffer-substring start end))
1936 (trans (babel-as-string orig)))
1938 (narrow-to-region start end)
1939 (delete-region start end)
1942 (defun article-hide-signature (&optional arg)
1943 "Hide the signature in the current article.
1944 If given a negative prefix, always show; if given a positive prefix,
1946 (interactive (gnus-article-hidden-arg))
1947 (unless (gnus-article-check-hidden-text 'signature arg)
1950 (let ((buffer-read-only nil))
1951 (when (gnus-article-narrow-to-signature)
1952 (gnus-article-hide-text-type
1953 (point-min) (point-max) 'signature)))))))
1955 (defun article-strip-headers-in-body ()
1956 "Strip offensive headers from bodies."
1960 (let ((case-fold-search t))
1961 (when (looking-at "x-no-archive:")
1962 (gnus-delete-line)))))
1964 (defun article-strip-leading-blank-lines ()
1965 "Remove all blank lines from the beginning of the article."
1968 (let ((inhibit-point-motion-hooks t)
1970 (when (article-goto-body)
1971 (while (and (not (eobp))
1972 (looking-at "[ \t]*$"))
1973 (gnus-delete-line))))))
1975 (defun article-narrow-to-head ()
1976 "Narrow the buffer to the head of the message.
1977 Point is left at the beginning of the narrowed-to region."
1979 (goto-char (point-min))
1980 (if (search-forward "\n\n" nil 1)
1983 (goto-char (point-min)))
1985 (defun article-goto-body ()
1986 "Place point at the start of the body."
1987 (goto-char (point-min))
1989 ;; This variable is only bound when dealing with separate
1991 (article-goto-body-goes-to-point-min-p
1993 ((search-forward "\n\n" nil t)
1996 (goto-char (point-max))
1999 (defun article-strip-multiple-blank-lines ()
2000 "Replace consecutive blank lines with one empty line."
2003 (let ((inhibit-point-motion-hooks t)
2005 ;; First make all blank lines empty.
2007 (while (re-search-forward "^[ \t]+$" nil t)
2008 (unless (gnus-annotation-in-region-p
2009 (match-beginning 0) (match-end 0))
2010 (replace-match "" nil t)))
2011 ;; Then replace multiple empty lines with a single empty line.
2013 (while (re-search-forward "\n\n\n+" nil t)
2014 (unless (gnus-annotation-in-region-p
2015 (match-beginning 0) (match-end 0))
2016 (replace-match "\n\n" t t))))))
2018 (defun article-strip-leading-space ()
2019 "Remove all white space from the beginning of the lines in the article."
2022 (let ((inhibit-point-motion-hooks t)
2025 (while (re-search-forward "^[ \t]+" nil t)
2026 (replace-match "" t t)))))
2028 (defun article-strip-trailing-space ()
2029 "Remove all white space from the end of the lines in the article."
2032 (let ((inhibit-point-motion-hooks t)
2035 (while (re-search-forward "[ \t]+$" nil t)
2036 (replace-match "" t t)))))
2038 (defun article-strip-blank-lines ()
2039 "Strip leading, trailing and multiple blank lines."
2041 (article-strip-leading-blank-lines)
2042 (article-remove-trailing-blank-lines)
2043 (article-strip-multiple-blank-lines))
2045 (defun article-strip-all-blank-lines ()
2046 "Strip all blank lines."
2049 (let ((inhibit-point-motion-hooks t)
2052 (while (re-search-forward "^[ \t]*\n" nil t)
2053 (replace-match "" t t)))))
2055 (defun gnus-article-narrow-to-signature ()
2056 "Narrow to the signature; return t if a signature is found, else nil."
2057 (let ((inhibit-point-motion-hooks t))
2058 (when (gnus-article-search-signature)
2060 ;; Check whether we have some limits to what we consider
2061 ;; to be a signature.
2062 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2063 (list gnus-signature-limit)))
2065 (while (setq limit (pop limits))
2066 (if (or (and (integerp limit)
2067 (< (- (point-max) (point)) limit))
2069 (< (count-lines (point) (point-max)) limit))
2070 (and (gnus-functionp limit)
2072 (and (stringp limit)
2073 (not (re-search-forward limit nil t))))
2074 () ; This limit did not succeed.
2078 (narrow-to-region (point) (point-max))
2081 (defun gnus-article-search-signature ()
2082 "Search the current buffer for the signature separator.
2083 Put point at the beginning of the signature separator."
2084 (let ((cur (point)))
2085 (goto-char (point-max))
2086 (if (if (stringp gnus-signature-separator)
2087 (re-search-backward gnus-signature-separator nil t)
2088 (let ((seps gnus-signature-separator))
2090 (not (re-search-backward (car seps) nil t)))
2097 (defun gnus-article-hidden-arg ()
2098 "Return the current prefix arg as a number, or 0 if no prefix."
2099 (list (if current-prefix-arg
2100 (prefix-numeric-value current-prefix-arg)
2103 (defun gnus-article-check-hidden-text (type arg)
2104 "Return nil if hiding is necessary.
2105 Arg can be nil or a number. Nil and positive means hide, negative
2106 means show, 0 means toggle."
2109 (let ((hide (gnus-article-hidden-text-p type)))
2115 (gnus-article-show-hidden-text type)
2118 (if (eq hide 'hidden)
2120 (gnus-article-show-hidden-text type)
2124 (defun gnus-article-hidden-text-p (type)
2125 "Say whether the current buffer contains hidden text of type TYPE."
2126 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2128 (not (get-text-property pos 'invisible))
2129 (not (get-text-property pos 'dummy-invisible)))
2131 (text-property-any (1+ pos) (point-max) 'article-type type)))
2136 (defun gnus-article-show-hidden-text (type &optional dummy)
2137 "Show all hidden text of type TYPE.
2138 Originally it is hide instead of DUMMY."
2139 (let ((buffer-read-only nil)
2140 (inhibit-point-motion-hooks t))
2141 (gnus-remove-text-properties-when
2143 (point-min) (point-max)
2144 (cons 'article-type (cons type
2145 gnus-hidden-properties)))))
2147 (defconst article-time-units
2148 `((year . ,(* 365.25 24 60 60))
2149 (week . ,(* 7 24 60 60))
2150 (day . ,(* 24 60 60))
2154 "Mapping from time units to seconds.")
2156 (defun article-date-ut (&optional type highlight header)
2157 "Convert DATE date to universal time in the current article.
2158 If TYPE is `local', convert to local time; if it is `lapsed', output
2159 how much time has lapsed since DATE. For `lapsed', the value of
2160 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2161 should replace the \"Date:\" one, or should be added below it."
2162 (interactive (list 'ut t))
2163 (let* ((header (or header
2164 (message-fetch-field "date")
2166 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2169 ((not gnus-article-date-lapsed-new-header)
2175 (date (if (vectorp header) (mail-header-date header)
2177 (inhibit-point-motion-hooks t)
2182 (article-narrow-to-head)
2183 (when (re-search-forward tdate-regexp nil t)
2184 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2185 date (or (get-text-property (gnus-point-at-bol)
2188 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2190 (when (and date (not (string= date "")))
2191 (goto-char (point-min))
2192 (let ((buffer-read-only nil))
2193 ;; Delete any old Date headers.
2194 (while (re-search-forward date-regexp nil t)
2196 (delete-region (progn (beginning-of-line) (point))
2197 (progn (forward-line 1) (point)))
2198 (delete-region (progn (beginning-of-line) (point))
2199 (progn (end-of-line) (point)))
2200 (setq pos (point))))
2201 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2203 (if pos (goto-char pos))
2204 (insert (article-make-date-line date (or type 'ut)))
2210 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2211 (put-text-property (match-beginning 1) (1+ (match-end 1))
2212 'original-date date)
2213 (put-text-property (match-beginning 1) (1+ (match-end 1))
2215 (put-text-property (match-beginning 2) (match-end 2)
2218 (defun article-make-date-line (date type)
2219 "Return a DATE line of TYPE."
2220 (let ((time (condition-case ()
2224 ;; Convert to the local timezone. We have to slap a
2225 ;; `condition-case' round the calls to the timezone
2226 ;; functions since they aren't particularly resistant to
2229 (let ((tz (car (current-time-zone time))))
2230 (format "Date: %s %s%02d%02d" (current-time-string time)
2231 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2232 (/ (% (abs tz) 3600) 60))))
2233 ;; Convert to Universal Time.
2236 (current-time-string
2237 (let* ((e (parse-time-string date))
2238 (tm (apply 'encode-time e))
2240 (ls (- (cadr tm) (car (current-time-zone time)))))
2241 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2242 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2245 ;; Get the original date from the article.
2246 ((eq type 'original)
2247 (concat "Date: " (if (string-match "\n+$" date)
2248 (substring date 0 (match-beginning 0))
2250 ;; Let the user define the format.
2252 (if (gnus-functionp gnus-article-time-format)
2253 (funcall gnus-article-time-format time)
2256 (format-time-string gnus-article-time-format time))))
2259 (let ((tz (car (current-time-zone time))))
2262 (format-time-string "%Y%m%dT%H%M%S" time)
2263 (format "%s%02d%02d"
2264 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2265 (/ (% (abs tz) 3600) 60)))))
2266 ;; Do an X-Sent lapsed format.
2268 ;; If the date is seriously mangled, the timezone functions are
2269 ;; liable to bug out, so we ignore all errors.
2270 (let* ((now (current-time))
2271 (real-time (subtract-time now time))
2272 (real-sec (and real-time
2273 (+ (* (float (car real-time)) 65536)
2275 (sec (and real-time (abs real-sec)))
2285 ;; This is a bit convoluted, but basically we go
2286 ;; through the time units for years, weeks, etc,
2287 ;; and divide things to see whether that results
2288 ;; in positive answers.
2291 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2292 ;; The (remaining) seconds are too few to
2293 ;; be divided into this time unit.
2295 ;; It's big enough, so we output it.
2296 (setq sec (- sec (* num (cdr unit))))
2298 (concat (if prev ", " "") (int-to-string
2300 " " (symbol-name (car unit))
2301 (if (> num 1) "s" ""))
2303 article-time-units "")
2304 ;; If dates are odd, then it might appear like the
2305 ;; article was sent in the future.
2308 " in the future"))))))
2309 ;; Display the date in proper English
2311 (let ((dtime (decode-time time)))
2314 (number-to-string (nth 3 dtime))
2315 (let ((digit (% (nth 3 dtime) 10)))
2317 ((memq (nth 3 dtime) '(11 12 13)) "th")
2323 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2325 (number-to-string (nth 5 dtime))
2327 (format "%02d" (nth 2 dtime))
2329 (format "%02d" (nth 1 dtime)))))
2331 (error "Unknown conversion type: %s" type)))))
2333 (defun article-date-local (&optional highlight)
2334 "Convert the current article date to the local timezone."
2335 (interactive (list t))
2336 (article-date-ut 'local highlight))
2338 (defun article-date-english (&optional highlight)
2339 "Convert the current article date to something that is proper English."
2340 (interactive (list t))
2341 (article-date-ut 'english highlight))
2343 (defun article-date-original (&optional highlight)
2344 "Convert the current article date to what it was originally.
2345 This is only useful if you have used some other date conversion
2346 function and want to see what the date was before converting."
2347 (interactive (list t))
2348 (article-date-ut 'original highlight))
2350 (defun article-date-lapsed (&optional highlight)
2351 "Convert the current article date to time lapsed since it was sent."
2352 (interactive (list t))
2353 (article-date-ut 'lapsed highlight))
2355 (defun article-update-date-lapsed ()
2356 "Function to be run from a timer to update the lapsed time line."
2357 (let (deactivate-mark)
2362 (set-buffer (window-buffer w))
2363 (when (eq major-mode 'gnus-article-mode)
2364 (goto-char (point-min))
2365 (when (re-search-forward "^X-Sent:" nil t)
2366 (article-date-lapsed t))))
2369 (defun gnus-start-date-timer (&optional n)
2370 "Start a timer to update the X-Sent header in the article buffers.
2371 The numerical prefix says how frequently (in seconds) the function
2376 (gnus-stop-date-timer)
2377 (setq article-lapsed-timer
2378 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2380 (defun gnus-stop-date-timer ()
2381 "Stop the X-Sent timer."
2383 (when article-lapsed-timer
2384 (nnheader-cancel-timer article-lapsed-timer)
2385 (setq article-lapsed-timer nil)))
2387 (defun article-date-user (&optional highlight)
2388 "Convert the current article date to the user-defined format.
2389 This format is defined by the `gnus-article-time-format' variable."
2390 (interactive (list t))
2391 (article-date-ut 'user highlight))
2393 (defun article-date-iso8601 (&optional highlight)
2394 "Convert the current article date to ISO8601."
2395 (interactive (list t))
2396 (article-date-ut 'iso8601 highlight))
2398 (defun article-show-all ()
2399 "Show all hidden text in the article buffer."
2402 (let ((buffer-read-only nil))
2403 (gnus-article-unhide-text (point-min) (point-max)))))
2405 (defun article-emphasize (&optional arg)
2406 "Emphasize text according to `gnus-emphasis-alist'."
2407 (interactive (gnus-article-hidden-arg))
2408 (unless (gnus-article-check-hidden-text 'emphasis arg)
2412 (with-current-buffer gnus-summary-buffer
2413 gnus-article-emphasis-alist)
2415 gnus-emphasis-alist))
2416 (buffer-read-only nil)
2417 (props (append '(article-type emphasis)
2418 gnus-hidden-properties))
2419 regexp elem beg invisible visible face)
2422 (while (setq elem (pop alist))
2424 (setq regexp (car elem)
2425 invisible (nth 1 elem)
2426 visible (nth 2 elem)
2428 (while (re-search-forward regexp nil t)
2429 (when (and (match-beginning visible) (match-beginning invisible))
2430 (push 'emphasis gnus-article-wash-types)
2431 (gnus-article-hide-text
2432 (match-beginning invisible) (match-end invisible) props)
2433 (gnus-article-unhide-text-type
2434 (match-beginning visible) (match-end visible) 'emphasis)
2435 (gnus-put-text-property-excluding-newlines
2436 (match-beginning visible) (match-end visible) 'face face)
2437 (goto-char (match-end invisible)))))))))
2439 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2440 "Setup newsgroup emphasis alist."
2441 (unless gnus-article-emphasis-alist
2442 (let ((name (and gnus-newsgroup-name
2443 (gnus-group-real-name gnus-newsgroup-name))))
2444 (make-local-variable 'gnus-article-emphasis-alist)
2445 (setq gnus-article-emphasis-alist
2447 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2448 (while (setq elem (pop alist))
2449 (when (and name (string-match (car elem) name))
2451 highlight (copy-sequence (cdr elem)))))
2453 (copy-sequence highlight-words)
2454 (if gnus-newsgroup-name
2455 (copy-sequence (gnus-group-find-parameter
2456 gnus-newsgroup-name 'highlight-words t)))
2457 gnus-emphasis-alist)))))
2459 (defvar gnus-summary-article-menu)
2460 (defvar gnus-summary-post-menu)
2462 ;;; Saving functions.
2464 (defun gnus-article-save (save-buffer file &optional num)
2465 "Save the currently selected article."
2466 (unless gnus-save-all-headers
2467 ;; Remove headers according to `gnus-saved-headers'.
2468 (let ((gnus-visible-headers
2469 (or gnus-saved-headers gnus-visible-headers))
2470 (gnus-article-buffer save-buffer))
2472 (set-buffer save-buffer)
2473 (article-hide-headers 1 t))))
2474 (save-window-excursion
2475 (if (not gnus-default-article-saver)
2476 (error "No default saver is defined")
2477 ;; !!! Magic! The saving functions all save
2478 ;; `gnus-save-article-buffer' (or so they think), but we
2479 ;; bind that variable to our save-buffer.
2480 (set-buffer gnus-article-buffer)
2481 (let* ((gnus-save-article-buffer save-buffer)
2484 ((not gnus-prompt-before-saving) 'default)
2485 ((eq gnus-prompt-before-saving 'always) nil)
2487 (gnus-number-of-articles-to-be-saved
2488 (when (eq gnus-prompt-before-saving t)
2490 (set-buffer gnus-article-current-summary)
2491 (funcall gnus-default-article-saver filename)))))
2493 (defun gnus-read-save-file-name (prompt &optional filename
2494 function group headers variable)
2496 (funcall function group headers (symbol-value variable)))
2501 ((eq filename 'default)
2507 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2510 (if (and gnus-number-of-articles-to-be-saved
2511 (> gnus-number-of-articles-to-be-saved 1))
2512 (format "these %d articles"
2513 gnus-number-of-articles-to-be-saved)
2516 ;; Let the split methods have their say.
2518 ;; No split name was found.
2521 (concat prompt " (default "
2522 (file-name-nondirectory default-name) ") ")
2523 (file-name-directory default-name)
2525 ;; A single group name is returned.
2526 ((stringp split-name)
2528 (funcall function split-name headers
2529 (symbol-value variable)))
2531 (concat prompt " (default "
2532 (file-name-nondirectory default-name) ") ")
2533 (file-name-directory default-name)
2535 ;; A single split name was found
2536 ((= 1 (length split-name))
2537 (let* ((name (expand-file-name
2539 gnus-article-save-directory))
2540 (dir (cond ((file-directory-p name)
2541 (file-name-as-directory name))
2542 ((file-exists-p name) name)
2543 (t gnus-article-save-directory))))
2545 (concat prompt " (default " name ") ")
2547 ;; A list of splits was found.
2549 (setq split-name (nreverse split-name))
2551 (let ((file-name-history
2552 (nconc split-name file-name-history)))
2556 (concat prompt " (`M-p' for defaults) ")
2557 gnus-article-save-directory
2559 gnus-article-save-directory)))
2560 (car (push result file-name-history)))))))
2561 ;; Create the directory.
2562 (gnus-make-directory (file-name-directory file))
2563 ;; If we have read a directory, we append the default file name.
2564 (when (file-directory-p file)
2565 (setq file (expand-file-name (file-name-nondirectory
2567 (file-name-as-directory file))))
2568 ;; Possibly translate some characters.
2569 (nnheader-translate-file-chars file))))))
2570 (gnus-make-directory (file-name-directory result))
2571 (set variable result)))
2573 (defun gnus-article-archive-name (group)
2574 "Return the first instance of an \"Archive-name\" in the current buffer."
2575 (let ((case-fold-search t))
2576 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2577 (nnheader-concat gnus-article-save-directory
2578 (match-string 1)))))
2580 (defun gnus-article-nndoc-name (group)
2581 "If GROUP is an nndoc group, return the name of the parent group."
2582 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2583 (gnus-group-get-parameter group 'save-article-group)))
2585 (defun gnus-summary-save-in-rmail (&optional filename)
2586 "Append this article to Rmail file.
2587 Optional argument FILENAME specifies file name.
2588 Directory to save to is default to `gnus-article-save-directory'."
2589 (setq filename (gnus-read-save-file-name
2590 "Save %s in rmail file:" filename
2591 gnus-rmail-save-name gnus-newsgroup-name
2592 gnus-current-headers 'gnus-newsgroup-last-rmail))
2593 (gnus-eval-in-buffer-window gnus-save-article-buffer
2597 (gnus-output-to-rmail filename))))
2600 (defun gnus-summary-save-in-mail (&optional filename)
2601 "Append this article to Unix mail file.
2602 Optional argument FILENAME specifies file name.
2603 Directory to save to is default to `gnus-article-save-directory'."
2604 (setq filename (gnus-read-save-file-name
2605 "Save %s in Unix mail file:" filename
2606 gnus-mail-save-name gnus-newsgroup-name
2607 gnus-current-headers 'gnus-newsgroup-last-mail))
2608 (gnus-eval-in-buffer-window gnus-save-article-buffer
2612 (if (and (file-readable-p filename)
2613 (mail-file-babyl-p filename))
2614 (rmail-output-to-rmail-file filename t)
2615 (gnus-output-to-mail filename)))))
2618 (defun gnus-summary-save-in-file (&optional filename overwrite)
2619 "Append this article to file.
2620 Optional argument FILENAME specifies file name.
2621 Directory to save to is default to `gnus-article-save-directory'."
2622 (setq filename (gnus-read-save-file-name
2623 "Save %s in file:" filename
2624 gnus-file-save-name gnus-newsgroup-name
2625 gnus-current-headers 'gnus-newsgroup-last-file))
2626 (gnus-eval-in-buffer-window gnus-save-article-buffer
2630 (when (and overwrite
2631 (file-exists-p filename))
2632 (delete-file filename))
2633 (gnus-output-to-file filename))))
2636 (defun gnus-summary-write-to-file (&optional filename)
2637 "Write this article to a file.
2638 Optional argument FILENAME specifies file name.
2639 The directory to save in defaults to `gnus-article-save-directory'."
2640 (gnus-summary-save-in-file nil t))
2642 (defun gnus-summary-save-body-in-file (&optional filename)
2643 "Append this article body to a file.
2644 Optional argument FILENAME specifies file name.
2645 The directory to save in defaults to `gnus-article-save-directory'."
2646 (setq filename (gnus-read-save-file-name
2647 "Save %s body in file:" filename
2648 gnus-file-save-name gnus-newsgroup-name
2649 gnus-current-headers 'gnus-newsgroup-last-file))
2650 (gnus-eval-in-buffer-window gnus-save-article-buffer
2654 (when (article-goto-body)
2655 (narrow-to-region (point) (point-max)))
2656 (gnus-output-to-file filename))))
2659 (defun gnus-summary-save-in-pipe (&optional command)
2660 "Pipe this article to subprocess."
2662 (cond ((and (eq command 'default)
2663 gnus-last-shell-command)
2664 gnus-last-shell-command)
2669 "Shell command on %s: "
2670 (if (and gnus-number-of-articles-to-be-saved
2671 (> gnus-number-of-articles-to-be-saved 1))
2672 (format "these %d articles"
2673 gnus-number-of-articles-to-be-saved)
2675 gnus-last-shell-command))))
2676 (when (string-equal command "")
2677 (if gnus-last-shell-command
2678 (setq command gnus-last-shell-command)
2679 (error "A command is required.")))
2680 (gnus-eval-in-buffer-window gnus-article-buffer
2683 (shell-command-on-region (point-min) (point-max) command nil)))
2684 (setq gnus-last-shell-command command))
2686 ;;; Article file names when saving.
2688 (defun gnus-capitalize-newsgroup (newsgroup)
2689 "Capitalize NEWSGROUP name."
2690 (when (not (zerop (length newsgroup)))
2691 (concat (char-to-string (upcase (aref newsgroup 0)))
2692 (substring newsgroup 1))))
2694 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2695 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2696 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2697 Otherwise, it is like ~/News/news/group/num."
2700 (concat (if (gnus-use-long-file-name 'not-save)
2701 (gnus-capitalize-newsgroup newsgroup)
2702 (gnus-newsgroup-directory-form newsgroup))
2703 "/" (int-to-string (mail-header-number headers)))
2704 gnus-article-save-directory)))
2706 (string-equal (file-name-directory default)
2707 (file-name-directory last-file))
2708 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2710 (or last-file default))))
2712 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2713 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2714 If variable `gnus-use-long-file-name' is non-nil, it is
2715 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2718 (concat (if (gnus-use-long-file-name 'not-save)
2720 (gnus-newsgroup-directory-form newsgroup))
2721 "/" (int-to-string (mail-header-number headers)))
2722 gnus-article-save-directory)))
2724 (string-equal (file-name-directory default)
2725 (file-name-directory last-file))
2726 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2728 (or last-file default))))
2730 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2731 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2732 If variable `gnus-use-long-file-name' is non-nil, it is
2733 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2736 (if (gnus-use-long-file-name 'not-save)
2738 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2739 gnus-article-save-directory)))
2741 (defun article-verify-x-pgp-sig ()
2744 (if (gnus-buffer-live-p gnus-original-article-buffer)
2745 (let ((sig (with-current-buffer gnus-original-article-buffer
2746 (gnus-fetch-field "X-PGP-Sig")))
2750 (mml2015-clear-verify-function))
2752 (insert-buffer gnus-original-article-buffer)
2753 (setq items (split-string sig))
2754 (message-narrow-to-head)
2755 (let ((inhibit-point-motion-hooks t)
2756 (case-fold-search t))
2757 ;; Don't verify multiple headers.
2758 (setq headers (mapconcat (lambda (header)
2760 (mail-fetch-field header) "\n"))
2761 (split-string (nth 1 items) ",") "")))
2762 (delete-region (point-min) (point-max))
2763 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2764 (insert "X-Signed-Headers: " (nth 1 items) "\n")
2769 (if (looking-at "^-")
2772 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
2773 (insert "Version: " (car items) "\n\n")
2774 (insert (mapconcat 'identity (cddr items) "\n"))
2775 (insert "\n-----END PGP SIGNATURE-----\n")
2776 (let ((mm-security-handle (list (format "multipart/signed"))))
2777 (mml2015-clean-buffer)
2778 (let ((coding-system-for-write (or gnus-newsgroup-charset
2780 (funcall (mml2015-clear-verify-function)))
2782 (or (mm-handle-multipart-ctl-parameter
2783 mm-security-handle 'gnus-details)
2784 (mm-handle-multipart-ctl-parameter
2785 mm-security-handle 'gnus-info)))))
2787 (let (buffer-read-only bface eface)
2789 (message-narrow-to-head)
2790 (goto-char (point-max))
2792 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2793 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2794 (message-remove-header "X-Gnus-PGP-Verify")
2795 (if (re-search-forward "^X-PGP-Sig:" nil t)
2797 (goto-char (point-max)))
2798 (narrow-to-region (point) (point))
2799 (insert "X-Gnus-PGP-Verify: " info "\n")
2800 (goto-char (point-min))
2803 (if (not (looking-at "^[ \t]"))
2807 (goto-char (point-min))
2808 (when (looking-at "\\([^:]+\\): *")
2809 (put-text-property (match-beginning 1) (1+ (match-end 1))
2811 (put-text-property (match-end 0) (point-max)
2812 'face eface)))))))))
2819 (setq afunc (car func)
2822 gfunc (intern (format "gnus-%s" func))))
2825 `(lambda (&optional interactive &rest args)
2826 ,(documentation afunc t)
2827 (interactive (list t))
2829 (set-buffer gnus-article-buffer)
2831 (call-interactively ',afunc)
2832 (apply ',afunc args))))))))
2833 '(article-hide-headers
2834 article-verify-x-pgp-sig
2835 article-hide-boring-headers
2836 article-treat-overstrike
2837 article-fill-long-lines
2838 article-capitalize-sentences
2840 article-display-x-face
2841 article-de-quoted-unreadable
2842 article-de-base64-unreadable
2845 article-hide-list-identifiers
2847 article-strip-banner
2850 article-hide-signature
2851 article-strip-headers-in-body
2852 article-remove-trailing-blank-lines
2853 article-strip-leading-blank-lines
2854 article-strip-multiple-blank-lines
2855 article-strip-leading-space
2856 article-strip-trailing-space
2857 article-strip-blank-lines
2858 article-strip-all-blank-lines
2860 article-date-english
2861 article-date-iso8601
2862 article-date-original
2864 article-decode-mime-words
2865 article-decode-charset
2866 article-decode-encoded-words
2870 article-treat-dumbquotes
2871 article-normalize-headers
2872 (article-show-all . gnus-article-show-all-headers))))
2875 ;;; Gnus article mode
2878 (put 'gnus-article-mode 'mode-class 'special)
2880 (set-keymap-parent gnus-article-mode-map widget-keymap)
2882 (gnus-define-keys gnus-article-mode-map
2883 " " gnus-article-goto-next-page
2884 "\177" gnus-article-goto-prev-page
2885 [delete] gnus-article-goto-prev-page
2886 [backspace] gnus-article-goto-prev-page
2887 "\C-c^" gnus-article-refer-article
2888 "h" gnus-article-show-summary
2889 "s" gnus-article-show-summary
2890 "\C-c\C-m" gnus-article-mail
2891 "?" gnus-article-describe-briefly
2892 "e" gnus-summary-edit-article
2893 "<" beginning-of-buffer
2895 "\C-c\C-i" gnus-info-find-node
2897 "\C-hk" gnus-article-describe-key
2898 "\C-hc" gnus-article-describe-key-briefly
2900 "\C-d" gnus-article-read-summary-keys
2901 "\M-*" gnus-article-read-summary-keys
2902 "\M-#" gnus-article-read-summary-keys
2903 "\M-^" gnus-article-read-summary-keys
2904 "\M-g" gnus-article-read-summary-keys)
2906 (substitute-key-definition
2907 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2910 (defvar gnus-article-commands-menu))
2912 (defun gnus-article-make-menu-bar ()
2913 (gnus-turn-off-edit-menu 'article)
2914 (unless (boundp 'gnus-article-article-menu)
2916 gnus-article-article-menu gnus-article-mode-map ""
2918 ["Scroll forwards" gnus-article-goto-next-page t]
2919 ["Scroll backwards" gnus-article-goto-prev-page t]
2920 ["Show summary" gnus-article-show-summary t]
2921 ["Fetch Message-ID at point" gnus-article-refer-article t]
2922 ["Mail to address at point" gnus-article-mail t]
2923 ["Send a bug report" gnus-bug t]))
2926 gnus-article-treatment-menu gnus-article-mode-map ""
2927 ;; Fixme: this should use :active (and maybe :visible).
2929 ["Hide headers" gnus-article-hide-headers t]
2930 ["Hide signature" gnus-article-hide-signature t]
2931 ["Hide citation" gnus-article-hide-citation t]
2932 ["Treat overstrike" gnus-article-treat-overstrike t]
2933 ["Remove carriage return" gnus-article-remove-cr t]
2934 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2935 ["Remove base64" gnus-article-de-base64-unreadable t]
2936 ["Treat html" gnus-article-wash-html t]
2937 ["Decode HZ" gnus-article-decode-HZ t]))
2939 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2941 (when (boundp 'gnus-summary-post-menu)
2942 (define-key gnus-article-mode-map [menu-bar post]
2943 (cons "Post" gnus-summary-post-menu)))
2945 (gnus-run-hooks 'gnus-article-menu-hook))
2947 (when (boundp 'gnus-article-commands-menu)
2948 (easy-menu-add gnus-article-commands-menu gnus-article-mode-map))
2949 (when (boundp 'gnus-summary-post-menu)
2950 (easy-menu-add gnus-summary-post-menu gnus-article-mode-map)))
2952 ;; Fixme: do something for the Emacs tool bar in Article mode a la
2955 (defun gnus-article-mode ()
2956 "Major mode for displaying an article.
2958 All normal editing commands are switched off.
2960 The following commands are available in addition to all summary mode
2962 \\<gnus-article-mode-map>
2963 \\[gnus-article-next-page]\t Scroll the article one page forwards
2964 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2965 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2966 \\[gnus-article-show-summary]\t Display the summary buffer
2967 \\[gnus-article-mail]\t Send a reply to the address near point
2968 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2969 \\[gnus-info-find-node]\t Go to the Gnus info node"
2971 (when (gnus-visual-p 'article-menu 'menu)
2972 (gnus-article-make-menu-bar))
2973 (gnus-simplify-mode-line)
2974 (setq mode-name "Article")
2975 (setq major-mode 'gnus-article-mode)
2976 (make-local-variable 'minor-mode-alist)
2977 (use-local-map gnus-article-mode-map)
2978 (gnus-update-format-specifications nil 'article-mode)
2979 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2980 (make-local-variable 'gnus-page-broken)
2981 (make-local-variable 'gnus-button-marker-list)
2982 (make-local-variable 'gnus-article-current-summary)
2983 (make-local-variable 'gnus-article-mime-handles)
2984 (make-local-variable 'gnus-article-decoded-p)
2985 (make-local-variable 'gnus-article-mime-handle-alist)
2986 (make-local-variable 'gnus-article-wash-types)
2987 (make-local-variable 'gnus-article-charset)
2988 (make-local-variable 'gnus-article-ignored-charsets)
2989 (gnus-set-default-directory)
2990 (buffer-disable-undo)
2991 (setq buffer-read-only t)
2992 (set-syntax-table gnus-article-mode-syntax-table)
2993 (mm-enable-multibyte)
2994 (gnus-run-hooks 'gnus-article-mode-hook))
2996 (defun gnus-article-setup-buffer ()
2997 "Initialize the article buffer."
2998 (let* ((name (if gnus-single-article-buffer "*Article*"
2999 (concat "*Article " gnus-newsgroup-name "*")))
3001 (progn (string-match "\\*Article" name)
3002 (concat " *Original Article"
3003 (substring name (match-end 0))))))
3004 (setq gnus-article-buffer name)
3005 (setq gnus-original-article-buffer original)
3006 (setq gnus-article-mime-handle-alist nil)
3007 ;; This might be a variable local to the summary buffer.
3008 (unless gnus-single-article-buffer
3010 (set-buffer gnus-summary-buffer)
3011 (setq gnus-article-buffer name)
3012 (setq gnus-original-article-buffer original)
3013 (gnus-set-global-variables)))
3014 (gnus-article-setup-highlight-words)
3015 ;; Init original article buffer.
3017 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3018 (mm-enable-multibyte)
3019 (setq major-mode 'gnus-original-article-mode)
3020 (make-local-variable 'gnus-original-article))
3021 (if (get-buffer name)
3024 (when gnus-article-mime-handles
3025 (mm-destroy-parts gnus-article-mime-handles)
3026 (setq gnus-article-mime-handles nil))
3027 ;; Set it to nil in article-buffer!
3028 (setq gnus-article-mime-handle-alist nil)
3029 (buffer-disable-undo)
3030 (setq buffer-read-only t)
3031 (unless (eq major-mode 'gnus-article-mode)
3032 (gnus-article-mode))
3035 (set-buffer (gnus-get-buffer-create name))
3037 (make-local-variable 'gnus-summary-buffer)
3038 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3039 (current-buffer)))))
3041 ;; Set article window start at LINE, where LINE is the number of lines
3042 ;; from the head of the article.
3043 (defun gnus-article-set-window-start (&optional line)
3045 (get-buffer-window gnus-article-buffer t)
3047 (set-buffer gnus-article-buffer)
3048 (goto-char (point-min))
3051 (gnus-message 6 "Moved to bookmark")
3052 (search-forward "\n\n" nil t)
3056 (defun gnus-article-prepare (article &optional all-headers header)
3057 "Prepare ARTICLE in article mode buffer.
3058 ARTICLE should either be an article number or a Message-ID.
3059 If ARTICLE is an id, HEADER should be the article headers.
3060 If ALL-HEADERS is non-nil, no headers are hidden."
3062 ;; Make sure we start in a summary buffer.
3063 (unless (eq major-mode 'gnus-summary-mode)
3064 (set-buffer gnus-summary-buffer))
3065 (setq gnus-summary-buffer (current-buffer))
3066 (let* ((gnus-article (if header (mail-header-number header) article))
3067 (summary-buffer (current-buffer))
3068 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3069 (group gnus-newsgroup-name)
3072 (gnus-article-setup-buffer)
3073 (set-buffer gnus-article-buffer)
3074 ;; Deactivate active regions.
3075 (when (and (boundp 'transient-mark-mode)
3076 transient-mark-mode)
3077 (setq mark-active nil))
3078 (if (not (setq result (let ((buffer-read-only nil))
3079 (gnus-request-article-this-buffer
3081 ;; There is no such article.
3083 (when (and (numberp article)
3084 (not (memq article gnus-newsgroup-sparse)))
3085 (setq gnus-article-current
3086 (cons gnus-newsgroup-name article))
3087 (set-buffer gnus-summary-buffer)
3088 (setq gnus-current-article article)
3089 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3091 (gnus-summary-set-agent-mark article)
3092 (message "Message marked for downloading"))
3093 (gnus-summary-mark-article article gnus-canceled-mark)
3094 (unless (memq article gnus-newsgroup-sparse)
3095 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3096 (if (or (eq result 'pseudo)
3097 (eq result 'nneething))
3100 (set-buffer summary-buffer)
3101 (push article gnus-newsgroup-history)
3102 (setq gnus-last-article gnus-current-article
3103 gnus-current-article 0
3104 gnus-current-headers nil
3105 gnus-article-current nil)
3106 (if (eq result 'nneething)
3107 (gnus-configure-windows 'summary)
3108 (gnus-configure-windows 'article))
3109 (gnus-set-global-variables))
3110 (let ((gnus-article-mime-handle-alist-1
3111 gnus-article-mime-handle-alist))
3112 (gnus-set-mode-line 'article)))
3113 ;; The result from the `request' was an actual article -
3114 ;; or at least some text that is now displayed in the
3116 (when (and (numberp article)
3117 (not (eq article gnus-current-article)))
3118 ;; Seems like a new article has been selected.
3119 ;; `gnus-current-article' must be an article number.
3121 (set-buffer summary-buffer)
3122 (push article gnus-newsgroup-history)
3123 (setq gnus-last-article gnus-current-article
3124 gnus-current-article article
3125 gnus-current-headers
3126 (gnus-summary-article-header gnus-current-article)
3127 gnus-article-current
3128 (cons gnus-newsgroup-name gnus-current-article))
3129 (unless (vectorp gnus-current-headers)
3130 (setq gnus-current-headers nil))
3131 (gnus-summary-goto-subject gnus-current-article)
3132 (when (gnus-summary-show-thread)
3133 ;; If the summary buffer really was folded, the
3134 ;; previous goto may not actually have gone to
3135 ;; the right article, but the thread root instead.
3137 (gnus-summary-goto-subject gnus-current-article))
3138 (gnus-run-hooks 'gnus-mark-article-hook)
3139 (gnus-set-mode-line 'summary)
3140 (when (gnus-visual-p 'article-highlight 'highlight)
3141 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3142 ;; Set the global newsgroup variables here.
3143 (gnus-set-global-variables)
3144 (setq gnus-have-all-headers
3145 (or all-headers gnus-show-all-headers))))
3147 (gnus-configure-windows 'article))
3148 (when (or (numberp article)
3150 (gnus-article-prepare-display)
3152 (goto-char (point-min))
3153 (setq gnus-page-broken
3154 (when gnus-break-pages
3155 (gnus-narrow-to-page)
3157 (let ((gnus-article-mime-handle-alist-1
3158 gnus-article-mime-handle-alist))
3159 (gnus-set-mode-line 'article))
3161 (set-window-point (get-buffer-window (current-buffer)) (point))
3162 (gnus-configure-windows 'article)
3166 (defun gnus-article-prepare-display ()
3167 "Make the current buffer look like a nice article."
3168 ;; Hooks for getting information from the article.
3169 ;; This hook must be called before being narrowed.
3170 (let ((gnus-article-buffer (current-buffer))
3172 (unless (eq major-mode 'gnus-article-mode)
3173 (gnus-article-mode))
3174 (setq buffer-read-only nil
3175 gnus-article-wash-types nil)
3176 (gnus-run-hooks 'gnus-tmp-internal-hook)
3177 (when gnus-display-mime-function
3178 (funcall gnus-display-mime-function))
3179 (gnus-run-hooks 'gnus-article-prepare-hook)))
3182 ;;; Gnus MIME viewing functions
3185 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3186 "The following specs can be used:
3188 %T MIME type, along with additional info
3189 %n The `name' parameter
3190 %d The description, if any
3191 %l The length of the encoded part
3192 %p The part identifier number
3193 %e Dots if the part isn't displayed")
3195 (defvar gnus-mime-button-line-format-alist
3196 '((?t gnus-tmp-type ?s)
3197 (?T gnus-tmp-type-long ?s)
3198 (?n gnus-tmp-name ?s)
3199 (?d gnus-tmp-description ?s)
3201 (?l gnus-tmp-length ?d)
3202 (?e gnus-tmp-dots ?s)))
3204 (defvar gnus-mime-button-commands
3205 '((gnus-article-press-button "\r" "Toggle Display")
3206 (gnus-mime-view-part "v" "View Interactively...")
3207 (gnus-mime-view-part-as-type "t" "View As Type...")
3208 (gnus-mime-view-part-as-charset "C" "View As charset...")
3209 (gnus-mime-save-part "o" "Save...")
3210 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3211 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3212 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3213 (gnus-mime-internalize-part "E" "View Internally")
3214 (gnus-mime-externalize-part "e" "View Externally")
3215 (gnus-mime-pipe-part "|" "Pipe To Command...")
3216 (gnus-mime-action-on-part "." "Take action on the part")))
3218 (defun gnus-article-mime-part-status ()
3219 (if gnus-article-mime-handle-alist-1
3220 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
3223 (defvar gnus-mime-button-map
3224 (let ((map (make-sparse-keymap)))
3225 (unless (>= (string-to-number emacs-version) 21)
3226 ;; XEmacs doesn't care.
3227 (set-keymap-parent map gnus-article-mode-map))
3228 (define-key map gnus-mouse-2 'gnus-article-push-button)
3229 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3230 (dolist (c gnus-mime-button-commands)
3231 (define-key map (cadr c) (car c)))
3234 (defun gnus-mime-button-menu (event)
3235 "Construct a context-sensitive menu of MIME commands."
3237 (save-window-excursion
3238 (let ((pos (event-start event)))
3239 (select-window (posn-window pos))
3240 (goto-char (posn-point pos))
3241 (gnus-article-check-buffer)
3242 (let ((response (x-popup-menu
3244 ("" ,@(mapcar (lambda (c)
3245 (cons (caddr c) (car c)))
3246 gnus-mime-button-commands))))))
3248 (call-interactively response))))))
3250 (defun gnus-mime-view-all-parts (&optional handles)
3251 "View all the MIME parts."
3253 (save-current-buffer
3254 (set-buffer gnus-article-buffer)
3255 (let ((handles (or handles gnus-article-mime-handles))
3256 (mail-parse-charset gnus-newsgroup-charset)
3257 (mail-parse-ignored-charsets
3258 (with-current-buffer gnus-summary-buffer
3259 gnus-newsgroup-ignored-charsets)))
3261 (mm-remove-parts handles)
3262 (goto-char (point-min))
3263 (or (search-forward "\n\n") (goto-char (point-max)))
3264 (let (buffer-read-only)
3265 (delete-region (point) (point-max)))
3266 (mm-display-parts handles)))))
3268 (defun gnus-mime-save-part-and-strip ()
3269 "Save the MIME part under point then replace it with an external body."
3271 (gnus-article-check-buffer)
3272 (let* ((data (get-text-property (point) 'gnus-data))
3273 (file (and data (mm-save-part data)))
3276 (with-current-buffer (mm-handle-buffer data)
3278 (insert "Content-Type: " (mm-handle-media-type data))
3279 (mml-insert-parameter-string (cdr (mm-handle-type data))
3282 (insert "Content-ID: " (message-make-message-id) "\n")
3283 (insert "Content-Transfer-Encoding: binary\n")
3286 (cdr (mm-make-handle nil
3287 `("message/external-body"
3288 (access-type . "LOCAL-FILE")
3290 (set-buffer gnus-summary-buffer)
3291 (gnus-article-edit-article
3294 (let ((mail-parse-charset (or gnus-article-charset
3295 ',gnus-newsgroup-charset))
3296 (mail-parse-ignored-charsets
3297 (or gnus-article-ignored-charsets
3298 ',gnus-newsgroup-ignored-charsets))
3299 (mbl mml-buffer-list))
3300 (setq mml-buffer-list nil)
3301 (insert-buffer gnus-original-article-buffer)
3302 (mime-to-mml gnus-article-mime-handles)
3303 (setq gnus-article-mime-handles nil)
3304 (make-local-hook 'kill-buffer-hook)
3305 (let ((mbl1 mml-buffer-list))
3306 (setq mml-buffer-list mbl)
3307 (set (make-local-variable 'mml-buffer-list) mbl1))
3308 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3309 `(lambda (no-highlight)
3310 (let ((mail-parse-charset (or gnus-article-charset
3311 ',gnus-newsgroup-charset))
3312 (message-options message-options)
3313 (message-options-set-recipient)
3314 (mail-parse-ignored-charsets
3315 (or gnus-article-ignored-charsets
3316 ',gnus-newsgroup-ignored-charsets)))
3318 (mml-destroy-buffers)
3319 (remove-hook 'kill-buffer-hook
3320 'mml-destroy-buffers t)
3321 (kill-local-variable 'mml-buffer-list))
3322 (gnus-summary-edit-article-done
3323 ,(or (mail-header-references gnus-current-headers) "")
3324 ,(gnus-group-read-only-p)
3325 ,gnus-summary-buffer no-highlight))))))
3327 (defun gnus-mime-save-part ()
3328 "Save the MIME part under point."
3330 (gnus-article-check-buffer)
3331 (let ((data (get-text-property (point) 'gnus-data)))
3333 (mm-save-part data))))
3335 (defun gnus-mime-pipe-part ()
3336 "Pipe the MIME part under point to a process."
3338 (gnus-article-check-buffer)
3339 (let ((data (get-text-property (point) 'gnus-data)))
3341 (mm-pipe-part data))))
3343 (defun gnus-mime-view-part ()
3344 "Interactively choose a viewing method for the MIME part under point."
3346 (gnus-article-check-buffer)
3347 (let ((data (get-text-property (point) 'gnus-data)))
3349 (push (setq data (copy-sequence data)) gnus-article-mime-handles)
3350 (mm-interactively-view-part data))))
3352 (defun gnus-mime-view-part-as-type-internal ()
3353 (gnus-article-check-buffer)
3354 (let* ((name (mail-content-type-get
3355 (mm-handle-type (get-text-property (point) 'gnus-data))
3357 (def-type (and name (mm-default-file-encoding name))))
3358 (and def-type (cons def-type 0))))
3360 (defun gnus-mime-view-part-as-type (&optional mime-type)
3361 "Choose a MIME media type, and view the part as such."
3364 (setq mime-type (completing-read
3365 "View as MIME type: "
3366 (mapcar #'list (mailcap-mime-types))
3368 (gnus-mime-view-part-as-type-internal))))
3369 (gnus-article-check-buffer)
3370 (let ((handle (get-text-property (point) 'gnus-data)))
3373 (mm-make-handle (mm-handle-buffer handle)
3374 (cons mime-type (cdr (mm-handle-type handle)))
3375 (mm-handle-encoding handle)
3376 (mm-handle-undisplayer handle)
3377 (mm-handle-disposition handle)
3378 (mm-handle-description handle)
3379 (mm-handle-cache handle)
3380 (mm-handle-id handle)))
3381 (push handle gnus-article-mime-handles)
3382 (gnus-mm-display-part handle))))
3384 (defun gnus-mime-copy-part (&optional handle)
3385 "Put the the MIME part under point into a new buffer."
3387 (gnus-article-check-buffer)
3388 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3389 (contents (and handle (mm-get-part handle)))
3391 (file-name-nondirectory
3393 (mail-content-type-get (mm-handle-type handle) 'name)
3394 (mail-content-type-get (mm-handle-type handle)
3397 (buffer (and base (generate-new-buffer base))))
3399 (switch-to-buffer buffer)
3401 ;; We do it this way to make `normal-mode' set the appropriate mode.
3404 (setq buffer-file-name (expand-file-name base))
3406 (setq buffer-file-name nil))
3407 (goto-char (point-min)))))
3409 (defun gnus-mime-inline-part (&optional handle arg)
3410 "Insert the MIME part under point into the current buffer."
3411 (interactive (list nil current-prefix-arg))
3412 (gnus-article-check-buffer)
3413 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3418 (if (and (not arg) (mm-handle-undisplayer handle))
3419 (mm-remove-part handle)
3420 (setq contents (mm-get-part handle))
3423 (setq charset (or (mail-content-type-get
3424 (mm-handle-type handle) 'charset)
3425 gnus-newsgroup-charset)))
3427 (if (mm-handle-undisplayer handle)
3428 (mm-remove-part handle))
3431 gnus-summary-show-article-charset-alist))
3432 (read-coding-system "Charset: ")))))
3434 (mm-insert-inline handle
3436 (setq charset (mm-charset-to-coding-system
3438 (not (eq charset 'ascii)))
3439 (mm-decode-coding-string contents charset)
3443 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3444 "Insert the MIME part under point into the current buffer."
3445 (interactive (list nil current-prefix-arg))
3446 (gnus-article-check-buffer)
3447 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3452 (if (mm-handle-undisplayer handle)
3453 (mm-remove-part handle))
3454 (let ((gnus-newsgroup-charset
3456 gnus-summary-show-article-charset-alist))
3457 (read-coding-system "Charset: ")))
3458 (gnus-newsgroup-ignored-charsets 'gnus-all))
3459 (gnus-article-press-button)))))
3461 (defun gnus-mime-externalize-part (&optional handle)
3462 "View the MIME part under point with an external viewer."
3464 (gnus-article-check-buffer)
3465 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3466 (mm-user-display-methods nil)
3467 (mm-inlined-types nil)
3468 (mail-parse-charset gnus-newsgroup-charset)
3469 (mail-parse-ignored-charsets
3470 (save-excursion (set-buffer gnus-summary-buffer)
3471 gnus-newsgroup-ignored-charsets)))
3473 (if (mm-handle-undisplayer handle)
3474 (mm-remove-part handle)
3475 (mm-display-part handle)))))
3477 (defun gnus-mime-internalize-part (&optional handle)
3478 "View the MIME part under point with an internal viewer.
3479 In no internal viewer is available, use an external viewer."
3481 (gnus-article-check-buffer)
3482 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3483 (mm-inlined-types '(".*"))
3484 (mm-inline-large-images t)
3485 (mail-parse-charset gnus-newsgroup-charset)
3486 (mail-parse-ignored-charsets
3487 (save-excursion (set-buffer gnus-summary-buffer)
3488 gnus-newsgroup-ignored-charsets)))
3490 (if (mm-handle-undisplayer handle)
3491 (mm-remove-part handle)
3492 (mm-display-part handle)))))
3494 (defun gnus-mime-action-on-part (&optional action)
3495 "Do something with the MIME attachment at \(point\)."
3497 (list (completing-read "Action: " gnus-mime-action-alist)))
3498 (gnus-article-check-buffer)
3499 (let ((action-pair (assoc action gnus-mime-action-alist)))
3501 (funcall (cdr action-pair)))))
3503 (defun gnus-article-part-wrapper (n function)
3504 (save-current-buffer
3505 (set-buffer gnus-article-buffer)
3506 (when (> n (length gnus-article-mime-handle-alist))
3507 (error "No such part"))
3508 (gnus-article-goto-part n)
3509 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3510 (funcall function handle))))
3512 (defun gnus-article-pipe-part (n)
3513 "Pipe MIME part N, which is the numerical prefix."
3515 (gnus-article-part-wrapper n 'mm-pipe-part))
3517 (defun gnus-article-save-part (n)
3518 "Save MIME part N, which is the numerical prefix."
3520 (gnus-article-part-wrapper n 'mm-save-part))
3522 (defun gnus-article-interactively-view-part (n)
3523 "View MIME part N interactively, which is the numerical prefix."
3525 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3527 (defun gnus-article-copy-part (n)
3528 "Copy MIME part N, which is the numerical prefix."
3530 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3532 (defun gnus-article-view-part-as-charset (n)
3533 "Copy MIME part N, which is the numerical prefix."
3535 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3537 (defun gnus-article-externalize-part (n)
3538 "View MIME part N externally, which is the numerical prefix."
3540 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3542 (defun gnus-article-inline-part (n)
3543 "Inline MIME part N, which is the numerical prefix."
3545 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3547 (defun gnus-article-mime-match-handle-first (condition)
3549 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3550 (while (setq ihandle (pop alist))
3552 ((functionp condition)
3553 (funcall condition (cdr ihandle)))
3554 ((eq condition 'undisplayed)
3555 (not (or (mm-handle-undisplayer (cdr ihandle))
3556 (equal (mm-handle-media-type (cdr ihandle))
3557 "multipart/alternative"))))
3558 ((eq condition 'undisplayed-alternative)
3559 (not (mm-handle-undisplayer (cdr ihandle))))
3561 (gnus-article-goto-part (car ihandle))
3562 (or (not n) (< (car ihandle) n)))
3563 (setq n (car ihandle))))
3567 (defun gnus-article-view-part (&optional n)
3568 "View MIME part N, which is the numerical prefix."
3570 (save-current-buffer
3571 (set-buffer gnus-article-buffer)
3572 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3573 gnus-article-mime-match-handle-function)))
3574 (when (> n (length gnus-article-mime-handle-alist))
3575 (error "No such part"))
3576 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3577 (when (gnus-article-goto-part n)
3578 (if (equal (car handle) "multipart/alternative")
3579 (gnus-article-press-button)
3580 (when (eq (gnus-mm-display-part handle) 'internal)
3581 (gnus-set-window-start)))))))
3583 (defsubst gnus-article-mime-total-parts ()
3584 (if (bufferp (car gnus-article-mime-handles))
3586 (1- (length gnus-article-mime-handles))))
3588 (defun gnus-mm-display-part (handle)
3589 "Display HANDLE and fix MIME button."
3590 (let ((id (get-text-property (point) 'gnus-part))
3595 (let ((window (selected-window))
3596 (mail-parse-charset gnus-newsgroup-charset)
3597 (mail-parse-ignored-charsets
3598 (save-excursion (set-buffer gnus-summary-buffer)
3599 gnus-newsgroup-ignored-charsets)))
3602 (let ((win (get-buffer-window (current-buffer) t))
3605 (select-window win))
3608 (if (mm-handle-displayed-p handle)
3609 ;; This will remove the part.
3610 (mm-display-part handle)
3612 (narrow-to-region (point) (1+ (point)))
3613 (mm-display-part handle)
3614 ;; We narrow to the part itself and
3615 ;; then call the treatment functions.
3616 (goto-char (point-min))
3618 (narrow-to-region (point) (point-max))
3621 (gnus-article-mime-total-parts)
3622 (mm-handle-media-type handle)))))
3623 (select-window window))))
3625 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3626 (gnus-insert-mime-button
3627 handle id (list (mm-handle-displayed-p handle)))
3628 (goto-char point))))
3630 (defun gnus-article-goto-part (n)
3631 "Go to MIME part N."
3632 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3634 (goto-char point))))
3636 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3637 (let ((gnus-tmp-name
3638 (or (mail-content-type-get (mm-handle-type handle)
3640 (mail-content-type-get (mm-handle-disposition handle)
3642 (mail-content-type-get (mm-handle-type handle)
3645 (gnus-tmp-type (mm-handle-media-type handle))
3646 (gnus-tmp-description
3647 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3650 (if (if displayed (car displayed)
3651 (mm-handle-displayed-p handle))
3653 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3655 gnus-tmp-type-long b e)
3656 (when (string-match ".*/" gnus-tmp-name)
3657 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3658 (setq gnus-tmp-type-long (concat gnus-tmp-type
3659 (and (not (equal gnus-tmp-name ""))
3660 (concat "; " gnus-tmp-name))))
3661 (or (equal gnus-tmp-description "")
3662 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3667 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3668 `(keymap ,gnus-mime-button-map
3669 ,@(if (>= (string-to-number emacs-version) 21)
3671 (list 'local-map gnus-mime-button-map))
3672 gnus-callback gnus-mm-display-part
3673 gnus-part ,gnus-tmp-id
3674 article-type annotation
3677 (widget-convert-button
3680 :action 'gnus-widget-press-button
3681 :button-keymap gnus-mime-button-map
3683 (lambda (widget/window &optional overlay pos)
3684 ;; Needed to properly clear the message due to a bug in
3685 ;; wid-edit (XEmacs only).
3686 (if (boundp 'help-echo-owns-message)
3687 (setq help-echo-owns-message t))
3689 "%S: %s the MIME part; %S: more options"
3690 (aref gnus-mouse-2 0)
3691 ;; XEmacs will get a single widget arg; Emacs 21 will get
3692 ;; window, overlay, position.
3693 (if (mm-handle-displayed-p
3695 (with-current-buffer (gnus-overlay-buffer overlay)
3696 (widget-get (widget-at (gnus-overlay-start overlay))
3698 (widget-get widget/window :mime-handle)))
3700 (aref gnus-down-mouse-3 0))))))
3702 (defun gnus-widget-press-button (elems el)
3703 (goto-char (widget-get elems :from))
3704 (gnus-article-press-button))
3706 (defvar gnus-displaying-mime nil)
3708 (defun gnus-display-mime (&optional ihandles)
3709 "Display the MIME parts."
3711 (save-selected-window
3712 (let ((window (get-buffer-window gnus-article-buffer))
3715 (select-window window)
3716 ;; We have to do this since selecting the window
3717 ;; may change the point. So we set the window point.
3718 (set-window-point window point)))
3719 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3720 buffer-read-only handle name type b e display)
3721 (when (and (not ihandles)
3722 (not gnus-displaying-mime))
3723 ;; Top-level call; we clean up.
3724 (when gnus-article-mime-handles
3725 (mm-destroy-parts gnus-article-mime-handles)
3726 (setq gnus-article-mime-handle-alist nil));; A trick.
3727 (setq gnus-article-mime-handles handles)
3728 ;; We allow users to glean info from the handles.
3729 (when gnus-article-mime-part-function
3730 (gnus-mime-part-function handles)))
3732 (or (not (stringp (car handles)))
3735 (when (and (not ihandles)
3736 (not gnus-displaying-mime))
3737 ;; Clean up for mime parts.
3739 (delete-region (point) (point-max)))
3740 (let ((gnus-displaying-mime t))
3741 (gnus-mime-display-part handles)))
3744 (narrow-to-region (point) (point-max))
3745 (gnus-treat-article nil 1 1)
3748 ;; Highlight the headers.
3752 (narrow-to-region (point-min) (point))
3753 (gnus-treat-article 'head))))))))
3755 (defvar gnus-mime-display-multipart-as-mixed nil)
3757 (defun gnus-mime-display-part (handle)
3760 ((not (stringp (car handle)))
3761 (gnus-mime-display-single handle))
3762 ;; User-defined multipart
3763 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3764 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3766 ;; multipart/alternative
3767 ((and (equal (car handle) "multipart/alternative")
3768 (not gnus-mime-display-multipart-as-mixed))
3769 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3770 (push (cons id handle) gnus-article-mime-handle-alist)
3771 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3772 ;; multipart/related
3773 ((and (equal (car handle) "multipart/related")
3774 (not gnus-mime-display-multipart-as-mixed))
3775 ;;;!!!We should find the start part, but we just default
3776 ;;;!!!to the first part.
3777 ;;(gnus-mime-display-part (cadr handle))
3778 ;;;!!! Most multipart/related is an HTML message plus images.
3779 ;;;!!! Unfortunately we are unable to let W3 display those
3780 ;;;!!! included images, so we just display it as a mixed multipart.
3781 ;;(gnus-mime-display-mixed (cdr handle))
3782 ;;;!!! No, w3 can display everything just fine.
3783 (gnus-mime-display-part (cadr handle)))
3784 ((equal (car handle) "multipart/signed")
3785 (or (memq 'signed gnus-article-wash-types)
3786 (push 'signed gnus-article-wash-types))
3787 (gnus-mime-display-security handle))
3788 ((equal (car handle) "multipart/encrypted")
3789 (or (memq 'encrypted gnus-article-wash-types)
3790 (push 'encrypted gnus-article-wash-types))
3791 (gnus-mime-display-security handle))
3792 ;; Other multiparts are handled like multipart/mixed.
3794 (gnus-mime-display-mixed (cdr handle)))))
3796 (defun gnus-mime-part-function (handles)
3797 (if (stringp (car handles))
3798 (mapcar 'gnus-mime-part-function (cdr handles))
3799 (funcall gnus-article-mime-part-function handles)))
3801 (defun gnus-mime-display-mixed (handles)
3802 (mapcar 'gnus-mime-display-part handles))
3804 (defun gnus-mime-display-single (handle)
3805 (let ((type (mm-handle-media-type handle))
3806 (ignored gnus-ignored-mime-types)
3813 (when (string-match (pop ignored) type)
3814 (throw 'ignored nil)))
3815 (if (and (setq not-attachment
3816 (and (not (mm-inline-override-p handle))
3817 (or (not (mm-handle-disposition handle))
3818 (equal (car (mm-handle-disposition handle))
3820 (mm-attachment-override-p handle))))
3821 (mm-automatic-display-p handle)
3822 (or (mm-inlined-p handle)
3823 (mm-automatic-external-display-p type)))
3825 (when (equal (mm-handle-media-supertype handle) "text")
3827 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3829 (push (cons id handle) gnus-article-mime-handle-alist)
3830 (when (or (not display)
3831 (not (gnus-unbuttonized-mime-type-p type)))
3832 ;(gnus-article-insert-newline)
3833 (gnus-insert-mime-button
3834 handle id (list (or display (and not-attachment text))))
3835 (gnus-article-insert-newline)
3836 ;(gnus-article-insert-newline)
3837 ;; Remember modify the number of forward lines.
3845 (let ((mail-parse-charset gnus-newsgroup-charset)
3846 (mail-parse-ignored-charsets
3847 (save-excursion (condition-case ()
3848 (set-buffer gnus-summary-buffer)
3850 gnus-newsgroup-ignored-charsets)))
3851 (mm-display-part handle t))
3852 (goto-char (point-max)))
3853 ((and text not-attachment)
3857 (gnus-article-insert-newline)
3858 (mm-insert-inline handle (mm-get-part handle))
3859 (goto-char (point-max))))
3863 (narrow-to-region beg (point))
3866 (gnus-article-mime-total-parts)
3867 (mm-handle-media-type handle)))))))))
3869 (defun gnus-unbuttonized-mime-type-p (type)
3870 "Say whether TYPE is to be unbuttonized."
3871 (unless gnus-inhibit-mime-unbuttonizing
3873 (let ((types gnus-unbuttonized-mime-types))
3875 (when (string-match (pop types) type)
3876 (throw 'found t)))))))
3878 (defun gnus-article-insert-newline ()
3879 "Insert a newline, but mark it as undeletable."
3880 (gnus-put-text-property
3881 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3883 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3884 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3887 handle buffer-read-only from props begend not-pref)
3888 (save-window-excursion
3891 (narrow-to-region (car ibegend)
3894 (goto-char (car ibegend))
3897 (delete-region (point-min) (point-max))
3898 (mm-remove-parts handles))
3899 (setq begend (list (point-marker)))
3901 (unless (setq not-pref (cadr (member preferred ihandles)))
3902 (setq not-pref (car ihandles)))
3905 (not (gnus-unbuttonized-mime-type-p
3906 "multipart/alternative")))
3907 (gnus-add-text-properties
3910 (insert (format "%d. " id))
3914 (unless ,(not ibegend)
3915 (setq gnus-article-mime-handle-alist
3916 ',gnus-article-mime-handle-alist))
3917 (gnus-mime-display-alternative
3918 ',ihandles ',not-pref ',begend ,id))
3919 ,@(if (>= (string-to-number emacs-version) 21)
3920 nil ;; XEmacs doesn't care
3921 (list 'local-map gnus-mime-button-map))
3922 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3923 face ,gnus-article-button-face
3924 keymap ,gnus-mime-button-map
3927 (widget-convert-button 'link from (point)
3928 :action 'gnus-widget-press-button
3929 :button-keymap gnus-widget-button-keymap)
3931 (while (setq handle (pop handles))
3932 (gnus-add-text-properties
3935 (insert (format "(%c) %-18s"
3936 (if (equal handle preferred) ?* ? )
3937 (mm-handle-media-type handle)))
3941 (unless ,(not ibegend)
3942 (setq gnus-article-mime-handle-alist
3943 ',gnus-article-mime-handle-alist))
3944 (gnus-mime-display-alternative
3945 ',ihandles ',handle ',begend ,id))
3946 ,@(if (>= (string-to-number emacs-version) 21)
3947 nil ;; XEmacs doesn't care
3948 (list 'local-map gnus-mime-button-map))
3949 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3950 face ,gnus-article-button-face
3951 keymap ,gnus-mime-button-map
3954 (widget-convert-button 'link from (point)
3955 :action 'gnus-widget-press-button
3956 :button-keymap gnus-widget-button-keymap)
3960 (if (stringp (car preferred))
3961 (gnus-display-mime preferred)
3962 (let ((mail-parse-charset gnus-newsgroup-charset)
3963 (mail-parse-ignored-charsets
3964 (save-excursion (set-buffer gnus-summary-buffer)
3965 gnus-newsgroup-ignored-charsets)))
3966 (mm-display-part preferred)
3970 (narrow-to-region (car begend) (point-max))
3972 nil (length gnus-article-mime-handle-alist)
3973 (gnus-article-mime-total-parts)
3974 (mm-handle-media-type handle))))))
3975 (goto-char (point-max))
3976 (setcdr begend (point-marker)))))
3978 (goto-char point))))
3980 (defun gnus-article-wash-status ()
3981 "Return a string which display status of article washing."
3983 (set-buffer gnus-article-buffer)
3984 (let ((cite (memq 'cite gnus-article-wash-types))
3985 (headers (memq 'headers gnus-article-wash-types))
3986 (boring (memq 'boring-headers gnus-article-wash-types))
3987 (pgp (memq 'pgp gnus-article-wash-types))
3988 (pem (memq 'pem gnus-article-wash-types))
3989 (signed (memq 'signed gnus-article-wash-types))
3990 (encrypted (memq 'encrypted gnus-article-wash-types))
3991 (signature (memq 'signature gnus-article-wash-types))
3992 (overstrike (memq 'overstrike gnus-article-wash-types))
3993 (emphasis (memq 'emphasis gnus-article-wash-types)))
3994 (format "%c%c%c%c%c%c"
3996 (if (or headers boring) ?h ? )
3997 (if (or pgp pem signed encrypted) ?p ? )
3998 (if signature ?s ? )
3999 (if overstrike ?o ? )
4000 (if emphasis ?e ? )))))
4002 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4004 (defun gnus-article-maybe-hide-headers ()
4005 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4006 Provided for backwards compatibility."
4007 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4008 (not (save-excursion (set-buffer gnus-summary-buffer)
4009 gnus-have-all-headers)))
4010 (not gnus-inhibit-hiding))
4011 (gnus-article-hide-headers)))
4015 (defun gnus-output-to-file (file-name)
4016 "Append the current article to a file named FILE-NAME."
4017 (let ((artbuf (current-buffer)))
4019 (insert-buffer-substring artbuf)
4020 ;; Append newline at end of the buffer as separator, and then
4022 (goto-char (point-max))
4024 (mm-append-to-file (point-min) (point-max) file-name)
4027 (defun gnus-narrow-to-page (&optional arg)
4028 "Narrow the article buffer to a page.
4029 If given a numerical ARG, move forward ARG pages."
4031 (setq arg (if arg (prefix-numeric-value arg) 0))
4033 (set-buffer gnus-article-buffer)
4034 (goto-char (point-min))
4036 ;; Remove any old next/prev buttons.
4037 (when (gnus-visual-p 'page-marker)
4038 (let ((buffer-read-only nil))
4039 (gnus-remove-text-with-property 'gnus-prev)
4040 (gnus-remove-text-with-property 'gnus-next)))
4043 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4045 (re-search-forward page-delimiter nil 'move arg)))
4046 (goto-char (match-end 0)))
4049 (if (re-search-forward page-delimiter nil 'move)
4052 (when (and (gnus-visual-p 'page-marker)
4053 (not (= (point-min) 1)))
4055 (goto-char (point-min))
4056 (gnus-insert-prev-page-button)))
4057 (when (and (gnus-visual-p 'page-marker)
4058 (< (+ (point-max) 2) (buffer-size)))
4060 (goto-char (point-max))
4061 (gnus-insert-next-page-button)))))
4063 ;; Article mode commands
4065 (defun gnus-article-goto-next-page ()
4066 "Show the next page of the article."
4068 (when (gnus-article-next-page)
4069 (goto-char (point-min))
4070 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4072 (defun gnus-article-goto-prev-page ()
4073 "Show the next page of the article."
4075 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4076 (gnus-article-prev-page nil)))
4078 (defun gnus-article-next-page (&optional lines)
4079 "Show the next page of the current article.
4080 If end of article, return non-nil. Otherwise return nil.
4081 Argument LINES specifies lines to be scrolled up."
4083 (move-to-window-line -1)
4086 (and (pos-visible-in-window-p) ;Not continuation line.
4088 ;; Nothing in this page.
4089 (if (or (not gnus-page-broken)
4092 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4094 (gnus-narrow-to-page 1) ;Go to next page.
4096 ;; More in this page.
4097 (let ((scroll-in-place nil))
4101 ;; Long lines may cause an end-of-buffer error.
4102 (goto-char (point-max)))))
4103 (move-to-window-line 0)
4106 (defun gnus-article-prev-page (&optional lines)
4107 "Show previous page of current article.
4108 Argument LINES specifies lines to be scrolled down."
4110 (move-to-window-line 0)
4111 (if (and gnus-page-broken
4113 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4115 (gnus-narrow-to-page -1) ;Go to previous page.
4116 (goto-char (point-max))
4118 (let ((scroll-in-place nil))
4122 (beginning-of-buffer
4123 (goto-char (point-min))))
4124 (move-to-window-line 0)))))
4126 (defun gnus-article-refer-article ()
4127 "Read article specified by message-id around point."
4129 (let ((point (point)))
4130 (search-forward ">" nil t) ;Move point to end of "<....>".
4131 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4132 (let ((message-id (match-string 1)))
4134 (set-buffer gnus-summary-buffer)
4135 (gnus-summary-refer-article message-id))
4137 (error "No references around point"))))
4139 (defun gnus-article-show-summary ()
4140 "Reconfigure windows to show summary buffer."
4142 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4143 (error "There is no summary buffer for this article buffer")
4144 (gnus-article-set-globals)
4145 (gnus-configure-windows 'article)
4146 (gnus-summary-goto-subject gnus-current-article)
4147 (gnus-summary-position-point)))
4149 (defun gnus-article-describe-briefly ()
4150 "Describe article mode commands briefly."
4152 (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")))
4154 (defun gnus-article-summary-command ()
4155 "Execute the last keystroke in the summary buffer."
4157 (let ((obuf (current-buffer))
4158 (owin (current-window-configuration))
4160 (switch-to-buffer gnus-article-current-summary 'norecord)
4161 (setq func (lookup-key (current-local-map) (this-command-keys)))
4162 (call-interactively func)
4164 (set-window-configuration owin)
4165 (set-window-point (get-buffer-window (current-buffer)) (point))))
4167 (defun gnus-article-summary-command-nosave ()
4168 "Execute the last keystroke in the summary buffer."
4171 (pop-to-buffer gnus-article-current-summary 'norecord)
4172 (setq func (lookup-key (current-local-map) (this-command-keys)))
4173 (call-interactively func)))
4175 (defun gnus-article-check-buffer ()
4176 "Beep if not in an article buffer."
4177 (unless (equal major-mode 'gnus-article-mode)
4178 (error "Command invoked outside of a Gnus article buffer")))
4180 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4181 "Read a summary buffer key sequence and execute it from the article buffer."
4183 (gnus-article-check-buffer)
4185 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4186 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4187 "=" "^" "\M-^" "|"))
4193 '("n" "Gn" "p" "Gp"))
4196 (set-buffer gnus-article-current-summary)
4197 (let (gnus-pick-mode)
4198 (push (or key last-command-event) unread-command-events)
4199 (setq keys (if (featurep 'xemacs)
4200 (events-to-keys (read-key-sequence nil))
4201 (read-key-sequence nil)))))
4205 (if (or (member keys nosaves)
4206 (member keys nosave-but-article)
4207 (member keys nosave-in-article))
4209 (save-window-excursion
4210 (pop-to-buffer gnus-article-current-summary 'norecord)
4211 ;; We disable the pick minor mode commands.
4212 (let (gnus-pick-mode)
4213 (setq func (lookup-key (current-local-map) keys))))
4217 (unless (member keys nosave-in-article)
4218 (set-buffer gnus-article-current-summary))
4219 (call-interactively func)
4220 (setq new-sum-point (point)))
4221 (when (member keys nosave-but-article)
4222 (pop-to-buffer gnus-article-buffer 'norecord)))
4223 ;; These commands should restore window configuration.
4224 (let ((obuf (current-buffer))
4225 (owin (current-window-configuration))
4227 (summary gnus-article-current-summary)
4228 func in-buffer selected)
4229 (if not-restore-window
4230 (pop-to-buffer summary 'norecord)
4231 (switch-to-buffer summary 'norecord))
4232 (setq in-buffer (current-buffer))
4233 ;; We disable the pick minor mode commands.
4234 (if (and (setq func (let (gnus-pick-mode)
4235 (lookup-key (current-local-map) keys)))
4238 (call-interactively func)
4239 (setq new-sum-point (point))
4240 (when (eq in-buffer (current-buffer))
4241 (setq selected (gnus-summary-select-article))
4243 (unless not-restore-window
4244 (set-window-configuration owin))
4245 (when (eq selected 'old)
4247 (set-window-start (get-buffer-window (current-buffer))
4249 (set-window-point (get-buffer-window (current-buffer))
4251 (let ((win (get-buffer-window gnus-article-current-summary)))
4253 (set-window-point win new-sum-point)))) )
4254 (switch-to-buffer gnus-article-buffer)
4257 (defun gnus-article-describe-key (key)
4258 "Display documentation of the function invoked by KEY. KEY is a string."
4259 (interactive "kDescribe key: ")
4260 (gnus-article-check-buffer)
4261 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4263 (set-buffer gnus-article-current-summary)
4264 (let (gnus-pick-mode)
4265 (push (elt key 0) unread-command-events)
4266 (setq key (if (featurep 'xemacs)
4267 (events-to-keys (read-key-sequence "Describe key: "))
4268 (read-key-sequence "Describe key: "))))
4270 (describe-key key)))
4272 (defun gnus-article-describe-key-briefly (key &optional insert)
4273 "Display documentation of the function invoked by KEY. KEY is a string."
4274 (interactive "kDescribe key: \nP")
4275 (gnus-article-check-buffer)
4276 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4278 (set-buffer gnus-article-current-summary)
4279 (let (gnus-pick-mode)
4280 (push (elt key 0) unread-command-events)
4281 (setq key (if (featurep 'xemacs)
4282 (events-to-keys (read-key-sequence "Describe key: "))
4283 (read-key-sequence "Describe key: "))))
4284 (describe-key-briefly key insert))
4285 (describe-key-briefly key insert)))
4287 (defun gnus-article-hide (&optional arg force)
4288 "Hide all the gruft in the current article.
4289 This means that PGP stuff, signatures, cited text and (some)
4290 headers will be hidden.
4291 If given a prefix, show the hidden text instead."
4292 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4293 (gnus-article-hide-headers arg)
4294 (gnus-article-hide-list-identifiers arg)
4295 (gnus-article-hide-pgp arg)
4296 (gnus-article-hide-citation-maybe arg force)
4297 (gnus-article-hide-signature arg))
4299 (defun gnus-article-maybe-highlight ()
4300 "Do some article highlighting if article highlighting is requested."
4301 (when (gnus-visual-p 'article-highlight 'highlight)
4302 (gnus-article-highlight-some)))
4304 (defun gnus-check-group-server ()
4305 ;; Make sure the connection to the server is alive.
4306 (unless (gnus-server-opened
4307 (gnus-find-method-for-group gnus-newsgroup-name))
4308 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4309 (gnus-request-group gnus-newsgroup-name t)))
4311 (defun gnus-request-article-this-buffer (article group)
4312 "Get an article and insert it into this buffer."
4313 (let (do-update-line sparse-header)
4317 (gnus-kill-all-overlays)
4318 (setq group (or group gnus-newsgroup-name))
4320 ;; Using `gnus-request-article' directly will insert the article into
4321 ;; `nntp-server-buffer' - so we'll save some time by not having to
4322 ;; copy it from the server buffer into the article buffer.
4324 ;; We only request an article by message-id when we do not have the
4325 ;; headers for it, so we'll have to get those.
4326 (when (stringp article)
4327 (gnus-read-header article))
4329 ;; If the article number is negative, that means that this article
4330 ;; doesn't belong in this newsgroup (possibly), so we find its
4331 ;; message-id and request it by id instead of number.
4332 (when (and (numberp article)
4334 (get-buffer gnus-summary-buffer)
4335 (gnus-buffer-exists-p gnus-summary-buffer))
4337 (set-buffer gnus-summary-buffer)
4338 (let ((header (gnus-summary-article-header article)))
4341 ((memq article gnus-newsgroup-sparse)
4342 ;; This is a sparse gap article.
4343 (setq do-update-line article)
4344 (setq article (mail-header-id header))
4345 (setq sparse-header (gnus-read-header article))
4346 (setq gnus-newsgroup-sparse
4347 (delq article gnus-newsgroup-sparse)))
4349 ;; It's a real article.
4350 (setq article (mail-header-id header)))
4352 ;; It is an extracted pseudo-article.
4353 (setq article 'pseudo)
4354 (gnus-request-pseudo-article header))))
4356 (let ((method (gnus-find-method-for-group
4357 gnus-newsgroup-name)))
4358 (when (and (eq (car method) 'nneething)
4360 (let ((dir (expand-file-name
4361 (mail-header-subject header)
4362 (file-name-as-directory
4363 (or (cadr (assq 'nneething-address method))
4365 (when (file-directory-p dir)
4366 (setq article 'nneething)
4367 (gnus-group-enter-directory dir))))))))
4370 ;; Refuse to select canceled articles.
4371 ((and (numberp article)
4373 (get-buffer gnus-summary-buffer)
4374 (gnus-buffer-exists-p gnus-summary-buffer)
4375 (eq (cdr (save-excursion
4376 (set-buffer gnus-summary-buffer)
4377 (assq article gnus-newsgroup-reads)))
4378 gnus-canceled-mark))
4380 ;; We first check `gnus-original-article-buffer'.
4381 ((and (get-buffer gnus-original-article-buffer)
4384 (set-buffer gnus-original-article-buffer)
4385 (and (equal (car gnus-original-article) group)
4386 (eq (cdr gnus-original-article) article))))
4387 (insert-buffer-substring gnus-original-article-buffer)
4389 ;; Check the backlog.
4390 ((and gnus-keep-backlog
4391 (gnus-backlog-request-article group article (current-buffer)))
4393 ;; Check asynchronous pre-fetch.
4394 ((gnus-async-request-fetched-article group article (current-buffer))
4395 (gnus-async-prefetch-next group article gnus-summary-buffer)
4396 (when (and (numberp article) gnus-keep-backlog)
4397 (gnus-backlog-enter-article group article (current-buffer)))
4400 ((and gnus-use-cache
4402 (gnus-cache-request-article article group))
4404 ;; Get the article and put into the article buffer.
4405 ((or (stringp article)
4407 (let ((gnus-override-method gnus-override-method)
4408 (methods (and (stringp article)
4409 gnus-refer-article-method))
4411 (buffer-read-only nil))
4412 (if (or (not (listp methods))
4413 (and (symbolp (car methods))
4414 (assq (car methods) nnoo-definition-alist)))
4415 (setq methods (list methods)))
4416 (when (and (null gnus-override-method)
4418 (setq gnus-override-method (pop methods)))
4420 (when (eq gnus-override-method 'current)
4421 (setq gnus-override-method gnus-current-select-method))
4423 (gnus-kill-all-overlays)
4424 (let ((gnus-newsgroup-name group))
4425 (gnus-check-group-server))
4426 (when (gnus-request-article article group (current-buffer))
4427 (when (numberp article)
4428 (gnus-async-prefetch-next group article
4429 gnus-summary-buffer)
4430 (when gnus-keep-backlog
4431 (gnus-backlog-enter-article
4432 group article (current-buffer))))
4433 (setq result 'article))
4436 (setq gnus-override-method (pop methods))
4437 (setq result 'done))))
4438 (and (eq result 'article) 'article)))
4442 ;; Associate this article with the current summary buffer.
4443 (setq gnus-article-current-summary gnus-summary-buffer)
4445 ;; Take the article from the original article buffer
4446 ;; and place it in the buffer it's supposed to be in.
4447 (when (and (get-buffer gnus-article-buffer)
4448 (equal (buffer-name (current-buffer))
4449 (buffer-name (get-buffer gnus-article-buffer))))
4451 (if (get-buffer gnus-original-article-buffer)
4452 (set-buffer gnus-original-article-buffer)
4453 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4454 (buffer-disable-undo)
4455 (setq major-mode 'gnus-original-article-mode)
4456 (setq buffer-read-only t))
4457 (let (buffer-read-only)
4459 (insert-buffer-substring gnus-article-buffer))
4460 (setq gnus-original-article (cons group article)))
4463 (run-hooks 'gnus-article-decode-hook)
4464 ;; Mark article as decoded or not.
4465 (setq gnus-article-decoded-p gnus-article-decode-hook))
4467 ;; Update sparse articles.
4468 (when (and do-update-line
4469 (or (numberp article)
4471 (let ((buf (current-buffer)))
4472 (set-buffer gnus-summary-buffer)
4473 (gnus-summary-update-article do-update-line sparse-header)
4474 (gnus-summary-goto-subject do-update-line nil t)
4475 (set-window-point (get-buffer-window (current-buffer) t)
4477 (set-buffer buf))))))
4483 (defcustom gnus-article-edit-mode-hook nil
4484 "Hook run in article edit mode buffers."
4485 :group 'gnus-article-various
4488 (defvar gnus-article-edit-done-function nil)
4490 (defvar gnus-article-edit-mode-map nil)
4492 ;; Should we be using derived.el for this?
4493 (unless gnus-article-edit-mode-map
4494 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4495 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4497 (gnus-define-keys gnus-article-edit-mode-map
4498 "\C-c\C-c" gnus-article-edit-done
4499 "\C-c\C-k" gnus-article-edit-exit)
4501 (gnus-define-keys (gnus-article-edit-wash-map
4502 "\C-c\C-w" gnus-article-edit-mode-map)
4503 "f" gnus-article-edit-full-stops))
4505 (defun gnus-article-edit-mode ()
4506 "Major mode for editing articles.
4507 This is an extended text-mode.
4509 \\{gnus-article-edit-mode-map}"
4511 (setq major-mode 'gnus-article-edit-mode)
4512 (setq mode-name "Article Edit")
4513 (use-local-map gnus-article-edit-mode-map)
4514 (make-local-variable 'gnus-article-edit-done-function)
4515 (make-local-variable 'gnus-prev-winconf)
4516 (setq buffer-read-only nil)
4517 (buffer-enable-undo)
4519 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4521 (defun gnus-article-edit (&optional force)
4522 "Edit the current article.
4523 This will have permanent effect only in mail groups.
4524 If FORCE is non-nil, allow editing of articles even in read-only
4527 (when (and (not force)
4528 (gnus-group-read-only-p))
4529 (error "The current newsgroup does not support article editing"))
4530 (gnus-article-date-original)
4531 (gnus-article-edit-article
4533 `(lambda (no-highlight)
4535 (gnus-summary-edit-article-done
4536 ,(or (mail-header-references gnus-current-headers) "")
4537 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4539 (defun gnus-article-edit-article (start-func exit-func)
4540 "Start editing the contents of the current article buffer."
4541 (let ((winconf (current-window-configuration)))
4542 (set-buffer gnus-article-buffer)
4543 (gnus-article-edit-mode)
4544 (funcall start-func)
4545 (gnus-configure-windows 'edit-article)
4546 (setq gnus-article-edit-done-function exit-func)
4547 (setq gnus-prev-winconf winconf)
4548 (gnus-message 6 "C-c C-c to end edits")))
4550 (defun gnus-article-edit-done (&optional arg)
4551 "Update the article edits and exit."
4553 (let ((func gnus-article-edit-done-function)
4554 (buf (current-buffer))
4555 (start (window-start)))
4556 (gnus-article-edit-exit)
4559 (let ((buffer-read-only nil))
4561 ;; The cache and backlog have to be flushed somewhat.
4562 (when gnus-keep-backlog
4563 (gnus-backlog-remove-article
4564 (car gnus-article-current) (cdr gnus-article-current)))
4565 ;; Flush original article as well.
4567 (when (get-buffer gnus-original-article-buffer)
4568 (set-buffer gnus-original-article-buffer)
4569 (setq gnus-original-article nil)))
4570 (when gnus-use-cache
4571 (gnus-cache-update-article
4572 (car gnus-article-current) (cdr gnus-article-current))))
4574 (set-window-start (get-buffer-window buf) start)
4575 (set-window-point (get-buffer-window buf) (point))))
4577 (defun gnus-article-edit-exit ()
4578 "Exit the article editing without updating."
4580 ;; We remove all text props from the article buffer.
4581 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4582 (curbuf (current-buffer))
4584 (window-start (window-start)))
4587 (let ((winconf gnus-prev-winconf))
4589 (set-window-configuration winconf)
4590 ;; Tippy-toe some to make sure that point remains where it was.
4591 (save-current-buffer
4593 (set-window-start (get-buffer-window (current-buffer)) window-start)
4596 (defun gnus-article-edit-full-stops ()
4597 "Interactively repair spacing at end of sentences."
4600 (goto-char (point-min))
4601 (search-forward-regexp "^$" nil t)
4602 (let ((case-fold-search nil))
4603 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4606 ;;; Article highlights
4609 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4611 ;;; Internal Variables:
4613 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4614 "Regular expression that matches URLs."
4615 :group 'gnus-article-buttons
4618 (defcustom gnus-button-alist
4619 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4620 0 t gnus-button-message-id 2)
4621 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4622 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4624 gnus-button-fetch-group 4)
4625 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4626 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4627 t gnus-button-message-id 3)
4628 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4629 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
4630 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4631 ;; This is how URLs _should_ be embedded in text...
4632 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4634 (,gnus-button-url-regexp 0 t browse-url 0))
4635 "*Alist of regexps matching buttons in article bodies.
4637 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4638 REGEXP: is the string matching text around the button,
4639 BUTTON: is the number of the regexp grouping actually matching the button,
4640 FORM: is a lisp expression which must eval to true for the button to
4642 CALLBACK: is the function to call when the user push this button, and each
4643 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4645 CALLBACK can also be a variable, in that case the value of that
4646 variable it the real callback function."
4647 :group 'gnus-article-buttons
4648 :type '(repeat (list regexp
4649 (integer :tag "Button")
4651 (function :tag "Callback")
4654 (integer :tag "Regexp group")))))
4656 (defcustom gnus-header-button-alist
4657 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4658 0 t gnus-button-message-id 0)
4659 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4660 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4661 0 t gnus-button-mailto 0)
4662 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4663 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4664 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4665 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4666 gnus-button-message-id 3))
4667 "*Alist of headers and regexps to match buttons in article heads.
4669 This alist is very similar to `gnus-button-alist', except that each
4670 alist has an additional HEADER element first in each entry:
4672 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4674 HEADER is a regexp to match a header. For a fuller explanation, see
4675 `gnus-button-alist'."
4676 :group 'gnus-article-buttons
4677 :group 'gnus-article-headers
4678 :type '(repeat (list (regexp :tag "Header")
4680 (integer :tag "Button")
4682 (function :tag "Callback")
4685 (integer :tag "Regexp group")))))
4687 (defvar gnus-button-regexp nil)
4688 (defvar gnus-button-marker-list nil)
4689 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4691 (defvar gnus-button-last nil)
4692 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4696 (defun gnus-article-push-button (event)
4697 "Check text under the mouse pointer for a callback function.
4698 If the text under the mouse pointer has a `gnus-callback' property,
4699 call it with the value of the `gnus-data' text property."
4701 (set-buffer (window-buffer (posn-window (event-start event))))
4702 (let* ((pos (posn-point (event-start event)))
4703 (data (get-text-property pos 'gnus-data))
4704 (fun (get-text-property pos 'gnus-callback)))
4707 (funcall fun data))))
4709 (defun gnus-article-press-button ()
4710 "Check text at point for a callback function.
4711 If the text at point has a `gnus-callback' property,
4712 call it with the value of the `gnus-data' text property."
4714 (let* ((data (get-text-property (point) 'gnus-data))
4715 (fun (get-text-property (point) 'gnus-callback)))
4717 (funcall fun data))))
4719 (defun gnus-article-highlight (&optional force)
4720 "Highlight current article.
4721 This function calls `gnus-article-highlight-headers',
4722 `gnus-article-highlight-citation',
4723 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4724 do the highlighting. See the documentation for those functions."
4725 (interactive (list 'force))
4726 (gnus-article-highlight-headers)
4727 (gnus-article-highlight-citation force)
4728 (gnus-article-highlight-signature)
4729 (gnus-article-add-buttons force)
4730 (gnus-article-add-buttons-to-head))
4732 (defun gnus-article-highlight-some (&optional force)
4733 "Highlight current article.
4734 This function calls `gnus-article-highlight-headers',
4735 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4736 do the highlighting. See the documentation for those functions."
4737 (interactive (list 'force))
4738 (gnus-article-highlight-headers)
4739 (gnus-article-highlight-signature)
4740 (gnus-article-add-buttons))
4742 (defun gnus-article-highlight-headers ()
4743 "Highlight article headers as specified by `gnus-header-face-alist'."
4746 (set-buffer gnus-article-buffer)
4748 (let ((alist gnus-header-face-alist)
4749 (buffer-read-only nil)
4750 (case-fold-search t)
4751 (inhibit-point-motion-hooks t)
4752 entry regexp header-face field-face from hpoints fpoints)
4753 (article-narrow-to-head)
4754 (while (setq entry (pop alist))
4755 (goto-char (point-min))
4756 (setq regexp (concat "^\\("
4757 (if (string-equal "" (nth 0 entry))
4761 header-face (nth 1 entry)
4762 field-face (nth 2 entry))
4763 (while (and (re-search-forward regexp nil t)
4767 (unless (search-forward ":" nil t)
4769 (when (and header-face
4770 (not (memq (point) hpoints)))
4771 (push (point) hpoints)
4772 (gnus-put-text-property from (point) 'face header-face))
4773 (when (and field-face
4774 (not (memq (setq from (point)) fpoints)))
4776 (if (re-search-forward "^[^ \t]" nil t)
4778 (goto-char (point-max)))
4779 (gnus-put-text-property from (point) 'face field-face))))))))
4781 (defun gnus-article-highlight-signature ()
4782 "Highlight the signature in an article.
4783 It does this by highlighting everything after
4784 `gnus-signature-separator' using `gnus-signature-face'."
4787 (set-buffer gnus-article-buffer)
4788 (let ((buffer-read-only nil)
4789 (inhibit-point-motion-hooks t))
4791 (when (and gnus-signature-face
4792 (gnus-article-narrow-to-signature))
4793 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4794 'face gnus-signature-face)
4796 (gnus-article-search-signature)
4797 (let ((start (match-beginning 0))
4798 (end (set-marker (make-marker) (1+ (match-end 0)))))
4799 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4802 (defun gnus-button-in-region-p (b e prop)
4803 "Say whether PROP exists in the region."
4804 (text-property-not-all b e prop nil))
4806 (defun gnus-article-add-buttons (&optional force)
4807 "Find external references in the article and make buttons of them.
4808 \"External references\" are things like Message-IDs and URLs, as
4809 specified by `gnus-button-alist'."
4810 (interactive (list 'force))
4812 (set-buffer gnus-article-buffer)
4813 (let ((buffer-read-only nil)
4814 (inhibit-point-motion-hooks t)
4815 (case-fold-search t)
4816 (alist gnus-button-alist)
4818 ;; Remove all old markers.
4819 (let (marker entry new-list)
4820 (while (setq marker (pop gnus-button-marker-list))
4821 (if (or (< marker (point-min)) (>= marker (point-max)))
4822 (push marker new-list)
4824 (when (setq entry (gnus-button-entry))
4825 (put-text-property (match-beginning (nth 1 entry))
4826 (match-end (nth 1 entry))
4827 'gnus-callback nil))
4828 (set-marker marker nil)))
4829 (setq gnus-button-marker-list new-list))
4830 ;; We skip the headers.
4833 (while (setq entry (pop alist))
4834 (setq regexp (car entry))
4836 (while (re-search-forward regexp nil t)
4837 (let* ((start (and entry (match-beginning (nth 1 entry))))
4838 (end (and entry (match-end (nth 1 entry))))
4839 (from (match-beginning 0)))
4840 (when (and (or (eq t (nth 2 entry))
4841 (eval (nth 2 entry)))
4842 (not (gnus-button-in-region-p
4843 start end 'gnus-callback)))
4844 ;; That optional form returned non-nil, so we add the
4846 (gnus-article-add-button
4847 start end 'gnus-button-push
4848 (car (push (set-marker (make-marker) from)
4849 gnus-button-marker-list))))))))))
4851 ;; Add buttons to the head of an article.
4852 (defun gnus-article-add-buttons-to-head ()
4853 "Add buttons to the head of the article."
4856 (set-buffer gnus-article-buffer)
4858 (let ((buffer-read-only nil)
4859 (inhibit-point-motion-hooks t)
4860 (case-fold-search t)
4861 (alist gnus-header-button-alist)
4863 (article-narrow-to-head)
4865 ;; Each alist entry.
4866 (setq entry (car alist)
4868 (goto-char (point-min))
4869 (while (re-search-forward (car entry) nil t)
4870 ;; Each header matching the entry.
4871 (setq beg (match-beginning 0))
4872 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4873 (match-beginning 0))
4876 (while (re-search-forward (nth 1 entry) end t)
4877 ;; Each match within a header.
4878 (let* ((entry (cdr entry))
4879 (start (match-beginning (nth 1 entry)))
4880 (end (match-end (nth 1 entry)))
4881 (form (nth 2 entry)))
4882 (goto-char (match-end 0))
4884 (gnus-article-add-button
4885 start end (nth 3 entry)
4886 (buffer-substring (match-beginning (nth 4 entry))
4887 (match-end (nth 4 entry)))))))
4888 (goto-char end)))))))
4890 ;;; External functions:
4892 (defun gnus-article-add-button (from to fun &optional data)
4893 "Create a button between FROM and TO with callback FUN and data DATA."
4894 (when gnus-article-button-face
4895 (gnus-overlay-put (gnus-make-overlay from to)
4896 'face gnus-article-button-face))
4897 (gnus-add-text-properties
4899 (nconc (and gnus-article-mouse-face
4900 (list gnus-mouse-face-prop gnus-article-mouse-face))
4901 (list 'gnus-callback fun)
4902 (and data (list 'gnus-data data))))
4903 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4904 :button-keymap gnus-widget-button-keymap))
4906 ;;; Internal functions:
4908 (defun gnus-article-set-globals ()
4910 (set-buffer gnus-summary-buffer)
4911 (gnus-set-global-variables)))
4913 (defun gnus-signature-toggle (end)
4915 (set-buffer gnus-article-buffer)
4916 (let ((buffer-read-only nil)
4917 (inhibit-point-motion-hooks t))
4918 (if (text-property-any end (point-max) 'article-type 'signature)
4919 (gnus-remove-text-properties-when
4920 'article-type 'signature end (point-max)
4921 (cons 'article-type (cons 'signature
4922 gnus-hidden-properties)))
4923 (gnus-add-text-properties-when
4924 'article-type nil end (point-max)
4925 (cons 'article-type (cons 'signature
4926 gnus-hidden-properties)))))))
4928 (defun gnus-button-entry ()
4929 ;; Return the first entry in `gnus-button-alist' matching this place.
4930 (let ((alist gnus-button-alist)
4933 (setq entry (pop alist))
4934 (if (looking-at (car entry))
4939 (defun gnus-button-push (marker)
4940 ;; Push button starting at MARKER.
4943 (let* ((entry (gnus-button-entry))
4944 (inhibit-point-motion-hooks t)
4946 (args (mapcar (lambda (group)
4947 (let ((string (match-string group)))
4948 (gnus-set-text-properties
4949 0 (length string) nil string)
4956 (fboundp (symbol-value fun)))
4957 (apply (symbol-value fun) args))
4959 (gnus-message 1 "You must define `%S' to use this button"
4960 (cons fun args)))))))
4962 (defun gnus-button-message-id (message-id)
4965 (set-buffer gnus-summary-buffer)
4966 (gnus-summary-refer-article message-id)))
4968 (defun gnus-button-fetch-group (address)
4969 "Fetch GROUP specified by ADDRESS."
4970 (if (not (string-match "[:/]" address))
4971 ;; This is just a simple group url.
4972 (gnus-group-read-ephemeral-group address gnus-select-method)
4973 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4975 (error "Can't parse %s" address)
4976 (gnus-group-read-ephemeral-group
4977 (match-string 4 address)
4978 `(nntp ,(match-string 1 address)
4979 (nntp-address ,(match-string 1 address))
4980 (nntp-port-number ,(if (match-end 3)
4981 (match-string 3 address)
4984 (defun gnus-url-parse-query-string (query &optional downcase)
4985 (let (retval pairs cur key val)
4986 (setq pairs (split-string query "&"))
4988 (setq cur (car pairs)
4990 (if (not (string-match "=" cur))
4992 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4993 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4995 (setq key (downcase key)))
4996 (setq cur (assoc key retval))
4998 (setcdr cur (cons val (cdr cur)))
4999 (setq retval (cons (list key val) retval)))))
5002 (defun gnus-url-unhex (x)
5009 (defun gnus-url-unhex-string (str &optional allow-newlines)
5010 "Remove %XXX embedded spaces, etc in a url.
5011 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5012 decoding of carriage returns and line feeds in the string, which is normally
5013 forbidden in URL encoding."
5014 (setq str (or str ""))
5016 (case-fold-search t))
5017 (while (string-match "%[0-9a-f][0-9a-f]" str)
5018 (let* ((start (match-beginning 0))
5019 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5021 (gnus-url-unhex (elt str (+ start 2))))))
5023 tmp (substring str 0 start)
5026 (char-to-string code))
5027 ((or (= code ?\n) (= code ?\r))
5029 (t (char-to-string code))))
5030 str (substring str (match-end 0)))))
5031 (setq tmp (concat tmp str))
5034 (defun gnus-url-mailto (url)
5035 ;; Send mail to someone
5036 (when (string-match "mailto:/*\\(.*\\)" url)
5037 (setq url (substring url (match-beginning 1) nil)))
5038 (let (to args subject func)
5039 (if (string-match (regexp-quote "?") url)
5040 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5041 args (gnus-url-parse-query-string
5042 (substring url (match-end 0) nil) t))
5043 (setq to (gnus-url-unhex-string url)))
5044 (setq args (cons (list "to" to) args)
5045 subject (cdr-safe (assoc "subject" args)))
5048 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5051 (message-position-on-field (caar args)))
5052 (insert (mapconcat 'identity (cdar args) ", "))
5053 (setq args (cdr args)))
5056 (message-goto-subject))))
5058 (defun gnus-button-embedded-url (address)
5059 "Activate ADDRESS with `browse-url'."
5060 (browse-url (gnus-strip-whitespace address)))
5062 ;;; Next/prev buttons in the article buffer.
5064 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5065 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5067 (defvar gnus-prev-page-map nil)
5068 (unless gnus-prev-page-map
5069 (setq gnus-prev-page-map (make-sparse-keymap))
5070 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5071 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5073 (defun gnus-insert-prev-page-button ()
5074 (let ((buffer-read-only nil))
5076 gnus-prev-page-line-format nil
5077 `(gnus-prev t local-map ,gnus-prev-page-map
5078 gnus-callback gnus-article-button-prev-page
5079 article-type annotation))))
5081 (defvar gnus-next-page-map nil)
5082 (unless gnus-next-page-map
5083 (setq gnus-next-page-map (make-keymap))
5084 (suppress-keymap gnus-prev-page-map)
5085 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5086 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5088 (defun gnus-button-next-page ()
5089 "Go to the next page."
5091 (let ((win (selected-window)))
5092 (select-window (get-buffer-window gnus-article-buffer t))
5093 (gnus-article-next-page)
5094 (select-window win)))
5096 (defun gnus-button-prev-page ()
5097 "Go to the prev page."
5099 (let ((win (selected-window)))
5100 (select-window (get-buffer-window gnus-article-buffer t))
5101 (gnus-article-prev-page)
5102 (select-window win)))
5104 (defun gnus-insert-next-page-button ()
5105 (let ((buffer-read-only nil))
5106 (gnus-eval-format gnus-next-page-line-format nil
5108 t local-map ,gnus-next-page-map
5109 gnus-callback gnus-article-button-next-page
5110 article-type annotation))))
5112 (defun gnus-article-button-next-page (arg)
5113 "Go to the next page."
5115 (let ((win (selected-window)))
5116 (select-window (get-buffer-window gnus-article-buffer t))
5117 (gnus-article-next-page)
5118 (select-window win)))
5120 (defun gnus-article-button-prev-page (arg)
5121 "Go to the prev page."
5123 (let ((win (selected-window)))
5124 (select-window (get-buffer-window gnus-article-buffer t))
5125 (gnus-article-prev-page)
5126 (select-window win)))
5128 (defvar gnus-decode-header-methods
5129 '(mail-decode-encoded-word-region)
5130 "List of methods used to decode headers.
5132 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5133 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5134 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5135 whose names match REGEXP.
5138 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5139 mail-decode-encoded-word-region
5140 (\"chinese\" . rfc1843-decode-region))
5143 (defvar gnus-decode-header-methods-cache nil)
5145 (defun gnus-multi-decode-header (start end)
5146 "Apply the functions from `gnus-encoded-word-methods' that match."
5147 (unless (and gnus-decode-header-methods-cache
5148 (eq gnus-newsgroup-name
5149 (car gnus-decode-header-methods-cache)))
5150 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5153 (nconc gnus-decode-header-methods-cache (list x))
5154 (if (and gnus-newsgroup-name
5155 (string-match (car x) gnus-newsgroup-name))
5156 (nconc gnus-decode-header-methods-cache
5158 gnus-decode-header-methods))
5159 (let ((xlist gnus-decode-header-methods-cache))
5162 (narrow-to-region start end)
5164 (funcall (pop xlist) (point-min) (point-max))))))
5167 ;;; Treatment top-level handling.
5170 (defun gnus-treat-article (condition &optional part-number total-parts type)
5171 (let ((length (- (point-max) (point-min)))
5172 (alist gnus-treatment-function-alist)
5173 (article-goto-body-goes-to-point-min-p t)
5177 (let ((list gnus-article-treat-types))
5179 (when (string-match (pop list) type)
5180 (throw 'found t)))))))
5181 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5183 (gnus-run-hooks 'gnus-part-display-hook)
5184 (while (setq elem (pop alist))
5187 (if (gnus-buffer-live-p gnus-summary-buffer)
5188 (set-buffer gnus-summary-buffer))
5189 (symbol-value (car elem))))
5190 (when (and (or (consp val)
5192 (gnus-treat-predicate val)
5193 (or (not (get (car elem) 'highlight))
5196 (funcall (cadr elem)))))))
5198 ;; Dynamic variables.
5200 (defvar part-number)
5201 (defvar total-parts)
5206 (defun gnus-treat-predicate (val)
5211 (stringp (car val)))
5212 (apply 'gnus-or (mapcar `(lambda (s)
5213 (string-match s ,(or gnus-newsgroup-name "")))
5216 (let ((pred (pop val)))
5219 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5221 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5223 (not (gnus-treat-predicate (car val))))
5225 (equal (car val) type))
5227 (error "%S is not a valid predicate" pred)))))
5235 (eq part-number total-parts))
5239 (error "%S is not a valid value" val))))
5241 (defun gnus-article-encrypt-body (protocol &optional n)
5242 "Encrypt the article body."
5245 (or gnus-article-encrypt-protocol
5246 (completing-read "Encrypt protocol: "
5247 gnus-article-encrypt-protocol-alist
5249 current-prefix-arg))
5250 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5252 (error (format "Can't find the encrypt protocol %s" protocol)))
5253 (if (equal gnus-newsgroup-name "nndraft:drafts")
5254 (error "Can't encrypt the article in group nndraft:drafts."))
5255 (if (equal gnus-newsgroup-name "nndraft:queue")
5256 (error "Don't encrypt the article in group nndraft:queue."))
5257 (gnus-summary-iterate n
5259 (set-buffer gnus-summary-buffer)
5260 (let ((mail-parse-charset gnus-newsgroup-charset)
5261 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5262 (summary-buffer gnus-summary-buffer)
5264 (gnus-set-global-variables)
5265 (when (gnus-group-read-only-p)
5266 (error "The current newsgroup does not support article encrypt"))
5267 (gnus-summary-show-article t)
5269 (or (mail-header-references gnus-current-headers) ""))
5270 (set-buffer gnus-article-buffer)
5271 (let* ((buffer-read-only nil)
5273 (mapcar (lambda (field)
5274 (and (save-restriction
5275 (message-narrow-to-head)
5276 (goto-char (point-min))
5277 (search-forward field nil t))
5279 (message-narrow-to-field)
5280 (buffer-substring (point-min) (point-max))
5281 (delete-region (point-min) (point-max))
5283 '("Content-Type:" "Content-Transfer-Encoding:"
5284 "Content-Disposition:"))))
5285 (message-narrow-to-head)
5286 (message-remove-header "MIME-Version")
5287 (goto-char (point-max))
5288 (setq point (point))
5289 (insert (apply 'concat headers))
5291 (narrow-to-region point (point-max))
5292 (let ((message-options message-options))
5293 (message-options-set 'message-sender user-mail-address)
5294 (message-options-set 'message-recipients user-mail-address)
5295 (message-options-set 'message-sign-encrypt 'not)
5297 (goto-char (point-min))
5298 (insert "MIME-Version: 1.0\n")
5300 (gnus-summary-edit-article-done
5301 references nil summary-buffer t))
5302 (when gnus-keep-backlog
5303 (gnus-backlog-remove-article
5304 (car gnus-article-current) (cdr gnus-article-current)))
5306 (when (get-buffer gnus-original-article-buffer)
5307 (set-buffer gnus-original-article-buffer)
5308 (setq gnus-original-article nil)))
5309 (when gnus-use-cache
5310 (gnus-cache-update-article
5311 (car gnus-article-current) (cdr gnus-article-current))))))))
5313 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5314 "The following specs can be used:
5315 %t The security MIME type
5318 %D Details if button is pressed")
5320 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5321 "The following specs can be used:
5322 %t The security MIME type
5325 %D Details if button is pressed")
5327 (defvar gnus-mime-security-button-line-format-alist
5328 '((?t gnus-tmp-type ?s)
5329 (?i gnus-tmp-info ?s)
5330 (?d gnus-tmp-details ?s)
5331 (?D gnus-tmp-pressed-details ?s)))
5333 (defvar gnus-mime-security-button-map
5334 (let ((map (make-sparse-keymap)))
5335 (unless (>= (string-to-number emacs-version) 21)
5336 (set-keymap-parent map gnus-article-mode-map))
5337 (define-key map gnus-mouse-2 'gnus-article-push-button)
5338 (define-key map "\r" 'gnus-article-press-button)
5341 (defvar gnus-mime-security-details-buffer nil)
5343 (defvar gnus-mime-security-button-pressed nil)
5345 (defvar gnus-mime-security-show-details-inline t
5346 "If non-nil, show details in the article buffer.")
5348 (defun gnus-mime-security-verify-or-decrypt (handle)
5349 (mm-remove-parts (cdr handle))
5350 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5353 (delete-region (car region) (cdr region))
5354 (set-marker (car region) nil)
5355 (set-marker (cdr region) nil)))
5356 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5357 (let* ((mm-verify-option 'known)
5358 (mm-decrypt-option 'known)
5359 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5360 (unless (eq nparts (cdr handle))
5361 (mm-destroy-parts (cdr handle))
5362 (setcdr handle nparts))))
5363 (let ((point (point))
5365 (gnus-mime-display-security handle)
5368 (defun gnus-mime-security-show-details (handle)
5369 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5371 (if gnus-mime-security-show-details-inline
5372 (let ((gnus-mime-security-button-pressed t)
5373 (gnus-mime-security-button-line-format
5374 (get-text-property (point) 'gnus-line-format))
5377 (while (eq (get-text-property (point) 'gnus-line-format)
5378 gnus-mime-security-button-line-format)
5381 (delete-region (point)
5382 (or (text-property-not-all
5385 gnus-mime-security-button-line-format)
5387 (gnus-insert-mime-security-button handle))
5388 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5389 (with-current-buffer gnus-mime-security-details-buffer
5392 (setq gnus-mime-security-details-buffer
5393 (gnus-get-buffer-create "*MIME Security Details*")))
5394 (with-current-buffer gnus-mime-security-details-buffer
5396 (goto-char (point-min)))
5397 (pop-to-buffer gnus-mime-security-details-buffer))
5398 (gnus-message 5 "No details."))))
5400 (defun gnus-mime-security-press-button (handle)
5401 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5402 (gnus-mime-security-show-details handle)
5403 (gnus-mime-security-verify-or-decrypt handle)))
5405 (defun gnus-insert-mime-security-button (handle &optional displayed)
5406 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5409 (or (nth 2 (assoc protocol mm-verify-function-alist))
5410 (nth 2 (assoc protocol mm-decrypt-function-alist))
5412 (if (equal (car handle) "multipart/signed")
5413 " Signed" " Encrypted")
5416 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5419 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5420 gnus-tmp-pressed-details
5422 (setq gnus-tmp-details
5423 (if gnus-tmp-details
5424 (concat "\n" gnus-tmp-details) ""))
5425 (setq gnus-tmp-pressed-details
5426 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5431 gnus-mime-security-button-line-format
5432 gnus-mime-security-button-line-format-alist
5433 `(keymap ,gnus-mime-security-button-map
5434 ,@(if (>= (string-to-number emacs-version) 21)
5435 nil ;; XEmacs doesn't care
5436 (list 'local-map gnus-mime-security-button-map))
5437 gnus-callback gnus-mime-security-press-button
5438 gnus-line-format ,gnus-mime-security-button-line-format
5439 article-type annotation
5442 (widget-convert-button
5445 :action 'gnus-widget-press-button
5446 :button-keymap gnus-mime-security-button-map
5448 (lambda (widget/window &optional overlay pos)
5449 ;; Needed to properly clear the message due to a bug in
5450 ;; wid-edit (XEmacs only).
5451 (if (boundp 'help-echo-owns-message)
5452 (setq help-echo-owns-message t))
5455 (aref gnus-mouse-2 0))))))
5457 (defun gnus-mime-display-security (handle)
5459 (narrow-to-region (point) (point))
5460 (gnus-insert-mime-security-button handle)
5461 (gnus-mime-display-mixed (cdr handle))
5464 (let ((gnus-mime-security-button-line-format
5465 gnus-mime-security-button-end-line-format))
5466 (gnus-insert-mime-security-button handle))
5467 (mm-set-handle-multipart-parameter
5469 (cons (set-marker (make-marker) (point-min))
5470 (set-marker (make-marker) (point-max))))))
5476 (run-hooks 'gnus-art-load-hook)
5478 ;;; gnus-art.el ends here