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)
245 :group 'gnus-article-washing)
247 (defcustom gnus-article-x-face-too-ugly nil
248 "Regexp matching posters whose face shouldn't be shown automatically."
249 :type '(choice regexp (const nil))
250 :group 'gnus-article-washing)
252 (defcustom gnus-article-banner-alist nil
253 "Banner alist for stripping.
255 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
257 :type '(repeat (cons symbol regexp))
258 :group 'gnus-article-washing)
260 (gnus-define-group-parameter
263 "Alist of regexps (to match group names) and banner."
264 :variable-group gnus-article-washing
266 '(choice :tag "Banner"
268 (const :tag "Remove signature" signature)
269 (symbol :tag "Item in `gnus-article-banner-alist'" none)
271 (const :tag "None" nil))
273 "If non-nil, specify how to remove `banners' from articles.
275 Symbol `signature' means to remove signatures delimited by
276 `gnus-signature-separator'. Any other symbol is used to look up a
277 regular expression to match the banner in `gnus-article-banner-alist'.
278 A string is used as a regular expression to match the banner
281 (defcustom gnus-emphasis-alist
283 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
288 ("_/" "/_" underline-italic)
289 ("_\\*" "\\*_" underline-bold)
290 ("\\*/" "/\\*" bold-italic)
291 ("_\\*/" "/\\*_" underline-bold-italic))))
295 (format format (car spec) (cadr spec))
296 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
298 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
299 2 3 gnus-emphasis-underline)))
300 "*Alist that says how to fontify certain phrases.
301 Each item looks like this:
303 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
305 The first element is a regular expression to be matched. The second
306 is a number that says what regular expression grouping used to find
307 the entire emphasized word. The third is a number that says what
308 regexp grouping should be displayed and highlighted. The fourth
309 is the face used for highlighting."
310 :type '(repeat (list :value ("" 0 0 default)
312 (integer :tag "Match group")
313 (integer :tag "Emphasize group")
315 :group 'gnus-article-emphasis)
317 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
318 "A regexp to describe whitespace which should not be emphasized.
319 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
320 The former avoids underlining of leading and trailing whitespace,
321 and the latter avoids underlining any whitespace at all."
323 :group 'gnus-article-emphasis
326 (defface gnus-emphasis-bold '((t (:bold t)))
327 "Face used for displaying strong emphasized text (*word*)."
328 :group 'gnus-article-emphasis)
330 (defface gnus-emphasis-italic '((t (:italic t)))
331 "Face used for displaying italic emphasized text (/word/)."
332 :group 'gnus-article-emphasis)
334 (defface gnus-emphasis-underline '((t (:underline t)))
335 "Face used for displaying underlined emphasized text (_word_)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
339 "Face used for displaying underlined bold emphasized text (_*word*_)."
340 :group 'gnus-article-emphasis)
342 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
343 "Face used for displaying underlined italic emphasized text (_/word/_)."
344 :group 'gnus-article-emphasis)
346 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
347 "Face used for displaying bold italic emphasized text (/*word*/)."
348 :group 'gnus-article-emphasis)
350 (defface gnus-emphasis-underline-bold-italic
351 '((t (:bold t :italic t :underline t)))
352 "Face used for displaying underlined bold italic emphasized text.
353 Esample: (_/*word*/_)."
354 :group 'gnus-article-emphasis)
356 (defface gnus-emphasis-highlight-words
357 '((t (:background "black" :foreground "yellow")))
358 "Face used for displaying highlighted words."
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
362 "Format for display of Date headers in article bodies.
363 See `format-time-string' for the possible values.
365 The variable can also be function, which should return a complete Date
366 header. The function is called with one argument, the time, which can
367 be fed to `format-time-string'."
368 :type '(choice string symbol)
369 :link '(custom-manual "(gnus)Article Date")
370 :group 'gnus-article-washing)
373 (autoload 'mail-extract-address-components "mail-extr"))
375 (defcustom gnus-save-all-headers t
376 "*If non-nil, don't remove any headers before saving."
377 :group 'gnus-article-saving
380 (defcustom gnus-prompt-before-saving 'always
381 "*This variable says how much prompting is to be done when saving articles.
382 If it is nil, no prompting will be done, and the articles will be
383 saved to the default files. If this variable is `always', each and
384 every article that is saved will be preceded by a prompt, even when
385 saving large batches of articles. If this variable is neither nil not
386 `always', there the user will be prompted once for a file name for
387 each invocation of the saving commands."
388 :group 'gnus-article-saving
389 :type '(choice (item always)
390 (item :tag "never" nil)
391 (sexp :tag "once" :format "%t\n" :value t)))
393 (defcustom gnus-saved-headers gnus-visible-headers
394 "Headers to keep if `gnus-save-all-headers' is nil.
395 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
396 If that variable is nil, however, all headers that match this regexp
397 will be kept while the rest will be deleted before saving."
398 :group 'gnus-article-saving
401 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
402 "A function to save articles in your favourite format.
403 The function must be interactively callable (in other words, it must
404 be an Emacs command).
406 Gnus provides the following functions:
408 * gnus-summary-save-in-rmail (Rmail format)
409 * gnus-summary-save-in-mail (Unix mail format)
410 * gnus-summary-save-in-folder (MH folder)
411 * gnus-summary-save-in-file (article format)
412 * gnus-summary-save-body-in-file (article body)
413 * gnus-summary-save-in-vm (use VM's folder format)
414 * gnus-summary-write-to-file (article format -- overwrite)."
415 :group 'gnus-article-saving
416 :type '(radio (function-item gnus-summary-save-in-rmail)
417 (function-item gnus-summary-save-in-mail)
418 (function-item gnus-summary-save-in-folder)
419 (function-item gnus-summary-save-in-file)
420 (function-item gnus-summary-save-body-in-file)
421 (function-item gnus-summary-save-in-vm)
422 (function-item gnus-summary-write-to-file)))
424 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
425 "A function generating a file name to save articles in Rmail format.
426 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
427 :group 'gnus-article-saving
430 (defcustom gnus-mail-save-name 'gnus-plain-save-name
431 "A function generating a file name to save articles in Unix mail format.
432 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
433 :group 'gnus-article-saving
436 (defcustom gnus-folder-save-name 'gnus-folder-save-name
437 "A function generating a file name to save articles in MH folder.
438 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
439 :group 'gnus-article-saving
442 (defcustom gnus-file-save-name 'gnus-numeric-save-name
443 "A function generating a file name to save articles in article format.
444 The function is called with NEWSGROUP, HEADERS, and optional
446 :group 'gnus-article-saving
449 (defcustom gnus-split-methods
450 '((gnus-article-archive-name)
451 (gnus-article-nndoc-name))
452 "*Variable used to suggest where articles are to be saved.
453 For instance, if you would like to save articles related to Gnus in
454 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
455 you could set this variable to something like:
457 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
458 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
460 This variable is an alist where the where the key is the match and the
461 value is a list of possible files to save in if the match is non-nil.
463 If the match is a string, it is used as a regexp match on the
464 article. If the match is a symbol, that symbol will be funcalled
465 from the buffer of the article to be saved with the newsgroup as the
466 parameter. If it is a list, it will be evaled in the same buffer.
468 If this form or function returns a string, this string will be used as
469 a possible file name; and if it returns a non-nil list, that list will
470 be used as possible file names."
471 :group 'gnus-article-saving
472 :type '(repeat (choice (list :value (fun) function)
473 (cons :value ("" "") regexp (repeat string))
476 (defcustom gnus-page-delimiter "^\^L"
477 "*Regexp describing what to use as article page delimiters.
478 The default value is \"^\^L\", which is a form linefeed at the
479 beginning of a line."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
484 "*The format specification for the article mode line.
485 See `gnus-summary-mode-line-format' for a closer description.
487 The following additional specs are available:
489 %w The article washing status.
490 %m The number of MIME parts in the article."
492 :group 'gnus-article-various)
494 (defcustom gnus-article-mode-hook nil
495 "*A hook for Gnus article mode."
497 :group 'gnus-article-various)
499 (when (featurep 'xemacs)
500 ;; Extracted from gnus-xmas-define in order to preserve user settings
501 (when (fboundp 'turn-off-scroll-in-place)
502 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
503 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
504 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
506 (defcustom gnus-article-menu-hook nil
507 "*Hook run after the creation of the article mode menu."
509 :group 'gnus-article-various)
511 (defcustom gnus-article-prepare-hook nil
512 "*A hook called after an article has been prepared in the article buffer."
514 :group 'gnus-article-various)
516 (defcustom gnus-article-hide-pgp-hook nil
517 "*A hook called after successfully hiding a PGP signature."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-button-face 'bold
522 "Face used for highlighting buttons in the article buffer.
524 An article button is a piece of text that you can activate by pressing
525 `RET' or `mouse-2' above it."
527 :group 'gnus-article-buttons)
529 (defcustom gnus-article-mouse-face 'highlight
530 "Face used for mouse highlighting in the article buffer.
532 Article buttons will be displayed in this face when the cursor is
535 :group 'gnus-article-buttons)
537 (defcustom gnus-signature-face 'gnus-signature-face
538 "Face used for highlighting a signature in the article buffer.
539 Obsolete; use the face `gnus-signature-face' for customizations instead."
541 :group 'gnus-article-highlight
542 :group 'gnus-article-signature)
544 (defface gnus-signature-face
547 "Face used for highlighting a signature in the article buffer."
548 :group 'gnus-article-highlight
549 :group 'gnus-article-signature)
551 (defface gnus-header-from-face
554 (:foreground "spring green"))
557 (:foreground "red3"))
560 "Face used for displaying from headers."
561 :group 'gnus-article-headers
562 :group 'gnus-article-highlight)
564 (defface gnus-header-subject-face
567 (:foreground "SeaGreen3"))
570 (:foreground "red4"))
572 (:bold t :italic t)))
573 "Face used for displaying subject headers."
574 :group 'gnus-article-headers
575 :group 'gnus-article-highlight)
577 (defface gnus-header-newsgroups-face
580 (:foreground "yellow" :italic t))
583 (:foreground "MidnightBlue" :italic t))
586 "Face used for displaying newsgroups headers."
587 :group 'gnus-article-headers
588 :group 'gnus-article-highlight)
590 (defface gnus-header-name-face
593 (:foreground "SeaGreen"))
596 (:foreground "maroon"))
599 "Face used for displaying header names."
600 :group 'gnus-article-headers
601 :group 'gnus-article-highlight)
603 (defface gnus-header-content-face
606 (:foreground "forest green" :italic t))
609 (:foreground "indianred4" :italic t))
611 (:italic t))) "Face used for displaying header content."
612 :group 'gnus-article-headers
613 :group 'gnus-article-highlight)
615 (defcustom gnus-header-face-alist
616 '(("From" nil gnus-header-from-face)
617 ("Subject" nil gnus-header-subject-face)
618 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
619 ("" gnus-header-name-face gnus-header-content-face))
620 "*Controls highlighting of article header.
622 An alist of the form (HEADER NAME CONTENT).
624 HEADER is a regular expression which should match the name of an
625 header header and NAME and CONTENT are either face names or nil.
627 The name of each header field will be displayed using the face
628 specified by the first element in the list where HEADER match the
629 header name and NAME is non-nil. Similarly, the content will be
630 displayed by the first non-nil matching CONTENT face."
631 :group 'gnus-article-headers
632 :group 'gnus-article-highlight
633 :type '(repeat (list (regexp :tag "Header")
635 (item :tag "skip" nil)
636 (face :value default))
637 (choice :tag "Content"
638 (item :tag "skip" nil)
639 (face :value default)))))
641 (defcustom gnus-article-decode-hook
642 '(article-decode-charset article-decode-encoded-words
643 article-decode-group-name)
644 "*Hook run to decode charsets in articles."
645 :group 'gnus-article-headers
648 (defcustom gnus-display-mime-function 'gnus-display-mime
649 "Function to display MIME articles."
650 :group 'gnus-article-mime
653 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
654 "Function used to decode headers.")
656 (defvar gnus-article-dumbquotes-map
675 "Table for MS-to-Latin1 translation.")
677 (defcustom gnus-ignored-mime-types nil
678 "List of MIME types that should be ignored by Gnus."
680 :group 'gnus-article-mime
681 :type '(repeat regexp))
683 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
684 "List of MIME types that should not be given buttons when rendered inline.
685 See also `gnus-buttonized-mime-types' which may override this variable."
687 :group 'gnus-article-mime
688 :type '(repeat regexp))
690 (defcustom gnus-buttonized-mime-types nil
691 "List of MIME types that should be given buttons when rendered inline.
692 If set, this variable overrides `gnus-unbuttonized-mime-types'.
693 To see e.g. security buttons you could set this to
694 `(\"multipart/signed\")'."
696 :group 'gnus-article-mime
697 :type '(repeat regexp))
699 (defcustom gnus-body-boundary-delimiter "_"
700 "String used to delimit header and body.
701 This variable is used by `gnus-article-treat-body-boundary' which can
702 be controlled by `gnus-treat-body-boundary'."
703 :group 'gnus-article-various
704 :type '(choice (item :tag "None" :value nil)
707 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
708 "*Defines the location of the faces database.
709 For information on obtaining this database of pretty pictures, please
710 see http://www.cs.indiana.edu/picons/ftp/index.html"
714 (defun gnus-picons-installed-p ()
715 "Say whether picons are installed on your machine."
716 (let ((installed nil))
717 (dolist (database gnus-picon-databases)
718 (when (file-exists-p database)
722 (defcustom gnus-article-mime-part-function nil
723 "Function called with a MIME handle as the argument.
724 This is meant for people who want to do something automatic based
725 on parts -- for instance, adding Vcard info to a database."
726 :group 'gnus-article-mime
729 (defcustom gnus-mime-multipart-functions nil
730 "An alist of MIME types to functions to display them."
732 :group 'gnus-article-mime
735 (defcustom gnus-article-date-lapsed-new-header nil
736 "Whether the X-Sent and Date headers can coexist.
737 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
738 either replace the old \"Date:\" header (if this variable is nil), or
739 be added below it (otherwise)."
741 :group 'gnus-article-headers
744 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
745 "Function called with a MIME handle as the argument.
746 This is meant for people who want to view first matched part.
747 For `undisplayed-alternative' (default), the first undisplayed
748 part or alternative part is used. For `undisplayed', the first
749 undisplayed part is used. For a function, the first part which
750 the function return `t' is used. For `nil', the first part is
753 :group 'gnus-article-mime
755 (item :tag "first" :value nil)
756 (item :tag "undisplayed" :value undisplayed)
757 (item :tag "undisplayed or alternative"
758 :value undisplayed-alternative)
761 (defcustom gnus-mime-action-alist
762 '(("save to file" . gnus-mime-save-part)
763 ("save and strip" . gnus-mime-save-part-and-strip)
764 ("display as text" . gnus-mime-inline-part)
765 ("view the part" . gnus-mime-view-part)
766 ("pipe to command" . gnus-mime-pipe-part)
767 ("toggle display" . gnus-article-press-button)
768 ("toggle display" . gnus-article-view-part-as-charset)
769 ("view as type" . gnus-mime-view-part-as-type)
770 ("view internally" . gnus-mime-view-part-internally)
771 ("view externally" . gnus-mime-view-part-externally))
772 "An alist of actions that run on the MIME attachment."
773 :group 'gnus-article-mime
774 :type '(repeat (cons (string :tag "name")
778 ;;; The treatment variables
781 (defvar gnus-part-display-hook nil
782 "Hook called on parts that are to receive treatment.")
784 (defvar gnus-article-treat-custom
785 '(choice (const :tag "Off" nil)
787 (const :tag "Header" head)
788 (const :tag "Last" last)
789 (integer :tag "Less")
790 (repeat :tag "Groups" regexp)
791 (sexp :tag "Predicate")))
793 (defvar gnus-article-treat-head-custom
794 '(choice (const :tag "Off" nil)
795 (const :tag "Header" head)))
797 (defvar gnus-article-treat-types '("text/plain")
800 (defvar gnus-inhibit-treatment nil
801 "Whether to inhibit treatment.")
803 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
804 "Highlight the signature.
805 Valid values are nil, t, `head', `last', an integer or a predicate.
806 See Info node `(gnus)Customizing Articles'."
807 :group 'gnus-article-treat
808 :type gnus-article-treat-custom)
809 (put 'gnus-treat-highlight-signature 'highlight t)
811 (defcustom gnus-treat-buttonize 100000
813 Valid values are nil, t, `head', `last', an integer or a predicate.
814 See Info node `(gnus)Customizing Articles'."
815 :group 'gnus-article-treat
816 :type gnus-article-treat-custom)
817 (put 'gnus-treat-buttonize 'highlight t)
819 (defcustom gnus-treat-buttonize-head 'head
820 "Add buttons to the head.
821 Valid values are nil, t, `head', `last', an integer or a predicate.
822 See Info node `(gnus)Customizing Articles' for details."
823 :group 'gnus-article-treat
824 :type gnus-article-treat-head-custom)
825 (put 'gnus-treat-buttonize-head 'highlight t)
827 (defcustom gnus-treat-emphasize
828 (and (or window-system
830 (>= (string-to-number emacs-version) 21))
833 Valid values are nil, t, `head', `last', an integer or a predicate.
834 See Info node `(gnus)Customizing Articles' for details."
835 :group 'gnus-article-treat
836 :type gnus-article-treat-custom)
837 (put 'gnus-treat-emphasize 'highlight t)
839 (defcustom gnus-treat-strip-cr nil
840 "Remove carriage returns.
841 Valid values are nil, t, `head', `last', an integer or a predicate.
842 See Info node `(gnus)Customizing Articles' for details."
843 :group 'gnus-article-treat
844 :type gnus-article-treat-custom)
846 (defcustom gnus-treat-unsplit-urls nil
847 "Remove newlines from within URLs.
848 Valid values are nil, t, `head', `last', an integer or a predicate.
849 See Info node `(gnus)Customizing Articles' for details."
850 :group 'gnus-article-treat
851 :type gnus-article-treat-custom)
853 (defcustom gnus-treat-leading-whitespace nil
854 "Remove leading whitespace in headers.
855 Valid values are nil, t, `head', `last', an integer or a predicate.
856 See Info node `(gnus)Customizing Articles' for details."
857 :group 'gnus-article-treat
858 :type gnus-article-treat-custom)
860 (defcustom gnus-treat-hide-headers 'head
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See Info node `(gnus)Customizing Articles' for details."
864 :group 'gnus-article-treat
865 :type gnus-article-treat-head-custom)
867 (defcustom gnus-treat-hide-boring-headers nil
868 "Hide boring headers.
869 Valid values are nil, t, `head', `last', an integer or a predicate.
870 See Info node `(gnus)Customizing Articles' for details."
871 :group 'gnus-article-treat
872 :type gnus-article-treat-head-custom)
874 (defcustom gnus-treat-hide-signature nil
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles' for details."
878 :group 'gnus-article-treat
879 :type gnus-article-treat-custom)
881 (defcustom gnus-treat-fill-article nil
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See Info node `(gnus)Customizing Articles' for details."
885 :group 'gnus-article-treat
886 :type gnus-article-treat-custom)
888 (defcustom gnus-treat-hide-citation nil
890 Valid values are nil, t, `head', `last', an integer or a predicate.
891 See Info node `(gnus)Customizing Articles' for details."
892 :group 'gnus-article-treat
893 :type gnus-article-treat-custom)
895 (defcustom gnus-treat-hide-citation-maybe nil
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See Info node `(gnus)Customizing Articles' for details."
899 :group 'gnus-article-treat
900 :type gnus-article-treat-custom)
902 (defcustom gnus-treat-strip-list-identifiers 'head
903 "Strip list identifiers from `gnus-list-identifiers`.
904 Valid values are nil, t, `head', `last', an integer or a predicate.
905 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :type gnus-article-treat-custom)
910 (defcustom gnus-treat-strip-pgp t
911 "Strip PGP signatures.
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-custom)
917 (defcustom gnus-treat-strip-pem nil
918 "Strip PEM signatures.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See Info node `(gnus)Customizing Articles' for details."
921 :group 'gnus-article-treat
922 :type gnus-article-treat-custom)
924 (defcustom gnus-treat-strip-banner t
925 "Strip banners from articles.
926 The banner to be stripped is specified in the `banner' group parameter.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-custom)
932 (defcustom gnus-treat-highlight-headers 'head
933 "Highlight the headers.
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See Info node `(gnus)Customizing Articles' for details."
936 :group 'gnus-article-treat
937 :type gnus-article-treat-head-custom)
938 (put 'gnus-treat-highlight-headers 'highlight t)
940 (defcustom gnus-treat-highlight-citation t
941 "Highlight cited text.
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :type gnus-article-treat-custom)
946 (put 'gnus-treat-highlight-citation 'highlight t)
948 (defcustom gnus-treat-date-ut nil
949 "Display the Date in UT (GMT).
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-head-custom)
955 (defcustom gnus-treat-date-local nil
956 "Display the Date in the local timezone.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :type gnus-article-treat-head-custom)
962 (defcustom gnus-treat-date-english nil
963 "Display the Date in a format that can be read aloud in English.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles' for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-head-custom)
969 (defcustom gnus-treat-date-lapsed nil
970 "Display the Date header in a way that says how much time has elapsed.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :type gnus-article-treat-head-custom)
976 (defcustom gnus-treat-date-original nil
977 "Display the date in the original timezone.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles' for details."
980 :group 'gnus-article-treat
981 :type gnus-article-treat-head-custom)
983 (defcustom gnus-treat-date-iso8601 nil
984 "Display the date in the ISO8601 format.
985 Valid values are nil, t, `head', `last', an integer or a predicate.
986 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :type gnus-article-treat-head-custom)
991 (defcustom gnus-treat-date-user-defined nil
992 "Display the date in a user-defined format.
993 The format is defined by the `gnus-article-time-format' variable.
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :type gnus-article-treat-head-custom)
999 (defcustom gnus-treat-strip-headers-in-body t
1000 "Strip the X-No-Archive header line from the beginning of the body.
1001 Valid values are nil, t, `head', `last', an integer or a predicate.
1002 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :type gnus-article-treat-custom)
1007 (defcustom gnus-treat-strip-trailing-blank-lines nil
1008 "Strip trailing blank lines.
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-custom)
1014 (defcustom gnus-treat-strip-leading-blank-lines nil
1015 "Strip leading blank lines.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :type gnus-article-treat-custom)
1021 (defcustom gnus-treat-strip-multiple-blank-lines nil
1022 "Strip multiple blank lines.
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-unfold-headers 'head
1029 "Unfold folded header lines.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :type gnus-article-treat-custom)
1035 (defcustom gnus-treat-fold-headers nil
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1039 :group 'gnus-article-treat
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-fold-newsgroups 'head
1043 "Fold the Newsgroups and Followup-To headers.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-custom)
1049 (defcustom gnus-treat-overstrike t
1050 "Treat overstrike highlighting.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :type gnus-article-treat-custom)
1055 (put 'gnus-treat-overstrike 'highlight t)
1057 (defcustom gnus-treat-display-xface
1058 (and (not noninteractive)
1059 (or (and (fboundp 'image-type-available-p)
1060 (image-type-available-p 'xbm)
1061 (string-match "^0x" (shell-command-to-string "uncompface")))
1062 (and (featurep 'xemacs)
1065 "Display X-Face headers.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' and Info node
1068 `(gnus)X-Face' for details."
1069 :group 'gnus-article-treat
1071 :type gnus-article-treat-head-custom)
1072 (put 'gnus-treat-display-xface 'highlight t)
1074 (defcustom gnus-treat-display-grey-xface
1075 (and (not noninteractive)
1076 (string-match "^0x" (shell-command-to-string "uncompface"))
1078 "Display grey X-Face headers.
1079 Valid values are nil, t."
1080 :group 'gnus-article-treat
1083 (put 'gnus-treat-display-grey-xface 'highlight t)
1085 (defcustom gnus-treat-display-smileys
1086 (if (or (and (featurep 'xemacs)
1088 (and (fboundp 'image-type-available-p)
1089 (image-type-available-p 'pbm)))
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' and Info node
1094 `(gnus)Smileys' for details."
1095 :group 'gnus-article-treat
1097 :type gnus-article-treat-custom)
1098 (put 'gnus-treat-display-smileys 'highlight t)
1100 (defcustom gnus-treat-from-picon
1101 (if (and (gnus-image-type-available-p 'xpm)
1102 (gnus-picons-installed-p))
1104 "Display picons in the From header.
1105 Valid values are nil, t, `head', `last', an integer or a predicate.
1106 See Info node `(gnus)Customizing Articles' and Info node
1107 `(gnus)Picons' for details."
1108 :group 'gnus-article-treat
1109 :type gnus-article-treat-head-custom)
1110 (put 'gnus-treat-from-picon 'highlight t)
1112 (defcustom gnus-treat-mail-picon
1113 (if (and (gnus-image-type-available-p 'xpm)
1114 (gnus-picons-installed-p))
1116 "Display picons in To and Cc headers.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' and Info node
1119 `(gnus)Picons' for details."
1120 :group 'gnus-article-treat
1121 :type gnus-article-treat-head-custom)
1122 (put 'gnus-treat-mail-picon 'highlight t)
1124 (defcustom gnus-treat-newsgroups-picon
1125 (if (and (gnus-image-type-available-p 'xpm)
1126 (gnus-picons-installed-p))
1128 "Display picons in the Newsgroups and Followup-To headers.
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' and Info node
1131 `(gnus)Picons' for details."
1132 :group 'gnus-article-treat
1133 :type gnus-article-treat-head-custom)
1134 (put 'gnus-treat-newsgroups-picon 'highlight t)
1136 (defcustom gnus-treat-body-boundary
1137 (if (or gnus-treat-newsgroups-picon
1138 gnus-treat-mail-picon
1139 gnus-treat-from-picon)
1141 "Draw a boundary at the end of the headers.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :type gnus-article-treat-custom)
1148 (defcustom gnus-treat-capitalize-sentences nil
1149 "Capitalize sentence-starting words.
1150 Valid values are nil, t, `head', `last', an integer or a predicate.
1151 See Info node `(gnus)Customizing Articles' for details."
1153 :group 'gnus-article-treat
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-fill-long-lines nil
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' for details."
1160 :group 'gnus-article-treat
1161 :type gnus-article-treat-custom)
1163 (defcustom gnus-treat-play-sounds nil
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1168 :group 'gnus-article-treat
1169 :type gnus-article-treat-custom)
1171 (defcustom gnus-treat-translate nil
1172 "Translate articles from one language to another.
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1176 :group 'gnus-article-treat
1177 :type gnus-article-treat-custom)
1179 (defcustom gnus-treat-x-pgp-sig nil
1181 To automatically treat X-PGP-Sig, set it to head.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1184 :group 'gnus-article-treat
1185 :group 'mime-security
1186 :type gnus-article-treat-custom)
1188 (defvar gnus-article-encrypt-protocol-alist
1189 '(("PGP" . mml2015-self-encrypt)))
1191 ;; Set to nil if more than one protocol added to
1192 ;; gnus-article-encrypt-protocol-alist.
1193 (defcustom gnus-article-encrypt-protocol "PGP"
1194 "The protocol used for encrypt articles.
1195 It is a string, such as \"PGP\". If nil, ask user."
1197 :group 'mime-security)
1199 (defvar gnus-article-wash-function nil
1200 "Function used for converting HTML into text.")
1202 ;;; Internal variables
1204 (defvar gnus-english-month-names
1205 '("January" "February" "March" "April" "May" "June" "July" "August"
1206 "September" "October" "November" "December"))
1208 (defvar article-goto-body-goes-to-point-min-p nil)
1209 (defvar gnus-article-wash-types nil)
1210 (defvar gnus-article-emphasis-alist nil)
1211 (defvar gnus-article-image-alist nil)
1213 (defvar gnus-article-mime-handle-alist-1 nil)
1214 (defvar gnus-treatment-function-alist
1215 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1216 (gnus-treat-strip-banner gnus-article-strip-banner)
1217 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1218 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1219 (gnus-treat-buttonize gnus-article-add-buttons)
1220 (gnus-treat-fill-article gnus-article-fill-cited-article)
1221 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1222 (gnus-treat-strip-cr gnus-article-remove-cr)
1223 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1224 (gnus-treat-date-ut gnus-article-date-ut)
1225 (gnus-treat-date-local gnus-article-date-local)
1226 (gnus-treat-date-english gnus-article-date-english)
1227 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1228 (gnus-treat-date-original gnus-article-date-original)
1229 (gnus-treat-date-user-defined gnus-article-date-user)
1230 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1231 (gnus-treat-display-xface gnus-article-display-x-face)
1232 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1233 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1234 (gnus-treat-hide-signature gnus-article-hide-signature)
1235 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1236 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1237 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1238 (gnus-treat-strip-pem gnus-article-hide-pem)
1239 (gnus-treat-from-picon gnus-treat-from-picon)
1240 (gnus-treat-mail-picon gnus-treat-mail-picon)
1241 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1242 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1243 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1244 (gnus-treat-strip-trailing-blank-lines
1245 gnus-article-remove-trailing-blank-lines)
1246 (gnus-treat-strip-leading-blank-lines
1247 gnus-article-strip-leading-blank-lines)
1248 (gnus-treat-strip-multiple-blank-lines
1249 gnus-article-strip-multiple-blank-lines)
1250 (gnus-treat-overstrike gnus-article-treat-overstrike)
1251 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1252 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1253 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1254 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1255 (gnus-treat-display-smileys gnus-treat-smiley)
1256 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1257 (gnus-treat-emphasize gnus-article-emphasize)
1258 (gnus-treat-hide-citation gnus-article-hide-citation)
1259 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1260 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1261 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1262 (gnus-treat-play-sounds gnus-earcon-display)))
1264 (defvar gnus-article-mime-handle-alist nil)
1265 (defvar article-lapsed-timer nil)
1266 (defvar gnus-article-current-summary nil)
1268 (defvar gnus-article-mode-syntax-table
1269 (let ((table (copy-syntax-table text-mode-syntax-table)))
1270 ;; This causes the citation match run O(2^n).
1271 ;; (modify-syntax-entry ?- "w" table)
1272 (modify-syntax-entry ?> ")" table)
1273 (modify-syntax-entry ?< "(" table)
1275 "Syntax table used in article mode buffers.
1276 Initialized from `text-mode-syntax-table.")
1278 (defvar gnus-save-article-buffer nil)
1280 (defvar gnus-article-mode-line-format-alist
1281 (nconc '((?w (gnus-article-wash-status) ?s)
1282 (?m (gnus-article-mime-part-status) ?s))
1283 gnus-summary-mode-line-format-alist))
1285 (defvar gnus-number-of-articles-to-be-saved nil)
1287 (defvar gnus-inhibit-hiding nil)
1289 ;;; Macros for dealing with the article buffer.
1291 (defmacro gnus-with-article-headers (&rest forms)
1293 (set-buffer gnus-article-buffer)
1295 (let ((buffer-read-only nil)
1296 (inhibit-point-motion-hooks t)
1297 (case-fold-search t))
1298 (article-narrow-to-head)
1301 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1302 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1304 (defmacro gnus-with-article-buffer (&rest forms)
1306 (set-buffer gnus-article-buffer)
1307 (let ((buffer-read-only nil))
1310 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1311 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1313 (defun gnus-article-goto-header (header)
1314 "Go to HEADER, which is a regular expression."
1315 (re-search-forward (concat "^\\(" header "\\):") nil t))
1317 (defsubst gnus-article-hide-text (b e props)
1318 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1319 (gnus-add-text-properties-when 'article-type nil b e props)
1320 (when (memq 'intangible props)
1322 (max (1- b) (point-min))
1323 b 'intangible (cddr (memq 'intangible props)))))
1325 (defsubst gnus-article-unhide-text (b e)
1326 "Remove hidden text properties from region between B and E."
1327 (remove-text-properties b e gnus-hidden-properties)
1328 (when (memq 'intangible gnus-hidden-properties)
1329 (put-text-property (max (1- b) (point-min))
1330 b 'intangible nil)))
1332 (defun gnus-article-hide-text-type (b e type)
1333 "Hide text of TYPE between B and E."
1334 (gnus-add-wash-type type)
1335 (gnus-article-hide-text
1336 b e (cons 'article-type (cons type gnus-hidden-properties))))
1338 (defun gnus-article-unhide-text-type (b e type)
1339 "Unhide text of TYPE between B and E."
1340 (gnus-delete-wash-type type)
1341 (remove-text-properties
1342 b e (cons 'article-type (cons type gnus-hidden-properties)))
1343 (when (memq 'intangible gnus-hidden-properties)
1344 (put-text-property (max (1- b) (point-min))
1345 b 'intangible nil)))
1347 (defun gnus-article-hide-text-of-type (type)
1348 "Hide text of TYPE in the current buffer."
1350 (let ((b (point-min))
1352 (while (setq b (text-property-any b e 'article-type type))
1353 (add-text-properties b (incf b) gnus-hidden-properties)))))
1355 (defun gnus-article-delete-text-of-type (type)
1356 "Delete text of TYPE in the current buffer."
1358 (let ((b (point-min)))
1359 (while (setq b (text-property-any b (point-max) 'article-type type))
1361 b (or (text-property-not-all b (point-max) 'article-type type)
1364 (defun gnus-article-delete-invisible-text ()
1365 "Delete all invisible text in the current buffer."
1367 (let ((b (point-min)))
1368 (while (setq b (text-property-any b (point-max) 'invisible t))
1370 b (or (text-property-not-all b (point-max) 'invisible t)
1373 (defun gnus-article-text-type-exists-p (type)
1374 "Say whether any text of type TYPE exists in the buffer."
1375 (text-property-any (point-min) (point-max) 'article-type type))
1377 (defsubst gnus-article-header-rank ()
1378 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1379 (let ((list gnus-sorted-header-list)
1382 (when (looking-at (car list))
1384 (setq list (cdr list))
1388 (defun article-hide-headers (&optional arg delete)
1389 "Hide unwanted headers and possibly sort them as well."
1391 ;; This function might be inhibited.
1392 (unless gnus-inhibit-hiding
1395 (let ((buffer-read-only nil)
1396 (case-fold-search t)
1397 (max (1+ (length gnus-sorted-header-list)))
1398 (ignored (when (not gnus-visible-headers)
1399 (cond ((stringp gnus-ignored-headers)
1400 gnus-ignored-headers)
1401 ((listp gnus-ignored-headers)
1402 (mapconcat 'identity gnus-ignored-headers
1405 (cond ((stringp gnus-visible-headers)
1406 gnus-visible-headers)
1407 ((and gnus-visible-headers
1408 (listp gnus-visible-headers))
1409 (mapconcat 'identity gnus-visible-headers "\\|"))))
1410 (inhibit-point-motion-hooks t)
1412 ;; First we narrow to just the headers.
1413 (article-narrow-to-head)
1414 ;; Hide any "From " lines at the beginning of (mail) articles.
1415 (while (looking-at "From ")
1418 (delete-region (point-min) (point)))
1419 ;; Then treat the rest of the header lines.
1420 ;; Then we use the two regular expressions
1421 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1422 ;; select which header lines is to remain visible in the
1424 (while (re-search-forward "^[^ \t:]*:" nil t)
1426 ;; Mark the rank of the header.
1428 (point) (1+ (point)) 'message-rank
1429 (if (or (and visible (looking-at visible))
1431 (not (looking-at ignored))))
1432 (gnus-article-header-rank)
1435 (message-sort-headers-1)
1436 (when (setq beg (text-property-any
1437 (point-min) (point-max) 'message-rank (+ 2 max)))
1438 ;; We delete the unwanted headers.
1439 (gnus-add-wash-type 'headers)
1440 (add-text-properties (point-min) (+ 5 (point-min))
1441 '(article-type headers dummy-invisible t))
1442 (delete-region beg (point-max))))))))
1444 (defun article-hide-boring-headers (&optional arg)
1445 "Toggle hiding of headers that aren't very interesting.
1446 If given a negative prefix, always show; if given a positive prefix,
1448 (interactive (gnus-article-hidden-arg))
1449 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1450 (not gnus-show-all-headers))
1453 (let ((buffer-read-only nil)
1454 (list gnus-boring-article-headers)
1455 (inhibit-point-motion-hooks t)
1457 (article-narrow-to-head)
1459 (setq elem (pop list))
1460 (goto-char (point-min))
1462 ;; Hide empty headers.
1464 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1466 (gnus-article-hide-text-type
1467 (progn (beginning-of-line) (point))
1470 (if (re-search-forward "^[^ \t]" nil t)
1474 ;; Hide boring Newsgroups header.
1475 ((eq elem 'newsgroups)
1476 (when (gnus-string-equal
1477 (gnus-fetch-field "newsgroups")
1478 (gnus-group-real-name
1479 (if (boundp 'gnus-newsgroup-name)
1482 (gnus-article-hide-header "newsgroups")))
1483 ((eq elem 'to-address)
1484 (let ((to (message-fetch-field "to"))
1486 (gnus-parameter-to-address
1487 (if (boundp 'gnus-newsgroup-name)
1488 gnus-newsgroup-name ""))))
1489 (when (and to to-address
1492 ;; only one address in To
1493 (nth 1 (mail-extract-address-components to))
1495 (gnus-article-hide-header "to"))))
1496 ((eq elem 'followup-to)
1497 (when (gnus-string-equal
1498 (message-fetch-field "followup-to")
1499 (message-fetch-field "newsgroups"))
1500 (gnus-article-hide-header "followup-to")))
1501 ((eq elem 'reply-to)
1502 (let ((from (message-fetch-field "from"))
1503 (reply-to (message-fetch-field "reply-to")))
1508 (nth 1 (mail-extract-address-components from))
1509 (nth 1 (mail-extract-address-components reply-to)))))
1510 (gnus-article-hide-header "reply-to"))))
1512 (let ((date (message-fetch-field "date")))
1514 (< (days-between (current-time-string) date)
1516 (gnus-article-hide-header "date"))))
1518 (let ((to (message-fetch-field "to"))
1519 (cc (message-fetch-field "cc")))
1520 (when (> (length to) 1024)
1521 (gnus-article-hide-header "to"))
1522 (when (> (length cc) 1024)
1523 (gnus-article-hide-header "cc"))))
1527 (goto-char (point-min))
1528 (while (re-search-forward "^to:" nil t)
1529 (setq to-count (1+ to-count)))
1530 (when (> to-count 1)
1531 (while (> to-count 0)
1532 (goto-char (point-min))
1534 (re-search-forward "^to:" nil nil to-count)
1536 (narrow-to-region (point) (point-max))
1537 (gnus-article-hide-header "to"))
1538 (setq to-count (1- to-count))))
1539 (goto-char (point-min))
1540 (while (re-search-forward "^cc:" nil t)
1541 (setq cc-count (1+ cc-count)))
1542 (when (> cc-count 1)
1543 (while (> cc-count 0)
1544 (goto-char (point-min))
1546 (re-search-forward "^cc:" nil nil cc-count)
1548 (narrow-to-region (point) (point-max))
1549 (gnus-article-hide-header "cc"))
1550 (setq cc-count (1- cc-count)))))))))))))
1552 (defun gnus-article-hide-header (header)
1554 (goto-char (point-min))
1555 (when (re-search-forward (concat "^" header ":") nil t)
1556 (gnus-article-hide-text-type
1557 (progn (beginning-of-line) (point))
1560 (if (re-search-forward "^[^ \t]" nil t)
1565 (defvar gnus-article-normalized-header-length 40
1566 "Length of normalized headers.")
1568 (defun article-normalize-headers ()
1569 "Make all header lines 40 characters long."
1571 (let ((buffer-read-only nil)
1575 (article-narrow-to-head)
1578 ((< (setq column (- (gnus-point-at-eol) (point)))
1579 gnus-article-normalized-header-length)
1581 (insert (make-string
1582 (- gnus-article-normalized-header-length column)
1584 ((> column gnus-article-normalized-header-length)
1585 (gnus-put-text-property
1587 (forward-char gnus-article-normalized-header-length)
1594 (forward-line 1))))))
1596 (defun article-treat-dumbquotes ()
1597 "Translate M****s*** sm*rtq**t*s into proper text.
1598 Note that this function guesses whether a character is a sm*rtq**t* or
1599 not, so it should only be used interactively.
1601 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1602 in an attempt to provide more quoting characters. If you see
1603 something like \\222 or \\264 where you're expecting some kind of
1604 apostrophe or quotation mark, then try this wash."
1606 (article-translate-strings gnus-article-dumbquotes-map))
1608 (defun article-translate-characters (from to)
1609 "Translate all characters in the body of the article according to FROM and TO.
1610 FROM is a string of characters to translate from; to is a string of
1611 characters to translate to."
1613 (when (article-goto-body)
1614 (let ((buffer-read-only nil)
1615 (x (make-string 225 ?x))
1617 (while (< (incf i) (length x))
1620 (while (< i (length from))
1621 (aset x (aref from i) (aref to i))
1623 (translate-region (point) (point-max) x)))))
1625 (defun article-translate-strings (map)
1626 "Translate all string in the body of the article according to MAP.
1627 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1629 (when (article-goto-body)
1630 (let ((buffer-read-only nil)
1632 (while (setq elem (pop map))
1634 (while (search-forward (car elem) nil t)
1635 (replace-match (cadr elem)))))))))
1637 (defun article-treat-overstrike ()
1638 "Translate overstrikes into bold text."
1641 (when (article-goto-body)
1642 (let ((buffer-read-only nil))
1643 (while (search-forward "\b" nil t)
1644 (let ((next (char-after))
1645 (previous (char-after (- (point) 2))))
1646 ;; We do the boldification/underlining by hiding the
1647 ;; overstrikes and putting the proper text property
1651 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1652 (put-text-property (point) (1+ (point)) 'face 'bold))
1654 (gnus-article-hide-text-type
1655 (1- (point)) (1+ (point)) 'overstrike)
1657 (- (point) 2) (1- (point)) 'face 'underline))
1659 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1661 (point) (1+ (point)) 'face 'underline)))))))))
1663 (defun gnus-article-treat-unfold-headers ()
1664 "Unfold folded message headers.
1665 Only the headers that fit into the current window width will be
1668 (gnus-with-article-headers
1672 (mail-header-narrow-to-field)
1673 (let ((header (buffer-substring (point-min) (point-max))))
1676 (goto-char (point-min))
1677 (while (re-search-forward "\n[\t ]" nil t)
1678 (replace-match " " t t)))
1679 (setq length (- (point-max) (point-min) 1)))
1680 (when (< length (window-width))
1681 (while (re-search-forward "\n[\t ]" nil t)
1682 (replace-match " " t t)))
1683 (goto-char (point-max)))))))
1685 (defun gnus-article-treat-fold-headers ()
1686 "Fold message headers."
1688 (gnus-with-article-headers
1691 (mail-header-narrow-to-field)
1692 (mail-header-fold-field)
1693 (goto-char (point-max))))))
1695 (defun gnus-treat-smiley ()
1696 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1698 (gnus-with-article-buffer
1699 (if (memq 'smiley gnus-article-wash-types)
1700 (gnus-delete-images 'smiley)
1702 (let ((images (smiley-region (point) (point-max))))
1704 (gnus-add-wash-type 'smiley)
1705 (dolist (image images)
1706 (gnus-add-image 'smiley image)))))))
1708 (defun gnus-article-remove-images ()
1709 "Remove all images from the article buffer."
1711 (gnus-with-article-buffer
1712 (dolist (elem gnus-article-image-alist)
1713 (gnus-delete-images (car elem)))))
1715 (defun gnus-article-treat-fold-newsgroups ()
1716 "Unfold folded message headers.
1717 Only the headers that fit into the current window width will be
1720 (gnus-with-article-headers
1721 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1723 (mail-header-narrow-to-field)
1724 (while (re-search-forward ", *" nil t)
1725 (replace-match ", " t t))
1726 (mail-header-fold-field)
1727 (goto-char (point-max))))))
1729 (defun gnus-article-treat-body-boundary ()
1730 "Place a boundary line at the end of the headers."
1732 (when (and gnus-body-boundary-delimiter
1733 (> (length gnus-body-boundary-delimiter) 0))
1734 (gnus-with-article-headers
1735 (goto-char (point-max))
1736 (let ((start (point)))
1737 (insert "X-Boundary: ")
1738 (gnus-add-text-properties start (point) '(invisible t intangible t))
1740 (while (>= (1- (window-width)) (length str))
1741 (setq str (concat str gnus-body-boundary-delimiter)))
1742 (substring str 0 (1- (window-width))))
1744 (gnus-add-text-properties start (point) '(gnus-decoration 'header))))))
1746 (defun article-fill-long-lines ()
1747 "Fill lines that are wider than the window width."
1750 (let ((buffer-read-only nil)
1751 (width (window-width (get-buffer-window (current-buffer)))))
1754 (let ((adaptive-fill-mode nil)) ;Why? -sm
1757 (when (>= (current-column) (min fill-column width))
1758 (narrow-to-region (point) (gnus-point-at-bol))
1759 (fill-paragraph nil)
1760 (goto-char (point-max))
1762 (forward-line 1)))))))
1764 (defun article-capitalize-sentences ()
1765 "Capitalize the first word in each sentence."
1768 (let ((buffer-read-only nil)
1769 (paragraph-start "^[\n\^L]"))
1773 (forward-sentence)))))
1775 (defun article-remove-cr ()
1776 "Remove trailing CRs and then translate remaining CRs into LFs."
1779 (let ((buffer-read-only nil))
1780 (goto-char (point-min))
1781 (while (re-search-forward "\r+$" nil t)
1782 (replace-match "" t t))
1783 (goto-char (point-min))
1784 (while (search-forward "\r" nil t)
1785 (replace-match "\n" t t)))))
1787 (defun article-remove-trailing-blank-lines ()
1788 "Remove all trailing blank lines from the article."
1791 (let ((buffer-read-only nil))
1792 (goto-char (point-max))
1796 (while (and (not (bobp))
1797 (looking-at "^[ \t]*$")
1798 (not (gnus-annotation-in-region-p
1799 (point) (gnus-point-at-eol))))
1804 (defun article-display-x-face (&optional force)
1805 "Look for an X-Face header and display it if present."
1806 (interactive (list 'force))
1807 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1808 (gnus-with-article-headers
1809 ;; Delete the old process, if any.
1810 (when (process-status "article-x-face")
1811 (delete-process "article-x-face"))
1812 (if (memq 'xface gnus-article-wash-types)
1813 ;; We have already displayed X-Faces, so we remove them
1815 (gnus-delete-images 'xface)
1817 (let (x-faces from face grey)
1819 (when (and wash-face-p
1821 (goto-char (point-min))
1822 (not (re-search-forward
1823 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1824 (gnus-buffer-live-p gnus-original-article-buffer))
1825 ;; If type `W f', use gnus-original-article-buffer,
1826 ;; otherwise use the current buffer because displaying
1827 ;; RFC822 parts calls this function too.
1828 (set-buffer gnus-original-article-buffer))
1830 (mail-narrow-to-head)
1831 (if gnus-treat-display-grey-xface
1833 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1834 (if (match-beginning 2)
1837 (push (cons (- (string-to-number (match-string 2)))
1838 (mail-header-field-value))
1840 (push (cons 0 (mail-header-field-value)) x-faces)))
1841 (dolist (x-face (prog1
1843 (sort x-faces 'car-less-than-car)
1845 (setq x-faces nil)))
1846 (push (cdr x-face) x-faces)))
1847 (while (gnus-article-goto-header "X-Face")
1848 (push (mail-header-field-value) x-faces)))
1849 (setq from (message-fetch-field "from"))))
1851 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1854 (setq image (gnus-create-image xpm 'xpm t))
1855 (gnus-article-goto-header "from")
1857 (insert "From: [no `from' set]\n")
1859 (gnus-add-wash-type 'xface)
1860 (gnus-add-image 'xface image)
1861 (gnus-put-image image)))
1862 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1863 ;; single external face.
1864 (when (stringp gnus-article-x-face-command)
1865 (setq x-faces (list (car x-faces))))
1866 (while (and (setq face (pop x-faces))
1867 gnus-article-x-face-command
1869 ;; Check whether this face is censored.
1870 (not gnus-article-x-face-too-ugly)
1871 (and gnus-article-x-face-too-ugly from
1872 (not (string-match gnus-article-x-face-too-ugly
1874 ;; We display the face.
1875 (if (symbolp gnus-article-x-face-command)
1876 ;; The command is a lisp function, so we call it.
1877 (if (gnus-functionp gnus-article-x-face-command)
1878 (funcall gnus-article-x-face-command face)
1879 (error "%s is not a function" gnus-article-x-face-command))
1880 ;; The command is a string, so we interpret the command
1881 ;; as a, well, command, and fork it off.
1882 (let ((process-connection-type nil))
1883 (process-kill-without-query
1885 "article-x-face" nil shell-file-name shell-command-switch
1886 gnus-article-x-face-command))
1889 (process-send-region "article-x-face"
1890 (point-min) (point-max)))
1891 (process-send-eof "article-x-face"))))))))))
1893 (defun article-decode-mime-words ()
1894 "Decode all MIME-encoded words in the article."
1897 (set-buffer gnus-article-buffer)
1898 (let ((inhibit-point-motion-hooks t)
1900 (mail-parse-charset gnus-newsgroup-charset)
1901 (mail-parse-ignored-charsets
1902 (save-excursion (set-buffer gnus-summary-buffer)
1903 gnus-newsgroup-ignored-charsets)))
1904 (mail-decode-encoded-word-region (point-min) (point-max)))))
1906 (defun article-decode-charset (&optional prompt)
1907 "Decode charset-encoded text in the article.
1908 If PROMPT (the prefix), prompt for a coding system to use."
1910 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1912 (mail-parse-charset gnus-newsgroup-charset)
1913 (mail-parse-ignored-charsets
1914 (save-excursion (condition-case nil
1915 (set-buffer gnus-summary-buffer)
1917 gnus-newsgroup-ignored-charsets))
1918 ct cte ctl charset format)
1921 (article-narrow-to-head)
1922 (setq ct (message-fetch-field "Content-Type" t)
1923 cte (message-fetch-field "Content-Transfer-Encoding" t)
1924 ctl (and ct (ignore-errors
1925 (mail-header-parse-content-type ct)))
1928 (mm-read-coding-system "Charset to decode: "))
1930 (mail-content-type-get ctl 'charset)))
1931 format (and ctl (mail-content-type-get ctl 'format)))
1933 (setq cte (mail-header-strip cte)))
1934 (if (and ctl (not (string-match "/" (car ctl))))
1936 (goto-char (point-max)))
1939 (narrow-to-region (point) (point-max))
1940 (when (and (eq mail-parse-charset 'gnus-decoded)
1941 (eq (mm-body-7-or-8) '8bit))
1942 ;; The text code could have been decoded.
1943 (setq charset mail-parse-charset))
1944 (when (and (or (not ctl)
1945 (equal (car ctl) "text/plain"))
1946 (not format)) ;; article with format will decode later.
1948 charset (and cte (intern (downcase
1949 (gnus-strip-whitespace cte))))
1952 (defun article-decode-encoded-words ()
1953 "Remove encoded-word encoding from headers."
1954 (let ((inhibit-point-motion-hooks t)
1955 (mail-parse-charset gnus-newsgroup-charset)
1956 (mail-parse-ignored-charsets
1957 (save-excursion (condition-case nil
1958 (set-buffer gnus-summary-buffer)
1960 gnus-newsgroup-ignored-charsets))
1963 (article-narrow-to-head)
1964 (funcall gnus-decode-header-function (point-min) (point-max)))))
1966 (defun article-decode-group-name ()
1967 "Decode group names in `Newsgroups:'."
1968 (let ((inhibit-point-motion-hooks t)
1970 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1971 (when (and (or gnus-group-name-charset-method-alist
1972 gnus-group-name-charset-group-alist)
1973 (gnus-buffer-live-p gnus-original-article-buffer))
1974 (when (nnmail-fetch-field "Newsgroups")
1975 (nnheader-replace-header "Newsgroups"
1976 (gnus-decode-newsgroups
1977 (with-current-buffer
1978 gnus-original-article-buffer
1979 (nnmail-fetch-field "Newsgroups"))
1980 gnus-newsgroup-name method)))
1981 (when (nnmail-fetch-field "Followup-To")
1982 (nnheader-replace-header "Followup-To"
1983 (gnus-decode-newsgroups
1984 (with-current-buffer
1985 gnus-original-article-buffer
1986 (nnmail-fetch-field "Followup-To"))
1987 gnus-newsgroup-name method))))))
1989 (defun article-de-quoted-unreadable (&optional force read-charset)
1990 "Translate a quoted-printable-encoded article.
1991 If FORCE, decode the article whether it is marked as quoted-printable
1993 If READ-CHARSET, ask for a coding system."
1994 (interactive (list 'force current-prefix-arg))
1996 (let ((buffer-read-only nil) type charset)
1997 (if (gnus-buffer-live-p gnus-original-article-buffer)
1998 (with-current-buffer gnus-original-article-buffer
2000 (gnus-fetch-field "content-transfer-encoding"))
2001 (let* ((ct (gnus-fetch-field "content-type"))
2004 (mail-header-parse-content-type ct)))))
2005 (setq charset (and ctl
2006 (mail-content-type-get ctl 'charset)))
2007 (if (stringp charset)
2008 (setq charset (intern (downcase charset)))))))
2010 (setq charset (mm-read-coding-system "Charset: " charset)))
2012 (setq charset gnus-newsgroup-charset))
2014 (and type (let ((case-fold-search t))
2015 (string-match "quoted-printable" type))))
2017 (quoted-printable-decode-region
2018 (point) (point-max) (mm-charset-to-coding-system charset))))))
2020 (defun article-de-base64-unreadable (&optional force read-charset)
2021 "Translate a base64 article.
2022 If FORCE, decode the article whether it is marked as base64 not.
2023 If READ-CHARSET, ask for a coding system."
2024 (interactive (list 'force current-prefix-arg))
2026 (let ((buffer-read-only nil) type charset)
2027 (if (gnus-buffer-live-p gnus-original-article-buffer)
2028 (with-current-buffer gnus-original-article-buffer
2030 (gnus-fetch-field "content-transfer-encoding"))
2031 (let* ((ct (gnus-fetch-field "content-type"))
2034 (mail-header-parse-content-type ct)))))
2035 (setq charset (and ctl
2036 (mail-content-type-get ctl 'charset)))
2037 (if (stringp charset)
2038 (setq charset (intern (downcase charset)))))))
2040 (setq charset (mm-read-coding-system "Charset: " charset)))
2042 (setq charset gnus-newsgroup-charset))
2044 (and type (let ((case-fold-search t))
2045 (string-match "base64" type))))
2048 (narrow-to-region (point) (point-max))
2049 (base64-decode-region (point-min) (point-max))
2050 (mm-decode-coding-region
2051 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2056 (defun article-decode-HZ ()
2057 "Translate a HZ-encoded article."
2061 (let ((buffer-read-only nil))
2062 (rfc1843-decode-region (point-min) (point-max)))))
2064 (defun article-unsplit-urls ()
2065 "Remove the newlines that some other mailers insert into URLs."
2068 (let ((buffer-read-only nil))
2069 (goto-char (point-min))
2070 (while (re-search-forward
2071 "^\\(\\(https?\\|ftp\\)://\\S-+\\)\n\\(\\S-+\\)" nil t)
2072 (replace-match "\\1\\3" t)))))
2074 (defun article-wash-html (&optional read-charset)
2075 "Format an html article.
2076 If READ-CHARSET, ask for a coding system."
2079 (let ((buffer-read-only nil)
2081 (if (gnus-buffer-live-p gnus-original-article-buffer)
2082 (with-current-buffer gnus-original-article-buffer
2083 (let* ((ct (gnus-fetch-field "content-type"))
2086 (mail-header-parse-content-type ct)))))
2087 (setq charset (and ctl
2088 (mail-content-type-get ctl 'charset)))
2089 (if (stringp charset)
2090 (setq charset (intern (downcase charset)))))))
2092 (setq charset (mm-read-coding-system "Charset: " charset)))
2094 (setq charset gnus-newsgroup-charset))
2096 (save-window-excursion
2098 (narrow-to-region (point) (point-max))
2099 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2100 (entry (assq func mm-text-html-washer-alist)))
2102 (setq func (cdr entry)))
2104 ((gnus-functionp func)
2107 (apply (car func) (cdr func))))))))))
2109 (defun gnus-article-wash-html-with-w3 ()
2110 "Wash the current buffer with w3."
2112 (let ((w3-strict-width (window-width))
2113 (url-standalone-mode t)
2114 (url-gateway-unplugged t)
2115 (w3-honor-stylesheets nil))
2117 (w3-region (point-min) (point-max))
2120 (defun gnus-article-wash-html-with-w3m ()
2121 "Wash the current buffer with emacs-w3m."
2124 (narrow-to-region (point) (point-max))
2125 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2128 (w3m-display-inline-images mm-inline-text-html-with-images)
2129 w3m-force-redisplay)
2130 (w3m-region (point-min) (point-max)))
2131 (when mm-inline-text-html-with-w3m-keymap
2132 (add-text-properties
2133 (point-min) (point-max)
2134 (append '(mm-inline-text-html-with-w3m t)
2135 (gnus-local-map-property mm-w3m-mode-map))))))
2137 (defun article-hide-list-identifiers ()
2138 "Remove list identifies from the Subject header.
2139 The `gnus-list-identifiers' variable specifies what to do."
2141 (let ((inhibit-point-motion-hooks t)
2142 (regexp (if (consp gnus-list-identifiers)
2143 (mapconcat 'identity gnus-list-identifiers " *\\|")
2144 gnus-list-identifiers))
2149 (article-narrow-to-head)
2150 (goto-char (point-min))
2151 (while (re-search-forward
2152 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2154 (delete-region (match-beginning 2) (match-end 0))
2155 (beginning-of-line))
2156 (when (re-search-forward
2157 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2158 (delete-region (match-beginning 1) (match-end 1))))))))
2160 (defun article-hide-pgp ()
2161 "Remove any PGP headers and signatures in the current article."
2165 (let ((inhibit-point-motion-hooks t)
2166 buffer-read-only beg end)
2168 ;; Hide the "header".
2169 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2170 (gnus-add-wash-type 'pgp)
2171 (delete-region (match-beginning 0) (match-end 0))
2172 ;; Remove armor headers (rfc2440 6.2)
2173 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2176 ;; Hide the actual signature.
2177 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2178 (setq end (1+ (match-beginning 0)))
2181 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2183 ;; Perhaps we shouldn't hide to the end of the buffer
2184 ;; if there is no end to the signature?
2186 ;; Hide "- " PGP quotation markers.
2188 (narrow-to-region beg end)
2189 (goto-char (point-min))
2190 (while (re-search-forward "^- " nil t)
2192 (match-beginning 0) (match-end 0)))
2194 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2196 (defun article-hide-pem (&optional arg)
2197 "Toggle hiding of any PEM headers and signatures in the current article.
2198 If given a negative prefix, always show; if given a positive prefix,
2200 (interactive (gnus-article-hidden-arg))
2201 (unless (gnus-article-check-hidden-text 'pem arg)
2203 (let (buffer-read-only end)
2204 (goto-char (point-min))
2205 ;; Hide the horrendously ugly "header".
2206 (when (and (search-forward
2207 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2209 (setq end (1+ (match-beginning 0))))
2210 (gnus-add-wash-type 'pem)
2211 (gnus-article-hide-text-type
2213 (if (search-forward "\n\n" nil t)
2217 ;; Hide the trailer as well
2218 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2220 (gnus-article-hide-text-type
2221 (match-beginning 0) (match-end 0) 'pem)))))))
2223 (defun article-strip-banner ()
2224 "Strip the banner specified by the `banner' group parameter."
2228 (let ((inhibit-point-motion-hooks t)
2229 (banner (gnus-parameter-banner gnus-newsgroup-name))
2230 (gnus-signature-limit nil)
2231 buffer-read-only beg end)
2235 ((eq banner 'signature)
2236 (when (gnus-article-narrow-to-signature)
2239 (delete-region (point) (point-max))))
2241 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2242 (while (re-search-forward banner nil t)
2243 (delete-region (match-beginning 0) (match-end 0)))))
2245 (while (re-search-forward banner nil t)
2246 (delete-region (match-beginning 0) (match-end 0))))))))))
2248 (defun article-babel ()
2249 "Translate article using an online translation service."
2253 (set-buffer gnus-article-buffer)
2254 (when (article-goto-body)
2255 (let* ((buffer-read-only nil)
2258 (orig (buffer-substring start end))
2259 (trans (babel-as-string orig)))
2261 (narrow-to-region start end)
2262 (delete-region start end)
2265 (defun article-hide-signature (&optional arg)
2266 "Hide the signature in the current article.
2267 If given a negative prefix, always show; if given a positive prefix,
2269 (interactive (gnus-article-hidden-arg))
2270 (unless (gnus-article-check-hidden-text 'signature arg)
2273 (let ((buffer-read-only nil))
2274 (when (gnus-article-narrow-to-signature)
2275 (gnus-article-hide-text-type
2276 (point-min) (point-max) 'signature))))))
2277 (gnus-set-mode-line 'article))
2279 (defun article-strip-headers-in-body ()
2280 "Strip offensive headers from bodies."
2284 (let ((case-fold-search t))
2285 (when (looking-at "x-no-archive:")
2286 (gnus-delete-line)))))
2288 (defun article-strip-leading-blank-lines ()
2289 "Remove all blank lines from the beginning of the article."
2292 (let ((inhibit-point-motion-hooks t)
2294 (when (article-goto-body)
2295 (while (and (not (eobp))
2296 (looking-at "[ \t]*$"))
2297 (gnus-delete-line))))))
2299 (defun article-narrow-to-head ()
2300 "Narrow the buffer to the head of the message.
2301 Point is left at the beginning of the narrowed-to region."
2303 (goto-char (point-min))
2304 (if (search-forward "\n\n" nil 1)
2307 (goto-char (point-min)))
2309 (defun article-goto-body ()
2310 "Place point at the start of the body."
2311 (goto-char (point-min))
2313 ;; This variable is only bound when dealing with separate
2315 (article-goto-body-goes-to-point-min-p
2317 ((search-forward "\n\n" nil t)
2320 (goto-char (point-max))
2323 (defun article-strip-multiple-blank-lines ()
2324 "Replace consecutive blank lines with one empty line."
2327 (let ((inhibit-point-motion-hooks t)
2329 ;; First make all blank lines empty.
2331 (while (re-search-forward "^[ \t]+$" nil t)
2332 (unless (gnus-annotation-in-region-p
2333 (match-beginning 0) (match-end 0))
2334 (replace-match "" nil t)))
2335 ;; Then replace multiple empty lines with a single empty line.
2337 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2338 (unless (gnus-annotation-in-region-p
2339 (match-beginning 0) (match-end 0))
2340 (delete-region (match-beginning 1) (match-end 1)))))))
2342 (defun article-strip-leading-space ()
2343 "Remove all white space from the beginning of the lines in the article."
2346 (let ((inhibit-point-motion-hooks t)
2349 (while (re-search-forward "^[ \t]+" nil t)
2350 (replace-match "" t t)))))
2352 (defun article-strip-trailing-space ()
2353 "Remove all white space from the end of the lines in the article."
2356 (let ((inhibit-point-motion-hooks t)
2359 (while (re-search-forward "[ \t]+$" nil t)
2360 (replace-match "" t t)))))
2362 (defun article-strip-blank-lines ()
2363 "Strip leading, trailing and multiple blank lines."
2365 (article-strip-leading-blank-lines)
2366 (article-remove-trailing-blank-lines)
2367 (article-strip-multiple-blank-lines))
2369 (defun article-strip-all-blank-lines ()
2370 "Strip all blank lines."
2373 (let ((inhibit-point-motion-hooks t)
2376 (while (re-search-forward "^[ \t]*\n" nil t)
2377 (replace-match "" t t)))))
2379 (defun gnus-article-narrow-to-signature ()
2380 "Narrow to the signature; return t if a signature is found, else nil."
2381 (let ((inhibit-point-motion-hooks t))
2382 (when (gnus-article-search-signature)
2384 ;; Check whether we have some limits to what we consider
2385 ;; to be a signature.
2386 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2387 (list gnus-signature-limit)))
2389 (while (setq limit (pop limits))
2390 (if (or (and (integerp limit)
2391 (< (- (point-max) (point)) limit))
2393 (< (count-lines (point) (point-max)) limit))
2394 (and (gnus-functionp limit)
2396 (and (stringp limit)
2397 (not (re-search-forward limit nil t))))
2398 () ; This limit did not succeed.
2402 (narrow-to-region (point) (point-max))
2405 (defun gnus-article-search-signature ()
2406 "Search the current buffer for the signature separator.
2407 Put point at the beginning of the signature separator."
2408 (let ((cur (point)))
2409 (goto-char (point-max))
2410 (if (if (stringp gnus-signature-separator)
2411 (re-search-backward gnus-signature-separator nil t)
2412 (let ((seps gnus-signature-separator))
2414 (not (re-search-backward (car seps) nil t)))
2421 (defun gnus-article-hidden-arg ()
2422 "Return the current prefix arg as a number, or 0 if no prefix."
2423 (list (if current-prefix-arg
2424 (prefix-numeric-value current-prefix-arg)
2427 (defun gnus-article-check-hidden-text (type arg)
2428 "Return nil if hiding is necessary.
2429 Arg can be nil or a number. nil and positive means hide, negative
2430 means show, 0 means toggle."
2433 (let ((hide (gnus-article-hidden-text-p type)))
2439 (gnus-article-show-hidden-text type)
2442 (if (eq hide 'hidden)
2444 (gnus-article-show-hidden-text type)
2448 (defun gnus-article-hidden-text-p (type)
2449 "Say whether the current buffer contains hidden text of type TYPE."
2450 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2452 (not (get-text-property pos 'invisible))
2453 (not (get-text-property pos 'dummy-invisible)))
2455 (text-property-any (1+ pos) (point-max) 'article-type type)))
2460 (defun gnus-article-show-hidden-text (type &optional dummy)
2461 "Show all hidden text of type TYPE.
2462 Originally it is hide instead of DUMMY."
2463 (let ((buffer-read-only nil)
2464 (inhibit-point-motion-hooks t))
2465 (gnus-remove-text-properties-when
2467 (point-min) (point-max)
2468 (cons 'article-type (cons type
2469 gnus-hidden-properties)))
2470 (gnus-delete-wash-type type)))
2472 (defconst article-time-units
2473 `((year . ,(* 365.25 24 60 60))
2474 (week . ,(* 7 24 60 60))
2475 (day . ,(* 24 60 60))
2479 "Mapping from time units to seconds.")
2481 (defun article-date-ut (&optional type highlight header)
2482 "Convert DATE date to universal time in the current article.
2483 If TYPE is `local', convert to local time; if it is `lapsed', output
2484 how much time has lapsed since DATE. For `lapsed', the value of
2485 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2486 should replace the \"Date:\" one, or should be added below it."
2487 (interactive (list 'ut t))
2488 (let* ((header (or header
2489 (message-fetch-field "date")
2491 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2494 ((not gnus-article-date-lapsed-new-header)
2500 (date (if (vectorp header) (mail-header-date header)
2502 (inhibit-point-motion-hooks t)
2507 (article-narrow-to-head)
2508 (when (re-search-forward tdate-regexp nil t)
2509 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2510 date (or (get-text-property (gnus-point-at-bol)
2513 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2515 (when (and date (not (string= date "")))
2516 (goto-char (point-min))
2517 (let ((buffer-read-only nil))
2518 ;; Delete any old Date headers.
2519 (while (re-search-forward date-regexp nil t)
2521 (delete-region (progn (beginning-of-line) (point))
2522 (progn (forward-line 1) (point)))
2523 (delete-region (progn (beginning-of-line) (point))
2524 (progn (end-of-line) (point)))
2525 (setq pos (point))))
2526 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2528 (if pos (goto-char pos))
2529 (insert (article-make-date-line date (or type 'ut)))
2535 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2536 (put-text-property (match-beginning 1) (1+ (match-end 1))
2537 'original-date date)
2538 (put-text-property (match-beginning 1) (1+ (match-end 1))
2540 (put-text-property (match-beginning 2) (match-end 2)
2543 (defun article-make-date-line (date type)
2544 "Return a DATE line of TYPE."
2545 (unless (memq type '(local ut original user iso8601 lapsed english))
2546 (error "Unknown conversion type: %s" type))
2548 (let ((time (date-to-time date)))
2550 ;; Convert to the local timezone.
2552 (let ((tz (car (current-time-zone time))))
2553 (format "Date: %s %s%02d%02d" (current-time-string time)
2554 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2555 (/ (% (abs tz) 3600) 60))))
2556 ;; Convert to Universal Time.
2559 (current-time-string
2560 (let* ((e (parse-time-string date))
2561 (tm (apply 'encode-time e))
2563 (ls (- (cadr tm) (car (current-time-zone time)))))
2564 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2565 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2568 ;; Get the original date from the article.
2569 ((eq type 'original)
2570 (concat "Date: " (if (string-match "\n+$" date)
2571 (substring date 0 (match-beginning 0))
2573 ;; Let the user define the format.
2575 (if (gnus-functionp gnus-article-time-format)
2576 (funcall gnus-article-time-format time)
2579 (format-time-string gnus-article-time-format time))))
2582 (let ((tz (car (current-time-zone time))))
2585 (format-time-string "%Y%m%dT%H%M%S" time)
2586 (format "%s%02d%02d"
2587 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2588 (/ (% (abs tz) 3600) 60)))))
2589 ;; Do an X-Sent lapsed format.
2591 ;; If the date is seriously mangled, the timezone functions are
2592 ;; liable to bug out, so we ignore all errors.
2593 (let* ((now (current-time))
2594 (real-time (subtract-time now time))
2595 (real-sec (and real-time
2596 (+ (* (float (car real-time)) 65536)
2598 (sec (and real-time (abs real-sec)))
2608 ;; This is a bit convoluted, but basically we go
2609 ;; through the time units for years, weeks, etc,
2610 ;; and divide things to see whether that results
2611 ;; in positive answers.
2614 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2615 ;; The (remaining) seconds are too few to
2616 ;; be divided into this time unit.
2618 ;; It's big enough, so we output it.
2619 (setq sec (- sec (* num (cdr unit))))
2621 (concat (if prev ", " "") (int-to-string
2623 " " (symbol-name (car unit))
2624 (if (> num 1) "s" ""))
2626 article-time-units "")
2627 ;; If dates are odd, then it might appear like the
2628 ;; article was sent in the future.
2631 " in the future"))))))
2632 ;; Display the date in proper English
2634 (let ((dtime (decode-time time)))
2637 (number-to-string (nth 3 dtime))
2638 (let ((digit (% (nth 3 dtime) 10)))
2640 ((memq (nth 3 dtime) '(11 12 13)) "th")
2646 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2648 (number-to-string (nth 5 dtime))
2650 (format "%02d" (nth 2 dtime))
2652 (format "%02d" (nth 1 dtime)))))))
2654 (format "Date: %s (from Oort)" date))))
2656 (defun article-date-local (&optional highlight)
2657 "Convert the current article date to the local timezone."
2658 (interactive (list t))
2659 (article-date-ut 'local highlight))
2661 (defun article-date-english (&optional highlight)
2662 "Convert the current article date to something that is proper English."
2663 (interactive (list t))
2664 (article-date-ut 'english highlight))
2666 (defun article-date-original (&optional highlight)
2667 "Convert the current article date to what it was originally.
2668 This is only useful if you have used some other date conversion
2669 function and want to see what the date was before converting."
2670 (interactive (list t))
2671 (article-date-ut 'original highlight))
2673 (defun article-date-lapsed (&optional highlight)
2674 "Convert the current article date to time lapsed since it was sent."
2675 (interactive (list t))
2676 (article-date-ut 'lapsed highlight))
2678 (defun article-update-date-lapsed ()
2679 "Function to be run from a timer to update the lapsed time line."
2680 (let (deactivate-mark)
2685 (set-buffer (window-buffer w))
2686 (when (eq major-mode 'gnus-article-mode)
2687 (goto-char (point-min))
2688 (when (re-search-forward "^X-Sent:" nil t)
2689 (article-date-lapsed t))))
2692 (defun gnus-start-date-timer (&optional n)
2693 "Start a timer to update the X-Sent header in the article buffers.
2694 The numerical prefix says how frequently (in seconds) the function
2699 (gnus-stop-date-timer)
2700 (setq article-lapsed-timer
2701 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2703 (defun gnus-stop-date-timer ()
2704 "Stop the X-Sent timer."
2706 (when article-lapsed-timer
2707 (nnheader-cancel-timer article-lapsed-timer)
2708 (setq article-lapsed-timer nil)))
2710 (defun article-date-user (&optional highlight)
2711 "Convert the current article date to the user-defined format.
2712 This format is defined by the `gnus-article-time-format' variable."
2713 (interactive (list t))
2714 (article-date-ut 'user highlight))
2716 (defun article-date-iso8601 (&optional highlight)
2717 "Convert the current article date to ISO8601."
2718 (interactive (list t))
2719 (article-date-ut 'iso8601 highlight))
2721 ;; (defun article-show-all ()
2722 ;; "Show all hidden text in the article buffer."
2725 ;; (let ((buffer-read-only nil))
2726 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2728 (defun article-remove-leading-whitespace ()
2729 "Remove excessive whitespace from all headers."
2733 (let ((buffer-read-only nil))
2734 (article-narrow-to-head)
2735 (goto-char (point-min))
2736 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2737 (delete-region (match-beginning 1) (match-end 1)))))))
2739 (defun article-emphasize (&optional arg)
2740 "Emphasize text according to `gnus-emphasis-alist'."
2741 (interactive (gnus-article-hidden-arg))
2742 (unless (gnus-article-check-hidden-text 'emphasis arg)
2746 (with-current-buffer gnus-summary-buffer
2747 gnus-article-emphasis-alist)
2749 gnus-emphasis-alist))
2750 (buffer-read-only nil)
2751 (props (append '(article-type emphasis)
2752 gnus-hidden-properties))
2753 regexp elem beg invisible visible face)
2756 (while (setq elem (pop alist))
2758 (setq regexp (car elem)
2759 invisible (nth 1 elem)
2760 visible (nth 2 elem)
2762 (while (re-search-forward regexp nil t)
2763 (when (and (match-beginning visible) (match-beginning invisible))
2764 (gnus-article-hide-text
2765 (match-beginning invisible) (match-end invisible) props)
2766 (gnus-article-unhide-text-type
2767 (match-beginning visible) (match-end visible) 'emphasis)
2768 (gnus-put-overlay-excluding-newlines
2769 (match-beginning visible) (match-end visible) 'face face)
2770 (gnus-add-wash-type 'emphasis)
2771 (goto-char (match-end invisible)))))))))
2773 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2774 "Setup newsgroup emphasis alist."
2775 (unless gnus-article-emphasis-alist
2776 (let ((name (and gnus-newsgroup-name
2777 (gnus-group-real-name gnus-newsgroup-name))))
2778 (make-local-variable 'gnus-article-emphasis-alist)
2779 (setq gnus-article-emphasis-alist
2781 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2782 (while (setq elem (pop alist))
2783 (when (and name (string-match (car elem) name))
2785 highlight (copy-sequence (cdr elem)))))
2787 (copy-sequence highlight-words)
2788 (if gnus-newsgroup-name
2789 (copy-sequence (gnus-group-find-parameter
2790 gnus-newsgroup-name 'highlight-words t)))
2791 gnus-emphasis-alist)))))
2794 (defvar gnus-summary-article-menu)
2795 (defvar gnus-summary-post-menu))
2797 ;;; Saving functions.
2799 (defun gnus-article-save (save-buffer file &optional num)
2800 "Save the currently selected article."
2801 (unless gnus-save-all-headers
2802 ;; Remove headers according to `gnus-saved-headers'.
2803 (let ((gnus-visible-headers
2804 (or gnus-saved-headers gnus-visible-headers))
2805 (gnus-article-buffer save-buffer))
2807 (set-buffer save-buffer)
2808 (article-hide-headers 1 t))))
2809 (save-window-excursion
2810 (if (not gnus-default-article-saver)
2811 (error "No default saver is defined")
2812 ;; !!! Magic! The saving functions all save
2813 ;; `gnus-save-article-buffer' (or so they think), but we
2814 ;; bind that variable to our save-buffer.
2815 (set-buffer gnus-article-buffer)
2816 (let* ((gnus-save-article-buffer save-buffer)
2819 ((not gnus-prompt-before-saving) 'default)
2820 ((eq gnus-prompt-before-saving 'always) nil)
2822 (gnus-number-of-articles-to-be-saved
2823 (when (eq gnus-prompt-before-saving t)
2825 (set-buffer gnus-article-current-summary)
2826 (funcall gnus-default-article-saver filename)))))
2828 (defun gnus-read-save-file-name (prompt &optional filename
2829 function group headers variable)
2831 (funcall function group headers (symbol-value variable)))
2836 ((eq filename 'default)
2842 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2845 (if (and gnus-number-of-articles-to-be-saved
2846 (> gnus-number-of-articles-to-be-saved 1))
2847 (format "these %d articles"
2848 gnus-number-of-articles-to-be-saved)
2851 ;; Let the split methods have their say.
2853 ;; No split name was found.
2856 (concat prompt " (default "
2857 (file-name-nondirectory default-name) ") ")
2858 (file-name-directory default-name)
2860 ;; A single group name is returned.
2861 ((stringp split-name)
2863 (funcall function split-name headers
2864 (symbol-value variable)))
2866 (concat prompt " (default "
2867 (file-name-nondirectory default-name) ") ")
2868 (file-name-directory default-name)
2870 ;; A single split name was found
2871 ((= 1 (length split-name))
2872 (let* ((name (expand-file-name
2874 gnus-article-save-directory))
2875 (dir (cond ((file-directory-p name)
2876 (file-name-as-directory name))
2877 ((file-exists-p name) name)
2878 (t gnus-article-save-directory))))
2880 (concat prompt " (default " name ") ")
2882 ;; A list of splits was found.
2884 (setq split-name (nreverse split-name))
2886 (let ((file-name-history
2887 (nconc split-name file-name-history)))
2891 (concat prompt " (`M-p' for defaults) ")
2892 gnus-article-save-directory
2894 gnus-article-save-directory)))
2895 (car (push result file-name-history)))))))
2896 ;; Create the directory.
2897 (gnus-make-directory (file-name-directory file))
2898 ;; If we have read a directory, we append the default file name.
2899 (when (file-directory-p file)
2900 (setq file (expand-file-name (file-name-nondirectory
2902 (file-name-as-directory file))))
2903 ;; Possibly translate some characters.
2904 (nnheader-translate-file-chars file))))))
2905 (gnus-make-directory (file-name-directory result))
2906 (set variable result)))
2908 (defun gnus-article-archive-name (group)
2909 "Return the first instance of an \"Archive-name\" in the current buffer."
2910 (let ((case-fold-search t))
2911 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2912 (nnheader-concat gnus-article-save-directory
2913 (match-string 1)))))
2915 (defun gnus-article-nndoc-name (group)
2916 "If GROUP is an nndoc group, return the name of the parent group."
2917 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2918 (gnus-group-get-parameter group 'save-article-group)))
2920 (defun gnus-summary-save-in-rmail (&optional filename)
2921 "Append this article to Rmail file.
2922 Optional argument FILENAME specifies file name.
2923 Directory to save to is default to `gnus-article-save-directory'."
2924 (setq filename (gnus-read-save-file-name
2925 "Save %s in rmail file:" filename
2926 gnus-rmail-save-name gnus-newsgroup-name
2927 gnus-current-headers 'gnus-newsgroup-last-rmail))
2928 (gnus-eval-in-buffer-window gnus-save-article-buffer
2932 (gnus-output-to-rmail filename))))
2935 (defun gnus-summary-save-in-mail (&optional filename)
2936 "Append this article to Unix mail file.
2937 Optional argument FILENAME specifies file name.
2938 Directory to save to is default to `gnus-article-save-directory'."
2939 (setq filename (gnus-read-save-file-name
2940 "Save %s in Unix mail file:" filename
2941 gnus-mail-save-name gnus-newsgroup-name
2942 gnus-current-headers 'gnus-newsgroup-last-mail))
2943 (gnus-eval-in-buffer-window gnus-save-article-buffer
2947 (if (and (file-readable-p filename)
2948 (mail-file-babyl-p filename))
2949 (rmail-output-to-rmail-file filename t)
2950 (gnus-output-to-mail filename)))))
2953 (defun gnus-summary-save-in-file (&optional filename overwrite)
2954 "Append this article to file.
2955 Optional argument FILENAME specifies file name.
2956 Directory to save to is default to `gnus-article-save-directory'."
2957 (setq filename (gnus-read-save-file-name
2958 "Save %s in file:" filename
2959 gnus-file-save-name gnus-newsgroup-name
2960 gnus-current-headers 'gnus-newsgroup-last-file))
2961 (gnus-eval-in-buffer-window gnus-save-article-buffer
2965 (when (and overwrite
2966 (file-exists-p filename))
2967 (delete-file filename))
2968 (gnus-output-to-file filename))))
2971 (defun gnus-summary-write-to-file (&optional filename)
2972 "Write this article to a file, overwriting it if the file exists.
2973 Optional argument FILENAME specifies file name.
2974 The directory to save in defaults to `gnus-article-save-directory'."
2975 (gnus-summary-save-in-file nil t))
2977 (defun gnus-summary-save-body-in-file (&optional filename)
2978 "Append this article body to a file.
2979 Optional argument FILENAME specifies file name.
2980 The directory to save in defaults to `gnus-article-save-directory'."
2981 (setq filename (gnus-read-save-file-name
2982 "Save %s body in file:" filename
2983 gnus-file-save-name gnus-newsgroup-name
2984 gnus-current-headers 'gnus-newsgroup-last-file))
2985 (gnus-eval-in-buffer-window gnus-save-article-buffer
2989 (when (article-goto-body)
2990 (narrow-to-region (point) (point-max)))
2991 (gnus-output-to-file filename))))
2994 (defun gnus-summary-save-in-pipe (&optional command)
2995 "Pipe this article to subprocess."
2997 (cond ((and (eq command 'default)
2998 gnus-last-shell-command)
2999 gnus-last-shell-command)
3004 "Shell command on %s: "
3005 (if (and gnus-number-of-articles-to-be-saved
3006 (> gnus-number-of-articles-to-be-saved 1))
3007 (format "these %d articles"
3008 gnus-number-of-articles-to-be-saved)
3010 gnus-last-shell-command))))
3011 (when (string-equal command "")
3012 (if gnus-last-shell-command
3013 (setq command gnus-last-shell-command)
3014 (error "A command is required")))
3015 (gnus-eval-in-buffer-window gnus-article-buffer
3018 (shell-command-on-region (point-min) (point-max) command nil)))
3019 (setq gnus-last-shell-command command))
3021 (defun gnus-summary-pipe-to-muttprint (&optional command)
3022 "Pipe this article to muttprint."
3023 (setq command (read-string
3024 "Print using command: " gnus-summary-muttprint-program
3025 nil gnus-summary-muttprint-program))
3026 (gnus-summary-save-in-pipe command))
3028 ;;; Article file names when saving.
3030 (defun gnus-capitalize-newsgroup (newsgroup)
3031 "Capitalize NEWSGROUP name."
3032 (when (not (zerop (length newsgroup)))
3033 (concat (char-to-string (upcase (aref newsgroup 0)))
3034 (substring newsgroup 1))))
3036 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3037 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3038 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3039 Otherwise, it is like ~/News/news/group/num."
3042 (concat (if (gnus-use-long-file-name 'not-save)
3043 (gnus-capitalize-newsgroup newsgroup)
3044 (gnus-newsgroup-directory-form newsgroup))
3045 "/" (int-to-string (mail-header-number headers)))
3046 gnus-article-save-directory)))
3048 (string-equal (file-name-directory default)
3049 (file-name-directory last-file))
3050 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3052 (or last-file default))))
3054 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3055 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3056 If variable `gnus-use-long-file-name' is non-nil, it is
3057 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3060 (concat (if (gnus-use-long-file-name 'not-save)
3062 (gnus-newsgroup-directory-form newsgroup))
3063 "/" (int-to-string (mail-header-number headers)))
3064 gnus-article-save-directory)))
3066 (string-equal (file-name-directory default)
3067 (file-name-directory last-file))
3068 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3070 (or last-file default))))
3072 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3073 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3074 If variable `gnus-use-long-file-name' is non-nil, it is
3075 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3078 (if (gnus-use-long-file-name 'not-save)
3081 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3083 gnus-article-save-directory)))
3085 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3086 "Generate file name from sender."
3087 (let ((from (mail-header-from headers)))
3089 (if (and from (string-match "\\([^ <]+\\)@" from))
3090 (match-string 1 from)
3092 gnus-article-save-directory)))
3094 (defun article-verify-x-pgp-sig ()
3097 (if (gnus-buffer-live-p gnus-original-article-buffer)
3098 (let ((sig (with-current-buffer gnus-original-article-buffer
3099 (gnus-fetch-field "X-PGP-Sig")))
3103 (mml2015-clear-verify-function))
3105 (insert-buffer gnus-original-article-buffer)
3106 (setq items (split-string sig))
3107 (message-narrow-to-head)
3108 (let ((inhibit-point-motion-hooks t)
3109 (case-fold-search t))
3110 ;; Don't verify multiple headers.
3111 (setq headers (mapconcat (lambda (header)
3113 (mail-fetch-field header) "\n"))
3114 (split-string (nth 1 items) ",") "")))
3115 (delete-region (point-min) (point-max))
3116 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3117 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3122 (if (looking-at "^-")
3125 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3126 (insert "Version: " (car items) "\n\n")
3127 (insert (mapconcat 'identity (cddr items) "\n"))
3128 (insert "\n-----END PGP SIGNATURE-----\n")
3129 (let ((mm-security-handle (list (format "multipart/signed"))))
3130 (mml2015-clean-buffer)
3131 (let ((coding-system-for-write (or gnus-newsgroup-charset
3133 (funcall (mml2015-clear-verify-function)))
3135 (or (mm-handle-multipart-ctl-parameter
3136 mm-security-handle 'gnus-details)
3137 (mm-handle-multipart-ctl-parameter
3138 mm-security-handle 'gnus-info)))))
3140 (let (buffer-read-only bface eface)
3142 (message-narrow-to-head)
3143 (goto-char (point-max))
3145 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3146 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3147 (message-remove-header "X-Gnus-PGP-Verify")
3148 (if (re-search-forward "^X-PGP-Sig:" nil t)
3150 (goto-char (point-max)))
3151 (narrow-to-region (point) (point))
3152 (insert "X-Gnus-PGP-Verify: " info "\n")
3153 (goto-char (point-min))
3156 (if (not (looking-at "^[ \t]"))
3160 (goto-char (point-min))
3161 (when (looking-at "\\([^:]+\\): *")
3162 (put-text-property (match-beginning 1) (1+ (match-end 1))
3164 (put-text-property (match-end 0) (point-max)
3165 'face eface)))))))))
3167 (defun article-verify-cancel-lock ()
3168 "Verify Cancel-Lock header."
3170 (if (gnus-buffer-live-p gnus-original-article-buffer)
3171 (canlock-verify gnus-original-article-buffer)))
3178 (setq afunc (car func)
3181 gfunc (intern (format "gnus-%s" func))))
3183 (when (fboundp afunc)
3184 `(lambda (&optional interactive &rest args)
3185 ,(documentation afunc t)
3186 (interactive (list t))
3188 (set-buffer gnus-article-buffer)
3190 (call-interactively ',afunc)
3191 (apply ',afunc args))))))))
3192 '(article-hide-headers
3193 article-verify-x-pgp-sig
3194 article-verify-cancel-lock
3195 article-hide-boring-headers
3196 article-treat-overstrike
3197 article-fill-long-lines
3198 article-capitalize-sentences
3200 article-remove-leading-whitespace
3201 article-display-x-face
3202 article-de-quoted-unreadable
3203 article-de-base64-unreadable
3206 article-unsplit-urls
3207 article-hide-list-identifiers
3209 article-strip-banner
3212 article-hide-signature
3213 article-strip-headers-in-body
3214 article-remove-trailing-blank-lines
3215 article-strip-leading-blank-lines
3216 article-strip-multiple-blank-lines
3217 article-strip-leading-space
3218 article-strip-trailing-space
3219 article-strip-blank-lines
3220 article-strip-all-blank-lines
3221 article-replace-with-quoted-text
3223 article-date-english
3224 article-date-iso8601
3225 article-date-original
3227 article-decode-mime-words
3228 article-decode-charset
3229 article-decode-encoded-words
3233 article-treat-dumbquotes
3234 article-normalize-headers
3235 ;; (article-show-all . gnus-article-show-all-headers)
3239 ;;; Gnus article mode
3242 (put 'gnus-article-mode 'mode-class 'special)
3244 (set-keymap-parent gnus-article-mode-map widget-keymap)
3246 (gnus-define-keys gnus-article-mode-map
3247 " " gnus-article-goto-next-page
3248 "\177" gnus-article-goto-prev-page
3249 [delete] gnus-article-goto-prev-page
3250 [backspace] gnus-article-goto-prev-page
3251 "\C-c^" gnus-article-refer-article
3252 "h" gnus-article-show-summary
3253 "s" gnus-article-show-summary
3254 "\C-c\C-m" gnus-article-mail
3255 "?" gnus-article-describe-briefly
3256 "e" gnus-summary-edit-article
3257 "<" beginning-of-buffer
3259 "\C-c\C-i" gnus-info-find-node
3261 "R" gnus-article-reply-with-original
3262 "F" gnus-article-followup-with-original
3263 "\C-hk" gnus-article-describe-key
3264 "\C-hc" gnus-article-describe-key-briefly
3266 "\C-d" gnus-article-read-summary-keys
3267 "\M-*" gnus-article-read-summary-keys
3268 "\M-#" gnus-article-read-summary-keys
3269 "\M-^" gnus-article-read-summary-keys
3270 "\M-g" gnus-article-read-summary-keys)
3272 (substitute-key-definition
3273 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3275 (defun gnus-article-make-menu-bar ()
3276 (unless (boundp 'gnus-article-commands-menu)
3277 (gnus-summary-make-menu-bar))
3278 (gnus-turn-off-edit-menu 'article)
3279 (unless (boundp 'gnus-article-article-menu)
3281 gnus-article-article-menu gnus-article-mode-map ""
3283 ["Scroll forwards" gnus-article-goto-next-page t]
3284 ["Scroll backwards" gnus-article-goto-prev-page t]
3285 ["Show summary" gnus-article-show-summary t]
3286 ["Fetch Message-ID at point" gnus-article-refer-article t]
3287 ["Mail to address at point" gnus-article-mail t]
3288 ["Send a bug report" gnus-bug t]))
3291 gnus-article-treatment-menu gnus-article-mode-map ""
3292 ;; Fixme: this should use :active (and maybe :visible).
3294 ["Hide headers" gnus-article-hide-headers t]
3295 ["Hide signature" gnus-article-hide-signature t]
3296 ["Hide citation" gnus-article-hide-citation t]
3297 ["Treat overstrike" gnus-article-treat-overstrike t]
3298 ["Remove carriage return" gnus-article-remove-cr t]
3299 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3300 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3301 ["Remove base64" gnus-article-de-base64-unreadable t]
3302 ["Treat html" gnus-article-wash-html t]
3303 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3304 ["Decode HZ" gnus-article-decode-HZ t]))
3306 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3308 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3310 (gnus-run-hooks 'gnus-article-menu-hook)))
3312 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3315 (defun gnus-article-mode ()
3316 "Major mode for displaying an article.
3318 All normal editing commands are switched off.
3320 The following commands are available in addition to all summary mode
3322 \\<gnus-article-mode-map>
3323 \\[gnus-article-next-page]\t Scroll the article one page forwards
3324 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3325 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3326 \\[gnus-article-show-summary]\t Display the summary buffer
3327 \\[gnus-article-mail]\t Send a reply to the address near point
3328 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3329 \\[gnus-info-find-node]\t Go to the Gnus info node"
3331 (gnus-simplify-mode-line)
3332 (setq mode-name "Article")
3333 (setq major-mode 'gnus-article-mode)
3334 (make-local-variable 'minor-mode-alist)
3335 (use-local-map gnus-article-mode-map)
3336 (when (gnus-visual-p 'article-menu 'menu)
3337 (gnus-article-make-menu-bar))
3338 (gnus-update-format-specifications nil 'article-mode)
3339 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3340 (make-local-variable 'gnus-page-broken)
3341 (make-local-variable 'gnus-button-marker-list)
3342 (make-local-variable 'gnus-article-current-summary)
3343 (make-local-variable 'gnus-article-mime-handles)
3344 (make-local-variable 'gnus-article-decoded-p)
3345 (make-local-variable 'gnus-article-mime-handle-alist)
3346 (make-local-variable 'gnus-article-wash-types)
3347 (make-local-variable 'gnus-article-image-alist)
3348 (make-local-variable 'gnus-article-charset)
3349 (make-local-variable 'gnus-article-ignored-charsets)
3350 (gnus-set-default-directory)
3351 (buffer-disable-undo)
3352 (setq buffer-read-only t)
3353 (set-syntax-table gnus-article-mode-syntax-table)
3354 (mm-enable-multibyte)
3355 (gnus-run-hooks 'gnus-article-mode-hook))
3357 (defun gnus-article-setup-buffer ()
3358 "Initialize the article buffer."
3359 (let* ((name (if gnus-single-article-buffer "*Article*"
3360 (concat "*Article " gnus-newsgroup-name "*")))
3362 (progn (string-match "\\*Article" name)
3363 (concat " *Original Article"
3364 (substring name (match-end 0))))))
3365 (setq gnus-article-buffer name)
3366 (setq gnus-original-article-buffer original)
3367 (setq gnus-article-mime-handle-alist nil)
3368 ;; This might be a variable local to the summary buffer.
3369 (unless gnus-single-article-buffer
3371 (set-buffer gnus-summary-buffer)
3372 (setq gnus-article-buffer name)
3373 (setq gnus-original-article-buffer original)
3374 (gnus-set-global-variables)))
3375 (gnus-article-setup-highlight-words)
3376 ;; Init original article buffer.
3378 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3379 (mm-enable-multibyte)
3380 (setq major-mode 'gnus-original-article-mode)
3381 (make-local-variable 'gnus-original-article))
3382 (if (get-buffer name)
3385 (when gnus-article-mime-handles
3386 (mm-destroy-parts gnus-article-mime-handles)
3387 (setq gnus-article-mime-handles nil))
3388 ;; Set it to nil in article-buffer!
3389 (setq gnus-article-mime-handle-alist nil)
3390 (buffer-disable-undo)
3391 (setq buffer-read-only t)
3392 (unless (eq major-mode 'gnus-article-mode)
3393 (gnus-article-mode))
3396 (set-buffer (gnus-get-buffer-create name))
3398 (make-local-variable 'gnus-summary-buffer)
3399 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3400 (current-buffer)))))
3402 ;; Set article window start at LINE, where LINE is the number of lines
3403 ;; from the head of the article.
3404 (defun gnus-article-set-window-start (&optional line)
3406 (gnus-get-buffer-window gnus-article-buffer t)
3408 (set-buffer gnus-article-buffer)
3409 (goto-char (point-min))
3412 (gnus-message 6 "Moved to bookmark")
3413 (search-forward "\n\n" nil t)
3417 (defun gnus-article-prepare (article &optional all-headers header)
3418 "Prepare ARTICLE in article mode buffer.
3419 ARTICLE should either be an article number or a Message-ID.
3420 If ARTICLE is an id, HEADER should be the article headers.
3421 If ALL-HEADERS is non-nil, no headers are hidden."
3423 ;; Make sure we start in a summary buffer.
3424 (unless (eq major-mode 'gnus-summary-mode)
3425 (set-buffer gnus-summary-buffer))
3426 (setq gnus-summary-buffer (current-buffer))
3427 (let* ((gnus-article (if header (mail-header-number header) article))
3428 (summary-buffer (current-buffer))
3429 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3430 (group gnus-newsgroup-name)
3433 (gnus-article-setup-buffer)
3434 (set-buffer gnus-article-buffer)
3435 ;; Deactivate active regions.
3436 (when (and (boundp 'transient-mark-mode)
3437 transient-mark-mode)
3438 (setq mark-active nil))
3439 (if (not (setq result (let ((buffer-read-only nil))
3440 (gnus-request-article-this-buffer
3442 ;; There is no such article.
3444 (when (and (numberp article)
3445 (not (memq article gnus-newsgroup-sparse)))
3446 (setq gnus-article-current
3447 (cons gnus-newsgroup-name article))
3448 (set-buffer gnus-summary-buffer)
3449 (setq gnus-current-article article)
3450 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3452 (gnus-summary-set-agent-mark article)
3453 (message "Message marked for downloading"))
3454 (gnus-summary-mark-article article gnus-canceled-mark)
3455 (unless (memq article gnus-newsgroup-sparse)
3456 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3457 (if (or (eq result 'pseudo)
3458 (eq result 'nneething))
3461 (set-buffer summary-buffer)
3462 (push article gnus-newsgroup-history)
3463 (setq gnus-last-article gnus-current-article
3464 gnus-current-article 0
3465 gnus-current-headers nil
3466 gnus-article-current nil)
3467 (if (eq result 'nneething)
3468 (gnus-configure-windows 'summary)
3469 (gnus-configure-windows 'article))
3470 (gnus-set-global-variables))
3471 (let ((gnus-article-mime-handle-alist-1
3472 gnus-article-mime-handle-alist))
3473 (gnus-set-mode-line 'article)))
3474 ;; The result from the `request' was an actual article -
3475 ;; or at least some text that is now displayed in the
3477 (when (and (numberp article)
3478 (not (eq article gnus-current-article)))
3479 ;; Seems like a new article has been selected.
3480 ;; `gnus-current-article' must be an article number.
3482 (set-buffer summary-buffer)
3483 (push article gnus-newsgroup-history)
3484 (setq gnus-last-article gnus-current-article
3485 gnus-current-article article
3486 gnus-current-headers
3487 (gnus-summary-article-header gnus-current-article)
3488 gnus-article-current
3489 (cons gnus-newsgroup-name gnus-current-article))
3490 (unless (vectorp gnus-current-headers)
3491 (setq gnus-current-headers nil))
3492 (gnus-summary-goto-subject gnus-current-article)
3493 (when (gnus-summary-show-thread)
3494 ;; If the summary buffer really was folded, the
3495 ;; previous goto may not actually have gone to
3496 ;; the right article, but the thread root instead.
3498 (gnus-summary-goto-subject gnus-current-article))
3499 (gnus-run-hooks 'gnus-mark-article-hook)
3500 (gnus-set-mode-line 'summary)
3501 (when (gnus-visual-p 'article-highlight 'highlight)
3502 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3503 ;; Set the global newsgroup variables here.
3504 (gnus-set-global-variables)
3505 (setq gnus-have-all-headers
3506 (or all-headers gnus-show-all-headers))))
3508 (gnus-configure-windows 'article))
3509 (when (or (numberp article)
3511 (gnus-article-prepare-display)
3513 (goto-char (point-min))
3514 (setq gnus-page-broken
3515 (when gnus-break-pages
3516 (gnus-narrow-to-page)
3518 (let ((gnus-article-mime-handle-alist-1
3519 gnus-article-mime-handle-alist))
3520 (gnus-set-mode-line 'article))
3522 (set-window-point (get-buffer-window (current-buffer)) (point))
3523 (gnus-configure-windows 'article)
3527 (defun gnus-article-prepare-display ()
3528 "Make the current buffer look like a nice article."
3529 ;; Hooks for getting information from the article.
3530 ;; This hook must be called before being narrowed.
3531 (let ((gnus-article-buffer (current-buffer))
3533 (unless (eq major-mode 'gnus-article-mode)
3534 (gnus-article-mode))
3535 (setq buffer-read-only nil
3536 gnus-article-wash-types nil
3537 gnus-article-image-alist nil)
3538 (gnus-run-hooks 'gnus-tmp-internal-hook)
3539 (when gnus-display-mime-function
3540 (funcall gnus-display-mime-function))
3541 (gnus-run-hooks 'gnus-article-prepare-hook)))
3544 ;;; Gnus MIME viewing functions
3547 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3548 "Format of the MIME buttons.
3550 Valid specifiers include:
3552 %T MIME type, along with additional info
3553 %n The `name' parameter
3554 %d The description, if any
3555 %l The length of the encoded part
3556 %p The part identifier number
3557 %e Dots if the part isn't displayed
3559 General format specifiers can also be used. See
3560 (gnus)Formatting Variables.")
3562 (defvar gnus-mime-button-line-format-alist
3563 '((?t gnus-tmp-type ?s)
3564 (?T gnus-tmp-type-long ?s)
3565 (?n gnus-tmp-name ?s)
3566 (?d gnus-tmp-description ?s)
3568 (?l gnus-tmp-length ?d)
3569 (?e gnus-tmp-dots ?s)))
3571 (defvar gnus-mime-button-commands
3572 '((gnus-article-press-button "\r" "Toggle Display")
3573 (gnus-mime-view-part "v" "View Interactively...")
3574 (gnus-mime-view-part-as-type "t" "View As Type...")
3575 (gnus-mime-view-part-as-charset "C" "View As charset...")
3576 (gnus-mime-save-part "o" "Save...")
3577 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3578 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3579 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3580 (gnus-mime-view-part-internally "E" "View Internally")
3581 (gnus-mime-view-part-externally "e" "View Externally")
3582 (gnus-mime-print-part "p" "Print")
3583 (gnus-mime-pipe-part "|" "Pipe To Command...")
3584 (gnus-mime-action-on-part "." "Take action on the part")))
3586 (defun gnus-article-mime-part-status ()
3587 (if gnus-article-mime-handle-alist-1
3588 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3590 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3593 (defvar gnus-mime-button-map
3594 (let ((map (make-sparse-keymap)))
3595 (unless (>= (string-to-number emacs-version) 21)
3596 ;; XEmacs doesn't care.
3597 (set-keymap-parent map gnus-article-mode-map))
3598 (define-key map gnus-mouse-2 'gnus-article-push-button)
3599 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3600 (dolist (c gnus-mime-button-commands)
3601 (define-key map (cadr c) (car c)))
3604 (defun gnus-mime-button-menu (event)
3605 "Construct a context-sensitive menu of MIME commands."
3607 (save-window-excursion
3608 (let ((pos (event-start event)))
3609 (select-window (posn-window pos))
3610 (goto-char (posn-point pos))
3611 (gnus-article-check-buffer)
3612 (let ((response (x-popup-menu
3614 ("" ,@(mapcar (lambda (c)
3615 (cons (caddr c) (car c)))
3616 gnus-mime-button-commands))))))
3618 (call-interactively response))))))
3620 (defun gnus-mime-view-all-parts (&optional handles)
3621 "View all the MIME parts."
3623 (save-current-buffer
3624 (set-buffer gnus-article-buffer)
3625 (let ((handles (or handles gnus-article-mime-handles))
3626 (mail-parse-charset gnus-newsgroup-charset)
3627 (mail-parse-ignored-charsets
3628 (with-current-buffer gnus-summary-buffer
3629 gnus-newsgroup-ignored-charsets)))
3631 (mm-remove-parts handles)
3632 (goto-char (point-min))
3633 (or (search-forward "\n\n") (goto-char (point-max)))
3634 (let (buffer-read-only)
3635 (delete-region (point) (point-max))
3636 (mm-display-parts handles))))))
3638 (defun gnus-mime-save-part-and-strip ()
3639 "Save the MIME part under point then replace it with an external body."
3641 (gnus-article-check-buffer)
3642 (let* ((data (get-text-property (point) 'gnus-data))
3644 (handles gnus-article-mime-handles))
3645 (if (mm-multiple-handles gnus-article-mime-handles)
3646 (error "This function is not implemented"))
3647 (setq file (and data (mm-save-part data)))
3649 (with-current-buffer (mm-handle-buffer data)
3651 (insert "Content-Type: " (mm-handle-media-type data))
3652 (mml-insert-parameter-string (cdr (mm-handle-type data))
3655 (insert "Content-ID: " (message-make-message-id) "\n")
3656 (insert "Content-Transfer-Encoding: binary\n")
3659 (cdr (mm-make-handle nil
3660 `("message/external-body"
3661 (access-type . "LOCAL-FILE")
3663 (set-buffer gnus-summary-buffer)
3664 (gnus-article-edit-article
3667 (let ((mail-parse-charset (or gnus-article-charset
3668 ',gnus-newsgroup-charset))
3669 (mail-parse-ignored-charsets
3670 (or gnus-article-ignored-charsets
3671 ',gnus-newsgroup-ignored-charsets))
3672 (mbl mml-buffer-list))
3673 (setq mml-buffer-list nil)
3674 (insert-buffer gnus-original-article-buffer)
3675 (mime-to-mml ',handles)
3676 (setq gnus-article-mime-handles nil)
3677 (let ((mbl1 mml-buffer-list))
3678 (setq mml-buffer-list mbl)
3679 (set (make-local-variable 'mml-buffer-list) mbl1))
3680 ;; LOCAL argument of add-hook differs between GNU Emacs
3681 ;; and XEmacs. make-local-hook makes sure they are local.
3682 (make-local-hook 'kill-buffer-hook)
3683 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3684 `(lambda (no-highlight)
3685 (let ((mail-parse-charset (or gnus-article-charset
3686 ',gnus-newsgroup-charset))
3687 (message-options message-options)
3688 (message-options-set-recipient)
3689 (mail-parse-ignored-charsets
3690 (or gnus-article-ignored-charsets
3691 ',gnus-newsgroup-ignored-charsets)))
3693 (mml-destroy-buffers)
3694 (remove-hook 'kill-buffer-hook
3695 'mml-destroy-buffers t)
3696 (kill-local-variable 'mml-buffer-list))
3697 (gnus-summary-edit-article-done
3698 ,(or (mail-header-references gnus-current-headers) "")
3699 ,(gnus-group-read-only-p)
3700 ,gnus-summary-buffer no-highlight))))))
3702 (defun gnus-mime-save-part ()
3703 "Save the MIME part under point."
3705 (gnus-article-check-buffer)
3706 (let ((data (get-text-property (point) 'gnus-data)))
3708 (mm-save-part data))))
3710 (defun gnus-mime-pipe-part ()
3711 "Pipe the MIME part under point to a process."
3713 (gnus-article-check-buffer)
3714 (let ((data (get-text-property (point) 'gnus-data)))
3716 (mm-pipe-part data))))
3718 (defun gnus-mime-view-part ()
3719 "Interactively choose a viewing method for the MIME part under point."
3721 (gnus-article-check-buffer)
3722 (let ((data (get-text-property (point) 'gnus-data)))
3724 (setq gnus-article-mime-handles
3726 gnus-article-mime-handles (setq data (copy-sequence data))))
3727 (mm-interactively-view-part data))))
3729 (defun gnus-mime-view-part-as-type-internal ()
3730 (gnus-article-check-buffer)
3731 (let* ((name (mail-content-type-get
3732 (mm-handle-type (get-text-property (point) 'gnus-data))
3734 (def-type (and name (mm-default-file-encoding name))))
3735 (and def-type (cons def-type 0))))
3737 (defun gnus-mime-view-part-as-type (&optional mime-type)
3738 "Choose a MIME media type, and view the part as such."
3741 (setq mime-type (completing-read
3742 "View as MIME type: "
3743 (mapcar #'list (mailcap-mime-types))
3745 (gnus-mime-view-part-as-type-internal))))
3746 (gnus-article-check-buffer)
3747 (let ((handle (get-text-property (point) 'gnus-data)))
3750 (mm-make-handle (mm-handle-buffer handle)
3751 (cons mime-type (cdr (mm-handle-type handle)))
3752 (mm-handle-encoding handle)
3753 (mm-handle-undisplayer handle)
3754 (mm-handle-disposition handle)
3755 (mm-handle-description handle)
3757 (mm-handle-id handle)))
3758 (setq gnus-article-mime-handles
3759 (mm-merge-handles gnus-article-mime-handles handle))
3760 (gnus-mm-display-part handle))))
3762 (defun gnus-mime-copy-part (&optional handle)
3763 "Put the MIME part under point into a new buffer."
3765 (gnus-article-check-buffer)
3766 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3767 (contents (and handle (mm-get-part handle)))
3769 (file-name-nondirectory
3771 (mail-content-type-get (mm-handle-type handle) 'name)
3772 (mail-content-type-get (mm-handle-type handle)
3775 (buffer (and base (generate-new-buffer base))))
3777 (switch-to-buffer buffer)
3779 ;; We do it this way to make `normal-mode' set the appropriate mode.
3782 (setq buffer-file-name (expand-file-name base))
3784 (setq buffer-file-name nil))
3785 (goto-char (point-min)))))
3787 (defun gnus-mime-print-part (&optional handle filename)
3788 "Print the MIME part under point."
3789 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3790 (gnus-article-check-buffer)
3791 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3792 (contents (and handle (mm-get-part handle)))
3793 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3794 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3799 (with-temp-file file
3801 (call-process shell-file-name nil
3802 (generate-new-buffer " *mm*")
3804 shell-command-switch
3806 printer file (mm-handle-type handle))))
3810 (gnus-print-buffer))
3811 (ps-despool filename)))))
3813 (defun gnus-mime-inline-part (&optional handle arg)
3814 "Insert the MIME part under point into the current buffer."
3815 (interactive (list nil current-prefix-arg))
3816 (gnus-article-check-buffer)
3817 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3822 (if (and (not arg) (mm-handle-undisplayer handle))
3823 (mm-remove-part handle)
3824 (setq contents (mm-get-part handle))
3827 (setq charset (or (mail-content-type-get
3828 (mm-handle-type handle) 'charset)
3829 gnus-newsgroup-charset)))
3831 (if (mm-handle-undisplayer handle)
3832 (mm-remove-part handle))
3835 gnus-summary-show-article-charset-alist))
3836 (mm-read-coding-system "Charset: ")))))
3838 (mm-insert-inline handle
3840 (setq charset (mm-charset-to-coding-system
3842 (not (eq charset 'ascii)))
3843 (mm-decode-coding-string contents charset)
3847 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3848 "Insert the MIME part under point into the current buffer using the
3850 (interactive (list nil current-prefix-arg))
3851 (gnus-article-check-buffer)
3852 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3857 (if (mm-handle-undisplayer handle)
3858 (mm-remove-part handle))
3859 (let ((gnus-newsgroup-charset
3861 gnus-summary-show-article-charset-alist))
3862 (mm-read-coding-system "Charset: ")))
3863 (gnus-newsgroup-ignored-charsets 'gnus-all))
3864 (gnus-article-press-button)))))
3866 (defun gnus-mime-view-part-externally (&optional handle)
3867 "View the MIME part under point with an external viewer."
3869 (gnus-article-check-buffer)
3870 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3871 (mm-user-display-methods nil)
3872 (mm-inlined-types nil)
3873 (mail-parse-charset gnus-newsgroup-charset)
3874 (mail-parse-ignored-charsets
3875 (save-excursion (set-buffer gnus-summary-buffer)
3876 gnus-newsgroup-ignored-charsets)))
3878 (if (mm-handle-undisplayer handle)
3879 (mm-remove-part handle)
3880 (mm-display-part handle)))))
3882 (defun gnus-mime-view-part-internally (&optional handle)
3883 "View the MIME part under point with an internal viewer.
3884 If no internal viewer is available, use an external viewer."
3886 (gnus-article-check-buffer)
3887 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3888 (mm-inlined-types '(".*"))
3889 (mm-inline-large-images t)
3890 (mail-parse-charset gnus-newsgroup-charset)
3891 (mail-parse-ignored-charsets
3892 (save-excursion (set-buffer gnus-summary-buffer)
3893 gnus-newsgroup-ignored-charsets)))
3895 (if (mm-handle-undisplayer handle)
3896 (mm-remove-part handle)
3897 (mm-display-part handle)))))
3899 (defun gnus-mime-action-on-part (&optional action)
3900 "Do something with the MIME attachment at \(point\)."
3902 (list (completing-read "Action: " gnus-mime-action-alist)))
3903 (gnus-article-check-buffer)
3904 (let ((action-pair (assoc action gnus-mime-action-alist)))
3906 (funcall (cdr action-pair)))))
3908 (defun gnus-article-part-wrapper (n function)
3909 (save-current-buffer
3910 (set-buffer gnus-article-buffer)
3911 (when (> n (length gnus-article-mime-handle-alist))
3912 (error "No such part"))
3913 (gnus-article-goto-part n)
3914 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3915 (funcall function handle))))
3917 (defun gnus-article-pipe-part (n)
3918 "Pipe MIME part N, which is the numerical prefix."
3920 (gnus-article-part-wrapper n 'mm-pipe-part))
3922 (defun gnus-article-save-part (n)
3923 "Save MIME part N, which is the numerical prefix."
3925 (gnus-article-part-wrapper n 'mm-save-part))
3927 (defun gnus-article-interactively-view-part (n)
3928 "View MIME part N interactively, which is the numerical prefix."
3930 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3932 (defun gnus-article-copy-part (n)
3933 "Copy MIME part N, which is the numerical prefix."
3935 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3937 (defun gnus-article-view-part-as-charset (n)
3938 "Copy MIME part N, which is the numerical prefix."
3940 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3942 (defun gnus-article-view-part-externally (n)
3943 "View MIME part N externally, which is the numerical prefix."
3945 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
3947 (defun gnus-article-inline-part (n)
3948 "Inline MIME part N, which is the numerical prefix."
3950 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3952 (defun gnus-article-mime-match-handle-first (condition)
3954 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3955 (while (setq ihandle (pop alist))
3957 ((functionp condition)
3958 (funcall condition (cdr ihandle)))
3959 ((eq condition 'undisplayed)
3960 (not (or (mm-handle-undisplayer (cdr ihandle))
3961 (equal (mm-handle-media-type (cdr ihandle))
3962 "multipart/alternative"))))
3963 ((eq condition 'undisplayed-alternative)
3964 (not (mm-handle-undisplayer (cdr ihandle))))
3966 (gnus-article-goto-part (car ihandle))
3967 (or (not n) (< (car ihandle) n)))
3968 (setq n (car ihandle))))
3972 (defun gnus-article-view-part (&optional n)
3973 "View MIME part N, which is the numerical prefix."
3975 (save-current-buffer
3976 (set-buffer gnus-article-buffer)
3977 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3978 gnus-article-mime-match-handle-function)))
3979 (when (> n (length gnus-article-mime-handle-alist))
3980 (error "No such part"))
3981 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3982 (when (gnus-article-goto-part n)
3983 (if (equal (car handle) "multipart/alternative")
3984 (gnus-article-press-button)
3985 (when (eq (gnus-mm-display-part handle) 'internal)
3986 (gnus-set-window-start)))))))
3988 (defsubst gnus-article-mime-total-parts ()
3989 (if (bufferp (car gnus-article-mime-handles))
3991 (1- (length gnus-article-mime-handles))))
3993 (defun gnus-mm-display-part (handle)
3994 "Display HANDLE and fix MIME button."
3995 (let ((id (get-text-property (point) 'gnus-part))
4000 (let ((window (selected-window))
4001 (mail-parse-charset gnus-newsgroup-charset)
4002 (mail-parse-ignored-charsets
4003 (if (gnus-buffer-live-p gnus-summary-buffer)
4005 (set-buffer gnus-summary-buffer)
4006 gnus-newsgroup-ignored-charsets)
4010 (let ((win (gnus-get-buffer-window (current-buffer) t))
4013 (select-window win))
4016 (if (mm-handle-displayed-p handle)
4017 ;; This will remove the part.
4018 (mm-display-part handle)
4020 (narrow-to-region (point)
4021 (if (eobp) (point) (1+ (point))))
4022 (mm-display-part handle)
4023 ;; We narrow to the part itself and
4024 ;; then call the treatment functions.
4025 (goto-char (point-min))
4027 (narrow-to-region (point) (point-max))
4030 (gnus-article-mime-total-parts)
4031 (mm-handle-media-type handle)))))
4032 (if (window-live-p window)
4033 (select-window window)))))
4035 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4036 (gnus-insert-mime-button
4037 handle id (list (mm-handle-displayed-p handle)))
4038 (goto-char point))))
4040 (defun gnus-article-goto-part (n)
4041 "Go to MIME part N."
4042 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4044 (goto-char point))))
4046 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4047 (let ((gnus-tmp-name
4048 (or (mail-content-type-get (mm-handle-type handle) 'name)
4049 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4050 (mail-content-type-get (mm-handle-type handle) 'url)
4052 (gnus-tmp-type (mm-handle-media-type handle))
4053 (gnus-tmp-description
4054 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4057 (if (if displayed (car displayed)
4058 (mm-handle-displayed-p handle))
4060 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4062 gnus-tmp-type-long b e)
4063 (when (string-match ".*/" gnus-tmp-name)
4064 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4065 (setq gnus-tmp-type-long (concat gnus-tmp-type
4066 (and (not (equal gnus-tmp-name ""))
4067 (concat "; " gnus-tmp-name))))
4068 (unless (equal gnus-tmp-description "")
4069 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4074 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4075 `(,@(gnus-local-map-property gnus-mime-button-map)
4076 gnus-callback gnus-mm-display-part
4077 gnus-part ,gnus-tmp-id
4078 article-type annotation
4081 (widget-convert-button
4084 :action 'gnus-widget-press-button
4085 :button-keymap gnus-mime-button-map
4087 (lambda (widget/window &optional overlay pos)
4088 ;; Needed to properly clear the message due to a bug in
4089 ;; wid-edit (XEmacs only).
4090 (if (boundp 'help-echo-owns-message)
4091 (setq help-echo-owns-message t))
4093 "%S: %s the MIME part; %S: more options"
4094 (aref gnus-mouse-2 0)
4095 ;; XEmacs will get a single widget arg; Emacs 21 will get
4096 ;; window, overlay, position.
4097 (if (mm-handle-displayed-p
4099 (with-current-buffer (gnus-overlay-buffer overlay)
4100 (widget-get (widget-at (gnus-overlay-start overlay))
4102 (widget-get widget/window :mime-handle)))
4104 (aref gnus-down-mouse-3 0))))))
4106 (defun gnus-widget-press-button (elems el)
4107 (goto-char (widget-get elems :from))
4108 (gnus-article-press-button))
4110 (defvar gnus-displaying-mime nil)
4112 (defun gnus-display-mime (&optional ihandles)
4113 "Display the MIME parts."
4115 (save-selected-window
4116 (let ((window (get-buffer-window gnus-article-buffer))
4119 (select-window window)
4120 ;; We have to do this since selecting the window
4121 ;; may change the point. So we set the window point.
4122 (set-window-point window point)))
4123 (let* ((handles (or ihandles (mm-dissect-buffer
4124 nil gnus-article-loose-mime)
4126 buffer-read-only handle name type b e display)
4127 (when (and (not ihandles)
4128 (not gnus-displaying-mime))
4129 ;; Top-level call; we clean up.
4130 (when gnus-article-mime-handles
4131 (mm-destroy-parts gnus-article-mime-handles)
4132 (setq gnus-article-mime-handle-alist nil));; A trick.
4133 (setq gnus-article-mime-handles handles)
4134 ;; We allow users to glean info from the handles.
4135 (when gnus-article-mime-part-function
4136 (gnus-mime-part-function handles)))
4138 (or (not (stringp (car handles)))
4141 (when (and (not ihandles)
4142 (not gnus-displaying-mime))
4143 ;; Clean up for mime parts.
4145 (delete-region (point) (point-max)))
4146 (let ((gnus-displaying-mime t))
4147 (gnus-mime-display-part handles)))
4150 (narrow-to-region (point) (point-max))
4151 (gnus-treat-article nil 1 1)
4154 ;; Highlight the headers.
4158 (narrow-to-region (point-min) (point))
4159 (gnus-treat-article 'head))))))))
4161 (defvar gnus-mime-display-multipart-as-mixed nil)
4162 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4163 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4165 (defun gnus-mime-display-part (handle)
4168 ((not (stringp (car handle)))
4169 (gnus-mime-display-single handle))
4170 ;; User-defined multipart
4171 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4172 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4174 ;; multipart/alternative
4175 ((and (equal (car handle) "multipart/alternative")
4176 (not (or gnus-mime-display-multipart-as-mixed
4177 gnus-mime-display-multipart-alternative-as-mixed)))
4178 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4179 (push (cons id handle) gnus-article-mime-handle-alist)
4180 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4181 ;; multipart/related
4182 ((and (equal (car handle) "multipart/related")
4183 (not (or gnus-mime-display-multipart-as-mixed
4184 gnus-mime-display-multipart-related-as-mixed)))
4185 ;;;!!!We should find the start part, but we just default
4186 ;;;!!!to the first part.
4187 ;;(gnus-mime-display-part (cadr handle))
4188 ;;;!!! Most multipart/related is an HTML message plus images.
4189 ;;;!!! Unfortunately we are unable to let W3 display those
4190 ;;;!!! included images, so we just display it as a mixed multipart.
4191 ;;(gnus-mime-display-mixed (cdr handle))
4192 ;;;!!! No, w3 can display everything just fine.
4193 (gnus-mime-display-part (cadr handle)))
4194 ((equal (car handle) "multipart/signed")
4195 (gnus-add-wash-type 'signed)
4196 (gnus-mime-display-security handle))
4197 ((equal (car handle) "multipart/encrypted")
4198 (gnus-add-wash-type 'encrypted)
4199 (gnus-mime-display-security handle))
4200 ;; Other multiparts are handled like multipart/mixed.
4202 (gnus-mime-display-mixed (cdr handle)))))
4204 (defun gnus-mime-part-function (handles)
4205 (if (stringp (car handles))
4206 (mapcar 'gnus-mime-part-function (cdr handles))
4207 (funcall gnus-article-mime-part-function handles)))
4209 (defun gnus-mime-display-mixed (handles)
4210 (mapcar 'gnus-mime-display-part handles))
4212 (defun gnus-mime-display-single (handle)
4213 (let ((type (mm-handle-media-type handle))
4214 (ignored gnus-ignored-mime-types)
4221 (when (string-match (pop ignored) type)
4222 (throw 'ignored nil)))
4223 (if (and (setq not-attachment
4224 (and (not (mm-inline-override-p handle))
4225 (or (not (mm-handle-disposition handle))
4226 (equal (car (mm-handle-disposition handle))
4228 (mm-attachment-override-p handle))))
4229 (mm-automatic-display-p handle)
4231 (mm-inlinable-p handle)
4232 (mm-inlined-p handle))
4233 (mm-automatic-external-display-p type)))
4235 (when (equal (mm-handle-media-supertype handle) "text")
4237 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4239 (push (cons id handle) gnus-article-mime-handle-alist)
4240 (when (or (not display)
4241 (not (gnus-unbuttonized-mime-type-p type)))
4242 ;(gnus-article-insert-newline)
4243 (gnus-insert-mime-button
4244 handle id (list (or display (and not-attachment text))))
4245 (gnus-article-insert-newline)
4246 ;(gnus-article-insert-newline)
4247 ;; Remember modify the number of forward lines.
4255 (let ((mail-parse-charset gnus-newsgroup-charset)
4256 (mail-parse-ignored-charsets
4257 (save-excursion (condition-case ()
4258 (set-buffer gnus-summary-buffer)
4260 gnus-newsgroup-ignored-charsets)))
4261 (mm-display-part handle t))
4262 (goto-char (point-max)))
4263 ((and text not-attachment)
4267 (gnus-article-insert-newline)
4268 (mm-insert-inline handle (mm-get-part handle))
4269 (goto-char (point-max))))
4273 (narrow-to-region beg (point))
4276 (gnus-article-mime-total-parts)
4277 (mm-handle-media-type handle)))))))))
4279 (defun gnus-unbuttonized-mime-type-p (type)
4280 "Say whether TYPE is to be unbuttonized."
4281 (unless gnus-inhibit-mime-unbuttonizing
4283 (let ((types gnus-unbuttonized-mime-types))
4285 (when (string-match (pop types) type)
4286 (throw 'found t)))))
4288 (let ((types gnus-buttonized-mime-types))
4290 (when (string-match (pop types) type)
4291 (throw 'found t)))))))))
4293 (defun gnus-article-insert-newline ()
4294 "Insert a newline, but mark it as undeletable."
4295 (gnus-put-text-property
4296 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4298 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4299 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4302 handle buffer-read-only from props begend not-pref)
4303 (save-window-excursion
4306 (narrow-to-region (car ibegend)
4309 (goto-char (car ibegend))
4312 (delete-region (point-min) (point-max))
4313 (mm-remove-parts handles))
4314 (setq begend (list (point-marker)))
4316 (unless (setq not-pref (cadr (member preferred ihandles)))
4317 (setq not-pref (car ihandles)))
4320 (not (gnus-unbuttonized-mime-type-p
4321 "multipart/alternative")))
4322 (gnus-add-text-properties
4325 (insert (format "%d. " id))
4329 (unless ,(not ibegend)
4330 (setq gnus-article-mime-handle-alist
4331 ',gnus-article-mime-handle-alist))
4332 (gnus-mime-display-alternative
4333 ',ihandles ',not-pref ',begend ,id))
4334 ,@(gnus-local-map-property gnus-mime-button-map)
4335 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4336 face ,gnus-article-button-face
4339 (widget-convert-button 'link from (point)
4340 :action 'gnus-widget-press-button
4341 :button-keymap gnus-widget-button-keymap)
4343 (while (setq handle (pop handles))
4344 (gnus-add-text-properties
4347 (insert (format "(%c) %-18s"
4348 (if (equal handle preferred) ?* ? )
4349 (mm-handle-media-type handle)))
4353 (unless ,(not ibegend)
4354 (setq gnus-article-mime-handle-alist
4355 ',gnus-article-mime-handle-alist))
4356 (gnus-mime-display-alternative
4357 ',ihandles ',handle ',begend ,id))
4358 ,@(gnus-local-map-property gnus-mime-button-map)
4359 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4360 face ,gnus-article-button-face
4363 (widget-convert-button 'link from (point)
4364 :action 'gnus-widget-press-button
4365 :button-keymap gnus-widget-button-keymap)
4369 (if (stringp (car preferred))
4370 (gnus-display-mime preferred)
4371 (let ((mail-parse-charset gnus-newsgroup-charset)
4372 (mail-parse-ignored-charsets
4373 (save-excursion (set-buffer gnus-summary-buffer)
4374 gnus-newsgroup-ignored-charsets)))
4375 (mm-display-part preferred)
4379 (narrow-to-region (car begend) (point-max))
4381 nil (length gnus-article-mime-handle-alist)
4382 (gnus-article-mime-total-parts)
4383 (mm-handle-media-type handle))))))
4384 (goto-char (point-max))
4385 (setcdr begend (point-marker)))))
4387 (goto-char point))))
4389 (defconst gnus-article-wash-status-strings
4390 (let ((alist '((cite "c" "Possible hidden citation text"
4391 " " "All citation text visible")
4392 (headers "h" "Hidden headers"
4393 " " "All headers visible.")
4394 (pgp "p" "Encrypted or signed message status hidden"
4395 " " "No hidden encryption nor digital signature status")
4396 (signature "s" "Signature has been hidden"
4397 " " "Signature is visible")
4398 (overstrike "o" "Overstrike (^H) characters applied"
4399 " " "No overstrike characters applied")
4400 (emphasis "e" "/*_Emphasis_*/ characters applied"
4401 " " "No /*_emphasis_*/ characters applied")))
4403 (dolist (entry alist result)
4404 (let ((key (nth 0 entry))
4405 (on (copy-sequence (nth 1 entry)))
4406 (on-help (nth 2 entry))
4407 (off (copy-sequence (nth 3 entry)))
4408 (off-help (nth 4 entry)))
4409 (put-text-property 0 1 'help-echo on-help on)
4410 (put-text-property 0 1 'help-echo off-help off)
4411 (push (list key on off) result))))
4412 "Alist of strings describing wash status in the mode line.
4413 Each entry has the form (KEY ON OF), where the KEY is a symbol
4414 representing the particular washing function, ON is the string to use
4415 in the article mode line when the washing function is active, and OFF
4416 is the string to use when it is inactive.")
4418 (defun gnus-article-wash-status-entry (key value)
4419 (let ((entry (assoc key gnus-article-wash-status-strings)))
4420 (if value (nth 1 entry) (nth 2 entry))))
4422 (defun gnus-article-wash-status ()
4423 "Return a string which display status of article washing."
4425 (set-buffer gnus-article-buffer)
4426 (let ((cite (memq 'cite gnus-article-wash-types))
4427 (headers (memq 'headers gnus-article-wash-types))
4428 (boring (memq 'boring-headers gnus-article-wash-types))
4429 (pgp (memq 'pgp gnus-article-wash-types))
4430 (pem (memq 'pem gnus-article-wash-types))
4431 (signed (memq 'signed gnus-article-wash-types))
4432 (encrypted (memq 'encrypted gnus-article-wash-types))
4433 (signature (memq 'signature gnus-article-wash-types))
4434 (overstrike (memq 'overstrike gnus-article-wash-types))
4435 (emphasis (memq 'emphasis gnus-article-wash-types)))
4437 (gnus-article-wash-status-entry 'cite cite)
4438 (gnus-article-wash-status-entry 'headers (or headers boring))
4439 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4440 (gnus-article-wash-status-entry 'signature signature)
4441 (gnus-article-wash-status-entry 'overstrike overstrike)
4442 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4444 (defun gnus-add-wash-type (type)
4445 "Add a washing of TYPE to the current status."
4446 (add-to-list 'gnus-article-wash-types type))
4448 (defun gnus-delete-wash-type (type)
4449 "Add a washing of TYPE to the current status."
4450 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4452 (defun gnus-add-image (category image)
4453 "Add IMAGE of CATEGORY to the list of displayed images."
4454 (let ((entry (assq category gnus-article-image-alist)))
4456 (setq entry (list category))
4457 (push entry gnus-article-image-alist))
4458 (nconc entry (list image))))
4460 (defun gnus-delete-images (category)
4461 "Delete all images in CATEGORY."
4462 (let ((entry (assq category gnus-article-image-alist)))
4463 (dolist (image (cdr entry))
4464 (gnus-remove-image image))
4465 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4466 (gnus-delete-wash-type category)))
4468 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4470 (defun gnus-article-maybe-hide-headers ()
4471 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4472 Provided for backwards compatibility."
4473 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4474 (not (save-excursion (set-buffer gnus-summary-buffer)
4475 gnus-have-all-headers)))
4476 (not gnus-inhibit-hiding))
4477 (gnus-article-hide-headers)))
4481 (defun gnus-output-to-file (file-name)
4482 "Append the current article to a file named FILE-NAME."
4483 (let ((artbuf (current-buffer)))
4485 (insert-buffer-substring artbuf)
4486 ;; Append newline at end of the buffer as separator, and then
4488 (goto-char (point-max))
4490 (let ((file-name-coding-system nnmail-pathname-coding-system))
4491 (mm-append-to-file (point-min) (point-max) file-name))
4494 (defun gnus-narrow-to-page (&optional arg)
4495 "Narrow the article buffer to a page.
4496 If given a numerical ARG, move forward ARG pages."
4498 (setq arg (if arg (prefix-numeric-value arg) 0))
4500 (set-buffer gnus-article-buffer)
4501 (goto-char (point-min))
4503 ;; Remove any old next/prev buttons.
4504 (when (gnus-visual-p 'page-marker)
4505 (let ((buffer-read-only nil))
4506 (gnus-remove-text-with-property 'gnus-prev)
4507 (gnus-remove-text-with-property 'gnus-next)))
4510 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4512 (re-search-forward page-delimiter nil 'move arg)))
4513 (goto-char (match-end 0)))
4516 (if (re-search-forward page-delimiter nil 'move)
4519 (when (and (gnus-visual-p 'page-marker)
4520 (not (= (point-min) 1)))
4522 (goto-char (point-min))
4523 (gnus-insert-prev-page-button)))
4524 (when (and (gnus-visual-p 'page-marker)
4525 (< (+ (point-max) 2) (buffer-size)))
4527 (goto-char (point-max))
4528 (gnus-insert-next-page-button)))))
4530 ;; Article mode commands
4532 (defun gnus-article-goto-next-page ()
4533 "Show the next page of the article."
4535 (when (gnus-article-next-page)
4536 (goto-char (point-min))
4537 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4539 (defun gnus-article-goto-prev-page ()
4540 "Show the next page of the article."
4542 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4543 (gnus-article-prev-page nil)))
4545 (defun gnus-article-next-page (&optional lines)
4546 "Show the next page of the current article.
4547 If end of article, return non-nil. Otherwise return nil.
4548 Argument LINES specifies lines to be scrolled up."
4550 (move-to-window-line -1)
4553 (and (pos-visible-in-window-p) ;Not continuation line.
4555 ;; Nothing in this page.
4556 (if (or (not gnus-page-broken)
4559 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4561 (gnus-narrow-to-page 1) ;Go to next page.
4563 ;; More in this page.
4564 (let ((scroll-in-place nil))
4568 ;; Long lines may cause an end-of-buffer error.
4569 (goto-char (point-max)))))
4570 (move-to-window-line 0)
4573 (defun gnus-article-prev-page (&optional lines)
4574 "Show previous page of current article.
4575 Argument LINES specifies lines to be scrolled down."
4577 (move-to-window-line 0)
4578 (if (and gnus-page-broken
4580 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4582 (gnus-narrow-to-page -1) ;Go to previous page.
4583 (goto-char (point-max))
4585 (let ((scroll-in-place nil))
4589 (beginning-of-buffer
4590 (goto-char (point-min))))
4591 (move-to-window-line 0)))))
4593 (defun gnus-article-refer-article ()
4594 "Read article specified by message-id around point."
4596 (let ((point (point)))
4597 (search-forward ">" nil t) ;Move point to end of "<....>".
4598 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4599 (let ((message-id (match-string 1)))
4601 (set-buffer gnus-summary-buffer)
4602 (gnus-summary-refer-article message-id))
4604 (error "No references around point"))))
4606 (defun gnus-article-show-summary ()
4607 "Reconfigure windows to show summary buffer."
4609 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4610 (error "There is no summary buffer for this article buffer")
4611 (gnus-article-set-globals)
4612 (gnus-configure-windows 'article)
4613 (gnus-summary-goto-subject gnus-current-article)
4614 (gnus-summary-position-point)))
4616 (defun gnus-article-describe-briefly ()
4617 "Describe article mode commands briefly."
4619 (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")))
4621 (defun gnus-article-summary-command ()
4622 "Execute the last keystroke in the summary buffer."
4624 (let ((obuf (current-buffer))
4625 (owin (current-window-configuration))
4627 (switch-to-buffer gnus-article-current-summary 'norecord)
4628 (setq func (lookup-key (current-local-map) (this-command-keys)))
4629 (call-interactively func)
4631 (set-window-configuration owin)
4632 (set-window-point (get-buffer-window (current-buffer)) (point))))
4634 (defun gnus-article-summary-command-nosave ()
4635 "Execute the last keystroke in the summary buffer."
4638 (pop-to-buffer gnus-article-current-summary 'norecord)
4639 (setq func (lookup-key (current-local-map) (this-command-keys)))
4640 (call-interactively func)))
4642 (defun gnus-article-check-buffer ()
4643 "Beep if not in an article buffer."
4644 (unless (equal major-mode 'gnus-article-mode)
4645 (error "Command invoked outside of a Gnus article buffer")))
4647 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4648 "Read a summary buffer key sequence and execute it from the article buffer."
4650 (gnus-article-check-buffer)
4652 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4653 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4654 "=" "^" "\M-^" "|"))
4660 '("n" "Gn" "p" "Gp"))
4663 (set-buffer gnus-article-current-summary)
4664 (let (gnus-pick-mode)
4665 (push (or key last-command-event) unread-command-events)
4666 (setq keys (if (featurep 'xemacs)
4667 (events-to-keys (read-key-sequence nil))
4668 (read-key-sequence nil)))))
4672 (if (or (member keys nosaves)
4673 (member keys nosave-but-article)
4674 (member keys nosave-in-article))
4676 (save-window-excursion
4677 (pop-to-buffer gnus-article-current-summary 'norecord)
4678 ;; We disable the pick minor mode commands.
4679 (let (gnus-pick-mode)
4680 (setq func (lookup-key (current-local-map) keys))))
4684 (unless (member keys nosave-in-article)
4685 (set-buffer gnus-article-current-summary))
4686 (call-interactively func)
4687 (setq new-sum-point (point)))
4688 (when (member keys nosave-but-article)
4689 (pop-to-buffer gnus-article-buffer 'norecord)))
4690 ;; These commands should restore window configuration.
4691 (let ((obuf (current-buffer))
4692 (owin (current-window-configuration))
4694 (summary gnus-article-current-summary)
4695 func in-buffer selected)
4696 (if not-restore-window
4697 (pop-to-buffer summary 'norecord)
4698 (switch-to-buffer summary 'norecord))
4699 (setq in-buffer (current-buffer))
4700 ;; We disable the pick minor mode commands.
4701 (if (and (setq func (let (gnus-pick-mode)
4702 (lookup-key (current-local-map) keys)))
4705 (call-interactively func)
4706 (setq new-sum-point (point))
4707 (when (eq in-buffer (current-buffer))
4708 (setq selected (gnus-summary-select-article))
4710 (unless not-restore-window
4711 (set-window-configuration owin))
4712 (when (eq selected 'old)
4714 (set-window-start (get-buffer-window (current-buffer))
4716 (set-window-point (get-buffer-window (current-buffer))
4718 (let ((win (get-buffer-window gnus-article-current-summary)))
4720 (set-window-point win new-sum-point)))) )
4721 (switch-to-buffer gnus-article-buffer)
4724 (defun gnus-article-describe-key (key)
4725 "Display documentation of the function invoked by KEY. KEY is a string."
4726 (interactive "kDescribe key: ")
4727 (gnus-article-check-buffer)
4728 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4730 (set-buffer gnus-article-current-summary)
4731 (let (gnus-pick-mode)
4732 (if (featurep 'xemacs)
4734 (push (elt key 0) unread-command-events)
4735 (setq key (events-to-keys
4736 (read-key-sequence "Describe key: "))))
4737 (setq unread-command-events
4739 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4740 (string-to-list key)))
4741 (setq key (read-key-sequence "Describe key: "))))
4743 (describe-key key)))
4745 (defun gnus-article-describe-key-briefly (key &optional insert)
4746 "Display documentation of the function invoked by KEY. KEY is a string."
4747 (interactive "kDescribe key: \nP")
4748 (gnus-article-check-buffer)
4749 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4751 (set-buffer gnus-article-current-summary)
4752 (let (gnus-pick-mode)
4753 (if (featurep 'xemacs)
4755 (push (elt key 0) unread-command-events)
4756 (setq key (events-to-keys
4757 (read-key-sequence "Describe key: "))))
4758 (setq unread-command-events
4760 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4761 (string-to-list key)))
4762 (setq key (read-key-sequence "Describe key: "))))
4763 (describe-key-briefly key insert))
4764 (describe-key-briefly key insert)))
4766 (defun gnus-article-reply-with-original (&optional wide)
4767 "Start composing a reply mail to the current message.
4768 The text in the region will be yanked. If the region isn't active,
4769 the entire article will be yanked."
4771 (let ((article (cdr gnus-article-current)) cont)
4773 (gnus-summary-reply (list (list article)) wide)
4774 (setq cont (buffer-substring (point) (mark t)))
4775 ;; Deactivate active regions.
4776 (when (and (boundp 'transient-mark-mode)
4777 transient-mark-mode)
4778 (setq mark-active nil))
4780 (list (list article cont)) wide))))
4782 (defun gnus-article-followup-with-original ()
4783 "Compose a followup to the current article.
4784 The text in the region will be yanked. If the region isn't active,
4785 the entire article will be yanked."
4787 (let ((article (cdr gnus-article-current))
4790 (gnus-summary-followup (list (list article)))
4791 (setq cont (buffer-substring (point) (mark t)))
4792 ;; Deactivate active regions.
4793 (when (and (boundp 'transient-mark-mode)
4794 transient-mark-mode)
4795 (setq mark-active nil))
4796 (gnus-summary-followup
4797 (list (list article cont))))))
4799 (defun gnus-article-hide (&optional arg force)
4800 "Hide all the gruft in the current article.
4801 This means that PGP stuff, signatures, cited text and (some)
4802 headers will be hidden.
4803 If given a prefix, show the hidden text instead."
4804 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4805 (gnus-article-hide-headers arg)
4806 (gnus-article-hide-list-identifiers arg)
4807 (gnus-article-hide-pgp arg)
4808 (gnus-article-hide-citation-maybe arg force)
4809 (gnus-article-hide-signature arg))
4811 (defun gnus-article-maybe-highlight ()
4812 "Do some article highlighting if article highlighting is requested."
4813 (when (gnus-visual-p 'article-highlight 'highlight)
4814 (gnus-article-highlight-some)))
4816 (defun gnus-check-group-server ()
4817 ;; Make sure the connection to the server is alive.
4818 (unless (gnus-server-opened
4819 (gnus-find-method-for-group gnus-newsgroup-name))
4820 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4821 (gnus-request-group gnus-newsgroup-name t)))
4824 (autoload 'nneething-get-file-name "nneething"))
4826 (defun gnus-request-article-this-buffer (article group)
4827 "Get an article and insert it into this buffer."
4828 (let (do-update-line sparse-header)
4832 (gnus-kill-all-overlays)
4833 (setq group (or group gnus-newsgroup-name))
4835 ;; Using `gnus-request-article' directly will insert the article into
4836 ;; `nntp-server-buffer' - so we'll save some time by not having to
4837 ;; copy it from the server buffer into the article buffer.
4839 ;; We only request an article by message-id when we do not have the
4840 ;; headers for it, so we'll have to get those.
4841 (when (stringp article)
4842 (gnus-read-header article))
4844 ;; If the article number is negative, that means that this article
4845 ;; doesn't belong in this newsgroup (possibly), so we find its
4846 ;; message-id and request it by id instead of number.
4847 (when (and (numberp article)
4849 (get-buffer gnus-summary-buffer)
4850 (gnus-buffer-exists-p gnus-summary-buffer))
4852 (set-buffer gnus-summary-buffer)
4853 (let ((header (gnus-summary-article-header article)))
4856 ((memq article gnus-newsgroup-sparse)
4857 ;; This is a sparse gap article.
4858 (setq do-update-line article)
4859 (setq article (mail-header-id header))
4860 (setq sparse-header (gnus-read-header article))
4861 (setq gnus-newsgroup-sparse
4862 (delq article gnus-newsgroup-sparse)))
4864 ;; It's a real article.
4865 (setq article (mail-header-id header)))
4867 ;; It is an extracted pseudo-article.
4868 (setq article 'pseudo)
4869 (gnus-request-pseudo-article header))))
4871 (let ((method (gnus-find-method-for-group
4872 gnus-newsgroup-name)))
4873 (when (and (eq (car method) 'nneething)
4875 (let ((dir (nneething-get-file-name
4876 (mail-header-id header))))
4877 (when (and (stringp dir)
4878 (file-directory-p dir))
4879 (setq article 'nneething)
4880 (gnus-group-enter-directory dir))))))))
4883 ;; Refuse to select canceled articles.
4884 ((and (numberp article)
4886 (get-buffer gnus-summary-buffer)
4887 (gnus-buffer-exists-p gnus-summary-buffer)
4888 (eq (cdr (save-excursion
4889 (set-buffer gnus-summary-buffer)
4890 (assq article gnus-newsgroup-reads)))
4891 gnus-canceled-mark))
4893 ;; We first check `gnus-original-article-buffer'.
4894 ((and (get-buffer gnus-original-article-buffer)
4897 (set-buffer gnus-original-article-buffer)
4898 (and (equal (car gnus-original-article) group)
4899 (eq (cdr gnus-original-article) article))))
4900 (insert-buffer-substring gnus-original-article-buffer)
4902 ;; Check the backlog.
4903 ((and gnus-keep-backlog
4904 (gnus-backlog-request-article group article (current-buffer)))
4906 ;; Check asynchronous pre-fetch.
4907 ((gnus-async-request-fetched-article group article (current-buffer))
4908 (gnus-async-prefetch-next group article gnus-summary-buffer)
4909 (when (and (numberp article) gnus-keep-backlog)
4910 (gnus-backlog-enter-article group article (current-buffer)))
4913 ((and gnus-use-cache
4915 (gnus-cache-request-article article group))
4917 ;; Check the agent cache.
4918 ((and gnus-agent gnus-agent-cache gnus-plugged
4920 (gnus-agent-request-article article group))
4922 ;; Get the article and put into the article buffer.
4923 ((or (stringp article)
4925 (let ((gnus-override-method gnus-override-method)
4926 (methods (and (stringp article)
4927 gnus-refer-article-method))
4929 (buffer-read-only nil))
4930 (if (or (not (listp methods))
4931 (and (symbolp (car methods))
4932 (assq (car methods) nnoo-definition-alist)))
4933 (setq methods (list methods)))
4934 (when (and (null gnus-override-method)
4936 (setq gnus-override-method (pop methods)))
4938 (when (eq gnus-override-method 'current)
4939 (setq gnus-override-method
4940 (with-current-buffer gnus-summary-buffer
4941 gnus-current-select-method)))
4943 (gnus-kill-all-overlays)
4944 (let ((gnus-newsgroup-name group))
4945 (gnus-check-group-server))
4946 (when (gnus-request-article article group (current-buffer))
4947 (when (numberp article)
4948 (gnus-async-prefetch-next group article
4949 gnus-summary-buffer)
4950 (when gnus-keep-backlog
4951 (gnus-backlog-enter-article
4952 group article (current-buffer))))
4953 (setq result 'article))
4956 (setq gnus-override-method (pop methods))
4957 (setq result 'done))))
4958 (and (eq result 'article) 'article)))
4962 ;; Associate this article with the current summary buffer.
4963 (setq gnus-article-current-summary gnus-summary-buffer)
4965 ;; Take the article from the original article buffer
4966 ;; and place it in the buffer it's supposed to be in.
4967 (when (and (get-buffer gnus-article-buffer)
4968 (equal (buffer-name (current-buffer))
4969 (buffer-name (get-buffer gnus-article-buffer))))
4971 (if (get-buffer gnus-original-article-buffer)
4972 (set-buffer gnus-original-article-buffer)
4973 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4974 (buffer-disable-undo)
4975 (setq major-mode 'gnus-original-article-mode)
4976 (setq buffer-read-only t))
4977 (let (buffer-read-only)
4979 (insert-buffer-substring gnus-article-buffer))
4980 (setq gnus-original-article (cons group article)))
4983 (run-hooks 'gnus-article-decode-hook)
4984 ;; Mark article as decoded or not.
4985 (setq gnus-article-decoded-p gnus-article-decode-hook))
4987 ;; Update sparse articles.
4988 (when (and do-update-line
4989 (or (numberp article)
4991 (let ((buf (current-buffer)))
4992 (set-buffer gnus-summary-buffer)
4993 (gnus-summary-update-article do-update-line sparse-header)
4994 (gnus-summary-goto-subject do-update-line nil t)
4995 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4997 (set-buffer buf))))))
5003 (defcustom gnus-article-edit-mode-hook nil
5004 "Hook run in article edit mode buffers."
5005 :group 'gnus-article-various
5008 (defvar gnus-article-edit-done-function nil)
5010 (defvar gnus-article-edit-mode-map nil)
5012 ;; Should we be using derived.el for this?
5013 (unless gnus-article-edit-mode-map
5014 (setq gnus-article-edit-mode-map (make-keymap))
5015 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5018 (gnus-define-keys gnus-article-edit-mode-map
5019 "\C-c?" describe-mode
5020 "\C-c\C-c" gnus-article-edit-done
5021 "\C-c\C-k" gnus-article-edit-exit
5022 "\C-c\C-f\C-t" message-goto-to
5023 "\C-c\C-f\C-o" message-goto-from
5024 "\C-c\C-f\C-b" message-goto-bcc
5025 ;;"\C-c\C-f\C-w" message-goto-fcc
5026 "\C-c\C-f\C-c" message-goto-cc
5027 "\C-c\C-f\C-s" message-goto-subject
5028 "\C-c\C-f\C-r" message-goto-reply-to
5029 "\C-c\C-f\C-n" message-goto-newsgroups
5030 "\C-c\C-f\C-d" message-goto-distribution
5031 "\C-c\C-f\C-f" message-goto-followup-to
5032 "\C-c\C-f\C-m" message-goto-mail-followup-to
5033 "\C-c\C-f\C-k" message-goto-keywords
5034 "\C-c\C-f\C-u" message-goto-summary
5035 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5036 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5037 "\C-c\C-b" message-goto-body
5038 "\C-c\C-i" message-goto-signature
5040 "\C-c\C-t" message-insert-to
5041 "\C-c\C-n" message-insert-newsgroups
5042 "\C-c\C-o" message-sort-headers
5043 "\C-c\C-e" message-elide-region
5044 "\C-c\C-v" message-delete-not-region
5045 "\C-c\C-z" message-kill-to-signature
5046 "\M-\r" message-newline-and-reformat
5047 "\C-c\C-a" mml-attach-file
5048 "\C-a" message-beginning-of-line
5050 "\M-;" comment-region)
5052 (gnus-define-keys (gnus-article-edit-wash-map
5053 "\C-c\C-w" gnus-article-edit-mode-map)
5054 "f" gnus-article-edit-full-stops))
5057 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5059 ["Fetch To" message-insert-to t]
5060 ["Fetch Newsgroups" message-insert-newsgroups t]
5062 ["To" message-goto-to t]
5063 ["From" message-goto-from t]
5064 ["Subject" message-goto-subject t]
5065 ["Cc" message-goto-cc t]
5066 ["Reply-To" message-goto-reply-to t]
5067 ["Summary" message-goto-summary t]
5068 ["Keywords" message-goto-keywords t]
5069 ["Newsgroups" message-goto-newsgroups t]
5070 ["Followup-To" message-goto-followup-to t]
5071 ["Mail-Followup-To" message-goto-mail-followup-to t]
5072 ["Distribution" message-goto-distribution t]
5073 ["Body" message-goto-body t]
5074 ["Signature" message-goto-signature t]))
5076 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5077 "Major mode for editing articles.
5078 This is an extended text-mode.
5080 \\{gnus-article-edit-mode-map}"
5081 (make-local-variable 'gnus-article-edit-done-function)
5082 (make-local-variable 'gnus-prev-winconf)
5083 (set (make-local-variable 'font-lock-defaults)
5084 '(message-font-lock-keywords t))
5085 (set (make-local-variable 'mail-header-separator) "")
5086 (easy-menu-add message-mode-field-menu message-mode-map)
5088 (setq buffer-read-only nil)
5089 (buffer-enable-undo)
5092 (defun gnus-article-edit (&optional force)
5093 "Edit the current article.
5094 This will have permanent effect only in mail groups.
5095 If FORCE is non-nil, allow editing of articles even in read-only
5098 (when (and (not force)
5099 (gnus-group-read-only-p))
5100 (error "The current newsgroup does not support article editing"))
5101 (gnus-article-date-original)
5102 (gnus-article-edit-article
5104 `(lambda (no-highlight)
5106 (gnus-summary-edit-article-done
5107 ,(or (mail-header-references gnus-current-headers) "")
5108 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5110 (defun gnus-article-edit-article (start-func exit-func)
5111 "Start editing the contents of the current article buffer."
5112 (let ((winconf (current-window-configuration)))
5113 (set-buffer gnus-article-buffer)
5114 (gnus-article-edit-mode)
5115 (funcall start-func)
5116 (set-buffer-modified-p nil)
5117 (gnus-configure-windows 'edit-article)
5118 (setq gnus-article-edit-done-function exit-func)
5119 (setq gnus-prev-winconf winconf)
5120 (gnus-message 6 "C-c C-c to end edits")))
5122 (defun gnus-article-edit-done (&optional arg)
5123 "Update the article edits and exit."
5125 (let ((func gnus-article-edit-done-function)
5126 (buf (current-buffer))
5127 (start (window-start))
5129 (winconf gnus-prev-winconf))
5130 (widen) ;; Widen it in case that users narrowed the buffer.
5133 ;; The cache and backlog have to be flushed somewhat.
5134 (when gnus-keep-backlog
5135 (gnus-backlog-remove-article
5136 (car gnus-article-current) (cdr gnus-article-current)))
5137 ;; Flush original article as well.
5139 (when (get-buffer gnus-original-article-buffer)
5140 (set-buffer gnus-original-article-buffer)
5141 (setq gnus-original-article nil)))
5142 (when gnus-use-cache
5143 (gnus-cache-update-article
5144 (car gnus-article-current) (cdr gnus-article-current)))
5145 ;; We remove all text props from the article buffer.
5146 (kill-all-local-variables)
5147 (gnus-set-text-properties (point-min) (point-max) nil)
5149 (set-window-configuration winconf)
5151 (set-window-start (get-buffer-window buf) start)
5152 (set-window-point (get-buffer-window buf) (point))))
5154 (defun gnus-article-edit-exit ()
5155 "Exit the article editing without updating."
5157 (when (or (not (buffer-modified-p))
5158 (yes-or-no-p "Article modified; kill anyway? "))
5159 (let ((curbuf (current-buffer))
5161 (window-start (window-start)))
5163 (if (gnus-buffer-live-p gnus-original-article-buffer)
5164 (insert-buffer gnus-original-article-buffer))
5165 (let ((winconf gnus-prev-winconf))
5167 (set-window-configuration winconf)
5168 ;; Tippy-toe some to make sure that point remains where it was.
5169 (save-current-buffer
5171 (set-window-start (get-buffer-window (current-buffer)) window-start)
5174 (defun gnus-article-edit-full-stops ()
5175 "Interactively repair spacing at end of sentences."
5178 (goto-char (point-min))
5179 (search-forward-regexp "^$" nil t)
5180 (let ((case-fold-search nil))
5181 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5184 ;;; Article highlights
5187 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5189 ;;; Internal Variables:
5191 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
5192 "Regular expression that matches URLs."
5193 :group 'gnus-article-buttons
5196 (defcustom gnus-button-alist
5197 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5198 0 t gnus-button-handle-news 3)
5199 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5200 gnus-button-handle-news 2)
5201 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5203 gnus-button-fetch-group 4)
5204 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5205 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5206 t gnus-button-message-id 3)
5207 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5208 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5209 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5211 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5212 gnus-button-handle-info 2)
5213 ;; This is how URLs _should_ be embedded in text...
5214 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5216 (,gnus-button-url-regexp 0 t browse-url 0))
5217 "*Alist of regexps matching buttons in article bodies.
5219 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5220 REGEXP: is the string matching text around the button,
5221 BUTTON: is the number of the regexp grouping actually matching the button,
5222 FORM: is a lisp expression which must eval to true for the button to
5224 CALLBACK: is the function to call when the user push this button, and each
5225 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5227 CALLBACK can also be a variable, in that case the value of that
5228 variable it the real callback function."
5229 :group 'gnus-article-buttons
5230 :type '(repeat (list regexp
5231 (integer :tag "Button")
5233 (function :tag "Callback")
5236 (integer :tag "Regexp group")))))
5238 (defcustom gnus-header-button-alist
5239 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5240 0 t gnus-button-message-id 0)
5241 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5242 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5243 0 t gnus-button-mailto 0)
5244 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5245 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5246 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5247 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5248 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5249 gnus-button-message-id 3))
5250 "*Alist of headers and regexps to match buttons in article heads.
5252 This alist is very similar to `gnus-button-alist', except that each
5253 alist has an additional HEADER element first in each entry:
5255 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5257 HEADER is a regexp to match a header. For a fuller explanation, see
5258 `gnus-button-alist'."
5259 :group 'gnus-article-buttons
5260 :group 'gnus-article-headers
5261 :type '(repeat (list (regexp :tag "Header")
5263 (integer :tag "Button")
5265 (function :tag "Callback")
5268 (integer :tag "Regexp group")))))
5270 (defvar gnus-button-regexp nil)
5271 (defvar gnus-button-marker-list nil)
5272 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5274 (defvar gnus-button-last nil)
5275 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5279 (defun gnus-article-push-button (event)
5280 "Check text under the mouse pointer for a callback function.
5281 If the text under the mouse pointer has a `gnus-callback' property,
5282 call it with the value of the `gnus-data' text property."
5284 (set-buffer (window-buffer (posn-window (event-start event))))
5285 (let* ((pos (posn-point (event-start event)))
5286 (data (get-text-property pos 'gnus-data))
5287 (fun (get-text-property pos 'gnus-callback)))
5290 (funcall fun data))))
5292 (defun gnus-article-press-button ()
5293 "Check text at point for a callback function.
5294 If the text at point has a `gnus-callback' property,
5295 call it with the value of the `gnus-data' text property."
5297 (let* ((data (get-text-property (point) 'gnus-data))
5298 (fun (get-text-property (point) 'gnus-callback)))
5300 (funcall fun data))))
5302 (defun gnus-article-highlight (&optional force)
5303 "Highlight current article.
5304 This function calls `gnus-article-highlight-headers',
5305 `gnus-article-highlight-citation',
5306 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5307 do the highlighting. See the documentation for those functions."
5308 (interactive (list 'force))
5309 (gnus-article-highlight-headers)
5310 (gnus-article-highlight-citation force)
5311 (gnus-article-highlight-signature)
5312 (gnus-article-add-buttons force)
5313 (gnus-article-add-buttons-to-head))
5315 (defun gnus-article-highlight-some (&optional force)
5316 "Highlight current article.
5317 This function calls `gnus-article-highlight-headers',
5318 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5319 do the highlighting. See the documentation for those functions."
5320 (interactive (list 'force))
5321 (gnus-article-highlight-headers)
5322 (gnus-article-highlight-signature)
5323 (gnus-article-add-buttons))
5325 (defun gnus-article-highlight-headers ()
5326 "Highlight article headers as specified by `gnus-header-face-alist'."
5329 (set-buffer gnus-article-buffer)
5331 (let ((alist gnus-header-face-alist)
5332 (buffer-read-only nil)
5333 (case-fold-search t)
5334 (inhibit-point-motion-hooks t)
5335 entry regexp header-face field-face from hpoints fpoints)
5336 (article-narrow-to-head)
5337 (while (setq entry (pop alist))
5338 (goto-char (point-min))
5339 (setq regexp (concat "^\\("
5340 (if (string-equal "" (nth 0 entry))
5344 header-face (nth 1 entry)
5345 field-face (nth 2 entry))
5346 (while (and (re-search-forward regexp nil t)
5350 (unless (search-forward ":" nil t)
5352 (when (and header-face
5353 (not (memq (point) hpoints)))
5354 (push (point) hpoints)
5355 (gnus-put-text-property from (point) 'face header-face))
5356 (when (and field-face
5357 (not (memq (setq from (point)) fpoints)))
5359 (if (re-search-forward "^[^ \t]" nil t)
5361 (goto-char (point-max)))
5362 (gnus-put-text-property from (point) 'face field-face))))))))
5364 (defun gnus-article-highlight-signature ()
5365 "Highlight the signature in an article.
5366 It does this by highlighting everything after
5367 `gnus-signature-separator' using `gnus-signature-face'."
5370 (set-buffer gnus-article-buffer)
5371 (let ((buffer-read-only nil)
5372 (inhibit-point-motion-hooks t))
5374 (when (and gnus-signature-face
5375 (gnus-article-narrow-to-signature))
5376 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5377 'face gnus-signature-face)
5379 (gnus-article-search-signature)
5380 (let ((start (match-beginning 0))
5381 (end (set-marker (make-marker) (1+ (match-end 0)))))
5382 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5385 (defun gnus-button-in-region-p (b e prop)
5386 "Say whether PROP exists in the region."
5387 (text-property-not-all b e prop nil))
5389 (defun gnus-article-add-buttons (&optional force)
5390 "Find external references in the article and make buttons of them.
5391 \"External references\" are things like Message-IDs and URLs, as
5392 specified by `gnus-button-alist'."
5393 (interactive (list 'force))
5395 (set-buffer gnus-article-buffer)
5396 (let ((buffer-read-only nil)
5397 (inhibit-point-motion-hooks t)
5398 (case-fold-search t)
5399 (alist gnus-button-alist)
5401 ;; Remove all old markers.
5402 (let (marker entry new-list)
5403 (while (setq marker (pop gnus-button-marker-list))
5404 (if (or (< marker (point-min)) (>= marker (point-max)))
5405 (push marker new-list)
5407 (when (setq entry (gnus-button-entry))
5408 (put-text-property (match-beginning (nth 1 entry))
5409 (match-end (nth 1 entry))
5410 'gnus-callback nil))
5411 (set-marker marker nil)))
5412 (setq gnus-button-marker-list new-list))
5413 ;; We skip the headers.
5416 (while (setq entry (pop alist))
5417 (setq regexp (car entry))
5419 (while (re-search-forward regexp nil t)
5420 (let* ((start (and entry (match-beginning (nth 1 entry))))
5421 (end (and entry (match-end (nth 1 entry))))
5422 (from (match-beginning 0)))
5423 (when (and (or (eq t (nth 2 entry))
5424 (eval (nth 2 entry)))
5425 (not (gnus-button-in-region-p
5426 start end 'gnus-callback)))
5427 ;; That optional form returned non-nil, so we add the
5429 (gnus-article-add-button
5430 start end 'gnus-button-push
5431 (car (push (set-marker (make-marker) from)
5432 gnus-button-marker-list))))))))))
5434 ;; Add buttons to the head of an article.
5435 (defun gnus-article-add-buttons-to-head ()
5436 "Add buttons to the head of the article."
5439 (set-buffer gnus-article-buffer)
5441 (let ((buffer-read-only nil)
5442 (inhibit-point-motion-hooks t)
5443 (case-fold-search t)
5444 (alist gnus-header-button-alist)
5446 (article-narrow-to-head)
5448 ;; Each alist entry.
5449 (setq entry (car alist)
5451 (goto-char (point-min))
5452 (while (re-search-forward (car entry) nil t)
5453 ;; Each header matching the entry.
5454 (setq beg (match-beginning 0))
5455 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5456 (match-beginning 0))
5459 (while (re-search-forward (nth 1 entry) end t)
5460 ;; Each match within a header.
5461 (let* ((entry (cdr entry))
5462 (start (match-beginning (nth 1 entry)))
5463 (end (match-end (nth 1 entry)))
5464 (form (nth 2 entry)))
5465 (goto-char (match-end 0))
5467 (gnus-article-add-button
5468 start end (nth 3 entry)
5469 (buffer-substring (match-beginning (nth 4 entry))
5470 (match-end (nth 4 entry)))))))
5471 (goto-char end)))))))
5473 ;;; External functions:
5475 (defun gnus-article-add-button (from to fun &optional data)
5476 "Create a button between FROM and TO with callback FUN and data DATA."
5477 (when gnus-article-button-face
5478 (gnus-overlay-put (gnus-make-overlay from to)
5479 'face gnus-article-button-face))
5480 (gnus-add-text-properties
5482 (nconc (and gnus-article-mouse-face
5483 (list gnus-mouse-face-prop gnus-article-mouse-face))
5484 (list 'gnus-callback fun)
5485 (and data (list 'gnus-data data))))
5486 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5487 :button-keymap gnus-widget-button-keymap))
5489 ;;; Internal functions:
5491 (defun gnus-article-set-globals ()
5493 (set-buffer gnus-summary-buffer)
5494 (gnus-set-global-variables)))
5496 (defun gnus-signature-toggle (end)
5498 (set-buffer gnus-article-buffer)
5499 (let ((buffer-read-only nil)
5500 (inhibit-point-motion-hooks t))
5501 (if (text-property-any end (point-max) 'article-type 'signature)
5503 (gnus-delete-wash-type 'signature)
5504 (gnus-remove-text-properties-when
5505 'article-type 'signature end (point-max)
5506 (cons 'article-type (cons 'signature
5507 gnus-hidden-properties))))
5508 (gnus-add-wash-type 'signature)
5509 (gnus-add-text-properties-when
5510 'article-type nil end (point-max)
5511 (cons 'article-type (cons 'signature
5512 gnus-hidden-properties)))))
5513 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5514 (gnus-set-mode-line 'article))))
5516 (defun gnus-button-entry ()
5517 ;; Return the first entry in `gnus-button-alist' matching this place.
5518 (let ((alist gnus-button-alist)
5521 (setq entry (pop alist))
5522 (if (looking-at (car entry))
5527 (defun gnus-button-push (marker)
5528 ;; Push button starting at MARKER.
5531 (let* ((entry (gnus-button-entry))
5532 (inhibit-point-motion-hooks t)
5534 (args (mapcar (lambda (group)
5535 (let ((string (match-string group)))
5536 (gnus-set-text-properties
5537 0 (length string) nil string)
5544 (fboundp (symbol-value fun)))
5545 (apply (symbol-value fun) args))
5547 (gnus-message 1 "You must define `%S' to use this button"
5548 (cons fun args)))))))
5550 (defun gnus-parse-news-url (url)
5551 (let (scheme server group message-id articles)
5554 (goto-char (point-min))
5555 (when (looking-at "\\([A-Za-z]+\\):")
5556 (setq scheme (match-string 1))
5557 (goto-char (match-end 0)))
5558 (when (looking-at "//\\([^/]+\\)/")
5559 (setq server (match-string 1))
5560 (goto-char (match-end 0)))
5563 ((looking-at "\\(.*@.*\\)")
5564 (setq message-id (match-string 1)))
5565 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5566 (setq group (match-string 1)
5567 articles (split-string (match-string 2) "-")))
5568 ((looking-at "\\([^/]+\\)/?")
5569 (setq group (match-string 1)))
5571 (error "Unknown news URL syntax"))))
5572 (list scheme server group message-id articles)))
5574 (defun gnus-button-handle-news (url)
5576 (destructuring-bind (scheme server group message-id articles)
5577 (gnus-parse-news-url url)
5581 (set-buffer gnus-summary-buffer)
5583 (let ((gnus-refer-article-method (list (list 'nntp server))))
5584 (gnus-summary-refer-article message-id))
5585 (gnus-summary-refer-article message-id))))
5587 (gnus-button-fetch-group url)))))
5589 (defun gnus-button-handle-info (url)
5590 "Fetch an info URL."
5592 "^\\([^:/]+\\)?/\\(.*\\)"
5594 (gnus-info-find-node
5595 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5598 (gnus-url-unhex-string (match-string 2 url))))
5599 (error "Can't parse %s" url)))
5601 (defun gnus-button-message-id (message-id)
5604 (set-buffer gnus-summary-buffer)
5605 (gnus-summary-refer-article message-id)))
5607 (defun gnus-button-fetch-group (address)
5608 "Fetch GROUP specified by ADDRESS."
5609 (if (not (string-match "[:/]" address))
5610 ;; This is just a simple group url.
5611 (gnus-group-read-ephemeral-group address gnus-select-method)
5614 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5616 (error "Can't parse %s" address)
5617 (gnus-group-read-ephemeral-group
5618 (match-string 4 address)
5619 `(nntp ,(match-string 1 address)
5620 (nntp-address ,(match-string 1 address))
5621 (nntp-port-number ,(if (match-end 3)
5622 (match-string 3 address)
5625 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5627 (defun gnus-url-parse-query-string (query &optional downcase)
5628 (let (retval pairs cur key val)
5629 (setq pairs (split-string query "&"))
5631 (setq cur (car pairs)
5633 (if (not (string-match "=" cur))
5635 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5636 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5638 (setq key (downcase key)))
5639 (setq cur (assoc key retval))
5641 (setcdr cur (cons val (cdr cur)))
5642 (setq retval (cons (list key val) retval)))))
5645 (defun gnus-url-mailto (url)
5646 ;; Send mail to someone
5647 (when (string-match "mailto:/*\\(.*\\)" url)
5648 (setq url (substring url (match-beginning 1) nil)))
5649 (let (to args subject func)
5650 (if (string-match (regexp-quote "?") url)
5651 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5652 args (gnus-url-parse-query-string
5653 (substring url (match-end 0) nil) t))
5654 (setq to (gnus-url-unhex-string url)))
5655 (setq args (cons (list "to" to) args)
5656 subject (cdr-safe (assoc "subject" args)))
5659 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5662 (message-position-on-field (caar args)))
5663 (insert (mapconcat 'identity (cdar args) ", "))
5664 (setq args (cdr args)))
5667 (message-goto-subject))))
5669 (defun gnus-button-embedded-url (address)
5670 "Activate ADDRESS with `browse-url'."
5671 (browse-url (gnus-strip-whitespace address)))
5673 ;;; Next/prev buttons in the article buffer.
5675 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5676 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5678 (defvar gnus-prev-page-map
5679 (let ((map (make-sparse-keymap)))
5680 (unless (>= emacs-major-version 21)
5681 ;; XEmacs doesn't care.
5682 (set-keymap-parent map gnus-article-mode-map))
5683 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5684 (define-key map "\r" 'gnus-button-prev-page)
5687 (defun gnus-insert-prev-page-button ()
5689 (buffer-read-only nil))
5691 gnus-prev-page-line-format nil
5692 `(,@(gnus-local-map-property gnus-prev-page-map)
5694 gnus-callback gnus-article-button-prev-page
5695 article-type annotation))
5696 (widget-convert-button
5698 :action 'gnus-button-prev-page
5699 :button-keymap gnus-prev-page-map)))
5701 (defvar gnus-prev-page-map
5702 (let ((map (make-sparse-keymap)))
5703 (unless (>= emacs-major-version 21)
5704 ;; XEmacs doesn't care.
5705 (set-keymap-parent map gnus-article-mode-map))
5706 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5707 (define-key map "\r" 'gnus-button-prev-page)
5710 (defvar gnus-next-page-map
5711 (let ((map (make-sparse-keymap)))
5712 (unless (>= emacs-major-version 21)
5713 ;; XEmacs doesn't care.
5714 (set-keymap-parent map gnus-article-mode-map))
5715 (define-key map gnus-mouse-2 'gnus-button-next-page)
5716 (define-key map "\r" 'gnus-button-next-page)
5719 (defun gnus-button-next-page (&optional args more-args)
5720 "Go to the next page."
5722 (let ((win (selected-window)))
5723 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5724 (gnus-article-next-page)
5725 (select-window win)))
5727 (defun gnus-button-prev-page (&optional args more-args)
5728 "Go to the prev page."
5730 (let ((win (selected-window)))
5731 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5732 (gnus-article-prev-page)
5733 (select-window win)))
5735 (defun gnus-insert-next-page-button ()
5737 (buffer-read-only nil))
5738 (gnus-eval-format gnus-next-page-line-format nil
5739 `(,@(gnus-local-map-property gnus-next-page-map)
5741 gnus-callback gnus-article-button-next-page
5742 article-type annotation))
5743 (widget-convert-button
5745 :action 'gnus-button-next-page
5746 :button-keymap gnus-next-page-map)))
5748 (defun gnus-article-button-next-page (arg)
5749 "Go to the next page."
5751 (let ((win (selected-window)))
5752 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5753 (gnus-article-next-page)
5754 (select-window win)))
5756 (defun gnus-article-button-prev-page (arg)
5757 "Go to the prev page."
5759 (let ((win (selected-window)))
5760 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5761 (gnus-article-prev-page)
5762 (select-window win)))
5764 (defvar gnus-decode-header-methods
5765 '(mail-decode-encoded-word-region)
5766 "List of methods used to decode headers.
5768 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5769 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5770 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5771 whose names match REGEXP.
5774 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5775 mail-decode-encoded-word-region
5776 (\"chinese\" . rfc1843-decode-region))
5779 (defvar gnus-decode-header-methods-cache nil)
5781 (defun gnus-multi-decode-header (start end)
5782 "Apply the functions from `gnus-encoded-word-methods' that match."
5783 (unless (and gnus-decode-header-methods-cache
5784 (eq gnus-newsgroup-name
5785 (car gnus-decode-header-methods-cache)))
5786 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5789 (nconc gnus-decode-header-methods-cache (list x))
5790 (if (and gnus-newsgroup-name
5791 (string-match (car x) gnus-newsgroup-name))
5792 (nconc gnus-decode-header-methods-cache
5794 gnus-decode-header-methods))
5795 (let ((xlist gnus-decode-header-methods-cache))
5798 (narrow-to-region start end)
5800 (funcall (pop xlist) (point-min) (point-max))))))
5803 ;;; Treatment top-level handling.
5806 (defun gnus-treat-article (condition &optional part-number total-parts type)
5807 (let ((length (- (point-max) (point-min)))
5808 (alist gnus-treatment-function-alist)
5809 (article-goto-body-goes-to-point-min-p t)
5813 (let ((list gnus-article-treat-types))
5815 (when (string-match (pop list) type)
5816 (throw 'found t)))))))
5817 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5819 (gnus-run-hooks 'gnus-part-display-hook)
5820 (while (setq elem (pop alist))
5823 (if (gnus-buffer-live-p gnus-summary-buffer)
5824 (set-buffer gnus-summary-buffer))
5825 (symbol-value (car elem))))
5826 (when (and (or (consp val)
5828 (gnus-treat-predicate val)
5829 (or (not (get (car elem) 'highlight))
5832 (funcall (cadr elem)))))))
5834 ;; Dynamic variables.
5836 (defvar part-number)
5837 (defvar total-parts)
5842 (defun gnus-treat-predicate (val)
5847 (stringp (car val)))
5848 (apply 'gnus-or (mapcar `(lambda (s)
5849 (string-match s ,(or gnus-newsgroup-name "")))
5852 (let ((pred (pop val)))
5855 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5857 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5859 (not (gnus-treat-predicate (car val))))
5861 (equal (car val) type))
5863 (error "%S is not a valid predicate" pred)))))
5871 (eq part-number total-parts))
5875 (error "%S is not a valid value" val))))
5877 (defun gnus-article-encrypt-body (protocol &optional n)
5878 "Encrypt the article body."
5881 (or gnus-article-encrypt-protocol
5882 (completing-read "Encrypt protocol: "
5883 gnus-article-encrypt-protocol-alist
5885 current-prefix-arg))
5886 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5888 (error (format "Can't find the encrypt protocol %s" protocol)))
5889 (if (equal gnus-newsgroup-name "nndraft:drafts")
5890 (error "Can't encrypt the article in group nndraft:drafts"))
5891 (if (equal gnus-newsgroup-name "nndraft:queue")
5892 (error "Don't encrypt the article in group nndraft:queue"))
5893 (gnus-summary-iterate n
5895 (set-buffer gnus-summary-buffer)
5896 (let ((mail-parse-charset gnus-newsgroup-charset)
5897 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5898 (summary-buffer gnus-summary-buffer)
5900 (gnus-set-global-variables)
5901 (when (gnus-group-read-only-p)
5902 (error "The current newsgroup does not support article encrypt"))
5903 (gnus-summary-show-article t)
5905 (or (mail-header-references gnus-current-headers) ""))
5906 (set-buffer gnus-article-buffer)
5907 (let* ((buffer-read-only nil)
5909 (mapcar (lambda (field)
5910 (and (save-restriction
5911 (message-narrow-to-head)
5912 (goto-char (point-min))
5913 (search-forward field nil t))
5915 (message-narrow-to-field)
5916 (buffer-substring (point-min) (point-max))
5917 (delete-region (point-min) (point-max))
5919 '("Content-Type:" "Content-Transfer-Encoding:"
5920 "Content-Disposition:"))))
5921 (message-narrow-to-head)
5922 (message-remove-header "MIME-Version")
5923 (goto-char (point-max))
5924 (setq point (point))
5925 (insert (apply 'concat headers))
5927 (narrow-to-region point (point-max))
5928 (let ((message-options message-options))
5929 (message-options-set 'message-sender user-mail-address)
5930 (message-options-set 'message-recipients user-mail-address)
5931 (message-options-set 'message-sign-encrypt 'not)
5933 (goto-char (point-min))
5934 (insert "MIME-Version: 1.0\n")
5936 (gnus-summary-edit-article-done
5937 references nil summary-buffer t))
5938 (when gnus-keep-backlog
5939 (gnus-backlog-remove-article
5940 (car gnus-article-current) (cdr gnus-article-current)))
5942 (when (get-buffer gnus-original-article-buffer)
5943 (set-buffer gnus-original-article-buffer)
5944 (setq gnus-original-article nil)))
5945 (when gnus-use-cache
5946 (gnus-cache-update-article
5947 (car gnus-article-current) (cdr gnus-article-current))))))))
5949 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5950 "The following specs can be used:
5951 %t The security MIME type
5954 %D Details if button is pressed")
5956 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5957 "The following specs can be used:
5958 %t The security MIME type
5961 %D Details if button is pressed")
5963 (defvar gnus-mime-security-button-line-format-alist
5964 '((?t gnus-tmp-type ?s)
5965 (?i gnus-tmp-info ?s)
5966 (?d gnus-tmp-details ?s)
5967 (?D gnus-tmp-pressed-details ?s)))
5969 (defvar gnus-mime-security-button-map
5970 (let ((map (make-sparse-keymap)))
5971 (unless (>= (string-to-number emacs-version) 21)
5972 (set-keymap-parent map gnus-article-mode-map))
5973 (define-key map gnus-mouse-2 'gnus-article-push-button)
5974 (define-key map "\r" 'gnus-article-press-button)
5977 (defvar gnus-mime-security-details-buffer nil)
5979 (defvar gnus-mime-security-button-pressed nil)
5981 (defvar gnus-mime-security-show-details-inline t
5982 "If non-nil, show details in the article buffer.")
5984 (defun gnus-mime-security-verify-or-decrypt (handle)
5985 (mm-remove-parts (cdr handle))
5986 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5987 point buffer-read-only)
5989 (goto-char (car region)))
5991 (narrow-to-region (point) (point))
5992 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5993 (let* ((mm-verify-option 'known)
5994 (mm-decrypt-option 'known)
5995 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5996 (unless (eq nparts (cdr handle))
5997 (mm-destroy-parts (cdr handle))
5998 (setcdr handle nparts))))
5999 (setq point (point))
6000 (gnus-mime-display-security handle)
6001 (goto-char (point-max)))
6003 (delete-region (point) (cdr region))
6004 (set-marker (car region) nil)
6005 (set-marker (cdr region) nil))
6008 (defun gnus-mime-security-show-details (handle)
6009 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6011 (if gnus-mime-security-show-details-inline
6012 (let ((gnus-mime-security-button-pressed t)
6013 (gnus-mime-security-button-line-format
6014 (get-text-property (point) 'gnus-line-format))
6017 (while (eq (get-text-property (point) 'gnus-line-format)
6018 gnus-mime-security-button-line-format)
6022 (narrow-to-region (point) (point))
6023 (gnus-insert-mime-security-button handle))
6024 (delete-region (point)
6025 (or (text-property-not-all
6028 gnus-mime-security-button-line-format)
6030 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6031 (with-current-buffer gnus-mime-security-details-buffer
6034 (setq gnus-mime-security-details-buffer
6035 (gnus-get-buffer-create "*MIME Security Details*")))
6036 (with-current-buffer gnus-mime-security-details-buffer
6038 (goto-char (point-min)))
6039 (pop-to-buffer gnus-mime-security-details-buffer))
6040 (gnus-message 5 "No details."))))
6042 (defun gnus-mime-security-press-button (handle)
6043 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6044 (gnus-mime-security-show-details handle)
6045 (gnus-mime-security-verify-or-decrypt handle)))
6047 (defun gnus-insert-mime-security-button (handle &optional displayed)
6048 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6051 (or (nth 2 (assoc protocol mm-verify-function-alist))
6052 (nth 2 (assoc protocol mm-decrypt-function-alist))
6054 (if (equal (car handle) "multipart/signed")
6055 " Signed" " Encrypted")
6058 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6061 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6062 gnus-tmp-pressed-details
6064 (setq gnus-tmp-details
6065 (if gnus-tmp-details
6066 (concat "\n" gnus-tmp-details) ""))
6067 (setq gnus-tmp-pressed-details
6068 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6073 gnus-mime-security-button-line-format
6074 gnus-mime-security-button-line-format-alist
6075 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6076 gnus-callback gnus-mime-security-press-button
6077 gnus-line-format ,gnus-mime-security-button-line-format
6078 article-type annotation
6081 (widget-convert-button
6084 :action 'gnus-widget-press-button
6085 :button-keymap gnus-mime-security-button-map
6087 (lambda (widget/window &optional overlay pos)
6088 ;; Needed to properly clear the message due to a bug in
6089 ;; wid-edit (XEmacs only).
6090 (if (boundp 'help-echo-owns-message)
6091 (setq help-echo-owns-message t))
6094 (aref gnus-mouse-2 0))))))
6096 (defun gnus-mime-display-security (handle)
6098 (narrow-to-region (point) (point))
6099 (unless (gnus-unbuttonized-mime-type-p (car handle))
6100 (gnus-insert-mime-security-button handle))
6101 (gnus-mime-display-mixed (cdr handle))
6104 (unless (gnus-unbuttonized-mime-type-p (car handle))
6105 (let ((gnus-mime-security-button-line-format
6106 gnus-mime-security-button-end-line-format))
6107 (gnus-insert-mime-security-button handle)))
6108 (mm-set-handle-multipart-parameter
6110 (cons (set-marker (make-marker) (point-min))
6111 (set-marker (make-marker) (point-max))))))
6117 (run-hooks 'gnus-art-load-hook)
6119 ;;; gnus-art.el ends here