1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
31 (eval-when-compile (require 'static))
42 ;; Avoid byte-compile warnings.
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)The Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
113 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
114 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
115 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
116 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
117 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
118 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
119 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
120 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
121 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
122 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
123 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
124 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
125 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
126 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
127 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
128 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
129 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
130 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
131 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
132 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
133 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
134 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
135 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
136 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
137 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
138 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
139 "^X-Received:" "^Content-length:" "X-precedence:")
140 "*All headers that start with this regexp will be hidden.
141 This variable can also be a list of regexps of headers to be ignored.
142 If `gnus-visible-headers' is non-nil, this variable will be ignored."
143 :type '(choice :custom-show nil
146 :group 'gnus-article-hiding)
148 (defcustom gnus-visible-headers
149 "^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:"
150 "*All headers that do not match this regexp will be hidden.
151 This variable can also be a list of regexp of headers to remain visible.
152 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
153 :type '(repeat :value-to-internal (lambda (widget value)
154 (custom-split-regexp-maybe value))
155 :match (lambda (widget value)
157 (widget-editable-list-match widget value)))
159 :group 'gnus-article-hiding)
161 (defcustom gnus-sorted-header-list
162 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
163 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
164 "*This variable is a list of regular expressions.
165 If it is non-nil, headers that match the regular expressions will
166 be placed first in the article buffer in the sequence specified by
168 :type '(repeat regexp)
169 :group 'gnus-article-hiding)
171 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
172 "Headers that are only to be displayed if they have interesting data.
173 Possible values in this list are `empty', `newsgroups', `followup-to',
174 `reply-to', `date', `long-to', and `many-to'."
175 :type '(set (const :tag "Headers with no content." empty)
176 (const :tag "Newsgroups with only one group." newsgroups)
177 (const :tag "Followup-to identical to newsgroups." followup-to)
178 (const :tag "Reply-to identical to from." reply-to)
179 (const :tag "Date less than four days old." date)
180 (const :tag "Very long To and/or Cc header." long-to)
181 (const :tag "Multiple To and/or Cc headers." many-to))
182 :group 'gnus-article-hiding)
184 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
185 "Regexp matching signature separator.
186 This can also be a list of regexps. In that case, it will be checked
187 from head to tail looking for a separator. Searches will be done from
188 the end of the buffer."
189 :type '(repeat string)
190 :group 'gnus-article-signature)
192 (defcustom gnus-signature-limit nil
193 "Provide a limit to what is considered a signature.
194 If it is a number, no signature may not be longer (in characters) than
195 that number. If it is a floating point number, no signature may be
196 longer (in lines) than that number. If it is a function, the function
197 will be called without any parameters, and if it returns nil, there is
198 no signature in the buffer. If it is a string, it will be used as a
199 regexp. If it matches, the text in question is not a signature."
200 :type '(choice (integer :value 200)
202 (function :value fun)
203 (regexp :value ".*"))
204 :group 'gnus-article-signature)
206 (defcustom gnus-hidden-properties '(invisible t intangible t)
207 "Property list to use for hiding text."
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-x-face-command
213 ;; Fixme: This isn't the right thing for mixed graphical and and
214 ;; non-graphical frames in a session.
215 ;; gnus-xmas.el overrides this for XEmacs.
216 ((and (fboundp 'image-type-available-p)
217 (image-type-available-p 'xbm))
218 'gnus-article-display-xface)
219 ((and (not (featurep 'xemacs))
221 (module-installed-p 'x-face-mule))
222 'x-face-mule-gnus-article-display-x-face)
223 (gnus-article-compface-xbm
224 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -")
226 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
228 "*String or function to be executed to display an X-Face header.
229 If it is a string, the command will be executed in a sub-shell
230 asynchronously. The compressed face will be piped to this command."
231 :type '(choice string
232 (function-item gnus-article-display-xface)
233 (function-item x-face-mule-gnus-article-display-x-face)
235 :group 'gnus-article-washing)
237 (defcustom gnus-article-x-face-too-ugly nil
238 "Regexp matching posters whose face shouldn't be shown automatically."
239 :type '(choice regexp (const nil))
240 :group 'gnus-article-washing)
242 (defcustom gnus-article-banner-alist nil
243 "Banner alist for stripping.
245 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
246 :type '(repeat (cons symbol regexp))
247 :group 'gnus-article-washing)
249 (defcustom gnus-emphasis-alist
251 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
253 '(("_" "_" underline)
256 ("_/" "/_" underline-italic)
257 ("_\\*" "\\*_" underline-bold)
258 ("\\*/" "/\\*" bold-italic)
259 ("_\\*/" "/\\*_" underline-bold-italic))))
260 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
261 2 3 gnus-emphasis-underline)
265 (format format (car spec) (car (cdr spec)))
266 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
268 "*Alist that says how to fontify certain phrases.
269 Each item looks like this:
271 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
273 The first element is a regular expression to be matched. The second
274 is a number that says what regular expression grouping used to find
275 the entire emphasized word. The third is a number that says what
276 regexp grouping should be displayed and highlighted. The fourth
277 is the face used for highlighting."
278 :type '(repeat (list :value ("" 0 0 default)
280 (integer :tag "Match group")
281 (integer :tag "Emphasize group")
283 :group 'gnus-article-emphasis)
285 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
286 "A regexp to describe whitespace which should not be emphasized.
287 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
288 The former avoids underlining of leading and trailing whitespace,
289 and the latter avoids underlining any whitespace at all."
290 :group 'gnus-article-emphasis
293 (defface gnus-emphasis-bold '((t (:bold t)))
294 "Face used for displaying strong emphasized text (*word*)."
295 :group 'gnus-article-emphasis)
297 (defface gnus-emphasis-italic '((t (:italic t)))
298 "Face used for displaying italic emphasized text (/word/)."
299 :group 'gnus-article-emphasis)
301 (defface gnus-emphasis-underline '((t (:underline t)))
302 "Face used for displaying underlined emphasized text (_word_)."
303 :group 'gnus-article-emphasis)
305 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
306 "Face used for displaying underlined bold emphasized text (_*word*_)."
307 :group 'gnus-article-emphasis)
309 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
310 "Face used for displaying underlined italic emphasized text (_/word/_)."
311 :group 'gnus-article-emphasis)
313 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
314 "Face used for displaying bold italic emphasized text (/*word*/)."
315 :group 'gnus-article-emphasis)
317 (defface gnus-emphasis-underline-bold-italic
318 '((t (:bold t :italic t :underline t)))
319 "Face used for displaying underlined bold italic emphasized text.
320 Esample: (_/*word*/_)."
321 :group 'gnus-article-emphasis)
323 (defface gnus-emphasis-highlight-words
324 '((t (:background "black" :foreground "yellow")))
325 "Face used for displaying highlighted words."
326 :group 'gnus-article-emphasis)
328 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
329 "Format for display of Date headers in article bodies.
330 See `format-time-string' for the possible values.
332 The variable can also be function, which should return a complete Date
333 header. The function is called with one argument, the time, which can
334 be fed to `format-time-string'."
335 :type '(choice string symbol)
336 :link '(custom-manual "(gnus)Article Date")
337 :group 'gnus-article-washing)
340 (autoload 'mail-extract-address-components "mail-extr"))
342 (defcustom gnus-save-all-headers t
343 "*If non-nil, don't remove any headers before saving."
344 :group 'gnus-article-saving
347 (defcustom gnus-prompt-before-saving 'always
348 "*This variable says how much prompting is to be done when saving articles.
349 If it is nil, no prompting will be done, and the articles will be
350 saved to the default files. If this variable is `always', each and
351 every article that is saved will be preceded by a prompt, even when
352 saving large batches of articles. If this variable is neither nil not
353 `always', there the user will be prompted once for a file name for
354 each invocation of the saving commands."
355 :group 'gnus-article-saving
356 :type '(choice (item always)
357 (item :tag "never" nil)
358 (sexp :tag "once" :format "%t\n" :value t)))
360 (defcustom gnus-saved-headers gnus-visible-headers
361 "Headers to keep if `gnus-save-all-headers' is nil.
362 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
363 If that variable is nil, however, all headers that match this regexp
364 will be kept while the rest will be deleted before saving."
365 :group 'gnus-article-saving
368 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
369 "A function to save articles in your favourite format.
370 The function must be interactively callable (in other words, it must
371 be an Emacs command).
373 Gnus provides the following functions:
375 * gnus-summary-save-in-rmail (Rmail format)
376 * gnus-summary-save-in-mail (Unix mail format)
377 * gnus-summary-save-in-folder (MH folder)
378 * gnus-summary-save-in-file (article format)
379 * gnus-summary-save-in-vm (use VM's folder format)
380 * gnus-summary-write-to-file (article format -- overwrite)."
381 :group 'gnus-article-saving
382 :type '(radio (function-item gnus-summary-save-in-rmail)
383 (function-item gnus-summary-save-in-mail)
384 (function-item gnus-summary-save-in-folder)
385 (function-item gnus-summary-save-in-file)
386 (function-item gnus-summary-save-in-vm)
387 (function-item gnus-summary-write-to-file)))
389 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
390 "A function generating a file name to save articles in Rmail format.
391 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
392 :group 'gnus-article-saving
395 (defcustom gnus-mail-save-name 'gnus-plain-save-name
396 "A function generating a file name to save articles in Unix mail format.
397 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
398 :group 'gnus-article-saving
401 (defcustom gnus-folder-save-name 'gnus-folder-save-name
402 "A function generating a file name to save articles in MH folder.
403 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
404 :group 'gnus-article-saving
407 (defcustom gnus-file-save-name 'gnus-numeric-save-name
408 "A function generating a file name to save articles in article format.
409 The function is called with NEWSGROUP, HEADERS, and optional
411 :group 'gnus-article-saving
414 (defcustom gnus-split-methods
415 '((gnus-article-archive-name)
416 (gnus-article-nndoc-name))
417 "*Variable used to suggest where articles are to be saved.
418 For instance, if you would like to save articles related to Gnus in
419 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
420 you could set this variable to something like:
422 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
423 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
425 This variable is an alist where the where the key is the match and the
426 value is a list of possible files to save in if the match is non-nil.
428 If the match is a string, it is used as a regexp match on the
429 article. If the match is a symbol, that symbol will be funcalled
430 from the buffer of the article to be saved with the newsgroup as the
431 parameter. If it is a list, it will be evaled in the same buffer.
433 If this form or function returns a string, this string will be used as
434 a possible file name; and if it returns a non-nil list, that list will
435 be used as possible file names."
436 :group 'gnus-article-saving
437 :type '(repeat (choice (list :value (fun) function)
438 (cons :value ("" "") regexp (repeat string))
441 (defcustom gnus-article-display-method-for-mime
442 'gnus-article-display-mime-message
443 "Function to display a MIME message.
444 The function is called from the article buffer."
445 :group 'gnus-article-mime
448 (defcustom gnus-article-display-method-for-traditional
449 'gnus-article-display-traditional-message
450 "*Function to display a traditional message.
451 The function is called from the article buffer."
452 :group 'gnus-article-mime
455 (defcustom gnus-page-delimiter "^\^L"
456 "*Regexp describing what to use as article page delimiters.
457 The default value is \"^\^L\", which is a form linefeed at the
458 beginning of a line."
460 :group 'gnus-article-various)
462 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
463 "*The format specification for the article mode line.
464 See `gnus-summary-mode-line-format' for a closer description.
466 The following additional specs are available:
468 %w The article washing status.
469 %m The number of MIME parts in the article."
471 :group 'gnus-article-various)
473 (defcustom gnus-article-mode-hook nil
474 "*A hook for Gnus article mode."
476 :group 'gnus-article-various)
478 (defcustom gnus-article-menu-hook nil
479 "*Hook run after the creation of the article mode menu."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-prepare-hook nil
484 "*A hook called after an article has been prepared in the article buffer."
486 :group 'gnus-article-various)
488 (defcustom gnus-article-hide-pgp-hook nil
489 "*A hook called after successfully hiding a PGP signature."
491 :group 'gnus-article-various)
493 (defcustom gnus-article-button-face 'bold
494 "Face used for highlighting buttons in the article buffer.
496 An article button is a piece of text that you can activate by pressing
497 `RET' or `mouse-2' above it."
499 :group 'gnus-article-buttons)
501 (defcustom gnus-article-mouse-face 'highlight
502 "Face used for mouse highlighting in the article buffer.
504 Article buttons will be displayed in this face when the cursor is
507 :group 'gnus-article-buttons)
509 (defcustom gnus-signature-face 'gnus-signature-face
510 "Face used for highlighting a signature in the article buffer.
511 Obsolete; use the face `gnus-signature-face' for customizations instead."
513 :group 'gnus-article-highlight
514 :group 'gnus-article-signature)
516 (defface gnus-signature-face
519 "Face used for highlighting a signature in the article buffer."
520 :group 'gnus-article-highlight
521 :group 'gnus-article-signature)
523 (defface gnus-header-from-face
526 (:foreground "spring green"))
529 (:foreground "red3"))
532 "Face used for displaying from headers."
533 :group 'gnus-article-headers
534 :group 'gnus-article-highlight)
536 (defface gnus-header-subject-face
539 (:foreground "SeaGreen3"))
542 (:foreground "red4"))
544 (:bold t :italic t)))
545 "Face used for displaying subject headers."
546 :group 'gnus-article-headers
547 :group 'gnus-article-highlight)
549 (defface gnus-header-newsgroups-face
552 (:foreground "yellow" :italic t))
555 (:foreground "MidnightBlue" :italic t))
558 "Face used for displaying newsgroups headers."
559 :group 'gnus-article-headers
560 :group 'gnus-article-highlight)
562 (defface gnus-header-name-face
565 (:foreground "SeaGreen"))
568 (:foreground "maroon"))
571 "Face used for displaying header names."
572 :group 'gnus-article-headers
573 :group 'gnus-article-highlight)
575 (defface gnus-header-content-face
578 (:foreground "forest green" :italic t))
581 (:foreground "indianred4" :italic t))
583 (:italic t))) "Face used for displaying header content."
584 :group 'gnus-article-headers
585 :group 'gnus-article-highlight)
587 (defcustom gnus-header-face-alist
588 '(("From" nil gnus-header-from-face)
589 ("Subject" nil gnus-header-subject-face)
590 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
591 ("" gnus-header-name-face gnus-header-content-face))
592 "*Controls highlighting of article header.
594 An alist of the form (HEADER NAME CONTENT).
596 HEADER is a regular expression which should match the name of an
597 header header and NAME and CONTENT are either face names or nil.
599 The name of each header field will be displayed using the face
600 specified by the first element in the list where HEADER match the
601 header name and NAME is non-nil. Similarly, the content will be
602 displayed by the first non-nil matching CONTENT face."
603 :group 'gnus-article-headers
604 :group 'gnus-article-highlight
605 :type '(repeat (list (regexp :tag "Header")
607 (item :tag "skip" nil)
608 (face :value default))
609 (choice :tag "Content"
610 (item :tag "skip" nil)
611 (face :value default)))))
613 (defcustom gnus-article-decode-hook nil
614 "*Hook run to decode charsets in articles."
615 :group 'gnus-article-headers
618 (defcustom gnus-display-mime-function 'gnus-display-mime
619 "Function to display MIME articles."
620 :group 'gnus-article-mime
623 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
624 "Function used to decode headers.")
626 (defvar gnus-article-dumbquotes-map
644 "Table for MS-to-Latin1 translation.")
646 (defcustom gnus-ignored-mime-types nil
647 "List of MIME types that should be ignored by Gnus."
648 :group 'gnus-article-mime
649 :type '(repeat regexp))
651 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
652 "List of MIME types that should not be given buttons when rendered inline."
653 :group 'gnus-article-mime
654 :type '(repeat regexp))
656 (defcustom gnus-article-mime-part-function nil
657 "Function called with a MIME handle as the argument.
658 This is meant for people who want to do something automatic based
659 on parts -- for instance, adding Vcard info to a database."
660 :group 'gnus-article-mime
663 (defcustom gnus-mime-multipart-functions nil
664 "An alist of MIME types to functions to display them.")
666 (defcustom gnus-article-date-lapsed-new-header nil
667 "Whether the X-Sent and Date headers can coexist.
668 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
669 either replace the old \"Date:\" header (if this variable is nil), or
670 be added below it (otherwise)."
671 :group 'gnus-article-headers
674 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
675 "Function called with a MIME handle as the argument.
676 This is meant for people who want to view first matched part.
677 For `undisplayed-alternative' (default), the first undisplayed
678 part or alternative part is used. For `undisplayed', the first
679 undisplayed part is used. For a function, the first part which
680 the function return `t' is used. For `nil', the first part is
682 :group 'gnus-article-mime
684 (item :tag "first" :value nil)
685 (item :tag "undisplayed" :value undisplayed)
686 (item :tag "undisplayed or alternative"
687 :value undisplayed-alternative)
690 (defcustom gnus-mime-action-alist
691 '(("save to file" . gnus-mime-save-part)
692 ("save and strip" . gnus-mime-save-part-and-strip)
693 ("display as text" . gnus-mime-inline-part)
694 ("view the part" . gnus-mime-view-part)
695 ("pipe to command" . gnus-mime-pipe-part)
696 ("toggle display" . gnus-article-press-button)
697 ("toggle display" . gnus-article-view-part-as-charset)
698 ("view as type" . gnus-mime-view-part-as-type)
699 ("internalize type" . gnus-mime-internalize-part)
700 ("externalize type" . gnus-mime-externalize-part))
701 "An alist of actions that run on the MIME attachment."
702 :group 'gnus-article-mime
703 :type '(repeat (cons (string :tag "name")
707 ;;; The treatment variables
710 (defvar gnus-part-display-hook nil
711 "Hook called on parts that are to receive treatment.")
713 (defvar gnus-article-treat-custom
714 '(choice (const :tag "Off" nil)
716 (const :tag "Header" head)
717 (const :tag "Last" last)
718 (const :tag "Mime" mime)
719 (integer :tag "Less")
720 (repeat :tag "Groups" regexp)
721 (sexp :tag "Predicate")))
723 (defvar gnus-article-treat-head-custom
724 '(choice (const :tag "Off" nil)
725 (const :tag "Header" head)))
727 (defvar gnus-article-treat-types '("text/plain")
730 (defvar gnus-inhibit-treatment nil
731 "Whether to inhibit treatment.")
733 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
734 "Highlight the signature.
735 Valid values are nil, t, `head', `last', an integer or a predicate.
736 See the manual for details."
737 :group 'gnus-article-treat
738 :type gnus-article-treat-custom)
739 (put 'gnus-treat-highlight-signature 'highlight t)
741 (defcustom gnus-treat-buttonize 100000
743 Valid values are nil, t, `head', `last', an integer or a predicate.
744 See the manual for details."
745 :group 'gnus-article-treat
746 :type gnus-article-treat-custom)
747 (put 'gnus-treat-buttonize 'highlight t)
749 (defcustom gnus-treat-buttonize-head 'head
750 "Add buttons to the head.
751 Valid values are nil, t, `head', `last', an integer or a predicate.
752 See the manual for details."
753 :group 'gnus-article-treat
754 :type gnus-article-treat-head-custom)
755 (put 'gnus-treat-buttonize-head 'highlight t)
757 (defcustom gnus-treat-emphasize nil
759 Valid values are nil, t, `head', `last', an integer or a predicate.
760 See the manual for details."
761 :group 'gnus-article-treat
762 :type gnus-article-treat-custom)
763 (put 'gnus-treat-emphasize 'highlight t)
765 (defcustom gnus-treat-strip-cr nil
766 "Remove carriage returns.
767 Valid values are nil, t, `head', `last', an integer or a predicate.
768 See the manual for details."
769 :group 'gnus-article-treat
770 :type gnus-article-treat-custom)
772 (defcustom gnus-treat-hide-headers 'head
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-head-custom)
779 (defcustom gnus-treat-hide-boring-headers nil
780 "Hide boring headers.
781 Valid values are nil, t, `head', `last', an integer or a predicate.
782 See the manual for details."
783 :group 'gnus-article-treat
784 :type gnus-article-treat-head-custom)
786 (defcustom gnus-treat-hide-signature nil
788 Valid values are nil, t, `head', `last', an integer or a predicate.
789 See the manual for details."
790 :group 'gnus-article-treat
791 :type gnus-article-treat-custom)
793 (defcustom gnus-treat-fill-article nil
795 Valid values are nil, t, `head', `last', an integer or a predicate.
796 See the manual for details."
797 :group 'gnus-article-treat
798 :type gnus-article-treat-custom)
800 (defcustom gnus-treat-hide-citation nil
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-citation-maybe nil
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-custom)
814 (defcustom gnus-treat-strip-list-identifiers 'head
815 "Strip list identifiers from `gnus-list-identifiers`.
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-custom)
821 (defcustom gnus-treat-strip-pgp t
822 "Strip PGP signatures.
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-strip-pem nil
829 "Strip PEM signatures.
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-strip-banner t
836 "Strip banners from articles.
837 The banner to be stripped is specified in the `banner' group parameter.
838 Valid values are nil, t, `head', `last', an integer or a predicate.
839 See the manual for details."
840 :group 'gnus-article-treat
841 :type gnus-article-treat-custom)
843 (defcustom gnus-treat-highlight-headers 'head
844 "Highlight the headers.
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See the manual for details."
847 :group 'gnus-article-treat
848 :type gnus-article-treat-head-custom)
849 (put 'gnus-treat-highlight-headers 'highlight t)
851 (defcustom gnus-treat-highlight-citation t
852 "Highlight cited text.
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See the manual for details."
855 :group 'gnus-article-treat
856 :type gnus-article-treat-custom)
857 (put 'gnus-treat-highlight-citation 'highlight t)
859 (defcustom gnus-treat-date-ut nil
860 "Display the Date in UT (GMT).
861 Valid values are nil, t, `head', `last', an integer or a predicate.
862 See the manual for details."
863 :group 'gnus-article-treat
864 :type gnus-article-treat-head-custom)
866 (defcustom gnus-treat-date-local nil
867 "Display the Date in the local timezone.
868 Valid values are nil, t, `head', `last', an integer or a predicate.
869 See the manual for details."
870 :group 'gnus-article-treat
871 :type gnus-article-treat-head-custom)
873 (defcustom gnus-treat-date-lapsed nil
874 "Display the Date header in a way that says how much time has elapsed.
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See the manual for details."
877 :group 'gnus-article-treat
878 :type gnus-article-treat-head-custom)
880 (defcustom gnus-treat-date-original nil
881 "Display the date in the original timezone.
882 Valid values are nil, t, `head', `last', an integer or a predicate.
883 See the manual for details."
884 :group 'gnus-article-treat
885 :type gnus-article-treat-head-custom)
887 (defcustom gnus-treat-date-iso8601 nil
888 "Display the date in the ISO8601 format.
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See the manual for details."
891 :group 'gnus-article-treat
892 :type gnus-article-treat-head-custom)
894 (defcustom gnus-treat-date-user-defined nil
895 "Display the date in a user-defined format.
896 The format is defined by the `gnus-article-time-format' variable.
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See the manual for details."
899 :group 'gnus-article-treat
900 :type gnus-article-treat-head-custom)
902 (defcustom gnus-treat-strip-headers-in-body t
903 "Strip the X-No-Archive header line from the beginning of the body.
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-custom)
909 (defcustom gnus-treat-strip-trailing-blank-lines nil
910 "Strip trailing blank lines.
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-custom)
916 (defcustom gnus-treat-strip-leading-blank-lines nil
917 "Strip leading blank lines.
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-custom)
923 (defcustom gnus-treat-strip-multiple-blank-lines nil
924 "Strip multiple blank lines.
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-custom)
930 (defcustom gnus-treat-overstrike t
931 "Treat overstrike highlighting.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See the manual for details."
934 :group 'gnus-article-treat
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-overstrike 'highlight t)
938 (defcustom gnus-treat-display-xface
939 (and (or (and (fboundp 'image-type-available-p)
940 (image-type-available-p 'xbm)
941 (string-match "^0x" (shell-command-to-string "uncompface")))
942 (and (featurep 'xemacs) (featurep 'xface))
943 (eq 'x-face-mule-gnus-article-display-x-face
944 gnus-article-x-face-command))
946 "Display X-Face headers.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See the manual for details."
949 :group 'gnus-article-treat
950 :type gnus-article-treat-head-custom)
951 (put 'gnus-treat-display-xface 'highlight t)
953 (defcustom gnus-treat-display-smileys
954 (if (or (and (featurep 'xemacs)
956 (and (fboundp 'image-type-available-p)
957 (image-type-available-p 'pbm))
958 (and (not (featurep 'xemacs))
960 (module-installed-p 'gnus-bitmap)))
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See the manual for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-custom)
968 (put 'gnus-treat-display-smileys 'highlight t)
970 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See the manual for details."
974 :group 'gnus-article-treat
975 :type gnus-article-treat-head-custom)
976 (put 'gnus-treat-display-picons 'highlight t)
978 (defcustom gnus-treat-capitalize-sentences nil
979 "Capitalize sentence-starting words.
980 Valid values are nil, t, `head', `last', an integer or a predicate.
981 See the manual for details."
982 :group 'gnus-article-treat
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-fill-long-lines nil
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See the manual for details."
989 :group 'gnus-article-treat
990 :type gnus-article-treat-custom)
992 (defcustom gnus-treat-play-sounds nil
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See the manual for details."
996 :group 'gnus-article-treat
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1000 "Decode an article as `default-mime-charset'. For instance, if you want to
1001 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1002 you could set this variable to something like: nil for don't decode, t for
1003 decode the body, '(or header t) for the whole article, etc."
1004 :group 'gnus-article-treat
1005 :type '(radio (const :tag "Off" nil)
1006 (const :tag "Decode body" t)
1007 (const :tag "Decode all" (or head t))))
1009 (defcustom gnus-treat-translate nil
1010 "Translate articles from one language to another.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See the manual for details."
1013 :group 'gnus-article-treat
1014 :type gnus-article-treat-custom)
1016 (defcustom gnus-treat-x-pgp-sig 'head
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 :group 'mime-security
1022 :type gnus-article-treat-custom)
1024 (defvar gnus-article-encrypt-protocol-alist
1025 '(("PGP" . mml2015-self-encrypt)))
1027 ;; Set to nil if more than one protocol added to
1028 ;; gnus-article-encrypt-protocol-alist.
1029 (defcustom gnus-article-encrypt-protocol "PGP"
1030 "The protocol used for encrypt articles.
1031 It is a string, such as \"PGP\". If nil, ask user."
1033 :group 'mime-security)
1035 ;;; Internal variables
1037 (defvar article-goto-body-goes-to-point-min-p nil)
1038 (defvar gnus-article-wash-types nil)
1039 (defvar gnus-article-emphasis-alist nil)
1041 (defvar gnus-article-mime-handle-alist-1 nil)
1042 (defvar gnus-treatment-function-alist
1043 '((gnus-treat-decode-article-as-default-mime-charset
1044 gnus-article-decode-article-as-default-mime-charset)
1045 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1046 (gnus-treat-strip-banner gnus-article-strip-banner)
1047 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1048 (gnus-treat-buttonize gnus-article-add-buttons)
1049 (gnus-treat-fill-article gnus-article-fill-cited-article)
1050 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1051 (gnus-treat-strip-cr gnus-article-remove-cr)
1052 (gnus-treat-display-xface gnus-article-display-x-face)
1053 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1054 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1055 (gnus-treat-hide-signature gnus-article-hide-signature)
1056 (gnus-treat-hide-citation gnus-article-hide-citation)
1057 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1058 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1059 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1060 (gnus-treat-strip-pem gnus-article-hide-pem)
1061 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1062 (gnus-treat-emphasize gnus-article-emphasize)
1063 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1064 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1065 (gnus-treat-date-ut gnus-article-date-ut)
1066 (gnus-treat-date-local gnus-article-date-local)
1067 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1068 (gnus-treat-date-original gnus-article-date-original)
1069 (gnus-treat-date-user-defined gnus-article-date-user)
1070 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1071 (gnus-treat-strip-trailing-blank-lines
1072 gnus-article-remove-trailing-blank-lines)
1073 (gnus-treat-strip-leading-blank-lines
1074 gnus-article-strip-leading-blank-lines)
1075 (gnus-treat-strip-multiple-blank-lines
1076 gnus-article-strip-multiple-blank-lines)
1077 (gnus-treat-overstrike gnus-article-treat-overstrike)
1078 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1079 (gnus-treat-display-smileys gnus-article-smiley-display)
1080 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1081 (gnus-treat-display-picons gnus-article-display-picons)
1082 (gnus-treat-play-sounds gnus-earcon-display)))
1084 (defvar gnus-article-mime-handle-alist nil)
1085 (defvar article-lapsed-timer nil)
1086 (defvar gnus-article-current-summary nil)
1088 (defvar gnus-article-mode-syntax-table
1089 (let ((table (copy-syntax-table text-mode-syntax-table)))
1090 (modify-syntax-entry ?- "w" table)
1091 (modify-syntax-entry ?> ")" table)
1092 (modify-syntax-entry ?< "(" table)
1094 "Syntax table used in article mode buffers.
1095 Initialized from `text-mode-syntax-table.")
1097 (defvar gnus-save-article-buffer nil)
1099 (defvar gnus-article-mode-line-format-alist
1100 (nconc '((?w (gnus-article-wash-status) ?s)
1101 (?m (gnus-article-mime-part-status) ?s))
1102 gnus-summary-mode-line-format-alist))
1104 (defvar gnus-number-of-articles-to-be-saved nil)
1106 (defvar gnus-inhibit-hiding nil)
1108 (defsubst gnus-article-hide-text (b e props)
1109 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1110 (add-text-properties b e props)
1111 (when (memq 'intangible props)
1113 (max (1- b) (point-min))
1114 b 'intangible (cddr (memq 'intangible props)))))
1115 (defsubst gnus-article-unhide-text (b e)
1116 "Remove hidden text properties from region between B and E."
1117 (remove-text-properties b e gnus-hidden-properties)
1118 (when (memq 'intangible gnus-hidden-properties)
1119 (put-text-property (max (1- b) (point-min))
1120 b 'intangible nil)))
1122 (defun gnus-article-hide-text-type (b e type)
1123 "Hide text of TYPE between B and E."
1124 (push type gnus-article-wash-types)
1125 (gnus-article-hide-text
1126 b e (cons 'article-type (cons type gnus-hidden-properties))))
1128 (defun gnus-article-unhide-text-type (b e type)
1129 "Unhide text of TYPE between B and E."
1130 (setq gnus-article-wash-types
1131 (delq type gnus-article-wash-types))
1132 (remove-text-properties
1133 b e (cons 'article-type (cons type gnus-hidden-properties)))
1134 (when (memq 'intangible gnus-hidden-properties)
1135 (put-text-property (max (1- b) (point-min))
1136 b 'intangible nil)))
1138 (defun gnus-article-hide-text-of-type (type)
1139 "Hide text of TYPE in the current buffer."
1141 (let ((b (point-min))
1143 (while (setq b (text-property-any b e 'article-type type))
1144 (add-text-properties b (incf b) gnus-hidden-properties)))))
1146 (defun gnus-article-delete-text-of-type (type)
1147 "Delete text of TYPE in the current buffer."
1149 (let ((b (point-min)))
1150 (while (setq b (text-property-any b (point-max) 'article-type type))
1152 b (or (text-property-not-all b (point-max) 'article-type type)
1155 (defun gnus-article-delete-invisible-text ()
1156 "Delete all invisible text in the current buffer."
1158 (let ((b (point-min)))
1159 (while (setq b (text-property-any b (point-max) 'invisible t))
1161 b (or (text-property-not-all b (point-max) 'invisible t)
1164 (defun gnus-article-text-type-exists-p (type)
1165 "Say whether any text of type TYPE exists in the buffer."
1166 (text-property-any (point-min) (point-max) 'article-type type))
1168 (defsubst gnus-article-header-rank ()
1169 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1170 (let ((list gnus-sorted-header-list)
1173 (when (looking-at (car list))
1175 (setq list (cdr list))
1179 (defun article-hide-headers (&optional arg delete)
1180 "Hide unwanted headers and possibly sort them as well."
1181 (interactive (gnus-article-hidden-arg))
1182 ;; Lars said that this function might be inhibited.
1183 (if (gnus-article-check-hidden-text 'headers arg)
1185 ;; Show boring headers as well.
1186 (gnus-article-show-hidden-text 'boring-headers)
1187 (when (eq 1 (point-min))
1188 (set-window-start (get-buffer-window (current-buffer)) 1)))
1189 (unless gnus-inhibit-hiding
1192 (let ((buffer-read-only nil)
1193 (inhibit-read-only t)
1194 (case-fold-search t)
1195 (max (1+ (length gnus-sorted-header-list)))
1196 (ignored (when (not gnus-visible-headers)
1197 (cond ((stringp gnus-ignored-headers)
1198 gnus-ignored-headers)
1199 ((listp gnus-ignored-headers)
1200 (mapconcat 'identity gnus-ignored-headers
1203 (cond ((stringp gnus-visible-headers)
1204 gnus-visible-headers)
1205 ((and gnus-visible-headers
1206 (listp gnus-visible-headers))
1207 (mapconcat 'identity gnus-visible-headers "\\|"))))
1208 (inhibit-point-motion-hooks t)
1210 ;; First we narrow to just the headers.
1211 (article-narrow-to-head)
1212 ;; Hide any "From " lines at the beginning of (mail) articles.
1213 (while (looking-at "From ")
1217 (delete-region (point-min) (point))
1218 (gnus-article-hide-text (point-min) (point)
1219 (nconc (list 'article-type 'headers)
1220 gnus-hidden-properties))))
1221 ;; Then treat the rest of the header lines.
1222 ;; Then we use the two regular expressions
1223 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1224 ;; select which header lines is to remain visible in the
1226 (while (re-search-forward "^[^ \t]*:" nil t)
1228 ;; Mark the rank of the header.
1230 (point) (1+ (point)) 'message-rank
1231 (if (or (and visible (looking-at visible))
1233 (not (looking-at ignored))))
1234 (gnus-article-header-rank)
1237 (message-sort-headers-1)
1238 (when (setq beg (text-property-any
1239 (point-min) (point-max) 'message-rank (+ 2 max)))
1240 ;; We delete or make invisible the unwanted headers.
1241 (push 'headers gnus-article-wash-types)
1244 (add-text-properties
1245 (point-min) (+ 5 (point-min))
1246 '(article-type headers dummy-invisible t))
1247 (delete-region beg (point-max)))
1248 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1251 (defun article-hide-boring-headers (&optional arg)
1252 "Toggle hiding of headers that aren't very interesting.
1253 If given a negative prefix, always show; if given a positive prefix,
1255 (interactive (gnus-article-hidden-arg))
1256 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1257 (not gnus-show-all-headers))
1260 (let ((buffer-read-only nil)
1261 (list gnus-boring-article-headers)
1262 (inhibit-point-motion-hooks t)
1264 (article-narrow-to-head)
1266 (setq elem (pop list))
1267 (goto-char (point-min))
1269 ;; Hide empty headers.
1271 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1273 (gnus-article-hide-text-type
1274 (progn (beginning-of-line) (point))
1277 (if (re-search-forward "^[^ \t]" nil t)
1281 ;; Hide boring Newsgroups header.
1282 ((eq elem 'newsgroups)
1283 (when (equal (gnus-fetch-field "newsgroups")
1284 (gnus-group-real-name
1285 (if (boundp 'gnus-newsgroup-name)
1288 (gnus-article-hide-header "newsgroups")))
1289 ((eq elem 'followup-to)
1290 (when (equal (message-fetch-field "followup-to")
1291 (message-fetch-field "newsgroups"))
1292 (gnus-article-hide-header "followup-to")))
1293 ((eq elem 'reply-to)
1294 (let ((from (message-fetch-field "from"))
1295 (reply-to (message-fetch-field "reply-to")))
1300 (nth 1 (funcall gnus-extract-address-components from))
1301 (nth 1 (funcall gnus-extract-address-components reply-to)))))
1302 (gnus-article-hide-header "reply-to"))))
1304 (let ((date (message-fetch-field "date")))
1306 (< (days-between (current-time-string) date)
1308 (gnus-article-hide-header "date"))))
1310 (let ((to (message-fetch-field "to"))
1311 (cc (message-fetch-field "cc")))
1312 (when (> (length to) 1024)
1313 (gnus-article-hide-header "to"))
1314 (when (> (length cc) 1024)
1315 (gnus-article-hide-header "cc"))))
1319 (goto-char (point-min))
1320 (while (re-search-forward "^to:" nil t)
1321 (setq to-count (1+ to-count)))
1322 (when (> to-count 1)
1323 (while (> to-count 0)
1324 (goto-char (point-min))
1326 (re-search-forward "^to:" nil nil to-count)
1328 (narrow-to-region (point) (point-max))
1329 (gnus-article-hide-header "to"))
1330 (setq to-count (1- to-count))))
1331 (goto-char (point-min))
1332 (while (re-search-forward "^cc:" nil t)
1333 (setq cc-count (1+ cc-count)))
1334 (when (> cc-count 1)
1335 (while (> cc-count 0)
1336 (goto-char (point-min))
1338 (re-search-forward "^cc:" nil nil cc-count)
1340 (narrow-to-region (point) (point-max))
1341 (gnus-article-hide-header "cc"))
1342 (setq cc-count (1- cc-count)))))))))))))
1344 (defun gnus-article-hide-header (header)
1346 (goto-char (point-min))
1347 (when (re-search-forward (concat "^" header ":") nil t)
1348 (gnus-article-hide-text-type
1349 (progn (beginning-of-line) (point))
1352 (if (re-search-forward "^[^ \t]" nil t)
1357 (defun article-toggle-headers (&optional arg)
1358 "Toggle hiding of headers. If given a negative prefix, always show;
1359 if given a positive prefix, always hide."
1360 (interactive (gnus-article-hidden-arg))
1361 (let ((force (when (numberp arg)
1362 (cond ((> arg 0) 'always-hide)
1363 ((< arg 0) 'always-show))))
1364 (window (get-buffer-window gnus-article-buffer))
1365 (header-end (point-min))
1366 header-start field-end field-start
1367 (inhibit-point-motion-hooks t)
1368 (inhibit-read-only t)
1372 (while (and (setq header-start
1373 (text-property-any header-end (point-max)
1374 'article-treated-header t))
1376 (text-property-not-all header-start (point-max)
1377 'article-treated-header t)))
1378 (setq field-end header-start)
1380 (;; Hide exposed invisible fields.
1381 (and (not (eq 'always-show force))
1383 (text-property-any field-end header-end
1384 'exposed-invisible-field t)))
1385 (while (and field-start
1386 (setq field-end (text-property-not-all
1387 field-start header-end
1388 'exposed-invisible-field t)))
1389 (add-text-properties field-start field-end gnus-hidden-properties)
1390 (setq field-start (text-property-any field-end header-end
1391 'exposed-invisible-field t)))
1392 (put-text-property header-start header-end
1393 'exposed-invisible-field nil))
1394 (;; Expose invisible fields.
1395 (and (not (eq 'always-hide force))
1397 (text-property-any field-end header-end 'invisible t)))
1398 (while (and field-start
1399 (setq field-end (text-property-not-all
1400 field-start header-end
1402 ;; If the invisible text is not terminated with newline, we
1403 ;; won't expose it. Because it may be created by x-face-mule.
1404 ;; BTW, XEmacs sometimes fail in putting a invisible text
1405 ;; property with `gnus-article-hide-text' (really?). In that
1406 ;; case, the invisible text might be started from the middle of
1407 ;; a line so we will expose the sort of thing.
1408 (when (or (not (or (eq header-start field-start)
1409 (eq ?\n (char-before field-start))))
1410 (eq ?\n (char-before field-end)))
1411 (remove-text-properties field-start field-end
1412 gnus-hidden-properties)
1413 (put-text-property field-start field-end
1414 'exposed-invisible-field t))
1415 (setq field-start (text-property-any field-end header-end
1418 (not (eq 'always-show force))
1419 (narrow-to-region header-start header-end)
1420 (article-hide-headers)
1421 ;; Re-display X-Face image under XEmacs.
1422 (when (and (featurep 'xemacs)
1423 (gnus-functionp gnus-article-x-face-command))
1424 (let ((func (cadr (assq 'gnus-treat-display-xface
1425 gnus-treatment-function-alist)))
1427 (when (and (not gnus-inhibit-treatment)
1429 (gnus-treat-predicate gnus-treat-display-xface))
1431 (put-text-property header-start header-end 'read-only nil))))
1434 (goto-char (point-min))
1436 (set-window-start window (point-min))))))
1438 (defvar gnus-article-normalized-header-length 40
1439 "Length of normalized headers.")
1441 (defun article-normalize-headers ()
1442 "Make all header lines 40 characters long."
1444 (let ((buffer-read-only nil)
1448 (article-narrow-to-head)
1451 ((< (setq column (- (gnus-point-at-eol) (point)))
1452 gnus-article-normalized-header-length)
1454 (insert (make-string
1455 (- gnus-article-normalized-header-length column)
1457 ((> column gnus-article-normalized-header-length)
1458 (gnus-put-text-property
1460 (forward-char gnus-article-normalized-header-length)
1467 (forward-line 1))))))
1469 (defun article-treat-dumbquotes ()
1470 "Translate M******** sm*rtq**t*s into proper text.
1471 Note that this function guesses whether a character is a sm*rtq**t* or
1472 not, so it should only be used interactively."
1474 (article-translate-strings gnus-article-dumbquotes-map))
1476 (defun article-translate-characters (from to)
1477 "Translate all characters in the body of the article according to FROM and TO.
1478 FROM is a string of characters to translate from; to is a string of
1479 characters to translate to."
1481 (when (article-goto-body)
1482 (let ((buffer-read-only nil)
1483 (x (make-string 225 ?x))
1485 (while (< (incf i) (length x))
1488 (while (< i (length from))
1489 (aset x (aref from i) (aref to i))
1491 (translate-region (point) (point-max) x)))))
1493 (defun article-translate-strings (map)
1494 "Translate all string in the body of the article according to MAP.
1495 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1497 (when (article-goto-body)
1498 (let ((buffer-read-only nil)
1500 (while (setq elem (pop map))
1502 (while (search-forward (car elem) nil t)
1503 (replace-match (cadr elem)))))))))
1505 (defun article-treat-overstrike ()
1506 "Translate overstrikes into bold text."
1509 (when (article-goto-body)
1510 (let ((buffer-read-only nil))
1511 (while (search-forward "\b" nil t)
1512 (let ((next (char-after))
1516 previous (char-after))
1520 ;; We do the boldification/underlining by hiding the
1521 ;; overstrikes and putting the proper text property
1525 (gnus-article-hide-text-type start (point) 'overstrike)
1526 (put-text-property (point) end 'face 'bold))
1528 (gnus-article-hide-text-type
1529 (1- (point)) (1+ (point)) 'overstrike)
1531 start (1- (point)) 'face 'underline))
1533 (gnus-article-hide-text-type start (point) 'overstrike)
1535 (point) end 'face 'underline)))))))))
1537 (defun article-fill-long-lines ()
1538 "Fill lines that are wider than the window width."
1541 (let ((buffer-read-only nil)
1542 (width (window-width (get-buffer-window (current-buffer)))))
1545 (let ((adaptive-fill-mode nil))
1548 (when (>= (current-column) (min fill-column width))
1549 (narrow-to-region (point) (gnus-point-at-bol))
1550 (fill-paragraph nil)
1551 (goto-char (point-max))
1553 (forward-line 1)))))))
1555 (defun article-capitalize-sentences ()
1556 "Capitalize the first word in each sentence."
1559 (let ((buffer-read-only nil)
1560 (paragraph-start "^[\n\^L]"))
1564 (forward-sentence)))))
1566 (defun article-remove-cr ()
1567 "Remove trailing CRs and then translate remaining CRs into LFs."
1570 (let ((buffer-read-only nil))
1571 (goto-char (point-min))
1572 (while (re-search-forward "\r+$" nil t)
1573 (replace-match "" t t))
1574 (goto-char (point-min))
1575 (while (search-forward "\r" nil t)
1576 (replace-match "\n" t t)))))
1578 (defun article-remove-trailing-blank-lines ()
1579 "Remove all trailing blank lines from the article."
1582 (let ((buffer-read-only nil))
1583 (goto-char (point-max))
1587 (while (and (not (bobp))
1588 (looking-at "^[ \t]*$")
1589 (not (gnus-annotation-in-region-p
1590 (point) (gnus-point-at-eol))))
1595 (defun article-display-x-face (&optional force)
1596 "Look for an X-Face header and display it if present."
1597 (interactive (list 'force))
1599 ;; Delete the old process, if any.
1600 (when (process-status "article-x-face")
1601 (delete-process "article-x-face"))
1602 (let ((inhibit-point-motion-hooks t)
1603 (case-fold-search t)
1606 (article-narrow-to-head)
1607 (goto-char (point-min))
1608 (setq from (message-fetch-field "from"))
1609 (goto-char (point-min))
1610 (while (and gnus-article-x-face-command
1613 ;; Check whether this face is censored.
1614 (not gnus-article-x-face-too-ugly)
1615 (and gnus-article-x-face-too-ugly from
1616 (not (string-match gnus-article-x-face-too-ugly
1618 ;; Has to be present.
1619 (re-search-forward "^X-Face:[ \t]*" nil t))
1620 ;; This used to try to do multiple faces (`while' instead of
1621 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1622 ;; work (b) it can crash some versions of Emacs (c) are
1623 ;; multiple faces really something to encourage?
1624 (when (stringp gnus-article-x-face-command)
1626 ;; We now have the area of the buffer where the X-Face is stored.
1629 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1630 ;; We display the face.
1631 (if (symbolp gnus-article-x-face-command)
1632 ;; The command is a lisp function, so we call it.
1633 (if (gnus-functionp gnus-article-x-face-command)
1634 (funcall gnus-article-x-face-command beg end)
1635 (error "%s is not a function" gnus-article-x-face-command))
1636 ;; The command is a string, so we interpret the command
1637 ;; as a, well, command, and fork it off.
1638 (let ((process-connection-type nil))
1639 (process-kill-without-query
1641 "article-x-face" nil shell-file-name shell-command-switch
1642 gnus-article-x-face-command))
1643 (process-send-region "article-x-face" beg end)
1644 (process-send-eof "article-x-face"))))))))))
1646 (defun article-decode-mime-words ()
1647 "Decode all MIME-encoded words in the article."
1650 (set-buffer gnus-article-buffer)
1651 (let ((inhibit-point-motion-hooks t)
1653 (mail-parse-charset gnus-newsgroup-charset)
1654 (mail-parse-ignored-charsets
1655 (save-excursion (set-buffer gnus-summary-buffer)
1656 gnus-newsgroup-ignored-charsets)))
1657 (mail-decode-encoded-word-region (point-min) (point-max)))))
1659 (defun article-decode-charset (&optional prompt)
1660 "Decode charset-encoded text in the article.
1661 If PROMPT (the prefix), prompt for a coding system to use."
1663 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1665 (mail-parse-charset gnus-newsgroup-charset)
1666 (mail-parse-ignored-charsets
1667 (save-excursion (condition-case nil
1668 (set-buffer gnus-summary-buffer)
1670 gnus-newsgroup-ignored-charsets))
1671 ct cte ctl charset format)
1674 (article-narrow-to-head)
1675 (setq ct (message-fetch-field "Content-Type" t)
1676 cte (message-fetch-field "Content-Transfer-Encoding" t)
1677 ctl (and ct (ignore-errors
1678 (mail-header-parse-content-type ct)))
1681 (mm-read-coding-system "Charset to decode: "))
1683 (mail-content-type-get ctl 'charset)))
1684 format (and ctl (mail-content-type-get ctl 'format)))
1686 (setq cte (mail-header-strip cte)))
1687 (if (and ctl (not (string-match "/" (car ctl))))
1689 (goto-char (point-max)))
1692 (narrow-to-region (point) (point-max))
1693 (when (and (eq mail-parse-charset 'gnus-decoded)
1694 (eq (mm-body-7-or-8) '8bit))
1695 ;; The text code could have been decoded.
1696 (setq charset mail-parse-charset))
1697 (when (and (or (not ctl)
1698 (equal (car ctl) "text/plain"))
1699 (not format)) ;; article with format will decode later.
1701 charset (and cte (intern (downcase
1702 (gnus-strip-whitespace cte))))
1705 (defun article-decode-encoded-words ()
1706 "Remove encoded-word encoding from headers."
1707 (let (buffer-read-only)
1708 (let ((charset (save-excursion
1709 (set-buffer gnus-summary-buffer)
1710 default-mime-charset)))
1711 (mime-decode-header-in-buffer charset)
1714 (defun article-de-quoted-unreadable (&optional force)
1715 "Translate a quoted-printable-encoded article.
1716 If FORCE, decode the article whether it is marked as quoted-printable
1718 (interactive (list 'force))
1720 (let ((buffer-read-only nil) type charset)
1721 (if (gnus-buffer-live-p gnus-original-article-buffer)
1722 (with-current-buffer gnus-original-article-buffer
1724 (gnus-fetch-field "content-transfer-encoding"))
1725 (let* ((ct (gnus-fetch-field "content-type"))
1728 (mail-header-parse-content-type ct)))))
1729 (setq charset (and ctl
1730 (mail-content-type-get ctl 'charset)))
1731 (if (stringp charset)
1732 (setq charset (intern (downcase charset)))))))
1734 (setq charset gnus-newsgroup-charset))
1736 (and type (let ((case-fold-search t))
1737 (string-match "quoted-printable" type))))
1739 (quoted-printable-decode-region
1740 (point) (point-max) (mm-charset-to-coding-system charset))))))
1742 (defun article-de-base64-unreadable (&optional force)
1743 "Translate a base64 article.
1744 If FORCE, decode the article whether it is marked as base64 not."
1745 (interactive (list 'force))
1747 (let ((buffer-read-only nil) type charset)
1748 (if (gnus-buffer-live-p gnus-original-article-buffer)
1749 (with-current-buffer gnus-original-article-buffer
1751 (gnus-fetch-field "content-transfer-encoding"))
1752 (let* ((ct (gnus-fetch-field "content-type"))
1755 (mail-header-parse-content-type ct)))))
1756 (setq charset (and ctl
1757 (mail-content-type-get ctl 'charset)))
1758 (if (stringp charset)
1759 (setq charset (intern (downcase charset)))))))
1761 (setq charset gnus-newsgroup-charset))
1763 (and type (let ((case-fold-search t))
1764 (string-match "base64" type))))
1767 (narrow-to-region (point) (point-max))
1768 (base64-decode-region (point-min) (point-max))
1769 (mm-decode-coding-region
1770 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1775 (defun article-decode-HZ ()
1776 "Translate a HZ-encoded article."
1780 (let ((buffer-read-only nil))
1781 (rfc1843-decode-region (point-min) (point-max)))))
1783 (defun article-wash-html ()
1784 "Format an html article."
1787 (let ((buffer-read-only nil)
1789 (if (gnus-buffer-live-p gnus-original-article-buffer)
1790 (with-current-buffer gnus-original-article-buffer
1791 (let* ((ct (gnus-fetch-field "content-type"))
1794 (mail-header-parse-content-type ct)))))
1795 (setq charset (and ctl
1796 (mail-content-type-get ctl 'charset)))
1797 (if (stringp charset)
1798 (setq charset (intern (downcase charset)))))))
1800 (setq charset gnus-newsgroup-charset))
1802 (save-window-excursion
1804 (narrow-to-region (point) (point-max))
1806 (let ((w3-strict-width (window-width))
1807 (url-standalone-mode t))
1809 (w3-region (point-min) (point-max))
1812 (defun article-hide-list-identifiers ()
1813 "Remove list identifies from the Subject header.
1814 The `gnus-list-identifiers' variable specifies what to do."
1818 (let ((inhibit-point-motion-hooks t)
1820 (article-narrow-to-head)
1821 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1822 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1824 (goto-char (point-min))
1825 (when (re-search-forward
1826 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1827 " *\\)\\)+\\(Re: +\\)?\\)")
1829 (let ((s (or (match-string 3) (match-string 5))))
1830 (delete-region (match-beginning 1) (match-end 1))
1832 (goto-char (match-beginning 1))
1835 (defun article-hide-pgp ()
1836 "Remove any PGP headers and signatures in the current article."
1840 (let ((inhibit-point-motion-hooks t)
1841 buffer-read-only beg end)
1843 ;; Hide the "header".
1844 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1845 (push 'pgp gnus-article-wash-types)
1846 (delete-region (match-beginning 0) (match-end 0))
1847 ;; Remove armor headers (rfc2440 6.2)
1848 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1851 ;; Hide the actual signature.
1852 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1853 (setq end (1+ (match-beginning 0)))
1856 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1858 ;; Perhaps we shouldn't hide to the end of the buffer
1859 ;; if there is no end to the signature?
1861 ;; Hide "- " PGP quotation markers.
1863 (narrow-to-region beg end)
1864 (goto-char (point-min))
1865 (while (re-search-forward "^- " nil t)
1867 (match-beginning 0) (match-end 0)))
1869 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1871 (defun article-hide-pem (&optional arg)
1872 "Toggle hiding of any PEM headers and signatures in the current article.
1873 If given a negative prefix, always show; if given a positive prefix,
1875 (interactive (gnus-article-hidden-arg))
1876 (unless (gnus-article-check-hidden-text 'pem arg)
1878 (let (buffer-read-only end)
1879 (goto-char (point-min))
1880 ;; Hide the horrendously ugly "header".
1881 (when (and (search-forward
1882 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1884 (setq end (1+ (match-beginning 0))))
1885 (push 'pem gnus-article-wash-types)
1886 (gnus-article-hide-text-type
1888 (if (search-forward "\n\n" nil t)
1892 ;; Hide the trailer as well
1893 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1895 (gnus-article-hide-text-type
1896 (match-beginning 0) (match-end 0) 'pem)))))))
1898 (defun article-strip-banner ()
1899 "Strip the banner specified by the `banner' group parameter."
1903 (let ((inhibit-point-motion-hooks t)
1904 (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
1905 (gnus-signature-limit nil)
1906 buffer-read-only beg end)
1910 ((eq banner 'signature)
1911 (when (gnus-article-narrow-to-signature)
1914 (delete-region (point) (point-max))))
1916 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1917 (while (re-search-forward banner nil t)
1918 (delete-region (match-beginning 0) (match-end 0)))))
1920 (while (re-search-forward banner nil t)
1921 (delete-region (match-beginning 0) (match-end 0))))))))))
1923 (defun article-babel ()
1924 "Translate article using an online translation service."
1928 (set-buffer gnus-article-buffer)
1929 (when (article-goto-body)
1930 (let* ((buffer-read-only nil)
1933 (orig (buffer-substring start end))
1934 (trans (babel-as-string orig)))
1936 (narrow-to-region start end)
1937 (delete-region start end)
1940 (defun article-hide-signature (&optional arg)
1941 "Hide the signature in the current article.
1942 If given a negative prefix, always show; if given a positive prefix,
1944 (interactive (gnus-article-hidden-arg))
1950 (article-goto-body))
1951 (goto-char (point-min)))
1952 (unless (gnus-article-check-hidden-text 'signature arg)
1953 (let ((buffer-read-only nil)
1955 (while (setq button (text-property-any button (point-max)
1957 'gnus-signature-toggle))
1958 (setq button (text-property-not-all button (point-max)
1960 'gnus-signature-toggle))
1961 (when (and button (not (eobp)))
1962 (gnus-article-hide-text-type
1964 (next-single-property-change (1+ button) 'mime-view-entity
1968 (defun article-strip-headers-in-body ()
1969 "Strip offensive headers from bodies."
1973 (let ((case-fold-search t))
1974 (when (looking-at "x-no-archive:")
1975 (gnus-delete-line)))))
1977 (defun article-strip-leading-blank-lines ()
1978 "Remove all blank lines from the beginning of the article."
1981 (let ((inhibit-point-motion-hooks t)
1983 (when (article-goto-body)
1984 (while (and (not (eobp))
1985 (looking-at "[ \t]*$"))
1986 (gnus-delete-line))))))
1988 (defun article-narrow-to-head ()
1989 "Narrow the buffer to the head of the message.
1990 Point is left at the beginning of the narrowed-to region."
1992 (goto-char (point-min))
1993 (if (search-forward "\n\n" nil 1)
1996 (goto-char (point-min)))
1998 (defun article-goto-body ()
1999 "Place point at the start of the body."
2000 (goto-char (point-min))
2002 ;; This variable is only bound when dealing with separate
2004 (article-goto-body-goes-to-point-min-p
2006 ((search-forward "\n\n" nil t)
2009 (goto-char (point-max))
2012 (defun article-strip-multiple-blank-lines ()
2013 "Replace consecutive blank lines with one empty line."
2016 (let ((inhibit-point-motion-hooks t)
2018 ;; First make all blank lines empty.
2020 (while (re-search-forward "^[ \t]+$" nil t)
2021 (unless (gnus-annotation-in-region-p
2022 (match-beginning 0) (match-end 0))
2023 (replace-match "" nil t)))
2024 ;; Then replace multiple empty lines with a single empty line.
2026 (while (re-search-forward "\n\n\n+" nil t)
2027 (unless (gnus-annotation-in-region-p
2028 (match-beginning 0) (match-end 0))
2029 (replace-match "\n\n" t t))))))
2031 (defun article-strip-leading-space ()
2032 "Remove all white space from the beginning of the lines in the article."
2035 (let ((inhibit-point-motion-hooks t)
2038 (while (re-search-forward "^[ \t]+" nil t)
2039 (replace-match "" t t)))))
2041 (defun article-strip-trailing-space ()
2042 "Remove all white space from the end of the lines in the article."
2045 (let ((inhibit-point-motion-hooks t)
2048 (while (re-search-forward "[ \t]+$" nil t)
2049 (replace-match "" t t)))))
2051 (defun article-strip-blank-lines ()
2052 "Strip leading, trailing and multiple blank lines."
2054 (article-strip-leading-blank-lines)
2055 (article-remove-trailing-blank-lines)
2056 (article-strip-multiple-blank-lines))
2058 (defun article-strip-all-blank-lines ()
2059 "Strip all blank lines."
2062 (let ((inhibit-point-motion-hooks t)
2065 (while (re-search-forward "^[ \t]*\n" nil t)
2066 (replace-match "" t t)))))
2068 (defun gnus-article-narrow-to-signature ()
2069 "Narrow to the signature; return t if a signature is found, else nil."
2070 (let ((inhibit-point-motion-hooks t))
2071 (when (gnus-article-search-signature)
2073 ;; Check whether we have some limits to what we consider
2074 ;; to be a signature.
2075 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2076 (list gnus-signature-limit)))
2078 (while (setq limit (pop limits))
2079 (if (or (and (integerp limit)
2080 (< (- (point-max) (point)) limit))
2082 (< (count-lines (point) (point-max)) limit))
2083 (and (gnus-functionp limit)
2085 (and (stringp limit)
2086 (not (re-search-forward limit nil t))))
2087 () ; This limit did not succeed.
2091 (narrow-to-region (point) (point-max))
2094 (defun gnus-article-search-signature ()
2095 "Search the current buffer for the signature separator.
2096 Put point at the beginning of the signature separator."
2097 (let ((cur (point)))
2098 (goto-char (point-max))
2099 (if (if (stringp gnus-signature-separator)
2100 (re-search-backward gnus-signature-separator nil t)
2101 (let ((seps gnus-signature-separator))
2103 (not (re-search-backward (car seps) nil t)))
2110 (defun gnus-article-hidden-arg ()
2111 "Return the current prefix arg as a number, or 0 if no prefix."
2112 (list (if current-prefix-arg
2113 (prefix-numeric-value current-prefix-arg)
2116 (defun gnus-article-check-hidden-text (type arg)
2117 "Return nil if hiding is necessary.
2118 Arg can be nil or a number. Nil and positive means hide, negative
2119 means show, 0 means toggle."
2122 (let ((hide (gnus-article-hidden-text-p type)))
2128 (gnus-article-show-hidden-text type))
2130 (if (eq hide 'hidden)
2131 (gnus-article-show-hidden-text type)
2134 (defun gnus-article-hidden-text-p (type)
2135 "Say whether the current buffer contains hidden text of type TYPE."
2136 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2138 (not (get-text-property pos 'invisible))
2139 (not (get-text-property pos 'dummy-invisible)))
2141 (text-property-any (1+ pos) (point-max) 'article-type type)))
2146 (defun gnus-article-show-hidden-text (type &optional hide)
2147 "Show all hidden text of type TYPE.
2148 If HIDE, hide the text instead."
2150 (let ((buffer-read-only nil)
2151 (inhibit-point-motion-hooks t)
2154 (while (setq beg (text-property-any end (point-max) 'article-type type))
2157 (text-property-not-all beg (point-max) 'article-type type)
2160 (gnus-article-hide-text beg end gnus-hidden-properties)
2161 (gnus-article-unhide-text beg end))
2165 (defconst article-time-units
2166 `((year . ,(* 365.25 24 60 60))
2167 (week . ,(* 7 24 60 60))
2168 (day . ,(* 24 60 60))
2172 "Mapping from time units to seconds.")
2174 (defun article-date-ut (&optional type highlight header)
2175 "Convert DATE date to universal time in the current article.
2176 If TYPE is `local', convert to local time; if it is `lapsed', output
2177 how much time has lapsed since DATE. For `lapsed', the value of
2178 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2179 should replace the \"Date:\" one, or should be added below it."
2180 (interactive (list 'ut t))
2181 (let* ((header (or header
2182 (and (eq 1 (point-min))
2183 (mail-header-date (save-excursion
2184 (set-buffer gnus-summary-buffer)
2185 gnus-current-headers)))
2186 (message-fetch-field "date")
2188 (date (if (vectorp header) (mail-header-date header)
2190 (inhibit-point-motion-hooks t)
2191 bface eface date-pos)
2192 (when (and date (not (string= date "")))
2195 (article-narrow-to-head)
2196 (when (or (and (eq type 'lapsed)
2197 gnus-article-date-lapsed-new-header
2198 ;; Attempt to get the face of X-Sent first.
2199 (re-search-forward "^X-Sent:[ \t]" nil t))
2200 (re-search-forward "^Date:[ \t]" nil t)
2201 ;; If Date is missing, try again for X-Sent.
2202 (re-search-forward "^X-Sent:[ \t]" nil t))
2203 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2204 date (or (get-text-property (gnus-point-at-bol)
2207 eface (get-text-property (1- (gnus-point-at-eol))
2209 (let ((buffer-read-only nil))
2210 ;; Delete any old X-Sent headers.
2211 (when (setq date-pos
2212 (text-property-any (point-min) (point-max)
2213 'article-date-lapsed t))
2214 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2215 (delete-region (match-beginning 0)
2216 (progn (forward-line 1) (point))))
2217 (goto-char (point-min))
2218 ;; Delete any old Date headers.
2219 (while (re-search-forward "^Date:[ \t]" nil t)
2221 (setq date-pos (match-beginning 0)))
2222 (unless (and (eq type 'lapsed)
2223 gnus-article-date-lapsed-new-header)
2224 (delete-region (match-beginning 0)
2225 (progn (message-next-header) (point)))))
2228 (goto-char date-pos)
2230 ;; Possibly, Date has been deleted.
2232 (when (and (eq type 'lapsed)
2233 gnus-article-date-lapsed-new-header
2234 (looking-at "Date:"))
2236 (goto-char (point-min)))
2237 (insert (article-make-date-line date type))
2238 (when (eq type 'lapsed)
2239 (put-text-property (gnus-point-at-bol) (point)
2240 'article-date-lapsed t))
2244 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2245 (put-text-property (match-beginning 1) (1+ (match-end 1))
2246 'original-date date)
2247 (put-text-property (match-beginning 1) (1+ (match-end 1))
2249 (put-text-property (match-beginning 2) (match-end 2)
2252 (defun article-make-date-line (date type)
2253 "Return a DATE line of TYPE."
2254 (let ((time (condition-case ()
2258 ;; Convert to the local timezone. We have to slap a
2259 ;; `condition-case' round the calls to the timezone
2260 ;; functions since they aren't particularly resistant to
2263 (let ((tz (car (current-time-zone time))))
2264 (format "Date: %s %s%02d%02d" (current-time-string time)
2265 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2266 (/ (% (abs tz) 3600) 60))))
2267 ;; Convert to Universal Time.
2270 (current-time-string
2271 (let* ((e (parse-time-string date))
2272 (tm (apply 'encode-time e))
2274 (ls (- (cadr tm) (car (current-time-zone time)))))
2275 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2276 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2279 ;; Get the original date from the article.
2280 ((eq type 'original)
2281 (concat "Date: " (if (string-match "\n+$" date)
2282 (substring date 0 (match-beginning 0))
2284 ;; Let the user define the format.
2286 (if (gnus-functionp gnus-article-time-format)
2287 (funcall gnus-article-time-format time)
2290 (format-time-string gnus-article-time-format time))))
2293 (let ((tz (car (current-time-zone time))))
2296 (format-time-string "%Y%m%dT%H%M%S" time)
2297 (format "%s%02d%02d"
2298 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2299 (/ (% (abs tz) 3600) 60)))))
2300 ;; Do an X-Sent lapsed format.
2302 ;; If the date is seriously mangled, the timezone functions are
2303 ;; liable to bug out, so we ignore all errors.
2304 (let* ((now (current-time))
2305 (real-time (subtract-time now time))
2306 (real-sec (and real-time
2307 (+ (* (float (car real-time)) 65536)
2309 (sec (and real-time (abs real-sec)))
2319 ;; This is a bit convoluted, but basically we go
2320 ;; through the time units for years, weeks, etc,
2321 ;; and divide things to see whether that results
2322 ;; in positive answers.
2325 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2326 ;; The (remaining) seconds are too few to
2327 ;; be divided into this time unit.
2329 ;; It's big enough, so we output it.
2330 (setq sec (- sec (* num (cdr unit))))
2332 (concat (if prev ", " "") (int-to-string
2334 " " (symbol-name (car unit))
2335 (if (> num 1) "s" ""))
2337 article-time-units "")
2338 ;; If dates are odd, then it might appear like the
2339 ;; article was sent in the future.
2342 " in the future"))))))
2344 (error "Unknown conversion type: %s" type)))))
2346 (defun article-date-local (&optional highlight)
2347 "Convert the current article date to the local timezone."
2348 (interactive (list t))
2349 (article-date-ut 'local highlight))
2351 (defun article-date-original (&optional highlight)
2352 "Convert the current article date to what it was originally.
2353 This is only useful if you have used some other date conversion
2354 function and want to see what the date was before converting."
2355 (interactive (list t))
2356 (article-date-ut 'original highlight))
2358 (defun article-date-lapsed (&optional highlight)
2359 "Convert the current article date to time lapsed since it was sent."
2360 (interactive (list t))
2361 (article-date-ut 'lapsed highlight))
2363 (defun article-update-date-lapsed ()
2364 "Function to be run from a timer to update the lapsed time line."
2365 (let (deactivate-mark)
2370 (set-buffer (window-buffer w))
2371 (when (eq major-mode 'gnus-article-mode)
2372 (goto-char (point-min))
2373 (when (re-search-forward "^X-Sent:" nil t)
2374 (article-date-lapsed t))))
2377 (defun gnus-start-date-timer (&optional n)
2378 "Start a timer to update the X-Sent header in the article buffers.
2379 The numerical prefix says how frequently (in seconds) the function
2384 (gnus-stop-date-timer)
2385 (setq article-lapsed-timer
2386 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2388 (defun gnus-stop-date-timer ()
2389 "Stop the X-Sent timer."
2391 (when article-lapsed-timer
2392 (nnheader-cancel-timer article-lapsed-timer)
2393 (setq article-lapsed-timer nil)))
2395 (defun article-date-user (&optional highlight)
2396 "Convert the current article date to the user-defined format.
2397 This format is defined by the `gnus-article-time-format' variable."
2398 (interactive (list t))
2399 (article-date-ut 'user highlight))
2401 (defun article-date-iso8601 (&optional highlight)
2402 "Convert the current article date to ISO8601."
2403 (interactive (list t))
2404 (article-date-ut 'iso8601 highlight))
2406 (defun article-show-all ()
2407 "Show all hidden text in the article buffer."
2411 (let ((buffer-read-only nil))
2412 (gnus-article-unhide-text (point-min) (point-max))
2413 (gnus-remove-text-with-property 'gnus-prev)
2414 (gnus-remove-text-with-property 'gnus-next))))
2416 (defun article-show-all-headers ()
2417 "Show all hidden headers in the article buffer."
2422 (article-narrow-to-head)
2423 (let ((buffer-read-only nil))
2424 (gnus-article-unhide-text (point-min) (point-max))))))
2426 (defun article-emphasize (&optional arg)
2427 "Emphasize text according to `gnus-emphasis-alist'."
2428 (interactive (gnus-article-hidden-arg))
2429 (unless (gnus-article-check-hidden-text 'emphasis arg)
2433 (with-current-buffer gnus-summary-buffer
2434 gnus-article-emphasis-alist)
2436 gnus-emphasis-alist))
2437 (buffer-read-only nil)
2438 (props (append '(article-type emphasis)
2439 gnus-hidden-properties))
2440 regexp elem beg invisible visible face)
2443 (while (setq elem (pop alist))
2445 (setq regexp (car elem)
2446 invisible (nth 1 elem)
2447 visible (nth 2 elem)
2449 (while (re-search-forward regexp nil t)
2450 (when (and (match-beginning visible) (match-beginning invisible))
2451 (push 'emphasis gnus-article-wash-types)
2452 (gnus-article-hide-text
2453 (match-beginning invisible) (match-end invisible) props)
2454 (gnus-article-unhide-text-type
2455 (match-beginning visible) (match-end visible) 'emphasis)
2456 (gnus-put-text-property-excluding-newlines
2457 (match-beginning visible) (match-end visible) 'face face)
2458 (goto-char (match-end invisible)))))))))
2460 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2461 "Setup newsgroup emphasis alist."
2462 (unless gnus-article-emphasis-alist
2463 (let ((name (and gnus-newsgroup-name
2464 (gnus-group-real-name gnus-newsgroup-name))))
2465 (make-local-variable 'gnus-article-emphasis-alist)
2466 (setq gnus-article-emphasis-alist
2468 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2469 (while (setq elem (pop alist))
2470 (when (and name (string-match (car elem) name))
2472 highlight (copy-sequence (cdr elem)))))
2474 (copy-sequence highlight-words)
2475 (if gnus-newsgroup-name
2476 (copy-sequence (gnus-group-find-parameter
2477 gnus-newsgroup-name 'highlight-words t)))
2478 gnus-emphasis-alist)))))
2480 (defvar gnus-summary-article-menu)
2481 (defvar gnus-summary-post-menu)
2483 ;;; Saving functions.
2485 (defun gnus-article-save (save-buffer file &optional num)
2486 "Save the currently selected article."
2487 (unless gnus-save-all-headers
2488 ;; Remove headers according to `gnus-saved-headers'.
2489 (let ((gnus-visible-headers
2490 (or gnus-saved-headers gnus-visible-headers))
2491 (gnus-article-buffer save-buffer))
2493 (set-buffer save-buffer)
2494 (article-hide-headers 1 t))))
2495 (save-window-excursion
2496 (if (not gnus-default-article-saver)
2497 (error "No default saver is defined")
2498 ;; !!! Magic! The saving functions all save
2499 ;; `gnus-save-article-buffer' (or so they think), but we
2500 ;; bind that variable to our save-buffer.
2501 (set-buffer gnus-article-buffer)
2502 (let* ((gnus-save-article-buffer save-buffer)
2505 ((not gnus-prompt-before-saving) 'default)
2506 ((eq gnus-prompt-before-saving 'always) nil)
2508 (gnus-number-of-articles-to-be-saved
2509 (when (eq gnus-prompt-before-saving t)
2511 (set-buffer gnus-article-current-summary)
2512 (funcall gnus-default-article-saver filename)))))
2514 (defun gnus-read-save-file-name (prompt &optional filename
2515 function group headers variable)
2517 (funcall function group headers (symbol-value variable)))
2522 ((eq filename 'default)
2528 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2531 (if (and gnus-number-of-articles-to-be-saved
2532 (> gnus-number-of-articles-to-be-saved 1))
2533 (format "these %d articles"
2534 gnus-number-of-articles-to-be-saved)
2537 ;; Let the split methods have their say.
2539 ;; No split name was found.
2542 (concat prompt " (default "
2543 (file-name-nondirectory default-name) ") ")
2544 (file-name-directory default-name)
2546 ;; A single group name is returned.
2547 ((stringp split-name)
2549 (funcall function split-name headers
2550 (symbol-value variable)))
2552 (concat prompt " (default "
2553 (file-name-nondirectory default-name) ") ")
2554 (file-name-directory default-name)
2556 ;; A single split name was found
2557 ((= 1 (length split-name))
2558 (let* ((name (expand-file-name
2560 gnus-article-save-directory))
2561 (dir (cond ((file-directory-p name)
2562 (file-name-as-directory name))
2563 ((file-exists-p name) name)
2564 (t gnus-article-save-directory))))
2566 (concat prompt " (default " name ") ")
2568 ;; A list of splits was found.
2570 (setq split-name (nreverse split-name))
2572 (let ((file-name-history
2573 (nconc split-name file-name-history)))
2577 (concat prompt " (`M-p' for defaults) ")
2578 gnus-article-save-directory
2580 gnus-article-save-directory)))
2581 (car (push result file-name-history)))))))
2582 ;; Create the directory.
2583 (gnus-make-directory (file-name-directory file))
2584 ;; If we have read a directory, we append the default file name.
2585 (when (file-directory-p file)
2586 (setq file (expand-file-name (file-name-nondirectory
2588 (file-name-as-directory file))))
2589 ;; Possibly translate some characters.
2590 (nnheader-translate-file-chars file))))))
2591 (gnus-make-directory (file-name-directory result))
2592 (set variable result)))
2594 (defun gnus-article-archive-name (group)
2595 "Return the first instance of an \"Archive-name\" in the current buffer."
2596 (let ((case-fold-search t))
2597 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2598 (nnheader-concat gnus-article-save-directory
2599 (match-string 1)))))
2601 (defun gnus-article-nndoc-name (group)
2602 "If GROUP is an nndoc group, return the name of the parent group."
2603 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2604 (gnus-group-get-parameter group 'save-article-group)))
2606 (defun gnus-summary-save-in-rmail (&optional filename)
2607 "Append this article to Rmail file.
2608 Optional argument FILENAME specifies file name.
2609 Directory to save to is default to `gnus-article-save-directory'."
2610 (setq filename (gnus-read-save-file-name
2611 "Save %s in rmail file:" filename
2612 gnus-rmail-save-name gnus-newsgroup-name
2613 gnus-current-headers 'gnus-newsgroup-last-rmail))
2614 (gnus-eval-in-buffer-window gnus-save-article-buffer
2618 (gnus-output-to-rmail filename))))
2621 (defun gnus-summary-save-in-mail (&optional filename)
2622 "Append this article to Unix mail file.
2623 Optional argument FILENAME specifies file name.
2624 Directory to save to is default to `gnus-article-save-directory'."
2625 (setq filename (gnus-read-save-file-name
2626 "Save %s in Unix mail file:" filename
2627 gnus-mail-save-name gnus-newsgroup-name
2628 gnus-current-headers 'gnus-newsgroup-last-mail))
2629 (gnus-eval-in-buffer-window gnus-save-article-buffer
2633 (if (and (file-readable-p filename)
2634 (mail-file-babyl-p filename))
2635 (rmail-output-to-rmail-file filename t)
2636 (gnus-output-to-mail filename)))))
2639 (defun gnus-summary-save-in-file (&optional filename overwrite)
2640 "Append this article to file.
2641 Optional argument FILENAME specifies file name.
2642 Directory to save to is default to `gnus-article-save-directory'."
2643 (setq filename (gnus-read-save-file-name
2644 "Save %s in file:" filename
2645 gnus-file-save-name gnus-newsgroup-name
2646 gnus-current-headers 'gnus-newsgroup-last-file))
2647 (gnus-eval-in-buffer-window gnus-save-article-buffer
2651 (when (and overwrite
2652 (file-exists-p filename))
2653 (delete-file filename))
2654 (gnus-output-to-file filename))))
2657 (defun gnus-summary-write-to-file (&optional filename)
2658 "Write this article to a file.
2659 Optional argument FILENAME specifies file name.
2660 The directory to save in defaults to `gnus-article-save-directory'."
2661 (gnus-summary-save-in-file nil t))
2663 (defun gnus-summary-save-body-in-file (&optional filename)
2664 "Append this article body to a file.
2665 Optional argument FILENAME specifies file name.
2666 The directory to save in defaults to `gnus-article-save-directory'."
2667 (setq filename (gnus-read-save-file-name
2668 "Save %s body in file:" filename
2669 gnus-file-save-name gnus-newsgroup-name
2670 gnus-current-headers 'gnus-newsgroup-last-file))
2671 (gnus-eval-in-buffer-window gnus-save-article-buffer
2675 (when (article-goto-body)
2676 (narrow-to-region (point) (point-max)))
2677 (gnus-output-to-file filename))))
2680 (defun gnus-summary-save-in-pipe (&optional command)
2681 "Pipe this article to subprocess."
2683 (cond ((and (eq command 'default)
2684 gnus-last-shell-command)
2685 gnus-last-shell-command)
2689 "Shell command on %s: "
2690 (if (and gnus-number-of-articles-to-be-saved
2691 (> gnus-number-of-articles-to-be-saved 1))
2692 (format "these %d articles"
2693 gnus-number-of-articles-to-be-saved)
2695 gnus-last-shell-command))))
2696 (when (string-equal command "")
2697 (setq command gnus-last-shell-command))
2698 (gnus-eval-in-buffer-window gnus-article-buffer
2701 (shell-command-on-region (point-min) (point-max) command nil)))
2702 (setq gnus-last-shell-command command))
2704 ;;; Article file names when saving.
2706 (defun gnus-capitalize-newsgroup (newsgroup)
2707 "Capitalize NEWSGROUP name."
2708 (when (not (zerop (length newsgroup)))
2709 (concat (char-to-string (upcase (aref newsgroup 0)))
2710 (substring newsgroup 1))))
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 ~/News/News.group/num.
2715 Otherwise, it is like ~/News/news/group/num."
2718 (concat (if (gnus-use-long-file-name 'not-save)
2719 (gnus-capitalize-newsgroup newsgroup)
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-numeric-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/num. Otherwise, it is like ~/News/news/group/num."
2736 (concat (if (gnus-use-long-file-name 'not-save)
2738 (gnus-newsgroup-directory-form newsgroup))
2739 "/" (int-to-string (mail-header-number headers)))
2740 gnus-article-save-directory)))
2742 (string-equal (file-name-directory default)
2743 (file-name-directory last-file))
2744 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2746 (or last-file default))))
2748 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2749 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2750 If variable `gnus-use-long-file-name' is non-nil, it is
2751 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2754 (if (gnus-use-long-file-name 'not-save)
2756 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2757 gnus-article-save-directory)))
2759 (defun article-verify-x-pgp-sig ()
2762 (let ((sig (with-current-buffer gnus-original-article-buffer
2763 (gnus-fetch-field "X-PGP-Sig")))
2765 (when (and sig (mm-uu-pgp-signed-test))
2767 (insert-buffer gnus-original-article-buffer)
2768 (setq items (split-string sig))
2769 (message-narrow-to-head)
2770 (let ((inhibit-point-motion-hooks t)
2771 (case-fold-search t))
2772 ;; Don't verify multiple headers.
2773 (setq headers (mapconcat (lambda (header)
2775 (mail-fetch-field header) "\n"))
2776 (split-string (nth 1 items) ",") "")))
2777 (delete-region (point-min) (point-max))
2778 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2779 (insert "X-Signed-Headers: " (nth 1 items) "\n")
2784 (if (looking-at "^-")
2787 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
2788 (insert "Version: " (car items) "\n\n")
2789 (insert (mapconcat 'identity (cddr items) "\n"))
2790 (insert "\n-----END PGP SIGNATURE-----\n")
2791 (let ((mm-security-handle (list (format "multipart/signed"))))
2792 (mml2015-clean-buffer)
2793 (let ((coding-system-for-write (or gnus-newsgroup-charset
2795 (funcall (mml2015-clear-verify-function)))
2797 (or (mm-handle-multipart-ctl-parameter
2798 mm-security-handle 'gnus-details)
2799 (mm-handle-multipart-ctl-parameter
2800 mm-security-handle 'gnus-info)))))
2802 (let (buffer-read-only bface eface)
2804 (message-narrow-to-head)
2805 (goto-char (point-max))
2807 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2808 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2809 (message-remove-header "X-Gnus-PGP-Verify")
2810 (if (re-search-forward "^X-PGP-Sig:" nil t)
2812 (goto-char (point-max)))
2813 (narrow-to-region (point) (point))
2814 (insert "X-Gnus-PGP-Verify: " info "\n")
2815 (goto-char (point-min))
2818 (if (not (looking-at "^[ \t]"))
2822 (goto-char (point-min))
2823 (when (looking-at "\\([^:]+\\): *")
2824 (put-text-property (match-beginning 1) (1+ (match-end 1))
2826 (put-text-property (match-end 0) (point-max)
2834 (setq afunc (car func)
2837 gfunc (intern (format "gnus-%s" func))))
2840 `(lambda (&optional interactive &rest args)
2841 ,(documentation afunc t)
2842 (interactive (list t))
2844 (set-buffer gnus-article-buffer)
2846 (call-interactively ',afunc)
2847 (apply ',afunc args))))))))
2848 '(article-hide-headers
2849 article-verify-x-pgp-sig
2850 article-hide-boring-headers
2851 article-toggle-headers
2852 article-treat-overstrike
2853 article-fill-long-lines
2854 article-capitalize-sentences
2856 article-display-x-face
2857 article-de-quoted-unreadable
2858 article-de-base64-unreadable
2861 article-hide-list-identifiers
2863 article-strip-banner
2866 article-hide-signature
2867 article-strip-headers-in-body
2868 article-remove-trailing-blank-lines
2869 article-strip-leading-blank-lines
2870 article-strip-multiple-blank-lines
2871 article-strip-leading-space
2872 article-strip-trailing-space
2873 article-strip-blank-lines
2874 article-strip-all-blank-lines
2876 article-date-iso8601
2877 article-date-original
2879 article-decode-mime-words
2880 article-decode-charset
2881 article-decode-encoded-words
2885 article-treat-dumbquotes
2886 article-normalize-headers
2887 (article-show-all-headers . gnus-article-show-all-headers)
2888 (article-show-all . gnus-article-show-all))))
2891 ;;; Gnus article mode
2894 (put 'gnus-article-mode 'mode-class 'special)
2896 (gnus-define-keys gnus-article-mode-map
2897 " " gnus-article-goto-next-page
2898 "\177" gnus-article-goto-prev-page
2899 [delete] gnus-article-goto-prev-page
2900 [backspace] gnus-article-goto-prev-page
2901 "\C-c^" gnus-article-refer-article
2902 "h" gnus-article-show-summary
2903 "s" gnus-article-show-summary
2904 "\C-c\C-m" gnus-article-mail
2905 "?" gnus-article-describe-briefly
2906 "e" gnus-summary-edit-article
2907 "<" beginning-of-buffer
2909 "\C-c\C-i" gnus-info-find-node
2912 "\C-d" gnus-article-read-summary-keys
2913 "\M-*" gnus-article-read-summary-keys
2914 "\M-#" gnus-article-read-summary-keys
2915 "\M-^" gnus-article-read-summary-keys
2916 "\M-g" gnus-article-read-summary-keys)
2918 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
2921 (unless (lookup-key gnus-article-mode-map key)
2922 (define-key gnus-article-mode-map key
2923 'gnus-article-read-summary-keys)))
2928 (let ((key (car elt)))
2929 (and (> (length key) 0)
2930 (not (eq 'menu-bar (aref key 0)))
2931 (symbolp (lookup-key gnus-summary-mode-map key))
2933 (accessible-keymaps gnus-summary-mode-map))
2937 (push (char-to-string c) keys)
2941 (defun gnus-article-make-menu-bar ()
2942 (gnus-turn-off-edit-menu 'article)
2943 (unless (boundp 'gnus-article-article-menu)
2945 gnus-article-article-menu gnus-article-mode-map ""
2947 ["Scroll forwards" gnus-article-goto-next-page t]
2948 ["Scroll backwards" gnus-article-goto-prev-page t]
2949 ["Show summary" gnus-article-show-summary t]
2950 ["Fetch Message-ID at point" gnus-article-refer-article t]
2951 ["Mail to address at point" gnus-article-mail t]
2952 ["Send a bug report" gnus-bug t]))
2955 gnus-article-treatment-menu gnus-article-mode-map ""
2957 ["Hide headers" gnus-article-toggle-headers t]
2958 ["Hide signature" gnus-article-hide-signature t]
2959 ["Hide citation" gnus-article-hide-citation t]
2960 ["Treat overstrike" gnus-article-treat-overstrike t]
2961 ["Remove carriage return" gnus-article-remove-cr t]
2962 ["Decode HZ" gnus-article-decode-HZ t]))
2964 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2966 (when (boundp 'gnus-summary-post-menu)
2967 (define-key gnus-article-mode-map [menu-bar post]
2968 (cons "Post" gnus-summary-post-menu)))
2970 (gnus-run-hooks 'gnus-article-menu-hook)))
2972 (defun gnus-article-mode ()
2973 "Major mode for displaying an article.
2975 All normal editing commands are switched off.
2977 The following commands are available in addition to all summary mode
2979 \\<gnus-article-mode-map>
2980 \\[gnus-article-next-page]\t Scroll the article one page forwards
2981 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2982 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2983 \\[gnus-article-show-summary]\t Display the summary buffer
2984 \\[gnus-article-mail]\t Send a reply to the address near point
2985 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2986 \\[gnus-info-find-node]\t Go to the Gnus info node"
2988 (when (gnus-visual-p 'article-menu 'menu)
2989 (gnus-article-make-menu-bar))
2990 (gnus-simplify-mode-line)
2991 (setq mode-name "Article")
2992 (setq major-mode 'gnus-article-mode)
2993 (make-local-variable 'minor-mode-alist)
2994 (unless (assq 'gnus-show-mime minor-mode-alist)
2995 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2996 (use-local-map gnus-article-mode-map)
2997 (gnus-update-format-specifications nil 'article-mode)
2998 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2999 (make-local-variable 'gnus-page-broken)
3000 (make-local-variable 'gnus-button-marker-list)
3001 (make-local-variable 'gnus-article-current-summary)
3002 (make-local-variable 'gnus-article-mime-handles)
3003 (make-local-variable 'gnus-article-decoded-p)
3004 (make-local-variable 'gnus-article-mime-handle-alist)
3005 (make-local-variable 'gnus-article-wash-types)
3006 (make-local-variable 'gnus-article-charset)
3007 (make-local-variable 'gnus-article-ignored-charsets)
3008 (gnus-set-default-directory)
3009 (buffer-disable-undo)
3010 (setq buffer-read-only t)
3011 (set-syntax-table gnus-article-mode-syntax-table)
3012 (gnus-run-hooks 'gnus-article-mode-hook))
3014 (defun gnus-article-setup-buffer ()
3015 "Initialize the article buffer."
3016 (let* ((name (if gnus-single-article-buffer "*Article*"
3017 (concat "*Article " gnus-newsgroup-name "*")))
3019 (progn (string-match "\\*Article" name)
3020 (concat " *Original Article"
3021 (substring name (match-end 0))))))
3022 (setq gnus-article-buffer name)
3023 (setq gnus-original-article-buffer original)
3024 (setq gnus-article-mime-handle-alist nil)
3025 ;; This might be a variable local to the summary buffer.
3026 (unless gnus-single-article-buffer
3028 (set-buffer gnus-summary-buffer)
3029 (setq gnus-article-buffer name)
3030 (setq gnus-original-article-buffer original)
3031 (gnus-set-global-variables)))
3032 (gnus-article-setup-highlight-words)
3033 ;; Init original article buffer.
3035 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3036 (set-buffer-multibyte nil)
3037 (setq major-mode 'gnus-original-article-mode)
3038 (make-local-variable 'gnus-original-article))
3039 (if (get-buffer name)
3042 (buffer-disable-undo)
3043 (setq buffer-read-only t)
3044 (unless (eq major-mode 'gnus-article-mode)
3045 (gnus-article-mode))
3048 (set-buffer (gnus-get-buffer-create name))
3050 (make-local-variable 'gnus-summary-buffer)
3051 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3052 (current-buffer)))))
3054 ;; Set article window start at LINE, where LINE is the number of lines
3055 ;; from the head of the article.
3056 (defun gnus-article-set-window-start (&optional line)
3058 (get-buffer-window gnus-article-buffer t)
3060 (set-buffer gnus-article-buffer)
3061 (goto-char (point-min))
3064 (gnus-message 6 "Moved to bookmark")
3065 (search-forward "\n\n" nil t)
3069 ;;; @@ article filters
3072 (defun gnus-article-display-mime-message ()
3073 "Article display method for MIME message."
3074 ;; called from `gnus-original-article-buffer'.
3075 (let (charset all-headers)
3076 (with-current-buffer gnus-summary-buffer
3077 (setq charset default-mime-charset
3078 all-headers gnus-have-all-headers))
3079 (make-local-variable 'default-mime-charset)
3080 (setq default-mime-charset charset)
3081 (with-current-buffer (get-buffer-create gnus-article-buffer)
3082 (make-local-variable 'default-mime-charset)
3083 (setq default-mime-charset charset))
3084 (mime-display-message mime-message-structure
3085 gnus-article-buffer nil gnus-article-mode-map)
3087 (gnus-article-hide-headers nil -1)))
3088 (run-hooks 'gnus-mime-article-prepare-hook))
3090 (defun gnus-article-display-traditional-message ()
3091 "Article display method for traditional message."
3092 (set-buffer gnus-article-buffer)
3093 (let (buffer-read-only)
3095 (insert-buffer-substring gnus-original-article-buffer)))
3097 (defun gnus-article-make-full-mail-header (&optional number charset)
3098 "Create a new mail header structure in a raw article buffer."
3099 (unless (and number charset)
3100 (save-current-buffer
3101 (set-buffer gnus-summary-buffer)
3103 (setq number (or (cdr gnus-article-current) 0)))
3105 (setq charset (or default-mime-charset 'x-ctext)))))
3106 (goto-char (point-min))
3107 (let ((header-end (if (search-forward "\n\n" nil t)
3109 (goto-char (point-max))))
3110 (chars (- (point-max) (point)))
3111 (lines (count-lines (point) (point-max)))
3112 (default-mime-charset charset)
3114 (narrow-to-region (point-min) header-end)
3115 (setq xref (std11-fetch-field "xref"))
3117 (make-full-mail-header
3119 (std11-fetch-field "subject")
3120 (std11-fetch-field "from")
3121 (std11-fetch-field "date")
3122 (std11-fetch-field "message-id")
3123 (std11-fetch-field "references")
3126 (when xref (concat "Xref: " xref)))
3129 (defun gnus-article-prepare (article &optional all-headers header)
3130 "Prepare ARTICLE in article mode buffer.
3131 ARTICLE should either be an article number or a Message-ID.
3132 If ARTICLE is an id, HEADER should be the article headers.
3133 If ALL-HEADERS is non-nil, no headers are hidden."
3135 ;; Make sure we start in a summary buffer.
3136 (unless (eq major-mode 'gnus-summary-mode)
3137 (set-buffer gnus-summary-buffer))
3138 (setq gnus-summary-buffer (current-buffer))
3139 (let* ((gnus-article (if header (mail-header-number header) article))
3140 (summary-buffer (current-buffer))
3141 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3142 (group gnus-newsgroup-name)
3145 (gnus-article-setup-buffer)
3146 (set-buffer gnus-original-article-buffer)
3147 ;; Deactivate active regions.
3148 (when (and (boundp 'transient-mark-mode)
3149 transient-mark-mode)
3150 (setq mark-active nil))
3151 (if (not (setq result (let ((buffer-read-only nil))
3152 (gnus-request-article-this-buffer
3154 ;; There is no such article.
3156 (when (and (numberp article)
3157 (not (memq article gnus-newsgroup-sparse)))
3158 (setq gnus-article-current
3159 (cons gnus-newsgroup-name article))
3160 (set-buffer gnus-summary-buffer)
3161 (setq gnus-current-article article)
3162 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3164 (gnus-summary-set-agent-mark article)
3165 (message "Message marked for downloading"))
3166 (gnus-summary-mark-article article gnus-canceled-mark)
3167 (unless (memq article gnus-newsgroup-sparse)
3168 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3169 (if (or (eq result 'pseudo)
3170 (eq result 'nneething))
3173 (set-buffer summary-buffer)
3174 (push article gnus-newsgroup-history)
3175 (setq gnus-last-article gnus-current-article
3176 gnus-current-article 0
3177 gnus-current-headers nil
3178 gnus-article-current nil)
3179 (if (eq result 'nneething)
3180 (gnus-configure-windows 'summary)
3181 (gnus-configure-windows 'article))
3182 (gnus-set-global-variables))
3183 (let ((gnus-article-mime-handle-alist-1
3184 gnus-article-mime-handle-alist))
3185 (gnus-set-mode-line 'article)))
3186 ;; The result from the `request' was an actual article -
3187 ;; or at least some text that is now displayed in the
3189 (when (and (numberp article)
3190 (not (eq article gnus-current-article)))
3191 ;; Seems like a new article has been selected.
3192 ;; `gnus-current-article' must be an article number.
3194 (set-buffer summary-buffer)
3195 (push article gnus-newsgroup-history)
3196 (setq gnus-last-article gnus-current-article
3197 gnus-current-article article
3198 gnus-current-headers
3199 (gnus-summary-article-header gnus-current-article)
3200 gnus-article-current
3201 (cons gnus-newsgroup-name gnus-current-article))
3202 (unless (vectorp gnus-current-headers)
3203 (setq gnus-current-headers nil))
3204 (gnus-summary-goto-subject gnus-current-article)
3205 (when (gnus-summary-show-thread)
3206 ;; If the summary buffer really was folded, the
3207 ;; previous goto may not actually have gone to
3208 ;; the right article, but the thread root instead.
3210 (gnus-summary-goto-subject gnus-current-article))
3211 (gnus-run-hooks 'gnus-mark-article-hook)
3212 (gnus-set-mode-line 'summary)
3213 (when (gnus-visual-p 'article-highlight 'highlight)
3214 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3215 ;; Set the global newsgroup variables here.
3216 (gnus-set-global-variables)
3217 (setq gnus-have-all-headers
3218 (or all-headers gnus-show-all-headers))))
3220 (gnus-configure-windows 'article))
3221 (when (or (numberp article)
3223 (gnus-article-prepare-display)
3225 (goto-char (point-min))
3226 (setq gnus-page-broken
3227 (when gnus-break-pages
3228 (gnus-narrow-to-page)
3230 (let ((gnus-article-mime-handle-alist-1
3231 gnus-article-mime-handle-alist))
3232 (gnus-set-mode-line 'article))
3234 (set-window-point (get-buffer-window (current-buffer)) (point))
3235 (gnus-configure-windows 'article)
3238 (defun gnus-article-prepare-mime-display (&optional number)
3239 (goto-char (point-min))
3240 (when (re-search-forward "^[^\t ]+:" nil t)
3241 (goto-char (match-beginning 0)))
3242 (let ((entity (if (eq 1 (point-min))
3243 (get-text-property 1 'mime-view-entity)
3244 (get-text-property (point) 'mime-view-entity)))
3245 last-entity child-entity next type)
3246 (setq child-entity (mime-entity-children entity))
3248 (setq last-entity (nth (1- (length child-entity))
3250 (setq last-entity entity))
3252 (narrow-to-region (point)
3253 (if (search-forward "\n\n" nil t)
3256 (gnus-treat-article 'head)
3257 (put-text-property (point-min) (point-max) 'article-treated-header t)
3258 (goto-char (point-max)))
3259 (while (and (not (eobp)) entity)
3260 (setq next (set-marker
3262 (next-single-property-change (point) 'mime-view-entity
3264 (let ((types (mime-entity-content-type entity)))
3265 (while (eq 'multipart (mime-content-type-primary-type types))
3266 (setq entity (car (mime-entity-children entity))
3267 types (mime-entity-content-type entity)))
3269 (setq type (format "%s/%s"
3270 (mime-content-type-primary-type types)
3271 (mime-content-type-subtype types)))))
3272 (if (string-equal type "message/rfc822")
3275 (let ((children (mime-entity-children entity))
3278 (setq last-children (nth (1- (length children)) children))
3281 (not (eq last-children
3282 (get-text-property next 'mime-view-entity)))
3284 (next-single-property-change next
3286 nil (point-max)))))))
3287 (setq next (next-single-property-change next 'mime-view-entity
3290 (narrow-to-region (point) next)
3291 (gnus-article-prepare-mime-display)
3292 (goto-char (point-max)))
3293 (setq entity (get-text-property (point) 'mime-view-entity)))
3295 (narrow-to-region (point) next)
3296 ;; Kludge. We have to count true number, but for now,
3297 ;; part number is here only to achieve `last'.
3298 (gnus-treat-article nil 1
3299 (if (eq entity last-entity)
3302 (goto-char (point-max)))
3303 (setq entity (get-text-property next 'mime-view-entity))))))
3306 (defun gnus-article-prepare-display ()
3307 "Make the current buffer look like a nice article."
3308 (setq gnus-article-wash-types nil)
3309 (gnus-run-hooks 'gnus-tmp-internal-hook)
3310 (gnus-run-hooks 'gnus-article-prepare-hook)
3312 (let (mime-display-header-hook mime-display-text/plain-hook)
3313 (funcall (if gnus-show-mime
3315 (setq mime-message-structure gnus-current-headers)
3316 (mime-buffer-entity-set-buffer-internal
3317 mime-message-structure
3318 gnus-original-article-buffer)
3319 (mime-entity-set-representation-type-internal
3320 mime-message-structure 'mime-buffer-entity)
3321 (luna-send mime-message-structure
3322 'initialize-instance
3323 mime-message-structure)
3324 gnus-article-display-method-for-mime)
3325 gnus-article-display-method-for-traditional)))
3326 ;; Associate this article with the current summary buffer.
3327 (setq gnus-article-current-summary gnus-summary-buffer)
3328 ;; Call the treatment functions.
3329 (let ((inhibit-read-only t)
3334 (gnus-article-prepare-mime-display)
3335 (narrow-to-region (goto-char (point-min))
3336 (if (search-forward "\n\n" nil t)
3339 (gnus-treat-article 'head)
3340 (put-text-property (point-min) (point-max) 'article-treated-header t)
3341 (goto-char (point-max))
3343 (narrow-to-region (point) (point-max))
3344 (gnus-treat-article nil))
3345 (put-text-property (point-min) (point-max) 'read-only nil)))
3346 ;; Perform the article display hooks. Incidentally, this hook is
3347 ;; an obsolete variable by now.
3348 (gnus-run-hooks 'gnus-article-display-hook))
3350 (defun gnus-article-decode-article-as-default-mime-charset ()
3351 "Decode an article as `default-mime-charset'. It won't work if the
3352 value of the variable `gnus-show-mime' is non-nil."
3353 (unless gnus-show-mime
3354 (decode-mime-charset-region (point-min) (point-max)
3355 (with-current-buffer gnus-summary-buffer
3356 default-mime-charset))))
3359 ;;; Gnus MIME viewing functions
3362 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3363 "The following specs can be used:
3365 %T MIME type, along with additional info
3366 %n The `name' parameter
3367 %d The description, if any
3368 %l The length of the encoded part
3369 %p The part identifier number
3370 %e Dots if the part isn't displayed")
3372 (defvar gnus-mime-button-line-format-alist
3373 '((?t gnus-tmp-type ?s)
3374 (?T gnus-tmp-type-long ?s)
3375 (?n gnus-tmp-name ?s)
3376 (?d gnus-tmp-description ?s)
3378 (?l gnus-tmp-length ?d)
3379 (?e gnus-tmp-dots ?s)))
3381 (defvar gnus-mime-button-commands
3382 '((gnus-article-press-button "\r" "Toggle Display")
3383 (gnus-mime-view-part "v" "View Interactively...")
3384 (gnus-mime-view-part-as-type "t" "View As Type...")
3385 (gnus-mime-view-part-as-charset "C" "View As charset...")
3386 (gnus-mime-save-part "o" "Save...")
3387 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3388 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3389 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3390 (gnus-mime-internalize-part "E" "View Internally")
3391 (gnus-mime-externalize-part "e" "View Externally")
3392 (gnus-mime-pipe-part "|" "Pipe To Command...")
3393 (gnus-mime-action-on-part "." "Take action on the part")))
3395 (defun gnus-article-mime-part-status ()
3396 (with-current-buffer gnus-article-buffer
3397 (let ((entity (get-text-property (point-min) 'mime-view-entity)))
3398 (if (and entity (mime-entity-children entity))
3399 (format " (%d parts)" (length (mime-entity-children entity)))
3402 (defvar gnus-mime-button-map
3403 (let ((map (make-sparse-keymap)))
3404 (set-keymap-parent map gnus-article-mode-map)
3405 (define-key map gnus-mouse-2 'gnus-article-push-button)
3406 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3407 (dolist (c gnus-mime-button-commands)
3408 (define-key map (cadr c) (car c)))
3411 (defun gnus-mime-button-menu (event)
3412 "Construct a context-sensitive menu of MIME commands."
3414 (save-window-excursion
3415 (let ((pos (event-start event)))
3416 (select-window (posn-window pos))
3417 (goto-char (posn-point pos))
3418 (gnus-article-check-buffer)
3419 (let ((response (x-popup-menu
3421 ("" ,@(mapcar (lambda (c)
3422 (cons (caddr c) (car c)))
3423 gnus-mime-button-commands))))))
3425 (call-interactively response))))))
3427 (defun gnus-mime-view-all-parts (&optional handles)
3428 "View all the MIME parts."
3430 (save-current-buffer
3431 (set-buffer gnus-article-buffer)
3432 (let ((handles (or handles gnus-article-mime-handles))
3433 (mail-parse-charset gnus-newsgroup-charset)
3434 (mail-parse-ignored-charsets
3435 (with-current-buffer gnus-summary-buffer
3436 gnus-newsgroup-ignored-charsets)))
3437 (mm-remove-parts handles)
3438 (goto-char (point-min))
3439 (or (search-forward "\n\n") (goto-char (point-max)))
3440 (let (buffer-read-only)
3441 (delete-region (point) (point-max)))
3442 (mm-display-parts handles))))
3444 (defun gnus-mime-save-part-and-strip ()
3445 "Save the MIME part under point then replace it with an external body."
3447 (gnus-article-check-buffer)
3448 (let* ((data (get-text-property (point) 'gnus-data))
3449 (file (mm-save-part data))
3452 (with-current-buffer (mm-handle-buffer data)
3454 (insert "Content-Type: " (mm-handle-media-type data))
3455 (mml-insert-parameter-string (cdr (mm-handle-type data))
3458 (insert "Content-ID: " (message-make-message-id) "\n")
3459 (insert "Content-Transfer-Encoding: binary\n")
3462 (cdr (mm-make-handle nil
3463 `("message/external-body"
3464 (access-type . "LOCAL-FILE")
3466 (set-buffer gnus-summary-buffer)
3467 (gnus-article-edit-article
3470 (let ((mail-parse-charset (or gnus-article-charset
3471 ',gnus-newsgroup-charset))
3472 (mail-parse-ignored-charsets
3473 (or gnus-article-ignored-charsets
3474 ',gnus-newsgroup-ignored-charsets))
3475 (mbl mml-buffer-list))
3476 (setq mml-buffer-list nil)
3477 (insert-buffer gnus-original-article-buffer)
3478 (mime-to-mml gnus-article-mime-handles)
3479 (setq gnus-article-mime-handles nil)
3480 (make-local-hook 'kill-buffer-hook)
3481 (let ((mbl1 mml-buffer-list))
3482 (setq mml-buffer-list mbl)
3483 (set (make-local-variable 'mml-buffer-list) mbl1))
3484 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3485 `(lambda (no-highlight)
3486 (let ((mail-parse-charset (or gnus-article-charset
3487 ',gnus-newsgroup-charset))
3488 (message-options message-options)
3489 (message-options-set-recipient)
3490 (mail-parse-ignored-charsets
3491 (or gnus-article-ignored-charsets
3492 ',gnus-newsgroup-ignored-charsets)))
3494 (mml-destroy-buffers)
3495 (remove-hook 'kill-buffer-hook
3496 'mml-destroy-buffers t)
3497 (kill-local-variable 'mml-buffer-list))
3498 (gnus-summary-edit-article-done
3499 ,(or (mail-header-references gnus-current-headers) "")
3500 ,(gnus-group-read-only-p)
3501 ,gnus-summary-buffer no-highlight))))))
3503 (defun gnus-mime-save-part ()
3504 "Save the MIME part under point."
3506 (gnus-article-check-buffer)
3507 (let ((data (get-text-property (point) 'gnus-data)))
3508 (mm-save-part data)))
3510 (defun gnus-mime-pipe-part ()
3511 "Pipe the MIME part under point to a process."
3513 (gnus-article-check-buffer)
3514 (let ((data (get-text-property (point) 'gnus-data)))
3515 (mm-pipe-part data)))
3517 (defun gnus-mime-view-part ()
3518 "Interactively choose a viewing method for the MIME part under point."
3520 (gnus-article-check-buffer)
3521 (let ((data (get-text-property (point) 'gnus-data)))
3522 (mm-interactively-view-part data)))
3524 (defun gnus-mime-view-part-as-type-internal ()
3525 (gnus-article-check-buffer)
3526 (let* ((name (mail-content-type-get
3527 (mm-handle-type (get-text-property (point) 'gnus-data))
3529 (def-type (and name (mm-default-file-encoding name))))
3530 (and def-type (cons def-type 0))))
3532 (defun gnus-mime-view-part-as-type (mime-type)
3533 "Choose a MIME media type, and view the part as such."
3535 (list (completing-read
3536 "View as MIME type: "
3537 (mapcar #'list (mailcap-mime-types))
3539 (gnus-mime-view-part-as-type-internal))))
3540 (gnus-article-check-buffer)
3541 (let ((handle (get-text-property (point) 'gnus-data)))
3542 (gnus-mm-display-part
3543 (mm-make-handle (mm-handle-buffer handle)
3544 (cons mime-type (cdr (mm-handle-type handle)))
3545 (mm-handle-encoding handle)
3546 (mm-handle-undisplayer handle)
3547 (mm-handle-disposition handle)
3548 (mm-handle-description handle)
3549 (mm-handle-cache handle)
3550 (mm-handle-id handle)))))
3552 (defun gnus-mime-copy-part (&optional handle)
3553 "Put the the MIME part under point into a new buffer."
3555 (gnus-article-check-buffer)
3556 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3557 (contents (mm-get-part handle))|
3558 (base (file-name-nondirectory
3560 (mail-content-type-get (mm-handle-type handle) 'name)
3561 (mail-content-type-get (mm-handle-type handle)
3564 (buffer (generate-new-buffer base)))
3565 (switch-to-buffer buffer)
3567 ;; We do it this way to make `normal-mode' set the appropriate mode.
3570 (setq buffer-file-name (expand-file-name base))
3572 (setq buffer-file-name nil))
3573 (goto-char (point-min))))
3575 (defun gnus-mime-inline-part (&optional handle arg)
3576 "Insert the MIME part under point into the current buffer."
3577 (interactive (list nil current-prefix-arg))
3578 (gnus-article-check-buffer)
3579 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3583 (if (and (not arg) (mm-handle-undisplayer handle))
3584 (mm-remove-part handle)
3585 (setq contents (mm-get-part handle))
3588 (setq charset (or (mail-content-type-get
3589 (mm-handle-type handle) 'charset)
3590 gnus-newsgroup-charset)))
3592 (if (mm-handle-undisplayer handle)
3593 (mm-remove-part handle))
3596 gnus-summary-show-article-charset-alist))
3597 (read-coding-system "Charset: ")))))
3599 (mm-insert-inline handle
3601 (setq charset (mm-charset-to-coding-system
3603 (not (eq charset 'ascii)))
3604 (mm-decode-coding-string contents charset)
3608 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3609 "Insert the MIME part under point into the current buffer."
3610 (interactive (list nil current-prefix-arg))
3611 (gnus-article-check-buffer)
3612 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3616 (if (mm-handle-undisplayer handle)
3617 (mm-remove-part handle))
3618 (let ((gnus-newsgroup-charset
3620 gnus-summary-show-article-charset-alist))
3621 (read-coding-system "Charset: ")))
3622 (gnus-newsgroup-ignored-charsets 'gnus-all))
3623 (gnus-article-press-button))))
3625 (defun gnus-mime-externalize-part (&optional handle)
3626 "View the MIME part under point with an external viewer."
3628 (gnus-article-check-buffer)
3629 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3630 (mm-user-display-methods nil)
3631 (mm-inlined-types nil)
3632 (mail-parse-charset gnus-newsgroup-charset)
3633 (mail-parse-ignored-charsets
3634 (save-excursion (set-buffer gnus-summary-buffer)
3635 gnus-newsgroup-ignored-charsets)))
3636 (if (mm-handle-undisplayer handle)
3637 (mm-remove-part handle)
3638 (mm-display-part handle))))
3640 (defun gnus-mime-internalize-part (&optional handle)
3641 "View the MIME part under point with an internal viewer.
3642 In no internal viewer is available, use an external viewer."
3644 (gnus-article-check-buffer)
3645 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3646 (mm-inlined-types '(".*"))
3647 (mm-inline-large-images t)
3648 (mail-parse-charset gnus-newsgroup-charset)
3649 (mail-parse-ignored-charsets
3650 (save-excursion (set-buffer gnus-summary-buffer)
3651 gnus-newsgroup-ignored-charsets)))
3652 (if (mm-handle-undisplayer handle)
3653 (mm-remove-part handle)
3654 (mm-display-part handle))))
3656 (defun gnus-mime-action-on-part (&optional action)
3657 "Do something with the MIME attachment at \(point\)."
3659 (list (completing-read "Action: " gnus-mime-action-alist)))
3660 (gnus-article-check-buffer)
3661 (let ((action-pair (assoc action gnus-mime-action-alist)))
3663 (funcall (cdr action-pair)))))
3666 (defun gnus-article-part-wrapper (n function)
3667 (save-current-buffer
3668 (set-buffer gnus-article-buffer)
3669 (when (> n (length gnus-article-mime-handle-alist))
3670 (error "No such part"))
3671 (gnus-article-goto-part n)
3672 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3673 (funcall function handle))))
3675 (defun gnus-article-pipe-part (n)
3676 "Pipe MIME part N, which is the numerical prefix."
3678 (gnus-article-part-wrapper n 'mm-pipe-part))
3680 (defun gnus-article-save-part (n)
3681 "Save MIME part N, which is the numerical prefix."
3683 (gnus-article-part-wrapper n 'mm-save-part))
3685 (defun gnus-article-interactively-view-part (n)
3686 "View MIME part N interactively, which is the numerical prefix."
3688 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3690 (defun gnus-article-copy-part (n)
3691 "Copy MIME part N, which is the numerical prefix."
3693 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3695 (defun gnus-article-view-part-as-charset (n)
3696 "Copy MIME part N, which is the numerical prefix."
3698 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3700 (defun gnus-article-externalize-part (n)
3701 "View MIME part N externally, which is the numerical prefix."
3703 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3705 (defun gnus-article-inline-part (n)
3706 "Inline MIME part N, which is the numerical prefix."
3708 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3710 (defun gnus-article-mime-match-handle-first (condition)
3712 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3713 (while (setq ihandle (pop alist))
3715 ((functionp condition)
3716 (funcall condition (cdr ihandle)))
3717 ((eq condition 'undisplayed)
3718 (not (or (mm-handle-undisplayer (cdr ihandle))
3719 (equal (mm-handle-media-type (cdr ihandle))
3720 "multipart/alternative"))))
3721 ((eq condition 'undisplayed-alternative)
3722 (not (mm-handle-undisplayer (cdr ihandle))))
3724 (gnus-article-goto-part (car ihandle))
3725 (or (not n) (< (car ihandle) n)))
3726 (setq n (car ihandle))))
3730 (defun gnus-article-view-part (&optional n)
3731 "View MIME part N, which is the numerical prefix."
3733 (save-current-buffer
3734 (set-buffer gnus-article-buffer)
3735 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3736 gnus-article-mime-match-handle-function)))
3737 (when (> n (length gnus-article-mime-handle-alist))
3738 (error "No such part"))
3739 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3740 (when (gnus-article-goto-part n)
3741 (if (equal (car handle) "multipart/alternative")
3742 (gnus-article-press-button)
3743 (when (eq (gnus-mm-display-part handle) 'internal)
3744 (gnus-set-window-start)))))))
3746 (defsubst gnus-article-mime-total-parts ()
3747 (if (bufferp (car gnus-article-mime-handles))
3749 (1- (length gnus-article-mime-handles))))
3751 (defun gnus-mm-display-part (handle)
3752 "Display HANDLE and fix MIME button."
3753 (let ((id (get-text-property (point) 'gnus-part))
3758 (let ((window (selected-window))
3759 (mail-parse-charset gnus-newsgroup-charset)
3760 (mail-parse-ignored-charsets
3761 (save-excursion (set-buffer gnus-summary-buffer)
3762 gnus-newsgroup-ignored-charsets)))
3765 (let ((win (get-buffer-window (current-buffer) t))
3768 (select-window win))
3771 (if (mm-handle-displayed-p handle)
3772 ;; This will remove the part.
3773 (mm-display-part handle)
3775 (narrow-to-region (point) (1+ (point)))
3776 (mm-display-part handle)
3777 ;; We narrow to the part itself and
3778 ;; then call the treatment functions.
3779 (goto-char (point-min))
3781 (narrow-to-region (point) (point-max))
3784 (gnus-article-mime-total-parts)
3785 (mm-handle-media-type handle)))))
3786 (select-window window))))
3788 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3789 (gnus-insert-mime-button
3790 handle id (list (mm-handle-displayed-p handle)))
3791 (goto-char point))))
3793 (defun gnus-article-goto-part (n)
3794 "Go to MIME part N."
3795 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3797 (goto-char point))))
3799 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3800 (let ((gnus-tmp-name
3801 (or (mail-content-type-get (mm-handle-type handle)
3803 (mail-content-type-get (mm-handle-disposition handle)
3805 (mail-content-type-get (mm-handle-type handle)
3808 (gnus-tmp-type (mm-handle-media-type handle))
3809 (gnus-tmp-description
3810 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3813 (if (if displayed (car displayed)
3814 (mm-handle-displayed-p handle))
3816 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3818 gnus-tmp-type-long b e)
3819 (when (string-match ".*/" gnus-tmp-name)
3820 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3821 (setq gnus-tmp-type-long (concat gnus-tmp-type
3822 (and (not (equal gnus-tmp-name ""))
3823 (concat "; " gnus-tmp-name))))
3824 (or (equal gnus-tmp-description "")
3825 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3830 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3831 `(local-map ,gnus-mime-button-map
3832 keymap ,gnus-mime-button-map
3833 gnus-callback gnus-mm-display-part
3834 gnus-part ,gnus-tmp-id
3835 article-type annotation
3838 (widget-convert-button
3841 :action 'gnus-widget-press-button
3842 :button-keymap gnus-mime-button-map
3844 (lambda (widget/window &optional overlay pos)
3845 ;; Needed to properly clear the message due to a bug in
3846 ;; wid-edit (XEmacs only).
3847 (if (boundp 'help-echo-owns-message)
3848 (setq help-echo-owns-message t))
3850 "%S: %s the MIME part; %S: more options"
3851 (aref gnus-mouse-2 0)
3852 ;; XEmacs will get a single widget arg; Emacs 21 will get
3853 ;; window, overlay, position.
3854 (if (mm-handle-displayed-p
3856 (with-current-buffer (gnus-overlay-buffer overlay)
3857 (widget-get (widget-at (gnus-overlay-start overlay))
3859 (widget-get widget/window :mime-handle)))
3861 (aref gnus-down-mouse-3 0))))))
3863 (defun gnus-widget-press-button (elems el)
3864 (goto-char (widget-get elems :from))
3865 (gnus-article-press-button))
3867 (defvar gnus-displaying-mime nil)
3869 (defun gnus-display-mime (&optional ihandles)
3870 "Display the MIME parts."
3872 (save-selected-window
3873 (let ((window (get-buffer-window gnus-article-buffer))
3876 (select-window window)
3877 ;; We have to do this since selecting the window
3878 ;; may change the point. So we set the window point.
3879 (set-window-point window point)))
3880 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3881 buffer-read-only handle name type b e display)
3882 (when (and (not ihandles)
3883 (not gnus-displaying-mime))
3884 ;; Top-level call; we clean up.
3885 (when gnus-article-mime-handles
3886 (mm-destroy-parts gnus-article-mime-handles)
3887 (setq gnus-article-mime-handle-alist nil));; A trick.
3888 (setq gnus-article-mime-handles handles)
3889 ;; We allow users to glean info from the handles.
3890 (when gnus-article-mime-part-function
3891 (gnus-mime-part-function handles)))
3893 (or (not (stringp (car handles)))
3896 (when (and (not ihandles)
3897 (not gnus-displaying-mime))
3898 ;; Clean up for mime parts.
3900 (delete-region (point) (point-max)))
3901 (let ((gnus-displaying-mime t))
3902 (gnus-mime-display-part handles)))
3905 (narrow-to-region (point) (point-max))
3906 (gnus-treat-article nil 1 1)
3909 ;; Highlight the headers.
3913 (narrow-to-region (point-min) (point))
3914 (gnus-treat-article 'head))))))))
3916 (defvar gnus-mime-display-multipart-as-mixed nil)
3918 (defun gnus-mime-display-part (handle)
3921 ((not (stringp (car handle)))
3922 (gnus-mime-display-single handle))
3923 ;; User-defined multipart
3924 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3925 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3927 ;; multipart/alternative
3928 ((and (equal (car handle) "multipart/alternative")
3929 (not gnus-mime-display-multipart-as-mixed))
3930 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3931 (push (cons id handle) gnus-article-mime-handle-alist)
3932 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3933 ;; multipart/related
3934 ((and (equal (car handle) "multipart/related")
3935 (not gnus-mime-display-multipart-as-mixed))
3936 ;;;!!!We should find the start part, but we just default
3937 ;;;!!!to the first part.
3938 ;;(gnus-mime-display-part (cadr handle))
3939 ;;;!!! Most multipart/related is an HTML message plus images.
3940 ;;;!!! Unfortunately we are unable to let W3 display those
3941 ;;;!!! included images, so we just display it as a mixed multipart.
3942 (gnus-mime-display-mixed (cdr handle)))
3943 ((equal (car handle) "multipart/signed")
3944 (or (memq 'signed gnus-article-wash-types)
3945 (push 'signed gnus-article-wash-types))
3946 (gnus-insert-mime-security-button handle)
3947 (gnus-mime-display-mixed (cdr handle)))
3948 ((equal (car handle) "multipart/encrypted")
3949 (or (memq 'encrypted gnus-article-wash-types)
3950 (push 'encrypted gnus-article-wash-types))
3951 (gnus-insert-mime-security-button handle)
3952 (gnus-mime-display-mixed (cdr handle)))
3953 ;; Other multiparts are handled like multipart/mixed.
3955 (gnus-mime-display-mixed (cdr handle)))))
3957 (defun gnus-mime-part-function (handles)
3958 (if (stringp (car handles))
3959 (mapcar 'gnus-mime-part-function (cdr handles))
3960 (funcall gnus-article-mime-part-function handles)))
3962 (defun gnus-mime-display-mixed (handles)
3963 (mapcar 'gnus-mime-display-part handles))
3965 (defun gnus-mime-display-single (handle)
3966 (let ((type (mm-handle-media-type handle))
3967 (ignored gnus-ignored-mime-types)
3974 (when (string-match (pop ignored) type)
3975 (throw 'ignored nil)))
3976 (if (and (setq not-attachment
3977 (and (not (mm-inline-override-p handle))
3978 (or (not (mm-handle-disposition handle))
3979 (equal (car (mm-handle-disposition handle))
3981 (mm-attachment-override-p handle))))
3982 (mm-automatic-display-p handle)
3983 (or (mm-inlined-p handle)
3984 (mm-automatic-external-display-p type)))
3986 (when (equal (mm-handle-media-supertype handle) "text")
3988 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3990 (push (cons id handle) gnus-article-mime-handle-alist)
3991 (when (or (not display)
3992 (not (gnus-unbuttonized-mime-type-p type)))
3993 ;(gnus-article-insert-newline)
3994 (gnus-insert-mime-button
3995 handle id (list (or display (and not-attachment text))))
3996 (gnus-article-insert-newline)
3997 ;(gnus-article-insert-newline)
3998 ;; Remember modify the number of forward lines.
4006 (let ((mail-parse-charset gnus-newsgroup-charset)
4007 (mail-parse-ignored-charsets
4008 (save-excursion (condition-case ()
4009 (set-buffer gnus-summary-buffer)
4011 gnus-newsgroup-ignored-charsets)))
4012 (mm-display-part handle t))
4013 (goto-char (point-max)))
4014 ((and text not-attachment)
4018 (gnus-article-insert-newline)
4019 (mm-insert-inline handle (mm-get-part handle))
4020 (goto-char (point-max))))
4024 (narrow-to-region beg (point))
4027 (gnus-article-mime-total-parts)
4028 (mm-handle-media-type handle)))))))))
4030 (defun gnus-unbuttonized-mime-type-p (type)
4031 "Say whether TYPE is to be unbuttonized."
4032 (unless gnus-inhibit-mime-unbuttonizing
4034 (let ((types gnus-unbuttonized-mime-types))
4036 (when (string-match (pop types) type)
4037 (throw 'found t)))))))
4039 (defun gnus-article-insert-newline ()
4040 "Insert a newline, but mark it as undeletable."
4041 (gnus-put-text-property
4042 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4044 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4045 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4048 handle buffer-read-only from props begend not-pref)
4049 (save-window-excursion
4052 (narrow-to-region (car ibegend)
4055 (goto-char (car ibegend))
4058 (delete-region (point-min) (point-max))
4059 (mm-remove-parts handles))
4060 (setq begend (list (point-marker)))
4062 (unless (setq not-pref (cadr (member preferred ihandles)))
4063 (setq not-pref (car ihandles)))
4066 (not (gnus-unbuttonized-mime-type-p
4067 "multipart/alternative")))
4068 (gnus-add-text-properties
4071 (insert (format "%d. " id))
4075 (unless ,(not ibegend)
4076 (setq gnus-article-mime-handle-alist
4077 ',gnus-article-mime-handle-alist))
4078 (gnus-mime-display-alternative
4079 ',ihandles ',not-pref ',begend ,id))
4080 local-map ,gnus-mime-button-map
4081 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4082 face ,gnus-article-button-face
4083 keymap ,gnus-mime-button-map
4086 (widget-convert-button 'link from (point)
4087 :action 'gnus-widget-press-button
4088 :button-keymap gnus-widget-button-keymap)
4090 (while (setq handle (pop handles))
4091 (gnus-add-text-properties
4094 (insert (format "(%c) %-18s"
4095 (if (equal handle preferred) ?* ? )
4096 (mm-handle-media-type handle)))
4100 (unless ,(not ibegend)
4101 (setq gnus-article-mime-handle-alist
4102 ',gnus-article-mime-handle-alist))
4103 (gnus-mime-display-alternative
4104 ',ihandles ',handle ',begend ,id))
4105 local-map ,gnus-mime-button-map
4106 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4107 face ,gnus-article-button-face
4108 keymap ,gnus-mime-button-map
4111 (widget-convert-button 'link from (point)
4112 :action 'gnus-widget-press-button
4113 :button-keymap gnus-widget-button-keymap)
4117 (if (stringp (car preferred))
4118 (gnus-display-mime preferred)
4119 (let ((mail-parse-charset gnus-newsgroup-charset)
4120 (mail-parse-ignored-charsets
4121 (save-excursion (set-buffer gnus-summary-buffer)
4122 gnus-newsgroup-ignored-charsets)))
4123 (mm-display-part preferred)
4127 (narrow-to-region (car begend) (point-max))
4129 nil (length gnus-article-mime-handle-alist)
4130 (gnus-article-mime-total-parts)
4131 (mm-handle-media-type handle))))))
4132 (goto-char (point-max))
4133 (setcdr begend (point-marker)))))
4135 (goto-char point))))
4137 (defun gnus-article-wash-status ()
4138 "Return a string which display status of article washing."
4140 (set-buffer gnus-article-buffer)
4141 (let ((cite (memq 'cite gnus-article-wash-types))
4142 (headers (memq 'headers gnus-article-wash-types))
4143 (boring (memq 'boring-headers gnus-article-wash-types))
4144 (pgp (memq 'pgp gnus-article-wash-types))
4145 (pem (memq 'pem gnus-article-wash-types))
4146 (signed (memq 'signed gnus-article-wash-types))
4147 (encrypted (memq 'encrypted gnus-article-wash-types))
4148 (signature (memq 'signature gnus-article-wash-types))
4149 (overstrike (memq 'overstrike gnus-article-wash-types))
4150 (emphasis (memq 'emphasis gnus-article-wash-types)))
4151 (format "%c%c%c%c%c%c%c"
4153 (if (or headers boring) ?h ? )
4154 (if (or pgp pem signed encrypted) ?p ? )
4155 (if signature ?s ? )
4156 (if overstrike ?o ? )
4157 (if gnus-show-mime ?m ? )
4158 (if emphasis ?e ? )))))
4160 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4162 (defun gnus-article-maybe-hide-headers ()
4163 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4164 Provided for backwards compatibility."
4165 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4166 (not (save-excursion (set-buffer gnus-summary-buffer)
4167 gnus-have-all-headers)))
4168 (not gnus-inhibit-hiding))
4169 (gnus-article-hide-headers)))
4173 (defun gnus-output-to-file (file-name)
4174 "Append the current article to a file named FILE-NAME."
4175 (let ((artbuf (current-buffer)))
4177 (insert-buffer-substring artbuf)
4178 ;; Append newline at end of the buffer as separator, and then
4180 (goto-char (point-max))
4182 (write-region-as-binary (point-min) (point-max) file-name 'append)
4185 (defun gnus-narrow-to-page (&optional arg)
4186 "Narrow the article buffer to a page.
4187 If given a numerical ARG, move forward ARG pages."
4189 (setq arg (if arg (prefix-numeric-value arg) 0))
4191 (set-buffer gnus-article-buffer)
4192 (goto-char (point-min))
4194 ;; Remove any old next/prev buttons.
4195 (when (gnus-visual-p 'page-marker)
4196 (let ((buffer-read-only nil))
4197 (gnus-remove-text-with-property 'gnus-prev)
4198 (gnus-remove-text-with-property 'gnus-next)))
4201 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4203 (re-search-forward page-delimiter nil 'move arg)))
4204 (goto-char (match-end 0)))
4207 (if (re-search-forward page-delimiter nil 'move)
4210 (when (and (gnus-visual-p 'page-marker)
4211 (not (= (point-min) 1)))
4213 (goto-char (point-min))
4214 (gnus-insert-prev-page-button)))
4215 (when (and (gnus-visual-p 'page-marker)
4216 (< (+ (point-max) 2) (buffer-size)))
4218 (goto-char (point-max))
4219 (gnus-insert-next-page-button)))))
4221 ;; Article mode commands
4223 (defun gnus-article-goto-next-page ()
4224 "Show the next page of the article."
4226 (when (gnus-article-next-page)
4227 (goto-char (point-min))
4228 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4230 (defun gnus-article-goto-prev-page ()
4231 "Show the next page of the article."
4233 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4234 (gnus-article-prev-page nil)))
4236 (defun gnus-article-next-page (&optional lines)
4237 "Show the next page of the current article.
4238 If end of article, return non-nil. Otherwise return nil.
4239 Argument LINES specifies lines to be scrolled up."
4241 (let ((start (window-start))
4242 end-of-buffer end-of-page)
4244 (move-to-window-line -1)
4245 (if (<= (point) start)
4248 (setq start (point)))
4251 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4252 (and (pos-visible-in-window-p)
4253 (setq end-of-buffer t)))
4255 (setq end-of-page t)))
4257 (move-to-window-line lines)
4258 (unless (search-backward "\n\n" nil t)
4259 (setq start (point)))))
4260 (cond (end-of-buffer t)
4262 (gnus-narrow-to-page 1)
4266 (set-window-start (selected-window) start)
4267 (let (window-pixel-scroll-increment)
4271 (defun gnus-article-prev-page (&optional lines)
4272 "Show previous page of current article.
4273 Argument LINES specifies lines to be scrolled down."
4275 (let (beginning-of-buffer beginning-of-page)
4277 (move-to-window-line 0)
4278 (cond ((eq 1 (point))
4279 (setq beginning-of-buffer t))
4281 (setq beginning-of-page t))))
4282 (cond (beginning-of-buffer)
4284 (gnus-narrow-to-page -1))
4287 (let (window-pixel-scroll-increment)
4288 (scroll-down lines))
4289 (beginning-of-buffer
4290 (goto-char (point-min))))))))
4292 (defun gnus-article-refer-article ()
4293 "Read article specified by message-id around point."
4295 (let ((point (point)))
4296 (search-forward ">" nil t) ;Move point to end of "<....>".
4297 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4298 (let ((message-id (match-string 1)))
4300 (set-buffer gnus-summary-buffer)
4301 (gnus-summary-refer-article message-id))
4303 (error "No references around point"))))
4305 (defun gnus-article-show-summary ()
4306 "Reconfigure windows to show summary buffer."
4308 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4309 (error "There is no summary buffer for this article buffer")
4310 (gnus-article-set-globals)
4311 (gnus-configure-windows 'article)
4312 (gnus-summary-goto-subject gnus-current-article)
4313 (gnus-summary-position-point)))
4315 (defun gnus-article-describe-briefly ()
4316 "Describe article mode commands briefly."
4318 (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")))
4320 (defun gnus-article-summary-command ()
4321 "Execute the last keystroke in the summary buffer."
4323 (let ((obuf (current-buffer))
4324 (owin (current-window-configuration))
4326 (switch-to-buffer gnus-article-current-summary 'norecord)
4327 (setq func (lookup-key (current-local-map) (this-command-keys)))
4328 (call-interactively func)
4330 (set-window-configuration owin)
4331 (set-window-point (get-buffer-window (current-buffer)) (point))))
4333 (defun gnus-article-summary-command-nosave ()
4334 "Execute the last keystroke in the summary buffer."
4337 (pop-to-buffer gnus-article-current-summary 'norecord)
4338 (setq func (lookup-key (current-local-map) (this-command-keys)))
4339 (call-interactively func)))
4341 (defun gnus-article-check-buffer ()
4342 "Beep if not in an article buffer."
4343 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4344 (error "Command invoked outside of a Gnus article buffer")))
4346 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4347 "Read a summary buffer key sequence and execute it from the article buffer."
4349 (gnus-article-check-buffer)
4351 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4352 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4353 "=" "^" "\M-^" "|"))
4359 '("n" "Gn" "p" "Gp"))
4362 (set-buffer gnus-article-current-summary)
4363 (let (gnus-pick-mode)
4364 (push (or key last-command-event) unread-command-events)
4365 (setq keys (static-if (featurep 'xemacs)
4366 (events-to-keys (read-key-sequence nil))
4367 (read-key-sequence nil)))))
4370 (if (or (member keys nosaves)
4371 (member keys nosave-but-article)
4372 (member keys nosave-in-article))
4374 (save-window-excursion
4375 (pop-to-buffer gnus-article-current-summary 'norecord)
4376 ;; We disable the pick minor mode commands.
4377 (let (gnus-pick-mode)
4378 (setq func (lookup-key (current-local-map) keys))))
4382 (unless (member keys nosave-in-article)
4383 (set-buffer gnus-article-current-summary))
4384 (call-interactively func)
4385 (setq new-sum-point (point)))
4386 (when (member keys nosave-but-article)
4387 (pop-to-buffer gnus-article-buffer 'norecord)))
4388 ;; These commands should restore window configuration.
4389 (let ((obuf (current-buffer))
4390 (owin (current-window-configuration))
4392 (summary gnus-article-current-summary)
4393 func in-buffer selected)
4394 (if not-restore-window
4395 (pop-to-buffer summary 'norecord)
4396 (switch-to-buffer summary 'norecord))
4397 (setq in-buffer (current-buffer))
4398 ;; We disable the pick minor mode commands.
4399 (if (setq func (let (gnus-pick-mode)
4400 (lookup-key (current-local-map) keys)))
4402 (call-interactively func)
4403 (setq new-sum-point (point)))
4405 (when (eq in-buffer (current-buffer))
4406 (setq selected (gnus-summary-select-article))
4408 (unless not-restore-window
4409 (set-window-configuration owin))
4410 (when (eq selected 'old)
4412 (set-window-start (get-buffer-window (current-buffer))
4414 (set-window-point (get-buffer-window (current-buffer))
4416 (let ((win (get-buffer-window gnus-article-current-summary)))
4418 (set-window-point win new-sum-point))))))))
4420 (defun gnus-article-hide (&optional arg force)
4421 "Hide all the gruft in the current article.
4422 This means that PGP stuff, signatures, cited text and (some)
4423 headers will be hidden.
4424 If given a prefix, show the hidden text instead."
4425 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4426 (gnus-article-hide-headers arg)
4427 (gnus-article-hide-list-identifiers arg)
4428 (gnus-article-hide-pgp arg)
4429 (gnus-article-hide-citation-maybe arg force)
4430 (gnus-article-hide-signature arg))
4432 (defun gnus-article-maybe-highlight ()
4433 "Do some article highlighting if article highlighting is requested."
4434 (when (gnus-visual-p 'article-highlight 'highlight)
4435 (gnus-article-highlight-some)))
4437 (defun gnus-check-group-server ()
4438 ;; Make sure the connection to the server is alive.
4439 (unless (gnus-server-opened
4440 (gnus-find-method-for-group gnus-newsgroup-name))
4441 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4442 (gnus-request-group gnus-newsgroup-name t)))
4444 (defun gnus-request-article-this-buffer (article group)
4445 "Get an article and insert it into this buffer."
4446 (let (do-update-line sparse-header)
4450 (gnus-kill-all-overlays)
4451 (setq group (or group gnus-newsgroup-name))
4453 ;; Using `gnus-request-article' directly will insert the article into
4454 ;; `nntp-server-buffer' - so we'll save some time by not having to
4455 ;; copy it from the server buffer into the article buffer.
4457 ;; We only request an article by message-id when we do not have the
4458 ;; headers for it, so we'll have to get those.
4459 (when (stringp article)
4460 (gnus-read-header article))
4462 ;; If the article number is negative, that means that this article
4463 ;; doesn't belong in this newsgroup (possibly), so we find its
4464 ;; message-id and request it by id instead of number.
4465 (when (and (numberp article)
4467 (get-buffer gnus-summary-buffer)
4468 (gnus-buffer-exists-p gnus-summary-buffer))
4470 (set-buffer gnus-summary-buffer)
4471 (let ((header (gnus-summary-article-header article)))
4474 ((memq article gnus-newsgroup-sparse)
4475 ;; This is a sparse gap article.
4476 (setq do-update-line article)
4477 (setq article (mail-header-id header))
4478 (setq sparse-header (gnus-read-header article))
4479 (setq gnus-newsgroup-sparse
4480 (delq article gnus-newsgroup-sparse)))
4482 ;; It's a real article.
4483 (setq article (mail-header-id header)))
4485 ;; It is an extracted pseudo-article.
4486 (setq article 'pseudo)
4487 (gnus-request-pseudo-article header))))
4489 (let ((method (gnus-find-method-for-group
4490 gnus-newsgroup-name)))
4491 (when (and (eq (car method) 'nneething)
4493 (let ((dir (expand-file-name
4494 (mail-header-subject header)
4495 (file-name-as-directory
4496 (or (cadr (assq 'nneething-address method))
4498 (when (file-directory-p dir)
4499 (setq article 'nneething)
4500 (gnus-group-enter-directory dir))))))))
4503 ;; Refuse to select canceled articles.
4504 ((and (numberp article)
4506 (get-buffer gnus-summary-buffer)
4507 (gnus-buffer-exists-p gnus-summary-buffer)
4508 (eq (cdr (save-excursion
4509 (set-buffer gnus-summary-buffer)
4510 (assq article gnus-newsgroup-reads)))
4511 gnus-canceled-mark))
4513 ;; Check the backlog.
4514 ((and gnus-keep-backlog
4515 (gnus-backlog-request-article group article (current-buffer)))
4517 ;; Check asynchronous pre-fetch.
4518 ((gnus-async-request-fetched-article group article (current-buffer))
4519 (gnus-async-prefetch-next group article gnus-summary-buffer)
4520 (when (and (numberp article) gnus-keep-backlog)
4521 (gnus-backlog-enter-article group article (current-buffer)))
4524 ((and gnus-use-cache
4526 (gnus-cache-request-article article group))
4528 ;; Get the article and put into the article buffer.
4529 ((or (stringp article)
4531 (let ((gnus-override-method gnus-override-method)
4532 (methods (and (stringp article)
4533 gnus-refer-article-method))
4535 (buffer-read-only nil))
4536 (if (or (not (listp methods))
4537 (and (symbolp (car methods))
4538 (assq (car methods) nnoo-definition-alist)))
4539 (setq methods (list methods)))
4540 (when (and (null gnus-override-method)
4542 (setq gnus-override-method (pop methods)))
4544 (when (eq gnus-override-method 'current)
4545 (setq gnus-override-method gnus-current-select-method))
4547 (gnus-kill-all-overlays)
4548 (let ((gnus-newsgroup-name group))
4549 (gnus-check-group-server))
4550 (when (gnus-request-article article group (current-buffer))
4551 (when (numberp article)
4552 (gnus-async-prefetch-next group article
4553 gnus-summary-buffer)
4554 (when gnus-keep-backlog
4555 (gnus-backlog-enter-article
4556 group article (current-buffer))))
4557 (setq result 'article))
4560 (setq gnus-override-method (pop methods))
4561 (setq result 'done))))
4562 (and (eq result 'article) 'article)))
4566 ;; Associate this article with the current summary buffer.
4567 (setq gnus-article-current-summary gnus-summary-buffer)
4569 ;; Take the article from the original article buffer
4570 ;; and place it in the buffer it's supposed to be in.
4571 (when (and (get-buffer gnus-article-buffer)
4572 (equal (buffer-name (current-buffer))
4573 (buffer-name (get-buffer gnus-article-buffer))))
4575 (if (get-buffer gnus-original-article-buffer)
4576 (set-buffer gnus-original-article-buffer)
4577 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4578 (set-buffer-multibyte nil)
4579 (buffer-disable-undo)
4580 (setq major-mode 'gnus-original-article-mode)
4581 (setq buffer-read-only t))
4582 (let (buffer-read-only)
4584 (insert-buffer-substring gnus-article-buffer))
4585 (setq gnus-original-article (cons group article)))
4588 (run-hooks 'gnus-article-decode-hook)
4589 ;; Mark article as decoded or not.
4590 (setq gnus-article-decoded-p gnus-article-decode-hook))
4592 ;; Update sparse articles.
4593 (when (and do-update-line
4594 (or (numberp article)
4596 (let ((buf (current-buffer)))
4597 (set-buffer gnus-summary-buffer)
4598 (gnus-summary-update-article do-update-line sparse-header)
4599 (gnus-summary-goto-subject do-update-line nil t)
4600 (set-window-point (get-buffer-window (current-buffer) t)
4602 (set-buffer buf))))))
4608 (defcustom gnus-article-edit-mode-hook nil
4609 "Hook run in article edit mode buffers."
4610 :group 'gnus-article-various
4613 (defcustom gnus-article-edit-article-setup-function
4614 'gnus-article-mime-edit-article-setup
4615 "Function called to setup an editing article buffer."
4616 :group 'gnus-article-various
4619 (defvar gnus-article-edit-done-function nil)
4621 (defvar gnus-article-edit-mode-map nil)
4623 ;; Should we be using derived.el for this?
4624 (unless gnus-article-edit-mode-map
4625 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4626 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4628 (gnus-define-keys gnus-article-edit-mode-map
4629 "\C-c\C-c" gnus-article-edit-done
4630 "\C-c\C-k" gnus-article-edit-exit)
4632 (gnus-define-keys (gnus-article-edit-wash-map
4633 "\C-c\C-w" gnus-article-edit-mode-map)
4634 "f" gnus-article-edit-full-stops))
4636 (defun gnus-article-edit-mode ()
4637 "Major mode for editing articles.
4638 This is an extended text-mode.
4640 \\{gnus-article-edit-mode-map}"
4642 (setq major-mode 'gnus-article-edit-mode)
4643 (setq mode-name "Article Edit")
4644 (use-local-map gnus-article-edit-mode-map)
4645 (make-local-variable 'gnus-article-edit-done-function)
4646 (make-local-variable 'gnus-prev-winconf)
4647 (setq buffer-read-only nil)
4648 (buffer-enable-undo)
4650 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4652 (defun gnus-article-edit (&optional force)
4653 "Edit the current article.
4654 This will have permanent effect only in mail groups.
4655 If FORCE is non-nil, allow editing of articles even in read-only
4658 (when (and (not force)
4659 (gnus-group-read-only-p))
4660 (error "The current newsgroup does not support article editing"))
4661 (gnus-article-date-original)
4662 (gnus-article-edit-article
4664 `(lambda (no-highlight)
4666 (gnus-summary-edit-article-done
4667 ,(or (mail-header-references gnus-current-headers) "")
4668 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4670 (defun gnus-article-edit-article (start-func exit-func)
4671 "Start editing the contents of the current article buffer."
4672 (let ((winconf (current-window-configuration)))
4673 (set-buffer gnus-article-buffer)
4674 (gnus-article-edit-mode)
4675 (funcall start-func)
4676 (gnus-configure-windows 'edit-article)
4677 (setq gnus-article-edit-done-function exit-func)
4678 (setq gnus-prev-winconf winconf)
4679 (when gnus-article-edit-article-setup-function
4680 (funcall gnus-article-edit-article-setup-function))
4681 (gnus-message 6 "C-c C-c to end edits")))
4683 (defun gnus-article-edit-done (&optional arg)
4684 "Update the article edits and exit."
4686 (let ((func gnus-article-edit-done-function)
4687 (buf (current-buffer))
4688 (start (window-start)))
4689 (remove-hook 'gnus-article-mode-hook
4690 'gnus-article-mime-edit-article-unwind)
4691 (gnus-article-edit-exit)
4694 (let ((buffer-read-only nil))
4696 ;; The cache and backlog have to be flushed somewhat.
4697 (when gnus-keep-backlog
4698 (gnus-backlog-remove-article
4699 (car gnus-article-current) (cdr gnus-article-current)))
4700 ;; Flush original article as well.
4702 (when (get-buffer gnus-original-article-buffer)
4703 (set-buffer gnus-original-article-buffer)
4704 (setq gnus-original-article nil)))
4705 (when gnus-use-cache
4706 (gnus-cache-update-article
4707 (car gnus-article-current) (cdr gnus-article-current))))
4709 (set-window-start (get-buffer-window buf) start)
4710 (set-window-point (get-buffer-window buf) (point))))
4712 (defun gnus-article-edit-exit ()
4713 "Exit the article editing without updating."
4715 ;; We remove all text props from the article buffer.
4716 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4717 (curbuf (current-buffer))
4719 (window-start (window-start)))
4722 (let ((winconf gnus-prev-winconf))
4724 (set-window-configuration winconf)
4725 ;; Tippy-toe some to make sure that point remains where it was.
4726 (save-current-buffer
4728 (set-window-start (get-buffer-window (current-buffer)) window-start)
4731 (defun gnus-article-edit-full-stops ()
4732 "Interactively repair spacing at end of sentences."
4735 (goto-char (point-min))
4736 (search-forward-regexp "^$" nil t)
4737 (let ((case-fold-search nil))
4738 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4741 ;;; Article editing with MIME-Edit
4744 (defcustom gnus-article-mime-edit-article-setup-hook nil
4745 "Hook run after setting up a MIME editing article buffer."
4746 :group 'gnus-article-various
4749 (defun gnus-article-mime-edit-article-unwind ()
4750 "Unwind `gnus-article-buffer' if article editing was given up."
4751 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4752 (when mime-edit-mode-flag
4753 (mime-edit-exit 'nomime 'no-error)
4755 (when (featurep 'font-lock)
4756 (setq font-lock-defaults nil)
4757 (font-lock-mode 0)))
4759 (defun gnus-article-mime-edit-article-setup ()
4760 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
4761 after replacing with the original article."
4762 (setq gnus-show-mime t)
4763 (setq gnus-article-edit-done-function
4764 `(lambda (&rest args)
4765 (when mime-edit-mode-flag
4768 (goto-char (point-min))
4769 (let (case-fold-search)
4770 (when (re-search-forward
4771 (format "^%s$" (regexp-quote mail-header-separator))
4773 (replace-match "")))
4774 (when (featurep 'font-lock)
4775 (setq font-lock-defaults nil)
4777 (apply ,gnus-article-edit-done-function args)
4778 (set-buffer gnus-original-article-buffer)
4780 (insert-buffer gnus-article-buffer)
4781 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4782 (gnus-article-prepare-display)))
4783 (substitute-key-definition
4784 'gnus-article-edit-exit 'gnus-article-mime-edit-exit
4785 gnus-article-edit-mode-map)
4787 (insert-buffer gnus-original-article-buffer)
4789 (when (featurep 'font-lock)
4790 (set (make-local-variable 'font-lock-defaults)
4791 '(message-font-lock-keywords t))
4792 (font-lock-set-defaults)
4793 (turn-on-font-lock))
4794 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4795 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
4797 (defun gnus-article-mime-edit-exit ()
4798 "Exit the article MIME editing without updating."
4800 (let ((winconf gnus-prev-winconf)
4802 (when mime-edit-mode-flag
4805 (goto-char (point-min))
4806 (let (case-fold-search)
4807 (when (re-search-forward
4808 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
4809 (replace-match "")))
4810 (when (featurep 'font-lock)
4811 (setq font-lock-defaults nil)
4813 ;; We remove all text props from the article buffer.
4814 (setq buf (format "%s" (buffer-string)))
4815 (set-buffer (get-buffer-create gnus-original-article-buffer))
4818 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4819 (gnus-article-prepare-display)
4820 (set-window-configuration winconf)))
4823 ;;; Article highlights
4826 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4828 ;;; Internal Variables:
4830 (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\\)\\)"
4831 "Regular expression that matches URLs."
4832 :group 'gnus-article-buttons
4835 (defcustom gnus-button-alist
4836 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4837 0 t gnus-button-message-id 2)
4838 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4839 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4841 gnus-button-fetch-group 4)
4842 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4843 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4844 t gnus-button-message-id 3)
4845 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4846 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4847 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4848 ;; This is how URLs _should_ be embedded in text...
4849 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4851 (,gnus-button-url-regexp 0 t browse-url 0))
4852 "*Alist of regexps matching buttons in article bodies.
4854 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4855 REGEXP: is the string matching text around the button,
4856 BUTTON: is the number of the regexp grouping actually matching the button,
4857 FORM: is a lisp expression which must eval to true for the button to
4859 CALLBACK: is the function to call when the user push this button, and each
4860 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4862 CALLBACK can also be a variable, in that case the value of that
4863 variable it the real callback function."
4864 :group 'gnus-article-buttons
4865 :type '(repeat (list regexp
4866 (integer :tag "Button")
4868 (function :tag "Callback")
4871 (integer :tag "Regexp group")))))
4873 (defcustom gnus-header-button-alist
4874 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4875 0 t gnus-button-message-id 0)
4876 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4877 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4878 0 t gnus-button-mailto 0)
4879 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4880 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4881 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4882 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4883 gnus-button-message-id 3))
4884 "*Alist of headers and regexps to match buttons in article heads.
4886 This alist is very similar to `gnus-button-alist', except that each
4887 alist has an additional HEADER element first in each entry:
4889 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4891 HEADER is a regexp to match a header. For a fuller explanation, see
4892 `gnus-button-alist'."
4893 :group 'gnus-article-buttons
4894 :group 'gnus-article-headers
4895 :type '(repeat (list (regexp :tag "Header")
4897 (integer :tag "Button")
4899 (function :tag "Callback")
4902 (integer :tag "Regexp group")))))
4904 (defvar gnus-button-regexp nil)
4905 (defvar gnus-button-marker-list nil)
4906 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4908 (defvar gnus-button-last nil)
4909 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4913 (defun gnus-article-push-button (event)
4914 "Check text under the mouse pointer for a callback function.
4915 If the text under the mouse pointer has a `gnus-callback' property,
4916 call it with the value of the `gnus-data' text property."
4918 (set-buffer (window-buffer (posn-window (event-start event))))
4919 (let* ((pos (posn-point (event-start event)))
4920 (data (get-text-property pos 'gnus-data))
4921 (fun (get-text-property pos 'gnus-callback)))
4924 (funcall fun data))))
4926 (defun gnus-article-press-button ()
4927 "Check text at point for a callback function.
4928 If the text at point has a `gnus-callback' property,
4929 call it with the value of the `gnus-data' text property."
4931 (let* ((data (get-text-property (point) 'gnus-data))
4932 (fun (get-text-property (point) 'gnus-callback)))
4934 (funcall fun data))))
4936 (defun gnus-article-prev-button (n)
4937 "Move point to N buttons backward.
4938 If N is negative, move forward instead."
4940 (gnus-article-next-button (- n)))
4942 (defun gnus-article-next-button (n)
4943 "Move point to N buttons forward.
4944 If N is negative, move backward instead."
4946 (let ((function (if (< n 0) 'previous-single-property-change
4947 'next-single-property-change))
4948 (inhibit-point-motion-hooks t)
4950 (limit (if (< n 0) (point-min) (point-max))))
4952 (while (and (not (= limit (point)))
4954 ;; Skip past the current button.
4955 (when (get-text-property (point) 'gnus-callback)
4956 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4957 ;; Go to the next (or previous) button.
4958 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
4959 ;; Put point at the start of the button.
4960 (when (and backward (not (get-text-property (point) 'gnus-callback)))
4961 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4962 ;; Skip past intangible buttons.
4963 (when (get-text-property (point) 'intangible)
4967 (gnus-message 5 "No more buttons"))
4970 (defun gnus-article-highlight (&optional force)
4971 "Highlight current article.
4972 This function calls `gnus-article-highlight-headers',
4973 `gnus-article-highlight-citation',
4974 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4975 do the highlighting. See the documentation for those functions."
4976 (interactive (list 'force))
4977 (gnus-article-highlight-headers)
4978 (gnus-article-highlight-citation force)
4979 (gnus-article-highlight-signature)
4980 (gnus-article-add-buttons force)
4981 (gnus-article-add-buttons-to-head))
4983 (defun gnus-article-highlight-some (&optional force)
4984 "Highlight current article.
4985 This function calls `gnus-article-highlight-headers',
4986 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4987 do the highlighting. See the documentation for those functions."
4988 (interactive (list 'force))
4989 (gnus-article-highlight-headers)
4990 (gnus-article-highlight-signature)
4991 (gnus-article-add-buttons))
4993 (defun gnus-article-highlight-headers ()
4994 "Highlight article headers as specified by `gnus-header-face-alist'."
4997 (set-buffer gnus-article-buffer)
4999 (let ((alist gnus-header-face-alist)
5000 (buffer-read-only nil)
5001 (case-fold-search t)
5002 (inhibit-point-motion-hooks t)
5003 entry regexp header-face field-face from hpoints fpoints)
5004 (article-narrow-to-head)
5005 (while (setq entry (pop alist))
5006 (goto-char (point-min))
5007 (setq regexp (concat "^\\("
5008 (if (string-equal "" (nth 0 entry))
5012 header-face (nth 1 entry)
5013 field-face (nth 2 entry))
5014 (while (and (re-search-forward regexp nil t)
5018 (unless (search-forward ":" nil t)
5020 (when (and header-face
5021 (not (memq (point) hpoints)))
5022 (push (point) hpoints)
5023 (gnus-put-text-property from (point) 'face header-face))
5024 (when (and field-face
5025 (not (memq (setq from (point)) fpoints)))
5027 (if (re-search-forward "^[^ \t]" nil t)
5029 (goto-char (point-max)))
5030 (gnus-put-text-property from (point) 'face field-face))))))))
5032 (defun gnus-article-highlight-signature ()
5033 "Highlight the signature in an article.
5034 It does this by highlighting everything after
5035 `gnus-signature-separator' using `gnus-signature-face'."
5037 (when gnus-signature-face
5039 (set-buffer gnus-article-buffer)
5040 (let ((buffer-read-only nil)
5041 (inhibit-point-motion-hooks t))
5043 (when (gnus-article-narrow-to-signature)
5044 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5045 'face gnus-signature-face)))))))
5047 (defun gnus-article-buttonize-signature ()
5048 "Add button to the signature."
5051 (set-buffer gnus-article-buffer)
5052 (let ((buffer-read-only nil)
5053 (inhibit-point-motion-hooks t))
5054 (when (gnus-article-search-signature)
5055 (gnus-article-add-button (match-beginning 0) (match-end 0)
5056 'gnus-signature-toggle
5057 (set-marker (make-marker)
5058 (1+ (match-end 0))))))))
5060 (defun gnus-button-in-region-p (b e prop)
5061 "Say whether PROP exists in the region."
5062 (text-property-not-all b e prop nil))
5064 (defun gnus-article-add-buttons (&optional force)
5065 "Find external references in the article and make buttons of them.
5066 \"External references\" are things like Message-IDs and URLs, as
5067 specified by `gnus-button-alist'."
5068 (interactive (list 'force))
5070 (set-buffer gnus-article-buffer)
5071 (let ((buffer-read-only nil)
5072 (inhibit-point-motion-hooks t)
5073 (case-fold-search t)
5074 (alist gnus-button-alist)
5076 ;; Remove all old markers.
5077 (let (marker entry new-list)
5078 (while (setq marker (pop gnus-button-marker-list))
5079 (if (or (< marker (point-min)) (>= marker (point-max)))
5080 (push marker new-list)
5082 (when (setq entry (gnus-button-entry))
5083 (put-text-property (match-beginning (nth 1 entry))
5084 (match-end (nth 1 entry))
5085 'gnus-callback nil))
5086 (set-marker marker nil)))
5087 (setq gnus-button-marker-list new-list))
5088 ;; We skip the headers.
5091 (while (setq entry (pop alist))
5092 (setq regexp (car entry))
5094 (while (re-search-forward regexp nil t)
5095 (let* ((start (and entry (match-beginning (nth 1 entry))))
5096 (end (and entry (match-end (nth 1 entry))))
5097 (from (match-beginning 0)))
5098 (when (and (or (eq t (nth 2 entry))
5099 (eval (nth 2 entry)))
5100 (not (gnus-button-in-region-p
5101 start end 'gnus-callback)))
5102 ;; That optional form returned non-nil, so we add the
5104 (gnus-article-add-button
5105 start end 'gnus-button-push
5106 (car (push (set-marker (make-marker) from)
5107 gnus-button-marker-list))))))))))
5109 ;; Add buttons to the head of an article.
5110 (defun gnus-article-add-buttons-to-head ()
5111 "Add buttons to the head of the article."
5114 (set-buffer gnus-article-buffer)
5116 (let ((buffer-read-only nil)
5117 (inhibit-point-motion-hooks t)
5118 (case-fold-search t)
5119 (alist gnus-header-button-alist)
5121 (article-narrow-to-head)
5123 ;; Each alist entry.
5124 (setq entry (car alist)
5126 (goto-char (point-min))
5127 (while (re-search-forward (car entry) nil t)
5128 ;; Each header matching the entry.
5129 (setq beg (match-beginning 0))
5130 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5131 (match-beginning 0))
5134 (while (re-search-forward (nth 1 entry) end t)
5135 ;; Each match within a header.
5136 (let* ((entry (cdr entry))
5137 (start (match-beginning (nth 1 entry)))
5138 (end (match-end (nth 1 entry)))
5139 (form (nth 2 entry)))
5140 (goto-char (match-end 0))
5142 (gnus-article-add-button
5143 start end (nth 3 entry)
5144 (buffer-substring (match-beginning (nth 4 entry))
5145 (match-end (nth 4 entry)))))))
5146 (goto-char end)))))))
5148 ;;; External functions:
5150 (defun gnus-article-add-button (from to fun &optional data)
5151 "Create a button between FROM and TO with callback FUN and data DATA."
5152 (when gnus-article-button-face
5153 (gnus-overlay-put (gnus-make-overlay from to)
5154 'face gnus-article-button-face))
5155 (gnus-add-text-properties
5157 (nconc (and gnus-article-mouse-face
5158 (list gnus-mouse-face-prop gnus-article-mouse-face))
5159 (list 'gnus-callback fun)
5160 (and data (list 'gnus-data data))))
5161 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5162 ;; Quote `:button-keymap' for Mule 2.3
5163 ;; but it won't work.
5164 ':button-keymap gnus-widget-button-keymap))
5166 ;;; Internal functions:
5168 (defun gnus-article-set-globals ()
5170 (set-buffer gnus-summary-buffer)
5171 (gnus-set-global-variables)))
5173 (defun gnus-signature-toggle (end)
5175 (set-buffer gnus-article-buffer)
5176 (let ((buffer-read-only nil)
5177 (inhibit-point-motion-hooks t)
5178 (limit (next-single-property-change end 'mime-view-entity
5180 (if (get-text-property end 'invisible)
5181 (gnus-article-unhide-text end limit)
5182 (gnus-article-hide-text end limit gnus-hidden-properties)))))
5184 (defun gnus-button-entry ()
5185 ;; Return the first entry in `gnus-button-alist' matching this place.
5186 (let ((alist gnus-button-alist)
5189 (setq entry (pop alist))
5190 (if (looking-at (car entry))
5195 (defun gnus-button-push (marker)
5196 ;; Push button starting at MARKER.
5199 (let* ((entry (gnus-button-entry))
5200 (inhibit-point-motion-hooks t)
5202 (args (mapcar (lambda (group)
5203 (let ((string (match-string group)))
5204 (gnus-set-text-properties
5205 0 (length string) nil string)
5212 (fboundp (symbol-value fun)))
5213 (apply (symbol-value fun) args))
5215 (gnus-message 1 "You must define `%S' to use this button"
5216 (cons fun args)))))))
5218 (defun gnus-button-message-id (message-id)
5221 (set-buffer gnus-summary-buffer)
5222 (gnus-summary-refer-article message-id)))
5224 (defun gnus-button-fetch-group (address)
5225 "Fetch GROUP specified by ADDRESS."
5226 (if (not (string-match "[:/]" address))
5227 ;; This is just a simple group url.
5228 (gnus-group-read-ephemeral-group address gnus-select-method)
5229 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
5231 (error "Can't parse %s" address)
5232 (gnus-group-read-ephemeral-group
5233 (match-string 4 address)
5234 `(nntp ,(match-string 1 address)
5235 (nntp-address ,(match-string 1 address))
5236 (nntp-port-number ,(if (match-end 3)
5237 (match-string 3 address)
5240 (defun gnus-url-parse-query-string (query &optional downcase)
5241 (let (retval pairs cur key val)
5242 (setq pairs (split-string query "&"))
5244 (setq cur (car pairs)
5246 (if (not (string-match "=" cur))
5248 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5249 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5251 (setq key (downcase key)))
5252 (setq cur (assoc key retval))
5254 (setcdr cur (cons val (cdr cur)))
5255 (setq retval (cons (list key val) retval)))))
5258 (defun gnus-url-unhex (x)
5265 (defun gnus-url-unhex-string (str &optional allow-newlines)
5266 "Remove %XXX embedded spaces, etc in a url.
5267 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5268 decoding of carriage returns and line feeds in the string, which is normally
5269 forbidden in URL encoding."
5270 (setq str (or str ""))
5272 (case-fold-search t))
5273 (while (string-match "%[0-9a-f][0-9a-f]" str)
5274 (let* ((start (match-beginning 0))
5275 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5277 (gnus-url-unhex (elt str (+ start 2))))))
5279 tmp (substring str 0 start)
5282 (char-to-string code))
5283 ((or (= code ?\n) (= code ?\r))
5285 (t (char-to-string code))))
5286 str (substring str (match-end 0)))))
5287 (setq tmp (concat tmp str))
5290 (defun gnus-url-mailto (url)
5291 ;; Send mail to someone
5292 (when (string-match "mailto:/*\\(.*\\)" url)
5293 (setq url (substring url (match-beginning 1) nil)))
5294 (let (to args subject func)
5295 (if (string-match (regexp-quote "?") url)
5296 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5297 args (gnus-url-parse-query-string
5298 (substring url (match-end 0) nil) t))
5299 (setq to (gnus-url-unhex-string url)))
5300 (setq args (cons (list "to" to) args)
5301 subject (cdr-safe (assoc "subject" args)))
5302 (gnus-setup-message 'reply
5305 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5308 (message-position-on-field (caar args)))
5309 (insert (mapconcat 'identity (cdar args) ", "))
5310 (setq args (cdr args)))
5313 (message-goto-subject)))))
5315 (defun gnus-button-mailto (address)
5317 (set-buffer (gnus-copy-article-buffer))
5318 (message-reply address))
5320 (defalias 'gnus-button-reply 'message-reply)
5322 (defun gnus-button-embedded-url (address)
5323 "Activate ADDRESS with `browse-url'."
5324 (browse-url (gnus-strip-whitespace address)))
5326 (defun gnus-article-smiley-display ()
5327 "Display \"smileys\" as small graphical icons."
5328 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5330 ;;; Next/prev buttons in the article buffer.
5332 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5333 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5335 (defvar gnus-prev-page-map nil)
5336 (unless gnus-prev-page-map
5337 (setq gnus-prev-page-map (make-sparse-keymap))
5338 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5339 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5341 (static-if (featurep 'xemacs)
5342 (defun gnus-insert-prev-page-button ()
5343 (let ((buffer-read-only nil))
5345 gnus-prev-page-line-format nil
5346 `(gnus-prev t local-map ,gnus-prev-page-map
5347 gnus-callback gnus-article-button-prev-page
5348 article-type annotation))))
5349 (defun gnus-insert-prev-page-button ()
5350 (let ((buffer-read-only nil)
5351 (situation (get-text-property (point-min) 'mime-view-situation)))
5352 (set-keymap-parent gnus-prev-page-map (current-local-map))
5354 gnus-prev-page-line-format nil
5355 `(gnus-prev t local-map ,gnus-prev-page-map
5356 gnus-callback gnus-article-button-prev-page
5357 article-type annotation
5358 mime-view-situation ,situation))))
5361 (defvar gnus-next-page-map nil)
5362 (unless gnus-next-page-map
5363 (setq gnus-next-page-map (make-sparse-keymap))
5364 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5365 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5367 (defun gnus-button-next-page ()
5368 "Go to the next page."
5370 (let ((win (selected-window)))
5371 (select-window (get-buffer-window gnus-article-buffer t))
5372 (gnus-article-next-page)
5373 (select-window win)))
5375 (defun gnus-button-prev-page ()
5376 "Go to the prev page."
5378 (let ((win (selected-window)))
5379 (select-window (get-buffer-window gnus-article-buffer t))
5380 (gnus-article-prev-page)
5381 (select-window win)))
5383 (static-if (featurep 'xemacs)
5384 (defun gnus-insert-next-page-button ()
5385 (let ((buffer-read-only nil))
5386 (gnus-eval-format gnus-next-page-line-format nil
5388 t local-map ,gnus-next-page-map
5389 gnus-callback gnus-article-button-next-page
5390 article-type annotation))))
5391 (defun gnus-insert-next-page-button ()
5392 (let ((buffer-read-only nil)
5393 (situation (get-text-property (point-min) 'mime-view-situation)))
5394 (set-keymap-parent gnus-next-page-map (current-local-map))
5395 (gnus-eval-format gnus-next-page-line-format nil
5397 t local-map ,gnus-next-page-map
5398 gnus-callback gnus-article-button-next-page
5399 article-type annotation
5400 mime-view-situation ,situation))))
5403 (defun gnus-article-button-next-page (arg)
5404 "Go to the next page."
5406 (let ((win (selected-window)))
5407 (select-window (get-buffer-window gnus-article-buffer t))
5408 (gnus-article-next-page)
5409 (select-window win)))
5411 (defun gnus-article-button-prev-page (arg)
5412 "Go to the prev page."
5414 (let ((win (selected-window)))
5415 (select-window (get-buffer-window gnus-article-buffer t))
5416 (gnus-article-prev-page)
5417 (select-window win)))
5419 (defvar gnus-decode-header-methods
5420 '(mail-decode-encoded-word-region)
5421 "List of methods used to decode headers.
5423 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5424 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5425 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5426 whose names match REGEXP.
5429 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5430 mail-decode-encoded-word-region
5431 (\"chinese\" . rfc1843-decode-region))
5434 (defvar gnus-decode-header-methods-cache nil)
5436 (defun gnus-multi-decode-header (start end)
5437 "Apply the functions from `gnus-encoded-word-methods' that match."
5438 (unless (and gnus-decode-header-methods-cache
5439 (eq gnus-newsgroup-name
5440 (car gnus-decode-header-methods-cache)))
5441 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5444 (nconc gnus-decode-header-methods-cache (list x))
5445 (if (and gnus-newsgroup-name
5446 (string-match (car x) gnus-newsgroup-name))
5447 (nconc gnus-decode-header-methods-cache
5449 gnus-decode-header-methods))
5450 (let ((xlist gnus-decode-header-methods-cache))
5453 (narrow-to-region start end)
5455 (funcall (pop xlist) (point-min) (point-max))))))
5458 ;;; Treatment top-level handling.
5461 (defun gnus-treat-article (condition &optional part-number total-parts type)
5462 (let ((length (- (point-max) (point-min)))
5463 (alist gnus-treatment-function-alist)
5464 (article-goto-body-goes-to-point-min-p t)
5468 (let ((list gnus-article-treat-types))
5470 (when (string-match (pop list) type)
5471 (throw 'found t)))))))
5472 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5473 (entity (static-unless (featurep 'xemacs)
5474 (when (eq 'head condition)
5475 (get-text-property (point-min) 'mime-view-entity))))
5476 val elem buttonized)
5477 (gnus-run-hooks 'gnus-part-display-hook)
5478 (unless gnus-inhibit-treatment
5479 (while (setq elem (pop alist))
5482 (if (gnus-buffer-live-p gnus-summary-buffer)
5483 (set-buffer gnus-summary-buffer))
5484 (symbol-value (car elem))))
5485 (when (and (or (consp val)
5487 (gnus-treat-predicate val)
5488 (or (not (get (car elem) 'highlight))
5490 (when (and (not buttonized)
5492 '(gnus-treat-hide-signature
5493 gnus-treat-highlight-signature)))
5494 (gnus-article-buttonize-signature)
5495 (setq buttonized t))
5497 (funcall (cadr elem)))))
5498 ;; FSF Emacsen does not inherit the existing text properties
5499 ;; in the new text, so we should do it for `mime-view-entity'.
5500 (static-unless (featurep 'xemacs)
5502 (put-text-property (point-min) (point-max)
5503 'mime-view-entity entity))))))
5505 ;; Dynamic variables.
5507 (defvar part-number)
5508 (defvar total-parts)
5513 (defun gnus-treat-predicate (val)
5518 (stringp (car val)))
5519 (apply 'gnus-or (mapcar `(lambda (s)
5520 (string-match s ,(or gnus-newsgroup-name "")))
5523 (let ((pred (pop val)))
5526 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5528 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5530 (not (gnus-treat-predicate (car val))))
5532 (equal (car val) type))
5534 (error "%S is not a valid predicate" pred)))))
5544 (eq part-number total-parts))
5548 (error "%S is not a valid value" val))))
5550 (defun gnus-article-encrypt-body (protocol &optional n)
5551 "Encrypt the article body."
5554 (or gnus-article-encrypt-protocol
5555 (completing-read "Encrypt protocol: "
5556 gnus-article-encrypt-protocol-alist
5558 current-prefix-arg))
5559 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5561 (error (format "Can't find the encrypt protocol %s" protocol)))
5562 (if (equal gnus-newsgroup-name "nndraft:drafts")
5563 (error "Can't encrypt the article in group nndraft:drafts."))
5564 (if (equal gnus-newsgroup-name "nndraft:queue")
5565 (error "Don't encrypt the article in group nndraft:queue."))
5566 (gnus-summary-iterate n
5568 (set-buffer gnus-summary-buffer)
5569 (let ((mail-parse-charset gnus-newsgroup-charset)
5570 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5571 (summary-buffer gnus-summary-buffer)
5573 (gnus-set-global-variables)
5574 (when (gnus-group-read-only-p)
5575 (error "The current newsgroup does not support article encrypt"))
5576 (gnus-summary-show-article t)
5578 (or (mail-header-references gnus-current-headers) ""))
5579 (set-buffer gnus-article-buffer)
5580 (let* ((buffer-read-only nil)
5582 (mapcar (lambda (field)
5583 (and (save-restriction
5584 (message-narrow-to-head)
5585 (goto-char (point-min))
5586 (search-forward field nil t))
5588 (message-narrow-to-field)
5589 (buffer-substring (point-min) (point-max))
5590 (delete-region (point-min) (point-max))
5592 '("Content-Type:" "Content-Transfer-Encoding:"
5593 "Content-Disposition:"))))
5594 (message-narrow-to-head)
5595 (message-remove-header "MIME-Version")
5596 (goto-char (point-max))
5597 (setq point (point))
5598 (insert (apply 'concat headers))
5600 (narrow-to-region point (point-max))
5601 (let ((message-options message-options))
5602 (message-options-set 'message-sender user-mail-address)
5603 (message-options-set 'message-recipients user-mail-address)
5604 (message-options-set 'message-sign-encrypt 'not)
5606 (goto-char (point-min))
5607 (insert "MIME-Version: 1.0\n")
5609 (gnus-summary-edit-article-done
5610 references nil summary-buffer t))
5611 (when gnus-keep-backlog
5612 (gnus-backlog-remove-article
5613 (car gnus-article-current) (cdr gnus-article-current)))
5615 (when (get-buffer gnus-original-article-buffer)
5616 (set-buffer gnus-original-article-buffer)
5617 (setq gnus-original-article nil)))
5618 (when gnus-use-cache
5619 (gnus-cache-update-article
5620 (car gnus-article-current) (cdr gnus-article-current))))))))
5622 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]]%)%}\n"
5623 "The following specs can be used:
5624 %t The security MIME type
5625 %i Additional info")
5627 (defvar gnus-mime-security-button-line-format-alist
5628 '((?t gnus-tmp-type ?s)
5629 (?i gnus-tmp-info ?s)))
5631 (defvar gnus-mime-security-button-map
5632 (let ((map (make-sparse-keymap)))
5633 (set-keymap-parent map gnus-article-mode-map)
5634 (define-key map gnus-mouse-2 'gnus-article-push-button)
5635 (define-key map "\r" 'gnus-article-press-button)
5638 (defvar gnus-mime-security-details-buffer nil)
5640 (defun gnus-mime-security-show-details (handle)
5641 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5644 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5645 (with-current-buffer gnus-mime-security-details-buffer
5648 (setq gnus-mime-security-details-buffer
5649 (gnus-get-buffer-create "*MIME Security Details*")))
5650 (with-current-buffer gnus-mime-security-details-buffer
5652 (pop-to-buffer gnus-mime-security-details-buffer))
5653 (gnus-message 5 "No details."))))
5655 (defun gnus-insert-mime-security-button (handle &optional displayed)
5656 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5659 (or (nth 2 (assoc protocol mm-verify-function-alist))
5660 (nth 2 (assoc protocol mm-decrypt-function-alist))
5662 (if (equal (car handle) "multipart/signed")
5663 " Signed" " Encrypted")))
5665 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5672 gnus-mime-security-button-line-format
5673 gnus-mime-security-button-line-format-alist
5674 `(local-map ,gnus-mime-security-button-map
5675 keymap ,gnus-mime-security-button-map
5676 gnus-callback gnus-mime-security-show-details
5677 article-type annotation
5680 (widget-convert-button
5683 :action 'gnus-widget-press-button
5684 :button-keymap gnus-mime-security-button-map
5686 (lambda (widget/window &optional overlay pos)
5687 ;; Needed to properly clear the message due to a bug in
5688 ;; wid-edit (XEmacs only).
5689 (if (boundp 'help-echo-owns-message)
5690 (setq help-echo-owns-message t))
5693 (aref gnus-mouse-2 0))))))
5699 (defun gnus-article-header-presentation-method (entity situation)
5700 (mime-insert-header entity)
5703 (set-alist 'mime-header-presentation-method-alist
5704 'gnus-original-article-mode
5705 #'gnus-article-header-presentation-method)
5707 (defun gnus-mime-preview-quitting-method ()
5708 (mime-preview-kill-buffer)
5709 (delete-other-windows)
5710 (gnus-article-show-summary)
5711 (gnus-summary-select-article gnus-show-all-headers t))
5713 (set-alist 'mime-preview-quitting-method-alist
5714 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
5716 (set-alist 'mime-preview-following-method-alist
5717 'gnus-original-article-mode #'gnus-following-method)
5719 (set-alist 'mime-preview-over-to-previous-method-alist
5720 'gnus-original-article-mode
5722 (if (> (point-min) 1)
5723 (gnus-article-prev-page)
5724 (gnus-article-read-summary-keys
5725 nil (gnus-character-to-event ?P)))))
5727 (set-alist 'mime-preview-over-to-next-method-alist
5728 'gnus-original-article-mode'
5730 (if (< (point-max) (buffer-size))
5731 (gnus-article-next-page)
5732 (gnus-article-read-summary-keys
5733 nil (gnus-character-to-event ?N)))))
5743 (run-hooks 'gnus-art-load-hook)
5745 ;;; gnus-art.el ends here