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-article-address-banner-alist nil
283 "Alist of mail addresses and banners.
284 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
285 to match a mail address in the From: header, BANNER is one of a symbol
286 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
287 If ADDRESS matches author's mail address, it will remove things like
288 advertisements. For example:
290 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
294 (regexp :tag "Address")
295 (choice :tag "Banner" :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
299 (const :tag "None" nil))))
300 :group 'gnus-article-washing)
302 (defcustom gnus-emphasis-alist
304 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
309 ("_/" "/_" underline-italic)
310 ("_\\*" "\\*_" underline-bold)
311 ("\\*/" "/\\*" bold-italic)
312 ("_\\*/" "/\\*_" underline-bold-italic))))
316 (format format (car spec) (cadr spec))
317 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
319 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
320 2 3 gnus-emphasis-strikethru)
321 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
322 2 3 gnus-emphasis-underline)))
323 "*Alist that says how to fontify certain phrases.
324 Each item looks like this:
326 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
328 The first element is a regular expression to be matched. The second
329 is a number that says what regular expression grouping used to find
330 the entire emphasized word. The third is a number that says what
331 regexp grouping should be displayed and highlighted. The fourth
332 is the face used for highlighting."
333 :type '(repeat (list :value ("" 0 0 default)
335 (integer :tag "Match group")
336 (integer :tag "Emphasize group")
338 :group 'gnus-article-emphasis)
340 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
341 "A regexp to describe whitespace which should not be emphasized.
342 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
343 The former avoids underlining of leading and trailing whitespace,
344 and the latter avoids underlining any whitespace at all."
346 :group 'gnus-article-emphasis
349 (defface gnus-emphasis-bold '((t (:bold t)))
350 "Face used for displaying strong emphasized text (*word*)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-italic '((t (:italic t)))
354 "Face used for displaying italic emphasized text (/word/)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-underline '((t (:underline t)))
358 "Face used for displaying underlined emphasized text (_word_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
362 "Face used for displaying underlined bold emphasized text (_*word*_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
366 "Face used for displaying underlined italic emphasized text (_/word/_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
370 "Face used for displaying bold italic emphasized text (/*word*/)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold-italic
374 '((t (:bold t :italic t :underline t)))
375 "Face used for displaying underlined bold italic emphasized text.
376 Example: (_/*word*/_)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
380 "Face used for displaying strike-through text (-word-)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-highlight-words
384 '((t (:background "black" :foreground "yellow")))
385 "Face used for displaying highlighted words."
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
389 "Format for display of Date headers in article bodies.
390 See `format-time-string' for the possible values.
392 The variable can also be function, which should return a complete Date
393 header. The function is called with one argument, the time, which can
394 be fed to `format-time-string'."
395 :type '(choice string symbol)
396 :link '(custom-manual "(gnus)Article Date")
397 :group 'gnus-article-washing)
400 (autoload 'mail-extract-address-components "mail-extr"))
402 (defcustom gnus-save-all-headers t
403 "*If non-nil, don't remove any headers before saving."
404 :group 'gnus-article-saving
407 (defcustom gnus-prompt-before-saving 'always
408 "*This variable says how much prompting is to be done when saving articles.
409 If it is nil, no prompting will be done, and the articles will be
410 saved to the default files. If this variable is `always', each and
411 every article that is saved will be preceded by a prompt, even when
412 saving large batches of articles. If this variable is neither nil not
413 `always', there the user will be prompted once for a file name for
414 each invocation of the saving commands."
415 :group 'gnus-article-saving
416 :type '(choice (item always)
417 (item :tag "never" nil)
418 (sexp :tag "once" :format "%t\n" :value t)))
420 (defcustom gnus-saved-headers gnus-visible-headers
421 "Headers to keep if `gnus-save-all-headers' is nil.
422 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
423 If that variable is nil, however, all headers that match this regexp
424 will be kept while the rest will be deleted before saving."
425 :group 'gnus-article-saving
428 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
429 "A function to save articles in your favourite format.
430 The function must be interactively callable (in other words, it must
431 be an Emacs command).
433 Gnus provides the following functions:
435 * gnus-summary-save-in-rmail (Rmail format)
436 * gnus-summary-save-in-mail (Unix mail format)
437 * gnus-summary-save-in-folder (MH folder)
438 * gnus-summary-save-in-file (article format)
439 * gnus-summary-save-body-in-file (article body)
440 * gnus-summary-save-in-vm (use VM's folder format)
441 * gnus-summary-write-to-file (article format -- overwrite)."
442 :group 'gnus-article-saving
443 :type '(radio (function-item gnus-summary-save-in-rmail)
444 (function-item gnus-summary-save-in-mail)
445 (function-item gnus-summary-save-in-folder)
446 (function-item gnus-summary-save-in-file)
447 (function-item gnus-summary-save-body-in-file)
448 (function-item gnus-summary-save-in-vm)
449 (function-item gnus-summary-write-to-file)))
451 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
452 "A function generating a file name to save articles in Rmail format.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
454 :group 'gnus-article-saving
457 (defcustom gnus-mail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Unix mail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-folder-save-name 'gnus-folder-save-name
464 "A function generating a file name to save articles in MH folder.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
466 :group 'gnus-article-saving
469 (defcustom gnus-file-save-name 'gnus-numeric-save-name
470 "A function generating a file name to save articles in article format.
471 The function is called with NEWSGROUP, HEADERS, and optional
473 :group 'gnus-article-saving
476 (defcustom gnus-split-methods
477 '((gnus-article-archive-name)
478 (gnus-article-nndoc-name))
479 "*Variable used to suggest where articles are to be saved.
480 For instance, if you would like to save articles related to Gnus in
481 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
482 you could set this variable to something like:
484 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
485 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
487 This variable is an alist where the where the key is the match and the
488 value is a list of possible files to save in if the match is non-nil.
490 If the match is a string, it is used as a regexp match on the
491 article. If the match is a symbol, that symbol will be funcalled
492 from the buffer of the article to be saved with the newsgroup as the
493 parameter. If it is a list, it will be evaled in the same buffer.
495 If this form or function returns a string, this string will be used as
496 a possible file name; and if it returns a non-nil list, that list will
497 be used as possible file names."
498 :group 'gnus-article-saving
499 :type '(repeat (choice (list :value (fun) function)
500 (cons :value ("" "") regexp (repeat string))
503 (defcustom gnus-page-delimiter "^\^L"
504 "*Regexp describing what to use as article page delimiters.
505 The default value is \"^\^L\", which is a form linefeed at the
506 beginning of a line."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
511 "*The format specification for the article mode line.
512 See `gnus-summary-mode-line-format' for a closer description.
514 The following additional specs are available:
516 %w The article washing status.
517 %m The number of MIME parts in the article."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-mode-hook nil
522 "*A hook for Gnus article mode."
524 :group 'gnus-article-various)
526 (when (featurep 'xemacs)
527 ;; Extracted from gnus-xmas-define in order to preserve user settings
528 (when (fboundp 'turn-off-scroll-in-place)
529 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
530 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
531 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
533 (defcustom gnus-article-menu-hook nil
534 "*Hook run after the creation of the article mode menu."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-prepare-hook nil
539 "*A hook called after an article has been prepared in the article buffer."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-hide-pgp-hook nil
544 "*A hook called after successfully hiding a PGP signature."
546 :group 'gnus-article-various)
548 (defcustom gnus-article-button-face 'bold
549 "Face used for highlighting buttons in the article buffer.
551 An article button is a piece of text that you can activate by pressing
552 `RET' or `mouse-2' above it."
554 :group 'gnus-article-buttons)
556 (defcustom gnus-article-mouse-face 'highlight
557 "Face used for mouse highlighting in the article buffer.
559 Article buttons will be displayed in this face when the cursor is
562 :group 'gnus-article-buttons)
564 (defcustom gnus-signature-face 'gnus-signature-face
565 "Face used for highlighting a signature in the article buffer.
566 Obsolete; use the face `gnus-signature-face' for customizations instead."
568 :group 'gnus-article-highlight
569 :group 'gnus-article-signature)
571 (defface gnus-signature-face
574 "Face used for highlighting a signature in the article buffer."
575 :group 'gnus-article-highlight
576 :group 'gnus-article-signature)
578 (defface gnus-header-from-face
581 (:foreground "spring green"))
584 (:foreground "red3"))
587 "Face used for displaying from headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-subject-face
594 (:foreground "SeaGreen3"))
597 (:foreground "red4"))
599 (:bold t :italic t)))
600 "Face used for displaying subject headers."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-newsgroups-face
607 (:foreground "yellow" :italic t))
610 (:foreground "MidnightBlue" :italic t))
613 "Face used for displaying newsgroups headers."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defface gnus-header-name-face
620 (:foreground "SeaGreen"))
623 (:foreground "maroon"))
626 "Face used for displaying header names."
627 :group 'gnus-article-headers
628 :group 'gnus-article-highlight)
630 (defface gnus-header-content-face
633 (:foreground "forest green" :italic t))
636 (:foreground "indianred4" :italic t))
638 (:italic t))) "Face used for displaying header content."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defcustom gnus-header-face-alist
643 '(("From" nil gnus-header-from-face)
644 ("Subject" nil gnus-header-subject-face)
645 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
646 ("" gnus-header-name-face gnus-header-content-face))
647 "*Controls highlighting of article header.
649 An alist of the form (HEADER NAME CONTENT).
651 HEADER is a regular expression which should match the name of an
652 header header and NAME and CONTENT are either face names or nil.
654 The name of each header field will be displayed using the face
655 specified by the first element in the list where HEADER match the
656 header name and NAME is non-nil. Similarly, the content will be
657 displayed by the first non-nil matching CONTENT face."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight
660 :type '(repeat (list (regexp :tag "Header")
662 (item :tag "skip" nil)
663 (face :value default))
664 (choice :tag "Content"
665 (item :tag "skip" nil)
666 (face :value default)))))
668 (defcustom gnus-article-decode-hook
669 '(article-decode-charset article-decode-encoded-words
670 article-decode-group-name)
671 "*Hook run to decode charsets in articles."
672 :group 'gnus-article-headers
675 (defcustom gnus-display-mime-function 'gnus-display-mime
676 "Function to display MIME articles."
677 :group 'gnus-article-mime
680 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
681 "Function used to decode headers.")
683 (defvar gnus-article-dumbquotes-map
698 ("\230" "-") ; This might not be correct.
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-body-boundary-delimiter "_"
728 "String used to delimit header and body.
729 This variable is used by `gnus-article-treat-body-boundary' which can
730 be controlled by `gnus-treat-body-boundary'."
731 :group 'gnus-article-various
732 :type '(choice (item :tag "None" :value nil)
735 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
736 "Defines the location of the faces database.
737 For information on obtaining this database of pretty pictures, please
738 see http://www.cs.indiana.edu/picons/ftp/index.html"
739 :type '(repeat directory)
740 :link '(url-link :tag "download"
741 "http://www.cs.indiana.edu/picons/ftp/index.html")
742 :link '(custom-manual "(gnus)Picons")
745 (defun gnus-picons-installed-p ()
746 "Say whether picons are installed on your machine."
747 (let ((installed nil))
748 (dolist (database gnus-picon-databases)
749 (when (file-exists-p database)
753 (defcustom gnus-article-mime-part-function nil
754 "Function called with a MIME handle as the argument.
755 This is meant for people who want to do something automatic based
756 on parts -- for instance, adding Vcard info to a database."
757 :group 'gnus-article-mime
760 (defcustom gnus-mime-multipart-functions nil
761 "An alist of MIME types to functions to display them."
763 :group 'gnus-article-mime
766 (defcustom gnus-article-date-lapsed-new-header nil
767 "Whether the X-Sent and Date headers can coexist.
768 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
769 either replace the old \"Date:\" header (if this variable is nil), or
770 be added below it (otherwise)."
772 :group 'gnus-article-headers
775 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
776 "Function called with a MIME handle as the argument.
777 This is meant for people who want to view first matched part.
778 For `undisplayed-alternative' (default), the first undisplayed
779 part or alternative part is used. For `undisplayed', the first
780 undisplayed part is used. For a function, the first part which
781 the function return `t' is used. For `nil', the first part is
784 :group 'gnus-article-mime
786 (item :tag "first" :value nil)
787 (item :tag "undisplayed" :value undisplayed)
788 (item :tag "undisplayed or alternative"
789 :value undisplayed-alternative)
792 (defcustom gnus-mime-action-alist
793 '(("save to file" . gnus-mime-save-part)
794 ("save and strip" . gnus-mime-save-part-and-strip)
795 ("display as text" . gnus-mime-inline-part)
796 ("view the part" . gnus-mime-view-part)
797 ("pipe to command" . gnus-mime-pipe-part)
798 ("toggle display" . gnus-article-press-button)
799 ("toggle display" . gnus-article-view-part-as-charset)
800 ("view as type" . gnus-mime-view-part-as-type)
801 ("view internally" . gnus-mime-view-part-internally)
802 ("view externally" . gnus-mime-view-part-externally))
803 "An alist of actions that run on the MIME attachment."
804 :group 'gnus-article-mime
805 :type '(repeat (cons (string :tag "name")
809 ;;; The treatment variables
812 (defvar gnus-part-display-hook nil
813 "Hook called on parts that are to receive treatment.")
815 (defvar gnus-article-treat-custom
816 '(choice (const :tag "Off" nil)
818 (const :tag "Header" head)
819 (const :tag "Last" last)
820 (integer :tag "Less")
821 (repeat :tag "Groups" regexp)
822 (sexp :tag "Predicate")))
824 (defvar gnus-article-treat-head-custom
825 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)))
828 (defvar gnus-article-treat-types '("text/plain")
831 (defvar gnus-inhibit-treatment nil
832 "Whether to inhibit treatment.")
834 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
835 "Highlight the signature.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles'."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-custom)
840 (put 'gnus-treat-highlight-signature 'highlight t)
842 (defcustom gnus-treat-buttonize 100000
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles'."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
848 (put 'gnus-treat-buttonize 'highlight t)
850 (defcustom gnus-treat-buttonize-head 'head
851 "Add buttons to the head.
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-head-custom)
856 (put 'gnus-treat-buttonize-head 'highlight t)
858 (defcustom gnus-treat-emphasize
859 (and (or window-system
861 (>= (string-to-number emacs-version) 21))
864 Valid values are nil, t, `head', `last', an integer or a predicate.
865 See Info node `(gnus)Customizing Articles' for details."
866 :group 'gnus-article-treat
867 :type gnus-article-treat-custom)
868 (put 'gnus-treat-emphasize 'highlight t)
870 (defcustom gnus-treat-strip-cr nil
871 "Remove carriage returns.
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See Info node `(gnus)Customizing Articles' for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-unsplit-urls nil
878 "Remove newlines from within URLs.
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles' for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-leading-whitespace nil
885 "Remove leading whitespace in headers.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See Info node `(gnus)Customizing Articles' for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 (defcustom gnus-treat-hide-headers 'head
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles' for details."
895 :group 'gnus-article-treat
896 :type gnus-article-treat-head-custom)
898 (defcustom gnus-treat-hide-boring-headers nil
899 "Hide boring headers.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :type gnus-article-treat-head-custom)
905 (defcustom gnus-treat-hide-signature nil
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles' for details."
909 :group 'gnus-article-treat
910 :type gnus-article-treat-custom)
912 (defcustom gnus-treat-fill-article nil
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles' for details."
916 :group 'gnus-article-treat
917 :type gnus-article-treat-custom)
919 (defcustom gnus-treat-hide-citation nil
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
923 :group 'gnus-article-treat
924 :type gnus-article-treat-custom)
926 (defcustom gnus-treat-hide-citation-maybe nil
928 Valid values are nil, t, `head', `last', an integer or a predicate.
929 See Info node `(gnus)Customizing Articles' for details."
930 :group 'gnus-article-treat
931 :type gnus-article-treat-custom)
933 (defcustom gnus-treat-strip-list-identifiers 'head
934 "Strip list identifiers from `gnus-list-identifiers`.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
938 :group 'gnus-article-treat
939 :type gnus-article-treat-custom)
941 (defcustom gnus-treat-strip-pgp t
942 "Strip PGP signatures.
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See Info node `(gnus)Customizing Articles' for details."
945 :group 'gnus-article-treat
946 :type gnus-article-treat-custom)
948 (defcustom gnus-treat-strip-pem nil
949 "Strip PEM signatures.
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-strip-banner t
956 "Strip banners from articles.
957 The banner to be stripped is specified in the `banner' group parameter.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-highlight-headers 'head
964 "Highlight the headers.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-head-custom)
969 (put 'gnus-treat-highlight-headers 'highlight t)
971 (defcustom gnus-treat-highlight-citation t
972 "Highlight cited text.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :type gnus-article-treat-custom)
977 (put 'gnus-treat-highlight-citation 'highlight t)
979 (defcustom gnus-treat-date-ut nil
980 "Display the Date in UT (GMT).
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :type gnus-article-treat-head-custom)
986 (defcustom gnus-treat-date-local nil
987 "Display the Date in the local timezone.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
990 :group 'gnus-article-treat
991 :type gnus-article-treat-head-custom)
993 (defcustom gnus-treat-date-english nil
994 "Display the Date in a format that can be read aloud in English.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :type gnus-article-treat-head-custom)
1000 (defcustom gnus-treat-date-lapsed nil
1001 "Display the Date header in a way that says how much time has elapsed.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :type gnus-article-treat-head-custom)
1007 (defcustom gnus-treat-date-original nil
1008 "Display the date in the original timezone.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-iso8601 nil
1015 "Display the date in the ISO8601 format.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-user-defined nil
1023 "Display the date in a user-defined format.
1024 The format is defined by the `gnus-article-time-format' variable.
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-strip-headers-in-body t
1031 "Strip the X-No-Archive header line from the beginning of the body.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-strip-trailing-blank-lines nil
1039 "Strip trailing blank lines.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-strip-leading-blank-lines nil
1046 "Strip leading blank lines.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :type gnus-article-treat-custom)
1052 (defcustom gnus-treat-strip-multiple-blank-lines nil
1053 "Strip multiple blank lines.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-unfold-headers 'head
1060 "Unfold folded header lines.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-fold-headers nil
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-fold-newsgroups 'head
1074 "Fold the Newsgroups and Followup-To headers.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :type gnus-article-treat-custom)
1080 (defcustom gnus-treat-overstrike t
1081 "Treat overstrike highlighting.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :type gnus-article-treat-custom)
1086 (put 'gnus-treat-overstrike 'highlight t)
1088 (defcustom gnus-treat-display-xface
1089 (and (not noninteractive)
1090 (or (and (fboundp 'image-type-available-p)
1091 (image-type-available-p 'xbm)
1092 (string-match "^0x" (shell-command-to-string "uncompface")))
1093 (and (featurep 'xemacs)
1096 "Display X-Face headers.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' and Info node
1099 `(gnus)X-Face' for details."
1100 :group 'gnus-article-treat
1102 :type gnus-article-treat-head-custom)
1103 (put 'gnus-treat-display-xface 'highlight t)
1105 (defcustom gnus-treat-display-grey-xface
1106 (and (not noninteractive)
1107 (string-match "^0x" (shell-command-to-string "uncompface"))
1109 "Display grey X-Face headers.
1110 Valid values are nil, t."
1111 :group 'gnus-article-treat
1114 (put 'gnus-treat-display-grey-xface 'highlight t)
1116 (defcustom gnus-treat-display-smileys
1117 (if (or (and (featurep 'xemacs)
1119 (and (fboundp 'image-type-available-p)
1120 (image-type-available-p 'pbm)))
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' and Info node
1125 `(gnus)Smileys' for details."
1126 :group 'gnus-article-treat
1128 :type gnus-article-treat-custom)
1129 (put 'gnus-treat-display-smileys 'highlight t)
1131 (defcustom gnus-treat-from-picon
1132 (if (and (gnus-image-type-available-p 'xpm)
1133 (gnus-picons-installed-p))
1135 "Display picons in the From header.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' and Info node
1138 `(gnus)Picons' for details."
1139 :group 'gnus-article-treat
1141 :link '(info-link "(gnus)Customizing Articles")
1142 :link '(info-link "(gnus)Picons")
1143 :type gnus-article-treat-head-custom)
1144 (put 'gnus-treat-from-picon 'highlight t)
1146 (defcustom gnus-treat-mail-picon
1147 (if (and (gnus-image-type-available-p 'xpm)
1148 (gnus-picons-installed-p))
1150 "Display picons in To and Cc headers.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' and Info node
1153 `(gnus)Picons' for details."
1154 :group 'gnus-article-treat
1156 :link '(info-link "(gnus)Customizing Articles")
1157 :link '(info-link "(gnus)Picons")
1158 :type gnus-article-treat-head-custom)
1159 (put 'gnus-treat-mail-picon 'highlight t)
1161 (defcustom gnus-treat-newsgroups-picon
1162 (if (and (gnus-image-type-available-p 'xpm)
1163 (gnus-picons-installed-p))
1165 "Display picons in the Newsgroups and Followup-To headers.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' and Info node
1168 `(gnus)Picons' for details."
1169 :group 'gnus-article-treat
1171 :link '(info-link "(gnus)Customizing Articles")
1172 :link '(info-link "(gnus)Picons")
1173 :type gnus-article-treat-head-custom)
1174 (put 'gnus-treat-newsgroups-picon 'highlight t)
1176 (defcustom gnus-treat-body-boundary
1177 (if (or gnus-treat-newsgroups-picon
1178 gnus-treat-mail-picon
1179 gnus-treat-from-picon)
1181 "Draw a boundary at the end of the headers.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :type gnus-article-treat-custom)
1188 (defcustom gnus-treat-capitalize-sentences nil
1189 "Capitalize sentence-starting words.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1193 :group 'gnus-article-treat
1194 :type gnus-article-treat-custom)
1196 (defcustom gnus-treat-fill-long-lines nil
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1200 :group 'gnus-article-treat
1201 :type gnus-article-treat-custom)
1203 (defcustom gnus-treat-play-sounds nil
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :type gnus-article-treat-custom)
1211 (defcustom gnus-treat-translate nil
1212 "Translate articles from one language to another.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' for details."
1216 :group 'gnus-article-treat
1217 :type gnus-article-treat-custom)
1219 (defcustom gnus-treat-x-pgp-sig nil
1221 To automatically treat X-PGP-Sig, set it to head.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' for details."
1224 :group 'gnus-article-treat
1225 :group 'mime-security
1226 :type gnus-article-treat-custom)
1228 (defvar gnus-article-encrypt-protocol-alist
1229 '(("PGP" . mml2015-self-encrypt)))
1231 ;; Set to nil if more than one protocol added to
1232 ;; gnus-article-encrypt-protocol-alist.
1233 (defcustom gnus-article-encrypt-protocol "PGP"
1234 "The protocol used for encrypt articles.
1235 It is a string, such as \"PGP\". If nil, ask user."
1237 :group 'mime-security)
1239 (defvar gnus-article-wash-function nil
1240 "Function used for converting HTML into text.")
1242 ;;; Internal variables
1244 (defvar gnus-english-month-names
1245 '("January" "February" "March" "April" "May" "June" "July" "August"
1246 "September" "October" "November" "December"))
1248 (defvar article-goto-body-goes-to-point-min-p nil)
1249 (defvar gnus-article-wash-types nil)
1250 (defvar gnus-article-emphasis-alist nil)
1251 (defvar gnus-article-image-alist nil)
1253 (defvar gnus-article-mime-handle-alist-1 nil)
1254 (defvar gnus-treatment-function-alist
1255 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1256 (gnus-treat-strip-banner gnus-article-strip-banner)
1257 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1258 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1259 (gnus-treat-buttonize gnus-article-add-buttons)
1260 (gnus-treat-fill-article gnus-article-fill-cited-article)
1261 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1262 (gnus-treat-strip-cr gnus-article-remove-cr)
1263 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1264 (gnus-treat-date-ut gnus-article-date-ut)
1265 (gnus-treat-date-local gnus-article-date-local)
1266 (gnus-treat-date-english gnus-article-date-english)
1267 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1268 (gnus-treat-date-original gnus-article-date-original)
1269 (gnus-treat-date-user-defined gnus-article-date-user)
1270 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1271 (gnus-treat-display-xface gnus-article-display-x-face)
1272 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1273 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1274 (gnus-treat-hide-signature gnus-article-hide-signature)
1275 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1276 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1277 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1278 (gnus-treat-strip-pem gnus-article-hide-pem)
1279 (gnus-treat-from-picon gnus-treat-from-picon)
1280 (gnus-treat-mail-picon gnus-treat-mail-picon)
1281 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1282 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1283 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1284 (gnus-treat-strip-trailing-blank-lines
1285 gnus-article-remove-trailing-blank-lines)
1286 (gnus-treat-strip-leading-blank-lines
1287 gnus-article-strip-leading-blank-lines)
1288 (gnus-treat-strip-multiple-blank-lines
1289 gnus-article-strip-multiple-blank-lines)
1290 (gnus-treat-overstrike gnus-article-treat-overstrike)
1291 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1292 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1293 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1294 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1295 (gnus-treat-display-smileys gnus-treat-smiley)
1296 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1297 (gnus-treat-emphasize gnus-article-emphasize)
1298 (gnus-treat-hide-citation gnus-article-hide-citation)
1299 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1300 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1301 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1302 (gnus-treat-play-sounds gnus-earcon-display)))
1304 (defvar gnus-article-mime-handle-alist nil)
1305 (defvar article-lapsed-timer nil)
1306 (defvar gnus-article-current-summary nil)
1308 (defvar gnus-article-mode-syntax-table
1309 (let ((table (copy-syntax-table text-mode-syntax-table)))
1310 ;; This causes the citation match run O(2^n).
1311 ;; (modify-syntax-entry ?- "w" table)
1312 (modify-syntax-entry ?> ")<" table)
1313 (modify-syntax-entry ?< "(>" table)
1315 "Syntax table used in article mode buffers.
1316 Initialized from `text-mode-syntax-table.")
1318 (defvar gnus-save-article-buffer nil)
1320 (defvar gnus-article-mode-line-format-alist
1321 (nconc '((?w (gnus-article-wash-status) ?s)
1322 (?m (gnus-article-mime-part-status) ?s))
1323 gnus-summary-mode-line-format-alist))
1325 (defvar gnus-number-of-articles-to-be-saved nil)
1327 (defvar gnus-inhibit-hiding nil)
1329 ;;; Macros for dealing with the article buffer.
1331 (defmacro gnus-with-article-headers (&rest forms)
1333 (set-buffer gnus-article-buffer)
1335 (let ((buffer-read-only nil)
1336 (inhibit-point-motion-hooks t)
1337 (case-fold-search t))
1338 (article-narrow-to-head)
1341 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1342 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1344 (defmacro gnus-with-article-buffer (&rest forms)
1346 (set-buffer gnus-article-buffer)
1347 (let ((buffer-read-only nil))
1350 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1351 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1353 (defun gnus-article-goto-header (header)
1354 "Go to HEADER, which is a regular expression."
1355 (re-search-forward (concat "^\\(" header "\\):") nil t))
1357 (defsubst gnus-article-hide-text (b e props)
1358 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1359 (gnus-add-text-properties-when 'article-type nil b e props)
1360 (when (memq 'intangible props)
1362 (max (1- b) (point-min))
1363 b 'intangible (cddr (memq 'intangible props)))))
1365 (defsubst gnus-article-unhide-text (b e)
1366 "Remove hidden text properties from region between B and E."
1367 (remove-text-properties b e gnus-hidden-properties)
1368 (when (memq 'intangible gnus-hidden-properties)
1369 (put-text-property (max (1- b) (point-min))
1370 b 'intangible nil)))
1372 (defun gnus-article-hide-text-type (b e type)
1373 "Hide text of TYPE between B and E."
1374 (gnus-add-wash-type type)
1375 (gnus-article-hide-text
1376 b e (cons 'article-type (cons type gnus-hidden-properties))))
1378 (defun gnus-article-unhide-text-type (b e type)
1379 "Unhide text of TYPE between B and E."
1380 (gnus-delete-wash-type type)
1381 (remove-text-properties
1382 b e (cons 'article-type (cons type gnus-hidden-properties)))
1383 (when (memq 'intangible gnus-hidden-properties)
1384 (put-text-property (max (1- b) (point-min))
1385 b 'intangible nil)))
1387 (defun gnus-article-hide-text-of-type (type)
1388 "Hide text of TYPE in the current buffer."
1390 (let ((b (point-min))
1392 (while (setq b (text-property-any b e 'article-type type))
1393 (add-text-properties b (incf b) gnus-hidden-properties)))))
1395 (defun gnus-article-delete-text-of-type (type)
1396 "Delete text of TYPE in the current buffer."
1398 (let ((b (point-min)))
1399 (while (setq b (text-property-any b (point-max) 'article-type type))
1401 b (or (text-property-not-all b (point-max) 'article-type type)
1404 (defun gnus-article-delete-invisible-text ()
1405 "Delete all invisible text in the current buffer."
1407 (let ((b (point-min)))
1408 (while (setq b (text-property-any b (point-max) 'invisible t))
1410 b (or (text-property-not-all b (point-max) 'invisible t)
1413 (defun gnus-article-text-type-exists-p (type)
1414 "Say whether any text of type TYPE exists in the buffer."
1415 (text-property-any (point-min) (point-max) 'article-type type))
1417 (defsubst gnus-article-header-rank ()
1418 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1419 (let ((list gnus-sorted-header-list)
1422 (when (looking-at (car list))
1424 (setq list (cdr list))
1428 (defun article-hide-headers (&optional arg delete)
1429 "Hide unwanted headers and possibly sort them as well."
1431 ;; This function might be inhibited.
1432 (unless gnus-inhibit-hiding
1435 (let ((buffer-read-only nil)
1436 (case-fold-search t)
1437 (max (1+ (length gnus-sorted-header-list)))
1438 (ignored (when (not gnus-visible-headers)
1439 (cond ((stringp gnus-ignored-headers)
1440 gnus-ignored-headers)
1441 ((listp gnus-ignored-headers)
1442 (mapconcat 'identity gnus-ignored-headers
1445 (cond ((stringp gnus-visible-headers)
1446 gnus-visible-headers)
1447 ((and gnus-visible-headers
1448 (listp gnus-visible-headers))
1449 (mapconcat 'identity gnus-visible-headers "\\|"))))
1450 (inhibit-point-motion-hooks t)
1452 ;; First we narrow to just the headers.
1453 (article-narrow-to-head)
1454 ;; Hide any "From " lines at the beginning of (mail) articles.
1455 (while (looking-at "From ")
1458 (delete-region (point-min) (point)))
1459 ;; Then treat the rest of the header lines.
1460 ;; Then we use the two regular expressions
1461 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1462 ;; select which header lines is to remain visible in the
1464 (while (re-search-forward "^[^ \t:]*:" nil t)
1466 ;; Mark the rank of the header.
1468 (point) (1+ (point)) 'message-rank
1469 (if (or (and visible (looking-at visible))
1471 (not (looking-at ignored))))
1472 (gnus-article-header-rank)
1475 (message-sort-headers-1)
1476 (when (setq beg (text-property-any
1477 (point-min) (point-max) 'message-rank (+ 2 max)))
1478 ;; We delete the unwanted headers.
1479 (gnus-add-wash-type 'headers)
1480 (add-text-properties (point-min) (+ 5 (point-min))
1481 '(article-type headers dummy-invisible t))
1482 (delete-region beg (point-max))))))))
1484 (defun article-hide-boring-headers (&optional arg)
1485 "Toggle hiding of headers that aren't very interesting.
1486 If given a negative prefix, always show; if given a positive prefix,
1488 (interactive (gnus-article-hidden-arg))
1489 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1490 (not gnus-show-all-headers))
1493 (let ((buffer-read-only nil)
1494 (list gnus-boring-article-headers)
1495 (inhibit-point-motion-hooks t)
1497 (article-narrow-to-head)
1499 (setq elem (pop list))
1500 (goto-char (point-min))
1502 ;; Hide empty headers.
1504 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1506 (gnus-article-hide-text-type
1507 (progn (beginning-of-line) (point))
1510 (if (re-search-forward "^[^ \t]" nil t)
1514 ;; Hide boring Newsgroups header.
1515 ((eq elem 'newsgroups)
1516 (when (gnus-string-equal
1517 (gnus-fetch-field "newsgroups")
1518 (gnus-group-real-name
1519 (if (boundp 'gnus-newsgroup-name)
1522 (gnus-article-hide-header "newsgroups")))
1523 ((eq elem 'to-address)
1524 (let ((to (message-fetch-field "to"))
1526 (gnus-parameter-to-address
1527 (if (boundp 'gnus-newsgroup-name)
1528 gnus-newsgroup-name ""))))
1529 (when (and to to-address
1532 ;; only one address in To
1533 (nth 1 (mail-extract-address-components to))
1535 (gnus-article-hide-header "to"))))
1536 ((eq elem 'followup-to)
1537 (when (gnus-string-equal
1538 (message-fetch-field "followup-to")
1539 (message-fetch-field "newsgroups"))
1540 (gnus-article-hide-header "followup-to")))
1541 ((eq elem 'reply-to)
1542 (let ((from (message-fetch-field "from"))
1543 (reply-to (message-fetch-field "reply-to")))
1548 (nth 1 (mail-extract-address-components from))
1549 (nth 1 (mail-extract-address-components reply-to)))))
1550 (gnus-article-hide-header "reply-to"))))
1552 (let ((date (message-fetch-field "date")))
1554 (< (days-between (current-time-string) date)
1556 (gnus-article-hide-header "date"))))
1558 (let ((to (message-fetch-field "to"))
1559 (cc (message-fetch-field "cc")))
1560 (when (> (length to) 1024)
1561 (gnus-article-hide-header "to"))
1562 (when (> (length cc) 1024)
1563 (gnus-article-hide-header "cc"))))
1567 (goto-char (point-min))
1568 (while (re-search-forward "^to:" nil t)
1569 (setq to-count (1+ to-count)))
1570 (when (> to-count 1)
1571 (while (> to-count 0)
1572 (goto-char (point-min))
1574 (re-search-forward "^to:" nil nil to-count)
1576 (narrow-to-region (point) (point-max))
1577 (gnus-article-hide-header "to"))
1578 (setq to-count (1- to-count))))
1579 (goto-char (point-min))
1580 (while (re-search-forward "^cc:" nil t)
1581 (setq cc-count (1+ cc-count)))
1582 (when (> cc-count 1)
1583 (while (> cc-count 0)
1584 (goto-char (point-min))
1586 (re-search-forward "^cc:" nil nil cc-count)
1588 (narrow-to-region (point) (point-max))
1589 (gnus-article-hide-header "cc"))
1590 (setq cc-count (1- cc-count)))))))))))))
1592 (defun gnus-article-hide-header (header)
1594 (goto-char (point-min))
1595 (when (re-search-forward (concat "^" header ":") nil t)
1596 (gnus-article-hide-text-type
1597 (progn (beginning-of-line) (point))
1600 (if (re-search-forward "^[^ \t]" nil t)
1605 (defvar gnus-article-normalized-header-length 40
1606 "Length of normalized headers.")
1608 (defun article-normalize-headers ()
1609 "Make all header lines 40 characters long."
1611 (let ((buffer-read-only nil)
1615 (article-narrow-to-head)
1618 ((< (setq column (- (gnus-point-at-eol) (point)))
1619 gnus-article-normalized-header-length)
1621 (insert (make-string
1622 (- gnus-article-normalized-header-length column)
1624 ((> column gnus-article-normalized-header-length)
1625 (gnus-put-text-property
1627 (forward-char gnus-article-normalized-header-length)
1634 (forward-line 1))))))
1636 (defun article-treat-dumbquotes ()
1637 "Translate M****s*** sm*rtq**t*s into proper text.
1638 Note that this function guesses whether a character is a sm*rtq**t* or
1639 not, so it should only be used interactively.
1641 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1642 in an attempt to provide more quoting characters. If you see
1643 something like \\222 or \\264 where you're expecting some kind of
1644 apostrophe or quotation mark, then try this wash."
1646 (article-translate-strings gnus-article-dumbquotes-map))
1648 (defun article-translate-characters (from to)
1649 "Translate all characters in the body of the article according to FROM and TO.
1650 FROM is a string of characters to translate from; to is a string of
1651 characters to translate to."
1653 (when (article-goto-body)
1654 (let ((buffer-read-only nil)
1655 (x (make-string 225 ?x))
1657 (while (< (incf i) (length x))
1660 (while (< i (length from))
1661 (aset x (aref from i) (aref to i))
1663 (translate-region (point) (point-max) x)))))
1665 (defun article-translate-strings (map)
1666 "Translate all string in the body of the article according to MAP.
1667 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1669 (when (article-goto-body)
1670 (let ((buffer-read-only nil)
1672 (while (setq elem (pop map))
1674 (while (search-forward (car elem) nil t)
1675 (replace-match (cadr elem)))))))))
1677 (defun article-treat-overstrike ()
1678 "Translate overstrikes into bold text."
1681 (when (article-goto-body)
1682 (let ((buffer-read-only nil))
1683 (while (search-forward "\b" nil t)
1684 (let ((next (char-after))
1685 (previous (char-after (- (point) 2))))
1686 ;; We do the boldification/underlining by hiding the
1687 ;; overstrikes and putting the proper text property
1691 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1692 (put-text-property (point) (1+ (point)) 'face 'bold))
1694 (gnus-article-hide-text-type
1695 (1- (point)) (1+ (point)) 'overstrike)
1697 (- (point) 2) (1- (point)) 'face 'underline))
1699 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1701 (point) (1+ (point)) 'face 'underline)))))))))
1703 (defun gnus-article-treat-unfold-headers ()
1704 "Unfold folded message headers.
1705 Only the headers that fit into the current window width will be
1708 (gnus-with-article-headers
1712 (mail-header-narrow-to-field)
1713 (let ((header (buffer-substring (point-min) (point-max))))
1716 (goto-char (point-min))
1717 (while (re-search-forward "\n[\t ]" nil t)
1718 (replace-match " " t t)))
1719 (setq length (- (point-max) (point-min) 1)))
1720 (when (< length (window-width))
1721 (while (re-search-forward "\n[\t ]" nil t)
1722 (replace-match " " t t)))
1723 (goto-char (point-max)))))))
1725 (defun gnus-article-treat-fold-headers ()
1726 "Fold message headers."
1728 (gnus-with-article-headers
1731 (mail-header-narrow-to-field)
1732 (mail-header-fold-field)
1733 (goto-char (point-max))))))
1735 (defun gnus-treat-smiley ()
1736 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1738 (gnus-with-article-buffer
1739 (if (memq 'smiley gnus-article-wash-types)
1740 (gnus-delete-images 'smiley)
1742 (let ((images (smiley-region (point) (point-max))))
1744 (gnus-add-wash-type 'smiley)
1745 (dolist (image images)
1746 (gnus-add-image 'smiley image)))))))
1748 (defun gnus-article-remove-images ()
1749 "Remove all images from the article buffer."
1751 (gnus-with-article-buffer
1752 (dolist (elem gnus-article-image-alist)
1753 (gnus-delete-images (car elem)))))
1755 (defun gnus-article-treat-fold-newsgroups ()
1756 "Unfold folded message headers.
1757 Only the headers that fit into the current window width will be
1760 (gnus-with-article-headers
1761 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1763 (mail-header-narrow-to-field)
1764 (while (re-search-forward ", *" nil t)
1765 (replace-match ", " t t))
1766 (mail-header-fold-field)
1767 (goto-char (point-max))))))
1769 (defun gnus-article-treat-body-boundary ()
1770 "Place a boundary line at the end of the headers."
1772 (when (and gnus-body-boundary-delimiter
1773 (> (length gnus-body-boundary-delimiter) 0))
1774 (gnus-with-article-headers
1775 (goto-char (point-max))
1776 (let ((start (point)))
1777 (insert "X-Boundary: ")
1778 (gnus-add-text-properties start (point) '(invisible t intangible t))
1780 (while (>= (1- (window-width)) (length str))
1781 (setq str (concat str gnus-body-boundary-delimiter)))
1782 (substring str 0 (1- (window-width))))
1784 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1786 (defun article-fill-long-lines ()
1787 "Fill lines that are wider than the window width."
1790 (let ((buffer-read-only nil)
1791 (width (window-width (get-buffer-window (current-buffer)))))
1794 (let ((adaptive-fill-mode nil)) ;Why? -sm
1797 (when (>= (current-column) (min fill-column width))
1798 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1799 (let ((goback (point-marker)))
1800 (fill-paragraph nil)
1801 (goto-char (marker-position goback)))
1803 (forward-line 1)))))))
1805 (defun article-capitalize-sentences ()
1806 "Capitalize the first word in each sentence."
1809 (let ((buffer-read-only nil)
1810 (paragraph-start "^[\n\^L]"))
1814 (forward-sentence)))))
1816 (defun article-remove-cr ()
1817 "Remove trailing CRs and then translate remaining CRs into LFs."
1820 (let ((buffer-read-only nil))
1821 (goto-char (point-min))
1822 (while (re-search-forward "\r+$" nil t)
1823 (replace-match "" t t))
1824 (goto-char (point-min))
1825 (while (search-forward "\r" nil t)
1826 (replace-match "\n" t t)))))
1828 (defun article-remove-trailing-blank-lines ()
1829 "Remove all trailing blank lines from the article."
1832 (let ((buffer-read-only nil))
1833 (goto-char (point-max))
1837 (while (and (not (bobp))
1838 (looking-at "^[ \t]*$")
1839 (not (gnus-annotation-in-region-p
1840 (point) (gnus-point-at-eol))))
1845 (defun article-display-x-face (&optional force)
1846 "Look for an X-Face header and display it if present."
1847 (interactive (list 'force))
1848 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1849 (gnus-with-article-headers
1850 ;; Delete the old process, if any.
1851 (when (process-status "article-x-face")
1852 (delete-process "article-x-face"))
1853 (if (memq 'xface gnus-article-wash-types)
1854 ;; We have already displayed X-Faces, so we remove them
1856 (gnus-delete-images 'xface)
1858 (let (x-faces from face grey)
1860 (when (and wash-face-p
1862 (goto-char (point-min))
1863 (not (re-search-forward
1864 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1865 (gnus-buffer-live-p gnus-original-article-buffer))
1866 ;; If type `W f', use gnus-original-article-buffer,
1867 ;; otherwise use the current buffer because displaying
1868 ;; RFC822 parts calls this function too.
1869 (set-buffer gnus-original-article-buffer))
1871 (mail-narrow-to-head)
1872 (if gnus-treat-display-grey-xface
1874 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1875 (if (match-beginning 2)
1878 (push (cons (- (string-to-number (match-string 2)))
1879 (mail-header-field-value))
1881 (push (cons 0 (mail-header-field-value)) x-faces)))
1882 (dolist (x-face (prog1
1884 (sort x-faces 'car-less-than-car)
1886 (setq x-faces nil)))
1887 (push (cdr x-face) x-faces)))
1888 (while (gnus-article-goto-header "X-Face")
1889 (push (mail-header-field-value) x-faces)))
1890 (setq from (message-fetch-field "from"))))
1892 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1895 (setq image (gnus-create-image xpm 'xpm t))
1896 (gnus-article-goto-header "from")
1898 (insert "From: [no `from' set]\n")
1900 (gnus-add-wash-type 'xface)
1901 (gnus-add-image 'xface image)
1902 (gnus-put-image image)))
1903 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1904 ;; single external face.
1905 (when (stringp gnus-article-x-face-command)
1906 (setq x-faces (list (car x-faces))))
1907 (while (and (setq face (pop x-faces))
1908 gnus-article-x-face-command
1910 ;; Check whether this face is censored.
1911 (not gnus-article-x-face-too-ugly)
1912 (and gnus-article-x-face-too-ugly from
1913 (not (string-match gnus-article-x-face-too-ugly
1915 ;; We display the face.
1916 (if (symbolp gnus-article-x-face-command)
1917 ;; The command is a lisp function, so we call it.
1918 (if (gnus-functionp gnus-article-x-face-command)
1919 (funcall gnus-article-x-face-command face)
1920 (error "%s is not a function" gnus-article-x-face-command))
1921 ;; The command is a string, so we interpret the command
1922 ;; as a, well, command, and fork it off.
1923 (let ((process-connection-type nil))
1924 (process-kill-without-query
1926 "article-x-face" nil shell-file-name shell-command-switch
1927 gnus-article-x-face-command))
1930 (process-send-region "article-x-face"
1931 (point-min) (point-max)))
1932 (process-send-eof "article-x-face"))))))))))
1934 (defun article-decode-mime-words ()
1935 "Decode all MIME-encoded words in the article."
1938 (set-buffer gnus-article-buffer)
1939 (let ((inhibit-point-motion-hooks t)
1941 (mail-parse-charset gnus-newsgroup-charset)
1942 (mail-parse-ignored-charsets
1943 (save-excursion (set-buffer gnus-summary-buffer)
1944 gnus-newsgroup-ignored-charsets)))
1945 (mail-decode-encoded-word-region (point-min) (point-max)))))
1947 (defun article-decode-charset (&optional prompt)
1948 "Decode charset-encoded text in the article.
1949 If PROMPT (the prefix), prompt for a coding system to use."
1951 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1953 (mail-parse-charset gnus-newsgroup-charset)
1954 (mail-parse-ignored-charsets
1955 (save-excursion (condition-case nil
1956 (set-buffer gnus-summary-buffer)
1958 gnus-newsgroup-ignored-charsets))
1959 ct cte ctl charset format)
1962 (article-narrow-to-head)
1963 (setq ct (message-fetch-field "Content-Type" t)
1964 cte (message-fetch-field "Content-Transfer-Encoding" t)
1965 ctl (and ct (ignore-errors
1966 (mail-header-parse-content-type ct)))
1969 (mm-read-coding-system "Charset to decode: "))
1971 (mail-content-type-get ctl 'charset)))
1972 format (and ctl (mail-content-type-get ctl 'format)))
1974 (setq cte (mail-header-strip cte)))
1975 (if (and ctl (not (string-match "/" (car ctl))))
1977 (goto-char (point-max)))
1980 (narrow-to-region (point) (point-max))
1981 (when (and (eq mail-parse-charset 'gnus-decoded)
1982 (eq (mm-body-7-or-8) '8bit))
1983 ;; The text code could have been decoded.
1984 (setq charset mail-parse-charset))
1985 (when (and (or (not ctl)
1986 (equal (car ctl) "text/plain"))
1987 (not format)) ;; article with format will decode later.
1989 charset (and cte (intern (downcase
1990 (gnus-strip-whitespace cte))))
1993 (defun article-decode-encoded-words ()
1994 "Remove encoded-word encoding from headers."
1995 (let ((inhibit-point-motion-hooks t)
1996 (mail-parse-charset gnus-newsgroup-charset)
1997 (mail-parse-ignored-charsets
1998 (save-excursion (condition-case nil
1999 (set-buffer gnus-summary-buffer)
2001 gnus-newsgroup-ignored-charsets))
2004 (article-narrow-to-head)
2005 (funcall gnus-decode-header-function (point-min) (point-max)))))
2007 (defun article-decode-group-name ()
2008 "Decode group names in `Newsgroups:'."
2009 (let ((inhibit-point-motion-hooks t)
2011 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2012 (when (and (or gnus-group-name-charset-method-alist
2013 gnus-group-name-charset-group-alist)
2014 (gnus-buffer-live-p gnus-original-article-buffer))
2015 (when (nnmail-fetch-field "Newsgroups")
2016 (nnheader-replace-header "Newsgroups"
2017 (gnus-decode-newsgroups
2018 (with-current-buffer
2019 gnus-original-article-buffer
2020 (nnmail-fetch-field "Newsgroups"))
2021 gnus-newsgroup-name method)))
2022 (when (nnmail-fetch-field "Followup-To")
2023 (nnheader-replace-header "Followup-To"
2024 (gnus-decode-newsgroups
2025 (with-current-buffer
2026 gnus-original-article-buffer
2027 (nnmail-fetch-field "Followup-To"))
2028 gnus-newsgroup-name method))))))
2030 (defun article-de-quoted-unreadable (&optional force read-charset)
2031 "Translate a quoted-printable-encoded article.
2032 If FORCE, decode the article whether it is marked as quoted-printable
2034 If READ-CHARSET, ask for a coding system."
2035 (interactive (list 'force current-prefix-arg))
2037 (let ((buffer-read-only nil) type charset)
2038 (if (gnus-buffer-live-p gnus-original-article-buffer)
2039 (with-current-buffer gnus-original-article-buffer
2041 (gnus-fetch-field "content-transfer-encoding"))
2042 (let* ((ct (gnus-fetch-field "content-type"))
2045 (mail-header-parse-content-type ct)))))
2046 (setq charset (and ctl
2047 (mail-content-type-get ctl 'charset)))
2048 (if (stringp charset)
2049 (setq charset (intern (downcase charset)))))))
2051 (setq charset (mm-read-coding-system "Charset: " charset)))
2053 (setq charset gnus-newsgroup-charset))
2055 (and type (let ((case-fold-search t))
2056 (string-match "quoted-printable" type))))
2058 (quoted-printable-decode-region
2059 (point) (point-max) (mm-charset-to-coding-system charset))))))
2061 (defun article-de-base64-unreadable (&optional force read-charset)
2062 "Translate a base64 article.
2063 If FORCE, decode the article whether it is marked as base64 not.
2064 If READ-CHARSET, ask for a coding system."
2065 (interactive (list 'force current-prefix-arg))
2067 (let ((buffer-read-only nil) type charset)
2068 (if (gnus-buffer-live-p gnus-original-article-buffer)
2069 (with-current-buffer gnus-original-article-buffer
2071 (gnus-fetch-field "content-transfer-encoding"))
2072 (let* ((ct (gnus-fetch-field "content-type"))
2075 (mail-header-parse-content-type ct)))))
2076 (setq charset (and ctl
2077 (mail-content-type-get ctl 'charset)))
2078 (if (stringp charset)
2079 (setq charset (intern (downcase charset)))))))
2081 (setq charset (mm-read-coding-system "Charset: " charset)))
2083 (setq charset gnus-newsgroup-charset))
2085 (and type (let ((case-fold-search t))
2086 (string-match "base64" type))))
2089 (narrow-to-region (point) (point-max))
2090 (base64-decode-region (point-min) (point-max))
2091 (mm-decode-coding-region
2092 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2097 (defun article-decode-HZ ()
2098 "Translate a HZ-encoded article."
2102 (let ((buffer-read-only nil))
2103 (rfc1843-decode-region (point-min) (point-max)))))
2105 (defun article-unsplit-urls ()
2106 "Remove the newlines that some other mailers insert into URLs."
2109 (let ((buffer-read-only nil))
2110 (goto-char (point-min))
2111 (while (re-search-forward
2112 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2113 (replace-match "\\1\\3" t)))
2114 (when (and gnus-display-mime-function (interactive-p))
2115 (funcall gnus-display-mime-function))))
2118 (defun article-wash-html (&optional read-charset)
2119 "Format an html article.
2120 If READ-CHARSET, ask for a coding system."
2123 (let ((buffer-read-only nil)
2125 (if (gnus-buffer-live-p gnus-original-article-buffer)
2126 (with-current-buffer gnus-original-article-buffer
2127 (let* ((ct (gnus-fetch-field "content-type"))
2130 (mail-header-parse-content-type ct)))))
2131 (setq charset (and ctl
2132 (mail-content-type-get ctl 'charset)))
2133 (if (stringp charset)
2134 (setq charset (intern (downcase charset)))))))
2136 (setq charset (mm-read-coding-system "Charset: " charset)))
2138 (setq charset gnus-newsgroup-charset))
2140 (save-window-excursion
2142 (narrow-to-region (point) (point-max))
2143 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2144 (entry (assq func mm-text-html-washer-alist)))
2146 (setq func (cdr entry)))
2148 ((gnus-functionp func)
2151 (apply (car func) (cdr func))))))))))
2153 (defun gnus-article-wash-html-with-w3 ()
2154 "Wash the current buffer with w3."
2156 (let ((w3-strict-width (window-width))
2157 (url-standalone-mode t)
2158 (url-gateway-unplugged t)
2159 (w3-honor-stylesheets nil))
2161 (w3-region (point-min) (point-max))
2164 (defun gnus-article-wash-html-with-w3m ()
2165 "Wash the current buffer with emacs-w3m."
2168 (narrow-to-region (point) (point-max))
2169 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2172 (w3m-display-inline-images mm-inline-text-html-with-images)
2173 w3m-force-redisplay)
2174 (w3m-region (point-min) (point-max)))
2175 (when mm-inline-text-html-with-w3m-keymap
2176 (add-text-properties
2177 (point-min) (point-max)
2178 (append '(mm-inline-text-html-with-w3m t)
2179 (gnus-local-map-property mm-w3m-mode-map))))))
2181 (defun article-hide-list-identifiers ()
2182 "Remove list identifies from the Subject header.
2183 The `gnus-list-identifiers' variable specifies what to do."
2185 (let ((inhibit-point-motion-hooks t)
2186 (regexp (if (consp gnus-list-identifiers)
2187 (mapconcat 'identity gnus-list-identifiers " *\\|")
2188 gnus-list-identifiers))
2193 (article-narrow-to-head)
2194 (goto-char (point-min))
2195 (while (re-search-forward
2196 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2198 (delete-region (match-beginning 2) (match-end 0))
2199 (beginning-of-line))
2200 (when (re-search-forward
2201 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2202 (delete-region (match-beginning 1) (match-end 1))))))))
2204 (defun article-hide-pgp ()
2205 "Remove any PGP headers and signatures in the current article."
2209 (let ((inhibit-point-motion-hooks t)
2210 buffer-read-only beg end)
2212 ;; Hide the "header".
2213 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2214 (gnus-add-wash-type 'pgp)
2215 (delete-region (match-beginning 0) (match-end 0))
2216 ;; Remove armor headers (rfc2440 6.2)
2217 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2220 ;; Hide the actual signature.
2221 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2222 (setq end (1+ (match-beginning 0)))
2225 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2227 ;; Perhaps we shouldn't hide to the end of the buffer
2228 ;; if there is no end to the signature?
2230 ;; Hide "- " PGP quotation markers.
2232 (narrow-to-region beg end)
2233 (goto-char (point-min))
2234 (while (re-search-forward "^- " nil t)
2236 (match-beginning 0) (match-end 0)))
2238 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2240 (defun article-hide-pem (&optional arg)
2241 "Toggle hiding of any PEM headers and signatures in the current article.
2242 If given a negative prefix, always show; if given a positive prefix,
2244 (interactive (gnus-article-hidden-arg))
2245 (unless (gnus-article-check-hidden-text 'pem arg)
2247 (let (buffer-read-only end)
2248 (goto-char (point-min))
2249 ;; Hide the horrendously ugly "header".
2250 (when (and (search-forward
2251 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2253 (setq end (1+ (match-beginning 0))))
2254 (gnus-add-wash-type 'pem)
2255 (gnus-article-hide-text-type
2257 (if (search-forward "\n\n" nil t)
2261 ;; Hide the trailer as well
2262 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2264 (gnus-article-hide-text-type
2265 (match-beginning 0) (match-end 0) 'pem)))))))
2267 (defun article-strip-banner ()
2268 "Strip the banner specified by the `banner' group parameter."
2272 (let ((inhibit-point-motion-hooks t)
2273 (banner (gnus-parameter-banner gnus-newsgroup-name))
2274 (gnus-signature-limit nil)
2275 buffer-read-only beg end)
2276 (when (and gnus-article-address-banner-alist
2279 (let ((from (save-restriction
2281 (article-narrow-to-head)
2282 (caar (mail-header-parse-addresses
2283 (mail-fetch-field "from"))))))
2285 (dolist (pair gnus-article-address-banner-alist)
2286 (when (string-match (car pair) from)
2287 (throw 'found (cdr pair))))))))
2291 ((eq banner 'signature)
2292 (when (gnus-article-narrow-to-signature)
2295 (delete-region (point) (point-max))))
2297 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2298 (while (re-search-forward banner nil t)
2299 (delete-region (match-beginning 0) (match-end 0)))))
2301 (while (re-search-forward banner nil t)
2302 (delete-region (match-beginning 0) (match-end 0))))))))))
2304 (defun article-babel ()
2305 "Translate article using an online translation service."
2309 (set-buffer gnus-article-buffer)
2310 (when (article-goto-body)
2311 (let* ((buffer-read-only nil)
2314 (orig (buffer-substring start end))
2315 (trans (babel-as-string orig)))
2317 (narrow-to-region start end)
2318 (delete-region start end)
2321 (defun article-hide-signature (&optional arg)
2322 "Hide the signature in the current article.
2323 If given a negative prefix, always show; if given a positive prefix,
2325 (interactive (gnus-article-hidden-arg))
2326 (unless (gnus-article-check-hidden-text 'signature arg)
2329 (let ((buffer-read-only nil))
2330 (when (gnus-article-narrow-to-signature)
2331 (gnus-article-hide-text-type
2332 (point-min) (point-max) 'signature))))))
2333 (gnus-set-mode-line 'article))
2335 (defun article-strip-headers-in-body ()
2336 "Strip offensive headers from bodies."
2340 (let ((case-fold-search t))
2341 (when (looking-at "x-no-archive:")
2342 (gnus-delete-line)))))
2344 (defun article-strip-leading-blank-lines ()
2345 "Remove all blank lines from the beginning of the article."
2348 (let ((inhibit-point-motion-hooks t)
2350 (when (article-goto-body)
2351 (while (and (not (eobp))
2352 (looking-at "[ \t]*$"))
2353 (gnus-delete-line))))))
2355 (defun article-narrow-to-head ()
2356 "Narrow the buffer to the head of the message.
2357 Point is left at the beginning of the narrowed-to region."
2359 (goto-char (point-min))
2360 (if (search-forward "\n\n" nil 1)
2363 (goto-char (point-min)))
2365 (defun article-goto-body ()
2366 "Place point at the start of the body."
2367 (goto-char (point-min))
2369 ;; This variable is only bound when dealing with separate
2371 (article-goto-body-goes-to-point-min-p
2373 ((search-forward "\n\n" nil t)
2376 (goto-char (point-max))
2379 (defun article-strip-multiple-blank-lines ()
2380 "Replace consecutive blank lines with one empty line."
2383 (let ((inhibit-point-motion-hooks t)
2385 ;; First make all blank lines empty.
2387 (while (re-search-forward "^[ \t]+$" nil t)
2388 (unless (gnus-annotation-in-region-p
2389 (match-beginning 0) (match-end 0))
2390 (replace-match "" nil t)))
2391 ;; Then replace multiple empty lines with a single empty line.
2393 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2394 (unless (gnus-annotation-in-region-p
2395 (match-beginning 0) (match-end 0))
2396 (delete-region (match-beginning 1) (match-end 1)))))))
2398 (defun article-strip-leading-space ()
2399 "Remove all white space from the beginning of the lines in the article."
2402 (let ((inhibit-point-motion-hooks t)
2405 (while (re-search-forward "^[ \t]+" nil t)
2406 (replace-match "" t t)))))
2408 (defun article-strip-trailing-space ()
2409 "Remove all white space from the end of the lines in the article."
2412 (let ((inhibit-point-motion-hooks t)
2415 (while (re-search-forward "[ \t]+$" nil t)
2416 (replace-match "" t t)))))
2418 (defun article-strip-blank-lines ()
2419 "Strip leading, trailing and multiple blank lines."
2421 (article-strip-leading-blank-lines)
2422 (article-remove-trailing-blank-lines)
2423 (article-strip-multiple-blank-lines))
2425 (defun article-strip-all-blank-lines ()
2426 "Strip all blank lines."
2429 (let ((inhibit-point-motion-hooks t)
2432 (while (re-search-forward "^[ \t]*\n" nil t)
2433 (replace-match "" t t)))))
2435 (defun gnus-article-narrow-to-signature ()
2436 "Narrow to the signature; return t if a signature is found, else nil."
2437 (let ((inhibit-point-motion-hooks t))
2438 (when (gnus-article-search-signature)
2440 ;; Check whether we have some limits to what we consider
2441 ;; to be a signature.
2442 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2443 (list gnus-signature-limit)))
2445 (while (setq limit (pop limits))
2446 (if (or (and (integerp limit)
2447 (< (- (point-max) (point)) limit))
2449 (< (count-lines (point) (point-max)) limit))
2450 (and (gnus-functionp limit)
2452 (and (stringp limit)
2453 (not (re-search-forward limit nil t))))
2454 () ; This limit did not succeed.
2458 (narrow-to-region (point) (point-max))
2461 (defun gnus-article-search-signature ()
2462 "Search the current buffer for the signature separator.
2463 Put point at the beginning of the signature separator."
2464 (let ((cur (point)))
2465 (goto-char (point-max))
2466 (if (if (stringp gnus-signature-separator)
2467 (re-search-backward gnus-signature-separator nil t)
2468 (let ((seps gnus-signature-separator))
2470 (not (re-search-backward (car seps) nil t)))
2477 (defun gnus-article-hidden-arg ()
2478 "Return the current prefix arg as a number, or 0 if no prefix."
2479 (list (if current-prefix-arg
2480 (prefix-numeric-value current-prefix-arg)
2483 (defun gnus-article-check-hidden-text (type arg)
2484 "Return nil if hiding is necessary.
2485 Arg can be nil or a number. nil and positive means hide, negative
2486 means show, 0 means toggle."
2489 (let ((hide (gnus-article-hidden-text-p type)))
2495 (gnus-article-show-hidden-text type)
2498 (if (eq hide 'hidden)
2500 (gnus-article-show-hidden-text type)
2504 (defun gnus-article-hidden-text-p (type)
2505 "Say whether the current buffer contains hidden text of type TYPE."
2506 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2508 (not (get-text-property pos 'invisible))
2509 (not (get-text-property pos 'dummy-invisible)))
2511 (text-property-any (1+ pos) (point-max) 'article-type type)))
2516 (defun gnus-article-show-hidden-text (type &optional dummy)
2517 "Show all hidden text of type TYPE.
2518 Originally it is hide instead of DUMMY."
2519 (let ((buffer-read-only nil)
2520 (inhibit-point-motion-hooks t))
2521 (gnus-remove-text-properties-when
2523 (point-min) (point-max)
2524 (cons 'article-type (cons type
2525 gnus-hidden-properties)))
2526 (gnus-delete-wash-type type)))
2528 (defconst article-time-units
2529 `((year . ,(* 365.25 24 60 60))
2530 (week . ,(* 7 24 60 60))
2531 (day . ,(* 24 60 60))
2535 "Mapping from time units to seconds.")
2537 (defun article-date-ut (&optional type highlight header)
2538 "Convert DATE date to universal time in the current article.
2539 If TYPE is `local', convert to local time; if it is `lapsed', output
2540 how much time has lapsed since DATE. For `lapsed', the value of
2541 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2542 should replace the \"Date:\" one, or should be added below it."
2543 (interactive (list 'ut t))
2544 (let* ((header (or header
2545 (message-fetch-field "date")
2547 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2550 ((not gnus-article-date-lapsed-new-header)
2556 (date (if (vectorp header) (mail-header-date header)
2558 (inhibit-point-motion-hooks t)
2563 (article-narrow-to-head)
2564 (when (re-search-forward tdate-regexp nil t)
2565 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2566 date (or (get-text-property (gnus-point-at-bol)
2569 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2571 (when (and date (not (string= date "")))
2572 (goto-char (point-min))
2573 (let ((buffer-read-only nil))
2574 ;; Delete any old Date headers.
2575 (while (re-search-forward date-regexp nil t)
2577 (delete-region (progn (beginning-of-line) (point))
2578 (progn (forward-line 1) (point)))
2579 (delete-region (progn (beginning-of-line) (point))
2580 (progn (end-of-line) (point)))
2581 (setq pos (point))))
2582 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2584 (if pos (goto-char pos))
2585 (insert (article-make-date-line date (or type 'ut)))
2591 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2592 (put-text-property (match-beginning 1) (1+ (match-end 1))
2593 'original-date date)
2594 (put-text-property (match-beginning 1) (1+ (match-end 1))
2596 (put-text-property (match-beginning 2) (match-end 2)
2599 (defun article-make-date-line (date type)
2600 "Return a DATE line of TYPE."
2601 (unless (memq type '(local ut original user iso8601 lapsed english))
2602 (error "Unknown conversion type: %s" type))
2604 (let ((time (date-to-time date)))
2606 ;; Convert to the local timezone.
2608 (let ((tz (car (current-time-zone time))))
2609 (format "Date: %s %s%02d%02d" (current-time-string time)
2610 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2611 (/ (% (abs tz) 3600) 60))))
2612 ;; Convert to Universal Time.
2615 (current-time-string
2616 (let* ((e (parse-time-string date))
2617 (tm (apply 'encode-time e))
2619 (ls (- (cadr tm) (car (current-time-zone time)))))
2620 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2621 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2624 ;; Get the original date from the article.
2625 ((eq type 'original)
2626 (concat "Date: " (if (string-match "\n+$" date)
2627 (substring date 0 (match-beginning 0))
2629 ;; Let the user define the format.
2631 (let ((format (or (condition-case nil
2632 (with-current-buffer gnus-summary-buffer
2633 gnus-article-time-format)
2635 gnus-article-time-format)))
2636 (if (gnus-functionp format)
2637 (funcall format time)
2638 (concat "Date: " (format-time-string format time)))))
2641 (let ((tz (car (current-time-zone time))))
2644 (format-time-string "%Y%m%dT%H%M%S" time)
2645 (format "%s%02d%02d"
2646 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2647 (/ (% (abs tz) 3600) 60)))))
2648 ;; Do an X-Sent lapsed format.
2650 ;; If the date is seriously mangled, the timezone functions are
2651 ;; liable to bug out, so we ignore all errors.
2652 (let* ((now (current-time))
2653 (real-time (subtract-time now time))
2654 (real-sec (and real-time
2655 (+ (* (float (car real-time)) 65536)
2657 (sec (and real-time (abs real-sec)))
2667 ;; This is a bit convoluted, but basically we go
2668 ;; through the time units for years, weeks, etc,
2669 ;; and divide things to see whether that results
2670 ;; in positive answers.
2673 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2674 ;; The (remaining) seconds are too few to
2675 ;; be divided into this time unit.
2677 ;; It's big enough, so we output it.
2678 (setq sec (- sec (* num (cdr unit))))
2680 (concat (if prev ", " "") (int-to-string
2682 " " (symbol-name (car unit))
2683 (if (> num 1) "s" ""))
2685 article-time-units "")
2686 ;; If dates are odd, then it might appear like the
2687 ;; article was sent in the future.
2690 " in the future"))))))
2691 ;; Display the date in proper English
2693 (let ((dtime (decode-time time)))
2696 (number-to-string (nth 3 dtime))
2697 (let ((digit (% (nth 3 dtime) 10)))
2699 ((memq (nth 3 dtime) '(11 12 13)) "th")
2705 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2707 (number-to-string (nth 5 dtime))
2709 (format "%02d" (nth 2 dtime))
2711 (format "%02d" (nth 1 dtime)))))))
2713 (format "Date: %s (from Gnus)" date))))
2715 (defun article-date-local (&optional highlight)
2716 "Convert the current article date to the local timezone."
2717 (interactive (list t))
2718 (article-date-ut 'local highlight))
2720 (defun article-date-english (&optional highlight)
2721 "Convert the current article date to something that is proper English."
2722 (interactive (list t))
2723 (article-date-ut 'english highlight))
2725 (defun article-date-original (&optional highlight)
2726 "Convert the current article date to what it was originally.
2727 This is only useful if you have used some other date conversion
2728 function and want to see what the date was before converting."
2729 (interactive (list t))
2730 (article-date-ut 'original highlight))
2732 (defun article-date-lapsed (&optional highlight)
2733 "Convert the current article date to time lapsed since it was sent."
2734 (interactive (list t))
2735 (article-date-ut 'lapsed highlight))
2737 (defun article-update-date-lapsed ()
2738 "Function to be run from a timer to update the lapsed time line."
2739 (let (deactivate-mark)
2744 (set-buffer (window-buffer w))
2745 (when (eq major-mode 'gnus-article-mode)
2746 (goto-char (point-min))
2747 (when (re-search-forward "^X-Sent:" nil t)
2748 (article-date-lapsed t))))
2751 (defun gnus-start-date-timer (&optional n)
2752 "Start a timer to update the X-Sent header in the article buffers.
2753 The numerical prefix says how frequently (in seconds) the function
2758 (gnus-stop-date-timer)
2759 (setq article-lapsed-timer
2760 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2762 (defun gnus-stop-date-timer ()
2763 "Stop the X-Sent timer."
2765 (when article-lapsed-timer
2766 (nnheader-cancel-timer article-lapsed-timer)
2767 (setq article-lapsed-timer nil)))
2769 (defun article-date-user (&optional highlight)
2770 "Convert the current article date to the user-defined format.
2771 This format is defined by the `gnus-article-time-format' variable."
2772 (interactive (list t))
2773 (article-date-ut 'user highlight))
2775 (defun article-date-iso8601 (&optional highlight)
2776 "Convert the current article date to ISO8601."
2777 (interactive (list t))
2778 (article-date-ut 'iso8601 highlight))
2780 ;; (defun article-show-all ()
2781 ;; "Show all hidden text in the article buffer."
2784 ;; (let ((buffer-read-only nil))
2785 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2787 (defun article-remove-leading-whitespace ()
2788 "Remove excessive whitespace from all headers."
2792 (let ((buffer-read-only nil))
2793 (article-narrow-to-head)
2794 (goto-char (point-min))
2795 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2796 (delete-region (match-beginning 1) (match-end 1)))))))
2798 (defun article-emphasize (&optional arg)
2799 "Emphasize text according to `gnus-emphasis-alist'."
2800 (interactive (gnus-article-hidden-arg))
2801 (unless (gnus-article-check-hidden-text 'emphasis arg)
2805 (with-current-buffer gnus-summary-buffer
2806 gnus-article-emphasis-alist)
2808 gnus-emphasis-alist))
2809 (buffer-read-only nil)
2810 (props (append '(article-type emphasis)
2811 gnus-hidden-properties))
2812 regexp elem beg invisible visible face)
2815 (while (setq elem (pop alist))
2817 (setq regexp (car elem)
2818 invisible (nth 1 elem)
2819 visible (nth 2 elem)
2821 (while (re-search-forward regexp nil t)
2822 (when (and (match-beginning visible) (match-beginning invisible))
2823 (gnus-article-hide-text
2824 (match-beginning invisible) (match-end invisible) props)
2825 (gnus-article-unhide-text-type
2826 (match-beginning visible) (match-end visible) 'emphasis)
2827 (gnus-put-overlay-excluding-newlines
2828 (match-beginning visible) (match-end visible) 'face face)
2829 (gnus-add-wash-type 'emphasis)
2830 (goto-char (match-end invisible)))))))))
2832 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2833 "Setup newsgroup emphasis alist."
2834 (unless gnus-article-emphasis-alist
2835 (let ((name (and gnus-newsgroup-name
2836 (gnus-group-real-name gnus-newsgroup-name))))
2837 (make-local-variable 'gnus-article-emphasis-alist)
2838 (setq gnus-article-emphasis-alist
2840 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2841 (while (setq elem (pop alist))
2842 (when (and name (string-match (car elem) name))
2844 highlight (copy-sequence (cdr elem)))))
2846 (copy-sequence highlight-words)
2847 (if gnus-newsgroup-name
2848 (copy-sequence (gnus-group-find-parameter
2849 gnus-newsgroup-name 'highlight-words t)))
2850 gnus-emphasis-alist)))))
2853 (defvar gnus-summary-article-menu)
2854 (defvar gnus-summary-post-menu))
2856 ;;; Saving functions.
2858 (defun gnus-article-save (save-buffer file &optional num)
2859 "Save the currently selected article."
2860 (unless gnus-save-all-headers
2861 ;; Remove headers according to `gnus-saved-headers'.
2862 (let ((gnus-visible-headers
2863 (or gnus-saved-headers gnus-visible-headers))
2864 (gnus-article-buffer save-buffer))
2866 (set-buffer save-buffer)
2867 (article-hide-headers 1 t))))
2868 (save-window-excursion
2869 (if (not gnus-default-article-saver)
2870 (error "No default saver is defined")
2871 ;; !!! Magic! The saving functions all save
2872 ;; `gnus-save-article-buffer' (or so they think), but we
2873 ;; bind that variable to our save-buffer.
2874 (set-buffer gnus-article-buffer)
2875 (let* ((gnus-save-article-buffer save-buffer)
2878 ((not gnus-prompt-before-saving) 'default)
2879 ((eq gnus-prompt-before-saving 'always) nil)
2881 (gnus-number-of-articles-to-be-saved
2882 (when (eq gnus-prompt-before-saving t)
2884 (set-buffer gnus-article-current-summary)
2885 (funcall gnus-default-article-saver filename)))))
2887 (defun gnus-read-save-file-name (prompt &optional filename
2888 function group headers variable)
2890 (funcall function group headers (symbol-value variable)))
2895 ((eq filename 'default)
2901 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2904 (if (and gnus-number-of-articles-to-be-saved
2905 (> gnus-number-of-articles-to-be-saved 1))
2906 (format "these %d articles"
2907 gnus-number-of-articles-to-be-saved)
2910 ;; Let the split methods have their say.
2912 ;; No split name was found.
2915 (concat prompt " (default "
2916 (file-name-nondirectory default-name) ") ")
2917 (file-name-directory default-name)
2919 ;; A single group name is returned.
2920 ((stringp split-name)
2922 (funcall function split-name headers
2923 (symbol-value variable)))
2925 (concat prompt " (default "
2926 (file-name-nondirectory default-name) ") ")
2927 (file-name-directory default-name)
2929 ;; A single split name was found
2930 ((= 1 (length split-name))
2931 (let* ((name (expand-file-name
2933 gnus-article-save-directory))
2934 (dir (cond ((file-directory-p name)
2935 (file-name-as-directory name))
2936 ((file-exists-p name) name)
2937 (t gnus-article-save-directory))))
2939 (concat prompt " (default " name ") ")
2941 ;; A list of splits was found.
2943 (setq split-name (nreverse split-name))
2945 (let ((file-name-history
2946 (nconc split-name file-name-history)))
2950 (concat prompt " (`M-p' for defaults) ")
2951 gnus-article-save-directory
2953 gnus-article-save-directory)))
2954 (car (push result file-name-history)))))))
2955 ;; Create the directory.
2956 (gnus-make-directory (file-name-directory file))
2957 ;; If we have read a directory, we append the default file name.
2958 (when (file-directory-p file)
2959 (setq file (expand-file-name (file-name-nondirectory
2961 (file-name-as-directory file))))
2962 ;; Possibly translate some characters.
2963 (nnheader-translate-file-chars file))))))
2964 (gnus-make-directory (file-name-directory result))
2965 (set variable result)))
2967 (defun gnus-article-archive-name (group)
2968 "Return the first instance of an \"Archive-name\" in the current buffer."
2969 (let ((case-fold-search t))
2970 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2971 (nnheader-concat gnus-article-save-directory
2972 (match-string 1)))))
2974 (defun gnus-article-nndoc-name (group)
2975 "If GROUP is an nndoc group, return the name of the parent group."
2976 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2977 (gnus-group-get-parameter group 'save-article-group)))
2979 (defun gnus-summary-save-in-rmail (&optional filename)
2980 "Append this article to Rmail 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 rmail file:" filename
2985 gnus-rmail-save-name gnus-newsgroup-name
2986 gnus-current-headers 'gnus-newsgroup-last-rmail))
2987 (gnus-eval-in-buffer-window gnus-save-article-buffer
2991 (gnus-output-to-rmail filename))))
2994 (defun gnus-summary-save-in-mail (&optional filename)
2995 "Append this article to Unix mail file.
2996 Optional argument FILENAME specifies file name.
2997 Directory to save to is default to `gnus-article-save-directory'."
2998 (setq filename (gnus-read-save-file-name
2999 "Save %s in Unix mail file:" filename
3000 gnus-mail-save-name gnus-newsgroup-name
3001 gnus-current-headers 'gnus-newsgroup-last-mail))
3002 (gnus-eval-in-buffer-window gnus-save-article-buffer
3006 (if (and (file-readable-p filename)
3007 (mail-file-babyl-p filename))
3008 (rmail-output-to-rmail-file filename t)
3009 (gnus-output-to-mail filename)))))
3012 (defun gnus-summary-save-in-file (&optional filename overwrite)
3013 "Append this article to file.
3014 Optional argument FILENAME specifies file name.
3015 Directory to save to is default to `gnus-article-save-directory'."
3016 (setq filename (gnus-read-save-file-name
3017 "Save %s in file:" filename
3018 gnus-file-save-name gnus-newsgroup-name
3019 gnus-current-headers 'gnus-newsgroup-last-file))
3020 (gnus-eval-in-buffer-window gnus-save-article-buffer
3024 (when (and overwrite
3025 (file-exists-p filename))
3026 (delete-file filename))
3027 (gnus-output-to-file filename))))
3030 (defun gnus-summary-write-to-file (&optional filename)
3031 "Write this article to a file, overwriting it if the file exists.
3032 Optional argument FILENAME specifies file name.
3033 The directory to save in defaults to `gnus-article-save-directory'."
3034 (gnus-summary-save-in-file nil t))
3036 (defun gnus-summary-save-body-in-file (&optional filename)
3037 "Append this article body to a file.
3038 Optional argument FILENAME specifies file name.
3039 The directory to save in defaults to `gnus-article-save-directory'."
3040 (setq filename (gnus-read-save-file-name
3041 "Save %s body in file:" filename
3042 gnus-file-save-name gnus-newsgroup-name
3043 gnus-current-headers 'gnus-newsgroup-last-file))
3044 (gnus-eval-in-buffer-window gnus-save-article-buffer
3048 (when (article-goto-body)
3049 (narrow-to-region (point) (point-max)))
3050 (gnus-output-to-file filename))))
3053 (defun gnus-summary-save-in-pipe (&optional command)
3054 "Pipe this article to subprocess."
3056 (cond ((and (eq command 'default)
3057 gnus-last-shell-command)
3058 gnus-last-shell-command)
3063 "Shell command on %s: "
3064 (if (and gnus-number-of-articles-to-be-saved
3065 (> gnus-number-of-articles-to-be-saved 1))
3066 (format "these %d articles"
3067 gnus-number-of-articles-to-be-saved)
3069 gnus-last-shell-command))))
3070 (when (string-equal command "")
3071 (if gnus-last-shell-command
3072 (setq command gnus-last-shell-command)
3073 (error "A command is required")))
3074 (gnus-eval-in-buffer-window gnus-article-buffer
3077 (shell-command-on-region (point-min) (point-max) command nil)))
3078 (setq gnus-last-shell-command command))
3080 (defun gnus-summary-pipe-to-muttprint (&optional command)
3081 "Pipe this article to muttprint."
3082 (setq command (read-string
3083 "Print using command: " gnus-summary-muttprint-program
3084 nil gnus-summary-muttprint-program))
3085 (gnus-summary-save-in-pipe command))
3087 ;;; Article file names when saving.
3089 (defun gnus-capitalize-newsgroup (newsgroup)
3090 "Capitalize NEWSGROUP name."
3091 (when (not (zerop (length newsgroup)))
3092 (concat (char-to-string (upcase (aref newsgroup 0)))
3093 (substring newsgroup 1))))
3095 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3096 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3097 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3098 Otherwise, it is like ~/News/news/group/num."
3101 (concat (if (gnus-use-long-file-name 'not-save)
3102 (gnus-capitalize-newsgroup newsgroup)
3103 (gnus-newsgroup-directory-form newsgroup))
3104 "/" (int-to-string (mail-header-number headers)))
3105 gnus-article-save-directory)))
3107 (string-equal (file-name-directory default)
3108 (file-name-directory last-file))
3109 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3111 (or last-file default))))
3113 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3114 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3115 If variable `gnus-use-long-file-name' is non-nil, it is
3116 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3119 (concat (if (gnus-use-long-file-name 'not-save)
3121 (gnus-newsgroup-directory-form newsgroup))
3122 "/" (int-to-string (mail-header-number headers)))
3123 gnus-article-save-directory)))
3125 (string-equal (file-name-directory default)
3126 (file-name-directory last-file))
3127 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3129 (or last-file default))))
3131 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3132 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3133 If variable `gnus-use-long-file-name' is non-nil, it is
3134 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3137 (if (gnus-use-long-file-name 'not-save)
3140 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3142 gnus-article-save-directory)))
3144 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3145 "Generate file name from sender."
3146 (let ((from (mail-header-from headers)))
3148 (if (and from (string-match "\\([^ <]+\\)@" from))
3149 (match-string 1 from)
3151 gnus-article-save-directory)))
3153 (defun article-verify-x-pgp-sig ()
3156 (if (gnus-buffer-live-p gnus-original-article-buffer)
3157 (let ((sig (with-current-buffer gnus-original-article-buffer
3158 (gnus-fetch-field "X-PGP-Sig")))
3162 (mml2015-clear-verify-function))
3164 (insert-buffer gnus-original-article-buffer)
3165 (setq items (split-string sig))
3166 (message-narrow-to-head)
3167 (let ((inhibit-point-motion-hooks t)
3168 (case-fold-search t))
3169 ;; Don't verify multiple headers.
3170 (setq headers (mapconcat (lambda (header)
3172 (mail-fetch-field header) "\n"))
3173 (split-string (nth 1 items) ",") "")))
3174 (delete-region (point-min) (point-max))
3175 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3176 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3181 (if (looking-at "^-")
3184 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3185 (insert "Version: " (car items) "\n\n")
3186 (insert (mapconcat 'identity (cddr items) "\n"))
3187 (insert "\n-----END PGP SIGNATURE-----\n")
3188 (let ((mm-security-handle (list (format "multipart/signed"))))
3189 (mml2015-clean-buffer)
3190 (let ((coding-system-for-write (or gnus-newsgroup-charset
3192 (funcall (mml2015-clear-verify-function)))
3194 (or (mm-handle-multipart-ctl-parameter
3195 mm-security-handle 'gnus-details)
3196 (mm-handle-multipart-ctl-parameter
3197 mm-security-handle 'gnus-info)))))
3199 (let (buffer-read-only bface eface)
3201 (message-narrow-to-head)
3202 (goto-char (point-max))
3204 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3205 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3206 (message-remove-header "X-Gnus-PGP-Verify")
3207 (if (re-search-forward "^X-PGP-Sig:" nil t)
3209 (goto-char (point-max)))
3210 (narrow-to-region (point) (point))
3211 (insert "X-Gnus-PGP-Verify: " info "\n")
3212 (goto-char (point-min))
3215 (if (not (looking-at "^[ \t]"))
3219 (goto-char (point-min))
3220 (when (looking-at "\\([^:]+\\): *")
3221 (put-text-property (match-beginning 1) (1+ (match-end 1))
3223 (put-text-property (match-end 0) (point-max)
3224 'face eface)))))))))
3226 (defun article-verify-cancel-lock ()
3227 "Verify Cancel-Lock header."
3229 (if (gnus-buffer-live-p gnus-original-article-buffer)
3230 (canlock-verify gnus-original-article-buffer)))
3237 (setq afunc (car func)
3240 gfunc (intern (format "gnus-%s" func))))
3242 (when (fboundp afunc)
3243 `(lambda (&optional interactive &rest args)
3244 ,(documentation afunc t)
3245 (interactive (list t))
3247 (set-buffer gnus-article-buffer)
3249 (call-interactively ',afunc)
3250 (apply ',afunc args))))))))
3251 '(article-hide-headers
3252 article-verify-x-pgp-sig
3253 article-verify-cancel-lock
3254 article-hide-boring-headers
3255 article-treat-overstrike
3256 article-fill-long-lines
3257 article-capitalize-sentences
3259 article-remove-leading-whitespace
3260 article-display-x-face
3261 article-de-quoted-unreadable
3262 article-de-base64-unreadable
3265 article-unsplit-urls
3266 article-hide-list-identifiers
3268 article-strip-banner
3271 article-hide-signature
3272 article-strip-headers-in-body
3273 article-remove-trailing-blank-lines
3274 article-strip-leading-blank-lines
3275 article-strip-multiple-blank-lines
3276 article-strip-leading-space
3277 article-strip-trailing-space
3278 article-strip-blank-lines
3279 article-strip-all-blank-lines
3281 article-date-english
3282 article-date-iso8601
3283 article-date-original
3285 article-decode-mime-words
3286 article-decode-charset
3287 article-decode-encoded-words
3291 article-treat-dumbquotes
3292 article-normalize-headers
3293 ;; (article-show-all . gnus-article-show-all-headers)
3297 ;;; Gnus article mode
3300 (put 'gnus-article-mode 'mode-class 'special)
3302 (set-keymap-parent gnus-article-mode-map widget-keymap)
3304 (gnus-define-keys gnus-article-mode-map
3305 " " gnus-article-goto-next-page
3306 "\177" gnus-article-goto-prev-page
3307 [delete] gnus-article-goto-prev-page
3308 [backspace] gnus-article-goto-prev-page
3309 "\C-c^" gnus-article-refer-article
3310 "h" gnus-article-show-summary
3311 "s" gnus-article-show-summary
3312 "\C-c\C-m" gnus-article-mail
3313 "?" gnus-article-describe-briefly
3314 "e" gnus-summary-edit-article
3315 "<" beginning-of-buffer
3317 "\C-c\C-i" gnus-info-find-node
3319 "R" gnus-article-reply-with-original
3320 "F" gnus-article-followup-with-original
3321 "\C-hk" gnus-article-describe-key
3322 "\C-hc" gnus-article-describe-key-briefly
3324 "\C-d" gnus-article-read-summary-keys
3325 "\M-*" gnus-article-read-summary-keys
3326 "\M-#" gnus-article-read-summary-keys
3327 "\M-^" gnus-article-read-summary-keys
3328 "\M-g" gnus-article-read-summary-keys)
3330 (substitute-key-definition
3331 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3333 (defun gnus-article-make-menu-bar ()
3334 (unless (boundp 'gnus-article-commands-menu)
3335 (gnus-summary-make-menu-bar))
3336 (gnus-turn-off-edit-menu 'article)
3337 (unless (boundp 'gnus-article-article-menu)
3339 gnus-article-article-menu gnus-article-mode-map ""
3341 ["Scroll forwards" gnus-article-goto-next-page t]
3342 ["Scroll backwards" gnus-article-goto-prev-page t]
3343 ["Show summary" gnus-article-show-summary t]
3344 ["Fetch Message-ID at point" gnus-article-refer-article t]
3345 ["Mail to address at point" gnus-article-mail t]
3346 ["Send a bug report" gnus-bug t]))
3349 gnus-article-treatment-menu gnus-article-mode-map ""
3350 ;; Fixme: this should use :active (and maybe :visible).
3352 ["Hide headers" gnus-article-hide-headers t]
3353 ["Hide signature" gnus-article-hide-signature t]
3354 ["Hide citation" gnus-article-hide-citation t]
3355 ["Treat overstrike" gnus-article-treat-overstrike t]
3356 ["Remove carriage return" gnus-article-remove-cr t]
3357 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3358 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3359 ["Remove base64" gnus-article-de-base64-unreadable t]
3360 ["Treat html" gnus-article-wash-html t]
3361 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3362 ["Decode HZ" gnus-article-decode-HZ t]))
3364 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3366 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3368 (gnus-run-hooks 'gnus-article-menu-hook)))
3370 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3373 (defun gnus-article-mode ()
3374 "Major mode for displaying an article.
3376 All normal editing commands are switched off.
3378 The following commands are available in addition to all summary mode
3380 \\<gnus-article-mode-map>
3381 \\[gnus-article-next-page]\t Scroll the article one page forwards
3382 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3383 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3384 \\[gnus-article-show-summary]\t Display the summary buffer
3385 \\[gnus-article-mail]\t Send a reply to the address near point
3386 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3387 \\[gnus-info-find-node]\t Go to the Gnus info node"
3389 (gnus-simplify-mode-line)
3390 (setq mode-name "Article")
3391 (setq major-mode 'gnus-article-mode)
3392 (make-local-variable 'minor-mode-alist)
3393 (use-local-map gnus-article-mode-map)
3394 (when (gnus-visual-p 'article-menu 'menu)
3395 (gnus-article-make-menu-bar))
3396 (gnus-update-format-specifications nil 'article-mode)
3397 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3398 (make-local-variable 'gnus-page-broken)
3399 (make-local-variable 'gnus-button-marker-list)
3400 (make-local-variable 'gnus-article-current-summary)
3401 (make-local-variable 'gnus-article-mime-handles)
3402 (make-local-variable 'gnus-article-decoded-p)
3403 (make-local-variable 'gnus-article-mime-handle-alist)
3404 (make-local-variable 'gnus-article-wash-types)
3405 (make-local-variable 'gnus-article-image-alist)
3406 (make-local-variable 'gnus-article-charset)
3407 (make-local-variable 'gnus-article-ignored-charsets)
3408 (gnus-set-default-directory)
3409 (buffer-disable-undo)
3410 (setq buffer-read-only t)
3411 (set-syntax-table gnus-article-mode-syntax-table)
3412 (mm-enable-multibyte)
3413 (gnus-run-hooks 'gnus-article-mode-hook))
3415 (defun gnus-article-setup-buffer ()
3416 "Initialize the article buffer."
3417 (let* ((name (if gnus-single-article-buffer "*Article*"
3418 (concat "*Article " gnus-newsgroup-name "*")))
3420 (progn (string-match "\\*Article" name)
3421 (concat " *Original Article"
3422 (substring name (match-end 0))))))
3423 (setq gnus-article-buffer name)
3424 (setq gnus-original-article-buffer original)
3425 (setq gnus-article-mime-handle-alist nil)
3426 ;; This might be a variable local to the summary buffer.
3427 (unless gnus-single-article-buffer
3429 (set-buffer gnus-summary-buffer)
3430 (setq gnus-article-buffer name)
3431 (setq gnus-original-article-buffer original)
3432 (gnus-set-global-variables)))
3433 (gnus-article-setup-highlight-words)
3434 ;; Init original article buffer.
3436 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3437 (mm-enable-multibyte)
3438 (setq major-mode 'gnus-original-article-mode)
3439 (make-local-variable 'gnus-original-article))
3440 (if (get-buffer name)
3443 (when gnus-article-mime-handles
3444 (mm-destroy-parts gnus-article-mime-handles)
3445 (setq gnus-article-mime-handles nil))
3446 ;; Set it to nil in article-buffer!
3447 (setq gnus-article-mime-handle-alist nil)
3448 (buffer-disable-undo)
3449 (setq buffer-read-only t)
3450 (unless (eq major-mode 'gnus-article-mode)
3451 (gnus-article-mode))
3454 (set-buffer (gnus-get-buffer-create name))
3456 (make-local-variable 'gnus-summary-buffer)
3457 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3458 (current-buffer)))))
3460 ;; Set article window start at LINE, where LINE is the number of lines
3461 ;; from the head of the article.
3462 (defun gnus-article-set-window-start (&optional line)
3464 (gnus-get-buffer-window gnus-article-buffer t)
3466 (set-buffer gnus-article-buffer)
3467 (goto-char (point-min))
3470 (gnus-message 6 "Moved to bookmark")
3471 (search-forward "\n\n" nil t)
3475 (defun gnus-article-prepare (article &optional all-headers header)
3476 "Prepare ARTICLE in article mode buffer.
3477 ARTICLE should either be an article number or a Message-ID.
3478 If ARTICLE is an id, HEADER should be the article headers.
3479 If ALL-HEADERS is non-nil, no headers are hidden."
3481 ;; Make sure we start in a summary buffer.
3482 (unless (eq major-mode 'gnus-summary-mode)
3483 (set-buffer gnus-summary-buffer))
3484 (setq gnus-summary-buffer (current-buffer))
3485 (let* ((gnus-article (if header (mail-header-number header) article))
3486 (summary-buffer (current-buffer))
3487 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3488 (group gnus-newsgroup-name)
3491 (gnus-article-setup-buffer)
3492 (set-buffer gnus-article-buffer)
3493 ;; Deactivate active regions.
3494 (when (and (boundp 'transient-mark-mode)
3495 transient-mark-mode)
3496 (setq mark-active nil))
3497 (if (not (setq result (let ((buffer-read-only nil))
3498 (gnus-request-article-this-buffer
3500 ;; There is no such article.
3502 (when (and (numberp article)
3503 (not (memq article gnus-newsgroup-sparse)))
3504 (setq gnus-article-current
3505 (cons gnus-newsgroup-name article))
3506 (set-buffer gnus-summary-buffer)
3507 (setq gnus-current-article article)
3508 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3510 (gnus-summary-set-agent-mark article)
3511 (message "Message marked for downloading"))
3512 (gnus-summary-mark-article article gnus-canceled-mark)
3513 (unless (memq article gnus-newsgroup-sparse)
3514 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3515 (if (or (eq result 'pseudo)
3516 (eq result 'nneething))
3519 (set-buffer summary-buffer)
3520 (push article gnus-newsgroup-history)
3521 (setq gnus-last-article gnus-current-article
3522 gnus-current-article 0
3523 gnus-current-headers nil
3524 gnus-article-current nil)
3525 (if (eq result 'nneething)
3526 (gnus-configure-windows 'summary)
3527 (gnus-configure-windows 'article))
3528 (gnus-set-global-variables))
3529 (let ((gnus-article-mime-handle-alist-1
3530 gnus-article-mime-handle-alist))
3531 (gnus-set-mode-line 'article)))
3532 ;; The result from the `request' was an actual article -
3533 ;; or at least some text that is now displayed in the
3535 (when (and (numberp article)
3536 (not (eq article gnus-current-article)))
3537 ;; Seems like a new article has been selected.
3538 ;; `gnus-current-article' must be an article number.
3540 (set-buffer summary-buffer)
3541 (push article gnus-newsgroup-history)
3542 (setq gnus-last-article gnus-current-article
3543 gnus-current-article article
3544 gnus-current-headers
3545 (gnus-summary-article-header gnus-current-article)
3546 gnus-article-current
3547 (cons gnus-newsgroup-name gnus-current-article))
3548 (unless (vectorp gnus-current-headers)
3549 (setq gnus-current-headers nil))
3550 (gnus-summary-goto-subject gnus-current-article)
3551 (when (gnus-summary-show-thread)
3552 ;; If the summary buffer really was folded, the
3553 ;; previous goto may not actually have gone to
3554 ;; the right article, but the thread root instead.
3556 (gnus-summary-goto-subject gnus-current-article))
3557 (gnus-run-hooks 'gnus-mark-article-hook)
3558 (gnus-set-mode-line 'summary)
3559 (when (gnus-visual-p 'article-highlight 'highlight)
3560 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3561 ;; Set the global newsgroup variables here.
3562 (gnus-set-global-variables)
3563 (setq gnus-have-all-headers
3564 (or all-headers gnus-show-all-headers))))
3566 (gnus-configure-windows 'article))
3567 (when (or (numberp article)
3569 (gnus-article-prepare-display)
3571 (goto-char (point-min))
3572 (setq gnus-page-broken
3573 (when gnus-break-pages
3574 (gnus-narrow-to-page)
3576 (let ((gnus-article-mime-handle-alist-1
3577 gnus-article-mime-handle-alist))
3578 (gnus-set-mode-line 'article))
3582 (set-window-point (get-buffer-window (current-buffer)) (point))
3583 (gnus-configure-windows 'article)
3587 (defun gnus-article-prepare-display ()
3588 "Make the current buffer look like a nice article."
3589 ;; Hooks for getting information from the article.
3590 ;; This hook must be called before being narrowed.
3591 (let ((gnus-article-buffer (current-buffer))
3593 (unless (eq major-mode 'gnus-article-mode)
3594 (gnus-article-mode))
3595 (setq buffer-read-only nil
3596 gnus-article-wash-types nil
3597 gnus-article-image-alist nil)
3598 (gnus-run-hooks 'gnus-tmp-internal-hook)
3599 (when gnus-display-mime-function
3600 (funcall gnus-display-mime-function))
3601 (gnus-run-hooks 'gnus-article-prepare-hook)))
3604 ;;; Gnus MIME viewing functions
3607 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3608 "Format of the MIME buttons.
3610 Valid specifiers include:
3612 %T MIME type, along with additional info
3613 %n The `name' parameter
3614 %d The description, if any
3615 %l The length of the encoded part
3616 %p The part identifier number
3617 %e Dots if the part isn't displayed
3619 General format specifiers can also be used. See
3620 (gnus)Formatting Variables.")
3622 (defvar gnus-mime-button-line-format-alist
3623 '((?t gnus-tmp-type ?s)
3624 (?T gnus-tmp-type-long ?s)
3625 (?n gnus-tmp-name ?s)
3626 (?d gnus-tmp-description ?s)
3628 (?l gnus-tmp-length ?d)
3629 (?e gnus-tmp-dots ?s)))
3631 (defvar gnus-mime-button-commands
3632 '((gnus-article-press-button "\r" "Toggle Display")
3633 (gnus-mime-view-part "v" "View Interactively...")
3634 (gnus-mime-view-part-as-type "t" "View As Type...")
3635 (gnus-mime-view-part-as-charset "C" "View As charset...")
3636 (gnus-mime-save-part "o" "Save...")
3637 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3638 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3639 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3640 (gnus-mime-view-part-internally "E" "View Internally")
3641 (gnus-mime-view-part-externally "e" "View Externally")
3642 (gnus-mime-print-part "p" "Print")
3643 (gnus-mime-pipe-part "|" "Pipe To Command...")
3644 (gnus-mime-action-on-part "." "Take action on the part")))
3646 (defun gnus-article-mime-part-status ()
3647 (if gnus-article-mime-handle-alist-1
3648 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3650 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3653 (defvar gnus-mime-button-map
3654 (let ((map (make-sparse-keymap)))
3655 (unless (>= (string-to-number emacs-version) 21)
3656 ;; XEmacs doesn't care.
3657 (set-keymap-parent map gnus-article-mode-map))
3658 (define-key map gnus-mouse-2 'gnus-article-push-button)
3659 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3660 (dolist (c gnus-mime-button-commands)
3661 (define-key map (cadr c) (car c)))
3664 (defun gnus-mime-button-menu (event)
3665 "Construct a context-sensitive menu of MIME commands."
3667 (save-window-excursion
3668 (let ((pos (event-start event)))
3669 (select-window (posn-window pos))
3670 (goto-char (posn-point pos))
3671 (gnus-article-check-buffer)
3672 (let ((response (x-popup-menu
3674 ("" ,@(mapcar (lambda (c)
3675 (cons (caddr c) (car c)))
3676 gnus-mime-button-commands))))))
3678 (call-interactively response))))))
3680 (defun gnus-mime-view-all-parts (&optional handles)
3681 "View all the MIME parts."
3683 (save-current-buffer
3684 (set-buffer gnus-article-buffer)
3685 (let ((handles (or handles gnus-article-mime-handles))
3686 (mail-parse-charset gnus-newsgroup-charset)
3687 (mail-parse-ignored-charsets
3688 (with-current-buffer gnus-summary-buffer
3689 gnus-newsgroup-ignored-charsets)))
3691 (mm-remove-parts handles)
3692 (goto-char (point-min))
3693 (or (search-forward "\n\n") (goto-char (point-max)))
3694 (let (buffer-read-only)
3695 (delete-region (point) (point-max))
3696 (mm-display-parts handles))))))
3698 (defun gnus-mime-save-part-and-strip ()
3699 "Save the MIME part under point then replace it with an external body."
3701 (gnus-article-check-buffer)
3702 (let* ((data (get-text-property (point) 'gnus-data))
3704 (handles gnus-article-mime-handles))
3705 (if (mm-multiple-handles gnus-article-mime-handles)
3706 (error "This function is not implemented"))
3707 (setq file (and data (mm-save-part data)))
3709 (with-current-buffer (mm-handle-buffer data)
3711 (insert "Content-Type: " (mm-handle-media-type data))
3712 (mml-insert-parameter-string (cdr (mm-handle-type data))
3715 (insert "Content-ID: " (message-make-message-id) "\n")
3716 (insert "Content-Transfer-Encoding: binary\n")
3719 (cdr (mm-make-handle nil
3720 `("message/external-body"
3721 (access-type . "LOCAL-FILE")
3723 (set-buffer gnus-summary-buffer)
3724 (gnus-article-edit-article
3727 (let ((mail-parse-charset (or gnus-article-charset
3728 ',gnus-newsgroup-charset))
3729 (mail-parse-ignored-charsets
3730 (or gnus-article-ignored-charsets
3731 ',gnus-newsgroup-ignored-charsets))
3732 (mbl mml-buffer-list))
3733 (setq mml-buffer-list nil)
3734 (insert-buffer gnus-original-article-buffer)
3735 (mime-to-mml ',handles)
3736 (setq gnus-article-mime-handles nil)
3737 (let ((mbl1 mml-buffer-list))
3738 (setq mml-buffer-list mbl)
3739 (set (make-local-variable 'mml-buffer-list) mbl1))
3740 ;; LOCAL argument of add-hook differs between GNU Emacs
3741 ;; and XEmacs. make-local-hook makes sure they are local.
3742 (make-local-hook 'kill-buffer-hook)
3743 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3744 `(lambda (no-highlight)
3745 (let ((mail-parse-charset (or gnus-article-charset
3746 ',gnus-newsgroup-charset))
3747 (message-options message-options)
3748 (message-options-set-recipient)
3749 (mail-parse-ignored-charsets
3750 (or gnus-article-ignored-charsets
3751 ',gnus-newsgroup-ignored-charsets)))
3753 (mml-destroy-buffers)
3754 (remove-hook 'kill-buffer-hook
3755 'mml-destroy-buffers t)
3756 (kill-local-variable 'mml-buffer-list))
3757 (gnus-summary-edit-article-done
3758 ,(or (mail-header-references gnus-current-headers) "")
3759 ,(gnus-group-read-only-p)
3760 ,gnus-summary-buffer no-highlight))))))
3762 (defun gnus-mime-save-part ()
3763 "Save the MIME part under point."
3765 (gnus-article-check-buffer)
3766 (let ((data (get-text-property (point) 'gnus-data)))
3768 (mm-save-part data))))
3770 (defun gnus-mime-pipe-part ()
3771 "Pipe the MIME part under point to a process."
3773 (gnus-article-check-buffer)
3774 (let ((data (get-text-property (point) 'gnus-data)))
3776 (mm-pipe-part data))))
3778 (defun gnus-mime-view-part ()
3779 "Interactively choose a viewing method for the MIME part under point."
3781 (gnus-article-check-buffer)
3782 (let ((data (get-text-property (point) 'gnus-data)))
3784 (setq gnus-article-mime-handles
3786 gnus-article-mime-handles (setq data (copy-sequence data))))
3787 (mm-interactively-view-part data))))
3789 (defun gnus-mime-view-part-as-type-internal ()
3790 (gnus-article-check-buffer)
3791 (let* ((name (mail-content-type-get
3792 (mm-handle-type (get-text-property (point) 'gnus-data))
3794 (def-type (and name (mm-default-file-encoding name))))
3795 (and def-type (cons def-type 0))))
3797 (defun gnus-mime-view-part-as-type (&optional mime-type)
3798 "Choose a MIME media type, and view the part as such."
3801 (setq mime-type (completing-read
3802 "View as MIME type: "
3803 (mapcar #'list (mailcap-mime-types))
3805 (gnus-mime-view-part-as-type-internal))))
3806 (gnus-article-check-buffer)
3807 (let ((handle (get-text-property (point) 'gnus-data)))
3810 (mm-make-handle (mm-handle-buffer handle)
3811 (cons mime-type (cdr (mm-handle-type handle)))
3812 (mm-handle-encoding handle)
3813 (mm-handle-undisplayer handle)
3814 (mm-handle-disposition handle)
3815 (mm-handle-description handle)
3817 (mm-handle-id handle)))
3818 (setq gnus-article-mime-handles
3819 (mm-merge-handles gnus-article-mime-handles handle))
3820 (gnus-mm-display-part handle))))
3822 (defun gnus-mime-copy-part (&optional handle)
3823 "Put the MIME part under point into a new buffer."
3825 (gnus-article-check-buffer)
3826 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3827 (contents (and handle (mm-get-part handle)))
3829 (file-name-nondirectory
3831 (mail-content-type-get (mm-handle-type handle) 'name)
3832 (mail-content-type-get (mm-handle-type handle)
3835 (buffer (and base (generate-new-buffer base))))
3837 (switch-to-buffer buffer)
3839 ;; We do it this way to make `normal-mode' set the appropriate mode.
3842 (setq buffer-file-name (expand-file-name base))
3844 (setq buffer-file-name nil))
3845 (goto-char (point-min)))))
3847 (defun gnus-mime-print-part (&optional handle filename)
3848 "Print the MIME part under point."
3849 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3850 (gnus-article-check-buffer)
3851 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3852 (contents (and handle (mm-get-part handle)))
3853 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3854 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3859 (with-temp-file file
3861 (call-process shell-file-name nil
3862 (generate-new-buffer " *mm*")
3864 shell-command-switch
3866 printer file (mm-handle-type handle))))
3870 (gnus-print-buffer))
3871 (ps-despool filename)))))
3873 (defun gnus-mime-inline-part (&optional handle arg)
3874 "Insert the MIME part under point into the current buffer."
3875 (interactive (list nil current-prefix-arg))
3876 (gnus-article-check-buffer)
3877 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3882 (if (and (not arg) (mm-handle-undisplayer handle))
3883 (mm-remove-part handle)
3884 (setq contents (mm-get-part handle))
3887 (setq charset (or (mail-content-type-get
3888 (mm-handle-type handle) 'charset)
3889 gnus-newsgroup-charset)))
3891 (if (mm-handle-undisplayer handle)
3892 (mm-remove-part handle))
3895 gnus-summary-show-article-charset-alist))
3896 (mm-read-coding-system "Charset: ")))))
3898 (mm-insert-inline handle
3900 (setq charset (mm-charset-to-coding-system
3902 (not (eq charset 'ascii)))
3903 (mm-decode-coding-string contents charset)
3907 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3908 "Insert the MIME part under point into the current buffer using the
3910 (interactive (list nil current-prefix-arg))
3911 (gnus-article-check-buffer)
3912 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3917 (if (mm-handle-undisplayer handle)
3918 (mm-remove-part handle))
3919 (let ((gnus-newsgroup-charset
3921 gnus-summary-show-article-charset-alist))
3922 (mm-read-coding-system "Charset: ")))
3923 (gnus-newsgroup-ignored-charsets 'gnus-all))
3924 (gnus-article-press-button)))))
3926 (defun gnus-mime-view-part-externally (&optional handle)
3927 "View the MIME part under point with an external viewer."
3929 (gnus-article-check-buffer)
3930 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3931 (mm-user-display-methods nil)
3932 (mm-inlined-types nil)
3933 (mail-parse-charset gnus-newsgroup-charset)
3934 (mail-parse-ignored-charsets
3935 (save-excursion (set-buffer gnus-summary-buffer)
3936 gnus-newsgroup-ignored-charsets)))
3938 (if (mm-handle-undisplayer handle)
3939 (mm-remove-part handle)
3940 (mm-display-part handle)))))
3942 (defun gnus-mime-view-part-internally (&optional handle)
3943 "View the MIME part under point with an internal viewer.
3944 If no internal viewer is available, use an external viewer."
3946 (gnus-article-check-buffer)
3947 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3948 (mm-inlined-types '(".*"))
3949 (mm-inline-large-images t)
3950 (mail-parse-charset gnus-newsgroup-charset)
3951 (mail-parse-ignored-charsets
3952 (save-excursion (set-buffer gnus-summary-buffer)
3953 gnus-newsgroup-ignored-charsets)))
3955 (if (mm-handle-undisplayer handle)
3956 (mm-remove-part handle)
3957 (mm-display-part handle)))))
3959 (defun gnus-mime-action-on-part (&optional action)
3960 "Do something with the MIME attachment at \(point\)."
3962 (list (completing-read "Action: " gnus-mime-action-alist)))
3963 (gnus-article-check-buffer)
3964 (let ((action-pair (assoc action gnus-mime-action-alist)))
3966 (funcall (cdr action-pair)))))
3968 (defun gnus-article-part-wrapper (n function)
3969 (save-current-buffer
3970 (set-buffer gnus-article-buffer)
3971 (when (> n (length gnus-article-mime-handle-alist))
3972 (error "No such part"))
3973 (gnus-article-goto-part n)
3974 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3975 (funcall function handle))))
3977 (defun gnus-article-pipe-part (n)
3978 "Pipe MIME part N, which is the numerical prefix."
3980 (gnus-article-part-wrapper n 'mm-pipe-part))
3982 (defun gnus-article-save-part (n)
3983 "Save MIME part N, which is the numerical prefix."
3985 (gnus-article-part-wrapper n 'mm-save-part))
3987 (defun gnus-article-interactively-view-part (n)
3988 "View MIME part N interactively, which is the numerical prefix."
3990 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3992 (defun gnus-article-copy-part (n)
3993 "Copy MIME part N, which is the numerical prefix."
3995 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3997 (defun gnus-article-view-part-as-charset (n)
3998 "Copy MIME part N, which is the numerical prefix."
4000 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4002 (defun gnus-article-view-part-externally (n)
4003 "View MIME part N externally, which is the numerical prefix."
4005 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4007 (defun gnus-article-inline-part (n)
4008 "Inline MIME part N, which is the numerical prefix."
4010 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4012 (defun gnus-article-mime-match-handle-first (condition)
4014 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4015 (while (setq ihandle (pop alist))
4017 ((functionp condition)
4018 (funcall condition (cdr ihandle)))
4019 ((eq condition 'undisplayed)
4020 (not (or (mm-handle-undisplayer (cdr ihandle))
4021 (equal (mm-handle-media-type (cdr ihandle))
4022 "multipart/alternative"))))
4023 ((eq condition 'undisplayed-alternative)
4024 (not (mm-handle-undisplayer (cdr ihandle))))
4026 (gnus-article-goto-part (car ihandle))
4027 (or (not n) (< (car ihandle) n)))
4028 (setq n (car ihandle))))
4032 (defun gnus-article-view-part (&optional n)
4033 "View MIME part N, which is the numerical prefix."
4035 (save-current-buffer
4036 (set-buffer gnus-article-buffer)
4037 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4038 gnus-article-mime-match-handle-function)))
4039 (when (> n (length gnus-article-mime-handle-alist))
4040 (error "No such part"))
4041 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4042 (when (gnus-article-goto-part n)
4043 (if (equal (car handle) "multipart/alternative")
4044 (gnus-article-press-button)
4045 (when (eq (gnus-mm-display-part handle) 'internal)
4046 (gnus-set-window-start)))))))
4048 (defsubst gnus-article-mime-total-parts ()
4049 (if (bufferp (car gnus-article-mime-handles))
4051 (1- (length gnus-article-mime-handles))))
4053 (defun gnus-mm-display-part (handle)
4054 "Display HANDLE and fix MIME button."
4055 (let ((id (get-text-property (point) 'gnus-part))
4060 (let ((window (selected-window))
4061 (mail-parse-charset gnus-newsgroup-charset)
4062 (mail-parse-ignored-charsets
4063 (if (gnus-buffer-live-p gnus-summary-buffer)
4065 (set-buffer gnus-summary-buffer)
4066 gnus-newsgroup-ignored-charsets)
4070 (let ((win (gnus-get-buffer-window (current-buffer) t))
4073 (select-window win))
4076 (if (mm-handle-displayed-p handle)
4077 ;; This will remove the part.
4078 (mm-display-part handle)
4080 (narrow-to-region (point)
4081 (if (eobp) (point) (1+ (point))))
4082 (mm-display-part handle)
4083 ;; We narrow to the part itself and
4084 ;; then call the treatment functions.
4085 (goto-char (point-min))
4087 (narrow-to-region (point) (point-max))
4090 (gnus-article-mime-total-parts)
4091 (mm-handle-media-type handle)))))
4092 (if (window-live-p window)
4093 (select-window window)))))
4095 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4096 (gnus-insert-mime-button
4097 handle id (list (mm-handle-displayed-p handle)))
4098 (goto-char point))))
4100 (defun gnus-article-goto-part (n)
4101 "Go to MIME part N."
4102 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4104 (goto-char point))))
4106 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4107 (let ((gnus-tmp-name
4108 (or (mail-content-type-get (mm-handle-type handle) 'name)
4109 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4110 (mail-content-type-get (mm-handle-type handle) 'url)
4112 (gnus-tmp-type (mm-handle-media-type handle))
4113 (gnus-tmp-description
4114 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4117 (if (if displayed (car displayed)
4118 (mm-handle-displayed-p handle))
4120 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4122 gnus-tmp-type-long b e)
4123 (when (string-match ".*/" gnus-tmp-name)
4124 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4125 (setq gnus-tmp-type-long (concat gnus-tmp-type
4126 (and (not (equal gnus-tmp-name ""))
4127 (concat "; " gnus-tmp-name))))
4128 (unless (equal gnus-tmp-description "")
4129 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4134 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4135 `(,@(gnus-local-map-property gnus-mime-button-map)
4136 gnus-callback gnus-mm-display-part
4137 gnus-part ,gnus-tmp-id
4138 article-type annotation
4141 (widget-convert-button
4144 :action 'gnus-widget-press-button
4145 :button-keymap gnus-mime-button-map
4147 (lambda (widget/window &optional overlay pos)
4148 ;; Needed to properly clear the message due to a bug in
4149 ;; wid-edit (XEmacs only).
4150 (if (boundp 'help-echo-owns-message)
4151 (setq help-echo-owns-message t))
4153 "%S: %s the MIME part; %S: more options"
4154 (aref gnus-mouse-2 0)
4155 ;; XEmacs will get a single widget arg; Emacs 21 will get
4156 ;; window, overlay, position.
4157 (if (mm-handle-displayed-p
4159 (with-current-buffer (gnus-overlay-buffer overlay)
4160 (widget-get (widget-at (gnus-overlay-start overlay))
4162 (widget-get widget/window :mime-handle)))
4164 (aref gnus-down-mouse-3 0))))))
4166 (defun gnus-widget-press-button (elems el)
4167 (goto-char (widget-get elems :from))
4168 (gnus-article-press-button))
4170 (defvar gnus-displaying-mime nil)
4172 (defun gnus-display-mime (&optional ihandles)
4173 "Display the MIME parts."
4175 (save-selected-window
4176 (let ((window (get-buffer-window gnus-article-buffer))
4179 (select-window window)
4180 ;; We have to do this since selecting the window
4181 ;; may change the point. So we set the window point.
4182 (set-window-point window point)))
4183 (let* ((handles (or ihandles (mm-dissect-buffer
4184 nil gnus-article-loose-mime)
4186 buffer-read-only handle name type b e display)
4187 (when (and (not ihandles)
4188 (not gnus-displaying-mime))
4189 ;; Top-level call; we clean up.
4190 (when gnus-article-mime-handles
4191 (mm-destroy-parts gnus-article-mime-handles)
4192 (setq gnus-article-mime-handle-alist nil));; A trick.
4193 (setq gnus-article-mime-handles handles)
4194 ;; We allow users to glean info from the handles.
4195 (when gnus-article-mime-part-function
4196 (gnus-mime-part-function handles)))
4198 (or (not (stringp (car handles)))
4201 (when (and (not ihandles)
4202 (not gnus-displaying-mime))
4203 ;; Clean up for mime parts.
4205 (delete-region (point) (point-max)))
4206 (let ((gnus-displaying-mime t))
4207 (gnus-mime-display-part handles)))
4210 (narrow-to-region (point) (point-max))
4211 (gnus-treat-article nil 1 1)
4214 ;; Highlight the headers.
4218 (narrow-to-region (point-min) (point))
4219 (gnus-treat-article 'head))))))))
4221 (defvar gnus-mime-display-multipart-as-mixed nil)
4222 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4223 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4225 (defun gnus-mime-display-part (handle)
4228 ((not (stringp (car handle)))
4229 (gnus-mime-display-single handle))
4230 ;; User-defined multipart
4231 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4232 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4234 ;; multipart/alternative
4235 ((and (equal (car handle) "multipart/alternative")
4236 (not (or gnus-mime-display-multipart-as-mixed
4237 gnus-mime-display-multipart-alternative-as-mixed)))
4238 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4239 (push (cons id handle) gnus-article-mime-handle-alist)
4240 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4241 ;; multipart/related
4242 ((and (equal (car handle) "multipart/related")
4243 (not (or gnus-mime-display-multipart-as-mixed
4244 gnus-mime-display-multipart-related-as-mixed)))
4245 ;;;!!!We should find the start part, but we just default
4246 ;;;!!!to the first part.
4247 ;;(gnus-mime-display-part (cadr handle))
4248 ;;;!!! Most multipart/related is an HTML message plus images.
4249 ;;;!!! Unfortunately we are unable to let W3 display those
4250 ;;;!!! included images, so we just display it as a mixed multipart.
4251 ;;(gnus-mime-display-mixed (cdr handle))
4252 ;;;!!! No, w3 can display everything just fine.
4253 (gnus-mime-display-part (cadr handle)))
4254 ((equal (car handle) "multipart/signed")
4255 (gnus-add-wash-type 'signed)
4256 (gnus-mime-display-security handle))
4257 ((equal (car handle) "multipart/encrypted")
4258 (gnus-add-wash-type 'encrypted)
4259 (gnus-mime-display-security handle))
4260 ;; Other multiparts are handled like multipart/mixed.
4262 (gnus-mime-display-mixed (cdr handle)))))
4264 (defun gnus-mime-part-function (handles)
4265 (if (stringp (car handles))
4266 (mapcar 'gnus-mime-part-function (cdr handles))
4267 (funcall gnus-article-mime-part-function handles)))
4269 (defun gnus-mime-display-mixed (handles)
4270 (mapcar 'gnus-mime-display-part handles))
4272 (defun gnus-mime-display-single (handle)
4273 (let ((type (mm-handle-media-type handle))
4274 (ignored gnus-ignored-mime-types)
4281 (when (string-match (pop ignored) type)
4282 (throw 'ignored nil)))
4283 (if (and (setq not-attachment
4284 (and (not (mm-inline-override-p handle))
4285 (or (not (mm-handle-disposition handle))
4286 (equal (car (mm-handle-disposition handle))
4288 (mm-attachment-override-p handle))))
4289 (mm-automatic-display-p handle)
4291 (mm-inlinable-p handle)
4292 (mm-inlined-p handle))
4293 (mm-automatic-external-display-p type)))
4295 (when (equal (mm-handle-media-supertype handle) "text")
4297 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4299 (push (cons id handle) gnus-article-mime-handle-alist)
4300 (when (or (not display)
4301 (not (gnus-unbuttonized-mime-type-p type)))
4302 ;(gnus-article-insert-newline)
4303 (gnus-insert-mime-button
4304 handle id (list (or display (and not-attachment text))))
4305 (gnus-article-insert-newline)
4306 ;(gnus-article-insert-newline)
4307 ;; Remember modify the number of forward lines.
4315 (let ((mail-parse-charset gnus-newsgroup-charset)
4316 (mail-parse-ignored-charsets
4317 (save-excursion (condition-case ()
4318 (set-buffer gnus-summary-buffer)
4320 gnus-newsgroup-ignored-charsets)))
4321 (mm-display-part handle t))
4322 (goto-char (point-max)))
4323 ((and text not-attachment)
4327 (gnus-article-insert-newline)
4328 (mm-insert-inline handle (mm-get-part handle))
4329 (goto-char (point-max))))
4333 (narrow-to-region beg (point))
4336 (gnus-article-mime-total-parts)
4337 (mm-handle-media-type handle)))))))))
4339 (defun gnus-unbuttonized-mime-type-p (type)
4340 "Say whether TYPE is to be unbuttonized."
4341 (unless gnus-inhibit-mime-unbuttonizing
4343 (let ((types gnus-unbuttonized-mime-types))
4345 (when (string-match (pop types) type)
4346 (throw 'found t)))))
4348 (let ((types gnus-buttonized-mime-types))
4350 (when (string-match (pop types) type)
4351 (throw 'found t)))))))))
4353 (defun gnus-article-insert-newline ()
4354 "Insert a newline, but mark it as undeletable."
4355 (gnus-put-text-property
4356 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4358 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4359 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4362 handle buffer-read-only from props begend not-pref)
4363 (save-window-excursion
4366 (narrow-to-region (car ibegend)
4369 (goto-char (car ibegend))
4372 (delete-region (point-min) (point-max))
4373 (mm-remove-parts handles))
4374 (setq begend (list (point-marker)))
4376 (unless (setq not-pref (cadr (member preferred ihandles)))
4377 (setq not-pref (car ihandles)))
4380 (not (gnus-unbuttonized-mime-type-p
4381 "multipart/alternative")))
4382 (gnus-add-text-properties
4385 (insert (format "%d. " id))
4389 (unless ,(not ibegend)
4390 (setq gnus-article-mime-handle-alist
4391 ',gnus-article-mime-handle-alist))
4392 (gnus-mime-display-alternative
4393 ',ihandles ',not-pref ',begend ,id))
4394 ,@(gnus-local-map-property gnus-mime-button-map)
4395 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4396 face ,gnus-article-button-face
4399 (widget-convert-button 'link from (point)
4400 :action 'gnus-widget-press-button
4401 :button-keymap gnus-widget-button-keymap)
4403 (while (setq handle (pop handles))
4404 (gnus-add-text-properties
4407 (insert (format "(%c) %-18s"
4408 (if (equal handle preferred) ?* ? )
4409 (mm-handle-media-type handle)))
4413 (unless ,(not ibegend)
4414 (setq gnus-article-mime-handle-alist
4415 ',gnus-article-mime-handle-alist))
4416 (gnus-mime-display-alternative
4417 ',ihandles ',handle ',begend ,id))
4418 ,@(gnus-local-map-property gnus-mime-button-map)
4419 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4420 face ,gnus-article-button-face
4423 (widget-convert-button 'link from (point)
4424 :action 'gnus-widget-press-button
4425 :button-keymap gnus-widget-button-keymap)
4429 (if (stringp (car preferred))
4430 (gnus-display-mime preferred)
4431 (let ((mail-parse-charset gnus-newsgroup-charset)
4432 (mail-parse-ignored-charsets
4433 (save-excursion (set-buffer gnus-summary-buffer)
4434 gnus-newsgroup-ignored-charsets)))
4435 (mm-display-part preferred)
4439 (narrow-to-region (car begend) (point-max))
4441 nil (length gnus-article-mime-handle-alist)
4442 (gnus-article-mime-total-parts)
4443 (mm-handle-media-type handle))))))
4444 (goto-char (point-max))
4445 (setcdr begend (point-marker)))))
4447 (goto-char point))))
4449 (defconst gnus-article-wash-status-strings
4450 (let ((alist '((cite "c" "Possible hidden citation text"
4451 " " "All citation text visible")
4452 (headers "h" "Hidden headers"
4453 " " "All headers visible.")
4454 (pgp "p" "Encrypted or signed message status hidden"
4455 " " "No hidden encryption nor digital signature status")
4456 (signature "s" "Signature has been hidden"
4457 " " "Signature is visible")
4458 (overstrike "o" "Overstrike (^H) characters applied"
4459 " " "No overstrike characters applied")
4460 (emphasis "e" "/*_Emphasis_*/ characters applied"
4461 " " "No /*_emphasis_*/ characters applied")))
4463 (dolist (entry alist result)
4464 (let ((key (nth 0 entry))
4465 (on (copy-sequence (nth 1 entry)))
4466 (on-help (nth 2 entry))
4467 (off (copy-sequence (nth 3 entry)))
4468 (off-help (nth 4 entry)))
4469 (put-text-property 0 1 'help-echo on-help on)
4470 (put-text-property 0 1 'help-echo off-help off)
4471 (push (list key on off) result))))
4472 "Alist of strings describing wash status in the mode line.
4473 Each entry has the form (KEY ON OF), where the KEY is a symbol
4474 representing the particular washing function, ON is the string to use
4475 in the article mode line when the washing function is active, and OFF
4476 is the string to use when it is inactive.")
4478 (defun gnus-article-wash-status-entry (key value)
4479 (let ((entry (assoc key gnus-article-wash-status-strings)))
4480 (if value (nth 1 entry) (nth 2 entry))))
4482 (defun gnus-article-wash-status ()
4483 "Return a string which display status of article washing."
4485 (set-buffer gnus-article-buffer)
4486 (let ((cite (memq 'cite gnus-article-wash-types))
4487 (headers (memq 'headers gnus-article-wash-types))
4488 (boring (memq 'boring-headers gnus-article-wash-types))
4489 (pgp (memq 'pgp gnus-article-wash-types))
4490 (pem (memq 'pem gnus-article-wash-types))
4491 (signed (memq 'signed gnus-article-wash-types))
4492 (encrypted (memq 'encrypted gnus-article-wash-types))
4493 (signature (memq 'signature gnus-article-wash-types))
4494 (overstrike (memq 'overstrike gnus-article-wash-types))
4495 (emphasis (memq 'emphasis gnus-article-wash-types)))
4497 (gnus-article-wash-status-entry 'cite cite)
4498 (gnus-article-wash-status-entry 'headers (or headers boring))
4499 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4500 (gnus-article-wash-status-entry 'signature signature)
4501 (gnus-article-wash-status-entry 'overstrike overstrike)
4502 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4504 (defun gnus-add-wash-type (type)
4505 "Add a washing of TYPE to the current status."
4506 (add-to-list 'gnus-article-wash-types type))
4508 (defun gnus-delete-wash-type (type)
4509 "Add a washing of TYPE to the current status."
4510 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4512 (defun gnus-add-image (category image)
4513 "Add IMAGE of CATEGORY to the list of displayed images."
4514 (let ((entry (assq category gnus-article-image-alist)))
4516 (setq entry (list category))
4517 (push entry gnus-article-image-alist))
4518 (nconc entry (list image))))
4520 (defun gnus-delete-images (category)
4521 "Delete all images in CATEGORY."
4522 (let ((entry (assq category gnus-article-image-alist)))
4523 (dolist (image (cdr entry))
4524 (gnus-remove-image image))
4525 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4526 (gnus-delete-wash-type category)))
4528 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4530 (defun gnus-article-maybe-hide-headers ()
4531 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4532 Provided for backwards compatibility."
4533 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4534 (not (save-excursion (set-buffer gnus-summary-buffer)
4535 gnus-have-all-headers)))
4536 (not gnus-inhibit-hiding))
4537 (gnus-article-hide-headers)))
4541 (defun gnus-output-to-file (file-name)
4542 "Append the current article to a file named FILE-NAME."
4543 (let ((artbuf (current-buffer)))
4545 (insert-buffer-substring artbuf)
4546 ;; Append newline at end of the buffer as separator, and then
4548 (goto-char (point-max))
4550 (let ((file-name-coding-system nnmail-pathname-coding-system))
4551 (mm-append-to-file (point-min) (point-max) file-name))
4554 (defun gnus-narrow-to-page (&optional arg)
4555 "Narrow the article buffer to a page.
4556 If given a numerical ARG, move forward ARG pages."
4558 (setq arg (if arg (prefix-numeric-value arg) 0))
4560 (set-buffer gnus-article-buffer)
4561 (goto-char (point-min))
4563 ;; Remove any old next/prev buttons.
4564 (when (gnus-visual-p 'page-marker)
4565 (let ((buffer-read-only nil))
4566 (gnus-remove-text-with-property 'gnus-prev)
4567 (gnus-remove-text-with-property 'gnus-next)))
4570 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4572 (re-search-forward page-delimiter nil 'move arg)))
4573 (goto-char (match-end 0)))
4576 (if (re-search-forward page-delimiter nil 'move)
4579 (when (and (gnus-visual-p 'page-marker)
4580 (not (= (point-min) 1)))
4582 (goto-char (point-min))
4583 (gnus-insert-prev-page-button)))
4584 (when (and (gnus-visual-p 'page-marker)
4585 (< (+ (point-max) 2) (buffer-size)))
4587 (goto-char (point-max))
4588 (gnus-insert-next-page-button)))))
4590 ;; Article mode commands
4592 (defun gnus-article-goto-next-page ()
4593 "Show the next page of the article."
4595 (when (gnus-article-next-page)
4596 (goto-char (point-min))
4597 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4599 (defun gnus-article-goto-prev-page ()
4600 "Show the next page of the article."
4602 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4603 (gnus-article-prev-page nil)))
4605 (defun gnus-article-next-page (&optional lines)
4606 "Show the next page of the current article.
4607 If end of article, return non-nil. Otherwise return nil.
4608 Argument LINES specifies lines to be scrolled up."
4610 (move-to-window-line -1)
4613 (and (pos-visible-in-window-p) ;Not continuation line.
4615 ;; Nothing in this page.
4616 (if (or (not gnus-page-broken)
4619 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4621 (gnus-narrow-to-page 1) ;Go to next page.
4623 ;; More in this page.
4624 (let ((scroll-in-place nil))
4628 ;; Long lines may cause an end-of-buffer error.
4629 (goto-char (point-max)))))
4630 (move-to-window-line 0)
4633 (defun gnus-article-prev-page (&optional lines)
4634 "Show previous page of current article.
4635 Argument LINES specifies lines to be scrolled down."
4637 (move-to-window-line 0)
4638 (if (and gnus-page-broken
4640 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4642 (gnus-narrow-to-page -1) ;Go to previous page.
4643 (goto-char (point-max))
4645 (let ((scroll-in-place nil))
4649 (beginning-of-buffer
4650 (goto-char (point-min))))
4651 (move-to-window-line 0)))))
4653 (defun gnus-article-refer-article ()
4654 "Read article specified by message-id around point."
4656 (let ((point (point)))
4657 (search-forward ">" nil t) ;Move point to end of "<....>".
4658 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4659 (let ((message-id (match-string 1)))
4661 (set-buffer gnus-summary-buffer)
4662 (gnus-summary-refer-article message-id))
4664 (error "No references around point"))))
4666 (defun gnus-article-show-summary ()
4667 "Reconfigure windows to show summary buffer."
4669 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4670 (error "There is no summary buffer for this article buffer")
4671 (gnus-article-set-globals)
4672 (gnus-configure-windows 'article)
4673 (gnus-summary-goto-subject gnus-current-article)
4674 (gnus-summary-position-point)))
4676 (defun gnus-article-describe-briefly ()
4677 "Describe article mode commands briefly."
4679 (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")))
4681 (defun gnus-article-summary-command ()
4682 "Execute the last keystroke in the summary buffer."
4684 (let ((obuf (current-buffer))
4685 (owin (current-window-configuration))
4687 (switch-to-buffer gnus-article-current-summary 'norecord)
4688 (setq func (lookup-key (current-local-map) (this-command-keys)))
4689 (call-interactively func)
4691 (set-window-configuration owin)
4692 (set-window-point (get-buffer-window (current-buffer)) (point))))
4694 (defun gnus-article-summary-command-nosave ()
4695 "Execute the last keystroke in the summary buffer."
4698 (pop-to-buffer gnus-article-current-summary 'norecord)
4699 (setq func (lookup-key (current-local-map) (this-command-keys)))
4700 (call-interactively func)))
4702 (defun gnus-article-check-buffer ()
4703 "Beep if not in an article buffer."
4704 (unless (equal major-mode 'gnus-article-mode)
4705 (error "Command invoked outside of a Gnus article buffer")))
4707 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4708 "Read a summary buffer key sequence and execute it from the article buffer."
4710 (gnus-article-check-buffer)
4712 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4713 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4714 "=" "^" "\M-^" "|"))
4720 '("n" "Gn" "p" "Gp"))
4723 (set-buffer gnus-article-current-summary)
4724 (let (gnus-pick-mode)
4725 (push (or key last-command-event) unread-command-events)
4726 (setq keys (if (featurep 'xemacs)
4727 (events-to-keys (read-key-sequence nil))
4728 (read-key-sequence nil)))))
4732 (if (or (member keys nosaves)
4733 (member keys nosave-but-article)
4734 (member keys nosave-in-article))
4736 (save-window-excursion
4737 (pop-to-buffer gnus-article-current-summary 'norecord)
4738 ;; We disable the pick minor mode commands.
4739 (let (gnus-pick-mode)
4740 (setq func (lookup-key (current-local-map) keys))))
4744 (unless (member keys nosave-in-article)
4745 (set-buffer gnus-article-current-summary))
4746 (call-interactively func)
4747 (setq new-sum-point (point)))
4748 (when (member keys nosave-but-article)
4749 (pop-to-buffer gnus-article-buffer 'norecord)))
4750 ;; These commands should restore window configuration.
4751 (let ((obuf (current-buffer))
4752 (owin (current-window-configuration))
4754 (summary gnus-article-current-summary)
4755 func in-buffer selected)
4756 (if not-restore-window
4757 (pop-to-buffer summary 'norecord)
4758 (switch-to-buffer summary 'norecord))
4759 (setq in-buffer (current-buffer))
4760 ;; We disable the pick minor mode commands.
4761 (if (and (setq func (let (gnus-pick-mode)
4762 (lookup-key (current-local-map) keys)))
4765 (call-interactively func)
4766 (setq new-sum-point (point))
4767 (when (eq in-buffer (current-buffer))
4768 (setq selected (gnus-summary-select-article))
4770 (unless not-restore-window
4771 (set-window-configuration owin))
4772 (when (eq selected 'old)
4774 (set-window-start (get-buffer-window (current-buffer))
4776 (set-window-point (get-buffer-window (current-buffer))
4778 (let ((win (get-buffer-window gnus-article-current-summary)))
4780 (set-window-point win new-sum-point)))) )
4781 (switch-to-buffer gnus-article-buffer)
4784 (defun gnus-article-describe-key (key)
4785 "Display documentation of the function invoked by KEY. KEY is a string."
4786 (interactive "kDescribe key: ")
4787 (gnus-article-check-buffer)
4788 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4790 (set-buffer gnus-article-current-summary)
4791 (let (gnus-pick-mode)
4792 (if (featurep 'xemacs)
4794 (push (elt key 0) unread-command-events)
4795 (setq key (events-to-keys
4796 (read-key-sequence "Describe key: "))))
4797 (setq unread-command-events
4799 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4800 (string-to-list key)))
4801 (setq key (read-key-sequence "Describe key: "))))
4803 (describe-key key)))
4805 (defun gnus-article-describe-key-briefly (key &optional insert)
4806 "Display documentation of the function invoked by KEY. KEY is a string."
4807 (interactive "kDescribe key: \nP")
4808 (gnus-article-check-buffer)
4809 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4811 (set-buffer gnus-article-current-summary)
4812 (let (gnus-pick-mode)
4813 (if (featurep 'xemacs)
4815 (push (elt key 0) unread-command-events)
4816 (setq key (events-to-keys
4817 (read-key-sequence "Describe key: "))))
4818 (setq unread-command-events
4820 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4821 (string-to-list key)))
4822 (setq key (read-key-sequence "Describe key: "))))
4823 (describe-key-briefly key insert))
4824 (describe-key-briefly key insert)))
4826 (defun gnus-article-reply-with-original (&optional wide)
4827 "Start composing a reply mail to the current message.
4828 The text in the region will be yanked. If the region isn't active,
4829 the entire article will be yanked."
4831 (let ((article (cdr gnus-article-current)) cont)
4833 (gnus-summary-reply (list (list article)) wide)
4834 (setq cont (buffer-substring (point) (mark t)))
4835 ;; Deactivate active regions.
4836 (when (and (boundp 'transient-mark-mode)
4837 transient-mark-mode)
4838 (setq mark-active nil))
4840 (list (list article cont)) wide))))
4842 (defun gnus-article-followup-with-original ()
4843 "Compose a followup to the current article.
4844 The text in the region will be yanked. If the region isn't active,
4845 the entire article will be yanked."
4847 (let ((article (cdr gnus-article-current))
4850 (gnus-summary-followup (list (list article)))
4851 (setq cont (buffer-substring (point) (mark t)))
4852 ;; Deactivate active regions.
4853 (when (and (boundp 'transient-mark-mode)
4854 transient-mark-mode)
4855 (setq mark-active nil))
4856 (gnus-summary-followup
4857 (list (list article cont))))))
4859 (defun gnus-article-hide (&optional arg force)
4860 "Hide all the gruft in the current article.
4861 This means that PGP stuff, signatures, cited text and (some)
4862 headers will be hidden.
4863 If given a prefix, show the hidden text instead."
4864 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4865 (gnus-article-hide-headers arg)
4866 (gnus-article-hide-list-identifiers arg)
4867 (gnus-article-hide-pgp arg)
4868 (gnus-article-hide-citation-maybe arg force)
4869 (gnus-article-hide-signature arg))
4871 (defun gnus-article-maybe-highlight ()
4872 "Do some article highlighting if article highlighting is requested."
4873 (when (gnus-visual-p 'article-highlight 'highlight)
4874 (gnus-article-highlight-some)))
4876 (defun gnus-check-group-server ()
4877 ;; Make sure the connection to the server is alive.
4878 (unless (gnus-server-opened
4879 (gnus-find-method-for-group gnus-newsgroup-name))
4880 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4881 (gnus-request-group gnus-newsgroup-name t)))
4884 (autoload 'nneething-get-file-name "nneething"))
4886 (defun gnus-request-article-this-buffer (article group)
4887 "Get an article and insert it into this buffer."
4888 (let (do-update-line sparse-header)
4892 (gnus-kill-all-overlays)
4893 (setq group (or group gnus-newsgroup-name))
4895 ;; Using `gnus-request-article' directly will insert the article into
4896 ;; `nntp-server-buffer' - so we'll save some time by not having to
4897 ;; copy it from the server buffer into the article buffer.
4899 ;; We only request an article by message-id when we do not have the
4900 ;; headers for it, so we'll have to get those.
4901 (when (stringp article)
4902 (gnus-read-header article))
4904 ;; If the article number is negative, that means that this article
4905 ;; doesn't belong in this newsgroup (possibly), so we find its
4906 ;; message-id and request it by id instead of number.
4907 (when (and (numberp article)
4909 (get-buffer gnus-summary-buffer)
4910 (gnus-buffer-exists-p gnus-summary-buffer))
4912 (set-buffer gnus-summary-buffer)
4913 (let ((header (gnus-summary-article-header article)))
4916 ((memq article gnus-newsgroup-sparse)
4917 ;; This is a sparse gap article.
4918 (setq do-update-line article)
4919 (setq article (mail-header-id header))
4920 (setq sparse-header (gnus-read-header article))
4921 (setq gnus-newsgroup-sparse
4922 (delq article gnus-newsgroup-sparse)))
4924 ;; It's a real article.
4925 (setq article (mail-header-id header)))
4927 ;; It is an extracted pseudo-article.
4928 (setq article 'pseudo)
4929 (gnus-request-pseudo-article header))))
4931 (let ((method (gnus-find-method-for-group
4932 gnus-newsgroup-name)))
4933 (when (and (eq (car method) 'nneething)
4935 (let ((dir (nneething-get-file-name
4936 (mail-header-id header))))
4937 (when (and (stringp dir)
4938 (file-directory-p dir))
4939 (setq article 'nneething)
4940 (gnus-group-enter-directory dir))))))))
4943 ;; Refuse to select canceled articles.
4944 ((and (numberp article)
4946 (get-buffer gnus-summary-buffer)
4947 (gnus-buffer-exists-p gnus-summary-buffer)
4948 (eq (cdr (save-excursion
4949 (set-buffer gnus-summary-buffer)
4950 (assq article gnus-newsgroup-reads)))
4951 gnus-canceled-mark))
4953 ;; We first check `gnus-original-article-buffer'.
4954 ((and (get-buffer gnus-original-article-buffer)
4957 (set-buffer gnus-original-article-buffer)
4958 (and (equal (car gnus-original-article) group)
4959 (eq (cdr gnus-original-article) article))))
4960 (insert-buffer-substring gnus-original-article-buffer)
4962 ;; Check the backlog.
4963 ((and gnus-keep-backlog
4964 (gnus-backlog-request-article group article (current-buffer)))
4966 ;; Check asynchronous pre-fetch.
4967 ((gnus-async-request-fetched-article group article (current-buffer))
4968 (gnus-async-prefetch-next group article gnus-summary-buffer)
4969 (when (and (numberp article) gnus-keep-backlog)
4970 (gnus-backlog-enter-article group article (current-buffer)))
4973 ((and gnus-use-cache
4975 (gnus-cache-request-article article group))
4977 ;; Check the agent cache.
4978 ((and gnus-agent gnus-agent-cache gnus-plugged
4980 (gnus-agent-request-article article group))
4982 ;; Get the article and put into the article buffer.
4983 ((or (stringp article)
4985 (let ((gnus-override-method gnus-override-method)
4986 (methods (and (stringp article)
4987 gnus-refer-article-method))
4988 (backend (car (gnus-find-method-for-group
4989 gnus-newsgroup-name)))
4991 (buffer-read-only nil))
4992 (if (or (not (listp methods))
4993 (and (symbolp (car methods))
4994 (assq (car methods) nnoo-definition-alist)))
4995 (setq methods (list methods)))
4996 (when (and (null gnus-override-method)
4998 (setq gnus-override-method (pop methods)))
5000 (when (eq gnus-override-method 'current)
5001 (setq gnus-override-method
5002 (with-current-buffer gnus-summary-buffer
5003 gnus-current-select-method)))
5005 (gnus-kill-all-overlays)
5006 (let ((gnus-newsgroup-name group))
5007 (gnus-check-group-server))
5009 ((gnus-request-article article group (current-buffer))
5010 (when (numberp article)
5011 (gnus-async-prefetch-next group article
5012 gnus-summary-buffer)
5013 (when gnus-keep-backlog
5014 (gnus-backlog-enter-article
5015 group article (current-buffer))))
5016 (setq result 'article))
5018 (setq gnus-override-method (pop methods)))
5019 ((not (string-match "^400 "
5020 (nnheader-get-report backend)))
5021 ;; If we get 400 server disconnect, reconnect and
5022 ;; retry; otherwise, assume the article has expired.
5023 (setq result 'done))))
5024 (and (eq result 'article) 'article)))
5028 ;; Associate this article with the current summary buffer.
5029 (setq gnus-article-current-summary gnus-summary-buffer)
5031 ;; Take the article from the original article buffer
5032 ;; and place it in the buffer it's supposed to be in.
5033 (when (and (get-buffer gnus-article-buffer)
5034 (equal (buffer-name (current-buffer))
5035 (buffer-name (get-buffer gnus-article-buffer))))
5037 (if (get-buffer gnus-original-article-buffer)
5038 (set-buffer gnus-original-article-buffer)
5039 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5040 (buffer-disable-undo)
5041 (setq major-mode 'gnus-original-article-mode)
5042 (setq buffer-read-only t))
5043 (let (buffer-read-only)
5045 (insert-buffer-substring gnus-article-buffer))
5046 (setq gnus-original-article (cons group article)))
5049 (run-hooks 'gnus-article-decode-hook)
5050 ;; Mark article as decoded or not.
5051 (setq gnus-article-decoded-p gnus-article-decode-hook))
5053 ;; Update sparse articles.
5054 (when (and do-update-line
5055 (or (numberp article)
5057 (let ((buf (current-buffer)))
5058 (set-buffer gnus-summary-buffer)
5059 (gnus-summary-update-article do-update-line sparse-header)
5060 (gnus-summary-goto-subject do-update-line nil t)
5061 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5063 (set-buffer buf))))))
5069 (defcustom gnus-article-edit-mode-hook nil
5070 "Hook run in article edit mode buffers."
5071 :group 'gnus-article-various
5074 (defvar gnus-article-edit-done-function nil)
5076 (defvar gnus-article-edit-mode-map nil)
5078 ;; Should we be using derived.el for this?
5079 (unless gnus-article-edit-mode-map
5080 (setq gnus-article-edit-mode-map (make-keymap))
5081 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5084 (gnus-define-keys gnus-article-edit-mode-map
5085 "\C-c?" describe-mode
5086 "\C-c\C-c" gnus-article-edit-done
5087 "\C-c\C-k" gnus-article-edit-exit
5088 "\C-c\C-f\C-t" message-goto-to
5089 "\C-c\C-f\C-o" message-goto-from
5090 "\C-c\C-f\C-b" message-goto-bcc
5091 ;;"\C-c\C-f\C-w" message-goto-fcc
5092 "\C-c\C-f\C-c" message-goto-cc
5093 "\C-c\C-f\C-s" message-goto-subject
5094 "\C-c\C-f\C-r" message-goto-reply-to
5095 "\C-c\C-f\C-n" message-goto-newsgroups
5096 "\C-c\C-f\C-d" message-goto-distribution
5097 "\C-c\C-f\C-f" message-goto-followup-to
5098 "\C-c\C-f\C-m" message-goto-mail-followup-to
5099 "\C-c\C-f\C-k" message-goto-keywords
5100 "\C-c\C-f\C-u" message-goto-summary
5101 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5102 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5103 "\C-c\C-b" message-goto-body
5104 "\C-c\C-i" message-goto-signature
5106 "\C-c\C-t" message-insert-to
5107 "\C-c\C-n" message-insert-newsgroups
5108 "\C-c\C-o" message-sort-headers
5109 "\C-c\C-e" message-elide-region
5110 "\C-c\C-v" message-delete-not-region
5111 "\C-c\C-z" message-kill-to-signature
5112 "\M-\r" message-newline-and-reformat
5113 "\C-c\C-a" mml-attach-file
5114 "\C-a" message-beginning-of-line
5116 "\M-;" comment-region)
5118 (gnus-define-keys (gnus-article-edit-wash-map
5119 "\C-c\C-w" gnus-article-edit-mode-map)
5120 "f" gnus-article-edit-full-stops))
5123 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5125 ["Fetch To" message-insert-to t]
5126 ["Fetch Newsgroups" message-insert-newsgroups t]
5128 ["To" message-goto-to t]
5129 ["From" message-goto-from t]
5130 ["Subject" message-goto-subject t]
5131 ["Cc" message-goto-cc t]
5132 ["Reply-To" message-goto-reply-to t]
5133 ["Summary" message-goto-summary t]
5134 ["Keywords" message-goto-keywords t]
5135 ["Newsgroups" message-goto-newsgroups t]
5136 ["Followup-To" message-goto-followup-to t]
5137 ["Mail-Followup-To" message-goto-mail-followup-to t]
5138 ["Distribution" message-goto-distribution t]
5139 ["Body" message-goto-body t]
5140 ["Signature" message-goto-signature t]))
5142 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5143 "Major mode for editing articles.
5144 This is an extended text-mode.
5146 \\{gnus-article-edit-mode-map}"
5147 (make-local-variable 'gnus-article-edit-done-function)
5148 (make-local-variable 'gnus-prev-winconf)
5149 (set (make-local-variable 'font-lock-defaults)
5150 '(message-font-lock-keywords t))
5151 (set (make-local-variable 'mail-header-separator) "")
5152 (easy-menu-add message-mode-field-menu message-mode-map)
5154 (setq buffer-read-only nil)
5155 (buffer-enable-undo)
5158 (defun gnus-article-edit (&optional force)
5159 "Edit the current article.
5160 This will have permanent effect only in mail groups.
5161 If FORCE is non-nil, allow editing of articles even in read-only
5164 (when (and (not force)
5165 (gnus-group-read-only-p))
5166 (error "The current newsgroup does not support article editing"))
5167 (gnus-article-date-original)
5168 (gnus-article-edit-article
5170 `(lambda (no-highlight)
5172 (gnus-summary-edit-article-done
5173 ,(or (mail-header-references gnus-current-headers) "")
5174 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5176 (defun gnus-article-edit-article (start-func exit-func)
5177 "Start editing the contents of the current article buffer."
5178 (let ((winconf (current-window-configuration)))
5179 (set-buffer gnus-article-buffer)
5180 (gnus-article-edit-mode)
5181 (funcall start-func)
5182 (set-buffer-modified-p nil)
5183 (gnus-configure-windows 'edit-article)
5184 (setq gnus-article-edit-done-function exit-func)
5185 (setq gnus-prev-winconf winconf)
5186 (gnus-message 6 "C-c C-c to end edits")))
5188 (defun gnus-article-edit-done (&optional arg)
5189 "Update the article edits and exit."
5191 (let ((func gnus-article-edit-done-function)
5192 (buf (current-buffer))
5193 (start (window-start))
5195 (winconf gnus-prev-winconf))
5196 (widen) ;; Widen it in case that users narrowed the buffer.
5199 ;; The cache and backlog have to be flushed somewhat.
5200 (when gnus-keep-backlog
5201 (gnus-backlog-remove-article
5202 (car gnus-article-current) (cdr gnus-article-current)))
5203 ;; Flush original article as well.
5205 (when (get-buffer gnus-original-article-buffer)
5206 (set-buffer gnus-original-article-buffer)
5207 (setq gnus-original-article nil)))
5208 (when gnus-use-cache
5209 (gnus-cache-update-article
5210 (car gnus-article-current) (cdr gnus-article-current)))
5211 ;; We remove all text props from the article buffer.
5212 (kill-all-local-variables)
5213 (gnus-set-text-properties (point-min) (point-max) nil)
5215 (set-window-configuration winconf)
5217 (set-window-start (get-buffer-window buf) start)
5218 (set-window-point (get-buffer-window buf) (point))))
5220 (defun gnus-article-edit-exit ()
5221 "Exit the article editing without updating."
5223 (when (or (not (buffer-modified-p))
5224 (yes-or-no-p "Article modified; kill anyway? "))
5225 (let ((curbuf (current-buffer))
5227 (window-start (window-start)))
5229 (if (gnus-buffer-live-p gnus-original-article-buffer)
5230 (insert-buffer gnus-original-article-buffer))
5231 (let ((winconf gnus-prev-winconf))
5233 (set-window-configuration winconf)
5234 ;; Tippy-toe some to make sure that point remains where it was.
5235 (save-current-buffer
5237 (set-window-start (get-buffer-window (current-buffer)) window-start)
5240 (defun gnus-article-edit-full-stops ()
5241 "Interactively repair spacing at end of sentences."
5244 (goto-char (point-min))
5245 (search-forward-regexp "^$" nil t)
5246 (let ((case-fold-search nil))
5247 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5250 ;;; Article highlights
5253 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5255 ;;; Internal Variables:
5257 (defcustom gnus-button-url-regexp
5258 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5259 "\\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:]]\\)"
5260 "\\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\\)\\)")
5261 "Regular expression that matches URLs."
5262 :group 'gnus-article-buttons
5265 (defcustom gnus-button-man-handler 'man
5266 "Function to use for displaying man pages.
5267 The function must take at least one argument with a string naming the
5269 :type '(choice (function-item :tag "Man" man)
5270 (function-item :tag "Woman" woman)
5271 (function :tag "Other"))
5272 :group 'gnus-article-buttons)
5274 (defcustom gnus-button-alist
5275 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5276 0 t gnus-button-handle-news 3)
5277 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5278 gnus-button-handle-news 2)
5279 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5281 gnus-button-fetch-group 4)
5282 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5283 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5284 t gnus-button-message-id 3)
5285 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5286 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5287 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5289 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5290 gnus-button-handle-info 2)
5291 ;; This is how URLs _should_ be embedded in text...
5292 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5294 (gnus-button-url-regexp 0 t browse-url 0)
5296 ("\\b\\([a-z]+\\)([0-9])\\W" 0 t gnus-button-handle-man 1))
5297 "*Alist of regexps matching buttons in article bodies.
5299 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5300 REGEXP: is the string matching text around the button (can also be lisp
5301 expression evaluating to a string),
5302 BUTTON: is the number of the regexp grouping actually matching the button,
5303 FORM: is a lisp expression which must eval to true for the button to
5305 CALLBACK: is the function to call when the user push this button, and each
5306 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5308 CALLBACK can also be a variable, in that case the value of that
5309 variable it the real callback function."
5310 :group 'gnus-article-buttons
5311 :type '(repeat (list (choice regexp variable)
5312 (integer :tag "Button")
5314 (function :tag "Callback")
5317 (integer :tag "Regexp group")))))
5319 (defcustom gnus-header-button-alist
5320 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5321 0 t gnus-button-message-id 0)
5322 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5323 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5324 0 t gnus-button-mailto 0)
5325 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5326 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5327 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5328 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5329 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5330 gnus-button-message-id 3))
5331 "*Alist of headers and regexps to match buttons in article heads.
5333 This alist is very similar to `gnus-button-alist', except that each
5334 alist has an additional HEADER element first in each entry:
5336 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5338 HEADER is a regexp to match a header. For a fuller explanation, see
5339 `gnus-button-alist'."
5340 :group 'gnus-article-buttons
5341 :group 'gnus-article-headers
5342 :type '(repeat (list (regexp :tag "Header")
5344 (integer :tag "Button")
5346 (function :tag "Callback")
5349 (integer :tag "Regexp group")))))
5351 (defvar gnus-button-regexp nil)
5352 (defvar gnus-button-marker-list nil)
5353 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5355 (defvar gnus-button-last nil)
5356 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5360 (defun gnus-article-push-button (event)
5361 "Check text under the mouse pointer for a callback function.
5362 If the text under the mouse pointer has a `gnus-callback' property,
5363 call it with the value of the `gnus-data' text property."
5365 (set-buffer (window-buffer (posn-window (event-start event))))
5366 (let* ((pos (posn-point (event-start event)))
5367 (data (get-text-property pos 'gnus-data))
5368 (fun (get-text-property pos 'gnus-callback)))
5371 (funcall fun data))))
5373 (defun gnus-article-press-button ()
5374 "Check text at point for a callback function.
5375 If the text at point has a `gnus-callback' property,
5376 call it with the value of the `gnus-data' text property."
5378 (let* ((data (get-text-property (point) 'gnus-data))
5379 (fun (get-text-property (point) 'gnus-callback)))
5381 (funcall fun data))))
5383 (defun gnus-article-highlight (&optional force)
5384 "Highlight current article.
5385 This function calls `gnus-article-highlight-headers',
5386 `gnus-article-highlight-citation',
5387 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5388 do the highlighting. See the documentation for those functions."
5389 (interactive (list 'force))
5390 (gnus-article-highlight-headers)
5391 (gnus-article-highlight-citation force)
5392 (gnus-article-highlight-signature)
5393 (gnus-article-add-buttons force)
5394 (gnus-article-add-buttons-to-head))
5396 (defun gnus-article-highlight-some (&optional force)
5397 "Highlight current article.
5398 This function calls `gnus-article-highlight-headers',
5399 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5400 do the highlighting. See the documentation for those functions."
5401 (interactive (list 'force))
5402 (gnus-article-highlight-headers)
5403 (gnus-article-highlight-signature)
5404 (gnus-article-add-buttons))
5406 (defun gnus-article-highlight-headers ()
5407 "Highlight article headers as specified by `gnus-header-face-alist'."
5410 (set-buffer gnus-article-buffer)
5412 (let ((alist gnus-header-face-alist)
5413 (buffer-read-only nil)
5414 (case-fold-search t)
5415 (inhibit-point-motion-hooks t)
5416 entry regexp header-face field-face from hpoints fpoints)
5417 (article-narrow-to-head)
5418 (while (setq entry (pop alist))
5419 (goto-char (point-min))
5420 (setq regexp (concat "^\\("
5421 (if (string-equal "" (nth 0 entry))
5425 header-face (nth 1 entry)
5426 field-face (nth 2 entry))
5427 (while (and (re-search-forward regexp nil t)
5431 (unless (search-forward ":" nil t)
5433 (when (and header-face
5434 (not (memq (point) hpoints)))
5435 (push (point) hpoints)
5436 (gnus-put-text-property from (point) 'face header-face))
5437 (when (and field-face
5438 (not (memq (setq from (point)) fpoints)))
5440 (if (re-search-forward "^[^ \t]" nil t)
5442 (goto-char (point-max)))
5443 (gnus-put-text-property from (point) 'face field-face))))))))
5445 (defun gnus-article-highlight-signature ()
5446 "Highlight the signature in an article.
5447 It does this by highlighting everything after
5448 `gnus-signature-separator' using `gnus-signature-face'."
5451 (set-buffer gnus-article-buffer)
5452 (let ((buffer-read-only nil)
5453 (inhibit-point-motion-hooks t))
5455 (when (and gnus-signature-face
5456 (gnus-article-narrow-to-signature))
5457 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5458 'face gnus-signature-face)
5460 (gnus-article-search-signature)
5461 (let ((start (match-beginning 0))
5462 (end (set-marker (make-marker) (1+ (match-end 0)))))
5463 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5466 (defun gnus-button-in-region-p (b e prop)
5467 "Say whether PROP exists in the region."
5468 (text-property-not-all b e prop nil))
5470 (defun gnus-article-add-buttons (&optional force)
5471 "Find external references in the article and make buttons of them.
5472 \"External references\" are things like Message-IDs and URLs, as
5473 specified by `gnus-button-alist'."
5474 (interactive (list 'force))
5476 (set-buffer gnus-article-buffer)
5477 (let ((buffer-read-only nil)
5478 (inhibit-point-motion-hooks t)
5479 (case-fold-search t)
5480 (alist gnus-button-alist)
5482 ;; Remove all old markers.
5483 (let (marker entry new-list)
5484 (while (setq marker (pop gnus-button-marker-list))
5485 (if (or (< marker (point-min)) (>= marker (point-max)))
5486 (push marker new-list)
5488 (when (setq entry (gnus-button-entry))
5489 (put-text-property (match-beginning (nth 1 entry))
5490 (match-end (nth 1 entry))
5491 'gnus-callback nil))
5492 (set-marker marker nil)))
5493 (setq gnus-button-marker-list new-list))
5494 ;; We skip the headers.
5497 (while (setq entry (pop alist))
5498 (setq regexp (eval (car entry)))
5500 (while (re-search-forward regexp nil t)
5501 (let* ((start (and entry (match-beginning (nth 1 entry))))
5502 (end (and entry (match-end (nth 1 entry))))
5503 (from (match-beginning 0)))
5504 (when (and (or (eq t (nth 2 entry))
5505 (eval (nth 2 entry)))
5506 (not (gnus-button-in-region-p
5507 start end 'gnus-callback)))
5508 ;; That optional form returned non-nil, so we add the
5510 (gnus-article-add-button
5511 start end 'gnus-button-push
5512 (car (push (set-marker (make-marker) from)
5513 gnus-button-marker-list))))))))))
5515 ;; Add buttons to the head of an article.
5516 (defun gnus-article-add-buttons-to-head ()
5517 "Add buttons to the head of the article."
5520 (set-buffer gnus-article-buffer)
5522 (let ((buffer-read-only nil)
5523 (inhibit-point-motion-hooks t)
5524 (case-fold-search t)
5525 (alist gnus-header-button-alist)
5527 (article-narrow-to-head)
5529 ;; Each alist entry.
5530 (setq entry (car alist)
5532 (goto-char (point-min))
5533 (while (re-search-forward (car entry) nil t)
5534 ;; Each header matching the entry.
5535 (setq beg (match-beginning 0))
5536 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5537 (match-beginning 0))
5540 (while (re-search-forward (eval (nth 1 entry)) end t)
5541 ;; Each match within a header.
5542 (let* ((entry (cdr entry))
5543 (start (match-beginning (nth 1 entry)))
5544 (end (match-end (nth 1 entry)))
5545 (form (nth 2 entry)))
5546 (goto-char (match-end 0))
5548 (gnus-article-add-button
5549 start end (nth 3 entry)
5550 (buffer-substring (match-beginning (nth 4 entry))
5551 (match-end (nth 4 entry)))))))
5552 (goto-char end)))))))
5554 ;;; External functions:
5556 (defun gnus-article-add-button (from to fun &optional data)
5557 "Create a button between FROM and TO with callback FUN and data DATA."
5558 (when gnus-article-button-face
5559 (gnus-overlay-put (gnus-make-overlay from to)
5560 'face gnus-article-button-face))
5561 (gnus-add-text-properties
5563 (nconc (and gnus-article-mouse-face
5564 (list gnus-mouse-face-prop gnus-article-mouse-face))
5565 (list 'gnus-callback fun)
5566 (and data (list 'gnus-data data))))
5567 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5568 :button-keymap gnus-widget-button-keymap))
5570 ;;; Internal functions:
5572 (defun gnus-article-set-globals ()
5574 (set-buffer gnus-summary-buffer)
5575 (gnus-set-global-variables)))
5577 (defun gnus-signature-toggle (end)
5579 (set-buffer gnus-article-buffer)
5580 (let ((buffer-read-only nil)
5581 (inhibit-point-motion-hooks t))
5582 (if (text-property-any end (point-max) 'article-type 'signature)
5584 (gnus-delete-wash-type 'signature)
5585 (gnus-remove-text-properties-when
5586 'article-type 'signature end (point-max)
5587 (cons 'article-type (cons 'signature
5588 gnus-hidden-properties))))
5589 (gnus-add-wash-type 'signature)
5590 (gnus-add-text-properties-when
5591 'article-type nil end (point-max)
5592 (cons 'article-type (cons 'signature
5593 gnus-hidden-properties)))))
5594 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5595 (gnus-set-mode-line 'article))))
5597 (defun gnus-button-entry ()
5598 ;; Return the first entry in `gnus-button-alist' matching this place.
5599 (let ((alist gnus-button-alist)
5602 (setq entry (pop alist))
5603 (if (looking-at (eval (car entry)))
5608 (defun gnus-button-push (marker)
5609 ;; Push button starting at MARKER.
5612 (let* ((entry (gnus-button-entry))
5613 (inhibit-point-motion-hooks t)
5615 (args (mapcar (lambda (group)
5616 (let ((string (match-string group)))
5617 (gnus-set-text-properties
5618 0 (length string) nil string)
5625 (fboundp (symbol-value fun)))
5626 (apply (symbol-value fun) args))
5628 (gnus-message 1 "You must define `%S' to use this button"
5629 (cons fun args)))))))
5631 (defun gnus-parse-news-url (url)
5632 (let (scheme server group message-id articles)
5635 (goto-char (point-min))
5636 (when (looking-at "\\([A-Za-z]+\\):")
5637 (setq scheme (match-string 1))
5638 (goto-char (match-end 0)))
5639 (when (looking-at "//\\([^/]+\\)/")
5640 (setq server (match-string 1))
5641 (goto-char (match-end 0)))
5644 ((looking-at "\\(.*@.*\\)")
5645 (setq message-id (match-string 1)))
5646 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5647 (setq group (match-string 1)
5648 articles (split-string (match-string 2) "-")))
5649 ((looking-at "\\([^/]+\\)/?")
5650 (setq group (match-string 1)))
5652 (error "Unknown news URL syntax"))))
5653 (list scheme server group message-id articles)))
5655 (defun gnus-button-handle-news (url)
5657 (destructuring-bind (scheme server group message-id articles)
5658 (gnus-parse-news-url url)
5662 (set-buffer gnus-summary-buffer)
5664 (let ((gnus-refer-article-method (list (list 'nntp server))))
5665 (gnus-summary-refer-article message-id))
5666 (gnus-summary-refer-article message-id))))
5668 (gnus-button-fetch-group url)))))
5670 (defun gnus-button-handle-man (url)
5672 (funcall gnus-button-man-handler url))
5674 (defun gnus-button-handle-info (url)
5675 "Fetch an info URL."
5677 "^\\([^:/]+\\)?/\\(.*\\)"
5679 (gnus-info-find-node
5680 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5683 (gnus-url-unhex-string (match-string 2 url))))
5684 (error "Can't parse %s" url)))
5686 (defun gnus-button-message-id (message-id)
5689 (set-buffer gnus-summary-buffer)
5690 (gnus-summary-refer-article message-id)))
5692 (defun gnus-button-fetch-group (address)
5693 "Fetch GROUP specified by ADDRESS."
5694 (if (not (string-match "[:/]" address))
5695 ;; This is just a simple group url.
5696 (gnus-group-read-ephemeral-group address gnus-select-method)
5699 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5701 (error "Can't parse %s" address)
5702 (gnus-group-read-ephemeral-group
5703 (match-string 4 address)
5704 `(nntp ,(match-string 1 address)
5705 (nntp-address ,(match-string 1 address))
5706 (nntp-port-number ,(if (match-end 3)
5707 (match-string 3 address)
5710 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5712 (defun gnus-url-parse-query-string (query &optional downcase)
5713 (let (retval pairs cur key val)
5714 (setq pairs (split-string query "&"))
5716 (setq cur (car pairs)
5718 (if (not (string-match "=" cur))
5720 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5721 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5723 (setq key (downcase key)))
5724 (setq cur (assoc key retval))
5726 (setcdr cur (cons val (cdr cur)))
5727 (setq retval (cons (list key val) retval)))))
5730 (defun gnus-url-mailto (url)
5731 ;; Send mail to someone
5732 (when (string-match "mailto:/*\\(.*\\)" url)
5733 (setq url (substring url (match-beginning 1) nil)))
5734 (let (to args subject func)
5735 (if (string-match (regexp-quote "?") url)
5736 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5737 args (gnus-url-parse-query-string
5738 (substring url (match-end 0) nil) t))
5739 (setq to (gnus-url-unhex-string url)))
5740 (setq args (cons (list "to" to) args)
5741 subject (cdr-safe (assoc "subject" args)))
5744 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5747 (message-position-on-field (caar args)))
5748 (insert (mapconcat 'identity (cdar args) ", "))
5749 (setq args (cdr args)))
5752 (message-goto-subject))))
5754 (defun gnus-button-embedded-url (address)
5755 "Activate ADDRESS with `browse-url'."
5756 (browse-url (gnus-strip-whitespace address)))
5758 ;;; Next/prev buttons in the article buffer.
5760 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5761 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5763 (defvar gnus-prev-page-map
5764 (let ((map (make-sparse-keymap)))
5765 (unless (>= emacs-major-version 21)
5766 ;; XEmacs doesn't care.
5767 (set-keymap-parent map gnus-article-mode-map))
5768 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5769 (define-key map "\r" 'gnus-button-prev-page)
5772 (defun gnus-insert-prev-page-button ()
5774 (buffer-read-only nil))
5776 gnus-prev-page-line-format nil
5777 `(,@(gnus-local-map-property gnus-prev-page-map)
5779 gnus-callback gnus-article-button-prev-page
5780 article-type annotation))
5781 (widget-convert-button
5783 :action 'gnus-button-prev-page
5784 :button-keymap gnus-prev-page-map)))
5786 (defvar gnus-prev-page-map
5787 (let ((map (make-sparse-keymap)))
5788 (unless (>= emacs-major-version 21)
5789 ;; XEmacs doesn't care.
5790 (set-keymap-parent map gnus-article-mode-map))
5791 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5792 (define-key map "\r" 'gnus-button-prev-page)
5795 (defvar gnus-next-page-map
5796 (let ((map (make-sparse-keymap)))
5797 (unless (>= emacs-major-version 21)
5798 ;; XEmacs doesn't care.
5799 (set-keymap-parent map gnus-article-mode-map))
5800 (define-key map gnus-mouse-2 'gnus-button-next-page)
5801 (define-key map "\r" 'gnus-button-next-page)
5804 (defun gnus-button-next-page (&optional args more-args)
5805 "Go to the next page."
5807 (let ((win (selected-window)))
5808 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5809 (gnus-article-next-page)
5810 (select-window win)))
5812 (defun gnus-button-prev-page (&optional args more-args)
5813 "Go to the prev page."
5815 (let ((win (selected-window)))
5816 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5817 (gnus-article-prev-page)
5818 (select-window win)))
5820 (defun gnus-insert-next-page-button ()
5822 (buffer-read-only nil))
5823 (gnus-eval-format gnus-next-page-line-format nil
5824 `(,@(gnus-local-map-property gnus-next-page-map)
5826 gnus-callback gnus-article-button-next-page
5827 article-type annotation))
5828 (widget-convert-button
5830 :action 'gnus-button-next-page
5831 :button-keymap gnus-next-page-map)))
5833 (defun gnus-article-button-next-page (arg)
5834 "Go to the next page."
5836 (let ((win (selected-window)))
5837 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5838 (gnus-article-next-page)
5839 (select-window win)))
5841 (defun gnus-article-button-prev-page (arg)
5842 "Go to the prev page."
5844 (let ((win (selected-window)))
5845 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5846 (gnus-article-prev-page)
5847 (select-window win)))
5849 (defvar gnus-decode-header-methods
5850 '(mail-decode-encoded-word-region)
5851 "List of methods used to decode headers.
5853 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5854 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5855 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5856 whose names match REGEXP.
5859 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5860 mail-decode-encoded-word-region
5861 (\"chinese\" . rfc1843-decode-region))
5864 (defvar gnus-decode-header-methods-cache nil)
5866 (defun gnus-multi-decode-header (start end)
5867 "Apply the functions from `gnus-encoded-word-methods' that match."
5868 (unless (and gnus-decode-header-methods-cache
5869 (eq gnus-newsgroup-name
5870 (car gnus-decode-header-methods-cache)))
5871 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5874 (nconc gnus-decode-header-methods-cache (list x))
5875 (if (and gnus-newsgroup-name
5876 (string-match (car x) gnus-newsgroup-name))
5877 (nconc gnus-decode-header-methods-cache
5879 gnus-decode-header-methods))
5880 (let ((xlist gnus-decode-header-methods-cache))
5883 (narrow-to-region start end)
5885 (funcall (pop xlist) (point-min) (point-max))))))
5888 ;;; Treatment top-level handling.
5891 (defun gnus-treat-article (condition &optional part-number total-parts type)
5892 (let ((length (- (point-max) (point-min)))
5893 (alist gnus-treatment-function-alist)
5894 (article-goto-body-goes-to-point-min-p t)
5898 (let ((list gnus-article-treat-types))
5900 (when (string-match (pop list) type)
5901 (throw 'found t)))))))
5902 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5904 (gnus-run-hooks 'gnus-part-display-hook)
5905 (while (setq elem (pop alist))
5908 (if (gnus-buffer-live-p gnus-summary-buffer)
5909 (set-buffer gnus-summary-buffer))
5910 (symbol-value (car elem))))
5911 (when (and (or (consp val)
5913 (gnus-treat-predicate val)
5914 (or (not (get (car elem) 'highlight))
5917 (funcall (cadr elem)))))))
5919 ;; Dynamic variables.
5921 (defvar part-number)
5922 (defvar total-parts)
5927 (defun gnus-treat-predicate (val)
5932 (stringp (car val)))
5933 (apply 'gnus-or (mapcar `(lambda (s)
5934 (string-match s ,(or gnus-newsgroup-name "")))
5937 (let ((pred (pop val)))
5940 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5942 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5944 (not (gnus-treat-predicate (car val))))
5946 (equal (car val) type))
5948 (error "%S is not a valid predicate" pred)))))
5956 (eq part-number total-parts))
5960 (error "%S is not a valid value" val))))
5962 (defun gnus-article-encrypt-body (protocol &optional n)
5963 "Encrypt the article body."
5966 (or gnus-article-encrypt-protocol
5967 (completing-read "Encrypt protocol: "
5968 gnus-article-encrypt-protocol-alist
5970 current-prefix-arg))
5971 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5973 (error (format "Can't find the encrypt protocol %s" protocol)))
5974 (if (equal gnus-newsgroup-name "nndraft:drafts")
5975 (error "Can't encrypt the article in group nndraft:drafts"))
5976 (if (equal gnus-newsgroup-name "nndraft:queue")
5977 (error "Don't encrypt the article in group nndraft:queue"))
5978 (gnus-summary-iterate n
5980 (set-buffer gnus-summary-buffer)
5981 (let ((mail-parse-charset gnus-newsgroup-charset)
5982 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5983 (summary-buffer gnus-summary-buffer)
5985 (gnus-set-global-variables)
5986 (when (gnus-group-read-only-p)
5987 (error "The current newsgroup does not support article encrypt"))
5988 (gnus-summary-show-article t)
5990 (or (mail-header-references gnus-current-headers) ""))
5991 (set-buffer gnus-article-buffer)
5992 (let* ((buffer-read-only nil)
5994 (mapcar (lambda (field)
5995 (and (save-restriction
5996 (message-narrow-to-head)
5997 (goto-char (point-min))
5998 (search-forward field nil t))
6000 (message-narrow-to-field)
6001 (buffer-substring (point-min) (point-max))
6002 (delete-region (point-min) (point-max))
6004 '("Content-Type:" "Content-Transfer-Encoding:"
6005 "Content-Disposition:"))))
6006 (message-narrow-to-head)
6007 (message-remove-header "MIME-Version")
6008 (goto-char (point-max))
6009 (setq point (point))
6010 (insert (apply 'concat headers))
6012 (narrow-to-region point (point-max))
6013 (let ((message-options message-options))
6014 (message-options-set 'message-sender user-mail-address)
6015 (message-options-set 'message-recipients user-mail-address)
6016 (message-options-set 'message-sign-encrypt 'not)
6018 (goto-char (point-min))
6019 (insert "MIME-Version: 1.0\n")
6021 (gnus-summary-edit-article-done
6022 references nil summary-buffer t))
6023 (when gnus-keep-backlog
6024 (gnus-backlog-remove-article
6025 (car gnus-article-current) (cdr gnus-article-current)))
6027 (when (get-buffer gnus-original-article-buffer)
6028 (set-buffer gnus-original-article-buffer)
6029 (setq gnus-original-article nil)))
6030 (when gnus-use-cache
6031 (gnus-cache-update-article
6032 (car gnus-article-current) (cdr gnus-article-current))))))))
6034 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6035 "The following specs can be used:
6036 %t The security MIME type
6039 %D Details if button is pressed")
6041 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6042 "The following specs can be used:
6043 %t The security MIME type
6046 %D Details if button is pressed")
6048 (defvar gnus-mime-security-button-line-format-alist
6049 '((?t gnus-tmp-type ?s)
6050 (?i gnus-tmp-info ?s)
6051 (?d gnus-tmp-details ?s)
6052 (?D gnus-tmp-pressed-details ?s)))
6054 (defvar gnus-mime-security-button-map
6055 (let ((map (make-sparse-keymap)))
6056 (unless (>= (string-to-number emacs-version) 21)
6057 (set-keymap-parent map gnus-article-mode-map))
6058 (define-key map gnus-mouse-2 'gnus-article-push-button)
6059 (define-key map "\r" 'gnus-article-press-button)
6062 (defvar gnus-mime-security-details-buffer nil)
6064 (defvar gnus-mime-security-button-pressed nil)
6066 (defvar gnus-mime-security-show-details-inline t
6067 "If non-nil, show details in the article buffer.")
6069 (defun gnus-mime-security-verify-or-decrypt (handle)
6070 (mm-remove-parts (cdr handle))
6071 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6072 point buffer-read-only)
6074 (goto-char (car region)))
6076 (narrow-to-region (point) (point))
6077 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6078 (let* ((mm-verify-option 'known)
6079 (mm-decrypt-option 'known)
6080 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6081 (unless (eq nparts (cdr handle))
6082 (mm-destroy-parts (cdr handle))
6083 (setcdr handle nparts))))
6084 (setq point (point))
6085 (gnus-mime-display-security handle)
6086 (goto-char (point-max)))
6088 (delete-region (point) (cdr region))
6089 (set-marker (car region) nil)
6090 (set-marker (cdr region) nil))
6093 (defun gnus-mime-security-show-details (handle)
6094 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6096 (if gnus-mime-security-show-details-inline
6097 (let ((gnus-mime-security-button-pressed t)
6098 (gnus-mime-security-button-line-format
6099 (get-text-property (point) 'gnus-line-format))
6102 (while (eq (get-text-property (point) 'gnus-line-format)
6103 gnus-mime-security-button-line-format)
6107 (narrow-to-region (point) (point))
6108 (gnus-insert-mime-security-button handle))
6109 (delete-region (point)
6110 (or (text-property-not-all
6113 gnus-mime-security-button-line-format)
6115 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6116 (with-current-buffer gnus-mime-security-details-buffer
6119 (setq gnus-mime-security-details-buffer
6120 (gnus-get-buffer-create "*MIME Security Details*")))
6121 (with-current-buffer gnus-mime-security-details-buffer
6123 (goto-char (point-min)))
6124 (pop-to-buffer gnus-mime-security-details-buffer))
6125 (gnus-message 5 "No details."))))
6127 (defun gnus-mime-security-press-button (handle)
6128 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6129 (gnus-mime-security-show-details handle)
6130 (gnus-mime-security-verify-or-decrypt handle)))
6132 (defun gnus-insert-mime-security-button (handle &optional displayed)
6133 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6136 (or (nth 2 (assoc protocol mm-verify-function-alist))
6137 (nth 2 (assoc protocol mm-decrypt-function-alist))
6139 (if (equal (car handle) "multipart/signed")
6140 " Signed" " Encrypted")
6143 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6146 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6147 gnus-tmp-pressed-details
6149 (setq gnus-tmp-details
6150 (if gnus-tmp-details
6151 (concat "\n" gnus-tmp-details) ""))
6152 (setq gnus-tmp-pressed-details
6153 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6158 gnus-mime-security-button-line-format
6159 gnus-mime-security-button-line-format-alist
6160 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6161 gnus-callback gnus-mime-security-press-button
6162 gnus-line-format ,gnus-mime-security-button-line-format
6163 article-type annotation
6166 (widget-convert-button
6169 :action 'gnus-widget-press-button
6170 :button-keymap gnus-mime-security-button-map
6172 (lambda (widget/window &optional overlay pos)
6173 ;; Needed to properly clear the message due to a bug in
6174 ;; wid-edit (XEmacs only).
6175 (if (boundp 'help-echo-owns-message)
6176 (setq help-echo-owns-message t))
6179 (aref gnus-mouse-2 0))))))
6181 (defun gnus-mime-display-security (handle)
6183 (narrow-to-region (point) (point))
6184 (unless (gnus-unbuttonized-mime-type-p (car handle))
6185 (gnus-insert-mime-security-button handle))
6186 (gnus-mime-display-mixed (cdr handle))
6189 (unless (gnus-unbuttonized-mime-type-p (car handle))
6190 (let ((gnus-mime-security-button-line-format
6191 gnus-mime-security-button-end-line-format))
6192 (gnus-insert-mime-security-button handle)))
6193 (mm-set-handle-multipart-parameter
6195 (cons (set-marker (make-marker) (point-min))
6196 (set-marker (make-marker) (point-max))))))
6202 (run-hooks 'gnus-art-load-hook)
6204 ;;; gnus-art.el ends here