1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-emphasis-alist
284 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
289 ("_/" "/_" underline-italic)
290 ("_\\*" "\\*_" underline-bold)
291 ("\\*/" "/\\*" bold-italic)
292 ("_\\*/" "/\\*_" underline-bold-italic))))
296 (format format (car spec) (cadr spec))
297 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
299 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
300 2 3 gnus-emphasis-strikethru)
301 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
302 2 3 gnus-emphasis-underline)))
303 "*Alist that says how to fontify certain phrases.
304 Each item looks like this:
306 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
308 The first element is a regular expression to be matched. The second
309 is a number that says what regular expression grouping used to find
310 the entire emphasized word. The third is a number that says what
311 regexp grouping should be displayed and highlighted. The fourth
312 is the face used for highlighting."
313 :type '(repeat (list :value ("" 0 0 default)
315 (integer :tag "Match group")
316 (integer :tag "Emphasize group")
318 :group 'gnus-article-emphasis)
320 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
321 "A regexp to describe whitespace which should not be emphasized.
322 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
323 The former avoids underlining of leading and trailing whitespace,
324 and the latter avoids underlining any whitespace at all."
326 :group 'gnus-article-emphasis
329 (defface gnus-emphasis-bold '((t (:bold t)))
330 "Face used for displaying strong emphasized text (*word*)."
331 :group 'gnus-article-emphasis)
333 (defface gnus-emphasis-italic '((t (:italic t)))
334 "Face used for displaying italic emphasized text (/word/)."
335 :group 'gnus-article-emphasis)
337 (defface gnus-emphasis-underline '((t (:underline t)))
338 "Face used for displaying underlined emphasized text (_word_)."
339 :group 'gnus-article-emphasis)
341 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
342 "Face used for displaying underlined bold emphasized text (_*word*_)."
343 :group 'gnus-article-emphasis)
345 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
346 "Face used for displaying underlined italic emphasized text (_/word/_)."
347 :group 'gnus-article-emphasis)
349 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
350 "Face used for displaying bold italic emphasized text (/*word*/)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-underline-bold-italic
354 '((t (:bold t :italic t :underline t)))
355 "Face used for displaying underlined bold italic emphasized text.
356 Example: (_/*word*/_)."
357 :group 'gnus-article-emphasis)
359 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
360 "Face used for displaying strike-through text (-word-)."
361 :group 'gnus-article-emphasis)
363 (defface gnus-emphasis-highlight-words
364 '((t (:background "black" :foreground "yellow")))
365 "Face used for displaying highlighted words."
366 :group 'gnus-article-emphasis)
368 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
369 "Format for display of Date headers in article bodies.
370 See `format-time-string' for the possible values.
372 The variable can also be function, which should return a complete Date
373 header. The function is called with one argument, the time, which can
374 be fed to `format-time-string'."
375 :type '(choice string symbol)
376 :link '(custom-manual "(gnus)Article Date")
377 :group 'gnus-article-washing)
380 (autoload 'mail-extract-address-components "mail-extr"))
382 (defcustom gnus-save-all-headers t
383 "*If non-nil, don't remove any headers before saving."
384 :group 'gnus-article-saving
387 (defcustom gnus-prompt-before-saving 'always
388 "*This variable says how much prompting is to be done when saving articles.
389 If it is nil, no prompting will be done, and the articles will be
390 saved to the default files. If this variable is `always', each and
391 every article that is saved will be preceded by a prompt, even when
392 saving large batches of articles. If this variable is neither nil not
393 `always', there the user will be prompted once for a file name for
394 each invocation of the saving commands."
395 :group 'gnus-article-saving
396 :type '(choice (item always)
397 (item :tag "never" nil)
398 (sexp :tag "once" :format "%t\n" :value t)))
400 (defcustom gnus-saved-headers gnus-visible-headers
401 "Headers to keep if `gnus-save-all-headers' is nil.
402 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
403 If that variable is nil, however, all headers that match this regexp
404 will be kept while the rest will be deleted before saving."
405 :group 'gnus-article-saving
408 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
409 "A function to save articles in your favourite format.
410 The function must be interactively callable (in other words, it must
411 be an Emacs command).
413 Gnus provides the following functions:
415 * gnus-summary-save-in-rmail (Rmail format)
416 * gnus-summary-save-in-mail (Unix mail format)
417 * gnus-summary-save-in-folder (MH folder)
418 * gnus-summary-save-in-file (article format)
419 * gnus-summary-save-body-in-file (article body)
420 * gnus-summary-save-in-vm (use VM's folder format)
421 * gnus-summary-write-to-file (article format -- overwrite)."
422 :group 'gnus-article-saving
423 :type '(radio (function-item gnus-summary-save-in-rmail)
424 (function-item gnus-summary-save-in-mail)
425 (function-item gnus-summary-save-in-folder)
426 (function-item gnus-summary-save-in-file)
427 (function-item gnus-summary-save-body-in-file)
428 (function-item gnus-summary-save-in-vm)
429 (function-item gnus-summary-write-to-file)))
431 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
432 "A function generating a file name to save articles in Rmail format.
433 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
434 :group 'gnus-article-saving
437 (defcustom gnus-mail-save-name 'gnus-plain-save-name
438 "A function generating a file name to save articles in Unix mail format.
439 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
440 :group 'gnus-article-saving
443 (defcustom gnus-folder-save-name 'gnus-folder-save-name
444 "A function generating a file name to save articles in MH folder.
445 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
446 :group 'gnus-article-saving
449 (defcustom gnus-file-save-name 'gnus-numeric-save-name
450 "A function generating a file name to save articles in article format.
451 The function is called with NEWSGROUP, HEADERS, and optional
453 :group 'gnus-article-saving
456 (defcustom gnus-split-methods
457 '((gnus-article-archive-name)
458 (gnus-article-nndoc-name))
459 "*Variable used to suggest where articles are to be saved.
460 For instance, if you would like to save articles related to Gnus in
461 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
462 you could set this variable to something like:
464 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
465 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
467 This variable is an alist where the where the key is the match and the
468 value is a list of possible files to save in if the match is non-nil.
470 If the match is a string, it is used as a regexp match on the
471 article. If the match is a symbol, that symbol will be funcalled
472 from the buffer of the article to be saved with the newsgroup as the
473 parameter. If it is a list, it will be evaled in the same buffer.
475 If this form or function returns a string, this string will be used as
476 a possible file name; and if it returns a non-nil list, that list will
477 be used as possible file names."
478 :group 'gnus-article-saving
479 :type '(repeat (choice (list :value (fun) function)
480 (cons :value ("" "") regexp (repeat string))
483 (defcustom gnus-page-delimiter "^\^L"
484 "*Regexp describing what to use as article page delimiters.
485 The default value is \"^\^L\", which is a form linefeed at the
486 beginning of a line."
488 :group 'gnus-article-various)
490 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
491 "*The format specification for the article mode line.
492 See `gnus-summary-mode-line-format' for a closer description.
494 The following additional specs are available:
496 %w The article washing status.
497 %m The number of MIME parts in the article."
499 :group 'gnus-article-various)
501 (defcustom gnus-article-mode-hook nil
502 "*A hook for Gnus article mode."
504 :group 'gnus-article-various)
506 (when (featurep 'xemacs)
507 ;; Extracted from gnus-xmas-define in order to preserve user settings
508 (when (fboundp 'turn-off-scroll-in-place)
509 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
510 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
511 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
513 (defcustom gnus-article-menu-hook nil
514 "*Hook run after the creation of the article mode menu."
516 :group 'gnus-article-various)
518 (defcustom gnus-article-prepare-hook nil
519 "*A hook called after an article has been prepared in the article buffer."
521 :group 'gnus-article-various)
523 (defcustom gnus-article-hide-pgp-hook nil
524 "*A hook called after successfully hiding a PGP signature."
526 :group 'gnus-article-various)
528 (defcustom gnus-article-button-face 'bold
529 "Face used for highlighting buttons in the article buffer.
531 An article button is a piece of text that you can activate by pressing
532 `RET' or `mouse-2' above it."
534 :group 'gnus-article-buttons)
536 (defcustom gnus-article-mouse-face 'highlight
537 "Face used for mouse highlighting in the article buffer.
539 Article buttons will be displayed in this face when the cursor is
542 :group 'gnus-article-buttons)
544 (defcustom gnus-signature-face 'gnus-signature-face
545 "Face used for highlighting a signature in the article buffer.
546 Obsolete; use the face `gnus-signature-face' for customizations instead."
548 :group 'gnus-article-highlight
549 :group 'gnus-article-signature)
551 (defface gnus-signature-face
554 "Face used for highlighting a signature in the article buffer."
555 :group 'gnus-article-highlight
556 :group 'gnus-article-signature)
558 (defface gnus-header-from-face
561 (:foreground "spring green"))
564 (:foreground "red3"))
567 "Face used for displaying from headers."
568 :group 'gnus-article-headers
569 :group 'gnus-article-highlight)
571 (defface gnus-header-subject-face
574 (:foreground "SeaGreen3"))
577 (:foreground "red4"))
579 (:bold t :italic t)))
580 "Face used for displaying subject headers."
581 :group 'gnus-article-headers
582 :group 'gnus-article-highlight)
584 (defface gnus-header-newsgroups-face
587 (:foreground "yellow" :italic t))
590 (:foreground "MidnightBlue" :italic t))
593 "Face used for displaying newsgroups headers."
594 :group 'gnus-article-headers
595 :group 'gnus-article-highlight)
597 (defface gnus-header-name-face
600 (:foreground "SeaGreen"))
603 (:foreground "maroon"))
606 "Face used for displaying header names."
607 :group 'gnus-article-headers
608 :group 'gnus-article-highlight)
610 (defface gnus-header-content-face
613 (:foreground "forest green" :italic t))
616 (:foreground "indianred4" :italic t))
618 (:italic t))) "Face used for displaying header content."
619 :group 'gnus-article-headers
620 :group 'gnus-article-highlight)
622 (defcustom gnus-header-face-alist
623 '(("From" nil gnus-header-from-face)
624 ("Subject" nil gnus-header-subject-face)
625 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
626 ("" gnus-header-name-face gnus-header-content-face))
627 "*Controls highlighting of article header.
629 An alist of the form (HEADER NAME CONTENT).
631 HEADER is a regular expression which should match the name of an
632 header header and NAME and CONTENT are either face names or nil.
634 The name of each header field will be displayed using the face
635 specified by the first element in the list where HEADER match the
636 header name and NAME is non-nil. Similarly, the content will be
637 displayed by the first non-nil matching CONTENT face."
638 :group 'gnus-article-headers
639 :group 'gnus-article-highlight
640 :type '(repeat (list (regexp :tag "Header")
642 (item :tag "skip" nil)
643 (face :value default))
644 (choice :tag "Content"
645 (item :tag "skip" nil)
646 (face :value default)))))
648 (defcustom gnus-article-decode-hook
649 '(article-decode-charset article-decode-encoded-words
650 article-decode-group-name)
651 "*Hook run to decode charsets in articles."
652 :group 'gnus-article-headers
655 (defcustom gnus-display-mime-function 'gnus-display-mime
656 "Function to display MIME articles."
657 :group 'gnus-article-mime
660 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
661 "Function used to decode headers.")
663 (defvar gnus-article-dumbquotes-map
678 ("\230" "-") ; This might not be correct.
683 "Table for MS-to-Latin1 translation.")
685 (defcustom gnus-ignored-mime-types nil
686 "List of MIME types that should be ignored by Gnus."
688 :group 'gnus-article-mime
689 :type '(repeat regexp))
691 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
692 "List of MIME types that should not be given buttons when rendered inline.
693 See also `gnus-buttonized-mime-types' which may override this variable."
695 :group 'gnus-article-mime
696 :type '(repeat regexp))
698 (defcustom gnus-buttonized-mime-types nil
699 "List of MIME types that should be given buttons when rendered inline.
700 If set, this variable overrides `gnus-unbuttonized-mime-types'.
701 To see e.g. security buttons you could set this to
702 `(\"multipart/signed\")'."
704 :group 'gnus-article-mime
705 :type '(repeat regexp))
707 (defcustom gnus-body-boundary-delimiter "_"
708 "String used to delimit header and body.
709 This variable is used by `gnus-article-treat-body-boundary' which can
710 be controlled by `gnus-treat-body-boundary'."
711 :group 'gnus-article-various
712 :type '(choice (item :tag "None" :value nil)
715 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
716 "Defines the location of the faces database.
717 For information on obtaining this database of pretty pictures, please
718 see http://www.cs.indiana.edu/picons/ftp/index.html"
719 :type '(repeat directory)
720 :link '(url-link :tag "download"
721 "http://www.cs.indiana.edu/picons/ftp/index.html")
722 :link '(custom-manual "(gnus)Picons")
725 (defun gnus-picons-installed-p ()
726 "Say whether picons are installed on your machine."
727 (let ((installed nil))
728 (dolist (database gnus-picon-databases)
729 (when (file-exists-p database)
733 (defcustom gnus-article-mime-part-function nil
734 "Function called with a MIME handle as the argument.
735 This is meant for people who want to do something automatic based
736 on parts -- for instance, adding Vcard info to a database."
737 :group 'gnus-article-mime
740 (defcustom gnus-mime-multipart-functions nil
741 "An alist of MIME types to functions to display them."
743 :group 'gnus-article-mime
746 (defcustom gnus-article-date-lapsed-new-header nil
747 "Whether the X-Sent and Date headers can coexist.
748 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
749 either replace the old \"Date:\" header (if this variable is nil), or
750 be added below it (otherwise)."
752 :group 'gnus-article-headers
755 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
756 "Function called with a MIME handle as the argument.
757 This is meant for people who want to view first matched part.
758 For `undisplayed-alternative' (default), the first undisplayed
759 part or alternative part is used. For `undisplayed', the first
760 undisplayed part is used. For a function, the first part which
761 the function return `t' is used. For `nil', the first part is
764 :group 'gnus-article-mime
766 (item :tag "first" :value nil)
767 (item :tag "undisplayed" :value undisplayed)
768 (item :tag "undisplayed or alternative"
769 :value undisplayed-alternative)
772 (defcustom gnus-mime-action-alist
773 '(("save to file" . gnus-mime-save-part)
774 ("save and strip" . gnus-mime-save-part-and-strip)
775 ("display as text" . gnus-mime-inline-part)
776 ("view the part" . gnus-mime-view-part)
777 ("pipe to command" . gnus-mime-pipe-part)
778 ("toggle display" . gnus-article-press-button)
779 ("toggle display" . gnus-article-view-part-as-charset)
780 ("view as type" . gnus-mime-view-part-as-type)
781 ("view internally" . gnus-mime-view-part-internally)
782 ("view externally" . gnus-mime-view-part-externally))
783 "An alist of actions that run on the MIME attachment."
784 :group 'gnus-article-mime
785 :type '(repeat (cons (string :tag "name")
789 ;;; The treatment variables
792 (defvar gnus-part-display-hook nil
793 "Hook called on parts that are to receive treatment.")
795 (defvar gnus-article-treat-custom
796 '(choice (const :tag "Off" nil)
798 (const :tag "Header" head)
799 (const :tag "Last" last)
800 (integer :tag "Less")
801 (repeat :tag "Groups" regexp)
802 (sexp :tag "Predicate")))
804 (defvar gnus-article-treat-head-custom
805 '(choice (const :tag "Off" nil)
806 (const :tag "Header" head)))
808 (defvar gnus-article-treat-types '("text/plain")
811 (defvar gnus-inhibit-treatment nil
812 "Whether to inhibit treatment.")
814 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
815 "Highlight the signature.
816 Valid values are nil, t, `head', `last', an integer or a predicate.
817 See Info node `(gnus)Customizing Articles'."
818 :group 'gnus-article-treat
819 :type gnus-article-treat-custom)
820 (put 'gnus-treat-highlight-signature 'highlight t)
822 (defcustom gnus-treat-buttonize 100000
824 Valid values are nil, t, `head', `last', an integer or a predicate.
825 See Info node `(gnus)Customizing Articles'."
826 :group 'gnus-article-treat
827 :type gnus-article-treat-custom)
828 (put 'gnus-treat-buttonize 'highlight t)
830 (defcustom gnus-treat-buttonize-head 'head
831 "Add buttons to the head.
832 Valid values are nil, t, `head', `last', an integer or a predicate.
833 See Info node `(gnus)Customizing Articles' for details."
834 :group 'gnus-article-treat
835 :type gnus-article-treat-head-custom)
836 (put 'gnus-treat-buttonize-head 'highlight t)
838 (defcustom gnus-treat-emphasize
839 (and (or window-system
841 (>= (string-to-number emacs-version) 21))
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles' for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
848 (put 'gnus-treat-emphasize 'highlight t)
850 (defcustom gnus-treat-strip-cr nil
851 "Remove carriage returns.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See Info node `(gnus)Customizing Articles' for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-custom)
857 (defcustom gnus-treat-unsplit-urls nil
858 "Remove newlines from within URLs.
859 Valid values are nil, t, `head', `last', an integer or a predicate.
860 See Info node `(gnus)Customizing Articles' for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-custom)
864 (defcustom gnus-treat-leading-whitespace nil
865 "Remove leading whitespace in headers.
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See Info node `(gnus)Customizing Articles' for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-custom)
871 (defcustom gnus-treat-hide-headers 'head
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See Info node `(gnus)Customizing Articles' for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-head-custom)
878 (defcustom gnus-treat-hide-boring-headers nil
879 "Hide boring headers.
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See Info node `(gnus)Customizing Articles' for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-head-custom)
885 (defcustom gnus-treat-hide-signature nil
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See Info node `(gnus)Customizing Articles' for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-fill-article nil
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See Info node `(gnus)Customizing Articles' for details."
896 :group 'gnus-article-treat
897 :type gnus-article-treat-custom)
899 (defcustom gnus-treat-hide-citation nil
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See Info node `(gnus)Customizing Articles' for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-hide-citation-maybe nil
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
910 :group 'gnus-article-treat
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-strip-list-identifiers 'head
914 "Strip list identifiers from `gnus-list-identifiers`.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-strip-pgp t
922 "Strip PGP signatures.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :type gnus-article-treat-custom)
928 (defcustom gnus-treat-strip-pem nil
929 "Strip PEM signatures.
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See Info node `(gnus)Customizing Articles' for details."
932 :group 'gnus-article-treat
933 :type gnus-article-treat-custom)
935 (defcustom gnus-treat-strip-banner t
936 "Strip banners from articles.
937 The banner to be stripped is specified in the `banner' group parameter.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :type gnus-article-treat-custom)
943 (defcustom gnus-treat-highlight-headers 'head
944 "Highlight the headers.
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles' for details."
947 :group 'gnus-article-treat
948 :type gnus-article-treat-head-custom)
949 (put 'gnus-treat-highlight-headers 'highlight t)
951 (defcustom gnus-treat-highlight-citation t
952 "Highlight cited text.
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See Info node `(gnus)Customizing Articles' for details."
955 :group 'gnus-article-treat
956 :type gnus-article-treat-custom)
957 (put 'gnus-treat-highlight-citation 'highlight t)
959 (defcustom gnus-treat-date-ut nil
960 "Display the Date in UT (GMT).
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See Info node `(gnus)Customizing Articles' for details."
963 :group 'gnus-article-treat
964 :type gnus-article-treat-head-custom)
966 (defcustom gnus-treat-date-local nil
967 "Display the Date in the local timezone.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See Info node `(gnus)Customizing Articles' for details."
970 :group 'gnus-article-treat
971 :type gnus-article-treat-head-custom)
973 (defcustom gnus-treat-date-english nil
974 "Display the Date in a format that can be read aloud in English.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :type gnus-article-treat-head-custom)
980 (defcustom gnus-treat-date-lapsed nil
981 "Display the Date header in a way that says how much time has elapsed.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :type gnus-article-treat-head-custom)
987 (defcustom gnus-treat-date-original nil
988 "Display the date in the original timezone.
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :type gnus-article-treat-head-custom)
994 (defcustom gnus-treat-date-iso8601 nil
995 "Display the date in the ISO8601 format.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See Info node `(gnus)Customizing Articles' for details."
999 :group 'gnus-article-treat
1000 :type gnus-article-treat-head-custom)
1002 (defcustom gnus-treat-date-user-defined nil
1003 "Display the date in a user-defined format.
1004 The format is defined by the `gnus-article-time-format' variable.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles' for details."
1007 :group 'gnus-article-treat
1008 :type gnus-article-treat-head-custom)
1010 (defcustom gnus-treat-strip-headers-in-body t
1011 "Strip the X-No-Archive header line from the beginning of the body.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1015 :group 'gnus-article-treat
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-strip-trailing-blank-lines nil
1019 "Strip trailing blank lines.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :type gnus-article-treat-custom)
1025 (defcustom gnus-treat-strip-leading-blank-lines nil
1026 "Strip leading blank lines.
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See Info node `(gnus)Customizing Articles' for details."
1029 :group 'gnus-article-treat
1030 :type gnus-article-treat-custom)
1032 (defcustom gnus-treat-strip-multiple-blank-lines nil
1033 "Strip multiple blank lines.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :type gnus-article-treat-custom)
1039 (defcustom gnus-treat-unfold-headers 'head
1040 "Unfold folded header lines.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :type gnus-article-treat-custom)
1046 (defcustom gnus-treat-fold-headers nil
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-fold-newsgroups 'head
1054 "Fold the Newsgroups and Followup-To headers.
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See Info node `(gnus)Customizing Articles' for details."
1057 :group 'gnus-article-treat
1058 :type gnus-article-treat-custom)
1060 (defcustom gnus-treat-overstrike t
1061 "Treat overstrike highlighting.
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See Info node `(gnus)Customizing Articles' for details."
1064 :group 'gnus-article-treat
1065 :type gnus-article-treat-custom)
1066 (put 'gnus-treat-overstrike 'highlight t)
1068 (defcustom gnus-treat-display-xface
1069 (and (not noninteractive)
1070 (or (and (fboundp 'image-type-available-p)
1071 (image-type-available-p 'xbm)
1072 (string-match "^0x" (shell-command-to-string "uncompface")))
1073 (and (featurep 'xemacs)
1076 "Display X-Face headers.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' and Info node
1079 `(gnus)X-Face' for details."
1080 :group 'gnus-article-treat
1082 :type gnus-article-treat-head-custom)
1083 (put 'gnus-treat-display-xface 'highlight t)
1085 (defcustom gnus-treat-display-grey-xface
1086 (and (not noninteractive)
1087 (string-match "^0x" (shell-command-to-string "uncompface"))
1089 "Display grey X-Face headers.
1090 Valid values are nil, t."
1091 :group 'gnus-article-treat
1094 (put 'gnus-treat-display-grey-xface 'highlight t)
1096 (defcustom gnus-treat-display-smileys
1097 (if (or (and (featurep 'xemacs)
1099 (and (fboundp 'image-type-available-p)
1100 (image-type-available-p 'pbm)))
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' and Info node
1105 `(gnus)Smileys' for details."
1106 :group 'gnus-article-treat
1108 :type gnus-article-treat-custom)
1109 (put 'gnus-treat-display-smileys 'highlight t)
1111 (defcustom gnus-treat-from-picon
1112 (if (and (gnus-image-type-available-p 'xpm)
1113 (gnus-picons-installed-p))
1115 "Display picons in the From header.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' and Info node
1118 `(gnus)Picons' for details."
1119 :group 'gnus-article-treat
1121 :link '(info-link "(gnus)Customizing Articles")
1122 :link '(info-link "(gnus)Picons")
1123 :type gnus-article-treat-head-custom)
1124 (put 'gnus-treat-from-picon 'highlight t)
1126 (defcustom gnus-treat-mail-picon
1127 (if (and (gnus-image-type-available-p 'xpm)
1128 (gnus-picons-installed-p))
1130 "Display picons in To and Cc headers.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' and Info node
1133 `(gnus)Picons' for details."
1134 :group 'gnus-article-treat
1136 :link '(info-link "(gnus)Customizing Articles")
1137 :link '(info-link "(gnus)Picons")
1138 :type gnus-article-treat-head-custom)
1139 (put 'gnus-treat-mail-picon 'highlight t)
1141 (defcustom gnus-treat-newsgroups-picon
1142 (if (and (gnus-image-type-available-p 'xpm)
1143 (gnus-picons-installed-p))
1145 "Display picons in the Newsgroups and Followup-To headers.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' and Info node
1148 `(gnus)Picons' for details."
1149 :group 'gnus-article-treat
1151 :link '(info-link "(gnus)Customizing Articles")
1152 :link '(info-link "(gnus)Picons")
1153 :type gnus-article-treat-head-custom)
1154 (put 'gnus-treat-newsgroups-picon 'highlight t)
1156 (defcustom gnus-treat-body-boundary
1157 (if (or gnus-treat-newsgroups-picon
1158 gnus-treat-mail-picon
1159 gnus-treat-from-picon)
1161 "Draw a boundary at the end of the headers.
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1165 :group 'gnus-article-treat
1166 :type gnus-article-treat-custom)
1168 (defcustom gnus-treat-capitalize-sentences nil
1169 "Capitalize sentence-starting words.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 See Info node `(gnus)Customizing Articles' for details."
1173 :group 'gnus-article-treat
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-fill-long-lines nil
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :type gnus-article-treat-custom)
1183 (defcustom gnus-treat-play-sounds nil
1185 Valid values are nil, t, `head', `last', an integer or a predicate.
1186 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :type gnus-article-treat-custom)
1191 (defcustom gnus-treat-translate nil
1192 "Translate articles from one language to another.
1193 Valid values are nil, t, `head', `last', an integer or a predicate.
1194 See Info node `(gnus)Customizing Articles' for details."
1196 :group 'gnus-article-treat
1197 :type gnus-article-treat-custom)
1199 (defcustom gnus-treat-x-pgp-sig nil
1201 To automatically treat X-PGP-Sig, set it to head.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1204 :group 'gnus-article-treat
1205 :group 'mime-security
1206 :type gnus-article-treat-custom)
1208 (defvar gnus-article-encrypt-protocol-alist
1209 '(("PGP" . mml2015-self-encrypt)))
1211 ;; Set to nil if more than one protocol added to
1212 ;; gnus-article-encrypt-protocol-alist.
1213 (defcustom gnus-article-encrypt-protocol "PGP"
1214 "The protocol used for encrypt articles.
1215 It is a string, such as \"PGP\". If nil, ask user."
1217 :group 'mime-security)
1219 (defvar gnus-article-wash-function nil
1220 "Function used for converting HTML into text.")
1222 ;;; Internal variables
1224 (defvar gnus-english-month-names
1225 '("January" "February" "March" "April" "May" "June" "July" "August"
1226 "September" "October" "November" "December"))
1228 (defvar article-goto-body-goes-to-point-min-p nil)
1229 (defvar gnus-article-wash-types nil)
1230 (defvar gnus-article-emphasis-alist nil)
1231 (defvar gnus-article-image-alist nil)
1233 (defvar gnus-article-mime-handle-alist-1 nil)
1234 (defvar gnus-treatment-function-alist
1235 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1236 (gnus-treat-strip-banner gnus-article-strip-banner)
1237 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1238 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1239 (gnus-treat-buttonize gnus-article-add-buttons)
1240 (gnus-treat-fill-article gnus-article-fill-cited-article)
1241 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1242 (gnus-treat-strip-cr gnus-article-remove-cr)
1243 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1244 (gnus-treat-date-ut gnus-article-date-ut)
1245 (gnus-treat-date-local gnus-article-date-local)
1246 (gnus-treat-date-english gnus-article-date-english)
1247 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1248 (gnus-treat-date-original gnus-article-date-original)
1249 (gnus-treat-date-user-defined gnus-article-date-user)
1250 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1251 (gnus-treat-display-xface gnus-article-display-x-face)
1252 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1253 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1254 (gnus-treat-hide-signature gnus-article-hide-signature)
1255 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1256 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1257 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1258 (gnus-treat-strip-pem gnus-article-hide-pem)
1259 (gnus-treat-from-picon gnus-treat-from-picon)
1260 (gnus-treat-mail-picon gnus-treat-mail-picon)
1261 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1262 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1263 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1264 (gnus-treat-strip-trailing-blank-lines
1265 gnus-article-remove-trailing-blank-lines)
1266 (gnus-treat-strip-leading-blank-lines
1267 gnus-article-strip-leading-blank-lines)
1268 (gnus-treat-strip-multiple-blank-lines
1269 gnus-article-strip-multiple-blank-lines)
1270 (gnus-treat-overstrike gnus-article-treat-overstrike)
1271 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1272 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1273 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1274 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1275 (gnus-treat-display-smileys gnus-treat-smiley)
1276 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1277 (gnus-treat-emphasize gnus-article-emphasize)
1278 (gnus-treat-hide-citation gnus-article-hide-citation)
1279 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1280 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1281 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1282 (gnus-treat-play-sounds gnus-earcon-display)))
1284 (defvar gnus-article-mime-handle-alist nil)
1285 (defvar article-lapsed-timer nil)
1286 (defvar gnus-article-current-summary nil)
1288 (defvar gnus-article-mode-syntax-table
1289 (let ((table (copy-syntax-table text-mode-syntax-table)))
1290 ;; This causes the citation match run O(2^n).
1291 ;; (modify-syntax-entry ?- "w" table)
1292 (modify-syntax-entry ?> ")<" table)
1293 (modify-syntax-entry ?< "(>" table)
1295 "Syntax table used in article mode buffers.
1296 Initialized from `text-mode-syntax-table.")
1298 (defvar gnus-save-article-buffer nil)
1300 (defvar gnus-article-mode-line-format-alist
1301 (nconc '((?w (gnus-article-wash-status) ?s)
1302 (?m (gnus-article-mime-part-status) ?s))
1303 gnus-summary-mode-line-format-alist))
1305 (defvar gnus-number-of-articles-to-be-saved nil)
1307 (defvar gnus-inhibit-hiding nil)
1309 ;;; Macros for dealing with the article buffer.
1311 (defmacro gnus-with-article-headers (&rest forms)
1313 (set-buffer gnus-article-buffer)
1315 (let ((buffer-read-only nil)
1316 (inhibit-point-motion-hooks t)
1317 (case-fold-search t))
1318 (article-narrow-to-head)
1321 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1322 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1324 (defmacro gnus-with-article-buffer (&rest forms)
1326 (set-buffer gnus-article-buffer)
1327 (let ((buffer-read-only nil))
1330 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1331 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1333 (defun gnus-article-goto-header (header)
1334 "Go to HEADER, which is a regular expression."
1335 (re-search-forward (concat "^\\(" header "\\):") nil t))
1337 (defsubst gnus-article-hide-text (b e props)
1338 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1339 (gnus-add-text-properties-when 'article-type nil b e props)
1340 (when (memq 'intangible props)
1342 (max (1- b) (point-min))
1343 b 'intangible (cddr (memq 'intangible props)))))
1345 (defsubst gnus-article-unhide-text (b e)
1346 "Remove hidden text properties from region between B and E."
1347 (remove-text-properties b e gnus-hidden-properties)
1348 (when (memq 'intangible gnus-hidden-properties)
1349 (put-text-property (max (1- b) (point-min))
1350 b 'intangible nil)))
1352 (defun gnus-article-hide-text-type (b e type)
1353 "Hide text of TYPE between B and E."
1354 (gnus-add-wash-type type)
1355 (gnus-article-hide-text
1356 b e (cons 'article-type (cons type gnus-hidden-properties))))
1358 (defun gnus-article-unhide-text-type (b e type)
1359 "Unhide text of TYPE between B and E."
1360 (gnus-delete-wash-type type)
1361 (remove-text-properties
1362 b e (cons 'article-type (cons type gnus-hidden-properties)))
1363 (when (memq 'intangible gnus-hidden-properties)
1364 (put-text-property (max (1- b) (point-min))
1365 b 'intangible nil)))
1367 (defun gnus-article-hide-text-of-type (type)
1368 "Hide text of TYPE in the current buffer."
1370 (let ((b (point-min))
1372 (while (setq b (text-property-any b e 'article-type type))
1373 (add-text-properties b (incf b) gnus-hidden-properties)))))
1375 (defun gnus-article-delete-text-of-type (type)
1376 "Delete text of TYPE in the current buffer."
1378 (let ((b (point-min)))
1379 (while (setq b (text-property-any b (point-max) 'article-type type))
1381 b (or (text-property-not-all b (point-max) 'article-type type)
1384 (defun gnus-article-delete-invisible-text ()
1385 "Delete all invisible text in the current buffer."
1387 (let ((b (point-min)))
1388 (while (setq b (text-property-any b (point-max) 'invisible t))
1390 b (or (text-property-not-all b (point-max) 'invisible t)
1393 (defun gnus-article-text-type-exists-p (type)
1394 "Say whether any text of type TYPE exists in the buffer."
1395 (text-property-any (point-min) (point-max) 'article-type type))
1397 (defsubst gnus-article-header-rank ()
1398 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1399 (let ((list gnus-sorted-header-list)
1402 (when (looking-at (car list))
1404 (setq list (cdr list))
1408 (defun article-hide-headers (&optional arg delete)
1409 "Hide unwanted headers and possibly sort them as well."
1411 ;; This function might be inhibited.
1412 (unless gnus-inhibit-hiding
1415 (let ((buffer-read-only nil)
1416 (case-fold-search t)
1417 (max (1+ (length gnus-sorted-header-list)))
1418 (ignored (when (not gnus-visible-headers)
1419 (cond ((stringp gnus-ignored-headers)
1420 gnus-ignored-headers)
1421 ((listp gnus-ignored-headers)
1422 (mapconcat 'identity gnus-ignored-headers
1425 (cond ((stringp gnus-visible-headers)
1426 gnus-visible-headers)
1427 ((and gnus-visible-headers
1428 (listp gnus-visible-headers))
1429 (mapconcat 'identity gnus-visible-headers "\\|"))))
1430 (inhibit-point-motion-hooks t)
1432 ;; First we narrow to just the headers.
1433 (article-narrow-to-head)
1434 ;; Hide any "From " lines at the beginning of (mail) articles.
1435 (while (looking-at "From ")
1438 (delete-region (point-min) (point)))
1439 ;; Then treat the rest of the header lines.
1440 ;; Then we use the two regular expressions
1441 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1442 ;; select which header lines is to remain visible in the
1444 (while (re-search-forward "^[^ \t:]*:" nil t)
1446 ;; Mark the rank of the header.
1448 (point) (1+ (point)) 'message-rank
1449 (if (or (and visible (looking-at visible))
1451 (not (looking-at ignored))))
1452 (gnus-article-header-rank)
1455 (message-sort-headers-1)
1456 (when (setq beg (text-property-any
1457 (point-min) (point-max) 'message-rank (+ 2 max)))
1458 ;; We delete the unwanted headers.
1459 (gnus-add-wash-type 'headers)
1460 (add-text-properties (point-min) (+ 5 (point-min))
1461 '(article-type headers dummy-invisible t))
1462 (delete-region beg (point-max))))))))
1464 (defun article-hide-boring-headers (&optional arg)
1465 "Toggle hiding of headers that aren't very interesting.
1466 If given a negative prefix, always show; if given a positive prefix,
1468 (interactive (gnus-article-hidden-arg))
1469 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1470 (not gnus-show-all-headers))
1473 (let ((buffer-read-only nil)
1474 (list gnus-boring-article-headers)
1475 (inhibit-point-motion-hooks t)
1477 (article-narrow-to-head)
1479 (setq elem (pop list))
1480 (goto-char (point-min))
1482 ;; Hide empty headers.
1484 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1486 (gnus-article-hide-text-type
1487 (progn (beginning-of-line) (point))
1490 (if (re-search-forward "^[^ \t]" nil t)
1494 ;; Hide boring Newsgroups header.
1495 ((eq elem 'newsgroups)
1496 (when (gnus-string-equal
1497 (gnus-fetch-field "newsgroups")
1498 (gnus-group-real-name
1499 (if (boundp 'gnus-newsgroup-name)
1502 (gnus-article-hide-header "newsgroups")))
1503 ((eq elem 'to-address)
1504 (let ((to (message-fetch-field "to"))
1506 (gnus-parameter-to-address
1507 (if (boundp 'gnus-newsgroup-name)
1508 gnus-newsgroup-name ""))))
1509 (when (and to to-address
1512 ;; only one address in To
1513 (nth 1 (mail-extract-address-components to))
1515 (gnus-article-hide-header "to"))))
1516 ((eq elem 'followup-to)
1517 (when (gnus-string-equal
1518 (message-fetch-field "followup-to")
1519 (message-fetch-field "newsgroups"))
1520 (gnus-article-hide-header "followup-to")))
1521 ((eq elem 'reply-to)
1522 (let ((from (message-fetch-field "from"))
1523 (reply-to (message-fetch-field "reply-to")))
1528 (nth 1 (mail-extract-address-components from))
1529 (nth 1 (mail-extract-address-components reply-to)))))
1530 (gnus-article-hide-header "reply-to"))))
1532 (let ((date (message-fetch-field "date")))
1534 (< (days-between (current-time-string) date)
1536 (gnus-article-hide-header "date"))))
1538 (let ((to (message-fetch-field "to"))
1539 (cc (message-fetch-field "cc")))
1540 (when (> (length to) 1024)
1541 (gnus-article-hide-header "to"))
1542 (when (> (length cc) 1024)
1543 (gnus-article-hide-header "cc"))))
1547 (goto-char (point-min))
1548 (while (re-search-forward "^to:" nil t)
1549 (setq to-count (1+ to-count)))
1550 (when (> to-count 1)
1551 (while (> to-count 0)
1552 (goto-char (point-min))
1554 (re-search-forward "^to:" nil nil to-count)
1556 (narrow-to-region (point) (point-max))
1557 (gnus-article-hide-header "to"))
1558 (setq to-count (1- to-count))))
1559 (goto-char (point-min))
1560 (while (re-search-forward "^cc:" nil t)
1561 (setq cc-count (1+ cc-count)))
1562 (when (> cc-count 1)
1563 (while (> cc-count 0)
1564 (goto-char (point-min))
1566 (re-search-forward "^cc:" nil nil cc-count)
1568 (narrow-to-region (point) (point-max))
1569 (gnus-article-hide-header "cc"))
1570 (setq cc-count (1- cc-count)))))))))))))
1572 (defun gnus-article-hide-header (header)
1574 (goto-char (point-min))
1575 (when (re-search-forward (concat "^" header ":") nil t)
1576 (gnus-article-hide-text-type
1577 (progn (beginning-of-line) (point))
1580 (if (re-search-forward "^[^ \t]" nil t)
1585 (defvar gnus-article-normalized-header-length 40
1586 "Length of normalized headers.")
1588 (defun article-normalize-headers ()
1589 "Make all header lines 40 characters long."
1591 (let ((buffer-read-only nil)
1595 (article-narrow-to-head)
1598 ((< (setq column (- (gnus-point-at-eol) (point)))
1599 gnus-article-normalized-header-length)
1601 (insert (make-string
1602 (- gnus-article-normalized-header-length column)
1604 ((> column gnus-article-normalized-header-length)
1605 (gnus-put-text-property
1607 (forward-char gnus-article-normalized-header-length)
1614 (forward-line 1))))))
1616 (defun article-treat-dumbquotes ()
1617 "Translate M****s*** sm*rtq**t*s into proper text.
1618 Note that this function guesses whether a character is a sm*rtq**t* or
1619 not, so it should only be used interactively.
1621 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1622 in an attempt to provide more quoting characters. If you see
1623 something like \\222 or \\264 where you're expecting some kind of
1624 apostrophe or quotation mark, then try this wash."
1626 (article-translate-strings gnus-article-dumbquotes-map))
1628 (defun article-translate-characters (from to)
1629 "Translate all characters in the body of the article according to FROM and TO.
1630 FROM is a string of characters to translate from; to is a string of
1631 characters to translate to."
1633 (when (article-goto-body)
1634 (let ((buffer-read-only nil)
1635 (x (make-string 225 ?x))
1637 (while (< (incf i) (length x))
1640 (while (< i (length from))
1641 (aset x (aref from i) (aref to i))
1643 (translate-region (point) (point-max) x)))))
1645 (defun article-translate-strings (map)
1646 "Translate all string in the body of the article according to MAP.
1647 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1649 (when (article-goto-body)
1650 (let ((buffer-read-only nil)
1652 (while (setq elem (pop map))
1654 (while (search-forward (car elem) nil t)
1655 (replace-match (cadr elem)))))))))
1657 (defun article-treat-overstrike ()
1658 "Translate overstrikes into bold text."
1661 (when (article-goto-body)
1662 (let ((buffer-read-only nil))
1663 (while (search-forward "\b" nil t)
1664 (let ((next (char-after))
1665 (previous (char-after (- (point) 2))))
1666 ;; We do the boldification/underlining by hiding the
1667 ;; overstrikes and putting the proper text property
1671 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1672 (put-text-property (point) (1+ (point)) 'face 'bold))
1674 (gnus-article-hide-text-type
1675 (1- (point)) (1+ (point)) 'overstrike)
1677 (- (point) 2) (1- (point)) 'face 'underline))
1679 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1681 (point) (1+ (point)) 'face 'underline)))))))))
1683 (defun gnus-article-treat-unfold-headers ()
1684 "Unfold folded message headers.
1685 Only the headers that fit into the current window width will be
1688 (gnus-with-article-headers
1692 (mail-header-narrow-to-field)
1693 (let ((header (buffer-substring (point-min) (point-max))))
1696 (goto-char (point-min))
1697 (while (re-search-forward "\n[\t ]" nil t)
1698 (replace-match " " t t)))
1699 (setq length (- (point-max) (point-min) 1)))
1700 (when (< length (window-width))
1701 (while (re-search-forward "\n[\t ]" nil t)
1702 (replace-match " " t t)))
1703 (goto-char (point-max)))))))
1705 (defun gnus-article-treat-fold-headers ()
1706 "Fold message headers."
1708 (gnus-with-article-headers
1711 (mail-header-narrow-to-field)
1712 (mail-header-fold-field)
1713 (goto-char (point-max))))))
1715 (defun gnus-treat-smiley ()
1716 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1718 (gnus-with-article-buffer
1719 (if (memq 'smiley gnus-article-wash-types)
1720 (gnus-delete-images 'smiley)
1722 (let ((images (smiley-region (point) (point-max))))
1724 (gnus-add-wash-type 'smiley)
1725 (dolist (image images)
1726 (gnus-add-image 'smiley image)))))))
1728 (defun gnus-article-remove-images ()
1729 "Remove all images from the article buffer."
1731 (gnus-with-article-buffer
1732 (dolist (elem gnus-article-image-alist)
1733 (gnus-delete-images (car elem)))))
1735 (defun gnus-article-treat-fold-newsgroups ()
1736 "Unfold folded message headers.
1737 Only the headers that fit into the current window width will be
1740 (gnus-with-article-headers
1741 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1743 (mail-header-narrow-to-field)
1744 (while (re-search-forward ", *" nil t)
1745 (replace-match ", " t t))
1746 (mail-header-fold-field)
1747 (goto-char (point-max))))))
1749 (defun gnus-article-treat-body-boundary ()
1750 "Place a boundary line at the end of the headers."
1752 (when (and gnus-body-boundary-delimiter
1753 (> (length gnus-body-boundary-delimiter) 0))
1754 (gnus-with-article-headers
1755 (goto-char (point-max))
1756 (let ((start (point)))
1757 (insert "X-Boundary: ")
1758 (gnus-add-text-properties start (point) '(invisible t intangible t))
1760 (while (>= (1- (window-width)) (length str))
1761 (setq str (concat str gnus-body-boundary-delimiter)))
1762 (substring str 0 (1- (window-width))))
1764 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1766 (defun article-fill-long-lines ()
1767 "Fill lines that are wider than the window width."
1770 (let ((buffer-read-only nil)
1771 (width (window-width (get-buffer-window (current-buffer)))))
1774 (let ((adaptive-fill-mode nil)) ;Why? -sm
1777 (when (>= (current-column) (min fill-column width))
1778 (narrow-to-region (point) (gnus-point-at-bol))
1779 (fill-paragraph nil)
1780 (goto-char (point-max))
1782 (forward-line 1)))))))
1784 (defun article-capitalize-sentences ()
1785 "Capitalize the first word in each sentence."
1788 (let ((buffer-read-only nil)
1789 (paragraph-start "^[\n\^L]"))
1793 (forward-sentence)))))
1795 (defun article-remove-cr ()
1796 "Remove trailing CRs and then translate remaining CRs into LFs."
1799 (let ((buffer-read-only nil))
1800 (goto-char (point-min))
1801 (while (re-search-forward "\r+$" nil t)
1802 (replace-match "" t t))
1803 (goto-char (point-min))
1804 (while (search-forward "\r" nil t)
1805 (replace-match "\n" t t)))))
1807 (defun article-remove-trailing-blank-lines ()
1808 "Remove all trailing blank lines from the article."
1811 (let ((buffer-read-only nil))
1812 (goto-char (point-max))
1816 (while (and (not (bobp))
1817 (looking-at "^[ \t]*$")
1818 (not (gnus-annotation-in-region-p
1819 (point) (gnus-point-at-eol))))
1824 (defun article-display-x-face (&optional force)
1825 "Look for an X-Face header and display it if present."
1826 (interactive (list 'force))
1827 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1828 (gnus-with-article-headers
1829 ;; Delete the old process, if any.
1830 (when (process-status "article-x-face")
1831 (delete-process "article-x-face"))
1832 (if (memq 'xface gnus-article-wash-types)
1833 ;; We have already displayed X-Faces, so we remove them
1835 (gnus-delete-images 'xface)
1837 (let (x-faces from face grey)
1839 (when (and wash-face-p
1841 (goto-char (point-min))
1842 (not (re-search-forward
1843 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1844 (gnus-buffer-live-p gnus-original-article-buffer))
1845 ;; If type `W f', use gnus-original-article-buffer,
1846 ;; otherwise use the current buffer because displaying
1847 ;; RFC822 parts calls this function too.
1848 (set-buffer gnus-original-article-buffer))
1850 (mail-narrow-to-head)
1851 (if gnus-treat-display-grey-xface
1853 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1854 (if (match-beginning 2)
1857 (push (cons (- (string-to-number (match-string 2)))
1858 (mail-header-field-value))
1860 (push (cons 0 (mail-header-field-value)) x-faces)))
1861 (dolist (x-face (prog1
1863 (sort x-faces 'car-less-than-car)
1865 (setq x-faces nil)))
1866 (push (cdr x-face) x-faces)))
1867 (while (gnus-article-goto-header "X-Face")
1868 (push (mail-header-field-value) x-faces)))
1869 (setq from (message-fetch-field "from"))))
1871 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1874 (setq image (gnus-create-image xpm 'xpm t))
1875 (gnus-article-goto-header "from")
1877 (insert "From: [no `from' set]\n")
1879 (gnus-add-wash-type 'xface)
1880 (gnus-add-image 'xface image)
1881 (gnus-put-image image)))
1882 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1883 ;; single external face.
1884 (when (stringp gnus-article-x-face-command)
1885 (setq x-faces (list (car x-faces))))
1886 (while (and (setq face (pop x-faces))
1887 gnus-article-x-face-command
1889 ;; Check whether this face is censored.
1890 (not gnus-article-x-face-too-ugly)
1891 (and gnus-article-x-face-too-ugly from
1892 (not (string-match gnus-article-x-face-too-ugly
1894 ;; We display the face.
1895 (if (symbolp gnus-article-x-face-command)
1896 ;; The command is a lisp function, so we call it.
1897 (if (gnus-functionp gnus-article-x-face-command)
1898 (funcall gnus-article-x-face-command face)
1899 (error "%s is not a function" gnus-article-x-face-command))
1900 ;; The command is a string, so we interpret the command
1901 ;; as a, well, command, and fork it off.
1902 (let ((process-connection-type nil))
1903 (process-kill-without-query
1905 "article-x-face" nil shell-file-name shell-command-switch
1906 gnus-article-x-face-command))
1909 (process-send-region "article-x-face"
1910 (point-min) (point-max)))
1911 (process-send-eof "article-x-face"))))))))))
1913 (defun article-decode-mime-words ()
1914 "Decode all MIME-encoded words in the article."
1917 (set-buffer gnus-article-buffer)
1918 (let ((inhibit-point-motion-hooks t)
1920 (mail-parse-charset gnus-newsgroup-charset)
1921 (mail-parse-ignored-charsets
1922 (save-excursion (set-buffer gnus-summary-buffer)
1923 gnus-newsgroup-ignored-charsets)))
1924 (mail-decode-encoded-word-region (point-min) (point-max)))))
1926 (defun article-decode-charset (&optional prompt)
1927 "Decode charset-encoded text in the article.
1928 If PROMPT (the prefix), prompt for a coding system to use."
1930 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1932 (mail-parse-charset gnus-newsgroup-charset)
1933 (mail-parse-ignored-charsets
1934 (save-excursion (condition-case nil
1935 (set-buffer gnus-summary-buffer)
1937 gnus-newsgroup-ignored-charsets))
1938 ct cte ctl charset format)
1941 (article-narrow-to-head)
1942 (setq ct (message-fetch-field "Content-Type" t)
1943 cte (message-fetch-field "Content-Transfer-Encoding" t)
1944 ctl (and ct (ignore-errors
1945 (mail-header-parse-content-type ct)))
1948 (mm-read-coding-system "Charset to decode: "))
1950 (mail-content-type-get ctl 'charset)))
1951 format (and ctl (mail-content-type-get ctl 'format)))
1953 (setq cte (mail-header-strip cte)))
1954 (if (and ctl (not (string-match "/" (car ctl))))
1956 (goto-char (point-max)))
1959 (narrow-to-region (point) (point-max))
1960 (when (and (eq mail-parse-charset 'gnus-decoded)
1961 (eq (mm-body-7-or-8) '8bit))
1962 ;; The text code could have been decoded.
1963 (setq charset mail-parse-charset))
1964 (when (and (or (not ctl)
1965 (equal (car ctl) "text/plain"))
1966 (not format)) ;; article with format will decode later.
1968 charset (and cte (intern (downcase
1969 (gnus-strip-whitespace cte))))
1972 (defun article-decode-encoded-words ()
1973 "Remove encoded-word encoding from headers."
1974 (let ((inhibit-point-motion-hooks t)
1975 (mail-parse-charset gnus-newsgroup-charset)
1976 (mail-parse-ignored-charsets
1977 (save-excursion (condition-case nil
1978 (set-buffer gnus-summary-buffer)
1980 gnus-newsgroup-ignored-charsets))
1983 (article-narrow-to-head)
1984 (funcall gnus-decode-header-function (point-min) (point-max)))))
1986 (defun article-decode-group-name ()
1987 "Decode group names in `Newsgroups:'."
1988 (let ((inhibit-point-motion-hooks t)
1990 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1991 (when (and (or gnus-group-name-charset-method-alist
1992 gnus-group-name-charset-group-alist)
1993 (gnus-buffer-live-p gnus-original-article-buffer))
1994 (when (nnmail-fetch-field "Newsgroups")
1995 (nnheader-replace-header "Newsgroups"
1996 (gnus-decode-newsgroups
1997 (with-current-buffer
1998 gnus-original-article-buffer
1999 (nnmail-fetch-field "Newsgroups"))
2000 gnus-newsgroup-name method)))
2001 (when (nnmail-fetch-field "Followup-To")
2002 (nnheader-replace-header "Followup-To"
2003 (gnus-decode-newsgroups
2004 (with-current-buffer
2005 gnus-original-article-buffer
2006 (nnmail-fetch-field "Followup-To"))
2007 gnus-newsgroup-name method))))))
2009 (defun article-de-quoted-unreadable (&optional force read-charset)
2010 "Translate a quoted-printable-encoded article.
2011 If FORCE, decode the article whether it is marked as quoted-printable
2013 If READ-CHARSET, ask for a coding system."
2014 (interactive (list 'force current-prefix-arg))
2016 (let ((buffer-read-only nil) type charset)
2017 (if (gnus-buffer-live-p gnus-original-article-buffer)
2018 (with-current-buffer gnus-original-article-buffer
2020 (gnus-fetch-field "content-transfer-encoding"))
2021 (let* ((ct (gnus-fetch-field "content-type"))
2024 (mail-header-parse-content-type ct)))))
2025 (setq charset (and ctl
2026 (mail-content-type-get ctl 'charset)))
2027 (if (stringp charset)
2028 (setq charset (intern (downcase charset)))))))
2030 (setq charset (mm-read-coding-system "Charset: " charset)))
2032 (setq charset gnus-newsgroup-charset))
2034 (and type (let ((case-fold-search t))
2035 (string-match "quoted-printable" type))))
2037 (quoted-printable-decode-region
2038 (point) (point-max) (mm-charset-to-coding-system charset))))))
2040 (defun article-de-base64-unreadable (&optional force read-charset)
2041 "Translate a base64 article.
2042 If FORCE, decode the article whether it is marked as base64 not.
2043 If READ-CHARSET, ask for a coding system."
2044 (interactive (list 'force current-prefix-arg))
2046 (let ((buffer-read-only nil) type charset)
2047 (if (gnus-buffer-live-p gnus-original-article-buffer)
2048 (with-current-buffer gnus-original-article-buffer
2050 (gnus-fetch-field "content-transfer-encoding"))
2051 (let* ((ct (gnus-fetch-field "content-type"))
2054 (mail-header-parse-content-type ct)))))
2055 (setq charset (and ctl
2056 (mail-content-type-get ctl 'charset)))
2057 (if (stringp charset)
2058 (setq charset (intern (downcase charset)))))))
2060 (setq charset (mm-read-coding-system "Charset: " charset)))
2062 (setq charset gnus-newsgroup-charset))
2064 (and type (let ((case-fold-search t))
2065 (string-match "base64" type))))
2068 (narrow-to-region (point) (point-max))
2069 (base64-decode-region (point-min) (point-max))
2070 (mm-decode-coding-region
2071 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2076 (defun article-decode-HZ ()
2077 "Translate a HZ-encoded article."
2081 (let ((buffer-read-only nil))
2082 (rfc1843-decode-region (point-min) (point-max)))))
2084 (defun article-unsplit-urls ()
2085 "Remove the newlines that some other mailers insert into URLs."
2088 (let ((buffer-read-only nil))
2089 (goto-char (point-min))
2090 (while (re-search-forward
2091 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2092 (replace-match "\\1\\3" t)))
2093 (when (and gnus-display-mime-function (interactive-p))
2094 (funcall gnus-display-mime-function))))
2097 (defun article-wash-html (&optional read-charset)
2098 "Format an html article.
2099 If READ-CHARSET, ask for a coding system."
2102 (let ((buffer-read-only nil)
2104 (if (gnus-buffer-live-p gnus-original-article-buffer)
2105 (with-current-buffer gnus-original-article-buffer
2106 (let* ((ct (gnus-fetch-field "content-type"))
2109 (mail-header-parse-content-type ct)))))
2110 (setq charset (and ctl
2111 (mail-content-type-get ctl 'charset)))
2112 (if (stringp charset)
2113 (setq charset (intern (downcase charset)))))))
2115 (setq charset (mm-read-coding-system "Charset: " charset)))
2117 (setq charset gnus-newsgroup-charset))
2119 (save-window-excursion
2121 (narrow-to-region (point) (point-max))
2122 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2123 (entry (assq func mm-text-html-washer-alist)))
2125 (setq func (cdr entry)))
2127 ((gnus-functionp func)
2130 (apply (car func) (cdr func))))))))))
2132 (defun gnus-article-wash-html-with-w3 ()
2133 "Wash the current buffer with w3."
2135 (let ((w3-strict-width (window-width))
2136 (url-standalone-mode t)
2137 (url-gateway-unplugged t)
2138 (w3-honor-stylesheets nil))
2140 (w3-region (point-min) (point-max))
2143 (defun gnus-article-wash-html-with-w3m ()
2144 "Wash the current buffer with emacs-w3m."
2147 (narrow-to-region (point) (point-max))
2148 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2151 (w3m-display-inline-images mm-inline-text-html-with-images)
2152 w3m-force-redisplay)
2153 (w3m-region (point-min) (point-max)))
2154 (when mm-inline-text-html-with-w3m-keymap
2155 (add-text-properties
2156 (point-min) (point-max)
2157 (append '(mm-inline-text-html-with-w3m t)
2158 (gnus-local-map-property mm-w3m-mode-map))))))
2160 (defun article-hide-list-identifiers ()
2161 "Remove list identifies from the Subject header.
2162 The `gnus-list-identifiers' variable specifies what to do."
2164 (let ((inhibit-point-motion-hooks t)
2165 (regexp (if (consp gnus-list-identifiers)
2166 (mapconcat 'identity gnus-list-identifiers " *\\|")
2167 gnus-list-identifiers))
2172 (article-narrow-to-head)
2173 (goto-char (point-min))
2174 (while (re-search-forward
2175 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2177 (delete-region (match-beginning 2) (match-end 0))
2178 (beginning-of-line))
2179 (when (re-search-forward
2180 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2181 (delete-region (match-beginning 1) (match-end 1))))))))
2183 (defun article-hide-pgp ()
2184 "Remove any PGP headers and signatures in the current article."
2188 (let ((inhibit-point-motion-hooks t)
2189 buffer-read-only beg end)
2191 ;; Hide the "header".
2192 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2193 (gnus-add-wash-type 'pgp)
2194 (delete-region (match-beginning 0) (match-end 0))
2195 ;; Remove armor headers (rfc2440 6.2)
2196 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2199 ;; Hide the actual signature.
2200 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2201 (setq end (1+ (match-beginning 0)))
2204 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2206 ;; Perhaps we shouldn't hide to the end of the buffer
2207 ;; if there is no end to the signature?
2209 ;; Hide "- " PGP quotation markers.
2211 (narrow-to-region beg end)
2212 (goto-char (point-min))
2213 (while (re-search-forward "^- " nil t)
2215 (match-beginning 0) (match-end 0)))
2217 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2219 (defun article-hide-pem (&optional arg)
2220 "Toggle hiding of any PEM headers and signatures in the current article.
2221 If given a negative prefix, always show; if given a positive prefix,
2223 (interactive (gnus-article-hidden-arg))
2224 (unless (gnus-article-check-hidden-text 'pem arg)
2226 (let (buffer-read-only end)
2227 (goto-char (point-min))
2228 ;; Hide the horrendously ugly "header".
2229 (when (and (search-forward
2230 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2232 (setq end (1+ (match-beginning 0))))
2233 (gnus-add-wash-type 'pem)
2234 (gnus-article-hide-text-type
2236 (if (search-forward "\n\n" nil t)
2240 ;; Hide the trailer as well
2241 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2243 (gnus-article-hide-text-type
2244 (match-beginning 0) (match-end 0) 'pem)))))))
2246 (defun article-strip-banner ()
2247 "Strip the banner specified by the `banner' group parameter."
2251 (let ((inhibit-point-motion-hooks t)
2252 (banner (gnus-parameter-banner gnus-newsgroup-name))
2253 (gnus-signature-limit nil)
2254 buffer-read-only beg end)
2258 ((eq banner 'signature)
2259 (when (gnus-article-narrow-to-signature)
2262 (delete-region (point) (point-max))))
2264 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2265 (while (re-search-forward banner nil t)
2266 (delete-region (match-beginning 0) (match-end 0)))))
2268 (while (re-search-forward banner nil t)
2269 (delete-region (match-beginning 0) (match-end 0))))))))))
2271 (defun article-babel ()
2272 "Translate article using an online translation service."
2276 (set-buffer gnus-article-buffer)
2277 (when (article-goto-body)
2278 (let* ((buffer-read-only nil)
2281 (orig (buffer-substring start end))
2282 (trans (babel-as-string orig)))
2284 (narrow-to-region start end)
2285 (delete-region start end)
2288 (defun article-hide-signature (&optional arg)
2289 "Hide the signature in the current article.
2290 If given a negative prefix, always show; if given a positive prefix,
2292 (interactive (gnus-article-hidden-arg))
2293 (unless (gnus-article-check-hidden-text 'signature arg)
2296 (let ((buffer-read-only nil))
2297 (when (gnus-article-narrow-to-signature)
2298 (gnus-article-hide-text-type
2299 (point-min) (point-max) 'signature))))))
2300 (gnus-set-mode-line 'article))
2302 (defun article-strip-headers-in-body ()
2303 "Strip offensive headers from bodies."
2307 (let ((case-fold-search t))
2308 (when (looking-at "x-no-archive:")
2309 (gnus-delete-line)))))
2311 (defun article-strip-leading-blank-lines ()
2312 "Remove all blank lines from the beginning of the article."
2315 (let ((inhibit-point-motion-hooks t)
2317 (when (article-goto-body)
2318 (while (and (not (eobp))
2319 (looking-at "[ \t]*$"))
2320 (gnus-delete-line))))))
2322 (defun article-narrow-to-head ()
2323 "Narrow the buffer to the head of the message.
2324 Point is left at the beginning of the narrowed-to region."
2326 (goto-char (point-min))
2327 (if (search-forward "\n\n" nil 1)
2330 (goto-char (point-min)))
2332 (defun article-goto-body ()
2333 "Place point at the start of the body."
2334 (goto-char (point-min))
2336 ;; This variable is only bound when dealing with separate
2338 (article-goto-body-goes-to-point-min-p
2340 ((search-forward "\n\n" nil t)
2343 (goto-char (point-max))
2346 (defun article-strip-multiple-blank-lines ()
2347 "Replace consecutive blank lines with one empty line."
2350 (let ((inhibit-point-motion-hooks t)
2352 ;; First make all blank lines empty.
2354 (while (re-search-forward "^[ \t]+$" nil t)
2355 (unless (gnus-annotation-in-region-p
2356 (match-beginning 0) (match-end 0))
2357 (replace-match "" nil t)))
2358 ;; Then replace multiple empty lines with a single empty line.
2360 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2361 (unless (gnus-annotation-in-region-p
2362 (match-beginning 0) (match-end 0))
2363 (delete-region (match-beginning 1) (match-end 1)))))))
2365 (defun article-strip-leading-space ()
2366 "Remove all white space from the beginning of the lines in the article."
2369 (let ((inhibit-point-motion-hooks t)
2372 (while (re-search-forward "^[ \t]+" nil t)
2373 (replace-match "" t t)))))
2375 (defun article-strip-trailing-space ()
2376 "Remove all white space from the end of the lines in the article."
2379 (let ((inhibit-point-motion-hooks t)
2382 (while (re-search-forward "[ \t]+$" nil t)
2383 (replace-match "" t t)))))
2385 (defun article-strip-blank-lines ()
2386 "Strip leading, trailing and multiple blank lines."
2388 (article-strip-leading-blank-lines)
2389 (article-remove-trailing-blank-lines)
2390 (article-strip-multiple-blank-lines))
2392 (defun article-strip-all-blank-lines ()
2393 "Strip all blank lines."
2396 (let ((inhibit-point-motion-hooks t)
2399 (while (re-search-forward "^[ \t]*\n" nil t)
2400 (replace-match "" t t)))))
2402 (defun gnus-article-narrow-to-signature ()
2403 "Narrow to the signature; return t if a signature is found, else nil."
2404 (let ((inhibit-point-motion-hooks t))
2405 (when (gnus-article-search-signature)
2407 ;; Check whether we have some limits to what we consider
2408 ;; to be a signature.
2409 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2410 (list gnus-signature-limit)))
2412 (while (setq limit (pop limits))
2413 (if (or (and (integerp limit)
2414 (< (- (point-max) (point)) limit))
2416 (< (count-lines (point) (point-max)) limit))
2417 (and (gnus-functionp limit)
2419 (and (stringp limit)
2420 (not (re-search-forward limit nil t))))
2421 () ; This limit did not succeed.
2425 (narrow-to-region (point) (point-max))
2428 (defun gnus-article-search-signature ()
2429 "Search the current buffer for the signature separator.
2430 Put point at the beginning of the signature separator."
2431 (let ((cur (point)))
2432 (goto-char (point-max))
2433 (if (if (stringp gnus-signature-separator)
2434 (re-search-backward gnus-signature-separator nil t)
2435 (let ((seps gnus-signature-separator))
2437 (not (re-search-backward (car seps) nil t)))
2444 (defun gnus-article-hidden-arg ()
2445 "Return the current prefix arg as a number, or 0 if no prefix."
2446 (list (if current-prefix-arg
2447 (prefix-numeric-value current-prefix-arg)
2450 (defun gnus-article-check-hidden-text (type arg)
2451 "Return nil if hiding is necessary.
2452 Arg can be nil or a number. nil and positive means hide, negative
2453 means show, 0 means toggle."
2456 (let ((hide (gnus-article-hidden-text-p type)))
2462 (gnus-article-show-hidden-text type)
2465 (if (eq hide 'hidden)
2467 (gnus-article-show-hidden-text type)
2471 (defun gnus-article-hidden-text-p (type)
2472 "Say whether the current buffer contains hidden text of type TYPE."
2473 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2475 (not (get-text-property pos 'invisible))
2476 (not (get-text-property pos 'dummy-invisible)))
2478 (text-property-any (1+ pos) (point-max) 'article-type type)))
2483 (defun gnus-article-show-hidden-text (type &optional dummy)
2484 "Show all hidden text of type TYPE.
2485 Originally it is hide instead of DUMMY."
2486 (let ((buffer-read-only nil)
2487 (inhibit-point-motion-hooks t))
2488 (gnus-remove-text-properties-when
2490 (point-min) (point-max)
2491 (cons 'article-type (cons type
2492 gnus-hidden-properties)))
2493 (gnus-delete-wash-type type)))
2495 (defconst article-time-units
2496 `((year . ,(* 365.25 24 60 60))
2497 (week . ,(* 7 24 60 60))
2498 (day . ,(* 24 60 60))
2502 "Mapping from time units to seconds.")
2504 (defun article-date-ut (&optional type highlight header)
2505 "Convert DATE date to universal time in the current article.
2506 If TYPE is `local', convert to local time; if it is `lapsed', output
2507 how much time has lapsed since DATE. For `lapsed', the value of
2508 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2509 should replace the \"Date:\" one, or should be added below it."
2510 (interactive (list 'ut t))
2511 (let* ((header (or header
2512 (message-fetch-field "date")
2514 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2517 ((not gnus-article-date-lapsed-new-header)
2523 (date (if (vectorp header) (mail-header-date header)
2525 (inhibit-point-motion-hooks t)
2530 (article-narrow-to-head)
2531 (when (re-search-forward tdate-regexp nil t)
2532 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2533 date (or (get-text-property (gnus-point-at-bol)
2536 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2538 (when (and date (not (string= date "")))
2539 (goto-char (point-min))
2540 (let ((buffer-read-only nil))
2541 ;; Delete any old Date headers.
2542 (while (re-search-forward date-regexp nil t)
2544 (delete-region (progn (beginning-of-line) (point))
2545 (progn (forward-line 1) (point)))
2546 (delete-region (progn (beginning-of-line) (point))
2547 (progn (end-of-line) (point)))
2548 (setq pos (point))))
2549 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2551 (if pos (goto-char pos))
2552 (insert (article-make-date-line date (or type 'ut)))
2558 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2559 (put-text-property (match-beginning 1) (1+ (match-end 1))
2560 'original-date date)
2561 (put-text-property (match-beginning 1) (1+ (match-end 1))
2563 (put-text-property (match-beginning 2) (match-end 2)
2566 (defun article-make-date-line (date type)
2567 "Return a DATE line of TYPE."
2568 (unless (memq type '(local ut original user iso8601 lapsed english))
2569 (error "Unknown conversion type: %s" type))
2571 (let ((time (date-to-time date)))
2573 ;; Convert to the local timezone.
2575 (let ((tz (car (current-time-zone time))))
2576 (format "Date: %s %s%02d%02d" (current-time-string time)
2577 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2578 (/ (% (abs tz) 3600) 60))))
2579 ;; Convert to Universal Time.
2582 (current-time-string
2583 (let* ((e (parse-time-string date))
2584 (tm (apply 'encode-time e))
2586 (ls (- (cadr tm) (car (current-time-zone time)))))
2587 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2588 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2591 ;; Get the original date from the article.
2592 ((eq type 'original)
2593 (concat "Date: " (if (string-match "\n+$" date)
2594 (substring date 0 (match-beginning 0))
2596 ;; Let the user define the format.
2598 (let ((format (or (condition-case nil
2599 (with-current-buffer gnus-summary-buffer
2600 gnus-article-time-format)
2602 gnus-article-time-format)))
2603 (if (gnus-functionp format)
2604 (funcall format time)
2605 (concat "Date: " (format-time-string format time)))))
2608 (let ((tz (car (current-time-zone time))))
2611 (format-time-string "%Y%m%dT%H%M%S" time)
2612 (format "%s%02d%02d"
2613 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2614 (/ (% (abs tz) 3600) 60)))))
2615 ;; Do an X-Sent lapsed format.
2617 ;; If the date is seriously mangled, the timezone functions are
2618 ;; liable to bug out, so we ignore all errors.
2619 (let* ((now (current-time))
2620 (real-time (subtract-time now time))
2621 (real-sec (and real-time
2622 (+ (* (float (car real-time)) 65536)
2624 (sec (and real-time (abs real-sec)))
2634 ;; This is a bit convoluted, but basically we go
2635 ;; through the time units for years, weeks, etc,
2636 ;; and divide things to see whether that results
2637 ;; in positive answers.
2640 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2641 ;; The (remaining) seconds are too few to
2642 ;; be divided into this time unit.
2644 ;; It's big enough, so we output it.
2645 (setq sec (- sec (* num (cdr unit))))
2647 (concat (if prev ", " "") (int-to-string
2649 " " (symbol-name (car unit))
2650 (if (> num 1) "s" ""))
2652 article-time-units "")
2653 ;; If dates are odd, then it might appear like the
2654 ;; article was sent in the future.
2657 " in the future"))))))
2658 ;; Display the date in proper English
2660 (let ((dtime (decode-time time)))
2663 (number-to-string (nth 3 dtime))
2664 (let ((digit (% (nth 3 dtime) 10)))
2666 ((memq (nth 3 dtime) '(11 12 13)) "th")
2672 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2674 (number-to-string (nth 5 dtime))
2676 (format "%02d" (nth 2 dtime))
2678 (format "%02d" (nth 1 dtime)))))))
2680 (format "Date: %s (from Gnus)" date))))
2682 (defun article-date-local (&optional highlight)
2683 "Convert the current article date to the local timezone."
2684 (interactive (list t))
2685 (article-date-ut 'local highlight))
2687 (defun article-date-english (&optional highlight)
2688 "Convert the current article date to something that is proper English."
2689 (interactive (list t))
2690 (article-date-ut 'english highlight))
2692 (defun article-date-original (&optional highlight)
2693 "Convert the current article date to what it was originally.
2694 This is only useful if you have used some other date conversion
2695 function and want to see what the date was before converting."
2696 (interactive (list t))
2697 (article-date-ut 'original highlight))
2699 (defun article-date-lapsed (&optional highlight)
2700 "Convert the current article date to time lapsed since it was sent."
2701 (interactive (list t))
2702 (article-date-ut 'lapsed highlight))
2704 (defun article-update-date-lapsed ()
2705 "Function to be run from a timer to update the lapsed time line."
2706 (let (deactivate-mark)
2711 (set-buffer (window-buffer w))
2712 (when (eq major-mode 'gnus-article-mode)
2713 (goto-char (point-min))
2714 (when (re-search-forward "^X-Sent:" nil t)
2715 (article-date-lapsed t))))
2718 (defun gnus-start-date-timer (&optional n)
2719 "Start a timer to update the X-Sent header in the article buffers.
2720 The numerical prefix says how frequently (in seconds) the function
2725 (gnus-stop-date-timer)
2726 (setq article-lapsed-timer
2727 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2729 (defun gnus-stop-date-timer ()
2730 "Stop the X-Sent timer."
2732 (when article-lapsed-timer
2733 (nnheader-cancel-timer article-lapsed-timer)
2734 (setq article-lapsed-timer nil)))
2736 (defun article-date-user (&optional highlight)
2737 "Convert the current article date to the user-defined format.
2738 This format is defined by the `gnus-article-time-format' variable."
2739 (interactive (list t))
2740 (article-date-ut 'user highlight))
2742 (defun article-date-iso8601 (&optional highlight)
2743 "Convert the current article date to ISO8601."
2744 (interactive (list t))
2745 (article-date-ut 'iso8601 highlight))
2747 ;; (defun article-show-all ()
2748 ;; "Show all hidden text in the article buffer."
2751 ;; (let ((buffer-read-only nil))
2752 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2754 (defun article-remove-leading-whitespace ()
2755 "Remove excessive whitespace from all headers."
2759 (let ((buffer-read-only nil))
2760 (article-narrow-to-head)
2761 (goto-char (point-min))
2762 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2763 (delete-region (match-beginning 1) (match-end 1)))))))
2765 (defun article-emphasize (&optional arg)
2766 "Emphasize text according to `gnus-emphasis-alist'."
2767 (interactive (gnus-article-hidden-arg))
2768 (unless (gnus-article-check-hidden-text 'emphasis arg)
2772 (with-current-buffer gnus-summary-buffer
2773 gnus-article-emphasis-alist)
2775 gnus-emphasis-alist))
2776 (buffer-read-only nil)
2777 (props (append '(article-type emphasis)
2778 gnus-hidden-properties))
2779 regexp elem beg invisible visible face)
2782 (while (setq elem (pop alist))
2784 (setq regexp (car elem)
2785 invisible (nth 1 elem)
2786 visible (nth 2 elem)
2788 (while (re-search-forward regexp nil t)
2789 (when (and (match-beginning visible) (match-beginning invisible))
2790 (gnus-article-hide-text
2791 (match-beginning invisible) (match-end invisible) props)
2792 (gnus-article-unhide-text-type
2793 (match-beginning visible) (match-end visible) 'emphasis)
2794 (gnus-put-overlay-excluding-newlines
2795 (match-beginning visible) (match-end visible) 'face face)
2796 (gnus-add-wash-type 'emphasis)
2797 (goto-char (match-end invisible)))))))))
2799 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2800 "Setup newsgroup emphasis alist."
2801 (unless gnus-article-emphasis-alist
2802 (let ((name (and gnus-newsgroup-name
2803 (gnus-group-real-name gnus-newsgroup-name))))
2804 (make-local-variable 'gnus-article-emphasis-alist)
2805 (setq gnus-article-emphasis-alist
2807 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2808 (while (setq elem (pop alist))
2809 (when (and name (string-match (car elem) name))
2811 highlight (copy-sequence (cdr elem)))))
2813 (copy-sequence highlight-words)
2814 (if gnus-newsgroup-name
2815 (copy-sequence (gnus-group-find-parameter
2816 gnus-newsgroup-name 'highlight-words t)))
2817 gnus-emphasis-alist)))))
2820 (defvar gnus-summary-article-menu)
2821 (defvar gnus-summary-post-menu))
2823 ;;; Saving functions.
2825 (defun gnus-article-save (save-buffer file &optional num)
2826 "Save the currently selected article."
2827 (unless gnus-save-all-headers
2828 ;; Remove headers according to `gnus-saved-headers'.
2829 (let ((gnus-visible-headers
2830 (or gnus-saved-headers gnus-visible-headers))
2831 (gnus-article-buffer save-buffer))
2833 (set-buffer save-buffer)
2834 (article-hide-headers 1 t))))
2835 (save-window-excursion
2836 (if (not gnus-default-article-saver)
2837 (error "No default saver is defined")
2838 ;; !!! Magic! The saving functions all save
2839 ;; `gnus-save-article-buffer' (or so they think), but we
2840 ;; bind that variable to our save-buffer.
2841 (set-buffer gnus-article-buffer)
2842 (let* ((gnus-save-article-buffer save-buffer)
2845 ((not gnus-prompt-before-saving) 'default)
2846 ((eq gnus-prompt-before-saving 'always) nil)
2848 (gnus-number-of-articles-to-be-saved
2849 (when (eq gnus-prompt-before-saving t)
2851 (set-buffer gnus-article-current-summary)
2852 (funcall gnus-default-article-saver filename)))))
2854 (defun gnus-read-save-file-name (prompt &optional filename
2855 function group headers variable)
2857 (funcall function group headers (symbol-value variable)))
2862 ((eq filename 'default)
2868 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2871 (if (and gnus-number-of-articles-to-be-saved
2872 (> gnus-number-of-articles-to-be-saved 1))
2873 (format "these %d articles"
2874 gnus-number-of-articles-to-be-saved)
2877 ;; Let the split methods have their say.
2879 ;; No split name was found.
2882 (concat prompt " (default "
2883 (file-name-nondirectory default-name) ") ")
2884 (file-name-directory default-name)
2886 ;; A single group name is returned.
2887 ((stringp split-name)
2889 (funcall function split-name headers
2890 (symbol-value variable)))
2892 (concat prompt " (default "
2893 (file-name-nondirectory default-name) ") ")
2894 (file-name-directory default-name)
2896 ;; A single split name was found
2897 ((= 1 (length split-name))
2898 (let* ((name (expand-file-name
2900 gnus-article-save-directory))
2901 (dir (cond ((file-directory-p name)
2902 (file-name-as-directory name))
2903 ((file-exists-p name) name)
2904 (t gnus-article-save-directory))))
2906 (concat prompt " (default " name ") ")
2908 ;; A list of splits was found.
2910 (setq split-name (nreverse split-name))
2912 (let ((file-name-history
2913 (nconc split-name file-name-history)))
2917 (concat prompt " (`M-p' for defaults) ")
2918 gnus-article-save-directory
2920 gnus-article-save-directory)))
2921 (car (push result file-name-history)))))))
2922 ;; Create the directory.
2923 (gnus-make-directory (file-name-directory file))
2924 ;; If we have read a directory, we append the default file name.
2925 (when (file-directory-p file)
2926 (setq file (expand-file-name (file-name-nondirectory
2928 (file-name-as-directory file))))
2929 ;; Possibly translate some characters.
2930 (nnheader-translate-file-chars file))))))
2931 (gnus-make-directory (file-name-directory result))
2932 (set variable result)))
2934 (defun gnus-article-archive-name (group)
2935 "Return the first instance of an \"Archive-name\" in the current buffer."
2936 (let ((case-fold-search t))
2937 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2938 (nnheader-concat gnus-article-save-directory
2939 (match-string 1)))))
2941 (defun gnus-article-nndoc-name (group)
2942 "If GROUP is an nndoc group, return the name of the parent group."
2943 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2944 (gnus-group-get-parameter group 'save-article-group)))
2946 (defun gnus-summary-save-in-rmail (&optional filename)
2947 "Append this article to Rmail file.
2948 Optional argument FILENAME specifies file name.
2949 Directory to save to is default to `gnus-article-save-directory'."
2950 (setq filename (gnus-read-save-file-name
2951 "Save %s in rmail file:" filename
2952 gnus-rmail-save-name gnus-newsgroup-name
2953 gnus-current-headers 'gnus-newsgroup-last-rmail))
2954 (gnus-eval-in-buffer-window gnus-save-article-buffer
2958 (gnus-output-to-rmail filename))))
2961 (defun gnus-summary-save-in-mail (&optional filename)
2962 "Append this article to Unix mail file.
2963 Optional argument FILENAME specifies file name.
2964 Directory to save to is default to `gnus-article-save-directory'."
2965 (setq filename (gnus-read-save-file-name
2966 "Save %s in Unix mail file:" filename
2967 gnus-mail-save-name gnus-newsgroup-name
2968 gnus-current-headers 'gnus-newsgroup-last-mail))
2969 (gnus-eval-in-buffer-window gnus-save-article-buffer
2973 (if (and (file-readable-p filename)
2974 (mail-file-babyl-p filename))
2975 (rmail-output-to-rmail-file filename t)
2976 (gnus-output-to-mail filename)))))
2979 (defun gnus-summary-save-in-file (&optional filename overwrite)
2980 "Append this article to file.
2981 Optional argument FILENAME specifies file name.
2982 Directory to save to is default to `gnus-article-save-directory'."
2983 (setq filename (gnus-read-save-file-name
2984 "Save %s in file:" filename
2985 gnus-file-save-name gnus-newsgroup-name
2986 gnus-current-headers 'gnus-newsgroup-last-file))
2987 (gnus-eval-in-buffer-window gnus-save-article-buffer
2991 (when (and overwrite
2992 (file-exists-p filename))
2993 (delete-file filename))
2994 (gnus-output-to-file filename))))
2997 (defun gnus-summary-write-to-file (&optional filename)
2998 "Write this article to a file, overwriting it if the file exists.
2999 Optional argument FILENAME specifies file name.
3000 The directory to save in defaults to `gnus-article-save-directory'."
3001 (gnus-summary-save-in-file nil t))
3003 (defun gnus-summary-save-body-in-file (&optional filename)
3004 "Append this article body to a file.
3005 Optional argument FILENAME specifies file name.
3006 The directory to save in defaults to `gnus-article-save-directory'."
3007 (setq filename (gnus-read-save-file-name
3008 "Save %s body in file:" filename
3009 gnus-file-save-name gnus-newsgroup-name
3010 gnus-current-headers 'gnus-newsgroup-last-file))
3011 (gnus-eval-in-buffer-window gnus-save-article-buffer
3015 (when (article-goto-body)
3016 (narrow-to-region (point) (point-max)))
3017 (gnus-output-to-file filename))))
3020 (defun gnus-summary-save-in-pipe (&optional command)
3021 "Pipe this article to subprocess."
3023 (cond ((and (eq command 'default)
3024 gnus-last-shell-command)
3025 gnus-last-shell-command)
3030 "Shell command on %s: "
3031 (if (and gnus-number-of-articles-to-be-saved
3032 (> gnus-number-of-articles-to-be-saved 1))
3033 (format "these %d articles"
3034 gnus-number-of-articles-to-be-saved)
3036 gnus-last-shell-command))))
3037 (when (string-equal command "")
3038 (if gnus-last-shell-command
3039 (setq command gnus-last-shell-command)
3040 (error "A command is required")))
3041 (gnus-eval-in-buffer-window gnus-article-buffer
3044 (shell-command-on-region (point-min) (point-max) command nil)))
3045 (setq gnus-last-shell-command command))
3047 (defun gnus-summary-pipe-to-muttprint (&optional command)
3048 "Pipe this article to muttprint."
3049 (setq command (read-string
3050 "Print using command: " gnus-summary-muttprint-program
3051 nil gnus-summary-muttprint-program))
3052 (gnus-summary-save-in-pipe command))
3054 ;;; Article file names when saving.
3056 (defun gnus-capitalize-newsgroup (newsgroup)
3057 "Capitalize NEWSGROUP name."
3058 (when (not (zerop (length newsgroup)))
3059 (concat (char-to-string (upcase (aref newsgroup 0)))
3060 (substring newsgroup 1))))
3062 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3063 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3064 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3065 Otherwise, it is like ~/News/news/group/num."
3068 (concat (if (gnus-use-long-file-name 'not-save)
3069 (gnus-capitalize-newsgroup newsgroup)
3070 (gnus-newsgroup-directory-form newsgroup))
3071 "/" (int-to-string (mail-header-number headers)))
3072 gnus-article-save-directory)))
3074 (string-equal (file-name-directory default)
3075 (file-name-directory last-file))
3076 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3078 (or last-file default))))
3080 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3081 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3082 If variable `gnus-use-long-file-name' is non-nil, it is
3083 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3086 (concat (if (gnus-use-long-file-name 'not-save)
3088 (gnus-newsgroup-directory-form newsgroup))
3089 "/" (int-to-string (mail-header-number headers)))
3090 gnus-article-save-directory)))
3092 (string-equal (file-name-directory default)
3093 (file-name-directory last-file))
3094 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3096 (or last-file default))))
3098 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3099 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3100 If variable `gnus-use-long-file-name' is non-nil, it is
3101 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3104 (if (gnus-use-long-file-name 'not-save)
3107 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3109 gnus-article-save-directory)))
3111 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3112 "Generate file name from sender."
3113 (let ((from (mail-header-from headers)))
3115 (if (and from (string-match "\\([^ <]+\\)@" from))
3116 (match-string 1 from)
3118 gnus-article-save-directory)))
3120 (defun article-verify-x-pgp-sig ()
3123 (if (gnus-buffer-live-p gnus-original-article-buffer)
3124 (let ((sig (with-current-buffer gnus-original-article-buffer
3125 (gnus-fetch-field "X-PGP-Sig")))
3129 (mml2015-clear-verify-function))
3131 (insert-buffer gnus-original-article-buffer)
3132 (setq items (split-string sig))
3133 (message-narrow-to-head)
3134 (let ((inhibit-point-motion-hooks t)
3135 (case-fold-search t))
3136 ;; Don't verify multiple headers.
3137 (setq headers (mapconcat (lambda (header)
3139 (mail-fetch-field header) "\n"))
3140 (split-string (nth 1 items) ",") "")))
3141 (delete-region (point-min) (point-max))
3142 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3143 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3148 (if (looking-at "^-")
3151 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3152 (insert "Version: " (car items) "\n\n")
3153 (insert (mapconcat 'identity (cddr items) "\n"))
3154 (insert "\n-----END PGP SIGNATURE-----\n")
3155 (let ((mm-security-handle (list (format "multipart/signed"))))
3156 (mml2015-clean-buffer)
3157 (let ((coding-system-for-write (or gnus-newsgroup-charset
3159 (funcall (mml2015-clear-verify-function)))
3161 (or (mm-handle-multipart-ctl-parameter
3162 mm-security-handle 'gnus-details)
3163 (mm-handle-multipart-ctl-parameter
3164 mm-security-handle 'gnus-info)))))
3166 (let (buffer-read-only bface eface)
3168 (message-narrow-to-head)
3169 (goto-char (point-max))
3171 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3172 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3173 (message-remove-header "X-Gnus-PGP-Verify")
3174 (if (re-search-forward "^X-PGP-Sig:" nil t)
3176 (goto-char (point-max)))
3177 (narrow-to-region (point) (point))
3178 (insert "X-Gnus-PGP-Verify: " info "\n")
3179 (goto-char (point-min))
3182 (if (not (looking-at "^[ \t]"))
3186 (goto-char (point-min))
3187 (when (looking-at "\\([^:]+\\): *")
3188 (put-text-property (match-beginning 1) (1+ (match-end 1))
3190 (put-text-property (match-end 0) (point-max)
3191 'face eface)))))))))
3193 (defun article-verify-cancel-lock ()
3194 "Verify Cancel-Lock header."
3196 (if (gnus-buffer-live-p gnus-original-article-buffer)
3197 (canlock-verify gnus-original-article-buffer)))
3204 (setq afunc (car func)
3207 gfunc (intern (format "gnus-%s" func))))
3209 (when (fboundp afunc)
3210 `(lambda (&optional interactive &rest args)
3211 ,(documentation afunc t)
3212 (interactive (list t))
3214 (set-buffer gnus-article-buffer)
3216 (call-interactively ',afunc)
3217 (apply ',afunc args))))))))
3218 '(article-hide-headers
3219 article-verify-x-pgp-sig
3220 article-verify-cancel-lock
3221 article-hide-boring-headers
3222 article-treat-overstrike
3223 article-fill-long-lines
3224 article-capitalize-sentences
3226 article-remove-leading-whitespace
3227 article-display-x-face
3228 article-de-quoted-unreadable
3229 article-de-base64-unreadable
3232 article-unsplit-urls
3233 article-hide-list-identifiers
3235 article-strip-banner
3238 article-hide-signature
3239 article-strip-headers-in-body
3240 article-remove-trailing-blank-lines
3241 article-strip-leading-blank-lines
3242 article-strip-multiple-blank-lines
3243 article-strip-leading-space
3244 article-strip-trailing-space
3245 article-strip-blank-lines
3246 article-strip-all-blank-lines
3248 article-date-english
3249 article-date-iso8601
3250 article-date-original
3252 article-decode-mime-words
3253 article-decode-charset
3254 article-decode-encoded-words
3258 article-treat-dumbquotes
3259 article-normalize-headers
3260 ;; (article-show-all . gnus-article-show-all-headers)
3264 ;;; Gnus article mode
3267 (put 'gnus-article-mode 'mode-class 'special)
3269 (set-keymap-parent gnus-article-mode-map widget-keymap)
3271 (gnus-define-keys gnus-article-mode-map
3272 " " gnus-article-goto-next-page
3273 "\177" gnus-article-goto-prev-page
3274 [delete] gnus-article-goto-prev-page
3275 [backspace] gnus-article-goto-prev-page
3276 "\C-c^" gnus-article-refer-article
3277 "h" gnus-article-show-summary
3278 "s" gnus-article-show-summary
3279 "\C-c\C-m" gnus-article-mail
3280 "?" gnus-article-describe-briefly
3281 "e" gnus-summary-edit-article
3282 "<" beginning-of-buffer
3284 "\C-c\C-i" gnus-info-find-node
3286 "R" gnus-article-reply-with-original
3287 "F" gnus-article-followup-with-original
3288 "\C-hk" gnus-article-describe-key
3289 "\C-hc" gnus-article-describe-key-briefly
3291 "\C-d" gnus-article-read-summary-keys
3292 "\M-*" gnus-article-read-summary-keys
3293 "\M-#" gnus-article-read-summary-keys
3294 "\M-^" gnus-article-read-summary-keys
3295 "\M-g" gnus-article-read-summary-keys)
3297 (substitute-key-definition
3298 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3300 (defun gnus-article-make-menu-bar ()
3301 (unless (boundp 'gnus-article-commands-menu)
3302 (gnus-summary-make-menu-bar))
3303 (gnus-turn-off-edit-menu 'article)
3304 (unless (boundp 'gnus-article-article-menu)
3306 gnus-article-article-menu gnus-article-mode-map ""
3308 ["Scroll forwards" gnus-article-goto-next-page t]
3309 ["Scroll backwards" gnus-article-goto-prev-page t]
3310 ["Show summary" gnus-article-show-summary t]
3311 ["Fetch Message-ID at point" gnus-article-refer-article t]
3312 ["Mail to address at point" gnus-article-mail t]
3313 ["Send a bug report" gnus-bug t]))
3316 gnus-article-treatment-menu gnus-article-mode-map ""
3317 ;; Fixme: this should use :active (and maybe :visible).
3319 ["Hide headers" gnus-article-hide-headers t]
3320 ["Hide signature" gnus-article-hide-signature t]
3321 ["Hide citation" gnus-article-hide-citation t]
3322 ["Treat overstrike" gnus-article-treat-overstrike t]
3323 ["Remove carriage return" gnus-article-remove-cr t]
3324 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3325 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3326 ["Remove base64" gnus-article-de-base64-unreadable t]
3327 ["Treat html" gnus-article-wash-html t]
3328 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3329 ["Decode HZ" gnus-article-decode-HZ t]))
3331 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3333 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3335 (gnus-run-hooks 'gnus-article-menu-hook)))
3337 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3340 (defun gnus-article-mode ()
3341 "Major mode for displaying an article.
3343 All normal editing commands are switched off.
3345 The following commands are available in addition to all summary mode
3347 \\<gnus-article-mode-map>
3348 \\[gnus-article-next-page]\t Scroll the article one page forwards
3349 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3350 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3351 \\[gnus-article-show-summary]\t Display the summary buffer
3352 \\[gnus-article-mail]\t Send a reply to the address near point
3353 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3354 \\[gnus-info-find-node]\t Go to the Gnus info node"
3356 (gnus-simplify-mode-line)
3357 (setq mode-name "Article")
3358 (setq major-mode 'gnus-article-mode)
3359 (make-local-variable 'minor-mode-alist)
3360 (use-local-map gnus-article-mode-map)
3361 (when (gnus-visual-p 'article-menu 'menu)
3362 (gnus-article-make-menu-bar))
3363 (gnus-update-format-specifications nil 'article-mode)
3364 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3365 (make-local-variable 'gnus-page-broken)
3366 (make-local-variable 'gnus-button-marker-list)
3367 (make-local-variable 'gnus-article-current-summary)
3368 (make-local-variable 'gnus-article-mime-handles)
3369 (make-local-variable 'gnus-article-decoded-p)
3370 (make-local-variable 'gnus-article-mime-handle-alist)
3371 (make-local-variable 'gnus-article-wash-types)
3372 (make-local-variable 'gnus-article-image-alist)
3373 (make-local-variable 'gnus-article-charset)
3374 (make-local-variable 'gnus-article-ignored-charsets)
3375 (gnus-set-default-directory)
3376 (buffer-disable-undo)
3377 (setq buffer-read-only t)
3378 (set-syntax-table gnus-article-mode-syntax-table)
3379 (mm-enable-multibyte)
3380 (gnus-run-hooks 'gnus-article-mode-hook))
3382 (defun gnus-article-setup-buffer ()
3383 "Initialize the article buffer."
3384 (let* ((name (if gnus-single-article-buffer "*Article*"
3385 (concat "*Article " gnus-newsgroup-name "*")))
3387 (progn (string-match "\\*Article" name)
3388 (concat " *Original Article"
3389 (substring name (match-end 0))))))
3390 (setq gnus-article-buffer name)
3391 (setq gnus-original-article-buffer original)
3392 (setq gnus-article-mime-handle-alist nil)
3393 ;; This might be a variable local to the summary buffer.
3394 (unless gnus-single-article-buffer
3396 (set-buffer gnus-summary-buffer)
3397 (setq gnus-article-buffer name)
3398 (setq gnus-original-article-buffer original)
3399 (gnus-set-global-variables)))
3400 (gnus-article-setup-highlight-words)
3401 ;; Init original article buffer.
3403 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3404 (mm-enable-multibyte)
3405 (setq major-mode 'gnus-original-article-mode)
3406 (make-local-variable 'gnus-original-article))
3407 (if (get-buffer name)
3410 (when gnus-article-mime-handles
3411 (mm-destroy-parts gnus-article-mime-handles)
3412 (setq gnus-article-mime-handles nil))
3413 ;; Set it to nil in article-buffer!
3414 (setq gnus-article-mime-handle-alist nil)
3415 (buffer-disable-undo)
3416 (setq buffer-read-only t)
3417 (unless (eq major-mode 'gnus-article-mode)
3418 (gnus-article-mode))
3421 (set-buffer (gnus-get-buffer-create name))
3423 (make-local-variable 'gnus-summary-buffer)
3424 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3425 (current-buffer)))))
3427 ;; Set article window start at LINE, where LINE is the number of lines
3428 ;; from the head of the article.
3429 (defun gnus-article-set-window-start (&optional line)
3431 (gnus-get-buffer-window gnus-article-buffer t)
3433 (set-buffer gnus-article-buffer)
3434 (goto-char (point-min))
3437 (gnus-message 6 "Moved to bookmark")
3438 (search-forward "\n\n" nil t)
3442 (defun gnus-article-prepare (article &optional all-headers header)
3443 "Prepare ARTICLE in article mode buffer.
3444 ARTICLE should either be an article number or a Message-ID.
3445 If ARTICLE is an id, HEADER should be the article headers.
3446 If ALL-HEADERS is non-nil, no headers are hidden."
3448 ;; Make sure we start in a summary buffer.
3449 (unless (eq major-mode 'gnus-summary-mode)
3450 (set-buffer gnus-summary-buffer))
3451 (setq gnus-summary-buffer (current-buffer))
3452 (let* ((gnus-article (if header (mail-header-number header) article))
3453 (summary-buffer (current-buffer))
3454 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3455 (group gnus-newsgroup-name)
3458 (gnus-article-setup-buffer)
3459 (set-buffer gnus-article-buffer)
3460 ;; Deactivate active regions.
3461 (when (and (boundp 'transient-mark-mode)
3462 transient-mark-mode)
3463 (setq mark-active nil))
3464 (if (not (setq result (let ((buffer-read-only nil))
3465 (gnus-request-article-this-buffer
3467 ;; There is no such article.
3469 (when (and (numberp article)
3470 (not (memq article gnus-newsgroup-sparse)))
3471 (setq gnus-article-current
3472 (cons gnus-newsgroup-name article))
3473 (set-buffer gnus-summary-buffer)
3474 (setq gnus-current-article article)
3475 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3477 (gnus-summary-set-agent-mark article)
3478 (message "Message marked for downloading"))
3479 (gnus-summary-mark-article article gnus-canceled-mark)
3480 (unless (memq article gnus-newsgroup-sparse)
3481 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3482 (if (or (eq result 'pseudo)
3483 (eq result 'nneething))
3486 (set-buffer summary-buffer)
3487 (push article gnus-newsgroup-history)
3488 (setq gnus-last-article gnus-current-article
3489 gnus-current-article 0
3490 gnus-current-headers nil
3491 gnus-article-current nil)
3492 (if (eq result 'nneething)
3493 (gnus-configure-windows 'summary)
3494 (gnus-configure-windows 'article))
3495 (gnus-set-global-variables))
3496 (let ((gnus-article-mime-handle-alist-1
3497 gnus-article-mime-handle-alist))
3498 (gnus-set-mode-line 'article)))
3499 ;; The result from the `request' was an actual article -
3500 ;; or at least some text that is now displayed in the
3502 (when (and (numberp article)
3503 (not (eq article gnus-current-article)))
3504 ;; Seems like a new article has been selected.
3505 ;; `gnus-current-article' must be an article number.
3507 (set-buffer summary-buffer)
3508 (push article gnus-newsgroup-history)
3509 (setq gnus-last-article gnus-current-article
3510 gnus-current-article article
3511 gnus-current-headers
3512 (gnus-summary-article-header gnus-current-article)
3513 gnus-article-current
3514 (cons gnus-newsgroup-name gnus-current-article))
3515 (unless (vectorp gnus-current-headers)
3516 (setq gnus-current-headers nil))
3517 (gnus-summary-goto-subject gnus-current-article)
3518 (when (gnus-summary-show-thread)
3519 ;; If the summary buffer really was folded, the
3520 ;; previous goto may not actually have gone to
3521 ;; the right article, but the thread root instead.
3523 (gnus-summary-goto-subject gnus-current-article))
3524 (gnus-run-hooks 'gnus-mark-article-hook)
3525 (gnus-set-mode-line 'summary)
3526 (when (gnus-visual-p 'article-highlight 'highlight)
3527 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3528 ;; Set the global newsgroup variables here.
3529 (gnus-set-global-variables)
3530 (setq gnus-have-all-headers
3531 (or all-headers gnus-show-all-headers))))
3533 (gnus-configure-windows 'article))
3534 (when (or (numberp article)
3536 (gnus-article-prepare-display)
3538 (goto-char (point-min))
3539 (setq gnus-page-broken
3540 (when gnus-break-pages
3541 (gnus-narrow-to-page)
3543 (let ((gnus-article-mime-handle-alist-1
3544 gnus-article-mime-handle-alist))
3545 (gnus-set-mode-line 'article))
3549 (set-window-point (get-buffer-window (current-buffer)) (point))
3550 (gnus-configure-windows 'article)
3554 (defun gnus-article-prepare-display ()
3555 "Make the current buffer look like a nice article."
3556 ;; Hooks for getting information from the article.
3557 ;; This hook must be called before being narrowed.
3558 (let ((gnus-article-buffer (current-buffer))
3560 (unless (eq major-mode 'gnus-article-mode)
3561 (gnus-article-mode))
3562 (setq buffer-read-only nil
3563 gnus-article-wash-types nil
3564 gnus-article-image-alist nil)
3565 (gnus-run-hooks 'gnus-tmp-internal-hook)
3566 (when gnus-display-mime-function
3567 (funcall gnus-display-mime-function))
3568 (gnus-run-hooks 'gnus-article-prepare-hook)))
3571 ;;; Gnus MIME viewing functions
3574 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3575 "Format of the MIME buttons.
3577 Valid specifiers include:
3579 %T MIME type, along with additional info
3580 %n The `name' parameter
3581 %d The description, if any
3582 %l The length of the encoded part
3583 %p The part identifier number
3584 %e Dots if the part isn't displayed
3586 General format specifiers can also be used. See
3587 (gnus)Formatting Variables.")
3589 (defvar gnus-mime-button-line-format-alist
3590 '((?t gnus-tmp-type ?s)
3591 (?T gnus-tmp-type-long ?s)
3592 (?n gnus-tmp-name ?s)
3593 (?d gnus-tmp-description ?s)
3595 (?l gnus-tmp-length ?d)
3596 (?e gnus-tmp-dots ?s)))
3598 (defvar gnus-mime-button-commands
3599 '((gnus-article-press-button "\r" "Toggle Display")
3600 (gnus-mime-view-part "v" "View Interactively...")
3601 (gnus-mime-view-part-as-type "t" "View As Type...")
3602 (gnus-mime-view-part-as-charset "C" "View As charset...")
3603 (gnus-mime-save-part "o" "Save...")
3604 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3605 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3606 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3607 (gnus-mime-view-part-internally "E" "View Internally")
3608 (gnus-mime-view-part-externally "e" "View Externally")
3609 (gnus-mime-print-part "p" "Print")
3610 (gnus-mime-pipe-part "|" "Pipe To Command...")
3611 (gnus-mime-action-on-part "." "Take action on the part")))
3613 (defun gnus-article-mime-part-status ()
3614 (if gnus-article-mime-handle-alist-1
3615 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3617 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3620 (defvar gnus-mime-button-map
3621 (let ((map (make-sparse-keymap)))
3622 (unless (>= (string-to-number emacs-version) 21)
3623 ;; XEmacs doesn't care.
3624 (set-keymap-parent map gnus-article-mode-map))
3625 (define-key map gnus-mouse-2 'gnus-article-push-button)
3626 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3627 (dolist (c gnus-mime-button-commands)
3628 (define-key map (cadr c) (car c)))
3631 (defun gnus-mime-button-menu (event)
3632 "Construct a context-sensitive menu of MIME commands."
3634 (save-window-excursion
3635 (let ((pos (event-start event)))
3636 (select-window (posn-window pos))
3637 (goto-char (posn-point pos))
3638 (gnus-article-check-buffer)
3639 (let ((response (x-popup-menu
3641 ("" ,@(mapcar (lambda (c)
3642 (cons (caddr c) (car c)))
3643 gnus-mime-button-commands))))))
3645 (call-interactively response))))))
3647 (defun gnus-mime-view-all-parts (&optional handles)
3648 "View all the MIME parts."
3650 (save-current-buffer
3651 (set-buffer gnus-article-buffer)
3652 (let ((handles (or handles gnus-article-mime-handles))
3653 (mail-parse-charset gnus-newsgroup-charset)
3654 (mail-parse-ignored-charsets
3655 (with-current-buffer gnus-summary-buffer
3656 gnus-newsgroup-ignored-charsets)))
3658 (mm-remove-parts handles)
3659 (goto-char (point-min))
3660 (or (search-forward "\n\n") (goto-char (point-max)))
3661 (let (buffer-read-only)
3662 (delete-region (point) (point-max))
3663 (mm-display-parts handles))))))
3665 (defun gnus-mime-save-part-and-strip ()
3666 "Save the MIME part under point then replace it with an external body."
3668 (gnus-article-check-buffer)
3669 (let* ((data (get-text-property (point) 'gnus-data))
3671 (handles gnus-article-mime-handles))
3672 (if (mm-multiple-handles gnus-article-mime-handles)
3673 (error "This function is not implemented"))
3674 (setq file (and data (mm-save-part data)))
3676 (with-current-buffer (mm-handle-buffer data)
3678 (insert "Content-Type: " (mm-handle-media-type data))
3679 (mml-insert-parameter-string (cdr (mm-handle-type data))
3682 (insert "Content-ID: " (message-make-message-id) "\n")
3683 (insert "Content-Transfer-Encoding: binary\n")
3686 (cdr (mm-make-handle nil
3687 `("message/external-body"
3688 (access-type . "LOCAL-FILE")
3690 (set-buffer gnus-summary-buffer)
3691 (gnus-article-edit-article
3694 (let ((mail-parse-charset (or gnus-article-charset
3695 ',gnus-newsgroup-charset))
3696 (mail-parse-ignored-charsets
3697 (or gnus-article-ignored-charsets
3698 ',gnus-newsgroup-ignored-charsets))
3699 (mbl mml-buffer-list))
3700 (setq mml-buffer-list nil)
3701 (insert-buffer gnus-original-article-buffer)
3702 (mime-to-mml ',handles)
3703 (setq gnus-article-mime-handles nil)
3704 (let ((mbl1 mml-buffer-list))
3705 (setq mml-buffer-list mbl)
3706 (set (make-local-variable 'mml-buffer-list) mbl1))
3707 ;; LOCAL argument of add-hook differs between GNU Emacs
3708 ;; and XEmacs. make-local-hook makes sure they are local.
3709 (make-local-hook 'kill-buffer-hook)
3710 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3711 `(lambda (no-highlight)
3712 (let ((mail-parse-charset (or gnus-article-charset
3713 ',gnus-newsgroup-charset))
3714 (message-options message-options)
3715 (message-options-set-recipient)
3716 (mail-parse-ignored-charsets
3717 (or gnus-article-ignored-charsets
3718 ',gnus-newsgroup-ignored-charsets)))
3720 (mml-destroy-buffers)
3721 (remove-hook 'kill-buffer-hook
3722 'mml-destroy-buffers t)
3723 (kill-local-variable 'mml-buffer-list))
3724 (gnus-summary-edit-article-done
3725 ,(or (mail-header-references gnus-current-headers) "")
3726 ,(gnus-group-read-only-p)
3727 ,gnus-summary-buffer no-highlight))))))
3729 (defun gnus-mime-save-part ()
3730 "Save the MIME part under point."
3732 (gnus-article-check-buffer)
3733 (let ((data (get-text-property (point) 'gnus-data)))
3735 (mm-save-part data))))
3737 (defun gnus-mime-pipe-part ()
3738 "Pipe the MIME part under point to a process."
3740 (gnus-article-check-buffer)
3741 (let ((data (get-text-property (point) 'gnus-data)))
3743 (mm-pipe-part data))))
3745 (defun gnus-mime-view-part ()
3746 "Interactively choose a viewing method for the MIME part under point."
3748 (gnus-article-check-buffer)
3749 (let ((data (get-text-property (point) 'gnus-data)))
3751 (setq gnus-article-mime-handles
3753 gnus-article-mime-handles (setq data (copy-sequence data))))
3754 (mm-interactively-view-part data))))
3756 (defun gnus-mime-view-part-as-type-internal ()
3757 (gnus-article-check-buffer)
3758 (let* ((name (mail-content-type-get
3759 (mm-handle-type (get-text-property (point) 'gnus-data))
3761 (def-type (and name (mm-default-file-encoding name))))
3762 (and def-type (cons def-type 0))))
3764 (defun gnus-mime-view-part-as-type (&optional mime-type)
3765 "Choose a MIME media type, and view the part as such."
3768 (setq mime-type (completing-read
3769 "View as MIME type: "
3770 (mapcar #'list (mailcap-mime-types))
3772 (gnus-mime-view-part-as-type-internal))))
3773 (gnus-article-check-buffer)
3774 (let ((handle (get-text-property (point) 'gnus-data)))
3777 (mm-make-handle (mm-handle-buffer handle)
3778 (cons mime-type (cdr (mm-handle-type handle)))
3779 (mm-handle-encoding handle)
3780 (mm-handle-undisplayer handle)
3781 (mm-handle-disposition handle)
3782 (mm-handle-description handle)
3784 (mm-handle-id handle)))
3785 (setq gnus-article-mime-handles
3786 (mm-merge-handles gnus-article-mime-handles handle))
3787 (gnus-mm-display-part handle))))
3789 (defun gnus-mime-copy-part (&optional handle)
3790 "Put the MIME part under point into a new buffer."
3792 (gnus-article-check-buffer)
3793 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3794 (contents (and handle (mm-get-part handle)))
3796 (file-name-nondirectory
3798 (mail-content-type-get (mm-handle-type handle) 'name)
3799 (mail-content-type-get (mm-handle-type handle)
3802 (buffer (and base (generate-new-buffer base))))
3804 (switch-to-buffer buffer)
3806 ;; We do it this way to make `normal-mode' set the appropriate mode.
3809 (setq buffer-file-name (expand-file-name base))
3811 (setq buffer-file-name nil))
3812 (goto-char (point-min)))))
3814 (defun gnus-mime-print-part (&optional handle filename)
3815 "Print the MIME part under point."
3816 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3817 (gnus-article-check-buffer)
3818 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3819 (contents (and handle (mm-get-part handle)))
3820 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3821 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3826 (with-temp-file file
3828 (call-process shell-file-name nil
3829 (generate-new-buffer " *mm*")
3831 shell-command-switch
3833 printer file (mm-handle-type handle))))
3837 (gnus-print-buffer))
3838 (ps-despool filename)))))
3840 (defun gnus-mime-inline-part (&optional handle arg)
3841 "Insert the MIME part under point into the current buffer."
3842 (interactive (list nil current-prefix-arg))
3843 (gnus-article-check-buffer)
3844 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3849 (if (and (not arg) (mm-handle-undisplayer handle))
3850 (mm-remove-part handle)
3851 (setq contents (mm-get-part handle))
3854 (setq charset (or (mail-content-type-get
3855 (mm-handle-type handle) 'charset)
3856 gnus-newsgroup-charset)))
3858 (if (mm-handle-undisplayer handle)
3859 (mm-remove-part handle))
3862 gnus-summary-show-article-charset-alist))
3863 (mm-read-coding-system "Charset: ")))))
3865 (mm-insert-inline handle
3867 (setq charset (mm-charset-to-coding-system
3869 (not (eq charset 'ascii)))
3870 (mm-decode-coding-string contents charset)
3874 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3875 "Insert the MIME part under point into the current buffer using the
3877 (interactive (list nil current-prefix-arg))
3878 (gnus-article-check-buffer)
3879 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3884 (if (mm-handle-undisplayer handle)
3885 (mm-remove-part handle))
3886 (let ((gnus-newsgroup-charset
3888 gnus-summary-show-article-charset-alist))
3889 (mm-read-coding-system "Charset: ")))
3890 (gnus-newsgroup-ignored-charsets 'gnus-all))
3891 (gnus-article-press-button)))))
3893 (defun gnus-mime-view-part-externally (&optional handle)
3894 "View the MIME part under point with an external viewer."
3896 (gnus-article-check-buffer)
3897 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3898 (mm-user-display-methods nil)
3899 (mm-inlined-types nil)
3900 (mail-parse-charset gnus-newsgroup-charset)
3901 (mail-parse-ignored-charsets
3902 (save-excursion (set-buffer gnus-summary-buffer)
3903 gnus-newsgroup-ignored-charsets)))
3905 (if (mm-handle-undisplayer handle)
3906 (mm-remove-part handle)
3907 (mm-display-part handle)))))
3909 (defun gnus-mime-view-part-internally (&optional handle)
3910 "View the MIME part under point with an internal viewer.
3911 If no internal viewer is available, use an external viewer."
3913 (gnus-article-check-buffer)
3914 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3915 (mm-inlined-types '(".*"))
3916 (mm-inline-large-images t)
3917 (mail-parse-charset gnus-newsgroup-charset)
3918 (mail-parse-ignored-charsets
3919 (save-excursion (set-buffer gnus-summary-buffer)
3920 gnus-newsgroup-ignored-charsets)))
3922 (if (mm-handle-undisplayer handle)
3923 (mm-remove-part handle)
3924 (mm-display-part handle)))))
3926 (defun gnus-mime-action-on-part (&optional action)
3927 "Do something with the MIME attachment at \(point\)."
3929 (list (completing-read "Action: " gnus-mime-action-alist)))
3930 (gnus-article-check-buffer)
3931 (let ((action-pair (assoc action gnus-mime-action-alist)))
3933 (funcall (cdr action-pair)))))
3935 (defun gnus-article-part-wrapper (n function)
3936 (save-current-buffer
3937 (set-buffer gnus-article-buffer)
3938 (when (> n (length gnus-article-mime-handle-alist))
3939 (error "No such part"))
3940 (gnus-article-goto-part n)
3941 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3942 (funcall function handle))))
3944 (defun gnus-article-pipe-part (n)
3945 "Pipe MIME part N, which is the numerical prefix."
3947 (gnus-article-part-wrapper n 'mm-pipe-part))
3949 (defun gnus-article-save-part (n)
3950 "Save MIME part N, which is the numerical prefix."
3952 (gnus-article-part-wrapper n 'mm-save-part))
3954 (defun gnus-article-interactively-view-part (n)
3955 "View MIME part N interactively, which is the numerical prefix."
3957 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3959 (defun gnus-article-copy-part (n)
3960 "Copy MIME part N, which is the numerical prefix."
3962 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3964 (defun gnus-article-view-part-as-charset (n)
3965 "Copy MIME part N, which is the numerical prefix."
3967 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3969 (defun gnus-article-view-part-externally (n)
3970 "View MIME part N externally, which is the numerical prefix."
3972 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
3974 (defun gnus-article-inline-part (n)
3975 "Inline MIME part N, which is the numerical prefix."
3977 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3979 (defun gnus-article-mime-match-handle-first (condition)
3981 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3982 (while (setq ihandle (pop alist))
3984 ((functionp condition)
3985 (funcall condition (cdr ihandle)))
3986 ((eq condition 'undisplayed)
3987 (not (or (mm-handle-undisplayer (cdr ihandle))
3988 (equal (mm-handle-media-type (cdr ihandle))
3989 "multipart/alternative"))))
3990 ((eq condition 'undisplayed-alternative)
3991 (not (mm-handle-undisplayer (cdr ihandle))))
3993 (gnus-article-goto-part (car ihandle))
3994 (or (not n) (< (car ihandle) n)))
3995 (setq n (car ihandle))))
3999 (defun gnus-article-view-part (&optional n)
4000 "View MIME part N, which is the numerical prefix."
4002 (save-current-buffer
4003 (set-buffer gnus-article-buffer)
4004 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4005 gnus-article-mime-match-handle-function)))
4006 (when (> n (length gnus-article-mime-handle-alist))
4007 (error "No such part"))
4008 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4009 (when (gnus-article-goto-part n)
4010 (if (equal (car handle) "multipart/alternative")
4011 (gnus-article-press-button)
4012 (when (eq (gnus-mm-display-part handle) 'internal)
4013 (gnus-set-window-start)))))))
4015 (defsubst gnus-article-mime-total-parts ()
4016 (if (bufferp (car gnus-article-mime-handles))
4018 (1- (length gnus-article-mime-handles))))
4020 (defun gnus-mm-display-part (handle)
4021 "Display HANDLE and fix MIME button."
4022 (let ((id (get-text-property (point) 'gnus-part))
4027 (let ((window (selected-window))
4028 (mail-parse-charset gnus-newsgroup-charset)
4029 (mail-parse-ignored-charsets
4030 (if (gnus-buffer-live-p gnus-summary-buffer)
4032 (set-buffer gnus-summary-buffer)
4033 gnus-newsgroup-ignored-charsets)
4037 (let ((win (gnus-get-buffer-window (current-buffer) t))
4040 (select-window win))
4043 (if (mm-handle-displayed-p handle)
4044 ;; This will remove the part.
4045 (mm-display-part handle)
4047 (narrow-to-region (point)
4048 (if (eobp) (point) (1+ (point))))
4049 (mm-display-part handle)
4050 ;; We narrow to the part itself and
4051 ;; then call the treatment functions.
4052 (goto-char (point-min))
4054 (narrow-to-region (point) (point-max))
4057 (gnus-article-mime-total-parts)
4058 (mm-handle-media-type handle)))))
4059 (if (window-live-p window)
4060 (select-window window)))))
4062 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4063 (gnus-insert-mime-button
4064 handle id (list (mm-handle-displayed-p handle)))
4065 (goto-char point))))
4067 (defun gnus-article-goto-part (n)
4068 "Go to MIME part N."
4069 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4071 (goto-char point))))
4073 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4074 (let ((gnus-tmp-name
4075 (or (mail-content-type-get (mm-handle-type handle) 'name)
4076 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4077 (mail-content-type-get (mm-handle-type handle) 'url)
4079 (gnus-tmp-type (mm-handle-media-type handle))
4080 (gnus-tmp-description
4081 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4084 (if (if displayed (car displayed)
4085 (mm-handle-displayed-p handle))
4087 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4089 gnus-tmp-type-long b e)
4090 (when (string-match ".*/" gnus-tmp-name)
4091 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4092 (setq gnus-tmp-type-long (concat gnus-tmp-type
4093 (and (not (equal gnus-tmp-name ""))
4094 (concat "; " gnus-tmp-name))))
4095 (unless (equal gnus-tmp-description "")
4096 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4101 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4102 `(,@(gnus-local-map-property gnus-mime-button-map)
4103 gnus-callback gnus-mm-display-part
4104 gnus-part ,gnus-tmp-id
4105 article-type annotation
4108 (widget-convert-button
4111 :action 'gnus-widget-press-button
4112 :button-keymap gnus-mime-button-map
4114 (lambda (widget/window &optional overlay pos)
4115 ;; Needed to properly clear the message due to a bug in
4116 ;; wid-edit (XEmacs only).
4117 (if (boundp 'help-echo-owns-message)
4118 (setq help-echo-owns-message t))
4120 "%S: %s the MIME part; %S: more options"
4121 (aref gnus-mouse-2 0)
4122 ;; XEmacs will get a single widget arg; Emacs 21 will get
4123 ;; window, overlay, position.
4124 (if (mm-handle-displayed-p
4126 (with-current-buffer (gnus-overlay-buffer overlay)
4127 (widget-get (widget-at (gnus-overlay-start overlay))
4129 (widget-get widget/window :mime-handle)))
4131 (aref gnus-down-mouse-3 0))))))
4133 (defun gnus-widget-press-button (elems el)
4134 (goto-char (widget-get elems :from))
4135 (gnus-article-press-button))
4137 (defvar gnus-displaying-mime nil)
4139 (defun gnus-display-mime (&optional ihandles)
4140 "Display the MIME parts."
4142 (save-selected-window
4143 (let ((window (get-buffer-window gnus-article-buffer))
4146 (select-window window)
4147 ;; We have to do this since selecting the window
4148 ;; may change the point. So we set the window point.
4149 (set-window-point window point)))
4150 (let* ((handles (or ihandles (mm-dissect-buffer
4151 nil gnus-article-loose-mime)
4153 buffer-read-only handle name type b e display)
4154 (when (and (not ihandles)
4155 (not gnus-displaying-mime))
4156 ;; Top-level call; we clean up.
4157 (when gnus-article-mime-handles
4158 (mm-destroy-parts gnus-article-mime-handles)
4159 (setq gnus-article-mime-handle-alist nil));; A trick.
4160 (setq gnus-article-mime-handles handles)
4161 ;; We allow users to glean info from the handles.
4162 (when gnus-article-mime-part-function
4163 (gnus-mime-part-function handles)))
4165 (or (not (stringp (car handles)))
4168 (when (and (not ihandles)
4169 (not gnus-displaying-mime))
4170 ;; Clean up for mime parts.
4172 (delete-region (point) (point-max)))
4173 (let ((gnus-displaying-mime t))
4174 (gnus-mime-display-part handles)))
4177 (narrow-to-region (point) (point-max))
4178 (gnus-treat-article nil 1 1)
4181 ;; Highlight the headers.
4185 (narrow-to-region (point-min) (point))
4186 (gnus-treat-article 'head))))))))
4188 (defvar gnus-mime-display-multipart-as-mixed nil)
4189 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4190 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4192 (defun gnus-mime-display-part (handle)
4195 ((not (stringp (car handle)))
4196 (gnus-mime-display-single handle))
4197 ;; User-defined multipart
4198 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4199 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4201 ;; multipart/alternative
4202 ((and (equal (car handle) "multipart/alternative")
4203 (not (or gnus-mime-display-multipart-as-mixed
4204 gnus-mime-display-multipart-alternative-as-mixed)))
4205 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4206 (push (cons id handle) gnus-article-mime-handle-alist)
4207 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4208 ;; multipart/related
4209 ((and (equal (car handle) "multipart/related")
4210 (not (or gnus-mime-display-multipart-as-mixed
4211 gnus-mime-display-multipart-related-as-mixed)))
4212 ;;;!!!We should find the start part, but we just default
4213 ;;;!!!to the first part.
4214 ;;(gnus-mime-display-part (cadr handle))
4215 ;;;!!! Most multipart/related is an HTML message plus images.
4216 ;;;!!! Unfortunately we are unable to let W3 display those
4217 ;;;!!! included images, so we just display it as a mixed multipart.
4218 ;;(gnus-mime-display-mixed (cdr handle))
4219 ;;;!!! No, w3 can display everything just fine.
4220 (gnus-mime-display-part (cadr handle)))
4221 ((equal (car handle) "multipart/signed")
4222 (gnus-add-wash-type 'signed)
4223 (gnus-mime-display-security handle))
4224 ((equal (car handle) "multipart/encrypted")
4225 (gnus-add-wash-type 'encrypted)
4226 (gnus-mime-display-security handle))
4227 ;; Other multiparts are handled like multipart/mixed.
4229 (gnus-mime-display-mixed (cdr handle)))))
4231 (defun gnus-mime-part-function (handles)
4232 (if (stringp (car handles))
4233 (mapcar 'gnus-mime-part-function (cdr handles))
4234 (funcall gnus-article-mime-part-function handles)))
4236 (defun gnus-mime-display-mixed (handles)
4237 (mapcar 'gnus-mime-display-part handles))
4239 (defun gnus-mime-display-single (handle)
4240 (let ((type (mm-handle-media-type handle))
4241 (ignored gnus-ignored-mime-types)
4248 (when (string-match (pop ignored) type)
4249 (throw 'ignored nil)))
4250 (if (and (setq not-attachment
4251 (and (not (mm-inline-override-p handle))
4252 (or (not (mm-handle-disposition handle))
4253 (equal (car (mm-handle-disposition handle))
4255 (mm-attachment-override-p handle))))
4256 (mm-automatic-display-p handle)
4258 (mm-inlinable-p handle)
4259 (mm-inlined-p handle))
4260 (mm-automatic-external-display-p type)))
4262 (when (equal (mm-handle-media-supertype handle) "text")
4264 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4266 (push (cons id handle) gnus-article-mime-handle-alist)
4267 (when (or (not display)
4268 (not (gnus-unbuttonized-mime-type-p type)))
4269 ;(gnus-article-insert-newline)
4270 (gnus-insert-mime-button
4271 handle id (list (or display (and not-attachment text))))
4272 (gnus-article-insert-newline)
4273 ;(gnus-article-insert-newline)
4274 ;; Remember modify the number of forward lines.
4282 (let ((mail-parse-charset gnus-newsgroup-charset)
4283 (mail-parse-ignored-charsets
4284 (save-excursion (condition-case ()
4285 (set-buffer gnus-summary-buffer)
4287 gnus-newsgroup-ignored-charsets)))
4288 (mm-display-part handle t))
4289 (goto-char (point-max)))
4290 ((and text not-attachment)
4294 (gnus-article-insert-newline)
4295 (mm-insert-inline handle (mm-get-part handle))
4296 (goto-char (point-max))))
4300 (narrow-to-region beg (point))
4303 (gnus-article-mime-total-parts)
4304 (mm-handle-media-type handle)))))))))
4306 (defun gnus-unbuttonized-mime-type-p (type)
4307 "Say whether TYPE is to be unbuttonized."
4308 (unless gnus-inhibit-mime-unbuttonizing
4310 (let ((types gnus-unbuttonized-mime-types))
4312 (when (string-match (pop types) type)
4313 (throw 'found t)))))
4315 (let ((types gnus-buttonized-mime-types))
4317 (when (string-match (pop types) type)
4318 (throw 'found t)))))))))
4320 (defun gnus-article-insert-newline ()
4321 "Insert a newline, but mark it as undeletable."
4322 (gnus-put-text-property
4323 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4325 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4326 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4329 handle buffer-read-only from props begend not-pref)
4330 (save-window-excursion
4333 (narrow-to-region (car ibegend)
4336 (goto-char (car ibegend))
4339 (delete-region (point-min) (point-max))
4340 (mm-remove-parts handles))
4341 (setq begend (list (point-marker)))
4343 (unless (setq not-pref (cadr (member preferred ihandles)))
4344 (setq not-pref (car ihandles)))
4347 (not (gnus-unbuttonized-mime-type-p
4348 "multipart/alternative")))
4349 (gnus-add-text-properties
4352 (insert (format "%d. " id))
4356 (unless ,(not ibegend)
4357 (setq gnus-article-mime-handle-alist
4358 ',gnus-article-mime-handle-alist))
4359 (gnus-mime-display-alternative
4360 ',ihandles ',not-pref ',begend ,id))
4361 ,@(gnus-local-map-property gnus-mime-button-map)
4362 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4363 face ,gnus-article-button-face
4366 (widget-convert-button 'link from (point)
4367 :action 'gnus-widget-press-button
4368 :button-keymap gnus-widget-button-keymap)
4370 (while (setq handle (pop handles))
4371 (gnus-add-text-properties
4374 (insert (format "(%c) %-18s"
4375 (if (equal handle preferred) ?* ? )
4376 (mm-handle-media-type handle)))
4380 (unless ,(not ibegend)
4381 (setq gnus-article-mime-handle-alist
4382 ',gnus-article-mime-handle-alist))
4383 (gnus-mime-display-alternative
4384 ',ihandles ',handle ',begend ,id))
4385 ,@(gnus-local-map-property gnus-mime-button-map)
4386 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4387 face ,gnus-article-button-face
4390 (widget-convert-button 'link from (point)
4391 :action 'gnus-widget-press-button
4392 :button-keymap gnus-widget-button-keymap)
4396 (if (stringp (car preferred))
4397 (gnus-display-mime preferred)
4398 (let ((mail-parse-charset gnus-newsgroup-charset)
4399 (mail-parse-ignored-charsets
4400 (save-excursion (set-buffer gnus-summary-buffer)
4401 gnus-newsgroup-ignored-charsets)))
4402 (mm-display-part preferred)
4406 (narrow-to-region (car begend) (point-max))
4408 nil (length gnus-article-mime-handle-alist)
4409 (gnus-article-mime-total-parts)
4410 (mm-handle-media-type handle))))))
4411 (goto-char (point-max))
4412 (setcdr begend (point-marker)))))
4414 (goto-char point))))
4416 (defconst gnus-article-wash-status-strings
4417 (let ((alist '((cite "c" "Possible hidden citation text"
4418 " " "All citation text visible")
4419 (headers "h" "Hidden headers"
4420 " " "All headers visible.")
4421 (pgp "p" "Encrypted or signed message status hidden"
4422 " " "No hidden encryption nor digital signature status")
4423 (signature "s" "Signature has been hidden"
4424 " " "Signature is visible")
4425 (overstrike "o" "Overstrike (^H) characters applied"
4426 " " "No overstrike characters applied")
4427 (emphasis "e" "/*_Emphasis_*/ characters applied"
4428 " " "No /*_emphasis_*/ characters applied")))
4430 (dolist (entry alist result)
4431 (let ((key (nth 0 entry))
4432 (on (copy-sequence (nth 1 entry)))
4433 (on-help (nth 2 entry))
4434 (off (copy-sequence (nth 3 entry)))
4435 (off-help (nth 4 entry)))
4436 (put-text-property 0 1 'help-echo on-help on)
4437 (put-text-property 0 1 'help-echo off-help off)
4438 (push (list key on off) result))))
4439 "Alist of strings describing wash status in the mode line.
4440 Each entry has the form (KEY ON OF), where the KEY is a symbol
4441 representing the particular washing function, ON is the string to use
4442 in the article mode line when the washing function is active, and OFF
4443 is the string to use when it is inactive.")
4445 (defun gnus-article-wash-status-entry (key value)
4446 (let ((entry (assoc key gnus-article-wash-status-strings)))
4447 (if value (nth 1 entry) (nth 2 entry))))
4449 (defun gnus-article-wash-status ()
4450 "Return a string which display status of article washing."
4452 (set-buffer gnus-article-buffer)
4453 (let ((cite (memq 'cite gnus-article-wash-types))
4454 (headers (memq 'headers gnus-article-wash-types))
4455 (boring (memq 'boring-headers gnus-article-wash-types))
4456 (pgp (memq 'pgp gnus-article-wash-types))
4457 (pem (memq 'pem gnus-article-wash-types))
4458 (signed (memq 'signed gnus-article-wash-types))
4459 (encrypted (memq 'encrypted gnus-article-wash-types))
4460 (signature (memq 'signature gnus-article-wash-types))
4461 (overstrike (memq 'overstrike gnus-article-wash-types))
4462 (emphasis (memq 'emphasis gnus-article-wash-types)))
4464 (gnus-article-wash-status-entry 'cite cite)
4465 (gnus-article-wash-status-entry 'headers (or headers boring))
4466 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4467 (gnus-article-wash-status-entry 'signature signature)
4468 (gnus-article-wash-status-entry 'overstrike overstrike)
4469 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4471 (defun gnus-add-wash-type (type)
4472 "Add a washing of TYPE to the current status."
4473 (add-to-list 'gnus-article-wash-types type))
4475 (defun gnus-delete-wash-type (type)
4476 "Add a washing of TYPE to the current status."
4477 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4479 (defun gnus-add-image (category image)
4480 "Add IMAGE of CATEGORY to the list of displayed images."
4481 (let ((entry (assq category gnus-article-image-alist)))
4483 (setq entry (list category))
4484 (push entry gnus-article-image-alist))
4485 (nconc entry (list image))))
4487 (defun gnus-delete-images (category)
4488 "Delete all images in CATEGORY."
4489 (let ((entry (assq category gnus-article-image-alist)))
4490 (dolist (image (cdr entry))
4491 (gnus-remove-image image))
4492 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4493 (gnus-delete-wash-type category)))
4495 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4497 (defun gnus-article-maybe-hide-headers ()
4498 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4499 Provided for backwards compatibility."
4500 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4501 (not (save-excursion (set-buffer gnus-summary-buffer)
4502 gnus-have-all-headers)))
4503 (not gnus-inhibit-hiding))
4504 (gnus-article-hide-headers)))
4508 (defun gnus-output-to-file (file-name)
4509 "Append the current article to a file named FILE-NAME."
4510 (let ((artbuf (current-buffer)))
4512 (insert-buffer-substring artbuf)
4513 ;; Append newline at end of the buffer as separator, and then
4515 (goto-char (point-max))
4517 (let ((file-name-coding-system nnmail-pathname-coding-system))
4518 (mm-append-to-file (point-min) (point-max) file-name))
4521 (defun gnus-narrow-to-page (&optional arg)
4522 "Narrow the article buffer to a page.
4523 If given a numerical ARG, move forward ARG pages."
4525 (setq arg (if arg (prefix-numeric-value arg) 0))
4527 (set-buffer gnus-article-buffer)
4528 (goto-char (point-min))
4530 ;; Remove any old next/prev buttons.
4531 (when (gnus-visual-p 'page-marker)
4532 (let ((buffer-read-only nil))
4533 (gnus-remove-text-with-property 'gnus-prev)
4534 (gnus-remove-text-with-property 'gnus-next)))
4537 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4539 (re-search-forward page-delimiter nil 'move arg)))
4540 (goto-char (match-end 0)))
4543 (if (re-search-forward page-delimiter nil 'move)
4546 (when (and (gnus-visual-p 'page-marker)
4547 (not (= (point-min) 1)))
4549 (goto-char (point-min))
4550 (gnus-insert-prev-page-button)))
4551 (when (and (gnus-visual-p 'page-marker)
4552 (< (+ (point-max) 2) (buffer-size)))
4554 (goto-char (point-max))
4555 (gnus-insert-next-page-button)))))
4557 ;; Article mode commands
4559 (defun gnus-article-goto-next-page ()
4560 "Show the next page of the article."
4562 (when (gnus-article-next-page)
4563 (goto-char (point-min))
4564 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4566 (defun gnus-article-goto-prev-page ()
4567 "Show the next page of the article."
4569 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4570 (gnus-article-prev-page nil)))
4572 (defun gnus-article-next-page (&optional lines)
4573 "Show the next page of the current article.
4574 If end of article, return non-nil. Otherwise return nil.
4575 Argument LINES specifies lines to be scrolled up."
4577 (move-to-window-line -1)
4580 (and (pos-visible-in-window-p) ;Not continuation line.
4582 ;; Nothing in this page.
4583 (if (or (not gnus-page-broken)
4586 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4588 (gnus-narrow-to-page 1) ;Go to next page.
4590 ;; More in this page.
4591 (let ((scroll-in-place nil))
4595 ;; Long lines may cause an end-of-buffer error.
4596 (goto-char (point-max)))))
4597 (move-to-window-line 0)
4600 (defun gnus-article-prev-page (&optional lines)
4601 "Show previous page of current article.
4602 Argument LINES specifies lines to be scrolled down."
4604 (move-to-window-line 0)
4605 (if (and gnus-page-broken
4607 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4609 (gnus-narrow-to-page -1) ;Go to previous page.
4610 (goto-char (point-max))
4612 (let ((scroll-in-place nil))
4616 (beginning-of-buffer
4617 (goto-char (point-min))))
4618 (move-to-window-line 0)))))
4620 (defun gnus-article-refer-article ()
4621 "Read article specified by message-id around point."
4623 (let ((point (point)))
4624 (search-forward ">" nil t) ;Move point to end of "<....>".
4625 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4626 (let ((message-id (match-string 1)))
4628 (set-buffer gnus-summary-buffer)
4629 (gnus-summary-refer-article message-id))
4631 (error "No references around point"))))
4633 (defun gnus-article-show-summary ()
4634 "Reconfigure windows to show summary buffer."
4636 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4637 (error "There is no summary buffer for this article buffer")
4638 (gnus-article-set-globals)
4639 (gnus-configure-windows 'article)
4640 (gnus-summary-goto-subject gnus-current-article)
4641 (gnus-summary-position-point)))
4643 (defun gnus-article-describe-briefly ()
4644 "Describe article mode commands briefly."
4646 (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")))
4648 (defun gnus-article-summary-command ()
4649 "Execute the last keystroke in the summary buffer."
4651 (let ((obuf (current-buffer))
4652 (owin (current-window-configuration))
4654 (switch-to-buffer gnus-article-current-summary 'norecord)
4655 (setq func (lookup-key (current-local-map) (this-command-keys)))
4656 (call-interactively func)
4658 (set-window-configuration owin)
4659 (set-window-point (get-buffer-window (current-buffer)) (point))))
4661 (defun gnus-article-summary-command-nosave ()
4662 "Execute the last keystroke in the summary buffer."
4665 (pop-to-buffer gnus-article-current-summary 'norecord)
4666 (setq func (lookup-key (current-local-map) (this-command-keys)))
4667 (call-interactively func)))
4669 (defun gnus-article-check-buffer ()
4670 "Beep if not in an article buffer."
4671 (unless (equal major-mode 'gnus-article-mode)
4672 (error "Command invoked outside of a Gnus article buffer")))
4674 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4675 "Read a summary buffer key sequence and execute it from the article buffer."
4677 (gnus-article-check-buffer)
4679 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4680 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4681 "=" "^" "\M-^" "|"))
4687 '("n" "Gn" "p" "Gp"))
4690 (set-buffer gnus-article-current-summary)
4691 (let (gnus-pick-mode)
4692 (push (or key last-command-event) unread-command-events)
4693 (setq keys (if (featurep 'xemacs)
4694 (events-to-keys (read-key-sequence nil))
4695 (read-key-sequence nil)))))
4699 (if (or (member keys nosaves)
4700 (member keys nosave-but-article)
4701 (member keys nosave-in-article))
4703 (save-window-excursion
4704 (pop-to-buffer gnus-article-current-summary 'norecord)
4705 ;; We disable the pick minor mode commands.
4706 (let (gnus-pick-mode)
4707 (setq func (lookup-key (current-local-map) keys))))
4711 (unless (member keys nosave-in-article)
4712 (set-buffer gnus-article-current-summary))
4713 (call-interactively func)
4714 (setq new-sum-point (point)))
4715 (when (member keys nosave-but-article)
4716 (pop-to-buffer gnus-article-buffer 'norecord)))
4717 ;; These commands should restore window configuration.
4718 (let ((obuf (current-buffer))
4719 (owin (current-window-configuration))
4721 (summary gnus-article-current-summary)
4722 func in-buffer selected)
4723 (if not-restore-window
4724 (pop-to-buffer summary 'norecord)
4725 (switch-to-buffer summary 'norecord))
4726 (setq in-buffer (current-buffer))
4727 ;; We disable the pick minor mode commands.
4728 (if (and (setq func (let (gnus-pick-mode)
4729 (lookup-key (current-local-map) keys)))
4732 (call-interactively func)
4733 (setq new-sum-point (point))
4734 (when (eq in-buffer (current-buffer))
4735 (setq selected (gnus-summary-select-article))
4737 (unless not-restore-window
4738 (set-window-configuration owin))
4739 (when (eq selected 'old)
4741 (set-window-start (get-buffer-window (current-buffer))
4743 (set-window-point (get-buffer-window (current-buffer))
4745 (let ((win (get-buffer-window gnus-article-current-summary)))
4747 (set-window-point win new-sum-point)))) )
4748 (switch-to-buffer gnus-article-buffer)
4751 (defun gnus-article-describe-key (key)
4752 "Display documentation of the function invoked by KEY. KEY is a string."
4753 (interactive "kDescribe key: ")
4754 (gnus-article-check-buffer)
4755 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4757 (set-buffer gnus-article-current-summary)
4758 (let (gnus-pick-mode)
4759 (if (featurep 'xemacs)
4761 (push (elt key 0) unread-command-events)
4762 (setq key (events-to-keys
4763 (read-key-sequence "Describe key: "))))
4764 (setq unread-command-events
4766 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4767 (string-to-list key)))
4768 (setq key (read-key-sequence "Describe key: "))))
4770 (describe-key key)))
4772 (defun gnus-article-describe-key-briefly (key &optional insert)
4773 "Display documentation of the function invoked by KEY. KEY is a string."
4774 (interactive "kDescribe key: \nP")
4775 (gnus-article-check-buffer)
4776 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4778 (set-buffer gnus-article-current-summary)
4779 (let (gnus-pick-mode)
4780 (if (featurep 'xemacs)
4782 (push (elt key 0) unread-command-events)
4783 (setq key (events-to-keys
4784 (read-key-sequence "Describe key: "))))
4785 (setq unread-command-events
4787 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4788 (string-to-list key)))
4789 (setq key (read-key-sequence "Describe key: "))))
4790 (describe-key-briefly key insert))
4791 (describe-key-briefly key insert)))
4793 (defun gnus-article-reply-with-original (&optional wide)
4794 "Start composing a reply mail to the current message.
4795 The text in the region will be yanked. If the region isn't active,
4796 the entire article will be yanked."
4798 (let ((article (cdr gnus-article-current)) cont)
4800 (gnus-summary-reply (list (list article)) wide)
4801 (setq cont (buffer-substring (point) (mark t)))
4802 ;; Deactivate active regions.
4803 (when (and (boundp 'transient-mark-mode)
4804 transient-mark-mode)
4805 (setq mark-active nil))
4807 (list (list article cont)) wide))))
4809 (defun gnus-article-followup-with-original ()
4810 "Compose a followup to the current article.
4811 The text in the region will be yanked. If the region isn't active,
4812 the entire article will be yanked."
4814 (let ((article (cdr gnus-article-current))
4817 (gnus-summary-followup (list (list article)))
4818 (setq cont (buffer-substring (point) (mark t)))
4819 ;; Deactivate active regions.
4820 (when (and (boundp 'transient-mark-mode)
4821 transient-mark-mode)
4822 (setq mark-active nil))
4823 (gnus-summary-followup
4824 (list (list article cont))))))
4826 (defun gnus-article-hide (&optional arg force)
4827 "Hide all the gruft in the current article.
4828 This means that PGP stuff, signatures, cited text and (some)
4829 headers will be hidden.
4830 If given a prefix, show the hidden text instead."
4831 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4832 (gnus-article-hide-headers arg)
4833 (gnus-article-hide-list-identifiers arg)
4834 (gnus-article-hide-pgp arg)
4835 (gnus-article-hide-citation-maybe arg force)
4836 (gnus-article-hide-signature arg))
4838 (defun gnus-article-maybe-highlight ()
4839 "Do some article highlighting if article highlighting is requested."
4840 (when (gnus-visual-p 'article-highlight 'highlight)
4841 (gnus-article-highlight-some)))
4843 (defun gnus-check-group-server ()
4844 ;; Make sure the connection to the server is alive.
4845 (unless (gnus-server-opened
4846 (gnus-find-method-for-group gnus-newsgroup-name))
4847 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4848 (gnus-request-group gnus-newsgroup-name t)))
4851 (autoload 'nneething-get-file-name "nneething"))
4853 (defun gnus-request-article-this-buffer (article group)
4854 "Get an article and insert it into this buffer."
4855 (let (do-update-line sparse-header)
4859 (gnus-kill-all-overlays)
4860 (setq group (or group gnus-newsgroup-name))
4862 ;; Using `gnus-request-article' directly will insert the article into
4863 ;; `nntp-server-buffer' - so we'll save some time by not having to
4864 ;; copy it from the server buffer into the article buffer.
4866 ;; We only request an article by message-id when we do not have the
4867 ;; headers for it, so we'll have to get those.
4868 (when (stringp article)
4869 (gnus-read-header article))
4871 ;; If the article number is negative, that means that this article
4872 ;; doesn't belong in this newsgroup (possibly), so we find its
4873 ;; message-id and request it by id instead of number.
4874 (when (and (numberp article)
4876 (get-buffer gnus-summary-buffer)
4877 (gnus-buffer-exists-p gnus-summary-buffer))
4879 (set-buffer gnus-summary-buffer)
4880 (let ((header (gnus-summary-article-header article)))
4883 ((memq article gnus-newsgroup-sparse)
4884 ;; This is a sparse gap article.
4885 (setq do-update-line article)
4886 (setq article (mail-header-id header))
4887 (setq sparse-header (gnus-read-header article))
4888 (setq gnus-newsgroup-sparse
4889 (delq article gnus-newsgroup-sparse)))
4891 ;; It's a real article.
4892 (setq article (mail-header-id header)))
4894 ;; It is an extracted pseudo-article.
4895 (setq article 'pseudo)
4896 (gnus-request-pseudo-article header))))
4898 (let ((method (gnus-find-method-for-group
4899 gnus-newsgroup-name)))
4900 (when (and (eq (car method) 'nneething)
4902 (let ((dir (nneething-get-file-name
4903 (mail-header-id header))))
4904 (when (and (stringp dir)
4905 (file-directory-p dir))
4906 (setq article 'nneething)
4907 (gnus-group-enter-directory dir))))))))
4910 ;; Refuse to select canceled articles.
4911 ((and (numberp article)
4913 (get-buffer gnus-summary-buffer)
4914 (gnus-buffer-exists-p gnus-summary-buffer)
4915 (eq (cdr (save-excursion
4916 (set-buffer gnus-summary-buffer)
4917 (assq article gnus-newsgroup-reads)))
4918 gnus-canceled-mark))
4920 ;; We first check `gnus-original-article-buffer'.
4921 ((and (get-buffer gnus-original-article-buffer)
4924 (set-buffer gnus-original-article-buffer)
4925 (and (equal (car gnus-original-article) group)
4926 (eq (cdr gnus-original-article) article))))
4927 (insert-buffer-substring gnus-original-article-buffer)
4929 ;; Check the backlog.
4930 ((and gnus-keep-backlog
4931 (gnus-backlog-request-article group article (current-buffer)))
4933 ;; Check asynchronous pre-fetch.
4934 ((gnus-async-request-fetched-article group article (current-buffer))
4935 (gnus-async-prefetch-next group article gnus-summary-buffer)
4936 (when (and (numberp article) gnus-keep-backlog)
4937 (gnus-backlog-enter-article group article (current-buffer)))
4940 ((and gnus-use-cache
4942 (gnus-cache-request-article article group))
4944 ;; Check the agent cache.
4945 ((and gnus-agent gnus-agent-cache gnus-plugged
4947 (gnus-agent-request-article article group))
4949 ;; Get the article and put into the article buffer.
4950 ((or (stringp article)
4952 (let ((gnus-override-method gnus-override-method)
4953 (methods (and (stringp article)
4954 gnus-refer-article-method))
4955 (backend (car (gnus-find-method-for-group
4956 gnus-newsgroup-name)))
4958 (buffer-read-only nil))
4959 (if (or (not (listp methods))
4960 (and (symbolp (car methods))
4961 (assq (car methods) nnoo-definition-alist)))
4962 (setq methods (list methods)))
4963 (when (and (null gnus-override-method)
4965 (setq gnus-override-method (pop methods)))
4967 (when (eq gnus-override-method 'current)
4968 (setq gnus-override-method
4969 (with-current-buffer gnus-summary-buffer
4970 gnus-current-select-method)))
4972 (gnus-kill-all-overlays)
4973 (let ((gnus-newsgroup-name group))
4974 (gnus-check-group-server))
4976 ((gnus-request-article article group (current-buffer))
4977 (when (numberp article)
4978 (gnus-async-prefetch-next group article
4979 gnus-summary-buffer)
4980 (when gnus-keep-backlog
4981 (gnus-backlog-enter-article
4982 group article (current-buffer))))
4983 (setq result 'article))
4985 (setq gnus-override-method (pop methods)))
4986 ((not (string-match "^400 "
4987 (nnheader-get-report backend)))
4988 ;; If we get 400 server disconnect, reconnect and
4989 ;; retry; otherwise, assume the article has expired.
4990 (setq result 'done))))
4991 (and (eq result 'article) 'article)))
4995 ;; Associate this article with the current summary buffer.
4996 (setq gnus-article-current-summary gnus-summary-buffer)
4998 ;; Take the article from the original article buffer
4999 ;; and place it in the buffer it's supposed to be in.
5000 (when (and (get-buffer gnus-article-buffer)
5001 (equal (buffer-name (current-buffer))
5002 (buffer-name (get-buffer gnus-article-buffer))))
5004 (if (get-buffer gnus-original-article-buffer)
5005 (set-buffer gnus-original-article-buffer)
5006 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5007 (buffer-disable-undo)
5008 (setq major-mode 'gnus-original-article-mode)
5009 (setq buffer-read-only t))
5010 (let (buffer-read-only)
5012 (insert-buffer-substring gnus-article-buffer))
5013 (setq gnus-original-article (cons group article)))
5016 (run-hooks 'gnus-article-decode-hook)
5017 ;; Mark article as decoded or not.
5018 (setq gnus-article-decoded-p gnus-article-decode-hook))
5020 ;; Update sparse articles.
5021 (when (and do-update-line
5022 (or (numberp article)
5024 (let ((buf (current-buffer)))
5025 (set-buffer gnus-summary-buffer)
5026 (gnus-summary-update-article do-update-line sparse-header)
5027 (gnus-summary-goto-subject do-update-line nil t)
5028 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5030 (set-buffer buf))))))
5036 (defcustom gnus-article-edit-mode-hook nil
5037 "Hook run in article edit mode buffers."
5038 :group 'gnus-article-various
5041 (defvar gnus-article-edit-done-function nil)
5043 (defvar gnus-article-edit-mode-map nil)
5045 ;; Should we be using derived.el for this?
5046 (unless gnus-article-edit-mode-map
5047 (setq gnus-article-edit-mode-map (make-keymap))
5048 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5051 (gnus-define-keys gnus-article-edit-mode-map
5052 "\C-c?" describe-mode
5053 "\C-c\C-c" gnus-article-edit-done
5054 "\C-c\C-k" gnus-article-edit-exit
5055 "\C-c\C-f\C-t" message-goto-to
5056 "\C-c\C-f\C-o" message-goto-from
5057 "\C-c\C-f\C-b" message-goto-bcc
5058 ;;"\C-c\C-f\C-w" message-goto-fcc
5059 "\C-c\C-f\C-c" message-goto-cc
5060 "\C-c\C-f\C-s" message-goto-subject
5061 "\C-c\C-f\C-r" message-goto-reply-to
5062 "\C-c\C-f\C-n" message-goto-newsgroups
5063 "\C-c\C-f\C-d" message-goto-distribution
5064 "\C-c\C-f\C-f" message-goto-followup-to
5065 "\C-c\C-f\C-m" message-goto-mail-followup-to
5066 "\C-c\C-f\C-k" message-goto-keywords
5067 "\C-c\C-f\C-u" message-goto-summary
5068 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5069 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5070 "\C-c\C-b" message-goto-body
5071 "\C-c\C-i" message-goto-signature
5073 "\C-c\C-t" message-insert-to
5074 "\C-c\C-n" message-insert-newsgroups
5075 "\C-c\C-o" message-sort-headers
5076 "\C-c\C-e" message-elide-region
5077 "\C-c\C-v" message-delete-not-region
5078 "\C-c\C-z" message-kill-to-signature
5079 "\M-\r" message-newline-and-reformat
5080 "\C-c\C-a" mml-attach-file
5081 "\C-a" message-beginning-of-line
5083 "\M-;" comment-region)
5085 (gnus-define-keys (gnus-article-edit-wash-map
5086 "\C-c\C-w" gnus-article-edit-mode-map)
5087 "f" gnus-article-edit-full-stops))
5090 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5092 ["Fetch To" message-insert-to t]
5093 ["Fetch Newsgroups" message-insert-newsgroups t]
5095 ["To" message-goto-to t]
5096 ["From" message-goto-from t]
5097 ["Subject" message-goto-subject t]
5098 ["Cc" message-goto-cc t]
5099 ["Reply-To" message-goto-reply-to t]
5100 ["Summary" message-goto-summary t]
5101 ["Keywords" message-goto-keywords t]
5102 ["Newsgroups" message-goto-newsgroups t]
5103 ["Followup-To" message-goto-followup-to t]
5104 ["Mail-Followup-To" message-goto-mail-followup-to t]
5105 ["Distribution" message-goto-distribution t]
5106 ["Body" message-goto-body t]
5107 ["Signature" message-goto-signature t]))
5109 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5110 "Major mode for editing articles.
5111 This is an extended text-mode.
5113 \\{gnus-article-edit-mode-map}"
5114 (make-local-variable 'gnus-article-edit-done-function)
5115 (make-local-variable 'gnus-prev-winconf)
5116 (set (make-local-variable 'font-lock-defaults)
5117 '(message-font-lock-keywords t))
5118 (set (make-local-variable 'mail-header-separator) "")
5119 (easy-menu-add message-mode-field-menu message-mode-map)
5121 (setq buffer-read-only nil)
5122 (buffer-enable-undo)
5125 (defun gnus-article-edit (&optional force)
5126 "Edit the current article.
5127 This will have permanent effect only in mail groups.
5128 If FORCE is non-nil, allow editing of articles even in read-only
5131 (when (and (not force)
5132 (gnus-group-read-only-p))
5133 (error "The current newsgroup does not support article editing"))
5134 (gnus-article-date-original)
5135 (gnus-article-edit-article
5137 `(lambda (no-highlight)
5139 (gnus-summary-edit-article-done
5140 ,(or (mail-header-references gnus-current-headers) "")
5141 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5143 (defun gnus-article-edit-article (start-func exit-func)
5144 "Start editing the contents of the current article buffer."
5145 (let ((winconf (current-window-configuration)))
5146 (set-buffer gnus-article-buffer)
5147 (gnus-article-edit-mode)
5148 (funcall start-func)
5149 (set-buffer-modified-p nil)
5150 (gnus-configure-windows 'edit-article)
5151 (setq gnus-article-edit-done-function exit-func)
5152 (setq gnus-prev-winconf winconf)
5153 (gnus-message 6 "C-c C-c to end edits")))
5155 (defun gnus-article-edit-done (&optional arg)
5156 "Update the article edits and exit."
5158 (let ((func gnus-article-edit-done-function)
5159 (buf (current-buffer))
5160 (start (window-start))
5162 (winconf gnus-prev-winconf))
5163 (widen) ;; Widen it in case that users narrowed the buffer.
5166 ;; The cache and backlog have to be flushed somewhat.
5167 (when gnus-keep-backlog
5168 (gnus-backlog-remove-article
5169 (car gnus-article-current) (cdr gnus-article-current)))
5170 ;; Flush original article as well.
5172 (when (get-buffer gnus-original-article-buffer)
5173 (set-buffer gnus-original-article-buffer)
5174 (setq gnus-original-article nil)))
5175 (when gnus-use-cache
5176 (gnus-cache-update-article
5177 (car gnus-article-current) (cdr gnus-article-current)))
5178 ;; We remove all text props from the article buffer.
5179 (kill-all-local-variables)
5180 (gnus-set-text-properties (point-min) (point-max) nil)
5182 (set-window-configuration winconf)
5184 (set-window-start (get-buffer-window buf) start)
5185 (set-window-point (get-buffer-window buf) (point))))
5187 (defun gnus-article-edit-exit ()
5188 "Exit the article editing without updating."
5190 (when (or (not (buffer-modified-p))
5191 (yes-or-no-p "Article modified; kill anyway? "))
5192 (let ((curbuf (current-buffer))
5194 (window-start (window-start)))
5196 (if (gnus-buffer-live-p gnus-original-article-buffer)
5197 (insert-buffer gnus-original-article-buffer))
5198 (let ((winconf gnus-prev-winconf))
5200 (set-window-configuration winconf)
5201 ;; Tippy-toe some to make sure that point remains where it was.
5202 (save-current-buffer
5204 (set-window-start (get-buffer-window (current-buffer)) window-start)
5207 (defun gnus-article-edit-full-stops ()
5208 "Interactively repair spacing at end of sentences."
5211 (goto-char (point-min))
5212 (search-forward-regexp "^$" nil t)
5213 (let ((case-fold-search nil))
5214 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5217 ;;; Article highlights
5220 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5222 ;;; Internal Variables:
5224 (defcustom gnus-button-url-regexp
5225 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5226 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-zA-Z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
5227 "\\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\\)\\)")
5228 "Regular expression that matches URLs."
5229 :group 'gnus-article-buttons
5232 (defcustom gnus-button-man-handler 'man
5233 "Function to use for displaying man pages.
5234 The function must take at least one argument with a string naming the
5236 :type '(choice (function-item :tag "Man" man)
5237 (function-item :tag "Woman" woman)
5238 (function :tag "Other"))
5239 :group 'gnus-article-buttons)
5241 (defcustom gnus-button-alist
5242 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5243 0 t gnus-button-handle-news 3)
5244 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5245 gnus-button-handle-news 2)
5246 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5248 gnus-button-fetch-group 4)
5249 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5250 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5251 t gnus-button-message-id 3)
5252 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5253 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5254 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5256 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5257 gnus-button-handle-info 2)
5258 ;; This is how URLs _should_ be embedded in text...
5259 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5261 (gnus-button-url-regexp 0 t browse-url 0)
5263 ("\\b\\([a-z]+\\)([0-9])\\W" 0 t gnus-button-handle-man 1))
5264 "*Alist of regexps matching buttons in article bodies.
5266 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5267 REGEXP: is the string matching text around the button (can also be lisp
5268 expression evaluating to a string),
5269 BUTTON: is the number of the regexp grouping actually matching the button,
5270 FORM: is a lisp expression which must eval to true for the button to
5272 CALLBACK: is the function to call when the user push this button, and each
5273 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5275 CALLBACK can also be a variable, in that case the value of that
5276 variable it the real callback function."
5277 :group 'gnus-article-buttons
5278 :type '(repeat (list (choice regexp variable)
5279 (integer :tag "Button")
5281 (function :tag "Callback")
5284 (integer :tag "Regexp group")))))
5286 (defcustom gnus-header-button-alist
5287 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5288 0 t gnus-button-message-id 0)
5289 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5290 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5291 0 t gnus-button-mailto 0)
5292 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5293 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5294 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5295 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5296 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5297 gnus-button-message-id 3))
5298 "*Alist of headers and regexps to match buttons in article heads.
5300 This alist is very similar to `gnus-button-alist', except that each
5301 alist has an additional HEADER element first in each entry:
5303 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5305 HEADER is a regexp to match a header. For a fuller explanation, see
5306 `gnus-button-alist'."
5307 :group 'gnus-article-buttons
5308 :group 'gnus-article-headers
5309 :type '(repeat (list (regexp :tag "Header")
5311 (integer :tag "Button")
5313 (function :tag "Callback")
5316 (integer :tag "Regexp group")))))
5318 (defvar gnus-button-regexp nil)
5319 (defvar gnus-button-marker-list nil)
5320 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5322 (defvar gnus-button-last nil)
5323 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5327 (defun gnus-article-push-button (event)
5328 "Check text under the mouse pointer for a callback function.
5329 If the text under the mouse pointer has a `gnus-callback' property,
5330 call it with the value of the `gnus-data' text property."
5332 (set-buffer (window-buffer (posn-window (event-start event))))
5333 (let* ((pos (posn-point (event-start event)))
5334 (data (get-text-property pos 'gnus-data))
5335 (fun (get-text-property pos 'gnus-callback)))
5338 (funcall fun data))))
5340 (defun gnus-article-press-button ()
5341 "Check text at point for a callback function.
5342 If the text at point has a `gnus-callback' property,
5343 call it with the value of the `gnus-data' text property."
5345 (let* ((data (get-text-property (point) 'gnus-data))
5346 (fun (get-text-property (point) 'gnus-callback)))
5348 (funcall fun data))))
5350 (defun gnus-article-highlight (&optional force)
5351 "Highlight current article.
5352 This function calls `gnus-article-highlight-headers',
5353 `gnus-article-highlight-citation',
5354 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5355 do the highlighting. See the documentation for those functions."
5356 (interactive (list 'force))
5357 (gnus-article-highlight-headers)
5358 (gnus-article-highlight-citation force)
5359 (gnus-article-highlight-signature)
5360 (gnus-article-add-buttons force)
5361 (gnus-article-add-buttons-to-head))
5363 (defun gnus-article-highlight-some (&optional force)
5364 "Highlight current article.
5365 This function calls `gnus-article-highlight-headers',
5366 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5367 do the highlighting. See the documentation for those functions."
5368 (interactive (list 'force))
5369 (gnus-article-highlight-headers)
5370 (gnus-article-highlight-signature)
5371 (gnus-article-add-buttons))
5373 (defun gnus-article-highlight-headers ()
5374 "Highlight article headers as specified by `gnus-header-face-alist'."
5377 (set-buffer gnus-article-buffer)
5379 (let ((alist gnus-header-face-alist)
5380 (buffer-read-only nil)
5381 (case-fold-search t)
5382 (inhibit-point-motion-hooks t)
5383 entry regexp header-face field-face from hpoints fpoints)
5384 (article-narrow-to-head)
5385 (while (setq entry (pop alist))
5386 (goto-char (point-min))
5387 (setq regexp (concat "^\\("
5388 (if (string-equal "" (nth 0 entry))
5392 header-face (nth 1 entry)
5393 field-face (nth 2 entry))
5394 (while (and (re-search-forward regexp nil t)
5398 (unless (search-forward ":" nil t)
5400 (when (and header-face
5401 (not (memq (point) hpoints)))
5402 (push (point) hpoints)
5403 (gnus-put-text-property from (point) 'face header-face))
5404 (when (and field-face
5405 (not (memq (setq from (point)) fpoints)))
5407 (if (re-search-forward "^[^ \t]" nil t)
5409 (goto-char (point-max)))
5410 (gnus-put-text-property from (point) 'face field-face))))))))
5412 (defun gnus-article-highlight-signature ()
5413 "Highlight the signature in an article.
5414 It does this by highlighting everything after
5415 `gnus-signature-separator' using `gnus-signature-face'."
5418 (set-buffer gnus-article-buffer)
5419 (let ((buffer-read-only nil)
5420 (inhibit-point-motion-hooks t))
5422 (when (and gnus-signature-face
5423 (gnus-article-narrow-to-signature))
5424 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5425 'face gnus-signature-face)
5427 (gnus-article-search-signature)
5428 (let ((start (match-beginning 0))
5429 (end (set-marker (make-marker) (1+ (match-end 0)))))
5430 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5433 (defun gnus-button-in-region-p (b e prop)
5434 "Say whether PROP exists in the region."
5435 (text-property-not-all b e prop nil))
5437 (defun gnus-article-add-buttons (&optional force)
5438 "Find external references in the article and make buttons of them.
5439 \"External references\" are things like Message-IDs and URLs, as
5440 specified by `gnus-button-alist'."
5441 (interactive (list 'force))
5443 (set-buffer gnus-article-buffer)
5444 (let ((buffer-read-only nil)
5445 (inhibit-point-motion-hooks t)
5446 (case-fold-search t)
5447 (alist gnus-button-alist)
5449 ;; Remove all old markers.
5450 (let (marker entry new-list)
5451 (while (setq marker (pop gnus-button-marker-list))
5452 (if (or (< marker (point-min)) (>= marker (point-max)))
5453 (push marker new-list)
5455 (when (setq entry (gnus-button-entry))
5456 (put-text-property (match-beginning (nth 1 entry))
5457 (match-end (nth 1 entry))
5458 'gnus-callback nil))
5459 (set-marker marker nil)))
5460 (setq gnus-button-marker-list new-list))
5461 ;; We skip the headers.
5464 (while (setq entry (pop alist))
5465 (setq regexp (eval (car entry)))
5467 (while (re-search-forward regexp nil t)
5468 (let* ((start (and entry (match-beginning (nth 1 entry))))
5469 (end (and entry (match-end (nth 1 entry))))
5470 (from (match-beginning 0)))
5471 (when (and (or (eq t (nth 2 entry))
5472 (eval (nth 2 entry)))
5473 (not (gnus-button-in-region-p
5474 start end 'gnus-callback)))
5475 ;; That optional form returned non-nil, so we add the
5477 (gnus-article-add-button
5478 start end 'gnus-button-push
5479 (car (push (set-marker (make-marker) from)
5480 gnus-button-marker-list))))))))))
5482 ;; Add buttons to the head of an article.
5483 (defun gnus-article-add-buttons-to-head ()
5484 "Add buttons to the head of the article."
5487 (set-buffer gnus-article-buffer)
5489 (let ((buffer-read-only nil)
5490 (inhibit-point-motion-hooks t)
5491 (case-fold-search t)
5492 (alist gnus-header-button-alist)
5494 (article-narrow-to-head)
5496 ;; Each alist entry.
5497 (setq entry (car alist)
5499 (goto-char (point-min))
5500 (while (re-search-forward (car entry) nil t)
5501 ;; Each header matching the entry.
5502 (setq beg (match-beginning 0))
5503 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5504 (match-beginning 0))
5507 (while (re-search-forward (eval (nth 1 entry)) end t)
5508 ;; Each match within a header.
5509 (let* ((entry (cdr entry))
5510 (start (match-beginning (nth 1 entry)))
5511 (end (match-end (nth 1 entry)))
5512 (form (nth 2 entry)))
5513 (goto-char (match-end 0))
5515 (gnus-article-add-button
5516 start end (nth 3 entry)
5517 (buffer-substring (match-beginning (nth 4 entry))
5518 (match-end (nth 4 entry)))))))
5519 (goto-char end)))))))
5521 ;;; External functions:
5523 (defun gnus-article-add-button (from to fun &optional data)
5524 "Create a button between FROM and TO with callback FUN and data DATA."
5525 (when gnus-article-button-face
5526 (gnus-overlay-put (gnus-make-overlay from to)
5527 'face gnus-article-button-face))
5528 (gnus-add-text-properties
5530 (nconc (and gnus-article-mouse-face
5531 (list gnus-mouse-face-prop gnus-article-mouse-face))
5532 (list 'gnus-callback fun)
5533 (and data (list 'gnus-data data))))
5534 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5535 :button-keymap gnus-widget-button-keymap))
5537 ;;; Internal functions:
5539 (defun gnus-article-set-globals ()
5541 (set-buffer gnus-summary-buffer)
5542 (gnus-set-global-variables)))
5544 (defun gnus-signature-toggle (end)
5546 (set-buffer gnus-article-buffer)
5547 (let ((buffer-read-only nil)
5548 (inhibit-point-motion-hooks t))
5549 (if (text-property-any end (point-max) 'article-type 'signature)
5551 (gnus-delete-wash-type 'signature)
5552 (gnus-remove-text-properties-when
5553 'article-type 'signature end (point-max)
5554 (cons 'article-type (cons 'signature
5555 gnus-hidden-properties))))
5556 (gnus-add-wash-type 'signature)
5557 (gnus-add-text-properties-when
5558 'article-type nil end (point-max)
5559 (cons 'article-type (cons 'signature
5560 gnus-hidden-properties)))))
5561 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5562 (gnus-set-mode-line 'article))))
5564 (defun gnus-button-entry ()
5565 ;; Return the first entry in `gnus-button-alist' matching this place.
5566 (let ((alist gnus-button-alist)
5569 (setq entry (pop alist))
5570 (if (looking-at (eval (car entry)))
5575 (defun gnus-button-push (marker)
5576 ;; Push button starting at MARKER.
5579 (let* ((entry (gnus-button-entry))
5580 (inhibit-point-motion-hooks t)
5582 (args (mapcar (lambda (group)
5583 (let ((string (match-string group)))
5584 (gnus-set-text-properties
5585 0 (length string) nil string)
5592 (fboundp (symbol-value fun)))
5593 (apply (symbol-value fun) args))
5595 (gnus-message 1 "You must define `%S' to use this button"
5596 (cons fun args)))))))
5598 (defun gnus-parse-news-url (url)
5599 (let (scheme server group message-id articles)
5602 (goto-char (point-min))
5603 (when (looking-at "\\([A-Za-z]+\\):")
5604 (setq scheme (match-string 1))
5605 (goto-char (match-end 0)))
5606 (when (looking-at "//\\([^/]+\\)/")
5607 (setq server (match-string 1))
5608 (goto-char (match-end 0)))
5611 ((looking-at "\\(.*@.*\\)")
5612 (setq message-id (match-string 1)))
5613 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5614 (setq group (match-string 1)
5615 articles (split-string (match-string 2) "-")))
5616 ((looking-at "\\([^/]+\\)/?")
5617 (setq group (match-string 1)))
5619 (error "Unknown news URL syntax"))))
5620 (list scheme server group message-id articles)))
5622 (defun gnus-button-handle-news (url)
5624 (destructuring-bind (scheme server group message-id articles)
5625 (gnus-parse-news-url url)
5629 (set-buffer gnus-summary-buffer)
5631 (let ((gnus-refer-article-method (list (list 'nntp server))))
5632 (gnus-summary-refer-article message-id))
5633 (gnus-summary-refer-article message-id))))
5635 (gnus-button-fetch-group url)))))
5637 (defun gnus-button-handle-man (url)
5639 (funcall gnus-button-man-handler url))
5641 (defun gnus-button-handle-info (url)
5642 "Fetch an info URL."
5644 "^\\([^:/]+\\)?/\\(.*\\)"
5646 (gnus-info-find-node
5647 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5650 (gnus-url-unhex-string (match-string 2 url))))
5651 (error "Can't parse %s" url)))
5653 (defun gnus-button-message-id (message-id)
5656 (set-buffer gnus-summary-buffer)
5657 (gnus-summary-refer-article message-id)))
5659 (defun gnus-button-fetch-group (address)
5660 "Fetch GROUP specified by ADDRESS."
5661 (if (not (string-match "[:/]" address))
5662 ;; This is just a simple group url.
5663 (gnus-group-read-ephemeral-group address gnus-select-method)
5666 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5668 (error "Can't parse %s" address)
5669 (gnus-group-read-ephemeral-group
5670 (match-string 4 address)
5671 `(nntp ,(match-string 1 address)
5672 (nntp-address ,(match-string 1 address))
5673 (nntp-port-number ,(if (match-end 3)
5674 (match-string 3 address)
5677 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5679 (defun gnus-url-parse-query-string (query &optional downcase)
5680 (let (retval pairs cur key val)
5681 (setq pairs (split-string query "&"))
5683 (setq cur (car pairs)
5685 (if (not (string-match "=" cur))
5687 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5688 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5690 (setq key (downcase key)))
5691 (setq cur (assoc key retval))
5693 (setcdr cur (cons val (cdr cur)))
5694 (setq retval (cons (list key val) retval)))))
5697 (defun gnus-url-mailto (url)
5698 ;; Send mail to someone
5699 (when (string-match "mailto:/*\\(.*\\)" url)
5700 (setq url (substring url (match-beginning 1) nil)))
5701 (let (to args subject func)
5702 (if (string-match (regexp-quote "?") url)
5703 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5704 args (gnus-url-parse-query-string
5705 (substring url (match-end 0) nil) t))
5706 (setq to (gnus-url-unhex-string url)))
5707 (setq args (cons (list "to" to) args)
5708 subject (cdr-safe (assoc "subject" args)))
5711 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5714 (message-position-on-field (caar args)))
5715 (insert (mapconcat 'identity (cdar args) ", "))
5716 (setq args (cdr args)))
5719 (message-goto-subject))))
5721 (defun gnus-button-embedded-url (address)
5722 "Activate ADDRESS with `browse-url'."
5723 (browse-url (gnus-strip-whitespace address)))
5725 ;;; Next/prev buttons in the article buffer.
5727 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5728 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5730 (defvar gnus-prev-page-map
5731 (let ((map (make-sparse-keymap)))
5732 (unless (>= emacs-major-version 21)
5733 ;; XEmacs doesn't care.
5734 (set-keymap-parent map gnus-article-mode-map))
5735 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5736 (define-key map "\r" 'gnus-button-prev-page)
5739 (defun gnus-insert-prev-page-button ()
5741 (buffer-read-only nil))
5743 gnus-prev-page-line-format nil
5744 `(,@(gnus-local-map-property gnus-prev-page-map)
5746 gnus-callback gnus-article-button-prev-page
5747 article-type annotation))
5748 (widget-convert-button
5750 :action 'gnus-button-prev-page
5751 :button-keymap gnus-prev-page-map)))
5753 (defvar gnus-prev-page-map
5754 (let ((map (make-sparse-keymap)))
5755 (unless (>= emacs-major-version 21)
5756 ;; XEmacs doesn't care.
5757 (set-keymap-parent map gnus-article-mode-map))
5758 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5759 (define-key map "\r" 'gnus-button-prev-page)
5762 (defvar gnus-next-page-map
5763 (let ((map (make-sparse-keymap)))
5764 (unless (>= emacs-major-version 21)
5765 ;; XEmacs doesn't care.
5766 (set-keymap-parent map gnus-article-mode-map))
5767 (define-key map gnus-mouse-2 'gnus-button-next-page)
5768 (define-key map "\r" 'gnus-button-next-page)
5771 (defun gnus-button-next-page (&optional args more-args)
5772 "Go to the next page."
5774 (let ((win (selected-window)))
5775 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5776 (gnus-article-next-page)
5777 (select-window win)))
5779 (defun gnus-button-prev-page (&optional args more-args)
5780 "Go to the prev page."
5782 (let ((win (selected-window)))
5783 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5784 (gnus-article-prev-page)
5785 (select-window win)))
5787 (defun gnus-insert-next-page-button ()
5789 (buffer-read-only nil))
5790 (gnus-eval-format gnus-next-page-line-format nil
5791 `(,@(gnus-local-map-property gnus-next-page-map)
5793 gnus-callback gnus-article-button-next-page
5794 article-type annotation))
5795 (widget-convert-button
5797 :action 'gnus-button-next-page
5798 :button-keymap gnus-next-page-map)))
5800 (defun gnus-article-button-next-page (arg)
5801 "Go to the next page."
5803 (let ((win (selected-window)))
5804 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5805 (gnus-article-next-page)
5806 (select-window win)))
5808 (defun gnus-article-button-prev-page (arg)
5809 "Go to the prev page."
5811 (let ((win (selected-window)))
5812 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5813 (gnus-article-prev-page)
5814 (select-window win)))
5816 (defvar gnus-decode-header-methods
5817 '(mail-decode-encoded-word-region)
5818 "List of methods used to decode headers.
5820 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5821 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5822 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5823 whose names match REGEXP.
5826 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5827 mail-decode-encoded-word-region
5828 (\"chinese\" . rfc1843-decode-region))
5831 (defvar gnus-decode-header-methods-cache nil)
5833 (defun gnus-multi-decode-header (start end)
5834 "Apply the functions from `gnus-encoded-word-methods' that match."
5835 (unless (and gnus-decode-header-methods-cache
5836 (eq gnus-newsgroup-name
5837 (car gnus-decode-header-methods-cache)))
5838 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5841 (nconc gnus-decode-header-methods-cache (list x))
5842 (if (and gnus-newsgroup-name
5843 (string-match (car x) gnus-newsgroup-name))
5844 (nconc gnus-decode-header-methods-cache
5846 gnus-decode-header-methods))
5847 (let ((xlist gnus-decode-header-methods-cache))
5850 (narrow-to-region start end)
5852 (funcall (pop xlist) (point-min) (point-max))))))
5855 ;;; Treatment top-level handling.
5858 (defun gnus-treat-article (condition &optional part-number total-parts type)
5859 (let ((length (- (point-max) (point-min)))
5860 (alist gnus-treatment-function-alist)
5861 (article-goto-body-goes-to-point-min-p t)
5865 (let ((list gnus-article-treat-types))
5867 (when (string-match (pop list) type)
5868 (throw 'found t)))))))
5869 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5871 (gnus-run-hooks 'gnus-part-display-hook)
5872 (while (setq elem (pop alist))
5875 (if (gnus-buffer-live-p gnus-summary-buffer)
5876 (set-buffer gnus-summary-buffer))
5877 (symbol-value (car elem))))
5878 (when (and (or (consp val)
5880 (gnus-treat-predicate val)
5881 (or (not (get (car elem) 'highlight))
5884 (funcall (cadr elem)))))))
5886 ;; Dynamic variables.
5888 (defvar part-number)
5889 (defvar total-parts)
5894 (defun gnus-treat-predicate (val)
5899 (stringp (car val)))
5900 (apply 'gnus-or (mapcar `(lambda (s)
5901 (string-match s ,(or gnus-newsgroup-name "")))
5904 (let ((pred (pop val)))
5907 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5909 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5911 (not (gnus-treat-predicate (car val))))
5913 (equal (car val) type))
5915 (error "%S is not a valid predicate" pred)))))
5923 (eq part-number total-parts))
5927 (error "%S is not a valid value" val))))
5929 (defun gnus-article-encrypt-body (protocol &optional n)
5930 "Encrypt the article body."
5933 (or gnus-article-encrypt-protocol
5934 (completing-read "Encrypt protocol: "
5935 gnus-article-encrypt-protocol-alist
5937 current-prefix-arg))
5938 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5940 (error (format "Can't find the encrypt protocol %s" protocol)))
5941 (if (equal gnus-newsgroup-name "nndraft:drafts")
5942 (error "Can't encrypt the article in group nndraft:drafts"))
5943 (if (equal gnus-newsgroup-name "nndraft:queue")
5944 (error "Don't encrypt the article in group nndraft:queue"))
5945 (gnus-summary-iterate n
5947 (set-buffer gnus-summary-buffer)
5948 (let ((mail-parse-charset gnus-newsgroup-charset)
5949 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5950 (summary-buffer gnus-summary-buffer)
5952 (gnus-set-global-variables)
5953 (when (gnus-group-read-only-p)
5954 (error "The current newsgroup does not support article encrypt"))
5955 (gnus-summary-show-article t)
5957 (or (mail-header-references gnus-current-headers) ""))
5958 (set-buffer gnus-article-buffer)
5959 (let* ((buffer-read-only nil)
5961 (mapcar (lambda (field)
5962 (and (save-restriction
5963 (message-narrow-to-head)
5964 (goto-char (point-min))
5965 (search-forward field nil t))
5967 (message-narrow-to-field)
5968 (buffer-substring (point-min) (point-max))
5969 (delete-region (point-min) (point-max))
5971 '("Content-Type:" "Content-Transfer-Encoding:"
5972 "Content-Disposition:"))))
5973 (message-narrow-to-head)
5974 (message-remove-header "MIME-Version")
5975 (goto-char (point-max))
5976 (setq point (point))
5977 (insert (apply 'concat headers))
5979 (narrow-to-region point (point-max))
5980 (let ((message-options message-options))
5981 (message-options-set 'message-sender user-mail-address)
5982 (message-options-set 'message-recipients user-mail-address)
5983 (message-options-set 'message-sign-encrypt 'not)
5985 (goto-char (point-min))
5986 (insert "MIME-Version: 1.0\n")
5988 (gnus-summary-edit-article-done
5989 references nil summary-buffer t))
5990 (when gnus-keep-backlog
5991 (gnus-backlog-remove-article
5992 (car gnus-article-current) (cdr gnus-article-current)))
5994 (when (get-buffer gnus-original-article-buffer)
5995 (set-buffer gnus-original-article-buffer)
5996 (setq gnus-original-article nil)))
5997 (when gnus-use-cache
5998 (gnus-cache-update-article
5999 (car gnus-article-current) (cdr gnus-article-current))))))))
6001 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6002 "The following specs can be used:
6003 %t The security MIME type
6006 %D Details if button is pressed")
6008 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6009 "The following specs can be used:
6010 %t The security MIME type
6013 %D Details if button is pressed")
6015 (defvar gnus-mime-security-button-line-format-alist
6016 '((?t gnus-tmp-type ?s)
6017 (?i gnus-tmp-info ?s)
6018 (?d gnus-tmp-details ?s)
6019 (?D gnus-tmp-pressed-details ?s)))
6021 (defvar gnus-mime-security-button-map
6022 (let ((map (make-sparse-keymap)))
6023 (unless (>= (string-to-number emacs-version) 21)
6024 (set-keymap-parent map gnus-article-mode-map))
6025 (define-key map gnus-mouse-2 'gnus-article-push-button)
6026 (define-key map "\r" 'gnus-article-press-button)
6029 (defvar gnus-mime-security-details-buffer nil)
6031 (defvar gnus-mime-security-button-pressed nil)
6033 (defvar gnus-mime-security-show-details-inline t
6034 "If non-nil, show details in the article buffer.")
6036 (defun gnus-mime-security-verify-or-decrypt (handle)
6037 (mm-remove-parts (cdr handle))
6038 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6039 point buffer-read-only)
6041 (goto-char (car region)))
6043 (narrow-to-region (point) (point))
6044 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6045 (let* ((mm-verify-option 'known)
6046 (mm-decrypt-option 'known)
6047 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6048 (unless (eq nparts (cdr handle))
6049 (mm-destroy-parts (cdr handle))
6050 (setcdr handle nparts))))
6051 (setq point (point))
6052 (gnus-mime-display-security handle)
6053 (goto-char (point-max)))
6055 (delete-region (point) (cdr region))
6056 (set-marker (car region) nil)
6057 (set-marker (cdr region) nil))
6060 (defun gnus-mime-security-show-details (handle)
6061 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6063 (if gnus-mime-security-show-details-inline
6064 (let ((gnus-mime-security-button-pressed t)
6065 (gnus-mime-security-button-line-format
6066 (get-text-property (point) 'gnus-line-format))
6069 (while (eq (get-text-property (point) 'gnus-line-format)
6070 gnus-mime-security-button-line-format)
6074 (narrow-to-region (point) (point))
6075 (gnus-insert-mime-security-button handle))
6076 (delete-region (point)
6077 (or (text-property-not-all
6080 gnus-mime-security-button-line-format)
6082 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6083 (with-current-buffer gnus-mime-security-details-buffer
6086 (setq gnus-mime-security-details-buffer
6087 (gnus-get-buffer-create "*MIME Security Details*")))
6088 (with-current-buffer gnus-mime-security-details-buffer
6090 (goto-char (point-min)))
6091 (pop-to-buffer gnus-mime-security-details-buffer))
6092 (gnus-message 5 "No details."))))
6094 (defun gnus-mime-security-press-button (handle)
6095 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6096 (gnus-mime-security-show-details handle)
6097 (gnus-mime-security-verify-or-decrypt handle)))
6099 (defun gnus-insert-mime-security-button (handle &optional displayed)
6100 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6103 (or (nth 2 (assoc protocol mm-verify-function-alist))
6104 (nth 2 (assoc protocol mm-decrypt-function-alist))
6106 (if (equal (car handle) "multipart/signed")
6107 " Signed" " Encrypted")
6110 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6113 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6114 gnus-tmp-pressed-details
6116 (setq gnus-tmp-details
6117 (if gnus-tmp-details
6118 (concat "\n" gnus-tmp-details) ""))
6119 (setq gnus-tmp-pressed-details
6120 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6125 gnus-mime-security-button-line-format
6126 gnus-mime-security-button-line-format-alist
6127 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6128 gnus-callback gnus-mime-security-press-button
6129 gnus-line-format ,gnus-mime-security-button-line-format
6130 article-type annotation
6133 (widget-convert-button
6136 :action 'gnus-widget-press-button
6137 :button-keymap gnus-mime-security-button-map
6139 (lambda (widget/window &optional overlay pos)
6140 ;; Needed to properly clear the message due to a bug in
6141 ;; wid-edit (XEmacs only).
6142 (if (boundp 'help-echo-owns-message)
6143 (setq help-echo-owns-message t))
6146 (aref gnus-mouse-2 0))))))
6148 (defun gnus-mime-display-security (handle)
6150 (narrow-to-region (point) (point))
6151 (unless (gnus-unbuttonized-mime-type-p (car handle))
6152 (gnus-insert-mime-security-button handle))
6153 (gnus-mime-display-mixed (cdr handle))
6156 (unless (gnus-unbuttonized-mime-type-p (car handle))
6157 (let ((gnus-mime-security-button-line-format
6158 gnus-mime-security-button-end-line-format))
6159 (gnus-insert-mime-security-button handle)))
6160 (mm-set-handle-multipart-parameter
6162 (cons (set-marker (make-marker) (point-min))
6163 (set-marker (make-marker) (point-max))))))
6169 (run-hooks 'gnus-art-load-hook)
6171 ;;; gnus-art.el ends here