1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:")
144 "*All headers that start with this regexp will be hidden.
145 This variable can also be a list of regexps of headers to be ignored.
146 If `gnus-visible-headers' is non-nil, this variable will be ignored."
147 :type '(choice :custom-show nil
150 :group 'gnus-article-hiding)
152 (defcustom gnus-visible-headers
153 "^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:"
154 "*All headers that do not match this regexp will be hidden.
155 This variable can also be a list of regexp of headers to remain visible.
156 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
157 :type '(repeat :value-to-internal (lambda (widget value)
158 (custom-split-regexp-maybe value))
159 :match (lambda (widget value)
161 (widget-editable-list-match widget value)))
163 :group 'gnus-article-hiding)
165 (defcustom gnus-sorted-header-list
166 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
167 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
168 "*This variable is a list of regular expressions.
169 If it is non-nil, headers that match the regular expressions will
170 be placed first in the article buffer in the sequence specified by
172 :type '(repeat regexp)
173 :group 'gnus-article-hiding)
175 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
176 "Headers that are only to be displayed if they have interesting data.
177 Possible values in this list are:
179 'empty Headers with no content.
180 'newsgroups Newsgroup identical to Gnus group.
181 'to-address To identical to To-address.
182 'followup-to Followup-to identical to Newsgroups.
183 'reply-to Reply-to identical to From.
184 'date Date less than four days old.
185 'long-to To and/or Cc longer than 1024 characters.
186 'many-to Multiple To and/or Cc."
187 :type '(set (const :tag "Headers with no content." empty)
188 (const :tag "Newsgroups identical to Gnus group." newsgroups)
189 (const :tag "To identical to To-address." to-address)
190 (const :tag "Followup-to identical to Newsgroups." followup-to)
191 (const :tag "Reply-to identical to From." reply-to)
192 (const :tag "Date less than four days old." date)
193 (const :tag "To and/or Cc longer than 1024 characters." long-to)
194 (const :tag "Multiple To and/or Cc headers." many-to))
195 :group 'gnus-article-hiding)
197 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
198 "Regexp matching signature separator.
199 This can also be a list of regexps. In that case, it will be checked
200 from head to tail looking for a separator. Searches will be done from
201 the end of the buffer."
202 :type '(repeat string)
203 :group 'gnus-article-signature)
205 (defcustom gnus-signature-limit nil
206 "Provide a limit to what is considered a signature.
207 If it is a number, no signature may not be longer (in characters) than
208 that number. If it is a floating point number, no signature may be
209 longer (in lines) than that number. If it is a function, the function
210 will be called without any parameters, and if it returns nil, there is
211 no signature in the buffer. If it is a string, it will be used as a
212 regexp. If it matches, the text in question is not a signature."
213 :type '(choice (integer :value 200)
215 (function :value fun)
216 (regexp :value ".*"))
217 :group 'gnus-article-signature)
219 (defcustom gnus-hidden-properties '(invisible t intangible t)
220 "Property list to use for hiding text."
222 :group 'gnus-article-hiding)
224 ;; Fixme: This isn't the right thing for mixed graphical and and
225 ;; non-graphical frames in a session.
226 (defcustom gnus-article-x-face-command
227 (if (featurep 'xemacs)
228 (if (or (featurep 'xface)
230 'gnus-xmas-article-display-xface
231 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
232 (if (and (fboundp 'image-type-available-p)
233 (image-type-available-p 'xbm))
234 'gnus-article-display-xface
235 (if gnus-article-compface-xbm
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
237 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
239 "*String or function to be executed to display an X-Face header.
240 If it is a string, the command will be executed in a sub-shell
241 asynchronously. The compressed face will be piped to this command."
242 :type `(choice string
244 ,(if (featurep 'xemacs)
245 'gnus-xmas-article-display-xface
246 'gnus-article-display-xface))
249 :group 'gnus-article-washing)
251 (defcustom gnus-article-x-face-too-ugly nil
252 "Regexp matching posters whose face shouldn't be shown automatically."
253 :type '(choice regexp (const nil))
254 :group 'gnus-article-washing)
256 (defcustom gnus-article-banner-alist nil
257 "Banner alist for stripping.
259 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
261 :type '(repeat (cons symbol regexp))
262 :group 'gnus-article-washing)
264 (gnus-define-group-parameter
267 "Alist of regexps (to match group names) and banner."
268 :variable-group gnus-article-washing
270 '(choice :tag "Banner"
272 (const :tag "Remove signature" signature)
273 (symbol :tag "Item in `gnus-article-banner-alist'" none)
275 (const :tag "None" nil))
277 "If non-nil, specify how to remove `banners' from articles.
279 Symbol `signature' means to remove signatures delimited by
280 `gnus-signature-separator'. Any other symbol is used to look up a
281 regular expression to match the banner in `gnus-article-banner-alist'.
282 A string is used as a regular expression to match the banner
285 (defcustom gnus-emphasis-alist
287 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
289 '(("_" "_" underline)
292 ("_/" "/_" underline-italic)
293 ("_\\*" "\\*_" underline-bold)
294 ("\\*/" "/\\*" bold-italic)
295 ("_\\*/" "/\\*_" underline-bold-italic))))
296 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
297 2 3 gnus-emphasis-underline)
301 (format format (car spec) (cadr spec))
302 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
304 "*Alist that says how to fontify certain phrases.
305 Each item looks like this:
307 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
309 The first element is a regular expression to be matched. The second
310 is a number that says what regular expression grouping used to find
311 the entire emphasized word. The third is a number that says what
312 regexp grouping should be displayed and highlighted. The fourth
313 is the face used for highlighting."
314 :type '(repeat (list :value ("" 0 0 default)
316 (integer :tag "Match group")
317 (integer :tag "Emphasize group")
319 :group 'gnus-article-emphasis)
321 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
322 "A regexp to describe whitespace which should not be emphasized.
323 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
324 The former avoids underlining of leading and trailing whitespace,
325 and the latter avoids underlining any whitespace at all."
327 :group 'gnus-article-emphasis
330 (defface gnus-emphasis-bold '((t (:bold t)))
331 "Face used for displaying strong emphasized text (*word*)."
332 :group 'gnus-article-emphasis)
334 (defface gnus-emphasis-italic '((t (:italic t)))
335 "Face used for displaying italic emphasized text (/word/)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-underline '((t (:underline t)))
339 "Face used for displaying underlined emphasized text (_word_)."
340 :group 'gnus-article-emphasis)
342 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
343 "Face used for displaying underlined bold emphasized text (_*word*_)."
344 :group 'gnus-article-emphasis)
346 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
347 "Face used for displaying underlined italic emphasized text (_/word/_)."
348 :group 'gnus-article-emphasis)
350 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
351 "Face used for displaying bold italic emphasized text (/*word*/)."
352 :group 'gnus-article-emphasis)
354 (defface gnus-emphasis-underline-bold-italic
355 '((t (:bold t :italic t :underline t)))
356 "Face used for displaying underlined bold italic emphasized text.
357 Esample: (_/*word*/_)."
358 :group 'gnus-article-emphasis)
360 (defface gnus-emphasis-highlight-words
361 '((t (:background "black" :foreground "yellow")))
362 "Face used for displaying highlighted words."
363 :group 'gnus-article-emphasis)
365 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
366 "Format for display of Date headers in article bodies.
367 See `format-time-string' for the possible values.
369 The variable can also be function, which should return a complete Date
370 header. The function is called with one argument, the time, which can
371 be fed to `format-time-string'."
372 :type '(choice string symbol)
373 :link '(custom-manual "(gnus)Article Date")
374 :group 'gnus-article-washing)
377 (autoload 'mail-extract-address-components "mail-extr"))
379 (defcustom gnus-save-all-headers t
380 "*If non-nil, don't remove any headers before saving."
381 :group 'gnus-article-saving
384 (defcustom gnus-prompt-before-saving 'always
385 "*This variable says how much prompting is to be done when saving articles.
386 If it is nil, no prompting will be done, and the articles will be
387 saved to the default files. If this variable is `always', each and
388 every article that is saved will be preceded by a prompt, even when
389 saving large batches of articles. If this variable is neither nil not
390 `always', there the user will be prompted once for a file name for
391 each invocation of the saving commands."
392 :group 'gnus-article-saving
393 :type '(choice (item always)
394 (item :tag "never" nil)
395 (sexp :tag "once" :format "%t\n" :value t)))
397 (defcustom gnus-saved-headers gnus-visible-headers
398 "Headers to keep if `gnus-save-all-headers' is nil.
399 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
400 If that variable is nil, however, all headers that match this regexp
401 will be kept while the rest will be deleted before saving."
402 :group 'gnus-article-saving
405 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
406 "A function to save articles in your favourite format.
407 The function must be interactively callable (in other words, it must
408 be an Emacs command).
410 Gnus provides the following functions:
412 * gnus-summary-save-in-rmail (Rmail format)
413 * gnus-summary-save-in-mail (Unix mail format)
414 * gnus-summary-save-in-folder (MH folder)
415 * gnus-summary-save-in-file (article format)
416 * gnus-summary-save-body-in-file (article body)
417 * gnus-summary-save-in-vm (use VM's folder format)
418 * gnus-summary-write-to-file (article format -- overwrite)."
419 :group 'gnus-article-saving
420 :type '(radio (function-item gnus-summary-save-in-rmail)
421 (function-item gnus-summary-save-in-mail)
422 (function-item gnus-summary-save-in-folder)
423 (function-item gnus-summary-save-in-file)
424 (function-item gnus-summary-save-body-in-file)
425 (function-item gnus-summary-save-in-vm)
426 (function-item gnus-summary-write-to-file)))
428 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
429 "A function generating a file name to save articles in Rmail format.
430 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
431 :group 'gnus-article-saving
434 (defcustom gnus-mail-save-name 'gnus-plain-save-name
435 "A function generating a file name to save articles in Unix mail format.
436 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
437 :group 'gnus-article-saving
440 (defcustom gnus-folder-save-name 'gnus-folder-save-name
441 "A function generating a file name to save articles in MH folder.
442 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
443 :group 'gnus-article-saving
446 (defcustom gnus-file-save-name 'gnus-numeric-save-name
447 "A function generating a file name to save articles in article format.
448 The function is called with NEWSGROUP, HEADERS, and optional
450 :group 'gnus-article-saving
453 (defcustom gnus-split-methods
454 '((gnus-article-archive-name)
455 (gnus-article-nndoc-name))
456 "*Variable used to suggest where articles are to be saved.
457 For instance, if you would like to save articles related to Gnus in
458 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
459 you could set this variable to something like:
461 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
462 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
464 This variable is an alist where the where the key is the match and the
465 value is a list of possible files to save in if the match is non-nil.
467 If the match is a string, it is used as a regexp match on the
468 article. If the match is a symbol, that symbol will be funcalled
469 from the buffer of the article to be saved with the newsgroup as the
470 parameter. If it is a list, it will be evaled in the same buffer.
472 If this form or function returns a string, this string will be used as
473 a possible file name; and if it returns a non-nil list, that list will
474 be used as possible file names."
475 :group 'gnus-article-saving
476 :type '(repeat (choice (list :value (fun) function)
477 (cons :value ("" "") regexp (repeat string))
480 (defcustom gnus-page-delimiter "^\^L"
481 "*Regexp describing what to use as article page delimiters.
482 The default value is \"^\^L\", which is a form linefeed at the
483 beginning of a line."
485 :group 'gnus-article-various)
487 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
488 "*The format specification for the article mode line.
489 See `gnus-summary-mode-line-format' for a closer description.
491 The following additional specs are available:
493 %w The article washing status.
494 %m The number of MIME parts in the article."
496 :group 'gnus-article-various)
498 (defcustom gnus-article-mode-hook nil
499 "*A hook for Gnus article mode."
501 :group 'gnus-article-various)
503 (when (featurep 'xemacs)
504 ;; Extracted from gnus-xmas-define in order to preserve user settings
505 (when (fboundp 'turn-off-scroll-in-place)
506 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
507 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
508 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
510 (defcustom gnus-article-menu-hook nil
511 "*Hook run after the creation of the article mode menu."
513 :group 'gnus-article-various)
515 (defcustom gnus-article-prepare-hook nil
516 "*A hook called after an article has been prepared in the article buffer."
518 :group 'gnus-article-various)
520 (defcustom gnus-article-hide-pgp-hook nil
521 "*A hook called after successfully hiding a PGP signature."
523 :group 'gnus-article-various)
525 (defcustom gnus-article-button-face 'bold
526 "Face used for highlighting buttons in the article buffer.
528 An article button is a piece of text that you can activate by pressing
529 `RET' or `mouse-2' above it."
531 :group 'gnus-article-buttons)
533 (defcustom gnus-article-mouse-face 'highlight
534 "Face used for mouse highlighting in the article buffer.
536 Article buttons will be displayed in this face when the cursor is
539 :group 'gnus-article-buttons)
541 (defcustom gnus-signature-face 'gnus-signature-face
542 "Face used for highlighting a signature in the article buffer.
543 Obsolete; use the face `gnus-signature-face' for customizations instead."
545 :group 'gnus-article-highlight
546 :group 'gnus-article-signature)
548 (defface gnus-signature-face
551 "Face used for highlighting a signature in the article buffer."
552 :group 'gnus-article-highlight
553 :group 'gnus-article-signature)
555 (defface gnus-header-from-face
558 (:foreground "spring green"))
561 (:foreground "red3"))
564 "Face used for displaying from headers."
565 :group 'gnus-article-headers
566 :group 'gnus-article-highlight)
568 (defface gnus-header-subject-face
571 (:foreground "SeaGreen3"))
574 (:foreground "red4"))
576 (:bold t :italic t)))
577 "Face used for displaying subject headers."
578 :group 'gnus-article-headers
579 :group 'gnus-article-highlight)
581 (defface gnus-header-newsgroups-face
584 (:foreground "yellow" :italic t))
587 (:foreground "MidnightBlue" :italic t))
590 "Face used for displaying newsgroups headers."
591 :group 'gnus-article-headers
592 :group 'gnus-article-highlight)
594 (defface gnus-header-name-face
597 (:foreground "SeaGreen"))
600 (:foreground "maroon"))
603 "Face used for displaying header names."
604 :group 'gnus-article-headers
605 :group 'gnus-article-highlight)
607 (defface gnus-header-content-face
610 (:foreground "forest green" :italic t))
613 (:foreground "indianred4" :italic t))
615 (:italic t))) "Face used for displaying header content."
616 :group 'gnus-article-headers
617 :group 'gnus-article-highlight)
619 (defcustom gnus-header-face-alist
620 '(("From" nil gnus-header-from-face)
621 ("Subject" nil gnus-header-subject-face)
622 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
623 ("" gnus-header-name-face gnus-header-content-face))
624 "*Controls highlighting of article header.
626 An alist of the form (HEADER NAME CONTENT).
628 HEADER is a regular expression which should match the name of an
629 header header and NAME and CONTENT are either face names or nil.
631 The name of each header field will be displayed using the face
632 specified by the first element in the list where HEADER match the
633 header name and NAME is non-nil. Similarly, the content will be
634 displayed by the first non-nil matching CONTENT face."
635 :group 'gnus-article-headers
636 :group 'gnus-article-highlight
637 :type '(repeat (list (regexp :tag "Header")
639 (item :tag "skip" nil)
640 (face :value default))
641 (choice :tag "Content"
642 (item :tag "skip" nil)
643 (face :value default)))))
645 (defcustom gnus-article-decode-hook
646 '(article-decode-charset article-decode-encoded-words
647 article-decode-group-name)
648 "*Hook run to decode charsets in articles."
649 :group 'gnus-article-headers
652 (defcustom gnus-display-mime-function 'gnus-display-mime
653 "Function to display MIME articles."
654 :group 'gnus-article-mime
657 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
658 "Function used to decode headers.")
660 (defvar gnus-article-dumbquotes-map
679 "Table for MS-to-Latin1 translation.")
681 (defcustom gnus-ignored-mime-types nil
682 "List of MIME types that should be ignored by Gnus."
684 :group 'gnus-article-mime
685 :type '(repeat regexp))
687 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
688 "List of MIME types that should not be given buttons when rendered inline.
689 See also `gnus-buttonized-mime-types' which may override this variable."
691 :group 'gnus-article-mime
692 :type '(repeat regexp))
694 (defcustom gnus-buttonized-mime-types nil
695 "List of MIME types that should be given buttons when rendered inline.
696 If set, this variable overrides `gnus-unbuttonized-mime-types'.
697 To see e.g. security buttons you could set this to
698 `(\"multipart/signed\")'."
700 :group 'gnus-article-mime
701 :type '(repeat regexp))
703 (defcustom gnus-article-mime-part-function nil
704 "Function called with a MIME handle as the argument.
705 This is meant for people who want to do something automatic based
706 on parts -- for instance, adding Vcard info to a database."
707 :group 'gnus-article-mime
710 (defcustom gnus-mime-multipart-functions nil
711 "An alist of MIME types to functions to display them."
713 :group 'gnus-article-mime
716 (defcustom gnus-article-date-lapsed-new-header nil
717 "Whether the X-Sent and Date headers can coexist.
718 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
719 either replace the old \"Date:\" header (if this variable is nil), or
720 be added below it (otherwise)."
722 :group 'gnus-article-headers
725 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
726 "Function called with a MIME handle as the argument.
727 This is meant for people who want to view first matched part.
728 For `undisplayed-alternative' (default), the first undisplayed
729 part or alternative part is used. For `undisplayed', the first
730 undisplayed part is used. For a function, the first part which
731 the function return `t' is used. For `nil', the first part is
734 :group 'gnus-article-mime
736 (item :tag "first" :value nil)
737 (item :tag "undisplayed" :value undisplayed)
738 (item :tag "undisplayed or alternative"
739 :value undisplayed-alternative)
742 (defcustom gnus-mime-action-alist
743 '(("save to file" . gnus-mime-save-part)
744 ("save and strip" . gnus-mime-save-part-and-strip)
745 ("display as text" . gnus-mime-inline-part)
746 ("view the part" . gnus-mime-view-part)
747 ("pipe to command" . gnus-mime-pipe-part)
748 ("toggle display" . gnus-article-press-button)
749 ("toggle display" . gnus-article-view-part-as-charset)
750 ("view as type" . gnus-mime-view-part-as-type)
751 ("internalize type" . gnus-mime-internalize-part)
752 ("externalize type" . gnus-mime-externalize-part))
753 "An alist of actions that run on the MIME attachment."
754 :group 'gnus-article-mime
755 :type '(repeat (cons (string :tag "name")
758 (defcustom gnus-mime-action-alist
759 '(("save to file" . gnus-mime-save-part)
760 ("display as text" . gnus-mime-inline-part)
761 ("view the part" . gnus-mime-view-part)
762 ("pipe to command" . gnus-mime-pipe-part)
763 ("toggle display" . gnus-article-press-button)
764 ("view as type" . gnus-mime-view-part-as-type)
765 ("internalize type" . gnus-mime-internalize-part)
766 ("externalize type" . gnus-mime-externalize-part))
767 "An alist of actions that run on the MIME attachment."
769 :group 'gnus-article-mime
770 :type '(repeat (cons (string :tag "name")
774 ;;; The treatment variables
777 (defvar gnus-part-display-hook nil
778 "Hook called on parts that are to receive treatment.")
780 (defvar gnus-article-treat-custom
781 '(choice (const :tag "Off" nil)
783 (const :tag "Header" head)
784 (const :tag "Last" last)
785 (integer :tag "Less")
786 (repeat :tag "Groups" regexp)
787 (sexp :tag "Predicate")))
789 (defvar gnus-article-treat-head-custom
790 '(choice (const :tag "Off" nil)
791 (const :tag "Header" head)))
793 (defvar gnus-article-treat-types '("text/plain")
796 (defvar gnus-inhibit-treatment nil
797 "Whether to inhibit treatment.")
799 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
800 "Highlight the signature.
801 Valid values are nil, t, `head', `last', an integer or a predicate.
802 See Info node `(gnus)Customizing Articles'."
803 :group 'gnus-article-treat
804 :type gnus-article-treat-custom)
805 (put 'gnus-treat-highlight-signature 'highlight t)
807 (defcustom gnus-treat-buttonize 100000
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)
813 (put 'gnus-treat-buttonize 'highlight t)
815 (defcustom gnus-treat-buttonize-head 'head
816 "Add buttons to the head.
817 Valid values are nil, t, `head', `last', an integer or a predicate.
818 See the manual for details."
819 :group 'gnus-article-treat
820 :type gnus-article-treat-head-custom)
821 (put 'gnus-treat-buttonize-head 'highlight t)
823 (defcustom gnus-treat-emphasize
824 (and (or window-system
826 (>= (string-to-number emacs-version) 21))
829 Valid values are nil, t, `head', `last', an integer or a predicate.
830 See the manual for details."
831 :group 'gnus-article-treat
832 :type gnus-article-treat-custom)
833 (put 'gnus-treat-emphasize 'highlight t)
835 (defcustom gnus-treat-strip-cr nil
836 "Remove carriage returns.
837 Valid values are nil, t, `head', `last', an integer or a predicate.
838 See the manual for details."
839 :group 'gnus-article-treat
840 :type gnus-article-treat-custom)
842 (defcustom gnus-treat-leading-whitespace nil
843 "Remove leading whitespace in headers.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See the manual for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
849 (defcustom gnus-treat-hide-headers 'head
851 Valid values are nil, t, `head', `last', an integer or a predicate.
852 See the manual for details."
853 :group 'gnus-article-treat
854 :type gnus-article-treat-head-custom)
856 (defcustom gnus-treat-hide-boring-headers nil
857 "Hide boring headers.
858 Valid values are nil, t, `head', `last', an integer or a predicate.
859 See the manual for details."
860 :group 'gnus-article-treat
861 :type gnus-article-treat-head-custom)
863 (defcustom gnus-treat-hide-signature nil
865 Valid values are nil, t, `head', `last', an integer or a predicate.
866 See the manual for details."
867 :group 'gnus-article-treat
868 :type gnus-article-treat-custom)
870 (defcustom gnus-treat-fill-article nil
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See the manual for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-hide-citation nil
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See the manual for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-hide-citation-maybe nil
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See the manual for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 (defcustom gnus-treat-strip-list-identifiers 'head
892 "Strip list identifiers from `gnus-list-identifiers`.
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See the manual for details."
896 :group 'gnus-article-treat
897 :type gnus-article-treat-custom)
899 (defcustom gnus-treat-strip-pgp t
900 "Strip PGP signatures.
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See the manual for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-strip-pem nil
907 "Strip PEM signatures.
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See the manual for details."
910 :group 'gnus-article-treat
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-strip-banner t
914 "Strip banners from articles.
915 The banner to be stripped is specified in the `banner' group parameter.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See the manual for details."
918 :group 'gnus-article-treat
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-highlight-headers 'head
922 "Highlight the headers.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See the manual for details."
925 :group 'gnus-article-treat
926 :type gnus-article-treat-head-custom)
927 (put 'gnus-treat-highlight-headers 'highlight t)
929 (defcustom gnus-treat-highlight-citation t
930 "Highlight cited text.
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See the manual for details."
933 :group 'gnus-article-treat
934 :type gnus-article-treat-custom)
935 (put 'gnus-treat-highlight-citation 'highlight t)
937 (defcustom gnus-treat-date-ut nil
938 "Display the Date in UT (GMT).
939 Valid values are nil, t, `head', `last', an integer or a predicate.
940 See the manual for details."
941 :group 'gnus-article-treat
942 :type gnus-article-treat-head-custom)
944 (defcustom gnus-treat-date-local nil
945 "Display the Date in the local timezone.
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See the manual for details."
948 :group 'gnus-article-treat
949 :type gnus-article-treat-head-custom)
951 (defcustom gnus-treat-date-english nil
952 "Display the Date in a format that can be read aloud in English.
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See the manual for details."
955 :group 'gnus-article-treat
956 :type gnus-article-treat-head-custom)
958 (defcustom gnus-treat-date-lapsed nil
959 "Display the Date header in a way that says how much time has elapsed.
960 Valid values are nil, t, `head', `last', an integer or a predicate.
961 See the manual for details."
962 :group 'gnus-article-treat
963 :type gnus-article-treat-head-custom)
965 (defcustom gnus-treat-date-original nil
966 "Display the date in the original timezone.
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See the manual for details."
969 :group 'gnus-article-treat
970 :type gnus-article-treat-head-custom)
972 (defcustom gnus-treat-date-iso8601 nil
973 "Display the date in the ISO8601 format.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See the manual for details."
977 :group 'gnus-article-treat
978 :type gnus-article-treat-head-custom)
980 (defcustom gnus-treat-date-user-defined nil
981 "Display the date in a user-defined format.
982 The format is defined by the `gnus-article-time-format' variable.
983 Valid values are nil, t, `head', `last', an integer or a predicate.
984 See the manual for details."
985 :group 'gnus-article-treat
986 :type gnus-article-treat-head-custom)
988 (defcustom gnus-treat-strip-headers-in-body t
989 "Strip the X-No-Archive header line from the beginning of the body.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See the manual for details."
993 :group 'gnus-article-treat
994 :type gnus-article-treat-custom)
996 (defcustom gnus-treat-strip-trailing-blank-lines nil
997 "Strip trailing blank lines.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See the manual for details."
1000 :group 'gnus-article-treat
1001 :type gnus-article-treat-custom)
1003 (defcustom gnus-treat-strip-leading-blank-lines nil
1004 "Strip leading blank lines.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See the manual for details."
1007 :group 'gnus-article-treat
1008 :type gnus-article-treat-custom)
1010 (defcustom gnus-treat-strip-multiple-blank-lines nil
1011 "Strip multiple blank lines.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See the manual for details."
1014 :group 'gnus-article-treat
1015 :type gnus-article-treat-custom)
1017 (defcustom gnus-treat-overstrike t
1018 "Treat overstrike highlighting.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See the manual for details."
1021 :group 'gnus-article-treat
1022 :type gnus-article-treat-custom)
1023 (put 'gnus-treat-overstrike 'highlight t)
1025 (defcustom gnus-treat-display-xface
1026 (and (or (and (fboundp 'image-type-available-p)
1027 (image-type-available-p 'xbm)
1028 (string-match "^0x" (shell-command-to-string "uncompface")))
1029 (and (featurep 'xemacs) (featurep 'xface)))
1031 "Display X-Face headers.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See the manual for details."
1034 :group 'gnus-article-treat
1036 :type gnus-article-treat-head-custom)
1037 (put 'gnus-treat-display-xface 'highlight t)
1039 (defcustom gnus-treat-display-smileys
1040 (if (or (and (featurep 'xemacs)
1042 (and (fboundp 'image-type-available-p)
1043 (image-type-available-p 'pbm)))
1046 Valid values are nil, t, `head', `last', an integer or a predicate.
1047 See the manual for details."
1048 :group 'gnus-article-treat
1050 :type gnus-article-treat-custom)
1051 (put 'gnus-treat-display-smileys 'highlight t)
1053 (defcustom gnus-treat-display-picons
1054 (if (or (and (featurep 'xemacs)
1056 (and (fboundp 'image-type-available-p)
1057 (image-type-available-p 'pbm)))
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See the manual for details."
1062 :group 'gnus-article-treat
1063 :type gnus-article-treat-head-custom)
1064 (put 'gnus-treat-display-picons 'highlight t)
1066 (defcustom gnus-treat-capitalize-sentences nil
1067 "Capitalize sentence-starting words.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See the manual for details."
1071 :group 'gnus-article-treat
1072 :type gnus-article-treat-custom)
1074 (defcustom gnus-treat-fill-long-lines nil
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See the manual for details."
1078 :group 'gnus-article-treat
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-play-sounds nil
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See the manual for details."
1086 :group 'gnus-article-treat
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-translate nil
1090 "Translate articles from one language to another.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See the manual for details."
1094 :group 'gnus-article-treat
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-x-pgp-sig nil
1099 To automatically treat X-PGP-Sig, set it to head.
1100 Valid values are nil, t, `head', `last', an integer or a predicate.
1101 See the manual for details."
1102 :group 'gnus-article-treat
1103 :group 'mime-security
1104 :type gnus-article-treat-custom)
1106 (defvar gnus-article-encrypt-protocol-alist
1107 '(("PGP" . mml2015-self-encrypt)))
1109 ;; Set to nil if more than one protocol added to
1110 ;; gnus-article-encrypt-protocol-alist.
1111 (defcustom gnus-article-encrypt-protocol "PGP"
1112 "The protocol used for encrypt articles.
1113 It is a string, such as \"PGP\". If nil, ask user."
1115 :group 'mime-security)
1117 ;;; Internal variables
1119 (defvar gnus-english-month-names
1120 '("January" "February" "March" "April" "May" "June" "July" "August"
1121 "September" "October" "November" "December"))
1123 (defvar article-goto-body-goes-to-point-min-p nil)
1124 (defvar gnus-article-wash-types nil)
1125 (defvar gnus-article-emphasis-alist nil)
1127 (defvar gnus-article-mime-handle-alist-1 nil)
1128 (defvar gnus-treatment-function-alist
1129 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1130 (gnus-treat-strip-banner gnus-article-strip-banner)
1131 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1132 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1133 (gnus-treat-buttonize gnus-article-add-buttons)
1134 (gnus-treat-fill-article gnus-article-fill-cited-article)
1135 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1136 (gnus-treat-strip-cr gnus-article-remove-cr)
1137 (gnus-treat-display-xface gnus-article-display-x-face)
1138 (gnus-treat-date-ut gnus-article-date-ut)
1139 (gnus-treat-date-local gnus-article-date-local)
1140 (gnus-treat-date-english gnus-article-date-english)
1141 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1142 (gnus-treat-date-original gnus-article-date-original)
1143 (gnus-treat-date-user-defined gnus-article-date-user)
1144 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1145 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1146 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1147 (gnus-treat-hide-signature gnus-article-hide-signature)
1148 (gnus-treat-hide-citation gnus-article-hide-citation)
1149 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1150 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1151 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1152 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1153 (gnus-treat-strip-pem gnus-article-hide-pem)
1154 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1155 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1156 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1157 (gnus-treat-strip-trailing-blank-lines
1158 gnus-article-remove-trailing-blank-lines)
1159 (gnus-treat-strip-leading-blank-lines
1160 gnus-article-strip-leading-blank-lines)
1161 (gnus-treat-strip-multiple-blank-lines
1162 gnus-article-strip-multiple-blank-lines)
1163 (gnus-treat-overstrike gnus-article-treat-overstrike)
1164 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1165 (gnus-treat-display-smileys gnus-smiley-display)
1166 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1167 (gnus-treat-display-picons gnus-article-display-picons)
1168 (gnus-treat-emphasize gnus-article-emphasize)
1169 (gnus-treat-play-sounds gnus-earcon-display)))
1171 (defvar gnus-article-mime-handle-alist nil)
1172 (defvar article-lapsed-timer nil)
1173 (defvar gnus-article-current-summary nil)
1175 (defvar gnus-article-mode-syntax-table
1176 (let ((table (copy-syntax-table text-mode-syntax-table)))
1177 ;; This causes the citation match run O(2^n).
1178 ;; (modify-syntax-entry ?- "w" table)
1179 (modify-syntax-entry ?> ")" table)
1180 (modify-syntax-entry ?< "(" table)
1182 "Syntax table used in article mode buffers.
1183 Initialized from `text-mode-syntax-table.")
1185 (defvar gnus-save-article-buffer nil)
1187 (defvar gnus-article-mode-line-format-alist
1188 (nconc '((?w (gnus-article-wash-status) ?s)
1189 (?m (gnus-article-mime-part-status) ?s))
1190 gnus-summary-mode-line-format-alist))
1192 (defvar gnus-number-of-articles-to-be-saved nil)
1194 (defvar gnus-inhibit-hiding nil)
1196 (defsubst gnus-article-hide-text (b e props)
1197 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1198 (gnus-add-text-properties-when 'article-type nil b e props)
1199 (when (memq 'intangible props)
1201 (max (1- b) (point-min))
1202 b 'intangible (cddr (memq 'intangible props)))))
1204 (defsubst gnus-article-unhide-text (b e)
1205 "Remove hidden text properties from region between B and E."
1206 (remove-text-properties b e gnus-hidden-properties)
1207 (when (memq 'intangible gnus-hidden-properties)
1208 (put-text-property (max (1- b) (point-min))
1209 b 'intangible nil)))
1211 (defun gnus-article-hide-text-type (b e type)
1212 "Hide text of TYPE between B and E."
1213 (push type gnus-article-wash-types)
1214 (gnus-article-hide-text
1215 b e (cons 'article-type (cons type gnus-hidden-properties))))
1217 (defun gnus-article-unhide-text-type (b e type)
1218 "Unhide text of TYPE between B and E."
1219 (setq gnus-article-wash-types
1220 (delq type gnus-article-wash-types))
1221 (remove-text-properties
1222 b e (cons 'article-type (cons type gnus-hidden-properties)))
1223 (when (memq 'intangible gnus-hidden-properties)
1224 (put-text-property (max (1- b) (point-min))
1225 b 'intangible nil)))
1227 (defun gnus-article-hide-text-of-type (type)
1228 "Hide text of TYPE in the current buffer."
1230 (let ((b (point-min))
1232 (while (setq b (text-property-any b e 'article-type type))
1233 (add-text-properties b (incf b) gnus-hidden-properties)))))
1235 (defun gnus-article-delete-text-of-type (type)
1236 "Delete text of TYPE in the current buffer."
1238 (let ((b (point-min)))
1239 (while (setq b (text-property-any b (point-max) 'article-type type))
1241 b (or (text-property-not-all b (point-max) 'article-type type)
1244 (defun gnus-article-delete-invisible-text ()
1245 "Delete all invisible text in the current buffer."
1247 (let ((b (point-min)))
1248 (while (setq b (text-property-any b (point-max) 'invisible t))
1250 b (or (text-property-not-all b (point-max) 'invisible t)
1253 (defun gnus-article-text-type-exists-p (type)
1254 "Say whether any text of type TYPE exists in the buffer."
1255 (text-property-any (point-min) (point-max) 'article-type type))
1257 (defsubst gnus-article-header-rank ()
1258 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1259 (let ((list gnus-sorted-header-list)
1262 (when (looking-at (car list))
1264 (setq list (cdr list))
1268 (defun article-hide-headers (&optional arg delete)
1269 "Hide unwanted headers and possibly sort them as well."
1271 ;; This function might be inhibited.
1272 (unless gnus-inhibit-hiding
1275 (let ((buffer-read-only nil)
1276 (case-fold-search t)
1277 (max (1+ (length gnus-sorted-header-list)))
1278 (ignored (when (not gnus-visible-headers)
1279 (cond ((stringp gnus-ignored-headers)
1280 gnus-ignored-headers)
1281 ((listp gnus-ignored-headers)
1282 (mapconcat 'identity gnus-ignored-headers
1285 (cond ((stringp gnus-visible-headers)
1286 gnus-visible-headers)
1287 ((and gnus-visible-headers
1288 (listp gnus-visible-headers))
1289 (mapconcat 'identity gnus-visible-headers "\\|"))))
1290 (inhibit-point-motion-hooks t)
1292 ;; First we narrow to just the headers.
1293 (article-narrow-to-head)
1294 ;; Hide any "From " lines at the beginning of (mail) articles.
1295 (while (looking-at "From ")
1298 (delete-region (point-min) (point)))
1299 ;; Then treat the rest of the header lines.
1300 ;; Then we use the two regular expressions
1301 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1302 ;; select which header lines is to remain visible in the
1304 (while (re-search-forward "^[^ \t:]*:" nil t)
1306 ;; Mark the rank of the header.
1308 (point) (1+ (point)) 'message-rank
1309 (if (or (and visible (looking-at visible))
1311 (not (looking-at ignored))))
1312 (gnus-article-header-rank)
1315 (message-sort-headers-1)
1316 (when (setq beg (text-property-any
1317 (point-min) (point-max) 'message-rank (+ 2 max)))
1318 ;; We delete the unwanted headers.
1319 (push 'headers gnus-article-wash-types)
1320 (add-text-properties (point-min) (+ 5 (point-min))
1321 '(article-type headers dummy-invisible t))
1322 (delete-region beg (point-max))))))))
1324 (defun article-hide-boring-headers (&optional arg)
1325 "Toggle hiding of headers that aren't very interesting.
1326 If given a negative prefix, always show; if given a positive prefix,
1328 (interactive (gnus-article-hidden-arg))
1329 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1330 (not gnus-show-all-headers))
1333 (let ((buffer-read-only nil)
1334 (list gnus-boring-article-headers)
1335 (inhibit-point-motion-hooks t)
1337 (article-narrow-to-head)
1339 (setq elem (pop list))
1340 (goto-char (point-min))
1342 ;; Hide empty headers.
1344 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1346 (gnus-article-hide-text-type
1347 (progn (beginning-of-line) (point))
1350 (if (re-search-forward "^[^ \t]" nil t)
1354 ;; Hide boring Newsgroups header.
1355 ((eq elem 'newsgroups)
1356 (when (gnus-string-equal
1357 (gnus-fetch-field "newsgroups")
1358 (gnus-group-real-name
1359 (if (boundp 'gnus-newsgroup-name)
1362 (gnus-article-hide-header "newsgroups")))
1363 ((eq elem 'to-address)
1364 (let ((to (message-fetch-field "to"))
1366 (gnus-parameter-to-address
1367 (if (boundp 'gnus-newsgroup-name)
1368 gnus-newsgroup-name ""))))
1369 (when (and to to-address
1372 ;; only one address in To
1373 (nth 1 (mail-extract-address-components to))
1375 (gnus-article-hide-header "to"))))
1376 ((eq elem 'followup-to)
1377 (when (gnus-string-equal
1378 (message-fetch-field "followup-to")
1379 (message-fetch-field "newsgroups"))
1380 (gnus-article-hide-header "followup-to")))
1381 ((eq elem 'reply-to)
1382 (let ((from (message-fetch-field "from"))
1383 (reply-to (message-fetch-field "reply-to")))
1388 (nth 1 (mail-extract-address-components from))
1389 (nth 1 (mail-extract-address-components reply-to)))))
1390 (gnus-article-hide-header "reply-to"))))
1392 (let ((date (message-fetch-field "date")))
1394 (< (days-between (current-time-string) date)
1396 (gnus-article-hide-header "date"))))
1398 (let ((to (message-fetch-field "to"))
1399 (cc (message-fetch-field "cc")))
1400 (when (> (length to) 1024)
1401 (gnus-article-hide-header "to"))
1402 (when (> (length cc) 1024)
1403 (gnus-article-hide-header "cc"))))
1407 (goto-char (point-min))
1408 (while (re-search-forward "^to:" nil t)
1409 (setq to-count (1+ to-count)))
1410 (when (> to-count 1)
1411 (while (> to-count 0)
1412 (goto-char (point-min))
1414 (re-search-forward "^to:" nil nil to-count)
1416 (narrow-to-region (point) (point-max))
1417 (gnus-article-hide-header "to"))
1418 (setq to-count (1- to-count))))
1419 (goto-char (point-min))
1420 (while (re-search-forward "^cc:" nil t)
1421 (setq cc-count (1+ cc-count)))
1422 (when (> cc-count 1)
1423 (while (> cc-count 0)
1424 (goto-char (point-min))
1426 (re-search-forward "^cc:" nil nil cc-count)
1428 (narrow-to-region (point) (point-max))
1429 (gnus-article-hide-header "cc"))
1430 (setq cc-count (1- cc-count)))))))))))))
1432 (defun gnus-article-hide-header (header)
1434 (goto-char (point-min))
1435 (when (re-search-forward (concat "^" header ":") nil t)
1436 (gnus-article-hide-text-type
1437 (progn (beginning-of-line) (point))
1440 (if (re-search-forward "^[^ \t]" nil t)
1445 (defvar gnus-article-normalized-header-length 40
1446 "Length of normalized headers.")
1448 (defun article-normalize-headers ()
1449 "Make all header lines 40 characters long."
1451 (let ((buffer-read-only nil)
1455 (article-narrow-to-head)
1458 ((< (setq column (- (gnus-point-at-eol) (point)))
1459 gnus-article-normalized-header-length)
1461 (insert (make-string
1462 (- gnus-article-normalized-header-length column)
1464 ((> column gnus-article-normalized-header-length)
1465 (gnus-put-text-property
1467 (forward-char gnus-article-normalized-header-length)
1474 (forward-line 1))))))
1476 (defun article-treat-dumbquotes ()
1477 "Translate M****s*** sm*rtq**t*s into proper text.
1478 Note that this function guesses whether a character is a sm*rtq**t* or
1479 not, so it should only be used interactively.
1481 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1482 in an attempt to provide more quoting characters. If you see
1483 something like \\222 or \\264 where you're expecting some kind of
1484 apostrophe or quotation mark, then try this wash."
1486 (article-translate-strings gnus-article-dumbquotes-map))
1488 (defun article-translate-characters (from to)
1489 "Translate all characters in the body of the article according to FROM and TO.
1490 FROM is a string of characters to translate from; to is a string of
1491 characters to translate to."
1493 (when (article-goto-body)
1494 (let ((buffer-read-only nil)
1495 (x (make-string 225 ?x))
1497 (while (< (incf i) (length x))
1500 (while (< i (length from))
1501 (aset x (aref from i) (aref to i))
1503 (translate-region (point) (point-max) x)))))
1505 (defun article-translate-strings (map)
1506 "Translate all string in the body of the article according to MAP.
1507 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1509 (when (article-goto-body)
1510 (let ((buffer-read-only nil)
1512 (while (setq elem (pop map))
1514 (while (search-forward (car elem) nil t)
1515 (replace-match (cadr elem)))))))))
1517 (defun article-treat-overstrike ()
1518 "Translate overstrikes into bold text."
1521 (when (article-goto-body)
1522 (let ((buffer-read-only nil))
1523 (while (search-forward "\b" nil t)
1524 (let ((next (char-after))
1525 (previous (char-after (- (point) 2))))
1526 ;; We do the boldification/underlining by hiding the
1527 ;; overstrikes and putting the proper text property
1531 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1532 (put-text-property (point) (1+ (point)) 'face 'bold))
1534 (gnus-article-hide-text-type
1535 (1- (point)) (1+ (point)) 'overstrike)
1537 (- (point) 2) (1- (point)) 'face 'underline))
1539 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1541 (point) (1+ (point)) 'face 'underline)))))))))
1543 (defun article-fill-long-lines ()
1544 "Fill lines that are wider than the window width."
1547 (let ((buffer-read-only nil)
1548 (width (window-width (get-buffer-window (current-buffer)))))
1551 (let ((adaptive-fill-mode nil)) ;Why? -sm
1554 (when (>= (current-column) (min fill-column width))
1555 (narrow-to-region (point) (gnus-point-at-bol))
1556 (fill-paragraph nil)
1557 (goto-char (point-max))
1559 (forward-line 1)))))))
1561 (defun article-capitalize-sentences ()
1562 "Capitalize the first word in each sentence."
1565 (let ((buffer-read-only nil)
1566 (paragraph-start "^[\n\^L]"))
1570 (forward-sentence)))))
1572 (defun article-remove-cr ()
1573 "Remove trailing CRs and then translate remaining CRs into LFs."
1576 (let ((buffer-read-only nil))
1577 (goto-char (point-min))
1578 (while (re-search-forward "\r+$" nil t)
1579 (replace-match "" t t))
1580 (goto-char (point-min))
1581 (while (search-forward "\r" nil t)
1582 (replace-match "\n" t t)))))
1584 (defun article-remove-trailing-blank-lines ()
1585 "Remove all trailing blank lines from the article."
1588 (let ((buffer-read-only nil))
1589 (goto-char (point-max))
1593 (while (and (not (bobp))
1594 (looking-at "^[ \t]*$")
1595 (not (gnus-annotation-in-region-p
1596 (point) (gnus-point-at-eol))))
1601 (defun article-display-x-face (&optional force)
1602 "Look for an X-Face header and display it if present."
1603 (interactive (list 'force))
1605 ;; Delete the old process, if any.
1606 (when (process-status "article-x-face")
1607 (delete-process "article-x-face"))
1608 (let ((inhibit-point-motion-hooks t)
1610 (case-fold-search t)
1613 (article-narrow-to-head)
1614 (when (and buffer-read-only ;; When type `W f'
1616 (goto-char (point-min))
1617 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1618 (gnus-buffer-live-p gnus-original-article-buffer))
1619 (with-current-buffer gnus-original-article-buffer
1621 (article-narrow-to-head)
1622 (while (re-search-forward "^X-Face:" nil t)
1628 (1- (re-search-forward
1629 "^\\($\\|[^ \t]\\)" nil t))))))))
1631 (let (point start bface eface buffer-read-only)
1632 (goto-char (point-max))
1634 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1635 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1636 (goto-char (point-max))
1637 (setq point (point))
1640 (while (looking-at "\\([^:]+\\): *")
1641 (put-text-property (match-beginning 1) (1+ (match-end 1))
1643 (setq start (match-end 0))
1645 (while (looking-at "[\t ]")
1647 (put-text-property start (point)
1649 (goto-char (point-min))
1650 (setq from (message-fetch-field "from"))
1651 (goto-char (point-min))
1652 (while (and gnus-article-x-face-command
1655 ;; Check whether this face is censored.
1656 (not gnus-article-x-face-too-ugly)
1657 (and gnus-article-x-face-too-ugly from
1658 (not (string-match gnus-article-x-face-too-ugly
1660 ;; Has to be present.
1661 (re-search-forward "^X-Face:[\t ]*" nil t))
1662 ;; This used to try to do multiple faces (`while' instead of
1663 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1664 ;; work (b) it can crash some versions of Emacs (c) are
1665 ;; multiple faces really something to encourage?
1666 (when (stringp gnus-article-x-face-command)
1668 ;; We now have the area of the buffer where the X-Face is stored.
1671 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))
1673 ;; We display the face.
1674 (if (symbolp gnus-article-x-face-command)
1675 ;; The command is a lisp function, so we call it.
1676 (if (gnus-functionp gnus-article-x-face-command)
1677 (funcall gnus-article-x-face-command beg end)
1678 (error "%s is not a function" gnus-article-x-face-command))
1679 ;; The command is a string, so we interpret the command
1680 ;; as a, well, command, and fork it off.
1681 (let ((process-connection-type nil))
1682 (process-kill-without-query
1684 "article-x-face" nil shell-file-name shell-command-switch
1685 gnus-article-x-face-command))
1686 (process-send-region "article-x-face" beg end)
1687 (process-send-eof "article-x-face"))))))))))
1689 (defun article-decode-mime-words ()
1690 "Decode all MIME-encoded words in the article."
1693 (set-buffer gnus-article-buffer)
1694 (let ((inhibit-point-motion-hooks t)
1696 (mail-parse-charset gnus-newsgroup-charset)
1697 (mail-parse-ignored-charsets
1698 (save-excursion (set-buffer gnus-summary-buffer)
1699 gnus-newsgroup-ignored-charsets)))
1700 (mail-decode-encoded-word-region (point-min) (point-max)))))
1702 (defun article-decode-charset (&optional prompt)
1703 "Decode charset-encoded text in the article.
1704 If PROMPT (the prefix), prompt for a coding system to use."
1706 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1708 (mail-parse-charset gnus-newsgroup-charset)
1709 (mail-parse-ignored-charsets
1710 (save-excursion (condition-case nil
1711 (set-buffer gnus-summary-buffer)
1713 gnus-newsgroup-ignored-charsets))
1714 ct cte ctl charset format)
1717 (article-narrow-to-head)
1718 (setq ct (message-fetch-field "Content-Type" t)
1719 cte (message-fetch-field "Content-Transfer-Encoding" t)
1720 ctl (and ct (ignore-errors
1721 (mail-header-parse-content-type ct)))
1724 (mm-read-coding-system "Charset to decode: "))
1726 (mail-content-type-get ctl 'charset)))
1727 format (and ctl (mail-content-type-get ctl 'format)))
1729 (setq cte (mail-header-strip cte)))
1730 (if (and ctl (not (string-match "/" (car ctl))))
1732 (goto-char (point-max)))
1735 (narrow-to-region (point) (point-max))
1736 (when (and (eq mail-parse-charset 'gnus-decoded)
1737 (eq (mm-body-7-or-8) '8bit))
1738 ;; The text code could have been decoded.
1739 (setq charset mail-parse-charset))
1740 (when (and (or (not ctl)
1741 (equal (car ctl) "text/plain"))
1742 (not format)) ;; article with format will decode later.
1744 charset (and cte (intern (downcase
1745 (gnus-strip-whitespace cte))))
1748 (defun article-decode-encoded-words ()
1749 "Remove encoded-word encoding from headers."
1750 (let ((inhibit-point-motion-hooks t)
1751 (mail-parse-charset gnus-newsgroup-charset)
1752 (mail-parse-ignored-charsets
1753 (save-excursion (condition-case nil
1754 (set-buffer gnus-summary-buffer)
1756 gnus-newsgroup-ignored-charsets))
1759 (article-narrow-to-head)
1760 (funcall gnus-decode-header-function (point-min) (point-max)))))
1762 (defun article-decode-group-name ()
1763 "Decode group names in `Newsgroups:'."
1764 (let ((inhibit-point-motion-hooks t)
1766 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1767 (when (and (or gnus-group-name-charset-method-alist
1768 gnus-group-name-charset-group-alist)
1769 (gnus-buffer-live-p gnus-original-article-buffer))
1770 (when (nnmail-fetch-field "Newsgroups")
1771 (nnheader-replace-header "Newsgroups"
1772 (gnus-decode-newsgroups
1773 (with-current-buffer
1774 gnus-original-article-buffer
1775 (nnmail-fetch-field "Newsgroups"))
1776 gnus-newsgroup-name method)))
1777 (when (nnmail-fetch-field "Followup-To")
1778 (nnheader-replace-header "Followup-To"
1779 (gnus-decode-newsgroups
1780 (with-current-buffer
1781 gnus-original-article-buffer
1782 (nnmail-fetch-field "Followup-To"))
1783 gnus-newsgroup-name method))))))
1785 (defun article-de-quoted-unreadable (&optional force read-charset)
1786 "Translate a quoted-printable-encoded article.
1787 If FORCE, decode the article whether it is marked as quoted-printable
1789 If READ-CHARSET, ask for a coding system."
1790 (interactive (list 'force current-prefix-arg))
1792 (let ((buffer-read-only nil) type charset)
1793 (if (gnus-buffer-live-p gnus-original-article-buffer)
1794 (with-current-buffer gnus-original-article-buffer
1796 (gnus-fetch-field "content-transfer-encoding"))
1797 (let* ((ct (gnus-fetch-field "content-type"))
1800 (mail-header-parse-content-type ct)))))
1801 (setq charset (and ctl
1802 (mail-content-type-get ctl 'charset)))
1803 (if (stringp charset)
1804 (setq charset (intern (downcase charset)))))))
1806 (setq charset (mm-read-coding-system "Charset: " charset)))
1808 (setq charset gnus-newsgroup-charset))
1810 (and type (let ((case-fold-search t))
1811 (string-match "quoted-printable" type))))
1813 (quoted-printable-decode-region
1814 (point) (point-max) (mm-charset-to-coding-system charset))))))
1816 (defun article-de-base64-unreadable (&optional force read-charset)
1817 "Translate a base64 article.
1818 If FORCE, decode the article whether it is marked as base64 not.
1819 If READ-CHARSET, ask for a coding system."
1820 (interactive (list 'force current-prefix-arg))
1822 (let ((buffer-read-only nil) type charset)
1823 (if (gnus-buffer-live-p gnus-original-article-buffer)
1824 (with-current-buffer gnus-original-article-buffer
1826 (gnus-fetch-field "content-transfer-encoding"))
1827 (let* ((ct (gnus-fetch-field "content-type"))
1830 (mail-header-parse-content-type ct)))))
1831 (setq charset (and ctl
1832 (mail-content-type-get ctl 'charset)))
1833 (if (stringp charset)
1834 (setq charset (intern (downcase charset)))))))
1836 (setq charset (mm-read-coding-system "Charset: " charset)))
1838 (setq charset gnus-newsgroup-charset))
1840 (and type (let ((case-fold-search t))
1841 (string-match "base64" type))))
1844 (narrow-to-region (point) (point-max))
1845 (base64-decode-region (point-min) (point-max))
1846 (mm-decode-coding-region
1847 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1852 (defun article-decode-HZ ()
1853 "Translate a HZ-encoded article."
1857 (let ((buffer-read-only nil))
1858 (rfc1843-decode-region (point-min) (point-max)))))
1860 (defun article-wash-html (&optional read-charset)
1861 "Format an html article.
1862 If READ-CHARSET, ask for a coding system."
1865 (let ((buffer-read-only nil)
1867 (if (gnus-buffer-live-p gnus-original-article-buffer)
1868 (with-current-buffer gnus-original-article-buffer
1869 (let* ((ct (gnus-fetch-field "content-type"))
1872 (mail-header-parse-content-type ct)))))
1873 (setq charset (and ctl
1874 (mail-content-type-get ctl 'charset)))
1875 (if (stringp charset)
1876 (setq charset (intern (downcase charset)))))))
1878 (setq charset (mm-read-coding-system "Charset: " charset)))
1880 (setq charset gnus-newsgroup-charset))
1882 (save-window-excursion
1884 (narrow-to-region (point) (point-max))
1886 (let ((w3-strict-width (window-width))
1887 (url-standalone-mode t)
1888 (w3-honor-stylesheets nil)
1889 (w3-delay-image-loads t))
1891 (w3-region (point-min) (point-max))
1894 (defun article-hide-list-identifiers ()
1895 "Remove list identifies from the Subject header.
1896 The `gnus-list-identifiers' variable specifies what to do."
1898 (let ((inhibit-point-motion-hooks t)
1899 (regexp (if (consp gnus-list-identifiers)
1900 (mapconcat 'identity gnus-list-identifiers " *\\|")
1901 gnus-list-identifiers))
1906 (article-narrow-to-head)
1907 (goto-char (point-min))
1908 (while (re-search-forward
1909 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
1911 (delete-region (match-beginning 2) (match-end 0))
1912 (beginning-of-line))
1913 (when (re-search-forward
1914 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
1915 (delete-region (match-beginning 1) (match-end 1))))))))
1917 (defun article-hide-pgp ()
1918 "Remove any PGP headers and signatures in the current article."
1922 (let ((inhibit-point-motion-hooks t)
1923 buffer-read-only beg end)
1925 ;; Hide the "header".
1926 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1927 (push 'pgp gnus-article-wash-types)
1928 (delete-region (match-beginning 0) (match-end 0))
1929 ;; Remove armor headers (rfc2440 6.2)
1930 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1933 ;; Hide the actual signature.
1934 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1935 (setq end (1+ (match-beginning 0)))
1938 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1940 ;; Perhaps we shouldn't hide to the end of the buffer
1941 ;; if there is no end to the signature?
1943 ;; Hide "- " PGP quotation markers.
1945 (narrow-to-region beg end)
1946 (goto-char (point-min))
1947 (while (re-search-forward "^- " nil t)
1949 (match-beginning 0) (match-end 0)))
1951 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1953 (defun article-hide-pem (&optional arg)
1954 "Toggle hiding of any PEM headers and signatures in the current article.
1955 If given a negative prefix, always show; if given a positive prefix,
1957 (interactive (gnus-article-hidden-arg))
1958 (unless (gnus-article-check-hidden-text 'pem arg)
1960 (let (buffer-read-only end)
1961 (goto-char (point-min))
1962 ;; Hide the horrendously ugly "header".
1963 (when (and (search-forward
1964 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1966 (setq end (1+ (match-beginning 0))))
1967 (push 'pem gnus-article-wash-types)
1968 (gnus-article-hide-text-type
1970 (if (search-forward "\n\n" nil t)
1974 ;; Hide the trailer as well
1975 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1977 (gnus-article-hide-text-type
1978 (match-beginning 0) (match-end 0) 'pem)))))))
1980 (defun article-strip-banner ()
1981 "Strip the banner specified by the `banner' group parameter."
1985 (let ((inhibit-point-motion-hooks t)
1986 (banner (gnus-parameter-banner gnus-newsgroup-name))
1987 (gnus-signature-limit nil)
1988 buffer-read-only beg end)
1992 ((eq banner 'signature)
1993 (when (gnus-article-narrow-to-signature)
1996 (delete-region (point) (point-max))))
1998 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1999 (while (re-search-forward banner nil t)
2000 (delete-region (match-beginning 0) (match-end 0)))))
2002 (while (re-search-forward banner nil t)
2003 (delete-region (match-beginning 0) (match-end 0))))))))))
2005 (defun article-babel ()
2006 "Translate article using an online translation service."
2010 (set-buffer gnus-article-buffer)
2011 (when (article-goto-body)
2012 (let* ((buffer-read-only nil)
2015 (orig (buffer-substring start end))
2016 (trans (babel-as-string orig)))
2018 (narrow-to-region start end)
2019 (delete-region start end)
2022 (defun article-hide-signature (&optional arg)
2023 "Hide the signature in the current article.
2024 If given a negative prefix, always show; if given a positive prefix,
2026 (interactive (gnus-article-hidden-arg))
2027 (unless (gnus-article-check-hidden-text 'signature arg)
2030 (let ((buffer-read-only nil))
2031 (when (gnus-article-narrow-to-signature)
2032 (gnus-article-hide-text-type
2033 (point-min) (point-max) 'signature))))))
2034 (gnus-set-mode-line 'article))
2036 (defun article-strip-headers-in-body ()
2037 "Strip offensive headers from bodies."
2041 (let ((case-fold-search t))
2042 (when (looking-at "x-no-archive:")
2043 (gnus-delete-line)))))
2045 (defun article-strip-leading-blank-lines ()
2046 "Remove all blank lines from the beginning of the article."
2049 (let ((inhibit-point-motion-hooks t)
2051 (when (article-goto-body)
2052 (while (and (not (eobp))
2053 (looking-at "[ \t]*$"))
2054 (gnus-delete-line))))))
2056 (defun article-narrow-to-head ()
2057 "Narrow the buffer to the head of the message.
2058 Point is left at the beginning of the narrowed-to region."
2060 (goto-char (point-min))
2061 (if (search-forward "\n\n" nil 1)
2064 (goto-char (point-min)))
2066 (defun article-goto-body ()
2067 "Place point at the start of the body."
2068 (goto-char (point-min))
2070 ;; This variable is only bound when dealing with separate
2072 (article-goto-body-goes-to-point-min-p
2074 ((search-forward "\n\n" nil t)
2077 (goto-char (point-max))
2080 (defun article-strip-multiple-blank-lines ()
2081 "Replace consecutive blank lines with one empty line."
2084 (let ((inhibit-point-motion-hooks t)
2086 ;; First make all blank lines empty.
2088 (while (re-search-forward "^[ \t]+$" nil t)
2089 (unless (gnus-annotation-in-region-p
2090 (match-beginning 0) (match-end 0))
2091 (replace-match "" nil t)))
2092 ;; Then replace multiple empty lines with a single empty line.
2094 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2095 (unless (gnus-annotation-in-region-p
2096 (match-beginning 0) (match-end 0))
2097 (delete-region (match-beginning 1) (match-end 1)))))))
2099 (defun article-strip-leading-space ()
2100 "Remove all white space from the beginning of the lines in the article."
2103 (let ((inhibit-point-motion-hooks t)
2106 (while (re-search-forward "^[ \t]+" nil t)
2107 (replace-match "" t t)))))
2109 (defun article-strip-trailing-space ()
2110 "Remove all white space from the end of the lines in the article."
2113 (let ((inhibit-point-motion-hooks t)
2116 (while (re-search-forward "[ \t]+$" nil t)
2117 (replace-match "" t t)))))
2119 (defun article-strip-blank-lines ()
2120 "Strip leading, trailing and multiple blank lines."
2122 (article-strip-leading-blank-lines)
2123 (article-remove-trailing-blank-lines)
2124 (article-strip-multiple-blank-lines))
2126 (defun article-strip-all-blank-lines ()
2127 "Strip all blank lines."
2130 (let ((inhibit-point-motion-hooks t)
2133 (while (re-search-forward "^[ \t]*\n" nil t)
2134 (replace-match "" t t)))))
2136 (defun gnus-article-narrow-to-signature ()
2137 "Narrow to the signature; return t if a signature is found, else nil."
2138 (let ((inhibit-point-motion-hooks t))
2139 (when (gnus-article-search-signature)
2141 ;; Check whether we have some limits to what we consider
2142 ;; to be a signature.
2143 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2144 (list gnus-signature-limit)))
2146 (while (setq limit (pop limits))
2147 (if (or (and (integerp limit)
2148 (< (- (point-max) (point)) limit))
2150 (< (count-lines (point) (point-max)) limit))
2151 (and (gnus-functionp limit)
2153 (and (stringp limit)
2154 (not (re-search-forward limit nil t))))
2155 () ; This limit did not succeed.
2159 (narrow-to-region (point) (point-max))
2162 (defun gnus-article-search-signature ()
2163 "Search the current buffer for the signature separator.
2164 Put point at the beginning of the signature separator."
2165 (let ((cur (point)))
2166 (goto-char (point-max))
2167 (if (if (stringp gnus-signature-separator)
2168 (re-search-backward gnus-signature-separator nil t)
2169 (let ((seps gnus-signature-separator))
2171 (not (re-search-backward (car seps) nil t)))
2178 (defun gnus-article-hidden-arg ()
2179 "Return the current prefix arg as a number, or 0 if no prefix."
2180 (list (if current-prefix-arg
2181 (prefix-numeric-value current-prefix-arg)
2184 (defun gnus-article-check-hidden-text (type arg)
2185 "Return nil if hiding is necessary.
2186 Arg can be nil or a number. nil and positive means hide, negative
2187 means show, 0 means toggle."
2190 (let ((hide (gnus-article-hidden-text-p type)))
2196 (gnus-article-show-hidden-text type)
2199 (if (eq hide 'hidden)
2201 (gnus-article-show-hidden-text type)
2205 (defun gnus-article-hidden-text-p (type)
2206 "Say whether the current buffer contains hidden text of type TYPE."
2207 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2209 (not (get-text-property pos 'invisible))
2210 (not (get-text-property pos 'dummy-invisible)))
2212 (text-property-any (1+ pos) (point-max) 'article-type type)))
2217 (defun gnus-article-show-hidden-text (type &optional dummy)
2218 "Show all hidden text of type TYPE.
2219 Originally it is hide instead of DUMMY."
2220 (let ((buffer-read-only nil)
2221 (inhibit-point-motion-hooks t))
2222 (gnus-remove-text-properties-when
2224 (point-min) (point-max)
2225 (cons 'article-type (cons type
2226 gnus-hidden-properties)))
2227 (setq gnus-article-wash-types (delq type gnus-article-wash-types))))
2229 (defconst article-time-units
2230 `((year . ,(* 365.25 24 60 60))
2231 (week . ,(* 7 24 60 60))
2232 (day . ,(* 24 60 60))
2236 "Mapping from time units to seconds.")
2238 (defun article-date-ut (&optional type highlight header)
2239 "Convert DATE date to universal time in the current article.
2240 If TYPE is `local', convert to local time; if it is `lapsed', output
2241 how much time has lapsed since DATE. For `lapsed', the value of
2242 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2243 should replace the \"Date:\" one, or should be added below it."
2244 (interactive (list 'ut t))
2245 (let* ((header (or header
2246 (message-fetch-field "date")
2248 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2251 ((not gnus-article-date-lapsed-new-header)
2257 (date (if (vectorp header) (mail-header-date header)
2259 (inhibit-point-motion-hooks t)
2264 (article-narrow-to-head)
2265 (when (re-search-forward tdate-regexp nil t)
2266 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2267 date (or (get-text-property (gnus-point-at-bol)
2270 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2272 (when (and date (not (string= date "")))
2273 (goto-char (point-min))
2274 (let ((buffer-read-only nil))
2275 ;; Delete any old Date headers.
2276 (while (re-search-forward date-regexp nil t)
2278 (delete-region (progn (beginning-of-line) (point))
2279 (progn (forward-line 1) (point)))
2280 (delete-region (progn (beginning-of-line) (point))
2281 (progn (end-of-line) (point)))
2282 (setq pos (point))))
2283 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2285 (if pos (goto-char pos))
2286 (insert (article-make-date-line date (or type 'ut)))
2292 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2293 (put-text-property (match-beginning 1) (1+ (match-end 1))
2294 'original-date date)
2295 (put-text-property (match-beginning 1) (1+ (match-end 1))
2297 (put-text-property (match-beginning 2) (match-end 2)
2300 (defun article-make-date-line (date type)
2301 "Return a DATE line of TYPE."
2302 (unless (memq type '(local ut original user iso8601 lapsed english))
2303 (error "Unknown conversion type: %s" type))
2305 (let ((time (date-to-time date)))
2307 ;; Convert to the local timezone.
2309 (let ((tz (car (current-time-zone time))))
2310 (format "Date: %s %s%02d%02d" (current-time-string time)
2311 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2312 (/ (% (abs tz) 3600) 60))))
2313 ;; Convert to Universal Time.
2316 (current-time-string
2317 (let* ((e (parse-time-string date))
2318 (tm (apply 'encode-time e))
2320 (ls (- (cadr tm) (car (current-time-zone time)))))
2321 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2322 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2325 ;; Get the original date from the article.
2326 ((eq type 'original)
2327 (concat "Date: " (if (string-match "\n+$" date)
2328 (substring date 0 (match-beginning 0))
2330 ;; Let the user define the format.
2332 (if (gnus-functionp gnus-article-time-format)
2333 (funcall gnus-article-time-format time)
2336 (format-time-string gnus-article-time-format time))))
2339 (let ((tz (car (current-time-zone time))))
2342 (format-time-string "%Y%m%dT%H%M%S" time)
2343 (format "%s%02d%02d"
2344 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2345 (/ (% (abs tz) 3600) 60)))))
2346 ;; Do an X-Sent lapsed format.
2348 ;; If the date is seriously mangled, the timezone functions are
2349 ;; liable to bug out, so we ignore all errors.
2350 (let* ((now (current-time))
2351 (real-time (subtract-time now time))
2352 (real-sec (and real-time
2353 (+ (* (float (car real-time)) 65536)
2355 (sec (and real-time (abs real-sec)))
2365 ;; This is a bit convoluted, but basically we go
2366 ;; through the time units for years, weeks, etc,
2367 ;; and divide things to see whether that results
2368 ;; in positive answers.
2371 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2372 ;; The (remaining) seconds are too few to
2373 ;; be divided into this time unit.
2375 ;; It's big enough, so we output it.
2376 (setq sec (- sec (* num (cdr unit))))
2378 (concat (if prev ", " "") (int-to-string
2380 " " (symbol-name (car unit))
2381 (if (> num 1) "s" ""))
2383 article-time-units "")
2384 ;; If dates are odd, then it might appear like the
2385 ;; article was sent in the future.
2388 " in the future"))))))
2389 ;; Display the date in proper English
2391 (let ((dtime (decode-time time)))
2394 (number-to-string (nth 3 dtime))
2395 (let ((digit (% (nth 3 dtime) 10)))
2397 ((memq (nth 3 dtime) '(11 12 13)) "th")
2403 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2405 (number-to-string (nth 5 dtime))
2407 (format "%02d" (nth 2 dtime))
2409 (format "%02d" (nth 1 dtime)))))))
2411 (format "Date: %s (from Oort)" date))))
2413 (defun article-date-local (&optional highlight)
2414 "Convert the current article date to the local timezone."
2415 (interactive (list t))
2416 (article-date-ut 'local highlight))
2418 (defun article-date-english (&optional highlight)
2419 "Convert the current article date to something that is proper English."
2420 (interactive (list t))
2421 (article-date-ut 'english highlight))
2423 (defun article-date-original (&optional highlight)
2424 "Convert the current article date to what it was originally.
2425 This is only useful if you have used some other date conversion
2426 function and want to see what the date was before converting."
2427 (interactive (list t))
2428 (article-date-ut 'original highlight))
2430 (defun article-date-lapsed (&optional highlight)
2431 "Convert the current article date to time lapsed since it was sent."
2432 (interactive (list t))
2433 (article-date-ut 'lapsed highlight))
2435 (defun article-update-date-lapsed ()
2436 "Function to be run from a timer to update the lapsed time line."
2437 (let (deactivate-mark)
2442 (set-buffer (window-buffer w))
2443 (when (eq major-mode 'gnus-article-mode)
2444 (goto-char (point-min))
2445 (when (re-search-forward "^X-Sent:" nil t)
2446 (article-date-lapsed t))))
2449 (defun gnus-start-date-timer (&optional n)
2450 "Start a timer to update the X-Sent header in the article buffers.
2451 The numerical prefix says how frequently (in seconds) the function
2456 (gnus-stop-date-timer)
2457 (setq article-lapsed-timer
2458 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2460 (defun gnus-stop-date-timer ()
2461 "Stop the X-Sent timer."
2463 (when article-lapsed-timer
2464 (nnheader-cancel-timer article-lapsed-timer)
2465 (setq article-lapsed-timer nil)))
2467 (defun article-date-user (&optional highlight)
2468 "Convert the current article date to the user-defined format.
2469 This format is defined by the `gnus-article-time-format' variable."
2470 (interactive (list t))
2471 (article-date-ut 'user highlight))
2473 (defun article-date-iso8601 (&optional highlight)
2474 "Convert the current article date to ISO8601."
2475 (interactive (list t))
2476 (article-date-ut 'iso8601 highlight))
2478 (defun article-show-all ()
2479 "Show all hidden text in the article buffer."
2482 (let ((buffer-read-only nil))
2483 (gnus-article-unhide-text (point-min) (point-max)))))
2485 (defun article-remove-leading-whitespace ()
2486 "Remove excessive whitespace from all headers."
2490 (let ((buffer-read-only nil))
2491 (article-narrow-to-head)
2492 (goto-char (point-min))
2493 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2494 (delete-region (match-beginning 1) (match-end 1)))))))
2496 (defun article-emphasize (&optional arg)
2497 "Emphasize text according to `gnus-emphasis-alist'."
2498 (interactive (gnus-article-hidden-arg))
2499 (unless (gnus-article-check-hidden-text 'emphasis arg)
2503 (with-current-buffer gnus-summary-buffer
2504 gnus-article-emphasis-alist)
2506 gnus-emphasis-alist))
2507 (buffer-read-only nil)
2508 (props (append '(article-type emphasis)
2509 gnus-hidden-properties))
2510 regexp elem beg invisible visible face)
2513 (while (setq elem (pop alist))
2515 (setq regexp (car elem)
2516 invisible (nth 1 elem)
2517 visible (nth 2 elem)
2519 (while (re-search-forward regexp nil t)
2520 (when (and (match-beginning visible) (match-beginning invisible))
2521 (gnus-article-hide-text
2522 (match-beginning invisible) (match-end invisible) props)
2523 (gnus-article-unhide-text-type
2524 (match-beginning visible) (match-end visible) 'emphasis)
2525 (gnus-put-overlay-excluding-newlines
2526 (match-beginning visible) (match-end visible) 'face face)
2527 (push 'emphasis gnus-article-wash-types)
2528 (goto-char (match-end invisible)))))))))
2530 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2531 "Setup newsgroup emphasis alist."
2532 (unless gnus-article-emphasis-alist
2533 (let ((name (and gnus-newsgroup-name
2534 (gnus-group-real-name gnus-newsgroup-name))))
2535 (make-local-variable 'gnus-article-emphasis-alist)
2536 (setq gnus-article-emphasis-alist
2538 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2539 (while (setq elem (pop alist))
2540 (when (and name (string-match (car elem) name))
2542 highlight (copy-sequence (cdr elem)))))
2544 (copy-sequence highlight-words)
2545 (if gnus-newsgroup-name
2546 (copy-sequence (gnus-group-find-parameter
2547 gnus-newsgroup-name 'highlight-words t)))
2548 gnus-emphasis-alist)))))
2551 (defvar gnus-summary-article-menu)
2552 (defvar gnus-summary-post-menu))
2554 ;;; Saving functions.
2556 (defun gnus-article-save (save-buffer file &optional num)
2557 "Save the currently selected article."
2558 (unless gnus-save-all-headers
2559 ;; Remove headers according to `gnus-saved-headers'.
2560 (let ((gnus-visible-headers
2561 (or gnus-saved-headers gnus-visible-headers))
2562 (gnus-article-buffer save-buffer))
2564 (set-buffer save-buffer)
2565 (article-hide-headers 1 t))))
2566 (save-window-excursion
2567 (if (not gnus-default-article-saver)
2568 (error "No default saver is defined")
2569 ;; !!! Magic! The saving functions all save
2570 ;; `gnus-save-article-buffer' (or so they think), but we
2571 ;; bind that variable to our save-buffer.
2572 (set-buffer gnus-article-buffer)
2573 (let* ((gnus-save-article-buffer save-buffer)
2576 ((not gnus-prompt-before-saving) 'default)
2577 ((eq gnus-prompt-before-saving 'always) nil)
2579 (gnus-number-of-articles-to-be-saved
2580 (when (eq gnus-prompt-before-saving t)
2582 (set-buffer gnus-article-current-summary)
2583 (funcall gnus-default-article-saver filename)))))
2585 (defun gnus-read-save-file-name (prompt &optional filename
2586 function group headers variable)
2588 (funcall function group headers (symbol-value variable)))
2593 ((eq filename 'default)
2599 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2602 (if (and gnus-number-of-articles-to-be-saved
2603 (> gnus-number-of-articles-to-be-saved 1))
2604 (format "these %d articles"
2605 gnus-number-of-articles-to-be-saved)
2608 ;; Let the split methods have their say.
2610 ;; No split name was found.
2613 (concat prompt " (default "
2614 (file-name-nondirectory default-name) ") ")
2615 (file-name-directory default-name)
2617 ;; A single group name is returned.
2618 ((stringp split-name)
2620 (funcall function split-name headers
2621 (symbol-value variable)))
2623 (concat prompt " (default "
2624 (file-name-nondirectory default-name) ") ")
2625 (file-name-directory default-name)
2627 ;; A single split name was found
2628 ((= 1 (length split-name))
2629 (let* ((name (expand-file-name
2631 gnus-article-save-directory))
2632 (dir (cond ((file-directory-p name)
2633 (file-name-as-directory name))
2634 ((file-exists-p name) name)
2635 (t gnus-article-save-directory))))
2637 (concat prompt " (default " name ") ")
2639 ;; A list of splits was found.
2641 (setq split-name (nreverse split-name))
2643 (let ((file-name-history
2644 (nconc split-name file-name-history)))
2648 (concat prompt " (`M-p' for defaults) ")
2649 gnus-article-save-directory
2651 gnus-article-save-directory)))
2652 (car (push result file-name-history)))))))
2653 ;; Create the directory.
2654 (gnus-make-directory (file-name-directory file))
2655 ;; If we have read a directory, we append the default file name.
2656 (when (file-directory-p file)
2657 (setq file (expand-file-name (file-name-nondirectory
2659 (file-name-as-directory file))))
2660 ;; Possibly translate some characters.
2661 (nnheader-translate-file-chars file))))))
2662 (gnus-make-directory (file-name-directory result))
2663 (set variable result)))
2665 (defun gnus-article-archive-name (group)
2666 "Return the first instance of an \"Archive-name\" in the current buffer."
2667 (let ((case-fold-search t))
2668 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2669 (nnheader-concat gnus-article-save-directory
2670 (match-string 1)))))
2672 (defun gnus-article-nndoc-name (group)
2673 "If GROUP is an nndoc group, return the name of the parent group."
2674 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2675 (gnus-group-get-parameter group 'save-article-group)))
2677 (defun gnus-summary-save-in-rmail (&optional filename)
2678 "Append this article to Rmail file.
2679 Optional argument FILENAME specifies file name.
2680 Directory to save to is default to `gnus-article-save-directory'."
2681 (setq filename (gnus-read-save-file-name
2682 "Save %s in rmail file:" filename
2683 gnus-rmail-save-name gnus-newsgroup-name
2684 gnus-current-headers 'gnus-newsgroup-last-rmail))
2685 (gnus-eval-in-buffer-window gnus-save-article-buffer
2689 (gnus-output-to-rmail filename))))
2692 (defun gnus-summary-save-in-mail (&optional filename)
2693 "Append this article to Unix mail file.
2694 Optional argument FILENAME specifies file name.
2695 Directory to save to is default to `gnus-article-save-directory'."
2696 (setq filename (gnus-read-save-file-name
2697 "Save %s in Unix mail file:" filename
2698 gnus-mail-save-name gnus-newsgroup-name
2699 gnus-current-headers 'gnus-newsgroup-last-mail))
2700 (gnus-eval-in-buffer-window gnus-save-article-buffer
2704 (if (and (file-readable-p filename)
2705 (mail-file-babyl-p filename))
2706 (rmail-output-to-rmail-file filename t)
2707 (gnus-output-to-mail filename)))))
2710 (defun gnus-summary-save-in-file (&optional filename overwrite)
2711 "Append this article to file.
2712 Optional argument FILENAME specifies file name.
2713 Directory to save to is default to `gnus-article-save-directory'."
2714 (setq filename (gnus-read-save-file-name
2715 "Save %s in file:" filename
2716 gnus-file-save-name gnus-newsgroup-name
2717 gnus-current-headers 'gnus-newsgroup-last-file))
2718 (gnus-eval-in-buffer-window gnus-save-article-buffer
2722 (when (and overwrite
2723 (file-exists-p filename))
2724 (delete-file filename))
2725 (gnus-output-to-file filename))))
2728 (defun gnus-summary-write-to-file (&optional filename)
2729 "Write this article to a file, overwriting it if the file exists.
2730 Optional argument FILENAME specifies file name.
2731 The directory to save in defaults to `gnus-article-save-directory'."
2732 (gnus-summary-save-in-file nil t))
2734 (defun gnus-summary-save-body-in-file (&optional filename)
2735 "Append this article body to a file.
2736 Optional argument FILENAME specifies file name.
2737 The directory to save in defaults to `gnus-article-save-directory'."
2738 (setq filename (gnus-read-save-file-name
2739 "Save %s body in file:" filename
2740 gnus-file-save-name gnus-newsgroup-name
2741 gnus-current-headers 'gnus-newsgroup-last-file))
2742 (gnus-eval-in-buffer-window gnus-save-article-buffer
2746 (when (article-goto-body)
2747 (narrow-to-region (point) (point-max)))
2748 (gnus-output-to-file filename))))
2751 (defun gnus-summary-save-in-pipe (&optional command)
2752 "Pipe this article to subprocess."
2754 (cond ((and (eq command 'default)
2755 gnus-last-shell-command)
2756 gnus-last-shell-command)
2761 "Shell command on %s: "
2762 (if (and gnus-number-of-articles-to-be-saved
2763 (> gnus-number-of-articles-to-be-saved 1))
2764 (format "these %d articles"
2765 gnus-number-of-articles-to-be-saved)
2767 gnus-last-shell-command))))
2768 (when (string-equal command "")
2769 (if gnus-last-shell-command
2770 (setq command gnus-last-shell-command)
2771 (error "A command is required")))
2772 (gnus-eval-in-buffer-window gnus-article-buffer
2775 (shell-command-on-region (point-min) (point-max) command nil)))
2776 (setq gnus-last-shell-command command))
2778 (defun gnus-summary-pipe-to-muttprint (&optional command)
2779 "Pipe this article to muttprint."
2780 (setq command (read-string
2781 "Print using command: " gnus-summary-muttprint-program
2782 nil gnus-summary-muttprint-program))
2783 (gnus-summary-save-in-pipe command))
2785 ;;; Article file names when saving.
2787 (defun gnus-capitalize-newsgroup (newsgroup)
2788 "Capitalize NEWSGROUP name."
2789 (when (not (zerop (length newsgroup)))
2790 (concat (char-to-string (upcase (aref newsgroup 0)))
2791 (substring newsgroup 1))))
2793 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2794 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2795 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2796 Otherwise, it is like ~/News/news/group/num."
2799 (concat (if (gnus-use-long-file-name 'not-save)
2800 (gnus-capitalize-newsgroup newsgroup)
2801 (gnus-newsgroup-directory-form newsgroup))
2802 "/" (int-to-string (mail-header-number headers)))
2803 gnus-article-save-directory)))
2805 (string-equal (file-name-directory default)
2806 (file-name-directory last-file))
2807 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2809 (or last-file default))))
2811 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2812 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2813 If variable `gnus-use-long-file-name' is non-nil, it is
2814 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2817 (concat (if (gnus-use-long-file-name 'not-save)
2819 (gnus-newsgroup-directory-form newsgroup))
2820 "/" (int-to-string (mail-header-number headers)))
2821 gnus-article-save-directory)))
2823 (string-equal (file-name-directory default)
2824 (file-name-directory last-file))
2825 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2827 (or last-file default))))
2829 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2830 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2831 If variable `gnus-use-long-file-name' is non-nil, it is
2832 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2835 (if (gnus-use-long-file-name 'not-save)
2838 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2840 gnus-article-save-directory)))
2842 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2843 "Generate file name from sender."
2844 (let ((from (mail-header-from headers)))
2846 (if (and from (string-match "\\([^ <]+\\)@" from))
2847 (match-string 1 from)
2849 gnus-article-save-directory)))
2851 (defun article-verify-x-pgp-sig ()
2854 (if (gnus-buffer-live-p gnus-original-article-buffer)
2855 (let ((sig (with-current-buffer gnus-original-article-buffer
2856 (gnus-fetch-field "X-PGP-Sig")))
2860 (mml2015-clear-verify-function))
2862 (insert-buffer gnus-original-article-buffer)
2863 (setq items (split-string sig))
2864 (message-narrow-to-head)
2865 (let ((inhibit-point-motion-hooks t)
2866 (case-fold-search t))
2867 ;; Don't verify multiple headers.
2868 (setq headers (mapconcat (lambda (header)
2870 (mail-fetch-field header) "\n"))
2871 (split-string (nth 1 items) ",") "")))
2872 (delete-region (point-min) (point-max))
2873 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2874 (insert "X-Signed-Headers: " (nth 1 items) "\n")
2879 (if (looking-at "^-")
2882 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
2883 (insert "Version: " (car items) "\n\n")
2884 (insert (mapconcat 'identity (cddr items) "\n"))
2885 (insert "\n-----END PGP SIGNATURE-----\n")
2886 (let ((mm-security-handle (list (format "multipart/signed"))))
2887 (mml2015-clean-buffer)
2888 (let ((coding-system-for-write (or gnus-newsgroup-charset
2890 (funcall (mml2015-clear-verify-function)))
2892 (or (mm-handle-multipart-ctl-parameter
2893 mm-security-handle 'gnus-details)
2894 (mm-handle-multipart-ctl-parameter
2895 mm-security-handle 'gnus-info)))))
2897 (let (buffer-read-only bface eface)
2899 (message-narrow-to-head)
2900 (goto-char (point-max))
2902 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2903 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2904 (message-remove-header "X-Gnus-PGP-Verify")
2905 (if (re-search-forward "^X-PGP-Sig:" nil t)
2907 (goto-char (point-max)))
2908 (narrow-to-region (point) (point))
2909 (insert "X-Gnus-PGP-Verify: " info "\n")
2910 (goto-char (point-min))
2913 (if (not (looking-at "^[ \t]"))
2917 (goto-char (point-min))
2918 (when (looking-at "\\([^:]+\\): *")
2919 (put-text-property (match-beginning 1) (1+ (match-end 1))
2921 (put-text-property (match-end 0) (point-max)
2922 'face eface)))))))))
2924 (defun article-verify-cancel-lock ()
2925 "Verify Cancel-Lock header."
2927 (if (gnus-buffer-live-p gnus-original-article-buffer)
2928 (canlock-verify gnus-original-article-buffer)))
2935 (setq afunc (car func)
2938 gfunc (intern (format "gnus-%s" func))))
2941 `(lambda (&optional interactive &rest args)
2942 ,(documentation afunc t)
2943 (interactive (list t))
2945 (set-buffer gnus-article-buffer)
2947 (call-interactively ',afunc)
2948 (apply ',afunc args))))))))
2949 '(article-hide-headers
2950 article-verify-x-pgp-sig
2951 article-verify-cancel-lock
2952 article-hide-boring-headers
2953 article-treat-overstrike
2954 article-fill-long-lines
2955 article-capitalize-sentences
2957 article-remove-leading-whitespace
2958 article-display-x-face
2959 article-de-quoted-unreadable
2960 article-de-base64-unreadable
2963 article-hide-list-identifiers
2965 article-strip-banner
2968 article-hide-signature
2969 article-strip-headers-in-body
2970 article-remove-trailing-blank-lines
2971 article-strip-leading-blank-lines
2972 article-strip-multiple-blank-lines
2973 article-strip-leading-space
2974 article-strip-trailing-space
2975 article-strip-blank-lines
2976 article-strip-all-blank-lines
2977 article-replace-with-quoted-text
2979 article-date-english
2980 article-date-iso8601
2981 article-date-original
2983 article-decode-mime-words
2984 article-decode-charset
2985 article-decode-encoded-words
2989 article-treat-dumbquotes
2990 article-normalize-headers
2991 (article-show-all . gnus-article-show-all-headers))))
2994 ;;; Gnus article mode
2997 (put 'gnus-article-mode 'mode-class 'special)
2999 (set-keymap-parent gnus-article-mode-map widget-keymap)
3001 (gnus-define-keys gnus-article-mode-map
3002 " " gnus-article-goto-next-page
3003 "\177" gnus-article-goto-prev-page
3004 [delete] gnus-article-goto-prev-page
3005 [backspace] gnus-article-goto-prev-page
3006 "\C-c^" gnus-article-refer-article
3007 "h" gnus-article-show-summary
3008 "s" gnus-article-show-summary
3009 "\C-c\C-m" gnus-article-mail
3010 "?" gnus-article-describe-briefly
3011 "e" gnus-summary-edit-article
3012 "<" beginning-of-buffer
3014 "\C-c\C-i" gnus-info-find-node
3016 "\C-hk" gnus-article-describe-key
3017 "\C-hc" gnus-article-describe-key-briefly
3019 "\C-d" gnus-article-read-summary-keys
3020 "\M-*" gnus-article-read-summary-keys
3021 "\M-#" gnus-article-read-summary-keys
3022 "\M-^" gnus-article-read-summary-keys
3023 "\M-g" gnus-article-read-summary-keys)
3025 (substitute-key-definition
3026 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3028 (defun gnus-article-make-menu-bar ()
3029 (unless (boundp 'gnus-article-commands-menu)
3030 (gnus-summary-make-menu-bar))
3031 (gnus-turn-off-edit-menu 'article)
3032 (unless (boundp 'gnus-article-article-menu)
3034 gnus-article-article-menu gnus-article-mode-map ""
3036 ["Scroll forwards" gnus-article-goto-next-page t]
3037 ["Scroll backwards" gnus-article-goto-prev-page t]
3038 ["Show summary" gnus-article-show-summary t]
3039 ["Fetch Message-ID at point" gnus-article-refer-article t]
3040 ["Mail to address at point" gnus-article-mail t]
3041 ["Send a bug report" gnus-bug t]))
3044 gnus-article-treatment-menu gnus-article-mode-map ""
3045 ;; Fixme: this should use :active (and maybe :visible).
3047 ["Hide headers" gnus-article-hide-headers t]
3048 ["Hide signature" gnus-article-hide-signature t]
3049 ["Hide citation" gnus-article-hide-citation t]
3050 ["Treat overstrike" gnus-article-treat-overstrike t]
3051 ["Remove carriage return" gnus-article-remove-cr t]
3052 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3053 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3054 ["Remove base64" gnus-article-de-base64-unreadable t]
3055 ["Treat html" gnus-article-wash-html t]
3056 ["Decode HZ" gnus-article-decode-HZ t]))
3058 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3060 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3062 (gnus-run-hooks 'gnus-article-menu-hook)))
3064 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3067 (defun gnus-article-mode ()
3068 "Major mode for displaying an article.
3070 All normal editing commands are switched off.
3072 The following commands are available in addition to all summary mode
3074 \\<gnus-article-mode-map>
3075 \\[gnus-article-next-page]\t Scroll the article one page forwards
3076 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3077 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3078 \\[gnus-article-show-summary]\t Display the summary buffer
3079 \\[gnus-article-mail]\t Send a reply to the address near point
3080 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3081 \\[gnus-info-find-node]\t Go to the Gnus info node"
3083 (gnus-simplify-mode-line)
3084 (setq mode-name "Article")
3085 (setq major-mode 'gnus-article-mode)
3086 (make-local-variable 'minor-mode-alist)
3087 (use-local-map gnus-article-mode-map)
3088 (when (gnus-visual-p 'article-menu 'menu)
3089 (gnus-article-make-menu-bar))
3090 (gnus-update-format-specifications nil 'article-mode)
3091 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3092 (make-local-variable 'gnus-page-broken)
3093 (make-local-variable 'gnus-button-marker-list)
3094 (make-local-variable 'gnus-article-current-summary)
3095 (make-local-variable 'gnus-article-mime-handles)
3096 (make-local-variable 'gnus-article-decoded-p)
3097 (make-local-variable 'gnus-article-mime-handle-alist)
3098 (make-local-variable 'gnus-article-wash-types)
3099 (make-local-variable 'gnus-article-charset)
3100 (make-local-variable 'gnus-article-ignored-charsets)
3101 (gnus-set-default-directory)
3102 (buffer-disable-undo)
3103 (setq buffer-read-only t)
3104 (set-syntax-table gnus-article-mode-syntax-table)
3105 (mm-enable-multibyte)
3106 (gnus-run-hooks 'gnus-article-mode-hook))
3108 (defun gnus-article-setup-buffer ()
3109 "Initialize the article buffer."
3110 (let* ((name (if gnus-single-article-buffer "*Article*"
3111 (concat "*Article " gnus-newsgroup-name "*")))
3113 (progn (string-match "\\*Article" name)
3114 (concat " *Original Article"
3115 (substring name (match-end 0))))))
3116 (setq gnus-article-buffer name)
3117 (setq gnus-original-article-buffer original)
3118 (setq gnus-article-mime-handle-alist nil)
3119 ;; This might be a variable local to the summary buffer.
3120 (unless gnus-single-article-buffer
3122 (set-buffer gnus-summary-buffer)
3123 (setq gnus-article-buffer name)
3124 (setq gnus-original-article-buffer original)
3125 (gnus-set-global-variables)))
3126 (gnus-article-setup-highlight-words)
3127 ;; Init original article buffer.
3129 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3130 (mm-enable-multibyte)
3131 (setq major-mode 'gnus-original-article-mode)
3132 (make-local-variable 'gnus-original-article))
3133 (if (get-buffer name)
3136 (when gnus-article-mime-handles
3137 (mm-destroy-parts gnus-article-mime-handles)
3138 (setq gnus-article-mime-handles nil))
3139 ;; Set it to nil in article-buffer!
3140 (setq gnus-article-mime-handle-alist nil)
3141 (buffer-disable-undo)
3142 (setq buffer-read-only t)
3143 (unless (eq major-mode 'gnus-article-mode)
3144 (gnus-article-mode))
3147 (set-buffer (gnus-get-buffer-create name))
3149 (make-local-variable 'gnus-summary-buffer)
3150 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3151 (current-buffer)))))
3153 ;; Set article window start at LINE, where LINE is the number of lines
3154 ;; from the head of the article.
3155 (defun gnus-article-set-window-start (&optional line)
3157 (gnus-get-buffer-window gnus-article-buffer t)
3159 (set-buffer gnus-article-buffer)
3160 (goto-char (point-min))
3163 (gnus-message 6 "Moved to bookmark")
3164 (search-forward "\n\n" nil t)
3168 (defun gnus-article-prepare (article &optional all-headers header)
3169 "Prepare ARTICLE in article mode buffer.
3170 ARTICLE should either be an article number or a Message-ID.
3171 If ARTICLE is an id, HEADER should be the article headers.
3172 If ALL-HEADERS is non-nil, no headers are hidden."
3174 ;; Make sure we start in a summary buffer.
3175 (unless (eq major-mode 'gnus-summary-mode)
3176 (set-buffer gnus-summary-buffer))
3177 (setq gnus-summary-buffer (current-buffer))
3178 (let* ((gnus-article (if header (mail-header-number header) article))
3179 (summary-buffer (current-buffer))
3180 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3181 (group gnus-newsgroup-name)
3184 (gnus-article-setup-buffer)
3185 (set-buffer gnus-article-buffer)
3186 ;; Deactivate active regions.
3187 (when (and (boundp 'transient-mark-mode)
3188 transient-mark-mode)
3189 (setq mark-active nil))
3190 (if (not (setq result (let ((buffer-read-only nil))
3191 (gnus-request-article-this-buffer
3193 ;; There is no such article.
3195 (when (and (numberp article)
3196 (not (memq article gnus-newsgroup-sparse)))
3197 (setq gnus-article-current
3198 (cons gnus-newsgroup-name article))
3199 (set-buffer gnus-summary-buffer)
3200 (setq gnus-current-article article)
3201 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3203 (gnus-summary-set-agent-mark article)
3204 (message "Message marked for downloading"))
3205 (gnus-summary-mark-article article gnus-canceled-mark)
3206 (unless (memq article gnus-newsgroup-sparse)
3207 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3208 (if (or (eq result 'pseudo)
3209 (eq result 'nneething))
3212 (set-buffer summary-buffer)
3213 (push article gnus-newsgroup-history)
3214 (setq gnus-last-article gnus-current-article
3215 gnus-current-article 0
3216 gnus-current-headers nil
3217 gnus-article-current nil)
3218 (if (eq result 'nneething)
3219 (gnus-configure-windows 'summary)
3220 (gnus-configure-windows 'article))
3221 (gnus-set-global-variables))
3222 (let ((gnus-article-mime-handle-alist-1
3223 gnus-article-mime-handle-alist))
3224 (gnus-set-mode-line 'article)))
3225 ;; The result from the `request' was an actual article -
3226 ;; or at least some text that is now displayed in the
3228 (when (and (numberp article)
3229 (not (eq article gnus-current-article)))
3230 ;; Seems like a new article has been selected.
3231 ;; `gnus-current-article' must be an article number.
3233 (set-buffer summary-buffer)
3234 (push article gnus-newsgroup-history)
3235 (setq gnus-last-article gnus-current-article
3236 gnus-current-article article
3237 gnus-current-headers
3238 (gnus-summary-article-header gnus-current-article)
3239 gnus-article-current
3240 (cons gnus-newsgroup-name gnus-current-article))
3241 (unless (vectorp gnus-current-headers)
3242 (setq gnus-current-headers nil))
3243 (gnus-summary-goto-subject gnus-current-article)
3244 (when (gnus-summary-show-thread)
3245 ;; If the summary buffer really was folded, the
3246 ;; previous goto may not actually have gone to
3247 ;; the right article, but the thread root instead.
3249 (gnus-summary-goto-subject gnus-current-article))
3250 (gnus-run-hooks 'gnus-mark-article-hook)
3251 (gnus-set-mode-line 'summary)
3252 (when (gnus-visual-p 'article-highlight 'highlight)
3253 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3254 ;; Set the global newsgroup variables here.
3255 (gnus-set-global-variables)
3256 (setq gnus-have-all-headers
3257 (or all-headers gnus-show-all-headers))))
3259 (gnus-configure-windows 'article))
3260 (when (or (numberp article)
3262 (gnus-article-prepare-display)
3264 (goto-char (point-min))
3265 (setq gnus-page-broken
3266 (when gnus-break-pages
3267 (gnus-narrow-to-page)
3269 (let ((gnus-article-mime-handle-alist-1
3270 gnus-article-mime-handle-alist))
3271 (gnus-set-mode-line 'article))
3273 (set-window-point (get-buffer-window (current-buffer)) (point))
3274 (gnus-configure-windows 'article)
3278 (defun gnus-article-prepare-display ()
3279 "Make the current buffer look like a nice article."
3280 ;; Hooks for getting information from the article.
3281 ;; This hook must be called before being narrowed.
3282 (let ((gnus-article-buffer (current-buffer))
3284 (unless (eq major-mode 'gnus-article-mode)
3285 (gnus-article-mode))
3286 (setq buffer-read-only nil
3287 gnus-article-wash-types nil)
3288 (gnus-run-hooks 'gnus-tmp-internal-hook)
3289 (when gnus-display-mime-function
3290 (funcall gnus-display-mime-function))
3291 (gnus-run-hooks 'gnus-article-prepare-hook)))
3294 ;;; Gnus MIME viewing functions
3297 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3298 "The following specs can be used:
3300 %T MIME type, along with additional info
3301 %n The `name' parameter
3302 %d The description, if any
3303 %l The length of the encoded part
3304 %p The part identifier number
3305 %e Dots if the part isn't displayed")
3307 (defvar gnus-mime-button-line-format-alist
3308 '((?t gnus-tmp-type ?s)
3309 (?T gnus-tmp-type-long ?s)
3310 (?n gnus-tmp-name ?s)
3311 (?d gnus-tmp-description ?s)
3313 (?l gnus-tmp-length ?d)
3314 (?e gnus-tmp-dots ?s)))
3316 (defvar gnus-mime-button-commands
3317 '((gnus-article-press-button "\r" "Toggle Display")
3318 (gnus-mime-view-part "v" "View Interactively...")
3319 (gnus-mime-view-part-as-type "t" "View As Type...")
3320 (gnus-mime-view-part-as-charset "C" "View As charset...")
3321 (gnus-mime-save-part "o" "Save...")
3322 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3323 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3324 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3325 (gnus-mime-internalize-part "E" "View Internally")
3326 (gnus-mime-externalize-part "e" "View Externally")
3327 (gnus-mime-pipe-part "|" "Pipe To Command...")
3328 (gnus-mime-action-on-part "." "Take action on the part")))
3330 (defun gnus-article-mime-part-status ()
3331 (if gnus-article-mime-handle-alist-1
3332 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3334 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3337 (defvar gnus-mime-button-map
3338 (let ((map (make-sparse-keymap)))
3339 (unless (>= (string-to-number emacs-version) 21)
3340 ;; XEmacs doesn't care.
3341 (set-keymap-parent map gnus-article-mode-map))
3342 (define-key map gnus-mouse-2 'gnus-article-push-button)
3343 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3344 (dolist (c gnus-mime-button-commands)
3345 (define-key map (cadr c) (car c)))
3348 (defun gnus-mime-button-menu (event)
3349 "Construct a context-sensitive menu of MIME commands."
3351 (save-window-excursion
3352 (let ((pos (event-start event)))
3353 (select-window (posn-window pos))
3354 (goto-char (posn-point pos))
3355 (gnus-article-check-buffer)
3356 (let ((response (x-popup-menu
3358 ("" ,@(mapcar (lambda (c)
3359 (cons (caddr c) (car c)))
3360 gnus-mime-button-commands))))))
3362 (call-interactively response))))))
3364 (defun gnus-mime-view-all-parts (&optional handles)
3365 "View all the MIME parts."
3367 (save-current-buffer
3368 (set-buffer gnus-article-buffer)
3369 (let ((handles (or handles gnus-article-mime-handles))
3370 (mail-parse-charset gnus-newsgroup-charset)
3371 (mail-parse-ignored-charsets
3372 (with-current-buffer gnus-summary-buffer
3373 gnus-newsgroup-ignored-charsets)))
3375 (mm-remove-parts handles)
3376 (goto-char (point-min))
3377 (or (search-forward "\n\n") (goto-char (point-max)))
3378 (let (buffer-read-only)
3379 (delete-region (point) (point-max))
3380 (mm-display-parts handles))))))
3382 (defun gnus-mime-save-part-and-strip ()
3383 "Save the MIME part under point then replace it with an external body."
3385 (gnus-article-check-buffer)
3386 (let* ((data (get-text-property (point) 'gnus-data))
3388 (handles gnus-article-mime-handles))
3389 (if (mm-multiple-handles gnus-article-mime-handles)
3390 (error "This function is not implemented"))
3391 (setq file (and data (mm-save-part data)))
3393 (with-current-buffer (mm-handle-buffer data)
3395 (insert "Content-Type: " (mm-handle-media-type data))
3396 (mml-insert-parameter-string (cdr (mm-handle-type data))
3399 (insert "Content-ID: " (message-make-message-id) "\n")
3400 (insert "Content-Transfer-Encoding: binary\n")
3403 (cdr (mm-make-handle nil
3404 `("message/external-body"
3405 (access-type . "LOCAL-FILE")
3407 (set-buffer gnus-summary-buffer)
3408 (gnus-article-edit-article
3411 (let ((mail-parse-charset (or gnus-article-charset
3412 ',gnus-newsgroup-charset))
3413 (mail-parse-ignored-charsets
3414 (or gnus-article-ignored-charsets
3415 ',gnus-newsgroup-ignored-charsets))
3416 (mbl mml-buffer-list))
3417 (setq mml-buffer-list nil)
3418 (insert-buffer gnus-original-article-buffer)
3419 (mime-to-mml ',handles)
3420 (setq gnus-article-mime-handles nil)
3421 (let ((mbl1 mml-buffer-list))
3422 (setq mml-buffer-list mbl)
3423 (set (make-local-variable 'mml-buffer-list) mbl1))
3424 ;; LOCAL argument of add-hook differs between GNU Emacs
3425 ;; and XEmacs. make-local-hook makes sure they are local.
3426 (make-local-hook 'kill-buffer-hook)
3427 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3428 `(lambda (no-highlight)
3429 (let ((mail-parse-charset (or gnus-article-charset
3430 ',gnus-newsgroup-charset))
3431 (message-options message-options)
3432 (message-options-set-recipient)
3433 (mail-parse-ignored-charsets
3434 (or gnus-article-ignored-charsets
3435 ',gnus-newsgroup-ignored-charsets)))
3437 (mml-destroy-buffers)
3438 (remove-hook 'kill-buffer-hook
3439 'mml-destroy-buffers t)
3440 (kill-local-variable 'mml-buffer-list))
3441 (gnus-summary-edit-article-done
3442 ,(or (mail-header-references gnus-current-headers) "")
3443 ,(gnus-group-read-only-p)
3444 ,gnus-summary-buffer no-highlight))))))
3446 (defun gnus-mime-save-part ()
3447 "Save the MIME part under point."
3449 (gnus-article-check-buffer)
3450 (let ((data (get-text-property (point) 'gnus-data)))
3452 (mm-save-part data))))
3454 (defun gnus-mime-pipe-part ()
3455 "Pipe the MIME part under point to a process."
3457 (gnus-article-check-buffer)
3458 (let ((data (get-text-property (point) 'gnus-data)))
3460 (mm-pipe-part data))))
3462 (defun gnus-mime-view-part ()
3463 "Interactively choose a viewing method for the MIME part under point."
3465 (gnus-article-check-buffer)
3466 (let ((data (get-text-property (point) 'gnus-data)))
3468 (setq gnus-article-mime-handles
3470 gnus-article-mime-handles (setq data (copy-sequence data))))
3471 (mm-interactively-view-part data))))
3473 (defun gnus-mime-view-part-as-type-internal ()
3474 (gnus-article-check-buffer)
3475 (let* ((name (mail-content-type-get
3476 (mm-handle-type (get-text-property (point) 'gnus-data))
3478 (def-type (and name (mm-default-file-encoding name))))
3479 (and def-type (cons def-type 0))))
3481 (defun gnus-mime-view-part-as-type (&optional mime-type)
3482 "Choose a MIME media type, and view the part as such."
3485 (setq mime-type (completing-read
3486 "View as MIME type: "
3487 (mapcar #'list (mailcap-mime-types))
3489 (gnus-mime-view-part-as-type-internal))))
3490 (gnus-article-check-buffer)
3491 (let ((handle (get-text-property (point) 'gnus-data)))
3494 (mm-make-handle (mm-handle-buffer handle)
3495 (cons mime-type (cdr (mm-handle-type handle)))
3496 (mm-handle-encoding handle)
3497 (mm-handle-undisplayer handle)
3498 (mm-handle-disposition handle)
3499 (mm-handle-description handle)
3501 (mm-handle-id handle)))
3502 (setq gnus-article-mime-handles
3503 (mm-merge-handles gnus-article-mime-handles handle))
3504 (gnus-mm-display-part handle))))
3506 (defun gnus-mime-copy-part (&optional handle)
3507 "Put the the MIME part under point into a new buffer."
3509 (gnus-article-check-buffer)
3510 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3511 (contents (and handle (mm-get-part handle)))
3513 (file-name-nondirectory
3515 (mail-content-type-get (mm-handle-type handle) 'name)
3516 (mail-content-type-get (mm-handle-type handle)
3519 (buffer (and base (generate-new-buffer base))))
3521 (switch-to-buffer buffer)
3523 ;; We do it this way to make `normal-mode' set the appropriate mode.
3526 (setq buffer-file-name (expand-file-name base))
3528 (setq buffer-file-name nil))
3529 (goto-char (point-min)))))
3531 (defun gnus-mime-inline-part (&optional handle arg)
3532 "Insert the MIME part under point into the current buffer."
3533 (interactive (list nil current-prefix-arg))
3534 (gnus-article-check-buffer)
3535 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3540 (if (and (not arg) (mm-handle-undisplayer handle))
3541 (mm-remove-part handle)
3542 (setq contents (mm-get-part handle))
3545 (setq charset (or (mail-content-type-get
3546 (mm-handle-type handle) 'charset)
3547 gnus-newsgroup-charset)))
3549 (if (mm-handle-undisplayer handle)
3550 (mm-remove-part handle))
3553 gnus-summary-show-article-charset-alist))
3554 (mm-read-coding-system "Charset: ")))))
3556 (mm-insert-inline handle
3558 (setq charset (mm-charset-to-coding-system
3560 (not (eq charset 'ascii)))
3561 (mm-decode-coding-string contents charset)
3565 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3566 "Insert the MIME part under point into the current buffer using the
3568 (interactive (list nil current-prefix-arg))
3569 (gnus-article-check-buffer)
3570 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3575 (if (mm-handle-undisplayer handle)
3576 (mm-remove-part handle))
3577 (let ((gnus-newsgroup-charset
3579 gnus-summary-show-article-charset-alist))
3580 (mm-read-coding-system "Charset: ")))
3581 (gnus-newsgroup-ignored-charsets 'gnus-all))
3582 (gnus-article-press-button)))))
3584 (defun gnus-mime-externalize-part (&optional handle)
3585 "View the MIME part under point with an external viewer."
3587 (gnus-article-check-buffer)
3588 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3589 (mm-user-display-methods nil)
3590 (mm-inlined-types nil)
3591 (mail-parse-charset gnus-newsgroup-charset)
3592 (mail-parse-ignored-charsets
3593 (save-excursion (set-buffer gnus-summary-buffer)
3594 gnus-newsgroup-ignored-charsets)))
3596 (if (mm-handle-undisplayer handle)
3597 (mm-remove-part handle)
3598 (mm-display-part handle)))))
3600 (defun gnus-mime-internalize-part (&optional handle)
3601 "View the MIME part under point with an internal viewer.
3602 If no internal viewer is available, use an external viewer."
3604 (gnus-article-check-buffer)
3605 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3606 (mm-inlined-types '(".*"))
3607 (mm-inline-large-images t)
3608 (mail-parse-charset gnus-newsgroup-charset)
3609 (mail-parse-ignored-charsets
3610 (save-excursion (set-buffer gnus-summary-buffer)
3611 gnus-newsgroup-ignored-charsets)))
3613 (if (mm-handle-undisplayer handle)
3614 (mm-remove-part handle)
3615 (mm-display-part handle)))))
3617 (defun gnus-mime-action-on-part (&optional action)
3618 "Do something with the MIME attachment at \(point\)."
3620 (list (completing-read "Action: " gnus-mime-action-alist)))
3621 (gnus-article-check-buffer)
3622 (let ((action-pair (assoc action gnus-mime-action-alist)))
3624 (funcall (cdr action-pair)))))
3626 (defun gnus-article-part-wrapper (n function)
3627 (save-current-buffer
3628 (set-buffer gnus-article-buffer)
3629 (when (> n (length gnus-article-mime-handle-alist))
3630 (error "No such part"))
3631 (gnus-article-goto-part n)
3632 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3633 (funcall function handle))))
3635 (defun gnus-article-pipe-part (n)
3636 "Pipe MIME part N, which is the numerical prefix."
3638 (gnus-article-part-wrapper n 'mm-pipe-part))
3640 (defun gnus-article-save-part (n)
3641 "Save MIME part N, which is the numerical prefix."
3643 (gnus-article-part-wrapper n 'mm-save-part))
3645 (defun gnus-article-interactively-view-part (n)
3646 "View MIME part N interactively, which is the numerical prefix."
3648 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3650 (defun gnus-article-copy-part (n)
3651 "Copy MIME part N, which is the numerical prefix."
3653 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3655 (defun gnus-article-view-part-as-charset (n)
3656 "Copy MIME part N, which is the numerical prefix."
3658 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3660 (defun gnus-article-externalize-part (n)
3661 "View MIME part N externally, which is the numerical prefix."
3663 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3665 (defun gnus-article-inline-part (n)
3666 "Inline MIME part N, which is the numerical prefix."
3668 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3670 (defun gnus-article-mime-match-handle-first (condition)
3672 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3673 (while (setq ihandle (pop alist))
3675 ((functionp condition)
3676 (funcall condition (cdr ihandle)))
3677 ((eq condition 'undisplayed)
3678 (not (or (mm-handle-undisplayer (cdr ihandle))
3679 (equal (mm-handle-media-type (cdr ihandle))
3680 "multipart/alternative"))))
3681 ((eq condition 'undisplayed-alternative)
3682 (not (mm-handle-undisplayer (cdr ihandle))))
3684 (gnus-article-goto-part (car ihandle))
3685 (or (not n) (< (car ihandle) n)))
3686 (setq n (car ihandle))))
3690 (defun gnus-article-view-part (&optional n)
3691 "View MIME part N, which is the numerical prefix."
3693 (save-current-buffer
3694 (set-buffer gnus-article-buffer)
3695 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3696 gnus-article-mime-match-handle-function)))
3697 (when (> n (length gnus-article-mime-handle-alist))
3698 (error "No such part"))
3699 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3700 (when (gnus-article-goto-part n)
3701 (if (equal (car handle) "multipart/alternative")
3702 (gnus-article-press-button)
3703 (when (eq (gnus-mm-display-part handle) 'internal)
3704 (gnus-set-window-start)))))))
3706 (defsubst gnus-article-mime-total-parts ()
3707 (if (bufferp (car gnus-article-mime-handles))
3709 (1- (length gnus-article-mime-handles))))
3711 (defun gnus-mm-display-part (handle)
3712 "Display HANDLE and fix MIME button."
3713 (let ((id (get-text-property (point) 'gnus-part))
3718 (let ((window (selected-window))
3719 (mail-parse-charset gnus-newsgroup-charset)
3720 (mail-parse-ignored-charsets
3721 (save-excursion (set-buffer gnus-summary-buffer)
3722 gnus-newsgroup-ignored-charsets)))
3725 (let ((win (gnus-get-buffer-window (current-buffer) t))
3728 (select-window win))
3731 (if (mm-handle-displayed-p handle)
3732 ;; This will remove the part.
3733 (mm-display-part handle)
3735 (narrow-to-region (point)
3736 (if (eobp) (point) (1+ (point))))
3737 (mm-display-part handle)
3738 ;; We narrow to the part itself and
3739 ;; then call the treatment functions.
3740 (goto-char (point-min))
3742 (narrow-to-region (point) (point-max))
3745 (gnus-article-mime-total-parts)
3746 (mm-handle-media-type handle)))))
3747 (if (window-live-p window)
3748 (select-window window)))))
3750 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3751 (gnus-insert-mime-button
3752 handle id (list (mm-handle-displayed-p handle)))
3753 (goto-char point))))
3755 (defun gnus-article-goto-part (n)
3756 "Go to MIME part N."
3757 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3759 (goto-char point))))
3761 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3762 (let ((gnus-tmp-name
3763 (or (mail-content-type-get (mm-handle-type handle) 'name)
3764 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3765 (mail-content-type-get (mm-handle-type handle) 'url)
3767 (gnus-tmp-type (mm-handle-media-type handle))
3768 (gnus-tmp-description
3769 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3772 (if (if displayed (car displayed)
3773 (mm-handle-displayed-p handle))
3775 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3777 gnus-tmp-type-long b e)
3778 (when (string-match ".*/" gnus-tmp-name)
3779 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3780 (setq gnus-tmp-type-long (concat gnus-tmp-type
3781 (and (not (equal gnus-tmp-name ""))
3782 (concat "; " gnus-tmp-name))))
3783 (unless (equal gnus-tmp-description "")
3784 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3789 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3790 `(keymap ,gnus-mime-button-map
3791 ,@(if (>= (string-to-number emacs-version) 21)
3793 (list 'local-map gnus-mime-button-map))
3794 gnus-callback gnus-mm-display-part
3795 gnus-part ,gnus-tmp-id
3796 article-type annotation
3799 (widget-convert-button
3802 :action 'gnus-widget-press-button
3803 :button-keymap gnus-mime-button-map
3805 (lambda (widget/window &optional overlay pos)
3806 ;; Needed to properly clear the message due to a bug in
3807 ;; wid-edit (XEmacs only).
3808 (if (boundp 'help-echo-owns-message)
3809 (setq help-echo-owns-message t))
3811 "%S: %s the MIME part; %S: more options"
3812 (aref gnus-mouse-2 0)
3813 ;; XEmacs will get a single widget arg; Emacs 21 will get
3814 ;; window, overlay, position.
3815 (if (mm-handle-displayed-p
3817 (with-current-buffer (gnus-overlay-buffer overlay)
3818 (widget-get (widget-at (gnus-overlay-start overlay))
3820 (widget-get widget/window :mime-handle)))
3822 (aref gnus-down-mouse-3 0))))))
3824 (defun gnus-widget-press-button (elems el)
3825 (goto-char (widget-get elems :from))
3826 (gnus-article-press-button))
3828 (defvar gnus-displaying-mime nil)
3830 (defun gnus-display-mime (&optional ihandles)
3831 "Display the MIME parts."
3833 (save-selected-window
3834 (let ((window (get-buffer-window gnus-article-buffer))
3837 (select-window window)
3838 ;; We have to do this since selecting the window
3839 ;; may change the point. So we set the window point.
3840 (set-window-point window point)))
3841 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3842 buffer-read-only handle name type b e display)
3843 (when (and (not ihandles)
3844 (not gnus-displaying-mime))
3845 ;; Top-level call; we clean up.
3846 (when gnus-article-mime-handles
3847 (mm-destroy-parts gnus-article-mime-handles)
3848 (setq gnus-article-mime-handle-alist nil));; A trick.
3849 (setq gnus-article-mime-handles handles)
3850 ;; We allow users to glean info from the handles.
3851 (when gnus-article-mime-part-function
3852 (gnus-mime-part-function handles)))
3854 (or (not (stringp (car handles)))
3857 (when (and (not ihandles)
3858 (not gnus-displaying-mime))
3859 ;; Clean up for mime parts.
3861 (delete-region (point) (point-max)))
3862 (let ((gnus-displaying-mime t))
3863 (gnus-mime-display-part handles)))
3866 (narrow-to-region (point) (point-max))
3867 (gnus-treat-article nil 1 1)
3870 ;; Highlight the headers.
3874 (narrow-to-region (point-min) (point))
3875 (gnus-treat-article 'head))))))))
3877 (defvar gnus-mime-display-multipart-as-mixed nil)
3878 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
3879 (defvar gnus-mime-display-multipart-related-as-mixed nil)
3881 (defun gnus-mime-display-part (handle)
3884 ((not (stringp (car handle)))
3885 (gnus-mime-display-single handle))
3886 ;; User-defined multipart
3887 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3888 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3890 ;; multipart/alternative
3891 ((and (equal (car handle) "multipart/alternative")
3892 (not (or gnus-mime-display-multipart-as-mixed
3893 gnus-mime-display-multipart-alternative-as-mixed)))
3894 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3895 (push (cons id handle) gnus-article-mime-handle-alist)
3896 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3897 ;; multipart/related
3898 ((and (equal (car handle) "multipart/related")
3899 (not (or gnus-mime-display-multipart-as-mixed
3900 gnus-mime-display-multipart-related-as-mixed)))
3901 ;;;!!!We should find the start part, but we just default
3902 ;;;!!!to the first part.
3903 ;;(gnus-mime-display-part (cadr handle))
3904 ;;;!!! Most multipart/related is an HTML message plus images.
3905 ;;;!!! Unfortunately we are unable to let W3 display those
3906 ;;;!!! included images, so we just display it as a mixed multipart.
3907 ;;(gnus-mime-display-mixed (cdr handle))
3908 ;;;!!! No, w3 can display everything just fine.
3909 (gnus-mime-display-part (cadr handle)))
3910 ((equal (car handle) "multipart/signed")
3911 (or (memq 'signed gnus-article-wash-types)
3912 (push 'signed gnus-article-wash-types))
3913 (gnus-mime-display-security handle))
3914 ((equal (car handle) "multipart/encrypted")
3915 (or (memq 'encrypted gnus-article-wash-types)
3916 (push 'encrypted gnus-article-wash-types))
3917 (gnus-mime-display-security handle))
3918 ;; Other multiparts are handled like multipart/mixed.
3920 (gnus-mime-display-mixed (cdr handle)))))
3922 (defun gnus-mime-part-function (handles)
3923 (if (stringp (car handles))
3924 (mapcar 'gnus-mime-part-function (cdr handles))
3925 (funcall gnus-article-mime-part-function handles)))
3927 (defun gnus-mime-display-mixed (handles)
3928 (mapcar 'gnus-mime-display-part handles))
3930 (defun gnus-mime-display-single (handle)
3931 (let ((type (mm-handle-media-type handle))
3932 (ignored gnus-ignored-mime-types)
3939 (when (string-match (pop ignored) type)
3940 (throw 'ignored nil)))
3941 (if (and (setq not-attachment
3942 (and (not (mm-inline-override-p handle))
3943 (or (not (mm-handle-disposition handle))
3944 (equal (car (mm-handle-disposition handle))
3946 (mm-attachment-override-p handle))))
3947 (mm-automatic-display-p handle)
3949 (mm-inlinable-p handle)
3950 (mm-inlined-p handle))
3951 (mm-automatic-external-display-p type)))
3953 (when (equal (mm-handle-media-supertype handle) "text")
3955 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3957 (push (cons id handle) gnus-article-mime-handle-alist)
3958 (when (or (not display)
3959 (not (gnus-unbuttonized-mime-type-p type)))
3960 ;(gnus-article-insert-newline)
3961 (gnus-insert-mime-button
3962 handle id (list (or display (and not-attachment text))))
3963 (gnus-article-insert-newline)
3964 ;(gnus-article-insert-newline)
3965 ;; Remember modify the number of forward lines.
3973 (let ((mail-parse-charset gnus-newsgroup-charset)
3974 (mail-parse-ignored-charsets
3975 (save-excursion (condition-case ()
3976 (set-buffer gnus-summary-buffer)
3978 gnus-newsgroup-ignored-charsets)))
3979 (mm-display-part handle t))
3980 (goto-char (point-max)))
3981 ((and text not-attachment)
3985 (gnus-article-insert-newline)
3986 (mm-insert-inline handle (mm-get-part handle))
3987 (goto-char (point-max))))
3991 (narrow-to-region beg (point))
3994 (gnus-article-mime-total-parts)
3995 (mm-handle-media-type handle)))))))))
3997 (defun gnus-unbuttonized-mime-type-p (type)
3998 "Say whether TYPE is to be unbuttonized."
3999 (unless gnus-inhibit-mime-unbuttonizing
4001 (let ((types gnus-unbuttonized-mime-types))
4003 (when (string-match (pop types) type)
4004 (throw 'found t)))))
4006 (let ((types gnus-buttonized-mime-types))
4008 (when (string-match (pop types) type)
4009 (throw 'found t)))))))))
4011 (defun gnus-article-insert-newline ()
4012 "Insert a newline, but mark it as undeletable."
4013 (gnus-put-text-property
4014 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4016 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4017 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4020 handle buffer-read-only from props begend not-pref)
4021 (save-window-excursion
4024 (narrow-to-region (car ibegend)
4027 (goto-char (car ibegend))
4030 (delete-region (point-min) (point-max))
4031 (mm-remove-parts handles))
4032 (setq begend (list (point-marker)))
4034 (unless (setq not-pref (cadr (member preferred ihandles)))
4035 (setq not-pref (car ihandles)))
4038 (not (gnus-unbuttonized-mime-type-p
4039 "multipart/alternative")))
4040 (gnus-add-text-properties
4043 (insert (format "%d. " id))
4047 (unless ,(not ibegend)
4048 (setq gnus-article-mime-handle-alist
4049 ',gnus-article-mime-handle-alist))
4050 (gnus-mime-display-alternative
4051 ',ihandles ',not-pref ',begend ,id))
4052 ,@(if (>= (string-to-number emacs-version) 21)
4053 nil ;; XEmacs doesn't care
4054 (list 'local-map gnus-mime-button-map))
4055 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4056 face ,gnus-article-button-face
4057 keymap ,gnus-mime-button-map
4060 (widget-convert-button 'link from (point)
4061 :action 'gnus-widget-press-button
4062 :button-keymap gnus-widget-button-keymap)
4064 (while (setq handle (pop handles))
4065 (gnus-add-text-properties
4068 (insert (format "(%c) %-18s"
4069 (if (equal handle preferred) ?* ? )
4070 (mm-handle-media-type handle)))
4074 (unless ,(not ibegend)
4075 (setq gnus-article-mime-handle-alist
4076 ',gnus-article-mime-handle-alist))
4077 (gnus-mime-display-alternative
4078 ',ihandles ',handle ',begend ,id))
4079 ,@(if (>= (string-to-number emacs-version) 21)
4080 nil ;; XEmacs doesn't care
4081 (list 'local-map gnus-mime-button-map))
4082 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4083 face ,gnus-article-button-face
4084 keymap ,gnus-mime-button-map
4087 (widget-convert-button 'link from (point)
4088 :action 'gnus-widget-press-button
4089 :button-keymap gnus-widget-button-keymap)
4093 (if (stringp (car preferred))
4094 (gnus-display-mime preferred)
4095 (let ((mail-parse-charset gnus-newsgroup-charset)
4096 (mail-parse-ignored-charsets
4097 (save-excursion (set-buffer gnus-summary-buffer)
4098 gnus-newsgroup-ignored-charsets)))
4099 (mm-display-part preferred)
4103 (narrow-to-region (car begend) (point-max))
4105 nil (length gnus-article-mime-handle-alist)
4106 (gnus-article-mime-total-parts)
4107 (mm-handle-media-type handle))))))
4108 (goto-char (point-max))
4109 (setcdr begend (point-marker)))))
4111 (goto-char point))))
4113 (defconst gnus-article-wash-status-strings
4114 (let ((alist '((cite "c" "Possible hidden citation text"
4115 " " "All citation text visible")
4116 (headers "h" "Hidden headers"
4117 " " "All headers visible.")
4118 (pgp "p" "Encrypted or signed message status hidden"
4119 " " "No hidden encryption nor digital signature status")
4120 (signature "s" "Signature has been hidden"
4121 " " "Signature is visible")
4122 (overstrike "o" "Overstrike (^H) characters applied"
4123 " " "No overstrike characters applied")
4124 (emphasis "e" "/*_Emphasis_*/ characters applied"
4125 " " "No /*_emphasis_*/ characters applied")))
4127 (dolist (entry alist result)
4128 (let ((key (nth 0 entry))
4129 (on (copy-sequence (nth 1 entry)))
4130 (on-help (nth 2 entry))
4131 (off (copy-sequence (nth 3 entry)))
4132 (off-help (nth 4 entry)))
4133 (put-text-property 0 1 'help-echo on-help on)
4134 (put-text-property 0 1 'help-echo off-help off)
4135 (push (list key on off) result))))
4136 "Alist of strings describing wash status in the mode line.
4137 Each entry has the form (KEY ON OF), where the KEY is a symbol
4138 representing the particular washing function, ON is the string to use
4139 in the article mode line when the washing function is active, and OFF
4140 is the string to use when it is inactive.")
4142 (defun gnus-gnus-article-wash-status-entry (key value)
4143 (let ((entry (assoc key gnus-article-wash-status-strings)))
4144 (if value (nth 1 entry) (nth 2 entry))))
4146 (defun gnus-article-wash-status ()
4147 "Return a string which display status of article washing."
4149 (set-buffer gnus-article-buffer)
4150 (let ((cite (memq 'cite gnus-article-wash-types))
4151 (headers (memq 'headers gnus-article-wash-types))
4152 (boring (memq 'boring-headers gnus-article-wash-types))
4153 (pgp (memq 'pgp gnus-article-wash-types))
4154 (pem (memq 'pem gnus-article-wash-types))
4155 (signed (memq 'signed gnus-article-wash-types))
4156 (encrypted (memq 'encrypted gnus-article-wash-types))
4157 (signature (memq 'signature gnus-article-wash-types))
4158 (overstrike (memq 'overstrike gnus-article-wash-types))
4159 (emphasis (memq 'emphasis gnus-article-wash-types)))
4160 (concat (gnus-gnus-article-wash-status-entry 'cite cite)
4161 (gnus-gnus-article-wash-status-entry 'headers
4162 (or headers boring))
4163 (gnus-gnus-article-wash-status-entry
4164 'pgp (or pgp pem signed encrypted))
4165 (gnus-gnus-article-wash-status-entry 'signature signature)
4166 (gnus-gnus-article-wash-status-entry 'overstrike overstrike)
4167 (gnus-gnus-article-wash-status-entry 'emphasis emphasis)))))
4169 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4171 (defun gnus-article-maybe-hide-headers ()
4172 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4173 Provided for backwards compatibility."
4174 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4175 (not (save-excursion (set-buffer gnus-summary-buffer)
4176 gnus-have-all-headers)))
4177 (not gnus-inhibit-hiding))
4178 (gnus-article-hide-headers)))
4182 (defun gnus-output-to-file (file-name)
4183 "Append the current article to a file named FILE-NAME."
4184 (let ((artbuf (current-buffer)))
4186 (insert-buffer-substring artbuf)
4187 ;; Append newline at end of the buffer as separator, and then
4189 (goto-char (point-max))
4191 (let ((file-name-coding-system nnmail-pathname-coding-system))
4192 (mm-append-to-file (point-min) (point-max) file-name))
4195 (defun gnus-narrow-to-page (&optional arg)
4196 "Narrow the article buffer to a page.
4197 If given a numerical ARG, move forward ARG pages."
4199 (setq arg (if arg (prefix-numeric-value arg) 0))
4201 (set-buffer gnus-article-buffer)
4202 (goto-char (point-min))
4204 ;; Remove any old next/prev buttons.
4205 (when (gnus-visual-p 'page-marker)
4206 (let ((buffer-read-only nil))
4207 (gnus-remove-text-with-property 'gnus-prev)
4208 (gnus-remove-text-with-property 'gnus-next)))
4211 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4213 (re-search-forward page-delimiter nil 'move arg)))
4214 (goto-char (match-end 0)))
4217 (if (re-search-forward page-delimiter nil 'move)
4220 (when (and (gnus-visual-p 'page-marker)
4221 (not (= (point-min) 1)))
4223 (goto-char (point-min))
4224 (gnus-insert-prev-page-button)))
4225 (when (and (gnus-visual-p 'page-marker)
4226 (< (+ (point-max) 2) (buffer-size)))
4228 (goto-char (point-max))
4229 (gnus-insert-next-page-button)))))
4231 ;; Article mode commands
4233 (defun gnus-article-goto-next-page ()
4234 "Show the next page of the article."
4236 (when (gnus-article-next-page)
4237 (goto-char (point-min))
4238 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4240 (defun gnus-article-goto-prev-page ()
4241 "Show the next page of the article."
4243 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4244 (gnus-article-prev-page nil)))
4246 (defun gnus-article-next-page (&optional lines)
4247 "Show the next page of the current article.
4248 If end of article, return non-nil. Otherwise return nil.
4249 Argument LINES specifies lines to be scrolled up."
4251 (move-to-window-line -1)
4254 (and (pos-visible-in-window-p) ;Not continuation line.
4256 ;; Nothing in this page.
4257 (if (or (not gnus-page-broken)
4260 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4262 (gnus-narrow-to-page 1) ;Go to next page.
4264 ;; More in this page.
4265 (let ((scroll-in-place nil))
4269 ;; Long lines may cause an end-of-buffer error.
4270 (goto-char (point-max)))))
4271 (move-to-window-line 0)
4274 (defun gnus-article-prev-page (&optional lines)
4275 "Show previous page of current article.
4276 Argument LINES specifies lines to be scrolled down."
4278 (move-to-window-line 0)
4279 (if (and gnus-page-broken
4281 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4283 (gnus-narrow-to-page -1) ;Go to previous page.
4284 (goto-char (point-max))
4286 (let ((scroll-in-place nil))
4290 (beginning-of-buffer
4291 (goto-char (point-min))))
4292 (move-to-window-line 0)))))
4294 (defun gnus-article-refer-article ()
4295 "Read article specified by message-id around point."
4297 (let ((point (point)))
4298 (search-forward ">" nil t) ;Move point to end of "<....>".
4299 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4300 (let ((message-id (match-string 1)))
4302 (set-buffer gnus-summary-buffer)
4303 (gnus-summary-refer-article message-id))
4305 (error "No references around point"))))
4307 (defun gnus-article-show-summary ()
4308 "Reconfigure windows to show summary buffer."
4310 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4311 (error "There is no summary buffer for this article buffer")
4312 (gnus-article-set-globals)
4313 (gnus-configure-windows 'article)
4314 (gnus-summary-goto-subject gnus-current-article)
4315 (gnus-summary-position-point)))
4317 (defun gnus-article-describe-briefly ()
4318 "Describe article mode commands briefly."
4320 (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")))
4322 (defun gnus-article-summary-command ()
4323 "Execute the last keystroke in the summary buffer."
4325 (let ((obuf (current-buffer))
4326 (owin (current-window-configuration))
4328 (switch-to-buffer gnus-article-current-summary 'norecord)
4329 (setq func (lookup-key (current-local-map) (this-command-keys)))
4330 (call-interactively func)
4332 (set-window-configuration owin)
4333 (set-window-point (get-buffer-window (current-buffer)) (point))))
4335 (defun gnus-article-summary-command-nosave ()
4336 "Execute the last keystroke in the summary buffer."
4339 (pop-to-buffer gnus-article-current-summary 'norecord)
4340 (setq func (lookup-key (current-local-map) (this-command-keys)))
4341 (call-interactively func)))
4343 (defun gnus-article-check-buffer ()
4344 "Beep if not in an article buffer."
4345 (unless (equal major-mode 'gnus-article-mode)
4346 (error "Command invoked outside of a Gnus article buffer")))
4348 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4349 "Read a summary buffer key sequence and execute it from the article buffer."
4351 (gnus-article-check-buffer)
4353 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4354 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4355 "=" "^" "\M-^" "|"))
4361 '("n" "Gn" "p" "Gp"))
4364 (set-buffer gnus-article-current-summary)
4365 (let (gnus-pick-mode)
4366 (push (or key last-command-event) unread-command-events)
4367 (setq keys (if (featurep 'xemacs)
4368 (events-to-keys (read-key-sequence nil))
4369 (read-key-sequence nil)))))
4373 (if (or (member keys nosaves)
4374 (member keys nosave-but-article)
4375 (member keys nosave-in-article))
4377 (save-window-excursion
4378 (pop-to-buffer gnus-article-current-summary 'norecord)
4379 ;; We disable the pick minor mode commands.
4380 (let (gnus-pick-mode)
4381 (setq func (lookup-key (current-local-map) keys))))
4385 (unless (member keys nosave-in-article)
4386 (set-buffer gnus-article-current-summary))
4387 (call-interactively func)
4388 (setq new-sum-point (point)))
4389 (when (member keys nosave-but-article)
4390 (pop-to-buffer gnus-article-buffer 'norecord)))
4391 ;; These commands should restore window configuration.
4392 (let ((obuf (current-buffer))
4393 (owin (current-window-configuration))
4395 (summary gnus-article-current-summary)
4396 func in-buffer selected)
4397 (if not-restore-window
4398 (pop-to-buffer summary 'norecord)
4399 (switch-to-buffer summary 'norecord))
4400 (setq in-buffer (current-buffer))
4401 ;; We disable the pick minor mode commands.
4402 (if (and (setq func (let (gnus-pick-mode)
4403 (lookup-key (current-local-map) keys)))
4406 (call-interactively func)
4407 (setq new-sum-point (point))
4408 (when (eq in-buffer (current-buffer))
4409 (setq selected (gnus-summary-select-article))
4411 (unless not-restore-window
4412 (set-window-configuration owin))
4413 (when (eq selected 'old)
4415 (set-window-start (get-buffer-window (current-buffer))
4417 (set-window-point (get-buffer-window (current-buffer))
4419 (let ((win (get-buffer-window gnus-article-current-summary)))
4421 (set-window-point win new-sum-point)))) )
4422 (switch-to-buffer gnus-article-buffer)
4425 (defun gnus-article-describe-key (key)
4426 "Display documentation of the function invoked by KEY. KEY is a string."
4427 (interactive "kDescribe key: ")
4428 (gnus-article-check-buffer)
4429 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4431 (set-buffer gnus-article-current-summary)
4432 (let (gnus-pick-mode)
4433 (if (featurep 'xemacs)
4435 (push (elt key 0) unread-command-events)
4436 (setq key (events-to-keys
4437 (read-key-sequence "Describe key: "))))
4438 (setq unread-command-events
4440 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4441 (string-to-list key)))
4442 (setq key (read-key-sequence "Describe key: "))))
4444 (describe-key key)))
4446 (defun gnus-article-describe-key-briefly (key &optional insert)
4447 "Display documentation of the function invoked by KEY. KEY is a string."
4448 (interactive "kDescribe key: \nP")
4449 (gnus-article-check-buffer)
4450 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4452 (set-buffer gnus-article-current-summary)
4453 (let (gnus-pick-mode)
4454 (if (featurep 'xemacs)
4456 (push (elt key 0) unread-command-events)
4457 (setq key (events-to-keys
4458 (read-key-sequence "Describe key: "))))
4459 (setq unread-command-events
4461 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4462 (string-to-list key)))
4463 (setq key (read-key-sequence "Describe key: "))))
4464 (describe-key-briefly key insert))
4465 (describe-key-briefly key insert)))
4467 (defun gnus-article-hide (&optional arg force)
4468 "Hide all the gruft in the current article.
4469 This means that PGP stuff, signatures, cited text and (some)
4470 headers will be hidden.
4471 If given a prefix, show the hidden text instead."
4472 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4473 (gnus-article-hide-headers arg)
4474 (gnus-article-hide-list-identifiers arg)
4475 (gnus-article-hide-pgp arg)
4476 (gnus-article-hide-citation-maybe arg force)
4477 (gnus-article-hide-signature arg))
4479 (defun gnus-article-maybe-highlight ()
4480 "Do some article highlighting if article highlighting is requested."
4481 (when (gnus-visual-p 'article-highlight 'highlight)
4482 (gnus-article-highlight-some)))
4484 (defun gnus-check-group-server ()
4485 ;; Make sure the connection to the server is alive.
4486 (unless (gnus-server-opened
4487 (gnus-find-method-for-group gnus-newsgroup-name))
4488 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4489 (gnus-request-group gnus-newsgroup-name t)))
4491 (defun gnus-request-article-this-buffer (article group)
4492 "Get an article and insert it into this buffer."
4493 (let (do-update-line sparse-header)
4497 (gnus-kill-all-overlays)
4498 (setq group (or group gnus-newsgroup-name))
4500 ;; Using `gnus-request-article' directly will insert the article into
4501 ;; `nntp-server-buffer' - so we'll save some time by not having to
4502 ;; copy it from the server buffer into the article buffer.
4504 ;; We only request an article by message-id when we do not have the
4505 ;; headers for it, so we'll have to get those.
4506 (when (stringp article)
4507 (gnus-read-header article))
4509 ;; If the article number is negative, that means that this article
4510 ;; doesn't belong in this newsgroup (possibly), so we find its
4511 ;; message-id and request it by id instead of number.
4512 (when (and (numberp article)
4514 (get-buffer gnus-summary-buffer)
4515 (gnus-buffer-exists-p gnus-summary-buffer))
4517 (set-buffer gnus-summary-buffer)
4518 (let ((header (gnus-summary-article-header article)))
4521 ((memq article gnus-newsgroup-sparse)
4522 ;; This is a sparse gap article.
4523 (setq do-update-line article)
4524 (setq article (mail-header-id header))
4525 (setq sparse-header (gnus-read-header article))
4526 (setq gnus-newsgroup-sparse
4527 (delq article gnus-newsgroup-sparse)))
4529 ;; It's a real article.
4530 (setq article (mail-header-id header)))
4532 ;; It is an extracted pseudo-article.
4533 (setq article 'pseudo)
4534 (gnus-request-pseudo-article header))))
4536 (let ((method (gnus-find-method-for-group
4537 gnus-newsgroup-name)))
4538 (when (and (eq (car method) 'nneething)
4540 (let ((dir (expand-file-name
4541 (mail-header-subject header)
4542 (file-name-as-directory
4543 (or (cadr (assq 'nneething-address method))
4545 (when (file-directory-p dir)
4546 (setq article 'nneething)
4547 (gnus-group-enter-directory dir))))))))
4550 ;; Refuse to select canceled articles.
4551 ((and (numberp article)
4553 (get-buffer gnus-summary-buffer)
4554 (gnus-buffer-exists-p gnus-summary-buffer)
4555 (eq (cdr (save-excursion
4556 (set-buffer gnus-summary-buffer)
4557 (assq article gnus-newsgroup-reads)))
4558 gnus-canceled-mark))
4560 ;; We first check `gnus-original-article-buffer'.
4561 ((and (get-buffer gnus-original-article-buffer)
4564 (set-buffer gnus-original-article-buffer)
4565 (and (equal (car gnus-original-article) group)
4566 (eq (cdr gnus-original-article) article))))
4567 (insert-buffer-substring gnus-original-article-buffer)
4569 ;; Check the backlog.
4570 ((and gnus-keep-backlog
4571 (gnus-backlog-request-article group article (current-buffer)))
4573 ;; Check asynchronous pre-fetch.
4574 ((gnus-async-request-fetched-article group article (current-buffer))
4575 (gnus-async-prefetch-next group article gnus-summary-buffer)
4576 (when (and (numberp article) gnus-keep-backlog)
4577 (gnus-backlog-enter-article group article (current-buffer)))
4580 ((and gnus-use-cache
4582 (gnus-cache-request-article article group))
4584 ;; Get the article and put into the article buffer.
4585 ((or (stringp article)
4587 (let ((gnus-override-method gnus-override-method)
4588 (methods (and (stringp article)
4589 gnus-refer-article-method))
4591 (buffer-read-only nil))
4592 (if (or (not (listp methods))
4593 (and (symbolp (car methods))
4594 (assq (car methods) nnoo-definition-alist)))
4595 (setq methods (list methods)))
4596 (when (and (null gnus-override-method)
4598 (setq gnus-override-method (pop methods)))
4600 (when (eq gnus-override-method 'current)
4601 (setq gnus-override-method
4602 (with-current-buffer gnus-summary-buffer
4603 gnus-current-select-method)))
4605 (gnus-kill-all-overlays)
4606 (let ((gnus-newsgroup-name group))
4607 (gnus-check-group-server))
4608 (when (gnus-request-article article group (current-buffer))
4609 (when (numberp article)
4610 (gnus-async-prefetch-next group article
4611 gnus-summary-buffer)
4612 (when gnus-keep-backlog
4613 (gnus-backlog-enter-article
4614 group article (current-buffer))))
4615 (setq result 'article))
4618 (setq gnus-override-method (pop methods))
4619 (setq result 'done))))
4620 (and (eq result 'article) 'article)))
4624 ;; Associate this article with the current summary buffer.
4625 (setq gnus-article-current-summary gnus-summary-buffer)
4627 ;; Take the article from the original article buffer
4628 ;; and place it in the buffer it's supposed to be in.
4629 (when (and (get-buffer gnus-article-buffer)
4630 (equal (buffer-name (current-buffer))
4631 (buffer-name (get-buffer gnus-article-buffer))))
4633 (if (get-buffer gnus-original-article-buffer)
4634 (set-buffer gnus-original-article-buffer)
4635 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4636 (buffer-disable-undo)
4637 (setq major-mode 'gnus-original-article-mode)
4638 (setq buffer-read-only t))
4639 (let (buffer-read-only)
4641 (insert-buffer-substring gnus-article-buffer))
4642 (setq gnus-original-article (cons group article)))
4645 (run-hooks 'gnus-article-decode-hook)
4646 ;; Mark article as decoded or not.
4647 (setq gnus-article-decoded-p gnus-article-decode-hook))
4649 ;; Update sparse articles.
4650 (when (and do-update-line
4651 (or (numberp article)
4653 (let ((buf (current-buffer)))
4654 (set-buffer gnus-summary-buffer)
4655 (gnus-summary-update-article do-update-line sparse-header)
4656 (gnus-summary-goto-subject do-update-line nil t)
4657 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4659 (set-buffer buf))))))
4665 (defcustom gnus-article-edit-mode-hook nil
4666 "Hook run in article edit mode buffers."
4667 :group 'gnus-article-various
4670 (defvar gnus-article-edit-done-function nil)
4672 (defvar gnus-article-edit-mode-map nil)
4674 ;; Should we be using derived.el for this?
4675 (unless gnus-article-edit-mode-map
4676 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4677 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4679 (gnus-define-keys gnus-article-edit-mode-map
4680 "\C-c\C-c" gnus-article-edit-done
4681 "\C-c\C-k" gnus-article-edit-exit)
4683 (gnus-define-keys (gnus-article-edit-wash-map
4684 "\C-c\C-w" gnus-article-edit-mode-map)
4685 "f" gnus-article-edit-full-stops))
4687 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4688 "Major mode for editing articles.
4689 This is an extended text-mode.
4691 \\{gnus-article-edit-mode-map}"
4692 (make-local-variable 'gnus-article-edit-done-function)
4693 (make-local-variable 'gnus-prev-winconf)
4694 (set (make-local-variable 'font-lock-defaults)
4695 '(message-font-lock-keywords t))
4696 (setq buffer-read-only nil)
4697 (buffer-enable-undo)
4700 (defun gnus-article-edit (&optional force)
4701 "Edit the current article.
4702 This will have permanent effect only in mail groups.
4703 If FORCE is non-nil, allow editing of articles even in read-only
4706 (when (and (not force)
4707 (gnus-group-read-only-p))
4708 (error "The current newsgroup does not support article editing"))
4709 (gnus-article-date-original)
4710 (gnus-article-edit-article
4712 `(lambda (no-highlight)
4714 (gnus-summary-edit-article-done
4715 ,(or (mail-header-references gnus-current-headers) "")
4716 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4718 (defun gnus-article-edit-article (start-func exit-func)
4719 "Start editing the contents of the current article buffer."
4720 (let ((winconf (current-window-configuration)))
4721 (set-buffer gnus-article-buffer)
4722 (gnus-article-edit-mode)
4723 (funcall start-func)
4724 (set-buffer-modified-p nil)
4725 (gnus-configure-windows 'edit-article)
4726 (setq gnus-article-edit-done-function exit-func)
4727 (setq gnus-prev-winconf winconf)
4728 (gnus-message 6 "C-c C-c to end edits")))
4730 (defun gnus-article-edit-done (&optional arg)
4731 "Update the article edits and exit."
4733 (let ((func gnus-article-edit-done-function)
4734 (buf (current-buffer))
4735 (start (window-start)))
4736 ;; We remove all text props from the article buffer.
4738 (buffer-substring-no-properties (point-min) (point-max)))
4742 (let ((winconf gnus-prev-winconf))
4744 (set-window-configuration winconf)
4745 ;; Tippy-toe some to make sure that point remains where it was.
4746 (save-current-buffer
4748 (set-window-start (get-buffer-window (current-buffer)) start)
4752 (let ((buffer-read-only nil))
4754 ;; The cache and backlog have to be flushed somewhat.
4755 (when gnus-keep-backlog
4756 (gnus-backlog-remove-article
4757 (car gnus-article-current) (cdr gnus-article-current)))
4758 ;; Flush original article as well.
4760 (when (get-buffer gnus-original-article-buffer)
4761 (set-buffer gnus-original-article-buffer)
4762 (setq gnus-original-article nil)))
4763 (when gnus-use-cache
4764 (gnus-cache-update-article
4765 (car gnus-article-current) (cdr gnus-article-current))))
4767 (set-window-start (get-buffer-window buf) start)
4768 (set-window-point (get-buffer-window buf) (point))))
4770 (defun gnus-article-edit-exit ()
4771 "Exit the article editing without updating."
4773 (when (or (not (buffer-modified-p))
4774 (yes-or-no-p "Article modified; kill anyway? "))
4775 (let ((curbuf (current-buffer))
4777 (window-start (window-start)))
4779 (if (gnus-buffer-live-p gnus-original-article-buffer)
4780 (insert-buffer gnus-original-article-buffer))
4781 (let ((winconf gnus-prev-winconf))
4783 (set-window-configuration winconf)
4784 ;; Tippy-toe some to make sure that point remains where it was.
4785 (save-current-buffer
4787 (set-window-start (get-buffer-window (current-buffer)) window-start)
4790 (defun gnus-article-edit-full-stops ()
4791 "Interactively repair spacing at end of sentences."
4794 (goto-char (point-min))
4795 (search-forward-regexp "^$" nil t)
4796 (let ((case-fold-search nil))
4797 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4800 ;;; Article highlights
4803 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4805 ;;; Internal Variables:
4807 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4808 "Regular expression that matches URLs."
4809 :group 'gnus-article-buttons
4812 (defcustom gnus-button-alist
4813 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4814 0 t gnus-button-handle-news 3)
4815 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
4816 gnus-button-handle-news 2)
4817 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4819 gnus-button-fetch-group 4)
4820 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4821 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4822 t gnus-button-message-id 3)
4823 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4824 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
4825 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4827 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
4828 gnus-button-handle-info 2)
4829 ;; This is how URLs _should_ be embedded in text...
4830 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4832 (,gnus-button-url-regexp 0 t browse-url 0))
4833 "*Alist of regexps matching buttons in article bodies.
4835 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4836 REGEXP: is the string matching text around the button,
4837 BUTTON: is the number of the regexp grouping actually matching the button,
4838 FORM: is a lisp expression which must eval to true for the button to
4840 CALLBACK: is the function to call when the user push this button, and each
4841 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4843 CALLBACK can also be a variable, in that case the value of that
4844 variable it the real callback function."
4845 :group 'gnus-article-buttons
4846 :type '(repeat (list regexp
4847 (integer :tag "Button")
4849 (function :tag "Callback")
4852 (integer :tag "Regexp group")))))
4854 (defcustom gnus-header-button-alist
4855 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
4856 0 t gnus-button-message-id 0)
4857 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4858 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4859 0 t gnus-button-mailto 0)
4860 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4861 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4862 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4863 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4864 gnus-button-message-id 3))
4865 "*Alist of headers and regexps to match buttons in article heads.
4867 This alist is very similar to `gnus-button-alist', except that each
4868 alist has an additional HEADER element first in each entry:
4870 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4872 HEADER is a regexp to match a header. For a fuller explanation, see
4873 `gnus-button-alist'."
4874 :group 'gnus-article-buttons
4875 :group 'gnus-article-headers
4876 :type '(repeat (list (regexp :tag "Header")
4878 (integer :tag "Button")
4880 (function :tag "Callback")
4883 (integer :tag "Regexp group")))))
4885 (defvar gnus-button-regexp nil)
4886 (defvar gnus-button-marker-list nil)
4887 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4889 (defvar gnus-button-last nil)
4890 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4894 (defun gnus-article-push-button (event)
4895 "Check text under the mouse pointer for a callback function.
4896 If the text under the mouse pointer has a `gnus-callback' property,
4897 call it with the value of the `gnus-data' text property."
4899 (set-buffer (window-buffer (posn-window (event-start event))))
4900 (let* ((pos (posn-point (event-start event)))
4901 (data (get-text-property pos 'gnus-data))
4902 (fun (get-text-property pos 'gnus-callback)))
4905 (funcall fun data))))
4907 (defun gnus-article-press-button ()
4908 "Check text at point for a callback function.
4909 If the text at point has a `gnus-callback' property,
4910 call it with the value of the `gnus-data' text property."
4912 (let* ((data (get-text-property (point) 'gnus-data))
4913 (fun (get-text-property (point) 'gnus-callback)))
4915 (funcall fun data))))
4917 (defun gnus-article-highlight (&optional force)
4918 "Highlight current article.
4919 This function calls `gnus-article-highlight-headers',
4920 `gnus-article-highlight-citation',
4921 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4922 do the highlighting. See the documentation for those functions."
4923 (interactive (list 'force))
4924 (gnus-article-highlight-headers)
4925 (gnus-article-highlight-citation force)
4926 (gnus-article-highlight-signature)
4927 (gnus-article-add-buttons force)
4928 (gnus-article-add-buttons-to-head))
4930 (defun gnus-article-highlight-some (&optional force)
4931 "Highlight current article.
4932 This function calls `gnus-article-highlight-headers',
4933 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4934 do the highlighting. See the documentation for those functions."
4935 (interactive (list 'force))
4936 (gnus-article-highlight-headers)
4937 (gnus-article-highlight-signature)
4938 (gnus-article-add-buttons))
4940 (defun gnus-article-highlight-headers ()
4941 "Highlight article headers as specified by `gnus-header-face-alist'."
4944 (set-buffer gnus-article-buffer)
4946 (let ((alist gnus-header-face-alist)
4947 (buffer-read-only nil)
4948 (case-fold-search t)
4949 (inhibit-point-motion-hooks t)
4950 entry regexp header-face field-face from hpoints fpoints)
4951 (article-narrow-to-head)
4952 (while (setq entry (pop alist))
4953 (goto-char (point-min))
4954 (setq regexp (concat "^\\("
4955 (if (string-equal "" (nth 0 entry))
4959 header-face (nth 1 entry)
4960 field-face (nth 2 entry))
4961 (while (and (re-search-forward regexp nil t)
4965 (unless (search-forward ":" nil t)
4967 (when (and header-face
4968 (not (memq (point) hpoints)))
4969 (push (point) hpoints)
4970 (gnus-put-text-property from (point) 'face header-face))
4971 (when (and field-face
4972 (not (memq (setq from (point)) fpoints)))
4974 (if (re-search-forward "^[^ \t]" nil t)
4976 (goto-char (point-max)))
4977 (gnus-put-text-property from (point) 'face field-face))))))))
4979 (defun gnus-article-highlight-signature ()
4980 "Highlight the signature in an article.
4981 It does this by highlighting everything after
4982 `gnus-signature-separator' using `gnus-signature-face'."
4985 (set-buffer gnus-article-buffer)
4986 (let ((buffer-read-only nil)
4987 (inhibit-point-motion-hooks t))
4989 (when (and gnus-signature-face
4990 (gnus-article-narrow-to-signature))
4991 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4992 'face gnus-signature-face)
4994 (gnus-article-search-signature)
4995 (let ((start (match-beginning 0))
4996 (end (set-marker (make-marker) (1+ (match-end 0)))))
4997 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5000 (defun gnus-button-in-region-p (b e prop)
5001 "Say whether PROP exists in the region."
5002 (text-property-not-all b e prop nil))
5004 (defun gnus-article-add-buttons (&optional force)
5005 "Find external references in the article and make buttons of them.
5006 \"External references\" are things like Message-IDs and URLs, as
5007 specified by `gnus-button-alist'."
5008 (interactive (list 'force))
5010 (set-buffer gnus-article-buffer)
5011 (let ((buffer-read-only nil)
5012 (inhibit-point-motion-hooks t)
5013 (case-fold-search t)
5014 (alist gnus-button-alist)
5016 ;; Remove all old markers.
5017 (let (marker entry new-list)
5018 (while (setq marker (pop gnus-button-marker-list))
5019 (if (or (< marker (point-min)) (>= marker (point-max)))
5020 (push marker new-list)
5022 (when (setq entry (gnus-button-entry))
5023 (put-text-property (match-beginning (nth 1 entry))
5024 (match-end (nth 1 entry))
5025 'gnus-callback nil))
5026 (set-marker marker nil)))
5027 (setq gnus-button-marker-list new-list))
5028 ;; We skip the headers.
5031 (while (setq entry (pop alist))
5032 (setq regexp (car entry))
5034 (while (re-search-forward regexp nil t)
5035 (let* ((start (and entry (match-beginning (nth 1 entry))))
5036 (end (and entry (match-end (nth 1 entry))))
5037 (from (match-beginning 0)))
5038 (when (and (or (eq t (nth 2 entry))
5039 (eval (nth 2 entry)))
5040 (not (gnus-button-in-region-p
5041 start end 'gnus-callback)))
5042 ;; That optional form returned non-nil, so we add the
5044 (gnus-article-add-button
5045 start end 'gnus-button-push
5046 (car (push (set-marker (make-marker) from)
5047 gnus-button-marker-list))))))))))
5049 ;; Add buttons to the head of an article.
5050 (defun gnus-article-add-buttons-to-head ()
5051 "Add buttons to the head of the article."
5054 (set-buffer gnus-article-buffer)
5056 (let ((buffer-read-only nil)
5057 (inhibit-point-motion-hooks t)
5058 (case-fold-search t)
5059 (alist gnus-header-button-alist)
5061 (article-narrow-to-head)
5063 ;; Each alist entry.
5064 (setq entry (car alist)
5066 (goto-char (point-min))
5067 (while (re-search-forward (car entry) nil t)
5068 ;; Each header matching the entry.
5069 (setq beg (match-beginning 0))
5070 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5071 (match-beginning 0))
5074 (while (re-search-forward (nth 1 entry) end t)
5075 ;; Each match within a header.
5076 (let* ((entry (cdr entry))
5077 (start (match-beginning (nth 1 entry)))
5078 (end (match-end (nth 1 entry)))
5079 (form (nth 2 entry)))
5080 (goto-char (match-end 0))
5082 (gnus-article-add-button
5083 start end (nth 3 entry)
5084 (buffer-substring (match-beginning (nth 4 entry))
5085 (match-end (nth 4 entry)))))))
5086 (goto-char end)))))))
5088 ;;; External functions:
5090 (defun gnus-article-add-button (from to fun &optional data)
5091 "Create a button between FROM and TO with callback FUN and data DATA."
5092 (when gnus-article-button-face
5093 (gnus-overlay-put (gnus-make-overlay from to)
5094 'face gnus-article-button-face))
5095 (gnus-add-text-properties
5097 (nconc (and gnus-article-mouse-face
5098 (list gnus-mouse-face-prop gnus-article-mouse-face))
5099 (list 'gnus-callback fun)
5100 (and data (list 'gnus-data data))))
5101 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5102 :button-keymap gnus-widget-button-keymap))
5104 ;;; Internal functions:
5106 (defun gnus-article-set-globals ()
5108 (set-buffer gnus-summary-buffer)
5109 (gnus-set-global-variables)))
5111 (defun gnus-signature-toggle (end)
5113 (set-buffer gnus-article-buffer)
5114 (let ((buffer-read-only nil)
5115 (inhibit-point-motion-hooks t))
5116 (if (text-property-any end (point-max) 'article-type 'signature)
5118 (setq gnus-article-wash-types
5119 (delq 'signature gnus-article-wash-types))
5120 (gnus-remove-text-properties-when
5121 'article-type 'signature end (point-max)
5122 (cons 'article-type (cons 'signature
5123 gnus-hidden-properties))))
5124 (or (memq 'signature gnus-article-wash-types)
5125 (push 'signature gnus-article-wash-types))
5126 (gnus-add-text-properties-when
5127 'article-type nil end (point-max)
5128 (cons 'article-type (cons 'signature
5129 gnus-hidden-properties)))))
5130 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5131 (gnus-set-mode-line 'article))))
5133 (defun gnus-button-entry ()
5134 ;; Return the first entry in `gnus-button-alist' matching this place.
5135 (let ((alist gnus-button-alist)
5138 (setq entry (pop alist))
5139 (if (looking-at (car entry))
5144 (defun gnus-button-push (marker)
5145 ;; Push button starting at MARKER.
5148 (let* ((entry (gnus-button-entry))
5149 (inhibit-point-motion-hooks t)
5151 (args (mapcar (lambda (group)
5152 (let ((string (match-string group)))
5153 (gnus-set-text-properties
5154 0 (length string) nil string)
5161 (fboundp (symbol-value fun)))
5162 (apply (symbol-value fun) args))
5164 (gnus-message 1 "You must define `%S' to use this button"
5165 (cons fun args)))))))
5167 (defun gnus-parse-news-url (url)
5168 (let (scheme server group message-id articles)
5171 (goto-char (point-min))
5172 (when (looking-at "\\([A-Za-z]+\\):")
5173 (setq scheme (match-string 1))
5174 (goto-char (match-end 0)))
5175 (when (looking-at "//\\([^/]+\\)/")
5176 (setq server (match-string 1))
5177 (goto-char (match-end 0)))
5180 ((looking-at "\\(.*@.*\\)")
5181 (setq message-id (match-string 1)))
5182 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5183 (setq group (match-string 1)
5184 articles (split-string (match-string 2) "-")))
5185 ((looking-at "\\([^/]+\\)/?")
5186 (setq group (match-string 1)))
5188 (error "Unknown news URL syntax"))))
5189 (list scheme server group message-id articles)))
5191 (defun gnus-button-handle-news (url)
5193 (destructuring-bind (scheme server group message-id articles)
5194 (gnus-parse-news-url url)
5198 (set-buffer gnus-summary-buffer)
5200 (let ((gnus-refer-article-method (list (list 'nntp server))))
5201 (gnus-summary-refer-article message-id))
5202 (gnus-summary-refer-article message-id))))
5204 (gnus-button-fetch-group url)))))
5206 (defun gnus-button-handle-info (url)
5207 "Fetch an info URL."
5209 "^\\([^:/]+\\)?/\\(.*\\)"
5211 (gnus-info-find-node
5212 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5215 (gnus-url-unhex-string (match-string 2 url))))
5216 (error "Can't parse %s" url)))
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)
5231 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5233 (error "Can't parse %s" address)
5234 (gnus-group-read-ephemeral-group
5235 (match-string 4 address)
5236 `(nntp ,(match-string 1 address)
5237 (nntp-address ,(match-string 1 address))
5238 (nntp-port-number ,(if (match-end 3)
5239 (match-string 3 address)
5242 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5244 (defun gnus-url-parse-query-string (query &optional downcase)
5245 (let (retval pairs cur key val)
5246 (setq pairs (split-string query "&"))
5248 (setq cur (car pairs)
5250 (if (not (string-match "=" cur))
5252 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5253 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5255 (setq key (downcase key)))
5256 (setq cur (assoc key retval))
5258 (setcdr cur (cons val (cdr cur)))
5259 (setq retval (cons (list key val) retval)))))
5262 (defun gnus-url-mailto (url)
5263 ;; Send mail to someone
5264 (when (string-match "mailto:/*\\(.*\\)" url)
5265 (setq url (substring url (match-beginning 1) nil)))
5266 (let (to args subject func)
5267 (if (string-match (regexp-quote "?") url)
5268 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5269 args (gnus-url-parse-query-string
5270 (substring url (match-end 0) nil) t))
5271 (setq to (gnus-url-unhex-string url)))
5272 (setq args (cons (list "to" to) args)
5273 subject (cdr-safe (assoc "subject" args)))
5276 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5279 (message-position-on-field (caar args)))
5280 (insert (mapconcat 'identity (cdar args) ", "))
5281 (setq args (cdr args)))
5284 (message-goto-subject))))
5286 (defun gnus-button-embedded-url (address)
5287 "Activate ADDRESS with `browse-url'."
5288 (browse-url (gnus-strip-whitespace address)))
5290 ;;; Next/prev buttons in the article buffer.
5292 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5293 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5295 (defvar gnus-prev-page-map nil)
5296 (unless gnus-prev-page-map
5297 (setq gnus-prev-page-map (make-sparse-keymap))
5298 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5299 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5301 (defun gnus-insert-prev-page-button ()
5302 (let ((buffer-read-only nil))
5304 gnus-prev-page-line-format nil
5305 `(gnus-prev t local-map ,gnus-prev-page-map
5306 gnus-callback gnus-article-button-prev-page
5307 article-type annotation))))
5309 (defvar gnus-next-page-map nil)
5310 (unless gnus-next-page-map
5311 (setq gnus-next-page-map (make-keymap))
5312 (suppress-keymap gnus-prev-page-map)
5313 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5314 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5316 (defun gnus-button-next-page ()
5317 "Go to the next page."
5319 (let ((win (selected-window)))
5320 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5321 (gnus-article-next-page)
5322 (select-window win)))
5324 (defun gnus-button-prev-page ()
5325 "Go to the prev page."
5327 (let ((win (selected-window)))
5328 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5329 (gnus-article-prev-page)
5330 (select-window win)))
5332 (defun gnus-insert-next-page-button ()
5333 (let ((buffer-read-only nil))
5334 (gnus-eval-format gnus-next-page-line-format nil
5336 t local-map ,gnus-next-page-map
5337 gnus-callback gnus-article-button-next-page
5338 article-type annotation))))
5340 (defun gnus-article-button-next-page (arg)
5341 "Go to the next page."
5343 (let ((win (selected-window)))
5344 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5345 (gnus-article-next-page)
5346 (select-window win)))
5348 (defun gnus-article-button-prev-page (arg)
5349 "Go to the prev page."
5351 (let ((win (selected-window)))
5352 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5353 (gnus-article-prev-page)
5354 (select-window win)))
5356 (defvar gnus-decode-header-methods
5357 '(mail-decode-encoded-word-region)
5358 "List of methods used to decode headers.
5360 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5361 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5362 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5363 whose names match REGEXP.
5366 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5367 mail-decode-encoded-word-region
5368 (\"chinese\" . rfc1843-decode-region))
5371 (defvar gnus-decode-header-methods-cache nil)
5373 (defun gnus-multi-decode-header (start end)
5374 "Apply the functions from `gnus-encoded-word-methods' that match."
5375 (unless (and gnus-decode-header-methods-cache
5376 (eq gnus-newsgroup-name
5377 (car gnus-decode-header-methods-cache)))
5378 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5381 (nconc gnus-decode-header-methods-cache (list x))
5382 (if (and gnus-newsgroup-name
5383 (string-match (car x) gnus-newsgroup-name))
5384 (nconc gnus-decode-header-methods-cache
5386 gnus-decode-header-methods))
5387 (let ((xlist gnus-decode-header-methods-cache))
5390 (narrow-to-region start end)
5392 (funcall (pop xlist) (point-min) (point-max))))))
5395 ;;; Treatment top-level handling.
5398 (defun gnus-treat-article (condition &optional part-number total-parts type)
5399 (let ((length (- (point-max) (point-min)))
5400 (alist gnus-treatment-function-alist)
5401 (article-goto-body-goes-to-point-min-p t)
5405 (let ((list gnus-article-treat-types))
5407 (when (string-match (pop list) type)
5408 (throw 'found t)))))))
5409 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5411 (gnus-run-hooks 'gnus-part-display-hook)
5412 (while (setq elem (pop alist))
5415 (if (gnus-buffer-live-p gnus-summary-buffer)
5416 (set-buffer gnus-summary-buffer))
5417 (symbol-value (car elem))))
5418 (when (and (or (consp val)
5420 (gnus-treat-predicate val)
5421 (or (not (get (car elem) 'highlight))
5424 (funcall (cadr elem)))))))
5426 ;; Dynamic variables.
5428 (defvar part-number)
5429 (defvar total-parts)
5434 (defun gnus-treat-predicate (val)
5439 (stringp (car val)))
5440 (apply 'gnus-or (mapcar `(lambda (s)
5441 (string-match s ,(or gnus-newsgroup-name "")))
5444 (let ((pred (pop val)))
5447 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5449 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5451 (not (gnus-treat-predicate (car val))))
5453 (equal (car val) type))
5455 (error "%S is not a valid predicate" pred)))))
5463 (eq part-number total-parts))
5467 (error "%S is not a valid value" val))))
5469 (defun gnus-article-encrypt-body (protocol &optional n)
5470 "Encrypt the article body."
5473 (or gnus-article-encrypt-protocol
5474 (completing-read "Encrypt protocol: "
5475 gnus-article-encrypt-protocol-alist
5477 current-prefix-arg))
5478 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5480 (error (format "Can't find the encrypt protocol %s" protocol)))
5481 (if (equal gnus-newsgroup-name "nndraft:drafts")
5482 (error "Can't encrypt the article in group nndraft:drafts"))
5483 (if (equal gnus-newsgroup-name "nndraft:queue")
5484 (error "Don't encrypt the article in group nndraft:queue"))
5485 (gnus-summary-iterate n
5487 (set-buffer gnus-summary-buffer)
5488 (let ((mail-parse-charset gnus-newsgroup-charset)
5489 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5490 (summary-buffer gnus-summary-buffer)
5492 (gnus-set-global-variables)
5493 (when (gnus-group-read-only-p)
5494 (error "The current newsgroup does not support article encrypt"))
5495 (gnus-summary-show-article t)
5497 (or (mail-header-references gnus-current-headers) ""))
5498 (set-buffer gnus-article-buffer)
5499 (let* ((buffer-read-only nil)
5501 (mapcar (lambda (field)
5502 (and (save-restriction
5503 (message-narrow-to-head)
5504 (goto-char (point-min))
5505 (search-forward field nil t))
5507 (message-narrow-to-field)
5508 (buffer-substring (point-min) (point-max))
5509 (delete-region (point-min) (point-max))
5511 '("Content-Type:" "Content-Transfer-Encoding:"
5512 "Content-Disposition:"))))
5513 (message-narrow-to-head)
5514 (message-remove-header "MIME-Version")
5515 (goto-char (point-max))
5516 (setq point (point))
5517 (insert (apply 'concat headers))
5519 (narrow-to-region point (point-max))
5520 (let ((message-options message-options))
5521 (message-options-set 'message-sender user-mail-address)
5522 (message-options-set 'message-recipients user-mail-address)
5523 (message-options-set 'message-sign-encrypt 'not)
5525 (goto-char (point-min))
5526 (insert "MIME-Version: 1.0\n")
5528 (gnus-summary-edit-article-done
5529 references nil summary-buffer t))
5530 (when gnus-keep-backlog
5531 (gnus-backlog-remove-article
5532 (car gnus-article-current) (cdr gnus-article-current)))
5534 (when (get-buffer gnus-original-article-buffer)
5535 (set-buffer gnus-original-article-buffer)
5536 (setq gnus-original-article nil)))
5537 (when gnus-use-cache
5538 (gnus-cache-update-article
5539 (car gnus-article-current) (cdr gnus-article-current))))))))
5541 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5542 "The following specs can be used:
5543 %t The security MIME type
5546 %D Details if button is pressed")
5548 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5549 "The following specs can be used:
5550 %t The security MIME type
5553 %D Details if button is pressed")
5555 (defvar gnus-mime-security-button-line-format-alist
5556 '((?t gnus-tmp-type ?s)
5557 (?i gnus-tmp-info ?s)
5558 (?d gnus-tmp-details ?s)
5559 (?D gnus-tmp-pressed-details ?s)))
5561 (defvar gnus-mime-security-button-map
5562 (let ((map (make-sparse-keymap)))
5563 (unless (>= (string-to-number emacs-version) 21)
5564 (set-keymap-parent map gnus-article-mode-map))
5565 (define-key map gnus-mouse-2 'gnus-article-push-button)
5566 (define-key map "\r" 'gnus-article-press-button)
5569 (defvar gnus-mime-security-details-buffer nil)
5571 (defvar gnus-mime-security-button-pressed nil)
5573 (defvar gnus-mime-security-show-details-inline t
5574 "If non-nil, show details in the article buffer.")
5576 (defun gnus-mime-security-verify-or-decrypt (handle)
5577 (mm-remove-parts (cdr handle))
5578 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5579 point buffer-read-only)
5581 (goto-char (car region)))
5583 (narrow-to-region (point) (point))
5584 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5585 (let* ((mm-verify-option 'known)
5586 (mm-decrypt-option 'known)
5587 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5588 (unless (eq nparts (cdr handle))
5589 (mm-destroy-parts (cdr handle))
5590 (setcdr handle nparts))))
5591 (setq point (point))
5592 (gnus-mime-display-security handle)
5593 (goto-char (point-max)))
5595 (delete-region (point) (cdr region))
5596 (set-marker (car region) nil)
5597 (set-marker (cdr region) nil))
5600 (defun gnus-mime-security-show-details (handle)
5601 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5603 (if gnus-mime-security-show-details-inline
5604 (let ((gnus-mime-security-button-pressed t)
5605 (gnus-mime-security-button-line-format
5606 (get-text-property (point) 'gnus-line-format))
5609 (while (eq (get-text-property (point) 'gnus-line-format)
5610 gnus-mime-security-button-line-format)
5614 (narrow-to-region (point) (point))
5615 (gnus-insert-mime-security-button handle))
5616 (delete-region (point)
5617 (or (text-property-not-all
5620 gnus-mime-security-button-line-format)
5622 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5623 (with-current-buffer gnus-mime-security-details-buffer
5626 (setq gnus-mime-security-details-buffer
5627 (gnus-get-buffer-create "*MIME Security Details*")))
5628 (with-current-buffer gnus-mime-security-details-buffer
5630 (goto-char (point-min)))
5631 (pop-to-buffer gnus-mime-security-details-buffer))
5632 (gnus-message 5 "No details."))))
5634 (defun gnus-mime-security-press-button (handle)
5635 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5636 (gnus-mime-security-show-details handle)
5637 (gnus-mime-security-verify-or-decrypt handle)))
5639 (defun gnus-insert-mime-security-button (handle &optional displayed)
5640 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5643 (or (nth 2 (assoc protocol mm-verify-function-alist))
5644 (nth 2 (assoc protocol mm-decrypt-function-alist))
5646 (if (equal (car handle) "multipart/signed")
5647 " Signed" " Encrypted")
5650 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5653 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5654 gnus-tmp-pressed-details
5656 (setq gnus-tmp-details
5657 (if gnus-tmp-details
5658 (concat "\n" gnus-tmp-details) ""))
5659 (setq gnus-tmp-pressed-details
5660 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5665 gnus-mime-security-button-line-format
5666 gnus-mime-security-button-line-format-alist
5667 `(keymap ,gnus-mime-security-button-map
5668 ,@(if (>= (string-to-number emacs-version) 21)
5669 nil ;; XEmacs doesn't care
5670 (list 'local-map gnus-mime-security-button-map))
5671 gnus-callback gnus-mime-security-press-button
5672 gnus-line-format ,gnus-mime-security-button-line-format
5673 article-type annotation
5676 (widget-convert-button
5679 :action 'gnus-widget-press-button
5680 :button-keymap gnus-mime-security-button-map
5682 (lambda (widget/window &optional overlay pos)
5683 ;; Needed to properly clear the message due to a bug in
5684 ;; wid-edit (XEmacs only).
5685 (if (boundp 'help-echo-owns-message)
5686 (setq help-echo-owns-message t))
5689 (aref gnus-mouse-2 0))))))
5691 (defun gnus-mime-display-security (handle)
5693 (narrow-to-region (point) (point))
5694 (unless (gnus-unbuttonized-mime-type-p (car handle))
5695 (gnus-insert-mime-security-button handle))
5696 (gnus-mime-display-mixed (cdr handle))
5699 (unless (gnus-unbuttonized-mime-type-p (car handle))
5700 (let ((gnus-mime-security-button-line-format
5701 gnus-mime-security-button-end-line-format))
5702 (gnus-insert-mime-security-button handle)))
5703 (mm-set-handle-multipart-parameter
5705 (cons (set-marker (make-marker) (point-min))
5706 (set-marker (make-marker) (point-max))))))
5712 (run-hooks 'gnus-art-load-hook)
5714 ;;; gnus-art.el ends here