1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-emphasis-alist
284 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
289 ("_/" "/_" underline-italic)
290 ("_\\*" "\\*_" underline-bold)
291 ("\\*/" "/\\*" bold-italic)
292 ("_\\*/" "/\\*_" underline-bold-italic))))
296 (format format (car spec) (cadr spec))
297 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
299 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
300 2 3 gnus-emphasis-underline)))
301 "*Alist that says how to fontify certain phrases.
302 Each item looks like this:
304 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
306 The first element is a regular expression to be matched. The second
307 is a number that says what regular expression grouping used to find
308 the entire emphasized word. The third is a number that says what
309 regexp grouping should be displayed and highlighted. The fourth
310 is the face used for highlighting."
311 :type '(repeat (list :value ("" 0 0 default)
313 (integer :tag "Match group")
314 (integer :tag "Emphasize group")
316 :group 'gnus-article-emphasis)
318 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
319 "A regexp to describe whitespace which should not be emphasized.
320 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
321 The former avoids underlining of leading and trailing whitespace,
322 and the latter avoids underlining any whitespace at all."
324 :group 'gnus-article-emphasis
327 (defface gnus-emphasis-bold '((t (:bold t)))
328 "Face used for displaying strong emphasized text (*word*)."
329 :group 'gnus-article-emphasis)
331 (defface gnus-emphasis-italic '((t (:italic t)))
332 "Face used for displaying italic emphasized text (/word/)."
333 :group 'gnus-article-emphasis)
335 (defface gnus-emphasis-underline '((t (:underline t)))
336 "Face used for displaying underlined emphasized text (_word_)."
337 :group 'gnus-article-emphasis)
339 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
340 "Face used for displaying underlined bold emphasized text (_*word*_)."
341 :group 'gnus-article-emphasis)
343 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
344 "Face used for displaying underlined italic emphasized text (_/word/_)."
345 :group 'gnus-article-emphasis)
347 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
348 "Face used for displaying bold italic emphasized text (/*word*/)."
349 :group 'gnus-article-emphasis)
351 (defface gnus-emphasis-underline-bold-italic
352 '((t (:bold t :italic t :underline t)))
353 "Face used for displaying underlined bold italic emphasized text.
354 Esample: (_/*word*/_)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-highlight-words
358 '((t (:background "black" :foreground "yellow")))
359 "Face used for displaying highlighted words."
360 :group 'gnus-article-emphasis)
362 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
363 "Format for display of Date headers in article bodies.
364 See `format-time-string' for the possible values.
366 The variable can also be function, which should return a complete Date
367 header. The function is called with one argument, the time, which can
368 be fed to `format-time-string'."
369 :type '(choice string symbol)
370 :link '(custom-manual "(gnus)Article Date")
371 :group 'gnus-article-washing)
374 (autoload 'mail-extract-address-components "mail-extr"))
376 (defcustom gnus-save-all-headers t
377 "*If non-nil, don't remove any headers before saving."
378 :group 'gnus-article-saving
381 (defcustom gnus-prompt-before-saving 'always
382 "*This variable says how much prompting is to be done when saving articles.
383 If it is nil, no prompting will be done, and the articles will be
384 saved to the default files. If this variable is `always', each and
385 every article that is saved will be preceded by a prompt, even when
386 saving large batches of articles. If this variable is neither nil not
387 `always', there the user will be prompted once for a file name for
388 each invocation of the saving commands."
389 :group 'gnus-article-saving
390 :type '(choice (item always)
391 (item :tag "never" nil)
392 (sexp :tag "once" :format "%t\n" :value t)))
394 (defcustom gnus-saved-headers gnus-visible-headers
395 "Headers to keep if `gnus-save-all-headers' is nil.
396 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
397 If that variable is nil, however, all headers that match this regexp
398 will be kept while the rest will be deleted before saving."
399 :group 'gnus-article-saving
402 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
403 "A function to save articles in your favourite format.
404 The function must be interactively callable (in other words, it must
405 be an Emacs command).
407 Gnus provides the following functions:
409 * gnus-summary-save-in-rmail (Rmail format)
410 * gnus-summary-save-in-mail (Unix mail format)
411 * gnus-summary-save-in-folder (MH folder)
412 * gnus-summary-save-in-file (article format)
413 * gnus-summary-save-body-in-file (article body)
414 * gnus-summary-save-in-vm (use VM's folder format)
415 * gnus-summary-write-to-file (article format -- overwrite)."
416 :group 'gnus-article-saving
417 :type '(radio (function-item gnus-summary-save-in-rmail)
418 (function-item gnus-summary-save-in-mail)
419 (function-item gnus-summary-save-in-folder)
420 (function-item gnus-summary-save-in-file)
421 (function-item gnus-summary-save-body-in-file)
422 (function-item gnus-summary-save-in-vm)
423 (function-item gnus-summary-write-to-file)))
425 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
426 "A function generating a file name to save articles in Rmail format.
427 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
428 :group 'gnus-article-saving
431 (defcustom gnus-mail-save-name 'gnus-plain-save-name
432 "A function generating a file name to save articles in Unix mail format.
433 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
434 :group 'gnus-article-saving
437 (defcustom gnus-folder-save-name 'gnus-folder-save-name
438 "A function generating a file name to save articles in MH folder.
439 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
440 :group 'gnus-article-saving
443 (defcustom gnus-file-save-name 'gnus-numeric-save-name
444 "A function generating a file name to save articles in article format.
445 The function is called with NEWSGROUP, HEADERS, and optional
447 :group 'gnus-article-saving
450 (defcustom gnus-split-methods
451 '((gnus-article-archive-name)
452 (gnus-article-nndoc-name))
453 "*Variable used to suggest where articles are to be saved.
454 For instance, if you would like to save articles related to Gnus in
455 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
456 you could set this variable to something like:
458 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
459 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
461 This variable is an alist where the where the key is the match and the
462 value is a list of possible files to save in if the match is non-nil.
464 If the match is a string, it is used as a regexp match on the
465 article. If the match is a symbol, that symbol will be funcalled
466 from the buffer of the article to be saved with the newsgroup as the
467 parameter. If it is a list, it will be evaled in the same buffer.
469 If this form or function returns a string, this string will be used as
470 a possible file name; and if it returns a non-nil list, that list will
471 be used as possible file names."
472 :group 'gnus-article-saving
473 :type '(repeat (choice (list :value (fun) function)
474 (cons :value ("" "") regexp (repeat string))
477 (defcustom gnus-page-delimiter "^\^L"
478 "*Regexp describing what to use as article page delimiters.
479 The default value is \"^\^L\", which is a form linefeed at the
480 beginning of a line."
482 :group 'gnus-article-various)
484 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
485 "*The format specification for the article mode line.
486 See `gnus-summary-mode-line-format' for a closer description.
488 The following additional specs are available:
490 %w The article washing status.
491 %m The number of MIME parts in the article."
493 :group 'gnus-article-various)
495 (defcustom gnus-article-mode-hook nil
496 "*A hook for Gnus article mode."
498 :group 'gnus-article-various)
500 (when (featurep 'xemacs)
501 ;; Extracted from gnus-xmas-define in order to preserve user settings
502 (when (fboundp 'turn-off-scroll-in-place)
503 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
504 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
505 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
507 (defcustom gnus-article-menu-hook nil
508 "*Hook run after the creation of the article mode menu."
510 :group 'gnus-article-various)
512 (defcustom gnus-article-prepare-hook nil
513 "*A hook called after an article has been prepared in the article buffer."
515 :group 'gnus-article-various)
517 (defcustom gnus-article-hide-pgp-hook nil
518 "*A hook called after successfully hiding a PGP signature."
520 :group 'gnus-article-various)
522 (defcustom gnus-article-button-face 'bold
523 "Face used for highlighting buttons in the article buffer.
525 An article button is a piece of text that you can activate by pressing
526 `RET' or `mouse-2' above it."
528 :group 'gnus-article-buttons)
530 (defcustom gnus-article-mouse-face 'highlight
531 "Face used for mouse highlighting in the article buffer.
533 Article buttons will be displayed in this face when the cursor is
536 :group 'gnus-article-buttons)
538 (defcustom gnus-signature-face 'gnus-signature-face
539 "Face used for highlighting a signature in the article buffer.
540 Obsolete; use the face `gnus-signature-face' for customizations instead."
542 :group 'gnus-article-highlight
543 :group 'gnus-article-signature)
545 (defface gnus-signature-face
548 "Face used for highlighting a signature in the article buffer."
549 :group 'gnus-article-highlight
550 :group 'gnus-article-signature)
552 (defface gnus-header-from-face
555 (:foreground "spring green"))
558 (:foreground "red3"))
561 "Face used for displaying from headers."
562 :group 'gnus-article-headers
563 :group 'gnus-article-highlight)
565 (defface gnus-header-subject-face
568 (:foreground "SeaGreen3"))
571 (:foreground "red4"))
573 (:bold t :italic t)))
574 "Face used for displaying subject headers."
575 :group 'gnus-article-headers
576 :group 'gnus-article-highlight)
578 (defface gnus-header-newsgroups-face
581 (:foreground "yellow" :italic t))
584 (:foreground "MidnightBlue" :italic t))
587 "Face used for displaying newsgroups headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-name-face
594 (:foreground "SeaGreen"))
597 (:foreground "maroon"))
600 "Face used for displaying header names."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-content-face
607 (:foreground "forest green" :italic t))
610 (:foreground "indianred4" :italic t))
612 (:italic t))) "Face used for displaying header content."
613 :group 'gnus-article-headers
614 :group 'gnus-article-highlight)
616 (defcustom gnus-header-face-alist
617 '(("From" nil gnus-header-from-face)
618 ("Subject" nil gnus-header-subject-face)
619 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
620 ("" gnus-header-name-face gnus-header-content-face))
621 "*Controls highlighting of article header.
623 An alist of the form (HEADER NAME CONTENT).
625 HEADER is a regular expression which should match the name of an
626 header header and NAME and CONTENT are either face names or nil.
628 The name of each header field will be displayed using the face
629 specified by the first element in the list where HEADER match the
630 header name and NAME is non-nil. Similarly, the content will be
631 displayed by the first non-nil matching CONTENT face."
632 :group 'gnus-article-headers
633 :group 'gnus-article-highlight
634 :type '(repeat (list (regexp :tag "Header")
636 (item :tag "skip" nil)
637 (face :value default))
638 (choice :tag "Content"
639 (item :tag "skip" nil)
640 (face :value default)))))
642 (defcustom gnus-article-decode-hook
643 '(article-decode-charset article-decode-encoded-words
644 article-decode-group-name)
645 "*Hook run to decode charsets in articles."
646 :group 'gnus-article-headers
649 (defcustom gnus-display-mime-function 'gnus-display-mime
650 "Function to display MIME articles."
651 :group 'gnus-article-mime
654 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
655 "Function used to decode headers.")
657 (defvar gnus-article-dumbquotes-map
676 "Table for MS-to-Latin1 translation.")
678 (defcustom gnus-ignored-mime-types nil
679 "List of MIME types that should be ignored by Gnus."
681 :group 'gnus-article-mime
682 :type '(repeat regexp))
684 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
685 "List of MIME types that should not be given buttons when rendered inline.
686 See also `gnus-buttonized-mime-types' which may override this variable."
688 :group 'gnus-article-mime
689 :type '(repeat regexp))
691 (defcustom gnus-buttonized-mime-types nil
692 "List of MIME types that should be given buttons when rendered inline.
693 If set, this variable overrides `gnus-unbuttonized-mime-types'.
694 To see e.g. security buttons you could set this to
695 `(\"multipart/signed\")'."
697 :group 'gnus-article-mime
698 :type '(repeat regexp))
700 (defcustom gnus-body-boundary-delimiter "_"
701 "String used to delimit header and body.
702 This variable is used by `gnus-article-treat-body-boundary' which can
703 be controlled by `gnus-treat-body-boundary'."
704 :group 'gnus-article-various
705 :type '(choice (item :tag "None" :value nil)
708 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
709 "Defines the location of the faces database.
710 For information on obtaining this database of pretty pictures, please
711 see http://www.cs.indiana.edu/picons/ftp/index.html"
712 :type '(repeat directory)
713 :link '(url-link :tag "download"
714 "http://www.cs.indiana.edu/picons/ftp/index.html")
715 :link '(custom-manual "(gnus)Picons")
718 (defun gnus-picons-installed-p ()
719 "Say whether picons are installed on your machine."
720 (let ((installed nil))
721 (dolist (database gnus-picon-databases)
722 (when (file-exists-p database)
726 (defcustom gnus-article-mime-part-function nil
727 "Function called with a MIME handle as the argument.
728 This is meant for people who want to do something automatic based
729 on parts -- for instance, adding Vcard info to a database."
730 :group 'gnus-article-mime
733 (defcustom gnus-mime-multipart-functions nil
734 "An alist of MIME types to functions to display them."
736 :group 'gnus-article-mime
739 (defcustom gnus-article-date-lapsed-new-header nil
740 "Whether the X-Sent and Date headers can coexist.
741 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
742 either replace the old \"Date:\" header (if this variable is nil), or
743 be added below it (otherwise)."
745 :group 'gnus-article-headers
748 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
749 "Function called with a MIME handle as the argument.
750 This is meant for people who want to view first matched part.
751 For `undisplayed-alternative' (default), the first undisplayed
752 part or alternative part is used. For `undisplayed', the first
753 undisplayed part is used. For a function, the first part which
754 the function return `t' is used. For `nil', the first part is
757 :group 'gnus-article-mime
759 (item :tag "first" :value nil)
760 (item :tag "undisplayed" :value undisplayed)
761 (item :tag "undisplayed or alternative"
762 :value undisplayed-alternative)
765 (defcustom gnus-mime-action-alist
766 '(("save to file" . gnus-mime-save-part)
767 ("save and strip" . gnus-mime-save-part-and-strip)
768 ("display as text" . gnus-mime-inline-part)
769 ("view the part" . gnus-mime-view-part)
770 ("pipe to command" . gnus-mime-pipe-part)
771 ("toggle display" . gnus-article-press-button)
772 ("toggle display" . gnus-article-view-part-as-charset)
773 ("view as type" . gnus-mime-view-part-as-type)
774 ("view internally" . gnus-mime-view-part-internally)
775 ("view externally" . gnus-mime-view-part-externally))
776 "An alist of actions that run on the MIME attachment."
777 :group 'gnus-article-mime
778 :type '(repeat (cons (string :tag "name")
782 ;;; The treatment variables
785 (defvar gnus-part-display-hook nil
786 "Hook called on parts that are to receive treatment.")
788 (defvar gnus-article-treat-custom
789 '(choice (const :tag "Off" nil)
791 (const :tag "Header" head)
792 (const :tag "Last" last)
793 (integer :tag "Less")
794 (repeat :tag "Groups" regexp)
795 (sexp :tag "Predicate")))
797 (defvar gnus-article-treat-head-custom
798 '(choice (const :tag "Off" nil)
799 (const :tag "Header" head)))
801 (defvar gnus-article-treat-types '("text/plain")
804 (defvar gnus-inhibit-treatment nil
805 "Whether to inhibit treatment.")
807 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
808 "Highlight the signature.
809 Valid values are nil, t, `head', `last', an integer or a predicate.
810 See Info node `(gnus)Customizing Articles'."
811 :group 'gnus-article-treat
812 :type gnus-article-treat-custom)
813 (put 'gnus-treat-highlight-signature 'highlight t)
815 (defcustom gnus-treat-buttonize 100000
817 Valid values are nil, t, `head', `last', an integer or a predicate.
818 See Info node `(gnus)Customizing Articles'."
819 :group 'gnus-article-treat
820 :type gnus-article-treat-custom)
821 (put 'gnus-treat-buttonize 'highlight t)
823 (defcustom gnus-treat-buttonize-head 'head
824 "Add buttons to the head.
825 Valid values are nil, t, `head', `last', an integer or a predicate.
826 See Info node `(gnus)Customizing Articles' for details."
827 :group 'gnus-article-treat
828 :type gnus-article-treat-head-custom)
829 (put 'gnus-treat-buttonize-head 'highlight t)
831 (defcustom gnus-treat-emphasize
832 (and (or window-system
834 (>= (string-to-number emacs-version) 21))
837 Valid values are nil, t, `head', `last', an integer or a predicate.
838 See Info node `(gnus)Customizing Articles' for details."
839 :group 'gnus-article-treat
840 :type gnus-article-treat-custom)
841 (put 'gnus-treat-emphasize 'highlight t)
843 (defcustom gnus-treat-strip-cr nil
844 "Remove carriage returns.
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See Info node `(gnus)Customizing Articles' for details."
847 :group 'gnus-article-treat
848 :type gnus-article-treat-custom)
850 (defcustom gnus-treat-unsplit-urls nil
851 "Remove newlines from within URLs.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See Info node `(gnus)Customizing Articles' for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-custom)
857 (defcustom gnus-treat-leading-whitespace nil
858 "Remove leading whitespace in headers.
859 Valid values are nil, t, `head', `last', an integer or a predicate.
860 See Info node `(gnus)Customizing Articles' for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-custom)
864 (defcustom gnus-treat-hide-headers 'head
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See Info node `(gnus)Customizing Articles' for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-head-custom)
871 (defcustom gnus-treat-hide-boring-headers nil
872 "Hide boring headers.
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See Info node `(gnus)Customizing Articles' for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-head-custom)
878 (defcustom gnus-treat-hide-signature nil
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See Info node `(gnus)Customizing Articles' for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-custom)
885 (defcustom gnus-treat-fill-article nil
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See Info node `(gnus)Customizing Articles' for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-hide-citation nil
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See Info node `(gnus)Customizing Articles' for details."
896 :group 'gnus-article-treat
897 :type gnus-article-treat-custom)
899 (defcustom gnus-treat-hide-citation-maybe nil
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See Info node `(gnus)Customizing Articles' for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-strip-list-identifiers 'head
907 "Strip list identifiers from `gnus-list-identifiers`.
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :type gnus-article-treat-custom)
914 (defcustom gnus-treat-strip-pgp t
915 "Strip PGP signatures.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles' for details."
918 :group 'gnus-article-treat
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-strip-pem nil
922 "Strip PEM signatures.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :type gnus-article-treat-custom)
928 (defcustom gnus-treat-strip-banner t
929 "Strip banners from articles.
930 The banner to be stripped is specified in the `banner' group parameter.
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles' for details."
933 :group 'gnus-article-treat
934 :type gnus-article-treat-custom)
936 (defcustom gnus-treat-highlight-headers 'head
937 "Highlight the headers.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :type gnus-article-treat-head-custom)
942 (put 'gnus-treat-highlight-headers 'highlight t)
944 (defcustom gnus-treat-highlight-citation t
945 "Highlight cited text.
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles' for details."
948 :group 'gnus-article-treat
949 :type gnus-article-treat-custom)
950 (put 'gnus-treat-highlight-citation 'highlight t)
952 (defcustom gnus-treat-date-ut nil
953 "Display the Date in UT (GMT).
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles' for details."
956 :group 'gnus-article-treat
957 :type gnus-article-treat-head-custom)
959 (defcustom gnus-treat-date-local nil
960 "Display the Date in the local timezone.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See Info node `(gnus)Customizing Articles' for details."
963 :group 'gnus-article-treat
964 :type gnus-article-treat-head-custom)
966 (defcustom gnus-treat-date-english nil
967 "Display the Date in a format that can be read aloud in English.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See Info node `(gnus)Customizing Articles' for details."
970 :group 'gnus-article-treat
971 :type gnus-article-treat-head-custom)
973 (defcustom gnus-treat-date-lapsed nil
974 "Display the Date header in a way that says how much time has elapsed.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :type gnus-article-treat-head-custom)
980 (defcustom gnus-treat-date-original nil
981 "Display the date in the original timezone.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :type gnus-article-treat-head-custom)
987 (defcustom gnus-treat-date-iso8601 nil
988 "Display the date in the ISO8601 format.
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :type gnus-article-treat-head-custom)
995 (defcustom gnus-treat-date-user-defined nil
996 "Display the date in a user-defined format.
997 The format is defined by the `gnus-article-time-format' variable.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :type gnus-article-treat-head-custom)
1003 (defcustom gnus-treat-strip-headers-in-body t
1004 "Strip the X-No-Archive header line from the beginning of the body.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :type gnus-article-treat-custom)
1011 (defcustom gnus-treat-strip-trailing-blank-lines nil
1012 "Strip trailing blank lines.
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See Info node `(gnus)Customizing Articles' for details."
1015 :group 'gnus-article-treat
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-strip-leading-blank-lines nil
1019 "Strip leading blank lines.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :type gnus-article-treat-custom)
1025 (defcustom gnus-treat-strip-multiple-blank-lines nil
1026 "Strip multiple blank lines.
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See Info node `(gnus)Customizing Articles' for details."
1029 :group 'gnus-article-treat
1030 :type gnus-article-treat-custom)
1032 (defcustom gnus-treat-unfold-headers 'head
1033 "Unfold folded header lines.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :type gnus-article-treat-custom)
1039 (defcustom gnus-treat-fold-headers nil
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :type gnus-article-treat-custom)
1046 (defcustom gnus-treat-fold-newsgroups 'head
1047 "Fold the Newsgroups and Followup-To headers.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-overstrike t
1054 "Treat overstrike highlighting.
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See Info node `(gnus)Customizing Articles' for details."
1057 :group 'gnus-article-treat
1058 :type gnus-article-treat-custom)
1059 (put 'gnus-treat-overstrike 'highlight t)
1061 (defcustom gnus-treat-display-xface
1062 (and (not noninteractive)
1063 (or (and (fboundp 'image-type-available-p)
1064 (image-type-available-p 'xbm)
1065 (string-match "^0x" (shell-command-to-string "uncompface")))
1066 (and (featurep 'xemacs)
1069 "Display X-Face headers.
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' and Info node
1072 `(gnus)X-Face' for details."
1073 :group 'gnus-article-treat
1075 :type gnus-article-treat-head-custom)
1076 (put 'gnus-treat-display-xface 'highlight t)
1078 (defcustom gnus-treat-display-grey-xface
1079 (and (not noninteractive)
1080 (string-match "^0x" (shell-command-to-string "uncompface"))
1082 "Display grey X-Face headers.
1083 Valid values are nil, t."
1084 :group 'gnus-article-treat
1087 (put 'gnus-treat-display-grey-xface 'highlight t)
1089 (defcustom gnus-treat-display-smileys
1090 (if (or (and (featurep 'xemacs)
1092 (and (fboundp 'image-type-available-p)
1093 (image-type-available-p 'pbm)))
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' and Info node
1098 `(gnus)Smileys' for details."
1099 :group 'gnus-article-treat
1101 :type gnus-article-treat-custom)
1102 (put 'gnus-treat-display-smileys 'highlight t)
1104 (defcustom gnus-treat-from-picon
1105 (if (and (gnus-image-type-available-p 'xpm)
1106 (gnus-picons-installed-p))
1108 "Display picons in the From header.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' and Info node
1111 `(gnus)Picons' for details."
1112 :group 'gnus-article-treat
1114 :link '(info-link "(gnus)Customizing Articles")
1115 :link '(info-link "(gnus)Picons")
1116 :type gnus-article-treat-head-custom)
1117 (put 'gnus-treat-from-picon 'highlight t)
1119 (defcustom gnus-treat-mail-picon
1120 (if (and (gnus-image-type-available-p 'xpm)
1121 (gnus-picons-installed-p))
1123 "Display picons in To and Cc headers.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' and Info node
1126 `(gnus)Picons' for details."
1127 :group 'gnus-article-treat
1129 :link '(info-link "(gnus)Customizing Articles")
1130 :link '(info-link "(gnus)Picons")
1131 :type gnus-article-treat-head-custom)
1132 (put 'gnus-treat-mail-picon 'highlight t)
1134 (defcustom gnus-treat-newsgroups-picon
1135 (if (and (gnus-image-type-available-p 'xpm)
1136 (gnus-picons-installed-p))
1138 "Display picons in the Newsgroups and Followup-To headers.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' and Info node
1141 `(gnus)Picons' for details."
1142 :group 'gnus-article-treat
1144 :link '(info-link "(gnus)Customizing Articles")
1145 :link '(info-link "(gnus)Picons")
1146 :type gnus-article-treat-head-custom)
1147 (put 'gnus-treat-newsgroups-picon 'highlight t)
1149 (defcustom gnus-treat-body-boundary
1150 (if (or gnus-treat-newsgroups-picon
1151 gnus-treat-mail-picon
1152 gnus-treat-from-picon)
1154 "Draw a boundary at the end of the headers.
1155 Valid values are nil, t, `head', `last', an integer or a predicate.
1156 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :type gnus-article-treat-custom)
1161 (defcustom gnus-treat-capitalize-sentences nil
1162 "Capitalize sentence-starting words.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :type gnus-article-treat-custom)
1169 (defcustom gnus-treat-fill-long-lines nil
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' for details."
1173 :group 'gnus-article-treat
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-play-sounds nil
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1181 :group 'gnus-article-treat
1182 :type gnus-article-treat-custom)
1184 (defcustom gnus-treat-translate nil
1185 "Translate articles from one language to another.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1189 :group 'gnus-article-treat
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-x-pgp-sig nil
1194 To automatically treat X-PGP-Sig, set it to head.
1195 Valid values are nil, t, `head', `last', an integer or a predicate.
1196 See Info node `(gnus)Customizing Articles' for details."
1197 :group 'gnus-article-treat
1198 :group 'mime-security
1199 :type gnus-article-treat-custom)
1201 (defvar gnus-article-encrypt-protocol-alist
1202 '(("PGP" . mml2015-self-encrypt)))
1204 ;; Set to nil if more than one protocol added to
1205 ;; gnus-article-encrypt-protocol-alist.
1206 (defcustom gnus-article-encrypt-protocol "PGP"
1207 "The protocol used for encrypt articles.
1208 It is a string, such as \"PGP\". If nil, ask user."
1210 :group 'mime-security)
1212 (defvar gnus-article-wash-function nil
1213 "Function used for converting HTML into text.")
1215 ;;; Internal variables
1217 (defvar gnus-english-month-names
1218 '("January" "February" "March" "April" "May" "June" "July" "August"
1219 "September" "October" "November" "December"))
1221 (defvar article-goto-body-goes-to-point-min-p nil)
1222 (defvar gnus-article-wash-types nil)
1223 (defvar gnus-article-emphasis-alist nil)
1224 (defvar gnus-article-image-alist nil)
1226 (defvar gnus-article-mime-handle-alist-1 nil)
1227 (defvar gnus-treatment-function-alist
1228 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1229 (gnus-treat-strip-banner gnus-article-strip-banner)
1230 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1231 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1232 (gnus-treat-buttonize gnus-article-add-buttons)
1233 (gnus-treat-fill-article gnus-article-fill-cited-article)
1234 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1235 (gnus-treat-strip-cr gnus-article-remove-cr)
1236 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1237 (gnus-treat-date-ut gnus-article-date-ut)
1238 (gnus-treat-date-local gnus-article-date-local)
1239 (gnus-treat-date-english gnus-article-date-english)
1240 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1241 (gnus-treat-date-original gnus-article-date-original)
1242 (gnus-treat-date-user-defined gnus-article-date-user)
1243 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1244 (gnus-treat-display-xface gnus-article-display-x-face)
1245 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1246 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1247 (gnus-treat-hide-signature gnus-article-hide-signature)
1248 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1249 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1250 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1251 (gnus-treat-strip-pem gnus-article-hide-pem)
1252 (gnus-treat-from-picon gnus-treat-from-picon)
1253 (gnus-treat-mail-picon gnus-treat-mail-picon)
1254 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1255 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1256 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1257 (gnus-treat-strip-trailing-blank-lines
1258 gnus-article-remove-trailing-blank-lines)
1259 (gnus-treat-strip-leading-blank-lines
1260 gnus-article-strip-leading-blank-lines)
1261 (gnus-treat-strip-multiple-blank-lines
1262 gnus-article-strip-multiple-blank-lines)
1263 (gnus-treat-overstrike gnus-article-treat-overstrike)
1264 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1265 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1266 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1267 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1268 (gnus-treat-display-smileys gnus-treat-smiley)
1269 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1270 (gnus-treat-emphasize gnus-article-emphasize)
1271 (gnus-treat-hide-citation gnus-article-hide-citation)
1272 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1273 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1274 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1275 (gnus-treat-play-sounds gnus-earcon-display)))
1277 (defvar gnus-article-mime-handle-alist nil)
1278 (defvar article-lapsed-timer nil)
1279 (defvar gnus-article-current-summary nil)
1281 (defvar gnus-article-mode-syntax-table
1282 (let ((table (copy-syntax-table text-mode-syntax-table)))
1283 ;; This causes the citation match run O(2^n).
1284 ;; (modify-syntax-entry ?- "w" table)
1285 (modify-syntax-entry ?> ")" table)
1286 (modify-syntax-entry ?< "(" table)
1288 "Syntax table used in article mode buffers.
1289 Initialized from `text-mode-syntax-table.")
1291 (defvar gnus-save-article-buffer nil)
1293 (defvar gnus-article-mode-line-format-alist
1294 (nconc '((?w (gnus-article-wash-status) ?s)
1295 (?m (gnus-article-mime-part-status) ?s))
1296 gnus-summary-mode-line-format-alist))
1298 (defvar gnus-number-of-articles-to-be-saved nil)
1300 (defvar gnus-inhibit-hiding nil)
1302 ;;; Macros for dealing with the article buffer.
1304 (defmacro gnus-with-article-headers (&rest forms)
1306 (set-buffer gnus-article-buffer)
1308 (let ((buffer-read-only nil)
1309 (inhibit-point-motion-hooks t)
1310 (case-fold-search t))
1311 (article-narrow-to-head)
1314 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1315 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1317 (defmacro gnus-with-article-buffer (&rest forms)
1319 (set-buffer gnus-article-buffer)
1320 (let ((buffer-read-only nil))
1323 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1324 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1326 (defun gnus-article-goto-header (header)
1327 "Go to HEADER, which is a regular expression."
1328 (re-search-forward (concat "^\\(" header "\\):") nil t))
1330 (defsubst gnus-article-hide-text (b e props)
1331 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1332 (gnus-add-text-properties-when 'article-type nil b e props)
1333 (when (memq 'intangible props)
1335 (max (1- b) (point-min))
1336 b 'intangible (cddr (memq 'intangible props)))))
1338 (defsubst gnus-article-unhide-text (b e)
1339 "Remove hidden text properties from region between B and E."
1340 (remove-text-properties b e gnus-hidden-properties)
1341 (when (memq 'intangible gnus-hidden-properties)
1342 (put-text-property (max (1- b) (point-min))
1343 b 'intangible nil)))
1345 (defun gnus-article-hide-text-type (b e type)
1346 "Hide text of TYPE between B and E."
1347 (gnus-add-wash-type type)
1348 (gnus-article-hide-text
1349 b e (cons 'article-type (cons type gnus-hidden-properties))))
1351 (defun gnus-article-unhide-text-type (b e type)
1352 "Unhide text of TYPE between B and E."
1353 (gnus-delete-wash-type type)
1354 (remove-text-properties
1355 b e (cons 'article-type (cons type gnus-hidden-properties)))
1356 (when (memq 'intangible gnus-hidden-properties)
1357 (put-text-property (max (1- b) (point-min))
1358 b 'intangible nil)))
1360 (defun gnus-article-hide-text-of-type (type)
1361 "Hide text of TYPE in the current buffer."
1363 (let ((b (point-min))
1365 (while (setq b (text-property-any b e 'article-type type))
1366 (add-text-properties b (incf b) gnus-hidden-properties)))))
1368 (defun gnus-article-delete-text-of-type (type)
1369 "Delete text of TYPE in the current buffer."
1371 (let ((b (point-min)))
1372 (while (setq b (text-property-any b (point-max) 'article-type type))
1374 b (or (text-property-not-all b (point-max) 'article-type type)
1377 (defun gnus-article-delete-invisible-text ()
1378 "Delete all invisible text in the current buffer."
1380 (let ((b (point-min)))
1381 (while (setq b (text-property-any b (point-max) 'invisible t))
1383 b (or (text-property-not-all b (point-max) 'invisible t)
1386 (defun gnus-article-text-type-exists-p (type)
1387 "Say whether any text of type TYPE exists in the buffer."
1388 (text-property-any (point-min) (point-max) 'article-type type))
1390 (defsubst gnus-article-header-rank ()
1391 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1392 (let ((list gnus-sorted-header-list)
1395 (when (looking-at (car list))
1397 (setq list (cdr list))
1401 (defun article-hide-headers (&optional arg delete)
1402 "Hide unwanted headers and possibly sort them as well."
1404 ;; This function might be inhibited.
1405 (unless gnus-inhibit-hiding
1408 (let ((buffer-read-only nil)
1409 (case-fold-search t)
1410 (max (1+ (length gnus-sorted-header-list)))
1411 (ignored (when (not gnus-visible-headers)
1412 (cond ((stringp gnus-ignored-headers)
1413 gnus-ignored-headers)
1414 ((listp gnus-ignored-headers)
1415 (mapconcat 'identity gnus-ignored-headers
1418 (cond ((stringp gnus-visible-headers)
1419 gnus-visible-headers)
1420 ((and gnus-visible-headers
1421 (listp gnus-visible-headers))
1422 (mapconcat 'identity gnus-visible-headers "\\|"))))
1423 (inhibit-point-motion-hooks t)
1425 ;; First we narrow to just the headers.
1426 (article-narrow-to-head)
1427 ;; Hide any "From " lines at the beginning of (mail) articles.
1428 (while (looking-at "From ")
1431 (delete-region (point-min) (point)))
1432 ;; Then treat the rest of the header lines.
1433 ;; Then we use the two regular expressions
1434 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1435 ;; select which header lines is to remain visible in the
1437 (while (re-search-forward "^[^ \t:]*:" nil t)
1439 ;; Mark the rank of the header.
1441 (point) (1+ (point)) 'message-rank
1442 (if (or (and visible (looking-at visible))
1444 (not (looking-at ignored))))
1445 (gnus-article-header-rank)
1448 (message-sort-headers-1)
1449 (when (setq beg (text-property-any
1450 (point-min) (point-max) 'message-rank (+ 2 max)))
1451 ;; We delete the unwanted headers.
1452 (gnus-add-wash-type 'headers)
1453 (add-text-properties (point-min) (+ 5 (point-min))
1454 '(article-type headers dummy-invisible t))
1455 (delete-region beg (point-max))))))))
1457 (defun article-hide-boring-headers (&optional arg)
1458 "Toggle hiding of headers that aren't very interesting.
1459 If given a negative prefix, always show; if given a positive prefix,
1461 (interactive (gnus-article-hidden-arg))
1462 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1463 (not gnus-show-all-headers))
1466 (let ((buffer-read-only nil)
1467 (list gnus-boring-article-headers)
1468 (inhibit-point-motion-hooks t)
1470 (article-narrow-to-head)
1472 (setq elem (pop list))
1473 (goto-char (point-min))
1475 ;; Hide empty headers.
1477 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1479 (gnus-article-hide-text-type
1480 (progn (beginning-of-line) (point))
1483 (if (re-search-forward "^[^ \t]" nil t)
1487 ;; Hide boring Newsgroups header.
1488 ((eq elem 'newsgroups)
1489 (when (gnus-string-equal
1490 (gnus-fetch-field "newsgroups")
1491 (gnus-group-real-name
1492 (if (boundp 'gnus-newsgroup-name)
1495 (gnus-article-hide-header "newsgroups")))
1496 ((eq elem 'to-address)
1497 (let ((to (message-fetch-field "to"))
1499 (gnus-parameter-to-address
1500 (if (boundp 'gnus-newsgroup-name)
1501 gnus-newsgroup-name ""))))
1502 (when (and to to-address
1505 ;; only one address in To
1506 (nth 1 (mail-extract-address-components to))
1508 (gnus-article-hide-header "to"))))
1509 ((eq elem 'followup-to)
1510 (when (gnus-string-equal
1511 (message-fetch-field "followup-to")
1512 (message-fetch-field "newsgroups"))
1513 (gnus-article-hide-header "followup-to")))
1514 ((eq elem 'reply-to)
1515 (let ((from (message-fetch-field "from"))
1516 (reply-to (message-fetch-field "reply-to")))
1521 (nth 1 (mail-extract-address-components from))
1522 (nth 1 (mail-extract-address-components reply-to)))))
1523 (gnus-article-hide-header "reply-to"))))
1525 (let ((date (message-fetch-field "date")))
1527 (< (days-between (current-time-string) date)
1529 (gnus-article-hide-header "date"))))
1531 (let ((to (message-fetch-field "to"))
1532 (cc (message-fetch-field "cc")))
1533 (when (> (length to) 1024)
1534 (gnus-article-hide-header "to"))
1535 (when (> (length cc) 1024)
1536 (gnus-article-hide-header "cc"))))
1540 (goto-char (point-min))
1541 (while (re-search-forward "^to:" nil t)
1542 (setq to-count (1+ to-count)))
1543 (when (> to-count 1)
1544 (while (> to-count 0)
1545 (goto-char (point-min))
1547 (re-search-forward "^to:" nil nil to-count)
1549 (narrow-to-region (point) (point-max))
1550 (gnus-article-hide-header "to"))
1551 (setq to-count (1- to-count))))
1552 (goto-char (point-min))
1553 (while (re-search-forward "^cc:" nil t)
1554 (setq cc-count (1+ cc-count)))
1555 (when (> cc-count 1)
1556 (while (> cc-count 0)
1557 (goto-char (point-min))
1559 (re-search-forward "^cc:" nil nil cc-count)
1561 (narrow-to-region (point) (point-max))
1562 (gnus-article-hide-header "cc"))
1563 (setq cc-count (1- cc-count)))))))))))))
1565 (defun gnus-article-hide-header (header)
1567 (goto-char (point-min))
1568 (when (re-search-forward (concat "^" header ":") nil t)
1569 (gnus-article-hide-text-type
1570 (progn (beginning-of-line) (point))
1573 (if (re-search-forward "^[^ \t]" nil t)
1578 (defvar gnus-article-normalized-header-length 40
1579 "Length of normalized headers.")
1581 (defun article-normalize-headers ()
1582 "Make all header lines 40 characters long."
1584 (let ((buffer-read-only nil)
1588 (article-narrow-to-head)
1591 ((< (setq column (- (gnus-point-at-eol) (point)))
1592 gnus-article-normalized-header-length)
1594 (insert (make-string
1595 (- gnus-article-normalized-header-length column)
1597 ((> column gnus-article-normalized-header-length)
1598 (gnus-put-text-property
1600 (forward-char gnus-article-normalized-header-length)
1607 (forward-line 1))))))
1609 (defun article-treat-dumbquotes ()
1610 "Translate M****s*** sm*rtq**t*s into proper text.
1611 Note that this function guesses whether a character is a sm*rtq**t* or
1612 not, so it should only be used interactively.
1614 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1615 in an attempt to provide more quoting characters. If you see
1616 something like \\222 or \\264 where you're expecting some kind of
1617 apostrophe or quotation mark, then try this wash."
1619 (article-translate-strings gnus-article-dumbquotes-map))
1621 (defun article-translate-characters (from to)
1622 "Translate all characters in the body of the article according to FROM and TO.
1623 FROM is a string of characters to translate from; to is a string of
1624 characters to translate to."
1626 (when (article-goto-body)
1627 (let ((buffer-read-only nil)
1628 (x (make-string 225 ?x))
1630 (while (< (incf i) (length x))
1633 (while (< i (length from))
1634 (aset x (aref from i) (aref to i))
1636 (translate-region (point) (point-max) x)))))
1638 (defun article-translate-strings (map)
1639 "Translate all string in the body of the article according to MAP.
1640 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1642 (when (article-goto-body)
1643 (let ((buffer-read-only nil)
1645 (while (setq elem (pop map))
1647 (while (search-forward (car elem) nil t)
1648 (replace-match (cadr elem)))))))))
1650 (defun article-treat-overstrike ()
1651 "Translate overstrikes into bold text."
1654 (when (article-goto-body)
1655 (let ((buffer-read-only nil))
1656 (while (search-forward "\b" nil t)
1657 (let ((next (char-after))
1658 (previous (char-after (- (point) 2))))
1659 ;; We do the boldification/underlining by hiding the
1660 ;; overstrikes and putting the proper text property
1664 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1665 (put-text-property (point) (1+ (point)) 'face 'bold))
1667 (gnus-article-hide-text-type
1668 (1- (point)) (1+ (point)) 'overstrike)
1670 (- (point) 2) (1- (point)) 'face 'underline))
1672 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1674 (point) (1+ (point)) 'face 'underline)))))))))
1676 (defun gnus-article-treat-unfold-headers ()
1677 "Unfold folded message headers.
1678 Only the headers that fit into the current window width will be
1681 (gnus-with-article-headers
1685 (mail-header-narrow-to-field)
1686 (let ((header (buffer-substring (point-min) (point-max))))
1689 (goto-char (point-min))
1690 (while (re-search-forward "\n[\t ]" nil t)
1691 (replace-match " " t t)))
1692 (setq length (- (point-max) (point-min) 1)))
1693 (when (< length (window-width))
1694 (while (re-search-forward "\n[\t ]" nil t)
1695 (replace-match " " t t)))
1696 (goto-char (point-max)))))))
1698 (defun gnus-article-treat-fold-headers ()
1699 "Fold message headers."
1701 (gnus-with-article-headers
1704 (mail-header-narrow-to-field)
1705 (mail-header-fold-field)
1706 (goto-char (point-max))))))
1708 (defun gnus-treat-smiley ()
1709 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1711 (gnus-with-article-buffer
1712 (if (memq 'smiley gnus-article-wash-types)
1713 (gnus-delete-images 'smiley)
1715 (let ((images (smiley-region (point) (point-max))))
1717 (gnus-add-wash-type 'smiley)
1718 (dolist (image images)
1719 (gnus-add-image 'smiley image)))))))
1721 (defun gnus-article-remove-images ()
1722 "Remove all images from the article buffer."
1724 (gnus-with-article-buffer
1725 (dolist (elem gnus-article-image-alist)
1726 (gnus-delete-images (car elem)))))
1728 (defun gnus-article-treat-fold-newsgroups ()
1729 "Unfold folded message headers.
1730 Only the headers that fit into the current window width will be
1733 (gnus-with-article-headers
1734 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1736 (mail-header-narrow-to-field)
1737 (while (re-search-forward ", *" nil t)
1738 (replace-match ", " t t))
1739 (mail-header-fold-field)
1740 (goto-char (point-max))))))
1742 (defun gnus-article-treat-body-boundary ()
1743 "Place a boundary line at the end of the headers."
1745 (when (and gnus-body-boundary-delimiter
1746 (> (length gnus-body-boundary-delimiter) 0))
1747 (gnus-with-article-headers
1748 (goto-char (point-max))
1749 (let ((start (point)))
1750 (insert "X-Boundary: ")
1751 (gnus-add-text-properties start (point) '(invisible t intangible t))
1753 (while (>= (1- (window-width)) (length str))
1754 (setq str (concat str gnus-body-boundary-delimiter)))
1755 (substring str 0 (1- (window-width))))
1757 (gnus-add-text-properties start (point) '(gnus-decoration 'header))))))
1759 (defun article-fill-long-lines ()
1760 "Fill lines that are wider than the window width."
1763 (let ((buffer-read-only nil)
1764 (width (window-width (get-buffer-window (current-buffer)))))
1767 (let ((adaptive-fill-mode nil)) ;Why? -sm
1770 (when (>= (current-column) (min fill-column width))
1771 (narrow-to-region (point) (gnus-point-at-bol))
1772 (fill-paragraph nil)
1773 (goto-char (point-max))
1775 (forward-line 1)))))))
1777 (defun article-capitalize-sentences ()
1778 "Capitalize the first word in each sentence."
1781 (let ((buffer-read-only nil)
1782 (paragraph-start "^[\n\^L]"))
1786 (forward-sentence)))))
1788 (defun article-remove-cr ()
1789 "Remove trailing CRs and then translate remaining CRs into LFs."
1792 (let ((buffer-read-only nil))
1793 (goto-char (point-min))
1794 (while (re-search-forward "\r+$" nil t)
1795 (replace-match "" t t))
1796 (goto-char (point-min))
1797 (while (search-forward "\r" nil t)
1798 (replace-match "\n" t t)))))
1800 (defun article-remove-trailing-blank-lines ()
1801 "Remove all trailing blank lines from the article."
1804 (let ((buffer-read-only nil))
1805 (goto-char (point-max))
1809 (while (and (not (bobp))
1810 (looking-at "^[ \t]*$")
1811 (not (gnus-annotation-in-region-p
1812 (point) (gnus-point-at-eol))))
1817 (defun article-display-x-face (&optional force)
1818 "Look for an X-Face header and display it if present."
1819 (interactive (list 'force))
1820 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1821 (gnus-with-article-headers
1822 ;; Delete the old process, if any.
1823 (when (process-status "article-x-face")
1824 (delete-process "article-x-face"))
1825 (if (memq 'xface gnus-article-wash-types)
1826 ;; We have already displayed X-Faces, so we remove them
1828 (gnus-delete-images 'xface)
1830 (let (x-faces from face grey)
1832 (when (and wash-face-p
1834 (goto-char (point-min))
1835 (not (re-search-forward
1836 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1837 (gnus-buffer-live-p gnus-original-article-buffer))
1838 ;; If type `W f', use gnus-original-article-buffer,
1839 ;; otherwise use the current buffer because displaying
1840 ;; RFC822 parts calls this function too.
1841 (set-buffer gnus-original-article-buffer))
1843 (mail-narrow-to-head)
1844 (if gnus-treat-display-grey-xface
1846 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1847 (if (match-beginning 2)
1850 (push (cons (- (string-to-number (match-string 2)))
1851 (mail-header-field-value))
1853 (push (cons 0 (mail-header-field-value)) x-faces)))
1854 (dolist (x-face (prog1
1856 (sort x-faces 'car-less-than-car)
1858 (setq x-faces nil)))
1859 (push (cdr x-face) x-faces)))
1860 (while (gnus-article-goto-header "X-Face")
1861 (push (mail-header-field-value) x-faces)))
1862 (setq from (message-fetch-field "from"))))
1864 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1867 (setq image (gnus-create-image xpm 'xpm t))
1868 (gnus-article-goto-header "from")
1870 (insert "From: [no `from' set]\n")
1872 (gnus-add-wash-type 'xface)
1873 (gnus-add-image 'xface image)
1874 (gnus-put-image image)))
1875 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1876 ;; single external face.
1877 (when (stringp gnus-article-x-face-command)
1878 (setq x-faces (list (car x-faces))))
1879 (while (and (setq face (pop x-faces))
1880 gnus-article-x-face-command
1882 ;; Check whether this face is censored.
1883 (not gnus-article-x-face-too-ugly)
1884 (and gnus-article-x-face-too-ugly from
1885 (not (string-match gnus-article-x-face-too-ugly
1887 ;; We display the face.
1888 (if (symbolp gnus-article-x-face-command)
1889 ;; The command is a lisp function, so we call it.
1890 (if (gnus-functionp gnus-article-x-face-command)
1891 (funcall gnus-article-x-face-command face)
1892 (error "%s is not a function" gnus-article-x-face-command))
1893 ;; The command is a string, so we interpret the command
1894 ;; as a, well, command, and fork it off.
1895 (let ((process-connection-type nil))
1896 (process-kill-without-query
1898 "article-x-face" nil shell-file-name shell-command-switch
1899 gnus-article-x-face-command))
1902 (process-send-region "article-x-face"
1903 (point-min) (point-max)))
1904 (process-send-eof "article-x-face"))))))))))
1906 (defun article-decode-mime-words ()
1907 "Decode all MIME-encoded words in the article."
1910 (set-buffer gnus-article-buffer)
1911 (let ((inhibit-point-motion-hooks t)
1913 (mail-parse-charset gnus-newsgroup-charset)
1914 (mail-parse-ignored-charsets
1915 (save-excursion (set-buffer gnus-summary-buffer)
1916 gnus-newsgroup-ignored-charsets)))
1917 (mail-decode-encoded-word-region (point-min) (point-max)))))
1919 (defun article-decode-charset (&optional prompt)
1920 "Decode charset-encoded text in the article.
1921 If PROMPT (the prefix), prompt for a coding system to use."
1923 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1925 (mail-parse-charset gnus-newsgroup-charset)
1926 (mail-parse-ignored-charsets
1927 (save-excursion (condition-case nil
1928 (set-buffer gnus-summary-buffer)
1930 gnus-newsgroup-ignored-charsets))
1931 ct cte ctl charset format)
1934 (article-narrow-to-head)
1935 (setq ct (message-fetch-field "Content-Type" t)
1936 cte (message-fetch-field "Content-Transfer-Encoding" t)
1937 ctl (and ct (ignore-errors
1938 (mail-header-parse-content-type ct)))
1941 (mm-read-coding-system "Charset to decode: "))
1943 (mail-content-type-get ctl 'charset)))
1944 format (and ctl (mail-content-type-get ctl 'format)))
1946 (setq cte (mail-header-strip cte)))
1947 (if (and ctl (not (string-match "/" (car ctl))))
1949 (goto-char (point-max)))
1952 (narrow-to-region (point) (point-max))
1953 (when (and (eq mail-parse-charset 'gnus-decoded)
1954 (eq (mm-body-7-or-8) '8bit))
1955 ;; The text code could have been decoded.
1956 (setq charset mail-parse-charset))
1957 (when (and (or (not ctl)
1958 (equal (car ctl) "text/plain"))
1959 (not format)) ;; article with format will decode later.
1961 charset (and cte (intern (downcase
1962 (gnus-strip-whitespace cte))))
1965 (defun article-decode-encoded-words ()
1966 "Remove encoded-word encoding from headers."
1967 (let ((inhibit-point-motion-hooks t)
1968 (mail-parse-charset gnus-newsgroup-charset)
1969 (mail-parse-ignored-charsets
1970 (save-excursion (condition-case nil
1971 (set-buffer gnus-summary-buffer)
1973 gnus-newsgroup-ignored-charsets))
1976 (article-narrow-to-head)
1977 (funcall gnus-decode-header-function (point-min) (point-max)))))
1979 (defun article-decode-group-name ()
1980 "Decode group names in `Newsgroups:'."
1981 (let ((inhibit-point-motion-hooks t)
1983 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1984 (when (and (or gnus-group-name-charset-method-alist
1985 gnus-group-name-charset-group-alist)
1986 (gnus-buffer-live-p gnus-original-article-buffer))
1987 (when (nnmail-fetch-field "Newsgroups")
1988 (nnheader-replace-header "Newsgroups"
1989 (gnus-decode-newsgroups
1990 (with-current-buffer
1991 gnus-original-article-buffer
1992 (nnmail-fetch-field "Newsgroups"))
1993 gnus-newsgroup-name method)))
1994 (when (nnmail-fetch-field "Followup-To")
1995 (nnheader-replace-header "Followup-To"
1996 (gnus-decode-newsgroups
1997 (with-current-buffer
1998 gnus-original-article-buffer
1999 (nnmail-fetch-field "Followup-To"))
2000 gnus-newsgroup-name method))))))
2002 (defun article-de-quoted-unreadable (&optional force read-charset)
2003 "Translate a quoted-printable-encoded article.
2004 If FORCE, decode the article whether it is marked as quoted-printable
2006 If READ-CHARSET, ask for a coding system."
2007 (interactive (list 'force current-prefix-arg))
2009 (let ((buffer-read-only nil) type charset)
2010 (if (gnus-buffer-live-p gnus-original-article-buffer)
2011 (with-current-buffer gnus-original-article-buffer
2013 (gnus-fetch-field "content-transfer-encoding"))
2014 (let* ((ct (gnus-fetch-field "content-type"))
2017 (mail-header-parse-content-type ct)))))
2018 (setq charset (and ctl
2019 (mail-content-type-get ctl 'charset)))
2020 (if (stringp charset)
2021 (setq charset (intern (downcase charset)))))))
2023 (setq charset (mm-read-coding-system "Charset: " charset)))
2025 (setq charset gnus-newsgroup-charset))
2027 (and type (let ((case-fold-search t))
2028 (string-match "quoted-printable" type))))
2030 (quoted-printable-decode-region
2031 (point) (point-max) (mm-charset-to-coding-system charset))))))
2033 (defun article-de-base64-unreadable (&optional force read-charset)
2034 "Translate a base64 article.
2035 If FORCE, decode the article whether it is marked as base64 not.
2036 If READ-CHARSET, ask for a coding system."
2037 (interactive (list 'force current-prefix-arg))
2039 (let ((buffer-read-only nil) type charset)
2040 (if (gnus-buffer-live-p gnus-original-article-buffer)
2041 (with-current-buffer gnus-original-article-buffer
2043 (gnus-fetch-field "content-transfer-encoding"))
2044 (let* ((ct (gnus-fetch-field "content-type"))
2047 (mail-header-parse-content-type ct)))))
2048 (setq charset (and ctl
2049 (mail-content-type-get ctl 'charset)))
2050 (if (stringp charset)
2051 (setq charset (intern (downcase charset)))))))
2053 (setq charset (mm-read-coding-system "Charset: " charset)))
2055 (setq charset gnus-newsgroup-charset))
2057 (and type (let ((case-fold-search t))
2058 (string-match "base64" type))))
2061 (narrow-to-region (point) (point-max))
2062 (base64-decode-region (point-min) (point-max))
2063 (mm-decode-coding-region
2064 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2069 (defun article-decode-HZ ()
2070 "Translate a HZ-encoded article."
2074 (let ((buffer-read-only nil))
2075 (rfc1843-decode-region (point-min) (point-max)))))
2077 (defun article-unsplit-urls ()
2078 "Remove the newlines that some other mailers insert into URLs."
2081 (let ((buffer-read-only nil))
2082 (goto-char (point-min))
2083 (while (re-search-forward
2084 "^\\(\\(https?\\|ftp\\)://\\S-+\\)\n\\(\\S-+\\)" nil t)
2085 (replace-match "\\1\\3" t)))))
2087 (defun article-wash-html (&optional read-charset)
2088 "Format an html article.
2089 If READ-CHARSET, ask for a coding system."
2092 (let ((buffer-read-only nil)
2094 (if (gnus-buffer-live-p gnus-original-article-buffer)
2095 (with-current-buffer gnus-original-article-buffer
2096 (let* ((ct (gnus-fetch-field "content-type"))
2099 (mail-header-parse-content-type ct)))))
2100 (setq charset (and ctl
2101 (mail-content-type-get ctl 'charset)))
2102 (if (stringp charset)
2103 (setq charset (intern (downcase charset)))))))
2105 (setq charset (mm-read-coding-system "Charset: " charset)))
2107 (setq charset gnus-newsgroup-charset))
2109 (save-window-excursion
2111 (narrow-to-region (point) (point-max))
2112 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2113 (entry (assq func mm-text-html-washer-alist)))
2115 (setq func (cdr entry)))
2117 ((gnus-functionp func)
2120 (apply (car func) (cdr func))))))))))
2122 (defun gnus-article-wash-html-with-w3 ()
2123 "Wash the current buffer with w3."
2125 (let ((w3-strict-width (window-width))
2126 (url-standalone-mode t)
2127 (url-gateway-unplugged t)
2128 (w3-honor-stylesheets nil))
2130 (w3-region (point-min) (point-max))
2133 (defun gnus-article-wash-html-with-w3m ()
2134 "Wash the current buffer with emacs-w3m."
2137 (narrow-to-region (point) (point-max))
2138 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2141 (w3m-display-inline-images mm-inline-text-html-with-images)
2142 w3m-force-redisplay)
2143 (w3m-region (point-min) (point-max)))
2144 (when mm-inline-text-html-with-w3m-keymap
2145 (add-text-properties
2146 (point-min) (point-max)
2147 (append '(mm-inline-text-html-with-w3m t)
2148 (gnus-local-map-property mm-w3m-mode-map))))))
2150 (defun article-hide-list-identifiers ()
2151 "Remove list identifies from the Subject header.
2152 The `gnus-list-identifiers' variable specifies what to do."
2154 (let ((inhibit-point-motion-hooks t)
2155 (regexp (if (consp gnus-list-identifiers)
2156 (mapconcat 'identity gnus-list-identifiers " *\\|")
2157 gnus-list-identifiers))
2162 (article-narrow-to-head)
2163 (goto-char (point-min))
2164 (while (re-search-forward
2165 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2167 (delete-region (match-beginning 2) (match-end 0))
2168 (beginning-of-line))
2169 (when (re-search-forward
2170 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2171 (delete-region (match-beginning 1) (match-end 1))))))))
2173 (defun article-hide-pgp ()
2174 "Remove any PGP headers and signatures in the current article."
2178 (let ((inhibit-point-motion-hooks t)
2179 buffer-read-only beg end)
2181 ;; Hide the "header".
2182 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2183 (gnus-add-wash-type 'pgp)
2184 (delete-region (match-beginning 0) (match-end 0))
2185 ;; Remove armor headers (rfc2440 6.2)
2186 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2189 ;; Hide the actual signature.
2190 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2191 (setq end (1+ (match-beginning 0)))
2194 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2196 ;; Perhaps we shouldn't hide to the end of the buffer
2197 ;; if there is no end to the signature?
2199 ;; Hide "- " PGP quotation markers.
2201 (narrow-to-region beg end)
2202 (goto-char (point-min))
2203 (while (re-search-forward "^- " nil t)
2205 (match-beginning 0) (match-end 0)))
2207 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2209 (defun article-hide-pem (&optional arg)
2210 "Toggle hiding of any PEM headers and signatures in the current article.
2211 If given a negative prefix, always show; if given a positive prefix,
2213 (interactive (gnus-article-hidden-arg))
2214 (unless (gnus-article-check-hidden-text 'pem arg)
2216 (let (buffer-read-only end)
2217 (goto-char (point-min))
2218 ;; Hide the horrendously ugly "header".
2219 (when (and (search-forward
2220 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2222 (setq end (1+ (match-beginning 0))))
2223 (gnus-add-wash-type 'pem)
2224 (gnus-article-hide-text-type
2226 (if (search-forward "\n\n" nil t)
2230 ;; Hide the trailer as well
2231 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2233 (gnus-article-hide-text-type
2234 (match-beginning 0) (match-end 0) 'pem)))))))
2236 (defun article-strip-banner ()
2237 "Strip the banner specified by the `banner' group parameter."
2241 (let ((inhibit-point-motion-hooks t)
2242 (banner (gnus-parameter-banner gnus-newsgroup-name))
2243 (gnus-signature-limit nil)
2244 buffer-read-only beg end)
2248 ((eq banner 'signature)
2249 (when (gnus-article-narrow-to-signature)
2252 (delete-region (point) (point-max))))
2254 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2255 (while (re-search-forward banner nil t)
2256 (delete-region (match-beginning 0) (match-end 0)))))
2258 (while (re-search-forward banner nil t)
2259 (delete-region (match-beginning 0) (match-end 0))))))))))
2261 (defun article-babel ()
2262 "Translate article using an online translation service."
2266 (set-buffer gnus-article-buffer)
2267 (when (article-goto-body)
2268 (let* ((buffer-read-only nil)
2271 (orig (buffer-substring start end))
2272 (trans (babel-as-string orig)))
2274 (narrow-to-region start end)
2275 (delete-region start end)
2278 (defun article-hide-signature (&optional arg)
2279 "Hide the signature in the current article.
2280 If given a negative prefix, always show; if given a positive prefix,
2282 (interactive (gnus-article-hidden-arg))
2283 (unless (gnus-article-check-hidden-text 'signature arg)
2286 (let ((buffer-read-only nil))
2287 (when (gnus-article-narrow-to-signature)
2288 (gnus-article-hide-text-type
2289 (point-min) (point-max) 'signature))))))
2290 (gnus-set-mode-line 'article))
2292 (defun article-strip-headers-in-body ()
2293 "Strip offensive headers from bodies."
2297 (let ((case-fold-search t))
2298 (when (looking-at "x-no-archive:")
2299 (gnus-delete-line)))))
2301 (defun article-strip-leading-blank-lines ()
2302 "Remove all blank lines from the beginning of the article."
2305 (let ((inhibit-point-motion-hooks t)
2307 (when (article-goto-body)
2308 (while (and (not (eobp))
2309 (looking-at "[ \t]*$"))
2310 (gnus-delete-line))))))
2312 (defun article-narrow-to-head ()
2313 "Narrow the buffer to the head of the message.
2314 Point is left at the beginning of the narrowed-to region."
2316 (goto-char (point-min))
2317 (if (search-forward "\n\n" nil 1)
2320 (goto-char (point-min)))
2322 (defun article-goto-body ()
2323 "Place point at the start of the body."
2324 (goto-char (point-min))
2326 ;; This variable is only bound when dealing with separate
2328 (article-goto-body-goes-to-point-min-p
2330 ((search-forward "\n\n" nil t)
2333 (goto-char (point-max))
2336 (defun article-strip-multiple-blank-lines ()
2337 "Replace consecutive blank lines with one empty line."
2340 (let ((inhibit-point-motion-hooks t)
2342 ;; First make all blank lines empty.
2344 (while (re-search-forward "^[ \t]+$" nil t)
2345 (unless (gnus-annotation-in-region-p
2346 (match-beginning 0) (match-end 0))
2347 (replace-match "" nil t)))
2348 ;; Then replace multiple empty lines with a single empty line.
2350 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2351 (unless (gnus-annotation-in-region-p
2352 (match-beginning 0) (match-end 0))
2353 (delete-region (match-beginning 1) (match-end 1)))))))
2355 (defun article-strip-leading-space ()
2356 "Remove all white space from the beginning of the lines in the article."
2359 (let ((inhibit-point-motion-hooks t)
2362 (while (re-search-forward "^[ \t]+" nil t)
2363 (replace-match "" t t)))))
2365 (defun article-strip-trailing-space ()
2366 "Remove all white space from the end of the lines in the article."
2369 (let ((inhibit-point-motion-hooks t)
2372 (while (re-search-forward "[ \t]+$" nil t)
2373 (replace-match "" t t)))))
2375 (defun article-strip-blank-lines ()
2376 "Strip leading, trailing and multiple blank lines."
2378 (article-strip-leading-blank-lines)
2379 (article-remove-trailing-blank-lines)
2380 (article-strip-multiple-blank-lines))
2382 (defun article-strip-all-blank-lines ()
2383 "Strip all blank lines."
2386 (let ((inhibit-point-motion-hooks t)
2389 (while (re-search-forward "^[ \t]*\n" nil t)
2390 (replace-match "" t t)))))
2392 (defun gnus-article-narrow-to-signature ()
2393 "Narrow to the signature; return t if a signature is found, else nil."
2394 (let ((inhibit-point-motion-hooks t))
2395 (when (gnus-article-search-signature)
2397 ;; Check whether we have some limits to what we consider
2398 ;; to be a signature.
2399 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2400 (list gnus-signature-limit)))
2402 (while (setq limit (pop limits))
2403 (if (or (and (integerp limit)
2404 (< (- (point-max) (point)) limit))
2406 (< (count-lines (point) (point-max)) limit))
2407 (and (gnus-functionp limit)
2409 (and (stringp limit)
2410 (not (re-search-forward limit nil t))))
2411 () ; This limit did not succeed.
2415 (narrow-to-region (point) (point-max))
2418 (defun gnus-article-search-signature ()
2419 "Search the current buffer for the signature separator.
2420 Put point at the beginning of the signature separator."
2421 (let ((cur (point)))
2422 (goto-char (point-max))
2423 (if (if (stringp gnus-signature-separator)
2424 (re-search-backward gnus-signature-separator nil t)
2425 (let ((seps gnus-signature-separator))
2427 (not (re-search-backward (car seps) nil t)))
2434 (defun gnus-article-hidden-arg ()
2435 "Return the current prefix arg as a number, or 0 if no prefix."
2436 (list (if current-prefix-arg
2437 (prefix-numeric-value current-prefix-arg)
2440 (defun gnus-article-check-hidden-text (type arg)
2441 "Return nil if hiding is necessary.
2442 Arg can be nil or a number. nil and positive means hide, negative
2443 means show, 0 means toggle."
2446 (let ((hide (gnus-article-hidden-text-p type)))
2452 (gnus-article-show-hidden-text type)
2455 (if (eq hide 'hidden)
2457 (gnus-article-show-hidden-text type)
2461 (defun gnus-article-hidden-text-p (type)
2462 "Say whether the current buffer contains hidden text of type TYPE."
2463 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2465 (not (get-text-property pos 'invisible))
2466 (not (get-text-property pos 'dummy-invisible)))
2468 (text-property-any (1+ pos) (point-max) 'article-type type)))
2473 (defun gnus-article-show-hidden-text (type &optional dummy)
2474 "Show all hidden text of type TYPE.
2475 Originally it is hide instead of DUMMY."
2476 (let ((buffer-read-only nil)
2477 (inhibit-point-motion-hooks t))
2478 (gnus-remove-text-properties-when
2480 (point-min) (point-max)
2481 (cons 'article-type (cons type
2482 gnus-hidden-properties)))
2483 (gnus-delete-wash-type type)))
2485 (defconst article-time-units
2486 `((year . ,(* 365.25 24 60 60))
2487 (week . ,(* 7 24 60 60))
2488 (day . ,(* 24 60 60))
2492 "Mapping from time units to seconds.")
2494 (defun article-date-ut (&optional type highlight header)
2495 "Convert DATE date to universal time in the current article.
2496 If TYPE is `local', convert to local time; if it is `lapsed', output
2497 how much time has lapsed since DATE. For `lapsed', the value of
2498 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2499 should replace the \"Date:\" one, or should be added below it."
2500 (interactive (list 'ut t))
2501 (let* ((header (or header
2502 (message-fetch-field "date")
2504 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2507 ((not gnus-article-date-lapsed-new-header)
2513 (date (if (vectorp header) (mail-header-date header)
2515 (inhibit-point-motion-hooks t)
2520 (article-narrow-to-head)
2521 (when (re-search-forward tdate-regexp nil t)
2522 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2523 date (or (get-text-property (gnus-point-at-bol)
2526 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2528 (when (and date (not (string= date "")))
2529 (goto-char (point-min))
2530 (let ((buffer-read-only nil))
2531 ;; Delete any old Date headers.
2532 (while (re-search-forward date-regexp nil t)
2534 (delete-region (progn (beginning-of-line) (point))
2535 (progn (forward-line 1) (point)))
2536 (delete-region (progn (beginning-of-line) (point))
2537 (progn (end-of-line) (point)))
2538 (setq pos (point))))
2539 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2541 (if pos (goto-char pos))
2542 (insert (article-make-date-line date (or type 'ut)))
2548 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2549 (put-text-property (match-beginning 1) (1+ (match-end 1))
2550 'original-date date)
2551 (put-text-property (match-beginning 1) (1+ (match-end 1))
2553 (put-text-property (match-beginning 2) (match-end 2)
2556 (defun article-make-date-line (date type)
2557 "Return a DATE line of TYPE."
2558 (unless (memq type '(local ut original user iso8601 lapsed english))
2559 (error "Unknown conversion type: %s" type))
2561 (let ((time (date-to-time date)))
2563 ;; Convert to the local timezone.
2565 (let ((tz (car (current-time-zone time))))
2566 (format "Date: %s %s%02d%02d" (current-time-string time)
2567 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2568 (/ (% (abs tz) 3600) 60))))
2569 ;; Convert to Universal Time.
2572 (current-time-string
2573 (let* ((e (parse-time-string date))
2574 (tm (apply 'encode-time e))
2576 (ls (- (cadr tm) (car (current-time-zone time)))))
2577 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2578 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2581 ;; Get the original date from the article.
2582 ((eq type 'original)
2583 (concat "Date: " (if (string-match "\n+$" date)
2584 (substring date 0 (match-beginning 0))
2586 ;; Let the user define the format.
2588 (if (gnus-functionp gnus-article-time-format)
2589 (funcall gnus-article-time-format time)
2592 (format-time-string gnus-article-time-format time))))
2595 (let ((tz (car (current-time-zone time))))
2598 (format-time-string "%Y%m%dT%H%M%S" time)
2599 (format "%s%02d%02d"
2600 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2601 (/ (% (abs tz) 3600) 60)))))
2602 ;; Do an X-Sent lapsed format.
2604 ;; If the date is seriously mangled, the timezone functions are
2605 ;; liable to bug out, so we ignore all errors.
2606 (let* ((now (current-time))
2607 (real-time (subtract-time now time))
2608 (real-sec (and real-time
2609 (+ (* (float (car real-time)) 65536)
2611 (sec (and real-time (abs real-sec)))
2621 ;; This is a bit convoluted, but basically we go
2622 ;; through the time units for years, weeks, etc,
2623 ;; and divide things to see whether that results
2624 ;; in positive answers.
2627 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2628 ;; The (remaining) seconds are too few to
2629 ;; be divided into this time unit.
2631 ;; It's big enough, so we output it.
2632 (setq sec (- sec (* num (cdr unit))))
2634 (concat (if prev ", " "") (int-to-string
2636 " " (symbol-name (car unit))
2637 (if (> num 1) "s" ""))
2639 article-time-units "")
2640 ;; If dates are odd, then it might appear like the
2641 ;; article was sent in the future.
2644 " in the future"))))))
2645 ;; Display the date in proper English
2647 (let ((dtime (decode-time time)))
2650 (number-to-string (nth 3 dtime))
2651 (let ((digit (% (nth 3 dtime) 10)))
2653 ((memq (nth 3 dtime) '(11 12 13)) "th")
2659 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2661 (number-to-string (nth 5 dtime))
2663 (format "%02d" (nth 2 dtime))
2665 (format "%02d" (nth 1 dtime)))))))
2667 (format "Date: %s (from Oort)" date))))
2669 (defun article-date-local (&optional highlight)
2670 "Convert the current article date to the local timezone."
2671 (interactive (list t))
2672 (article-date-ut 'local highlight))
2674 (defun article-date-english (&optional highlight)
2675 "Convert the current article date to something that is proper English."
2676 (interactive (list t))
2677 (article-date-ut 'english highlight))
2679 (defun article-date-original (&optional highlight)
2680 "Convert the current article date to what it was originally.
2681 This is only useful if you have used some other date conversion
2682 function and want to see what the date was before converting."
2683 (interactive (list t))
2684 (article-date-ut 'original highlight))
2686 (defun article-date-lapsed (&optional highlight)
2687 "Convert the current article date to time lapsed since it was sent."
2688 (interactive (list t))
2689 (article-date-ut 'lapsed highlight))
2691 (defun article-update-date-lapsed ()
2692 "Function to be run from a timer to update the lapsed time line."
2693 (let (deactivate-mark)
2698 (set-buffer (window-buffer w))
2699 (when (eq major-mode 'gnus-article-mode)
2700 (goto-char (point-min))
2701 (when (re-search-forward "^X-Sent:" nil t)
2702 (article-date-lapsed t))))
2705 (defun gnus-start-date-timer (&optional n)
2706 "Start a timer to update the X-Sent header in the article buffers.
2707 The numerical prefix says how frequently (in seconds) the function
2712 (gnus-stop-date-timer)
2713 (setq article-lapsed-timer
2714 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2716 (defun gnus-stop-date-timer ()
2717 "Stop the X-Sent timer."
2719 (when article-lapsed-timer
2720 (nnheader-cancel-timer article-lapsed-timer)
2721 (setq article-lapsed-timer nil)))
2723 (defun article-date-user (&optional highlight)
2724 "Convert the current article date to the user-defined format.
2725 This format is defined by the `gnus-article-time-format' variable."
2726 (interactive (list t))
2727 (article-date-ut 'user highlight))
2729 (defun article-date-iso8601 (&optional highlight)
2730 "Convert the current article date to ISO8601."
2731 (interactive (list t))
2732 (article-date-ut 'iso8601 highlight))
2734 ;; (defun article-show-all ()
2735 ;; "Show all hidden text in the article buffer."
2738 ;; (let ((buffer-read-only nil))
2739 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2741 (defun article-remove-leading-whitespace ()
2742 "Remove excessive whitespace from all headers."
2746 (let ((buffer-read-only nil))
2747 (article-narrow-to-head)
2748 (goto-char (point-min))
2749 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2750 (delete-region (match-beginning 1) (match-end 1)))))))
2752 (defun article-emphasize (&optional arg)
2753 "Emphasize text according to `gnus-emphasis-alist'."
2754 (interactive (gnus-article-hidden-arg))
2755 (unless (gnus-article-check-hidden-text 'emphasis arg)
2759 (with-current-buffer gnus-summary-buffer
2760 gnus-article-emphasis-alist)
2762 gnus-emphasis-alist))
2763 (buffer-read-only nil)
2764 (props (append '(article-type emphasis)
2765 gnus-hidden-properties))
2766 regexp elem beg invisible visible face)
2769 (while (setq elem (pop alist))
2771 (setq regexp (car elem)
2772 invisible (nth 1 elem)
2773 visible (nth 2 elem)
2775 (while (re-search-forward regexp nil t)
2776 (when (and (match-beginning visible) (match-beginning invisible))
2777 (gnus-article-hide-text
2778 (match-beginning invisible) (match-end invisible) props)
2779 (gnus-article-unhide-text-type
2780 (match-beginning visible) (match-end visible) 'emphasis)
2781 (gnus-put-overlay-excluding-newlines
2782 (match-beginning visible) (match-end visible) 'face face)
2783 (gnus-add-wash-type 'emphasis)
2784 (goto-char (match-end invisible)))))))))
2786 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2787 "Setup newsgroup emphasis alist."
2788 (unless gnus-article-emphasis-alist
2789 (let ((name (and gnus-newsgroup-name
2790 (gnus-group-real-name gnus-newsgroup-name))))
2791 (make-local-variable 'gnus-article-emphasis-alist)
2792 (setq gnus-article-emphasis-alist
2794 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2795 (while (setq elem (pop alist))
2796 (when (and name (string-match (car elem) name))
2798 highlight (copy-sequence (cdr elem)))))
2800 (copy-sequence highlight-words)
2801 (if gnus-newsgroup-name
2802 (copy-sequence (gnus-group-find-parameter
2803 gnus-newsgroup-name 'highlight-words t)))
2804 gnus-emphasis-alist)))))
2807 (defvar gnus-summary-article-menu)
2808 (defvar gnus-summary-post-menu))
2810 ;;; Saving functions.
2812 (defun gnus-article-save (save-buffer file &optional num)
2813 "Save the currently selected article."
2814 (unless gnus-save-all-headers
2815 ;; Remove headers according to `gnus-saved-headers'.
2816 (let ((gnus-visible-headers
2817 (or gnus-saved-headers gnus-visible-headers))
2818 (gnus-article-buffer save-buffer))
2820 (set-buffer save-buffer)
2821 (article-hide-headers 1 t))))
2822 (save-window-excursion
2823 (if (not gnus-default-article-saver)
2824 (error "No default saver is defined")
2825 ;; !!! Magic! The saving functions all save
2826 ;; `gnus-save-article-buffer' (or so they think), but we
2827 ;; bind that variable to our save-buffer.
2828 (set-buffer gnus-article-buffer)
2829 (let* ((gnus-save-article-buffer save-buffer)
2832 ((not gnus-prompt-before-saving) 'default)
2833 ((eq gnus-prompt-before-saving 'always) nil)
2835 (gnus-number-of-articles-to-be-saved
2836 (when (eq gnus-prompt-before-saving t)
2838 (set-buffer gnus-article-current-summary)
2839 (funcall gnus-default-article-saver filename)))))
2841 (defun gnus-read-save-file-name (prompt &optional filename
2842 function group headers variable)
2844 (funcall function group headers (symbol-value variable)))
2849 ((eq filename 'default)
2855 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2858 (if (and gnus-number-of-articles-to-be-saved
2859 (> gnus-number-of-articles-to-be-saved 1))
2860 (format "these %d articles"
2861 gnus-number-of-articles-to-be-saved)
2864 ;; Let the split methods have their say.
2866 ;; No split name was found.
2869 (concat prompt " (default "
2870 (file-name-nondirectory default-name) ") ")
2871 (file-name-directory default-name)
2873 ;; A single group name is returned.
2874 ((stringp split-name)
2876 (funcall function split-name headers
2877 (symbol-value variable)))
2879 (concat prompt " (default "
2880 (file-name-nondirectory default-name) ") ")
2881 (file-name-directory default-name)
2883 ;; A single split name was found
2884 ((= 1 (length split-name))
2885 (let* ((name (expand-file-name
2887 gnus-article-save-directory))
2888 (dir (cond ((file-directory-p name)
2889 (file-name-as-directory name))
2890 ((file-exists-p name) name)
2891 (t gnus-article-save-directory))))
2893 (concat prompt " (default " name ") ")
2895 ;; A list of splits was found.
2897 (setq split-name (nreverse split-name))
2899 (let ((file-name-history
2900 (nconc split-name file-name-history)))
2904 (concat prompt " (`M-p' for defaults) ")
2905 gnus-article-save-directory
2907 gnus-article-save-directory)))
2908 (car (push result file-name-history)))))))
2909 ;; Create the directory.
2910 (gnus-make-directory (file-name-directory file))
2911 ;; If we have read a directory, we append the default file name.
2912 (when (file-directory-p file)
2913 (setq file (expand-file-name (file-name-nondirectory
2915 (file-name-as-directory file))))
2916 ;; Possibly translate some characters.
2917 (nnheader-translate-file-chars file))))))
2918 (gnus-make-directory (file-name-directory result))
2919 (set variable result)))
2921 (defun gnus-article-archive-name (group)
2922 "Return the first instance of an \"Archive-name\" in the current buffer."
2923 (let ((case-fold-search t))
2924 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2925 (nnheader-concat gnus-article-save-directory
2926 (match-string 1)))))
2928 (defun gnus-article-nndoc-name (group)
2929 "If GROUP is an nndoc group, return the name of the parent group."
2930 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2931 (gnus-group-get-parameter group 'save-article-group)))
2933 (defun gnus-summary-save-in-rmail (&optional filename)
2934 "Append this article to Rmail file.
2935 Optional argument FILENAME specifies file name.
2936 Directory to save to is default to `gnus-article-save-directory'."
2937 (setq filename (gnus-read-save-file-name
2938 "Save %s in rmail file:" filename
2939 gnus-rmail-save-name gnus-newsgroup-name
2940 gnus-current-headers 'gnus-newsgroup-last-rmail))
2941 (gnus-eval-in-buffer-window gnus-save-article-buffer
2945 (gnus-output-to-rmail filename))))
2948 (defun gnus-summary-save-in-mail (&optional filename)
2949 "Append this article to Unix mail file.
2950 Optional argument FILENAME specifies file name.
2951 Directory to save to is default to `gnus-article-save-directory'."
2952 (setq filename (gnus-read-save-file-name
2953 "Save %s in Unix mail file:" filename
2954 gnus-mail-save-name gnus-newsgroup-name
2955 gnus-current-headers 'gnus-newsgroup-last-mail))
2956 (gnus-eval-in-buffer-window gnus-save-article-buffer
2960 (if (and (file-readable-p filename)
2961 (mail-file-babyl-p filename))
2962 (rmail-output-to-rmail-file filename t)
2963 (gnus-output-to-mail filename)))))
2966 (defun gnus-summary-save-in-file (&optional filename overwrite)
2967 "Append this article to file.
2968 Optional argument FILENAME specifies file name.
2969 Directory to save to is default to `gnus-article-save-directory'."
2970 (setq filename (gnus-read-save-file-name
2971 "Save %s in file:" filename
2972 gnus-file-save-name gnus-newsgroup-name
2973 gnus-current-headers 'gnus-newsgroup-last-file))
2974 (gnus-eval-in-buffer-window gnus-save-article-buffer
2978 (when (and overwrite
2979 (file-exists-p filename))
2980 (delete-file filename))
2981 (gnus-output-to-file filename))))
2984 (defun gnus-summary-write-to-file (&optional filename)
2985 "Write this article to a file, overwriting it if the file exists.
2986 Optional argument FILENAME specifies file name.
2987 The directory to save in defaults to `gnus-article-save-directory'."
2988 (gnus-summary-save-in-file nil t))
2990 (defun gnus-summary-save-body-in-file (&optional filename)
2991 "Append this article body to a file.
2992 Optional argument FILENAME specifies file name.
2993 The directory to save in defaults to `gnus-article-save-directory'."
2994 (setq filename (gnus-read-save-file-name
2995 "Save %s body in file:" filename
2996 gnus-file-save-name gnus-newsgroup-name
2997 gnus-current-headers 'gnus-newsgroup-last-file))
2998 (gnus-eval-in-buffer-window gnus-save-article-buffer
3002 (when (article-goto-body)
3003 (narrow-to-region (point) (point-max)))
3004 (gnus-output-to-file filename))))
3007 (defun gnus-summary-save-in-pipe (&optional command)
3008 "Pipe this article to subprocess."
3010 (cond ((and (eq command 'default)
3011 gnus-last-shell-command)
3012 gnus-last-shell-command)
3017 "Shell command on %s: "
3018 (if (and gnus-number-of-articles-to-be-saved
3019 (> gnus-number-of-articles-to-be-saved 1))
3020 (format "these %d articles"
3021 gnus-number-of-articles-to-be-saved)
3023 gnus-last-shell-command))))
3024 (when (string-equal command "")
3025 (if gnus-last-shell-command
3026 (setq command gnus-last-shell-command)
3027 (error "A command is required")))
3028 (gnus-eval-in-buffer-window gnus-article-buffer
3031 (shell-command-on-region (point-min) (point-max) command nil)))
3032 (setq gnus-last-shell-command command))
3034 (defun gnus-summary-pipe-to-muttprint (&optional command)
3035 "Pipe this article to muttprint."
3036 (setq command (read-string
3037 "Print using command: " gnus-summary-muttprint-program
3038 nil gnus-summary-muttprint-program))
3039 (gnus-summary-save-in-pipe command))
3041 ;;; Article file names when saving.
3043 (defun gnus-capitalize-newsgroup (newsgroup)
3044 "Capitalize NEWSGROUP name."
3045 (when (not (zerop (length newsgroup)))
3046 (concat (char-to-string (upcase (aref newsgroup 0)))
3047 (substring newsgroup 1))))
3049 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3050 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3051 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3052 Otherwise, it is like ~/News/news/group/num."
3055 (concat (if (gnus-use-long-file-name 'not-save)
3056 (gnus-capitalize-newsgroup newsgroup)
3057 (gnus-newsgroup-directory-form newsgroup))
3058 "/" (int-to-string (mail-header-number headers)))
3059 gnus-article-save-directory)))
3061 (string-equal (file-name-directory default)
3062 (file-name-directory last-file))
3063 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3065 (or last-file default))))
3067 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3068 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3069 If variable `gnus-use-long-file-name' is non-nil, it is
3070 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3073 (concat (if (gnus-use-long-file-name 'not-save)
3075 (gnus-newsgroup-directory-form newsgroup))
3076 "/" (int-to-string (mail-header-number headers)))
3077 gnus-article-save-directory)))
3079 (string-equal (file-name-directory default)
3080 (file-name-directory last-file))
3081 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3083 (or last-file default))))
3085 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3086 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3087 If variable `gnus-use-long-file-name' is non-nil, it is
3088 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3091 (if (gnus-use-long-file-name 'not-save)
3094 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3096 gnus-article-save-directory)))
3098 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3099 "Generate file name from sender."
3100 (let ((from (mail-header-from headers)))
3102 (if (and from (string-match "\\([^ <]+\\)@" from))
3103 (match-string 1 from)
3105 gnus-article-save-directory)))
3107 (defun article-verify-x-pgp-sig ()
3110 (if (gnus-buffer-live-p gnus-original-article-buffer)
3111 (let ((sig (with-current-buffer gnus-original-article-buffer
3112 (gnus-fetch-field "X-PGP-Sig")))
3116 (mml2015-clear-verify-function))
3118 (insert-buffer gnus-original-article-buffer)
3119 (setq items (split-string sig))
3120 (message-narrow-to-head)
3121 (let ((inhibit-point-motion-hooks t)
3122 (case-fold-search t))
3123 ;; Don't verify multiple headers.
3124 (setq headers (mapconcat (lambda (header)
3126 (mail-fetch-field header) "\n"))
3127 (split-string (nth 1 items) ",") "")))
3128 (delete-region (point-min) (point-max))
3129 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3130 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3135 (if (looking-at "^-")
3138 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3139 (insert "Version: " (car items) "\n\n")
3140 (insert (mapconcat 'identity (cddr items) "\n"))
3141 (insert "\n-----END PGP SIGNATURE-----\n")
3142 (let ((mm-security-handle (list (format "multipart/signed"))))
3143 (mml2015-clean-buffer)
3144 (let ((coding-system-for-write (or gnus-newsgroup-charset
3146 (funcall (mml2015-clear-verify-function)))
3148 (or (mm-handle-multipart-ctl-parameter
3149 mm-security-handle 'gnus-details)
3150 (mm-handle-multipart-ctl-parameter
3151 mm-security-handle 'gnus-info)))))
3153 (let (buffer-read-only bface eface)
3155 (message-narrow-to-head)
3156 (goto-char (point-max))
3158 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3159 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3160 (message-remove-header "X-Gnus-PGP-Verify")
3161 (if (re-search-forward "^X-PGP-Sig:" nil t)
3163 (goto-char (point-max)))
3164 (narrow-to-region (point) (point))
3165 (insert "X-Gnus-PGP-Verify: " info "\n")
3166 (goto-char (point-min))
3169 (if (not (looking-at "^[ \t]"))
3173 (goto-char (point-min))
3174 (when (looking-at "\\([^:]+\\): *")
3175 (put-text-property (match-beginning 1) (1+ (match-end 1))
3177 (put-text-property (match-end 0) (point-max)
3178 'face eface)))))))))
3180 (defun article-verify-cancel-lock ()
3181 "Verify Cancel-Lock header."
3183 (if (gnus-buffer-live-p gnus-original-article-buffer)
3184 (canlock-verify gnus-original-article-buffer)))
3191 (setq afunc (car func)
3194 gfunc (intern (format "gnus-%s" func))))
3196 (when (fboundp afunc)
3197 `(lambda (&optional interactive &rest args)
3198 ,(documentation afunc t)
3199 (interactive (list t))
3201 (set-buffer gnus-article-buffer)
3203 (call-interactively ',afunc)
3204 (apply ',afunc args))))))))
3205 '(article-hide-headers
3206 article-verify-x-pgp-sig
3207 article-verify-cancel-lock
3208 article-hide-boring-headers
3209 article-treat-overstrike
3210 article-fill-long-lines
3211 article-capitalize-sentences
3213 article-remove-leading-whitespace
3214 article-display-x-face
3215 article-de-quoted-unreadable
3216 article-de-base64-unreadable
3219 article-unsplit-urls
3220 article-hide-list-identifiers
3222 article-strip-banner
3225 article-hide-signature
3226 article-strip-headers-in-body
3227 article-remove-trailing-blank-lines
3228 article-strip-leading-blank-lines
3229 article-strip-multiple-blank-lines
3230 article-strip-leading-space
3231 article-strip-trailing-space
3232 article-strip-blank-lines
3233 article-strip-all-blank-lines
3234 article-replace-with-quoted-text
3236 article-date-english
3237 article-date-iso8601
3238 article-date-original
3240 article-decode-mime-words
3241 article-decode-charset
3242 article-decode-encoded-words
3246 article-treat-dumbquotes
3247 article-normalize-headers
3248 ;; (article-show-all . gnus-article-show-all-headers)
3252 ;;; Gnus article mode
3255 (put 'gnus-article-mode 'mode-class 'special)
3257 (set-keymap-parent gnus-article-mode-map widget-keymap)
3259 (gnus-define-keys gnus-article-mode-map
3260 " " gnus-article-goto-next-page
3261 "\177" gnus-article-goto-prev-page
3262 [delete] gnus-article-goto-prev-page
3263 [backspace] gnus-article-goto-prev-page
3264 "\C-c^" gnus-article-refer-article
3265 "h" gnus-article-show-summary
3266 "s" gnus-article-show-summary
3267 "\C-c\C-m" gnus-article-mail
3268 "?" gnus-article-describe-briefly
3269 "e" gnus-summary-edit-article
3270 "<" beginning-of-buffer
3272 "\C-c\C-i" gnus-info-find-node
3274 "R" gnus-article-reply-with-original
3275 "F" gnus-article-followup-with-original
3276 "\C-hk" gnus-article-describe-key
3277 "\C-hc" gnus-article-describe-key-briefly
3279 "\C-d" gnus-article-read-summary-keys
3280 "\M-*" gnus-article-read-summary-keys
3281 "\M-#" gnus-article-read-summary-keys
3282 "\M-^" gnus-article-read-summary-keys
3283 "\M-g" gnus-article-read-summary-keys)
3285 (substitute-key-definition
3286 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3288 (defun gnus-article-make-menu-bar ()
3289 (unless (boundp 'gnus-article-commands-menu)
3290 (gnus-summary-make-menu-bar))
3291 (gnus-turn-off-edit-menu 'article)
3292 (unless (boundp 'gnus-article-article-menu)
3294 gnus-article-article-menu gnus-article-mode-map ""
3296 ["Scroll forwards" gnus-article-goto-next-page t]
3297 ["Scroll backwards" gnus-article-goto-prev-page t]
3298 ["Show summary" gnus-article-show-summary t]
3299 ["Fetch Message-ID at point" gnus-article-refer-article t]
3300 ["Mail to address at point" gnus-article-mail t]
3301 ["Send a bug report" gnus-bug t]))
3304 gnus-article-treatment-menu gnus-article-mode-map ""
3305 ;; Fixme: this should use :active (and maybe :visible).
3307 ["Hide headers" gnus-article-hide-headers t]
3308 ["Hide signature" gnus-article-hide-signature t]
3309 ["Hide citation" gnus-article-hide-citation t]
3310 ["Treat overstrike" gnus-article-treat-overstrike t]
3311 ["Remove carriage return" gnus-article-remove-cr t]
3312 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3313 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3314 ["Remove base64" gnus-article-de-base64-unreadable t]
3315 ["Treat html" gnus-article-wash-html t]
3316 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3317 ["Decode HZ" gnus-article-decode-HZ t]))
3319 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3321 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3323 (gnus-run-hooks 'gnus-article-menu-hook)))
3325 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3328 (defun gnus-article-mode ()
3329 "Major mode for displaying an article.
3331 All normal editing commands are switched off.
3333 The following commands are available in addition to all summary mode
3335 \\<gnus-article-mode-map>
3336 \\[gnus-article-next-page]\t Scroll the article one page forwards
3337 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3338 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3339 \\[gnus-article-show-summary]\t Display the summary buffer
3340 \\[gnus-article-mail]\t Send a reply to the address near point
3341 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3342 \\[gnus-info-find-node]\t Go to the Gnus info node"
3344 (gnus-simplify-mode-line)
3345 (setq mode-name "Article")
3346 (setq major-mode 'gnus-article-mode)
3347 (make-local-variable 'minor-mode-alist)
3348 (use-local-map gnus-article-mode-map)
3349 (when (gnus-visual-p 'article-menu 'menu)
3350 (gnus-article-make-menu-bar))
3351 (gnus-update-format-specifications nil 'article-mode)
3352 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3353 (make-local-variable 'gnus-page-broken)
3354 (make-local-variable 'gnus-button-marker-list)
3355 (make-local-variable 'gnus-article-current-summary)
3356 (make-local-variable 'gnus-article-mime-handles)
3357 (make-local-variable 'gnus-article-decoded-p)
3358 (make-local-variable 'gnus-article-mime-handle-alist)
3359 (make-local-variable 'gnus-article-wash-types)
3360 (make-local-variable 'gnus-article-image-alist)
3361 (make-local-variable 'gnus-article-charset)
3362 (make-local-variable 'gnus-article-ignored-charsets)
3363 (gnus-set-default-directory)
3364 (buffer-disable-undo)
3365 (setq buffer-read-only t)
3366 (set-syntax-table gnus-article-mode-syntax-table)
3367 (mm-enable-multibyte)
3368 (gnus-run-hooks 'gnus-article-mode-hook))
3370 (defun gnus-article-setup-buffer ()
3371 "Initialize the article buffer."
3372 (let* ((name (if gnus-single-article-buffer "*Article*"
3373 (concat "*Article " gnus-newsgroup-name "*")))
3375 (progn (string-match "\\*Article" name)
3376 (concat " *Original Article"
3377 (substring name (match-end 0))))))
3378 (setq gnus-article-buffer name)
3379 (setq gnus-original-article-buffer original)
3380 (setq gnus-article-mime-handle-alist nil)
3381 ;; This might be a variable local to the summary buffer.
3382 (unless gnus-single-article-buffer
3384 (set-buffer gnus-summary-buffer)
3385 (setq gnus-article-buffer name)
3386 (setq gnus-original-article-buffer original)
3387 (gnus-set-global-variables)))
3388 (gnus-article-setup-highlight-words)
3389 ;; Init original article buffer.
3391 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3392 (mm-enable-multibyte)
3393 (setq major-mode 'gnus-original-article-mode)
3394 (make-local-variable 'gnus-original-article))
3395 (if (get-buffer name)
3398 (when gnus-article-mime-handles
3399 (mm-destroy-parts gnus-article-mime-handles)
3400 (setq gnus-article-mime-handles nil))
3401 ;; Set it to nil in article-buffer!
3402 (setq gnus-article-mime-handle-alist nil)
3403 (buffer-disable-undo)
3404 (setq buffer-read-only t)
3405 (unless (eq major-mode 'gnus-article-mode)
3406 (gnus-article-mode))
3409 (set-buffer (gnus-get-buffer-create name))
3411 (make-local-variable 'gnus-summary-buffer)
3412 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3413 (current-buffer)))))
3415 ;; Set article window start at LINE, where LINE is the number of lines
3416 ;; from the head of the article.
3417 (defun gnus-article-set-window-start (&optional line)
3419 (gnus-get-buffer-window gnus-article-buffer t)
3421 (set-buffer gnus-article-buffer)
3422 (goto-char (point-min))
3425 (gnus-message 6 "Moved to bookmark")
3426 (search-forward "\n\n" nil t)
3430 (defun gnus-article-prepare (article &optional all-headers header)
3431 "Prepare ARTICLE in article mode buffer.
3432 ARTICLE should either be an article number or a Message-ID.
3433 If ARTICLE is an id, HEADER should be the article headers.
3434 If ALL-HEADERS is non-nil, no headers are hidden."
3436 ;; Make sure we start in a summary buffer.
3437 (unless (eq major-mode 'gnus-summary-mode)
3438 (set-buffer gnus-summary-buffer))
3439 (setq gnus-summary-buffer (current-buffer))
3440 (let* ((gnus-article (if header (mail-header-number header) article))
3441 (summary-buffer (current-buffer))
3442 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3443 (group gnus-newsgroup-name)
3446 (gnus-article-setup-buffer)
3447 (set-buffer gnus-article-buffer)
3448 ;; Deactivate active regions.
3449 (when (and (boundp 'transient-mark-mode)
3450 transient-mark-mode)
3451 (setq mark-active nil))
3452 (if (not (setq result (let ((buffer-read-only nil))
3453 (gnus-request-article-this-buffer
3455 ;; There is no such article.
3457 (when (and (numberp article)
3458 (not (memq article gnus-newsgroup-sparse)))
3459 (setq gnus-article-current
3460 (cons gnus-newsgroup-name article))
3461 (set-buffer gnus-summary-buffer)
3462 (setq gnus-current-article article)
3463 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3465 (gnus-summary-set-agent-mark article)
3466 (message "Message marked for downloading"))
3467 (gnus-summary-mark-article article gnus-canceled-mark)
3468 (unless (memq article gnus-newsgroup-sparse)
3469 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3470 (if (or (eq result 'pseudo)
3471 (eq result 'nneething))
3474 (set-buffer summary-buffer)
3475 (push article gnus-newsgroup-history)
3476 (setq gnus-last-article gnus-current-article
3477 gnus-current-article 0
3478 gnus-current-headers nil
3479 gnus-article-current nil)
3480 (if (eq result 'nneething)
3481 (gnus-configure-windows 'summary)
3482 (gnus-configure-windows 'article))
3483 (gnus-set-global-variables))
3484 (let ((gnus-article-mime-handle-alist-1
3485 gnus-article-mime-handle-alist))
3486 (gnus-set-mode-line 'article)))
3487 ;; The result from the `request' was an actual article -
3488 ;; or at least some text that is now displayed in the
3490 (when (and (numberp article)
3491 (not (eq article gnus-current-article)))
3492 ;; Seems like a new article has been selected.
3493 ;; `gnus-current-article' must be an article number.
3495 (set-buffer summary-buffer)
3496 (push article gnus-newsgroup-history)
3497 (setq gnus-last-article gnus-current-article
3498 gnus-current-article article
3499 gnus-current-headers
3500 (gnus-summary-article-header gnus-current-article)
3501 gnus-article-current
3502 (cons gnus-newsgroup-name gnus-current-article))
3503 (unless (vectorp gnus-current-headers)
3504 (setq gnus-current-headers nil))
3505 (gnus-summary-goto-subject gnus-current-article)
3506 (when (gnus-summary-show-thread)
3507 ;; If the summary buffer really was folded, the
3508 ;; previous goto may not actually have gone to
3509 ;; the right article, but the thread root instead.
3511 (gnus-summary-goto-subject gnus-current-article))
3512 (gnus-run-hooks 'gnus-mark-article-hook)
3513 (gnus-set-mode-line 'summary)
3514 (when (gnus-visual-p 'article-highlight 'highlight)
3515 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3516 ;; Set the global newsgroup variables here.
3517 (gnus-set-global-variables)
3518 (setq gnus-have-all-headers
3519 (or all-headers gnus-show-all-headers))))
3521 (gnus-configure-windows 'article))
3522 (when (or (numberp article)
3524 (gnus-article-prepare-display)
3526 (goto-char (point-min))
3527 (setq gnus-page-broken
3528 (when gnus-break-pages
3529 (gnus-narrow-to-page)
3531 (let ((gnus-article-mime-handle-alist-1
3532 gnus-article-mime-handle-alist))
3533 (gnus-set-mode-line 'article))
3535 (set-window-point (get-buffer-window (current-buffer)) (point))
3536 (gnus-configure-windows 'article)
3540 (defun gnus-article-prepare-display ()
3541 "Make the current buffer look like a nice article."
3542 ;; Hooks for getting information from the article.
3543 ;; This hook must be called before being narrowed.
3544 (let ((gnus-article-buffer (current-buffer))
3546 (unless (eq major-mode 'gnus-article-mode)
3547 (gnus-article-mode))
3548 (setq buffer-read-only nil
3549 gnus-article-wash-types nil
3550 gnus-article-image-alist nil)
3551 (gnus-run-hooks 'gnus-tmp-internal-hook)
3552 (when gnus-display-mime-function
3553 (funcall gnus-display-mime-function))
3554 (gnus-run-hooks 'gnus-article-prepare-hook)))
3557 ;;; Gnus MIME viewing functions
3560 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3561 "Format of the MIME buttons.
3563 Valid specifiers include:
3565 %T MIME type, along with additional info
3566 %n The `name' parameter
3567 %d The description, if any
3568 %l The length of the encoded part
3569 %p The part identifier number
3570 %e Dots if the part isn't displayed
3572 General format specifiers can also be used. See
3573 (gnus)Formatting Variables.")
3575 (defvar gnus-mime-button-line-format-alist
3576 '((?t gnus-tmp-type ?s)
3577 (?T gnus-tmp-type-long ?s)
3578 (?n gnus-tmp-name ?s)
3579 (?d gnus-tmp-description ?s)
3581 (?l gnus-tmp-length ?d)
3582 (?e gnus-tmp-dots ?s)))
3584 (defvar gnus-mime-button-commands
3585 '((gnus-article-press-button "\r" "Toggle Display")
3586 (gnus-mime-view-part "v" "View Interactively...")
3587 (gnus-mime-view-part-as-type "t" "View As Type...")
3588 (gnus-mime-view-part-as-charset "C" "View As charset...")
3589 (gnus-mime-save-part "o" "Save...")
3590 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3591 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3592 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3593 (gnus-mime-view-part-internally "E" "View Internally")
3594 (gnus-mime-view-part-externally "e" "View Externally")
3595 (gnus-mime-print-part "p" "Print")
3596 (gnus-mime-pipe-part "|" "Pipe To Command...")
3597 (gnus-mime-action-on-part "." "Take action on the part")))
3599 (defun gnus-article-mime-part-status ()
3600 (if gnus-article-mime-handle-alist-1
3601 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3603 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3606 (defvar gnus-mime-button-map
3607 (let ((map (make-sparse-keymap)))
3608 (unless (>= (string-to-number emacs-version) 21)
3609 ;; XEmacs doesn't care.
3610 (set-keymap-parent map gnus-article-mode-map))
3611 (define-key map gnus-mouse-2 'gnus-article-push-button)
3612 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3613 (dolist (c gnus-mime-button-commands)
3614 (define-key map (cadr c) (car c)))
3617 (defun gnus-mime-button-menu (event)
3618 "Construct a context-sensitive menu of MIME commands."
3620 (save-window-excursion
3621 (let ((pos (event-start event)))
3622 (select-window (posn-window pos))
3623 (goto-char (posn-point pos))
3624 (gnus-article-check-buffer)
3625 (let ((response (x-popup-menu
3627 ("" ,@(mapcar (lambda (c)
3628 (cons (caddr c) (car c)))
3629 gnus-mime-button-commands))))))
3631 (call-interactively response))))))
3633 (defun gnus-mime-view-all-parts (&optional handles)
3634 "View all the MIME parts."
3636 (save-current-buffer
3637 (set-buffer gnus-article-buffer)
3638 (let ((handles (or handles gnus-article-mime-handles))
3639 (mail-parse-charset gnus-newsgroup-charset)
3640 (mail-parse-ignored-charsets
3641 (with-current-buffer gnus-summary-buffer
3642 gnus-newsgroup-ignored-charsets)))
3644 (mm-remove-parts handles)
3645 (goto-char (point-min))
3646 (or (search-forward "\n\n") (goto-char (point-max)))
3647 (let (buffer-read-only)
3648 (delete-region (point) (point-max))
3649 (mm-display-parts handles))))))
3651 (defun gnus-mime-save-part-and-strip ()
3652 "Save the MIME part under point then replace it with an external body."
3654 (gnus-article-check-buffer)
3655 (let* ((data (get-text-property (point) 'gnus-data))
3657 (handles gnus-article-mime-handles))
3658 (if (mm-multiple-handles gnus-article-mime-handles)
3659 (error "This function is not implemented"))
3660 (setq file (and data (mm-save-part data)))
3662 (with-current-buffer (mm-handle-buffer data)
3664 (insert "Content-Type: " (mm-handle-media-type data))
3665 (mml-insert-parameter-string (cdr (mm-handle-type data))
3668 (insert "Content-ID: " (message-make-message-id) "\n")
3669 (insert "Content-Transfer-Encoding: binary\n")
3672 (cdr (mm-make-handle nil
3673 `("message/external-body"
3674 (access-type . "LOCAL-FILE")
3676 (set-buffer gnus-summary-buffer)
3677 (gnus-article-edit-article
3680 (let ((mail-parse-charset (or gnus-article-charset
3681 ',gnus-newsgroup-charset))
3682 (mail-parse-ignored-charsets
3683 (or gnus-article-ignored-charsets
3684 ',gnus-newsgroup-ignored-charsets))
3685 (mbl mml-buffer-list))
3686 (setq mml-buffer-list nil)
3687 (insert-buffer gnus-original-article-buffer)
3688 (mime-to-mml ',handles)
3689 (setq gnus-article-mime-handles nil)
3690 (let ((mbl1 mml-buffer-list))
3691 (setq mml-buffer-list mbl)
3692 (set (make-local-variable 'mml-buffer-list) mbl1))
3693 ;; LOCAL argument of add-hook differs between GNU Emacs
3694 ;; and XEmacs. make-local-hook makes sure they are local.
3695 (make-local-hook 'kill-buffer-hook)
3696 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3697 `(lambda (no-highlight)
3698 (let ((mail-parse-charset (or gnus-article-charset
3699 ',gnus-newsgroup-charset))
3700 (message-options message-options)
3701 (message-options-set-recipient)
3702 (mail-parse-ignored-charsets
3703 (or gnus-article-ignored-charsets
3704 ',gnus-newsgroup-ignored-charsets)))
3706 (mml-destroy-buffers)
3707 (remove-hook 'kill-buffer-hook
3708 'mml-destroy-buffers t)
3709 (kill-local-variable 'mml-buffer-list))
3710 (gnus-summary-edit-article-done
3711 ,(or (mail-header-references gnus-current-headers) "")
3712 ,(gnus-group-read-only-p)
3713 ,gnus-summary-buffer no-highlight))))))
3715 (defun gnus-mime-save-part ()
3716 "Save the MIME part under point."
3718 (gnus-article-check-buffer)
3719 (let ((data (get-text-property (point) 'gnus-data)))
3721 (mm-save-part data))))
3723 (defun gnus-mime-pipe-part ()
3724 "Pipe the MIME part under point to a process."
3726 (gnus-article-check-buffer)
3727 (let ((data (get-text-property (point) 'gnus-data)))
3729 (mm-pipe-part data))))
3731 (defun gnus-mime-view-part ()
3732 "Interactively choose a viewing method for the MIME part under point."
3734 (gnus-article-check-buffer)
3735 (let ((data (get-text-property (point) 'gnus-data)))
3737 (setq gnus-article-mime-handles
3739 gnus-article-mime-handles (setq data (copy-sequence data))))
3740 (mm-interactively-view-part data))))
3742 (defun gnus-mime-view-part-as-type-internal ()
3743 (gnus-article-check-buffer)
3744 (let* ((name (mail-content-type-get
3745 (mm-handle-type (get-text-property (point) 'gnus-data))
3747 (def-type (and name (mm-default-file-encoding name))))
3748 (and def-type (cons def-type 0))))
3750 (defun gnus-mime-view-part-as-type (&optional mime-type)
3751 "Choose a MIME media type, and view the part as such."
3754 (setq mime-type (completing-read
3755 "View as MIME type: "
3756 (mapcar #'list (mailcap-mime-types))
3758 (gnus-mime-view-part-as-type-internal))))
3759 (gnus-article-check-buffer)
3760 (let ((handle (get-text-property (point) 'gnus-data)))
3763 (mm-make-handle (mm-handle-buffer handle)
3764 (cons mime-type (cdr (mm-handle-type handle)))
3765 (mm-handle-encoding handle)
3766 (mm-handle-undisplayer handle)
3767 (mm-handle-disposition handle)
3768 (mm-handle-description handle)
3770 (mm-handle-id handle)))
3771 (setq gnus-article-mime-handles
3772 (mm-merge-handles gnus-article-mime-handles handle))
3773 (gnus-mm-display-part handle))))
3775 (defun gnus-mime-copy-part (&optional handle)
3776 "Put the MIME part under point into a new buffer."
3778 (gnus-article-check-buffer)
3779 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3780 (contents (and handle (mm-get-part handle)))
3782 (file-name-nondirectory
3784 (mail-content-type-get (mm-handle-type handle) 'name)
3785 (mail-content-type-get (mm-handle-type handle)
3788 (buffer (and base (generate-new-buffer base))))
3790 (switch-to-buffer buffer)
3792 ;; We do it this way to make `normal-mode' set the appropriate mode.
3795 (setq buffer-file-name (expand-file-name base))
3797 (setq buffer-file-name nil))
3798 (goto-char (point-min)))))
3800 (defun gnus-mime-print-part (&optional handle filename)
3801 "Print the MIME part under point."
3802 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3803 (gnus-article-check-buffer)
3804 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3805 (contents (and handle (mm-get-part handle)))
3806 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3807 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3812 (with-temp-file file
3814 (call-process shell-file-name nil
3815 (generate-new-buffer " *mm*")
3817 shell-command-switch
3819 printer file (mm-handle-type handle))))
3823 (gnus-print-buffer))
3824 (ps-despool filename)))))
3826 (defun gnus-mime-inline-part (&optional handle arg)
3827 "Insert the MIME part under point into the current buffer."
3828 (interactive (list nil current-prefix-arg))
3829 (gnus-article-check-buffer)
3830 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3835 (if (and (not arg) (mm-handle-undisplayer handle))
3836 (mm-remove-part handle)
3837 (setq contents (mm-get-part handle))
3840 (setq charset (or (mail-content-type-get
3841 (mm-handle-type handle) 'charset)
3842 gnus-newsgroup-charset)))
3844 (if (mm-handle-undisplayer handle)
3845 (mm-remove-part handle))
3848 gnus-summary-show-article-charset-alist))
3849 (mm-read-coding-system "Charset: ")))))
3851 (mm-insert-inline handle
3853 (setq charset (mm-charset-to-coding-system
3855 (not (eq charset 'ascii)))
3856 (mm-decode-coding-string contents charset)
3860 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3861 "Insert the MIME part under point into the current buffer using the
3863 (interactive (list nil current-prefix-arg))
3864 (gnus-article-check-buffer)
3865 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3870 (if (mm-handle-undisplayer handle)
3871 (mm-remove-part handle))
3872 (let ((gnus-newsgroup-charset
3874 gnus-summary-show-article-charset-alist))
3875 (mm-read-coding-system "Charset: ")))
3876 (gnus-newsgroup-ignored-charsets 'gnus-all))
3877 (gnus-article-press-button)))))
3879 (defun gnus-mime-view-part-externally (&optional handle)
3880 "View the MIME part under point with an external viewer."
3882 (gnus-article-check-buffer)
3883 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3884 (mm-user-display-methods nil)
3885 (mm-inlined-types nil)
3886 (mail-parse-charset gnus-newsgroup-charset)
3887 (mail-parse-ignored-charsets
3888 (save-excursion (set-buffer gnus-summary-buffer)
3889 gnus-newsgroup-ignored-charsets)))
3891 (if (mm-handle-undisplayer handle)
3892 (mm-remove-part handle)
3893 (mm-display-part handle)))))
3895 (defun gnus-mime-view-part-internally (&optional handle)
3896 "View the MIME part under point with an internal viewer.
3897 If no internal viewer is available, use an external viewer."
3899 (gnus-article-check-buffer)
3900 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3901 (mm-inlined-types '(".*"))
3902 (mm-inline-large-images t)
3903 (mail-parse-charset gnus-newsgroup-charset)
3904 (mail-parse-ignored-charsets
3905 (save-excursion (set-buffer gnus-summary-buffer)
3906 gnus-newsgroup-ignored-charsets)))
3908 (if (mm-handle-undisplayer handle)
3909 (mm-remove-part handle)
3910 (mm-display-part handle)))))
3912 (defun gnus-mime-action-on-part (&optional action)
3913 "Do something with the MIME attachment at \(point\)."
3915 (list (completing-read "Action: " gnus-mime-action-alist)))
3916 (gnus-article-check-buffer)
3917 (let ((action-pair (assoc action gnus-mime-action-alist)))
3919 (funcall (cdr action-pair)))))
3921 (defun gnus-article-part-wrapper (n function)
3922 (save-current-buffer
3923 (set-buffer gnus-article-buffer)
3924 (when (> n (length gnus-article-mime-handle-alist))
3925 (error "No such part"))
3926 (gnus-article-goto-part n)
3927 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3928 (funcall function handle))))
3930 (defun gnus-article-pipe-part (n)
3931 "Pipe MIME part N, which is the numerical prefix."
3933 (gnus-article-part-wrapper n 'mm-pipe-part))
3935 (defun gnus-article-save-part (n)
3936 "Save MIME part N, which is the numerical prefix."
3938 (gnus-article-part-wrapper n 'mm-save-part))
3940 (defun gnus-article-interactively-view-part (n)
3941 "View MIME part N interactively, which is the numerical prefix."
3943 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3945 (defun gnus-article-copy-part (n)
3946 "Copy MIME part N, which is the numerical prefix."
3948 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3950 (defun gnus-article-view-part-as-charset (n)
3951 "Copy MIME part N, which is the numerical prefix."
3953 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3955 (defun gnus-article-view-part-externally (n)
3956 "View MIME part N externally, which is the numerical prefix."
3958 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
3960 (defun gnus-article-inline-part (n)
3961 "Inline MIME part N, which is the numerical prefix."
3963 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3965 (defun gnus-article-mime-match-handle-first (condition)
3967 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3968 (while (setq ihandle (pop alist))
3970 ((functionp condition)
3971 (funcall condition (cdr ihandle)))
3972 ((eq condition 'undisplayed)
3973 (not (or (mm-handle-undisplayer (cdr ihandle))
3974 (equal (mm-handle-media-type (cdr ihandle))
3975 "multipart/alternative"))))
3976 ((eq condition 'undisplayed-alternative)
3977 (not (mm-handle-undisplayer (cdr ihandle))))
3979 (gnus-article-goto-part (car ihandle))
3980 (or (not n) (< (car ihandle) n)))
3981 (setq n (car ihandle))))
3985 (defun gnus-article-view-part (&optional n)
3986 "View MIME part N, which is the numerical prefix."
3988 (save-current-buffer
3989 (set-buffer gnus-article-buffer)
3990 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3991 gnus-article-mime-match-handle-function)))
3992 (when (> n (length gnus-article-mime-handle-alist))
3993 (error "No such part"))
3994 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3995 (when (gnus-article-goto-part n)
3996 (if (equal (car handle) "multipart/alternative")
3997 (gnus-article-press-button)
3998 (when (eq (gnus-mm-display-part handle) 'internal)
3999 (gnus-set-window-start)))))))
4001 (defsubst gnus-article-mime-total-parts ()
4002 (if (bufferp (car gnus-article-mime-handles))
4004 (1- (length gnus-article-mime-handles))))
4006 (defun gnus-mm-display-part (handle)
4007 "Display HANDLE and fix MIME button."
4008 (let ((id (get-text-property (point) 'gnus-part))
4013 (let ((window (selected-window))
4014 (mail-parse-charset gnus-newsgroup-charset)
4015 (mail-parse-ignored-charsets
4016 (if (gnus-buffer-live-p gnus-summary-buffer)
4018 (set-buffer gnus-summary-buffer)
4019 gnus-newsgroup-ignored-charsets)
4023 (let ((win (gnus-get-buffer-window (current-buffer) t))
4026 (select-window win))
4029 (if (mm-handle-displayed-p handle)
4030 ;; This will remove the part.
4031 (mm-display-part handle)
4033 (narrow-to-region (point)
4034 (if (eobp) (point) (1+ (point))))
4035 (mm-display-part handle)
4036 ;; We narrow to the part itself and
4037 ;; then call the treatment functions.
4038 (goto-char (point-min))
4040 (narrow-to-region (point) (point-max))
4043 (gnus-article-mime-total-parts)
4044 (mm-handle-media-type handle)))))
4045 (if (window-live-p window)
4046 (select-window window)))))
4048 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4049 (gnus-insert-mime-button
4050 handle id (list (mm-handle-displayed-p handle)))
4051 (goto-char point))))
4053 (defun gnus-article-goto-part (n)
4054 "Go to MIME part N."
4055 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4057 (goto-char point))))
4059 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4060 (let ((gnus-tmp-name
4061 (or (mail-content-type-get (mm-handle-type handle) 'name)
4062 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4063 (mail-content-type-get (mm-handle-type handle) 'url)
4065 (gnus-tmp-type (mm-handle-media-type handle))
4066 (gnus-tmp-description
4067 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4070 (if (if displayed (car displayed)
4071 (mm-handle-displayed-p handle))
4073 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4075 gnus-tmp-type-long b e)
4076 (when (string-match ".*/" gnus-tmp-name)
4077 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4078 (setq gnus-tmp-type-long (concat gnus-tmp-type
4079 (and (not (equal gnus-tmp-name ""))
4080 (concat "; " gnus-tmp-name))))
4081 (unless (equal gnus-tmp-description "")
4082 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4087 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4088 `(,@(gnus-local-map-property gnus-mime-button-map)
4089 gnus-callback gnus-mm-display-part
4090 gnus-part ,gnus-tmp-id
4091 article-type annotation
4094 (widget-convert-button
4097 :action 'gnus-widget-press-button
4098 :button-keymap gnus-mime-button-map
4100 (lambda (widget/window &optional overlay pos)
4101 ;; Needed to properly clear the message due to a bug in
4102 ;; wid-edit (XEmacs only).
4103 (if (boundp 'help-echo-owns-message)
4104 (setq help-echo-owns-message t))
4106 "%S: %s the MIME part; %S: more options"
4107 (aref gnus-mouse-2 0)
4108 ;; XEmacs will get a single widget arg; Emacs 21 will get
4109 ;; window, overlay, position.
4110 (if (mm-handle-displayed-p
4112 (with-current-buffer (gnus-overlay-buffer overlay)
4113 (widget-get (widget-at (gnus-overlay-start overlay))
4115 (widget-get widget/window :mime-handle)))
4117 (aref gnus-down-mouse-3 0))))))
4119 (defun gnus-widget-press-button (elems el)
4120 (goto-char (widget-get elems :from))
4121 (gnus-article-press-button))
4123 (defvar gnus-displaying-mime nil)
4125 (defun gnus-display-mime (&optional ihandles)
4126 "Display the MIME parts."
4128 (save-selected-window
4129 (let ((window (get-buffer-window gnus-article-buffer))
4132 (select-window window)
4133 ;; We have to do this since selecting the window
4134 ;; may change the point. So we set the window point.
4135 (set-window-point window point)))
4136 (let* ((handles (or ihandles (mm-dissect-buffer
4137 nil gnus-article-loose-mime)
4139 buffer-read-only handle name type b e display)
4140 (when (and (not ihandles)
4141 (not gnus-displaying-mime))
4142 ;; Top-level call; we clean up.
4143 (when gnus-article-mime-handles
4144 (mm-destroy-parts gnus-article-mime-handles)
4145 (setq gnus-article-mime-handle-alist nil));; A trick.
4146 (setq gnus-article-mime-handles handles)
4147 ;; We allow users to glean info from the handles.
4148 (when gnus-article-mime-part-function
4149 (gnus-mime-part-function handles)))
4151 (or (not (stringp (car handles)))
4154 (when (and (not ihandles)
4155 (not gnus-displaying-mime))
4156 ;; Clean up for mime parts.
4158 (delete-region (point) (point-max)))
4159 (let ((gnus-displaying-mime t))
4160 (gnus-mime-display-part handles)))
4163 (narrow-to-region (point) (point-max))
4164 (gnus-treat-article nil 1 1)
4167 ;; Highlight the headers.
4171 (narrow-to-region (point-min) (point))
4172 (gnus-treat-article 'head))))))))
4174 (defvar gnus-mime-display-multipart-as-mixed nil)
4175 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4176 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4178 (defun gnus-mime-display-part (handle)
4181 ((not (stringp (car handle)))
4182 (gnus-mime-display-single handle))
4183 ;; User-defined multipart
4184 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4185 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4187 ;; multipart/alternative
4188 ((and (equal (car handle) "multipart/alternative")
4189 (not (or gnus-mime-display-multipart-as-mixed
4190 gnus-mime-display-multipart-alternative-as-mixed)))
4191 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4192 (push (cons id handle) gnus-article-mime-handle-alist)
4193 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4194 ;; multipart/related
4195 ((and (equal (car handle) "multipart/related")
4196 (not (or gnus-mime-display-multipart-as-mixed
4197 gnus-mime-display-multipart-related-as-mixed)))
4198 ;;;!!!We should find the start part, but we just default
4199 ;;;!!!to the first part.
4200 ;;(gnus-mime-display-part (cadr handle))
4201 ;;;!!! Most multipart/related is an HTML message plus images.
4202 ;;;!!! Unfortunately we are unable to let W3 display those
4203 ;;;!!! included images, so we just display it as a mixed multipart.
4204 ;;(gnus-mime-display-mixed (cdr handle))
4205 ;;;!!! No, w3 can display everything just fine.
4206 (gnus-mime-display-part (cadr handle)))
4207 ((equal (car handle) "multipart/signed")
4208 (gnus-add-wash-type 'signed)
4209 (gnus-mime-display-security handle))
4210 ((equal (car handle) "multipart/encrypted")
4211 (gnus-add-wash-type 'encrypted)
4212 (gnus-mime-display-security handle))
4213 ;; Other multiparts are handled like multipart/mixed.
4215 (gnus-mime-display-mixed (cdr handle)))))
4217 (defun gnus-mime-part-function (handles)
4218 (if (stringp (car handles))
4219 (mapcar 'gnus-mime-part-function (cdr handles))
4220 (funcall gnus-article-mime-part-function handles)))
4222 (defun gnus-mime-display-mixed (handles)
4223 (mapcar 'gnus-mime-display-part handles))
4225 (defun gnus-mime-display-single (handle)
4226 (let ((type (mm-handle-media-type handle))
4227 (ignored gnus-ignored-mime-types)
4234 (when (string-match (pop ignored) type)
4235 (throw 'ignored nil)))
4236 (if (and (setq not-attachment
4237 (and (not (mm-inline-override-p handle))
4238 (or (not (mm-handle-disposition handle))
4239 (equal (car (mm-handle-disposition handle))
4241 (mm-attachment-override-p handle))))
4242 (mm-automatic-display-p handle)
4244 (mm-inlinable-p handle)
4245 (mm-inlined-p handle))
4246 (mm-automatic-external-display-p type)))
4248 (when (equal (mm-handle-media-supertype handle) "text")
4250 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4252 (push (cons id handle) gnus-article-mime-handle-alist)
4253 (when (or (not display)
4254 (not (gnus-unbuttonized-mime-type-p type)))
4255 ;(gnus-article-insert-newline)
4256 (gnus-insert-mime-button
4257 handle id (list (or display (and not-attachment text))))
4258 (gnus-article-insert-newline)
4259 ;(gnus-article-insert-newline)
4260 ;; Remember modify the number of forward lines.
4268 (let ((mail-parse-charset gnus-newsgroup-charset)
4269 (mail-parse-ignored-charsets
4270 (save-excursion (condition-case ()
4271 (set-buffer gnus-summary-buffer)
4273 gnus-newsgroup-ignored-charsets)))
4274 (mm-display-part handle t))
4275 (goto-char (point-max)))
4276 ((and text not-attachment)
4280 (gnus-article-insert-newline)
4281 (mm-insert-inline handle (mm-get-part handle))
4282 (goto-char (point-max))))
4286 (narrow-to-region beg (point))
4289 (gnus-article-mime-total-parts)
4290 (mm-handle-media-type handle)))))))))
4292 (defun gnus-unbuttonized-mime-type-p (type)
4293 "Say whether TYPE is to be unbuttonized."
4294 (unless gnus-inhibit-mime-unbuttonizing
4296 (let ((types gnus-unbuttonized-mime-types))
4298 (when (string-match (pop types) type)
4299 (throw 'found t)))))
4301 (let ((types gnus-buttonized-mime-types))
4303 (when (string-match (pop types) type)
4304 (throw 'found t)))))))))
4306 (defun gnus-article-insert-newline ()
4307 "Insert a newline, but mark it as undeletable."
4308 (gnus-put-text-property
4309 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4311 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4312 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4315 handle buffer-read-only from props begend not-pref)
4316 (save-window-excursion
4319 (narrow-to-region (car ibegend)
4322 (goto-char (car ibegend))
4325 (delete-region (point-min) (point-max))
4326 (mm-remove-parts handles))
4327 (setq begend (list (point-marker)))
4329 (unless (setq not-pref (cadr (member preferred ihandles)))
4330 (setq not-pref (car ihandles)))
4333 (not (gnus-unbuttonized-mime-type-p
4334 "multipart/alternative")))
4335 (gnus-add-text-properties
4338 (insert (format "%d. " id))
4342 (unless ,(not ibegend)
4343 (setq gnus-article-mime-handle-alist
4344 ',gnus-article-mime-handle-alist))
4345 (gnus-mime-display-alternative
4346 ',ihandles ',not-pref ',begend ,id))
4347 ,@(gnus-local-map-property gnus-mime-button-map)
4348 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4349 face ,gnus-article-button-face
4352 (widget-convert-button 'link from (point)
4353 :action 'gnus-widget-press-button
4354 :button-keymap gnus-widget-button-keymap)
4356 (while (setq handle (pop handles))
4357 (gnus-add-text-properties
4360 (insert (format "(%c) %-18s"
4361 (if (equal handle preferred) ?* ? )
4362 (mm-handle-media-type handle)))
4366 (unless ,(not ibegend)
4367 (setq gnus-article-mime-handle-alist
4368 ',gnus-article-mime-handle-alist))
4369 (gnus-mime-display-alternative
4370 ',ihandles ',handle ',begend ,id))
4371 ,@(gnus-local-map-property gnus-mime-button-map)
4372 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4373 face ,gnus-article-button-face
4376 (widget-convert-button 'link from (point)
4377 :action 'gnus-widget-press-button
4378 :button-keymap gnus-widget-button-keymap)
4382 (if (stringp (car preferred))
4383 (gnus-display-mime preferred)
4384 (let ((mail-parse-charset gnus-newsgroup-charset)
4385 (mail-parse-ignored-charsets
4386 (save-excursion (set-buffer gnus-summary-buffer)
4387 gnus-newsgroup-ignored-charsets)))
4388 (mm-display-part preferred)
4392 (narrow-to-region (car begend) (point-max))
4394 nil (length gnus-article-mime-handle-alist)
4395 (gnus-article-mime-total-parts)
4396 (mm-handle-media-type handle))))))
4397 (goto-char (point-max))
4398 (setcdr begend (point-marker)))))
4400 (goto-char point))))
4402 (defconst gnus-article-wash-status-strings
4403 (let ((alist '((cite "c" "Possible hidden citation text"
4404 " " "All citation text visible")
4405 (headers "h" "Hidden headers"
4406 " " "All headers visible.")
4407 (pgp "p" "Encrypted or signed message status hidden"
4408 " " "No hidden encryption nor digital signature status")
4409 (signature "s" "Signature has been hidden"
4410 " " "Signature is visible")
4411 (overstrike "o" "Overstrike (^H) characters applied"
4412 " " "No overstrike characters applied")
4413 (emphasis "e" "/*_Emphasis_*/ characters applied"
4414 " " "No /*_emphasis_*/ characters applied")))
4416 (dolist (entry alist result)
4417 (let ((key (nth 0 entry))
4418 (on (copy-sequence (nth 1 entry)))
4419 (on-help (nth 2 entry))
4420 (off (copy-sequence (nth 3 entry)))
4421 (off-help (nth 4 entry)))
4422 (put-text-property 0 1 'help-echo on-help on)
4423 (put-text-property 0 1 'help-echo off-help off)
4424 (push (list key on off) result))))
4425 "Alist of strings describing wash status in the mode line.
4426 Each entry has the form (KEY ON OF), where the KEY is a symbol
4427 representing the particular washing function, ON is the string to use
4428 in the article mode line when the washing function is active, and OFF
4429 is the string to use when it is inactive.")
4431 (defun gnus-article-wash-status-entry (key value)
4432 (let ((entry (assoc key gnus-article-wash-status-strings)))
4433 (if value (nth 1 entry) (nth 2 entry))))
4435 (defun gnus-article-wash-status ()
4436 "Return a string which display status of article washing."
4438 (set-buffer gnus-article-buffer)
4439 (let ((cite (memq 'cite gnus-article-wash-types))
4440 (headers (memq 'headers gnus-article-wash-types))
4441 (boring (memq 'boring-headers gnus-article-wash-types))
4442 (pgp (memq 'pgp gnus-article-wash-types))
4443 (pem (memq 'pem gnus-article-wash-types))
4444 (signed (memq 'signed gnus-article-wash-types))
4445 (encrypted (memq 'encrypted gnus-article-wash-types))
4446 (signature (memq 'signature gnus-article-wash-types))
4447 (overstrike (memq 'overstrike gnus-article-wash-types))
4448 (emphasis (memq 'emphasis gnus-article-wash-types)))
4450 (gnus-article-wash-status-entry 'cite cite)
4451 (gnus-article-wash-status-entry 'headers (or headers boring))
4452 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4453 (gnus-article-wash-status-entry 'signature signature)
4454 (gnus-article-wash-status-entry 'overstrike overstrike)
4455 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4457 (defun gnus-add-wash-type (type)
4458 "Add a washing of TYPE to the current status."
4459 (add-to-list 'gnus-article-wash-types type))
4461 (defun gnus-delete-wash-type (type)
4462 "Add a washing of TYPE to the current status."
4463 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4465 (defun gnus-add-image (category image)
4466 "Add IMAGE of CATEGORY to the list of displayed images."
4467 (let ((entry (assq category gnus-article-image-alist)))
4469 (setq entry (list category))
4470 (push entry gnus-article-image-alist))
4471 (nconc entry (list image))))
4473 (defun gnus-delete-images (category)
4474 "Delete all images in CATEGORY."
4475 (let ((entry (assq category gnus-article-image-alist)))
4476 (dolist (image (cdr entry))
4477 (gnus-remove-image image))
4478 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4479 (gnus-delete-wash-type category)))
4481 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4483 (defun gnus-article-maybe-hide-headers ()
4484 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4485 Provided for backwards compatibility."
4486 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4487 (not (save-excursion (set-buffer gnus-summary-buffer)
4488 gnus-have-all-headers)))
4489 (not gnus-inhibit-hiding))
4490 (gnus-article-hide-headers)))
4494 (defun gnus-output-to-file (file-name)
4495 "Append the current article to a file named FILE-NAME."
4496 (let ((artbuf (current-buffer)))
4498 (insert-buffer-substring artbuf)
4499 ;; Append newline at end of the buffer as separator, and then
4501 (goto-char (point-max))
4503 (let ((file-name-coding-system nnmail-pathname-coding-system))
4504 (mm-append-to-file (point-min) (point-max) file-name))
4507 (defun gnus-narrow-to-page (&optional arg)
4508 "Narrow the article buffer to a page.
4509 If given a numerical ARG, move forward ARG pages."
4511 (setq arg (if arg (prefix-numeric-value arg) 0))
4513 (set-buffer gnus-article-buffer)
4514 (goto-char (point-min))
4516 ;; Remove any old next/prev buttons.
4517 (when (gnus-visual-p 'page-marker)
4518 (let ((buffer-read-only nil))
4519 (gnus-remove-text-with-property 'gnus-prev)
4520 (gnus-remove-text-with-property 'gnus-next)))
4523 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4525 (re-search-forward page-delimiter nil 'move arg)))
4526 (goto-char (match-end 0)))
4529 (if (re-search-forward page-delimiter nil 'move)
4532 (when (and (gnus-visual-p 'page-marker)
4533 (not (= (point-min) 1)))
4535 (goto-char (point-min))
4536 (gnus-insert-prev-page-button)))
4537 (when (and (gnus-visual-p 'page-marker)
4538 (< (+ (point-max) 2) (buffer-size)))
4540 (goto-char (point-max))
4541 (gnus-insert-next-page-button)))))
4543 ;; Article mode commands
4545 (defun gnus-article-goto-next-page ()
4546 "Show the next page of the article."
4548 (when (gnus-article-next-page)
4549 (goto-char (point-min))
4550 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4552 (defun gnus-article-goto-prev-page ()
4553 "Show the next page of the article."
4555 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4556 (gnus-article-prev-page nil)))
4558 (defun gnus-article-next-page (&optional lines)
4559 "Show the next page of the current article.
4560 If end of article, return non-nil. Otherwise return nil.
4561 Argument LINES specifies lines to be scrolled up."
4563 (move-to-window-line -1)
4566 (and (pos-visible-in-window-p) ;Not continuation line.
4568 ;; Nothing in this page.
4569 (if (or (not gnus-page-broken)
4572 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4574 (gnus-narrow-to-page 1) ;Go to next page.
4576 ;; More in this page.
4577 (let ((scroll-in-place nil))
4581 ;; Long lines may cause an end-of-buffer error.
4582 (goto-char (point-max)))))
4583 (move-to-window-line 0)
4586 (defun gnus-article-prev-page (&optional lines)
4587 "Show previous page of current article.
4588 Argument LINES specifies lines to be scrolled down."
4590 (move-to-window-line 0)
4591 (if (and gnus-page-broken
4593 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4595 (gnus-narrow-to-page -1) ;Go to previous page.
4596 (goto-char (point-max))
4598 (let ((scroll-in-place nil))
4602 (beginning-of-buffer
4603 (goto-char (point-min))))
4604 (move-to-window-line 0)))))
4606 (defun gnus-article-refer-article ()
4607 "Read article specified by message-id around point."
4609 (let ((point (point)))
4610 (search-forward ">" nil t) ;Move point to end of "<....>".
4611 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4612 (let ((message-id (match-string 1)))
4614 (set-buffer gnus-summary-buffer)
4615 (gnus-summary-refer-article message-id))
4617 (error "No references around point"))))
4619 (defun gnus-article-show-summary ()
4620 "Reconfigure windows to show summary buffer."
4622 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4623 (error "There is no summary buffer for this article buffer")
4624 (gnus-article-set-globals)
4625 (gnus-configure-windows 'article)
4626 (gnus-summary-goto-subject gnus-current-article)
4627 (gnus-summary-position-point)))
4629 (defun gnus-article-describe-briefly ()
4630 "Describe article mode commands briefly."
4632 (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")))
4634 (defun gnus-article-summary-command ()
4635 "Execute the last keystroke in the summary buffer."
4637 (let ((obuf (current-buffer))
4638 (owin (current-window-configuration))
4640 (switch-to-buffer gnus-article-current-summary 'norecord)
4641 (setq func (lookup-key (current-local-map) (this-command-keys)))
4642 (call-interactively func)
4644 (set-window-configuration owin)
4645 (set-window-point (get-buffer-window (current-buffer)) (point))))
4647 (defun gnus-article-summary-command-nosave ()
4648 "Execute the last keystroke in the summary buffer."
4651 (pop-to-buffer gnus-article-current-summary 'norecord)
4652 (setq func (lookup-key (current-local-map) (this-command-keys)))
4653 (call-interactively func)))
4655 (defun gnus-article-check-buffer ()
4656 "Beep if not in an article buffer."
4657 (unless (equal major-mode 'gnus-article-mode)
4658 (error "Command invoked outside of a Gnus article buffer")))
4660 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4661 "Read a summary buffer key sequence and execute it from the article buffer."
4663 (gnus-article-check-buffer)
4665 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4666 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4667 "=" "^" "\M-^" "|"))
4673 '("n" "Gn" "p" "Gp"))
4676 (set-buffer gnus-article-current-summary)
4677 (let (gnus-pick-mode)
4678 (push (or key last-command-event) unread-command-events)
4679 (setq keys (if (featurep 'xemacs)
4680 (events-to-keys (read-key-sequence nil))
4681 (read-key-sequence nil)))))
4685 (if (or (member keys nosaves)
4686 (member keys nosave-but-article)
4687 (member keys nosave-in-article))
4689 (save-window-excursion
4690 (pop-to-buffer gnus-article-current-summary 'norecord)
4691 ;; We disable the pick minor mode commands.
4692 (let (gnus-pick-mode)
4693 (setq func (lookup-key (current-local-map) keys))))
4697 (unless (member keys nosave-in-article)
4698 (set-buffer gnus-article-current-summary))
4699 (call-interactively func)
4700 (setq new-sum-point (point)))
4701 (when (member keys nosave-but-article)
4702 (pop-to-buffer gnus-article-buffer 'norecord)))
4703 ;; These commands should restore window configuration.
4704 (let ((obuf (current-buffer))
4705 (owin (current-window-configuration))
4707 (summary gnus-article-current-summary)
4708 func in-buffer selected)
4709 (if not-restore-window
4710 (pop-to-buffer summary 'norecord)
4711 (switch-to-buffer summary 'norecord))
4712 (setq in-buffer (current-buffer))
4713 ;; We disable the pick minor mode commands.
4714 (if (and (setq func (let (gnus-pick-mode)
4715 (lookup-key (current-local-map) keys)))
4718 (call-interactively func)
4719 (setq new-sum-point (point))
4720 (when (eq in-buffer (current-buffer))
4721 (setq selected (gnus-summary-select-article))
4723 (unless not-restore-window
4724 (set-window-configuration owin))
4725 (when (eq selected 'old)
4727 (set-window-start (get-buffer-window (current-buffer))
4729 (set-window-point (get-buffer-window (current-buffer))
4731 (let ((win (get-buffer-window gnus-article-current-summary)))
4733 (set-window-point win new-sum-point)))) )
4734 (switch-to-buffer gnus-article-buffer)
4737 (defun gnus-article-describe-key (key)
4738 "Display documentation of the function invoked by KEY. KEY is a string."
4739 (interactive "kDescribe key: ")
4740 (gnus-article-check-buffer)
4741 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4743 (set-buffer gnus-article-current-summary)
4744 (let (gnus-pick-mode)
4745 (if (featurep 'xemacs)
4747 (push (elt key 0) unread-command-events)
4748 (setq key (events-to-keys
4749 (read-key-sequence "Describe key: "))))
4750 (setq unread-command-events
4752 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4753 (string-to-list key)))
4754 (setq key (read-key-sequence "Describe key: "))))
4756 (describe-key key)))
4758 (defun gnus-article-describe-key-briefly (key &optional insert)
4759 "Display documentation of the function invoked by KEY. KEY is a string."
4760 (interactive "kDescribe key: \nP")
4761 (gnus-article-check-buffer)
4762 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4764 (set-buffer gnus-article-current-summary)
4765 (let (gnus-pick-mode)
4766 (if (featurep 'xemacs)
4768 (push (elt key 0) unread-command-events)
4769 (setq key (events-to-keys
4770 (read-key-sequence "Describe key: "))))
4771 (setq unread-command-events
4773 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4774 (string-to-list key)))
4775 (setq key (read-key-sequence "Describe key: "))))
4776 (describe-key-briefly key insert))
4777 (describe-key-briefly key insert)))
4779 (defun gnus-article-reply-with-original (&optional wide)
4780 "Start composing a reply mail to the current message.
4781 The text in the region will be yanked. If the region isn't active,
4782 the entire article will be yanked."
4784 (let ((article (cdr gnus-article-current)) cont)
4786 (gnus-summary-reply (list (list article)) wide)
4787 (setq cont (buffer-substring (point) (mark t)))
4788 ;; Deactivate active regions.
4789 (when (and (boundp 'transient-mark-mode)
4790 transient-mark-mode)
4791 (setq mark-active nil))
4793 (list (list article cont)) wide))))
4795 (defun gnus-article-followup-with-original ()
4796 "Compose a followup to the current article.
4797 The text in the region will be yanked. If the region isn't active,
4798 the entire article will be yanked."
4800 (let ((article (cdr gnus-article-current))
4803 (gnus-summary-followup (list (list article)))
4804 (setq cont (buffer-substring (point) (mark t)))
4805 ;; Deactivate active regions.
4806 (when (and (boundp 'transient-mark-mode)
4807 transient-mark-mode)
4808 (setq mark-active nil))
4809 (gnus-summary-followup
4810 (list (list article cont))))))
4812 (defun gnus-article-hide (&optional arg force)
4813 "Hide all the gruft in the current article.
4814 This means that PGP stuff, signatures, cited text and (some)
4815 headers will be hidden.
4816 If given a prefix, show the hidden text instead."
4817 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4818 (gnus-article-hide-headers arg)
4819 (gnus-article-hide-list-identifiers arg)
4820 (gnus-article-hide-pgp arg)
4821 (gnus-article-hide-citation-maybe arg force)
4822 (gnus-article-hide-signature arg))
4824 (defun gnus-article-maybe-highlight ()
4825 "Do some article highlighting if article highlighting is requested."
4826 (when (gnus-visual-p 'article-highlight 'highlight)
4827 (gnus-article-highlight-some)))
4829 (defun gnus-check-group-server ()
4830 ;; Make sure the connection to the server is alive.
4831 (unless (gnus-server-opened
4832 (gnus-find-method-for-group gnus-newsgroup-name))
4833 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4834 (gnus-request-group gnus-newsgroup-name t)))
4837 (autoload 'nneething-get-file-name "nneething"))
4839 (defun gnus-request-article-this-buffer (article group)
4840 "Get an article and insert it into this buffer."
4841 (let (do-update-line sparse-header)
4845 (gnus-kill-all-overlays)
4846 (setq group (or group gnus-newsgroup-name))
4848 ;; Using `gnus-request-article' directly will insert the article into
4849 ;; `nntp-server-buffer' - so we'll save some time by not having to
4850 ;; copy it from the server buffer into the article buffer.
4852 ;; We only request an article by message-id when we do not have the
4853 ;; headers for it, so we'll have to get those.
4854 (when (stringp article)
4855 (gnus-read-header article))
4857 ;; If the article number is negative, that means that this article
4858 ;; doesn't belong in this newsgroup (possibly), so we find its
4859 ;; message-id and request it by id instead of number.
4860 (when (and (numberp article)
4862 (get-buffer gnus-summary-buffer)
4863 (gnus-buffer-exists-p gnus-summary-buffer))
4865 (set-buffer gnus-summary-buffer)
4866 (let ((header (gnus-summary-article-header article)))
4869 ((memq article gnus-newsgroup-sparse)
4870 ;; This is a sparse gap article.
4871 (setq do-update-line article)
4872 (setq article (mail-header-id header))
4873 (setq sparse-header (gnus-read-header article))
4874 (setq gnus-newsgroup-sparse
4875 (delq article gnus-newsgroup-sparse)))
4877 ;; It's a real article.
4878 (setq article (mail-header-id header)))
4880 ;; It is an extracted pseudo-article.
4881 (setq article 'pseudo)
4882 (gnus-request-pseudo-article header))))
4884 (let ((method (gnus-find-method-for-group
4885 gnus-newsgroup-name)))
4886 (when (and (eq (car method) 'nneething)
4888 (let ((dir (nneething-get-file-name
4889 (mail-header-id header))))
4890 (when (and (stringp dir)
4891 (file-directory-p dir))
4892 (setq article 'nneething)
4893 (gnus-group-enter-directory dir))))))))
4896 ;; Refuse to select canceled articles.
4897 ((and (numberp article)
4899 (get-buffer gnus-summary-buffer)
4900 (gnus-buffer-exists-p gnus-summary-buffer)
4901 (eq (cdr (save-excursion
4902 (set-buffer gnus-summary-buffer)
4903 (assq article gnus-newsgroup-reads)))
4904 gnus-canceled-mark))
4906 ;; We first check `gnus-original-article-buffer'.
4907 ((and (get-buffer gnus-original-article-buffer)
4910 (set-buffer gnus-original-article-buffer)
4911 (and (equal (car gnus-original-article) group)
4912 (eq (cdr gnus-original-article) article))))
4913 (insert-buffer-substring gnus-original-article-buffer)
4915 ;; Check the backlog.
4916 ((and gnus-keep-backlog
4917 (gnus-backlog-request-article group article (current-buffer)))
4919 ;; Check asynchronous pre-fetch.
4920 ((gnus-async-request-fetched-article group article (current-buffer))
4921 (gnus-async-prefetch-next group article gnus-summary-buffer)
4922 (when (and (numberp article) gnus-keep-backlog)
4923 (gnus-backlog-enter-article group article (current-buffer)))
4926 ((and gnus-use-cache
4928 (gnus-cache-request-article article group))
4930 ;; Check the agent cache.
4931 ((and gnus-agent gnus-agent-cache gnus-plugged
4933 (gnus-agent-request-article article group))
4935 ;; Get the article and put into the article buffer.
4936 ((or (stringp article)
4938 (let ((gnus-override-method gnus-override-method)
4939 (methods (and (stringp article)
4940 gnus-refer-article-method))
4942 (buffer-read-only nil))
4943 (if (or (not (listp methods))
4944 (and (symbolp (car methods))
4945 (assq (car methods) nnoo-definition-alist)))
4946 (setq methods (list methods)))
4947 (when (and (null gnus-override-method)
4949 (setq gnus-override-method (pop methods)))
4951 (when (eq gnus-override-method 'current)
4952 (setq gnus-override-method
4953 (with-current-buffer gnus-summary-buffer
4954 gnus-current-select-method)))
4956 (gnus-kill-all-overlays)
4957 (let ((gnus-newsgroup-name group))
4958 (gnus-check-group-server))
4959 (when (gnus-request-article article group (current-buffer))
4960 (when (numberp article)
4961 (gnus-async-prefetch-next group article
4962 gnus-summary-buffer)
4963 (when gnus-keep-backlog
4964 (gnus-backlog-enter-article
4965 group article (current-buffer))))
4966 (setq result 'article))
4969 (setq gnus-override-method (pop methods))
4970 (setq result 'done))))
4971 (and (eq result 'article) 'article)))
4975 ;; Associate this article with the current summary buffer.
4976 (setq gnus-article-current-summary gnus-summary-buffer)
4978 ;; Take the article from the original article buffer
4979 ;; and place it in the buffer it's supposed to be in.
4980 (when (and (get-buffer gnus-article-buffer)
4981 (equal (buffer-name (current-buffer))
4982 (buffer-name (get-buffer gnus-article-buffer))))
4984 (if (get-buffer gnus-original-article-buffer)
4985 (set-buffer gnus-original-article-buffer)
4986 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4987 (buffer-disable-undo)
4988 (setq major-mode 'gnus-original-article-mode)
4989 (setq buffer-read-only t))
4990 (let (buffer-read-only)
4992 (insert-buffer-substring gnus-article-buffer))
4993 (setq gnus-original-article (cons group article)))
4996 (run-hooks 'gnus-article-decode-hook)
4997 ;; Mark article as decoded or not.
4998 (setq gnus-article-decoded-p gnus-article-decode-hook))
5000 ;; Update sparse articles.
5001 (when (and do-update-line
5002 (or (numberp article)
5004 (let ((buf (current-buffer)))
5005 (set-buffer gnus-summary-buffer)
5006 (gnus-summary-update-article do-update-line sparse-header)
5007 (gnus-summary-goto-subject do-update-line nil t)
5008 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5010 (set-buffer buf))))))
5016 (defcustom gnus-article-edit-mode-hook nil
5017 "Hook run in article edit mode buffers."
5018 :group 'gnus-article-various
5021 (defvar gnus-article-edit-done-function nil)
5023 (defvar gnus-article-edit-mode-map nil)
5025 ;; Should we be using derived.el for this?
5026 (unless gnus-article-edit-mode-map
5027 (setq gnus-article-edit-mode-map (make-keymap))
5028 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5031 (gnus-define-keys gnus-article-edit-mode-map
5032 "\C-c?" describe-mode
5033 "\C-c\C-c" gnus-article-edit-done
5034 "\C-c\C-k" gnus-article-edit-exit
5035 "\C-c\C-f\C-t" message-goto-to
5036 "\C-c\C-f\C-o" message-goto-from
5037 "\C-c\C-f\C-b" message-goto-bcc
5038 ;;"\C-c\C-f\C-w" message-goto-fcc
5039 "\C-c\C-f\C-c" message-goto-cc
5040 "\C-c\C-f\C-s" message-goto-subject
5041 "\C-c\C-f\C-r" message-goto-reply-to
5042 "\C-c\C-f\C-n" message-goto-newsgroups
5043 "\C-c\C-f\C-d" message-goto-distribution
5044 "\C-c\C-f\C-f" message-goto-followup-to
5045 "\C-c\C-f\C-m" message-goto-mail-followup-to
5046 "\C-c\C-f\C-k" message-goto-keywords
5047 "\C-c\C-f\C-u" message-goto-summary
5048 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5049 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5050 "\C-c\C-b" message-goto-body
5051 "\C-c\C-i" message-goto-signature
5053 "\C-c\C-t" message-insert-to
5054 "\C-c\C-n" message-insert-newsgroups
5055 "\C-c\C-o" message-sort-headers
5056 "\C-c\C-e" message-elide-region
5057 "\C-c\C-v" message-delete-not-region
5058 "\C-c\C-z" message-kill-to-signature
5059 "\M-\r" message-newline-and-reformat
5060 "\C-c\C-a" mml-attach-file
5061 "\C-a" message-beginning-of-line
5063 "\M-;" comment-region)
5065 (gnus-define-keys (gnus-article-edit-wash-map
5066 "\C-c\C-w" gnus-article-edit-mode-map)
5067 "f" gnus-article-edit-full-stops))
5070 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5072 ["Fetch To" message-insert-to t]
5073 ["Fetch Newsgroups" message-insert-newsgroups t]
5075 ["To" message-goto-to t]
5076 ["From" message-goto-from t]
5077 ["Subject" message-goto-subject t]
5078 ["Cc" message-goto-cc t]
5079 ["Reply-To" message-goto-reply-to t]
5080 ["Summary" message-goto-summary t]
5081 ["Keywords" message-goto-keywords t]
5082 ["Newsgroups" message-goto-newsgroups t]
5083 ["Followup-To" message-goto-followup-to t]
5084 ["Mail-Followup-To" message-goto-mail-followup-to t]
5085 ["Distribution" message-goto-distribution t]
5086 ["Body" message-goto-body t]
5087 ["Signature" message-goto-signature t]))
5089 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5090 "Major mode for editing articles.
5091 This is an extended text-mode.
5093 \\{gnus-article-edit-mode-map}"
5094 (make-local-variable 'gnus-article-edit-done-function)
5095 (make-local-variable 'gnus-prev-winconf)
5096 (set (make-local-variable 'font-lock-defaults)
5097 '(message-font-lock-keywords t))
5098 (set (make-local-variable 'mail-header-separator) "")
5099 (easy-menu-add message-mode-field-menu message-mode-map)
5101 (setq buffer-read-only nil)
5102 (buffer-enable-undo)
5105 (defun gnus-article-edit (&optional force)
5106 "Edit the current article.
5107 This will have permanent effect only in mail groups.
5108 If FORCE is non-nil, allow editing of articles even in read-only
5111 (when (and (not force)
5112 (gnus-group-read-only-p))
5113 (error "The current newsgroup does not support article editing"))
5114 (gnus-article-date-original)
5115 (gnus-article-edit-article
5117 `(lambda (no-highlight)
5119 (gnus-summary-edit-article-done
5120 ,(or (mail-header-references gnus-current-headers) "")
5121 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5123 (defun gnus-article-edit-article (start-func exit-func)
5124 "Start editing the contents of the current article buffer."
5125 (let ((winconf (current-window-configuration)))
5126 (set-buffer gnus-article-buffer)
5127 (gnus-article-edit-mode)
5128 (funcall start-func)
5129 (set-buffer-modified-p nil)
5130 (gnus-configure-windows 'edit-article)
5131 (setq gnus-article-edit-done-function exit-func)
5132 (setq gnus-prev-winconf winconf)
5133 (gnus-message 6 "C-c C-c to end edits")))
5135 (defun gnus-article-edit-done (&optional arg)
5136 "Update the article edits and exit."
5138 (let ((func gnus-article-edit-done-function)
5139 (buf (current-buffer))
5140 (start (window-start))
5142 (winconf gnus-prev-winconf))
5143 (widen) ;; Widen it in case that users narrowed the buffer.
5146 ;; The cache and backlog have to be flushed somewhat.
5147 (when gnus-keep-backlog
5148 (gnus-backlog-remove-article
5149 (car gnus-article-current) (cdr gnus-article-current)))
5150 ;; Flush original article as well.
5152 (when (get-buffer gnus-original-article-buffer)
5153 (set-buffer gnus-original-article-buffer)
5154 (setq gnus-original-article nil)))
5155 (when gnus-use-cache
5156 (gnus-cache-update-article
5157 (car gnus-article-current) (cdr gnus-article-current)))
5158 ;; We remove all text props from the article buffer.
5159 (kill-all-local-variables)
5160 (gnus-set-text-properties (point-min) (point-max) nil)
5162 (set-window-configuration winconf)
5164 (set-window-start (get-buffer-window buf) start)
5165 (set-window-point (get-buffer-window buf) (point))))
5167 (defun gnus-article-edit-exit ()
5168 "Exit the article editing without updating."
5170 (when (or (not (buffer-modified-p))
5171 (yes-or-no-p "Article modified; kill anyway? "))
5172 (let ((curbuf (current-buffer))
5174 (window-start (window-start)))
5176 (if (gnus-buffer-live-p gnus-original-article-buffer)
5177 (insert-buffer gnus-original-article-buffer))
5178 (let ((winconf gnus-prev-winconf))
5180 (set-window-configuration winconf)
5181 ;; Tippy-toe some to make sure that point remains where it was.
5182 (save-current-buffer
5184 (set-window-start (get-buffer-window (current-buffer)) window-start)
5187 (defun gnus-article-edit-full-stops ()
5188 "Interactively repair spacing at end of sentences."
5191 (goto-char (point-min))
5192 (search-forward-regexp "^$" nil t)
5193 (let ((case-fold-search nil))
5194 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5197 ;;; Article highlights
5200 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5202 ;;; Internal Variables:
5204 (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\\)\\)"
5205 "Regular expression that matches URLs."
5206 :group 'gnus-article-buttons
5209 (defcustom gnus-button-alist
5210 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5211 0 t gnus-button-handle-news 3)
5212 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5213 gnus-button-handle-news 2)
5214 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5216 gnus-button-fetch-group 4)
5217 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5218 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5219 t gnus-button-message-id 3)
5220 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5221 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5222 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5224 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5225 gnus-button-handle-info 2)
5226 ;; This is how URLs _should_ be embedded in text...
5227 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5229 (,gnus-button-url-regexp 0 t browse-url 0))
5230 "*Alist of regexps matching buttons in article bodies.
5232 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5233 REGEXP: is the string matching text around the button,
5234 BUTTON: is the number of the regexp grouping actually matching the button,
5235 FORM: is a lisp expression which must eval to true for the button to
5237 CALLBACK: is the function to call when the user push this button, and each
5238 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5240 CALLBACK can also be a variable, in that case the value of that
5241 variable it the real callback function."
5242 :group 'gnus-article-buttons
5243 :type '(repeat (list regexp
5244 (integer :tag "Button")
5246 (function :tag "Callback")
5249 (integer :tag "Regexp group")))))
5251 (defcustom gnus-header-button-alist
5252 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5253 0 t gnus-button-message-id 0)
5254 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5255 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5256 0 t gnus-button-mailto 0)
5257 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5258 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5259 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5260 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5261 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5262 gnus-button-message-id 3))
5263 "*Alist of headers and regexps to match buttons in article heads.
5265 This alist is very similar to `gnus-button-alist', except that each
5266 alist has an additional HEADER element first in each entry:
5268 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5270 HEADER is a regexp to match a header. For a fuller explanation, see
5271 `gnus-button-alist'."
5272 :group 'gnus-article-buttons
5273 :group 'gnus-article-headers
5274 :type '(repeat (list (regexp :tag "Header")
5276 (integer :tag "Button")
5278 (function :tag "Callback")
5281 (integer :tag "Regexp group")))))
5283 (defvar gnus-button-regexp nil)
5284 (defvar gnus-button-marker-list nil)
5285 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5287 (defvar gnus-button-last nil)
5288 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5292 (defun gnus-article-push-button (event)
5293 "Check text under the mouse pointer for a callback function.
5294 If the text under the mouse pointer has a `gnus-callback' property,
5295 call it with the value of the `gnus-data' text property."
5297 (set-buffer (window-buffer (posn-window (event-start event))))
5298 (let* ((pos (posn-point (event-start event)))
5299 (data (get-text-property pos 'gnus-data))
5300 (fun (get-text-property pos 'gnus-callback)))
5303 (funcall fun data))))
5305 (defun gnus-article-press-button ()
5306 "Check text at point for a callback function.
5307 If the text at point has a `gnus-callback' property,
5308 call it with the value of the `gnus-data' text property."
5310 (let* ((data (get-text-property (point) 'gnus-data))
5311 (fun (get-text-property (point) 'gnus-callback)))
5313 (funcall fun data))))
5315 (defun gnus-article-highlight (&optional force)
5316 "Highlight current article.
5317 This function calls `gnus-article-highlight-headers',
5318 `gnus-article-highlight-citation',
5319 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5320 do the highlighting. See the documentation for those functions."
5321 (interactive (list 'force))
5322 (gnus-article-highlight-headers)
5323 (gnus-article-highlight-citation force)
5324 (gnus-article-highlight-signature)
5325 (gnus-article-add-buttons force)
5326 (gnus-article-add-buttons-to-head))
5328 (defun gnus-article-highlight-some (&optional force)
5329 "Highlight current article.
5330 This function calls `gnus-article-highlight-headers',
5331 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5332 do the highlighting. See the documentation for those functions."
5333 (interactive (list 'force))
5334 (gnus-article-highlight-headers)
5335 (gnus-article-highlight-signature)
5336 (gnus-article-add-buttons))
5338 (defun gnus-article-highlight-headers ()
5339 "Highlight article headers as specified by `gnus-header-face-alist'."
5342 (set-buffer gnus-article-buffer)
5344 (let ((alist gnus-header-face-alist)
5345 (buffer-read-only nil)
5346 (case-fold-search t)
5347 (inhibit-point-motion-hooks t)
5348 entry regexp header-face field-face from hpoints fpoints)
5349 (article-narrow-to-head)
5350 (while (setq entry (pop alist))
5351 (goto-char (point-min))
5352 (setq regexp (concat "^\\("
5353 (if (string-equal "" (nth 0 entry))
5357 header-face (nth 1 entry)
5358 field-face (nth 2 entry))
5359 (while (and (re-search-forward regexp nil t)
5363 (unless (search-forward ":" nil t)
5365 (when (and header-face
5366 (not (memq (point) hpoints)))
5367 (push (point) hpoints)
5368 (gnus-put-text-property from (point) 'face header-face))
5369 (when (and field-face
5370 (not (memq (setq from (point)) fpoints)))
5372 (if (re-search-forward "^[^ \t]" nil t)
5374 (goto-char (point-max)))
5375 (gnus-put-text-property from (point) 'face field-face))))))))
5377 (defun gnus-article-highlight-signature ()
5378 "Highlight the signature in an article.
5379 It does this by highlighting everything after
5380 `gnus-signature-separator' using `gnus-signature-face'."
5383 (set-buffer gnus-article-buffer)
5384 (let ((buffer-read-only nil)
5385 (inhibit-point-motion-hooks t))
5387 (when (and gnus-signature-face
5388 (gnus-article-narrow-to-signature))
5389 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5390 'face gnus-signature-face)
5392 (gnus-article-search-signature)
5393 (let ((start (match-beginning 0))
5394 (end (set-marker (make-marker) (1+ (match-end 0)))))
5395 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5398 (defun gnus-button-in-region-p (b e prop)
5399 "Say whether PROP exists in the region."
5400 (text-property-not-all b e prop nil))
5402 (defun gnus-article-add-buttons (&optional force)
5403 "Find external references in the article and make buttons of them.
5404 \"External references\" are things like Message-IDs and URLs, as
5405 specified by `gnus-button-alist'."
5406 (interactive (list 'force))
5408 (set-buffer gnus-article-buffer)
5409 (let ((buffer-read-only nil)
5410 (inhibit-point-motion-hooks t)
5411 (case-fold-search t)
5412 (alist gnus-button-alist)
5414 ;; Remove all old markers.
5415 (let (marker entry new-list)
5416 (while (setq marker (pop gnus-button-marker-list))
5417 (if (or (< marker (point-min)) (>= marker (point-max)))
5418 (push marker new-list)
5420 (when (setq entry (gnus-button-entry))
5421 (put-text-property (match-beginning (nth 1 entry))
5422 (match-end (nth 1 entry))
5423 'gnus-callback nil))
5424 (set-marker marker nil)))
5425 (setq gnus-button-marker-list new-list))
5426 ;; We skip the headers.
5429 (while (setq entry (pop alist))
5430 (setq regexp (car entry))
5432 (while (re-search-forward regexp nil t)
5433 (let* ((start (and entry (match-beginning (nth 1 entry))))
5434 (end (and entry (match-end (nth 1 entry))))
5435 (from (match-beginning 0)))
5436 (when (and (or (eq t (nth 2 entry))
5437 (eval (nth 2 entry)))
5438 (not (gnus-button-in-region-p
5439 start end 'gnus-callback)))
5440 ;; That optional form returned non-nil, so we add the
5442 (gnus-article-add-button
5443 start end 'gnus-button-push
5444 (car (push (set-marker (make-marker) from)
5445 gnus-button-marker-list))))))))))
5447 ;; Add buttons to the head of an article.
5448 (defun gnus-article-add-buttons-to-head ()
5449 "Add buttons to the head of the article."
5452 (set-buffer gnus-article-buffer)
5454 (let ((buffer-read-only nil)
5455 (inhibit-point-motion-hooks t)
5456 (case-fold-search t)
5457 (alist gnus-header-button-alist)
5459 (article-narrow-to-head)
5461 ;; Each alist entry.
5462 (setq entry (car alist)
5464 (goto-char (point-min))
5465 (while (re-search-forward (car entry) nil t)
5466 ;; Each header matching the entry.
5467 (setq beg (match-beginning 0))
5468 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5469 (match-beginning 0))
5472 (while (re-search-forward (nth 1 entry) end t)
5473 ;; Each match within a header.
5474 (let* ((entry (cdr entry))
5475 (start (match-beginning (nth 1 entry)))
5476 (end (match-end (nth 1 entry)))
5477 (form (nth 2 entry)))
5478 (goto-char (match-end 0))
5480 (gnus-article-add-button
5481 start end (nth 3 entry)
5482 (buffer-substring (match-beginning (nth 4 entry))
5483 (match-end (nth 4 entry)))))))
5484 (goto-char end)))))))
5486 ;;; External functions:
5488 (defun gnus-article-add-button (from to fun &optional data)
5489 "Create a button between FROM and TO with callback FUN and data DATA."
5490 (when gnus-article-button-face
5491 (gnus-overlay-put (gnus-make-overlay from to)
5492 'face gnus-article-button-face))
5493 (gnus-add-text-properties
5495 (nconc (and gnus-article-mouse-face
5496 (list gnus-mouse-face-prop gnus-article-mouse-face))
5497 (list 'gnus-callback fun)
5498 (and data (list 'gnus-data data))))
5499 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5500 :button-keymap gnus-widget-button-keymap))
5502 ;;; Internal functions:
5504 (defun gnus-article-set-globals ()
5506 (set-buffer gnus-summary-buffer)
5507 (gnus-set-global-variables)))
5509 (defun gnus-signature-toggle (end)
5511 (set-buffer gnus-article-buffer)
5512 (let ((buffer-read-only nil)
5513 (inhibit-point-motion-hooks t))
5514 (if (text-property-any end (point-max) 'article-type 'signature)
5516 (gnus-delete-wash-type 'signature)
5517 (gnus-remove-text-properties-when
5518 'article-type 'signature end (point-max)
5519 (cons 'article-type (cons 'signature
5520 gnus-hidden-properties))))
5521 (gnus-add-wash-type 'signature)
5522 (gnus-add-text-properties-when
5523 'article-type nil end (point-max)
5524 (cons 'article-type (cons 'signature
5525 gnus-hidden-properties)))))
5526 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5527 (gnus-set-mode-line 'article))))
5529 (defun gnus-button-entry ()
5530 ;; Return the first entry in `gnus-button-alist' matching this place.
5531 (let ((alist gnus-button-alist)
5534 (setq entry (pop alist))
5535 (if (looking-at (car entry))
5540 (defun gnus-button-push (marker)
5541 ;; Push button starting at MARKER.
5544 (let* ((entry (gnus-button-entry))
5545 (inhibit-point-motion-hooks t)
5547 (args (mapcar (lambda (group)
5548 (let ((string (match-string group)))
5549 (gnus-set-text-properties
5550 0 (length string) nil string)
5557 (fboundp (symbol-value fun)))
5558 (apply (symbol-value fun) args))
5560 (gnus-message 1 "You must define `%S' to use this button"
5561 (cons fun args)))))))
5563 (defun gnus-parse-news-url (url)
5564 (let (scheme server group message-id articles)
5567 (goto-char (point-min))
5568 (when (looking-at "\\([A-Za-z]+\\):")
5569 (setq scheme (match-string 1))
5570 (goto-char (match-end 0)))
5571 (when (looking-at "//\\([^/]+\\)/")
5572 (setq server (match-string 1))
5573 (goto-char (match-end 0)))
5576 ((looking-at "\\(.*@.*\\)")
5577 (setq message-id (match-string 1)))
5578 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5579 (setq group (match-string 1)
5580 articles (split-string (match-string 2) "-")))
5581 ((looking-at "\\([^/]+\\)/?")
5582 (setq group (match-string 1)))
5584 (error "Unknown news URL syntax"))))
5585 (list scheme server group message-id articles)))
5587 (defun gnus-button-handle-news (url)
5589 (destructuring-bind (scheme server group message-id articles)
5590 (gnus-parse-news-url url)
5594 (set-buffer gnus-summary-buffer)
5596 (let ((gnus-refer-article-method (list (list 'nntp server))))
5597 (gnus-summary-refer-article message-id))
5598 (gnus-summary-refer-article message-id))))
5600 (gnus-button-fetch-group url)))))
5602 (defun gnus-button-handle-info (url)
5603 "Fetch an info URL."
5605 "^\\([^:/]+\\)?/\\(.*\\)"
5607 (gnus-info-find-node
5608 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5611 (gnus-url-unhex-string (match-string 2 url))))
5612 (error "Can't parse %s" url)))
5614 (defun gnus-button-message-id (message-id)
5617 (set-buffer gnus-summary-buffer)
5618 (gnus-summary-refer-article message-id)))
5620 (defun gnus-button-fetch-group (address)
5621 "Fetch GROUP specified by ADDRESS."
5622 (if (not (string-match "[:/]" address))
5623 ;; This is just a simple group url.
5624 (gnus-group-read-ephemeral-group address gnus-select-method)
5627 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5629 (error "Can't parse %s" address)
5630 (gnus-group-read-ephemeral-group
5631 (match-string 4 address)
5632 `(nntp ,(match-string 1 address)
5633 (nntp-address ,(match-string 1 address))
5634 (nntp-port-number ,(if (match-end 3)
5635 (match-string 3 address)
5638 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5640 (defun gnus-url-parse-query-string (query &optional downcase)
5641 (let (retval pairs cur key val)
5642 (setq pairs (split-string query "&"))
5644 (setq cur (car pairs)
5646 (if (not (string-match "=" cur))
5648 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5649 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5651 (setq key (downcase key)))
5652 (setq cur (assoc key retval))
5654 (setcdr cur (cons val (cdr cur)))
5655 (setq retval (cons (list key val) retval)))))
5658 (defun gnus-url-mailto (url)
5659 ;; Send mail to someone
5660 (when (string-match "mailto:/*\\(.*\\)" url)
5661 (setq url (substring url (match-beginning 1) nil)))
5662 (let (to args subject func)
5663 (if (string-match (regexp-quote "?") url)
5664 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5665 args (gnus-url-parse-query-string
5666 (substring url (match-end 0) nil) t))
5667 (setq to (gnus-url-unhex-string url)))
5668 (setq args (cons (list "to" to) args)
5669 subject (cdr-safe (assoc "subject" args)))
5672 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5675 (message-position-on-field (caar args)))
5676 (insert (mapconcat 'identity (cdar args) ", "))
5677 (setq args (cdr args)))
5680 (message-goto-subject))))
5682 (defun gnus-button-embedded-url (address)
5683 "Activate ADDRESS with `browse-url'."
5684 (browse-url (gnus-strip-whitespace address)))
5686 ;;; Next/prev buttons in the article buffer.
5688 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5689 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5691 (defvar gnus-prev-page-map
5692 (let ((map (make-sparse-keymap)))
5693 (unless (>= emacs-major-version 21)
5694 ;; XEmacs doesn't care.
5695 (set-keymap-parent map gnus-article-mode-map))
5696 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5697 (define-key map "\r" 'gnus-button-prev-page)
5700 (defun gnus-insert-prev-page-button ()
5702 (buffer-read-only nil))
5704 gnus-prev-page-line-format nil
5705 `(,@(gnus-local-map-property gnus-prev-page-map)
5707 gnus-callback gnus-article-button-prev-page
5708 article-type annotation))
5709 (widget-convert-button
5711 :action 'gnus-button-prev-page
5712 :button-keymap gnus-prev-page-map)))
5714 (defvar gnus-prev-page-map
5715 (let ((map (make-sparse-keymap)))
5716 (unless (>= emacs-major-version 21)
5717 ;; XEmacs doesn't care.
5718 (set-keymap-parent map gnus-article-mode-map))
5719 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5720 (define-key map "\r" 'gnus-button-prev-page)
5723 (defvar gnus-next-page-map
5724 (let ((map (make-sparse-keymap)))
5725 (unless (>= emacs-major-version 21)
5726 ;; XEmacs doesn't care.
5727 (set-keymap-parent map gnus-article-mode-map))
5728 (define-key map gnus-mouse-2 'gnus-button-next-page)
5729 (define-key map "\r" 'gnus-button-next-page)
5732 (defun gnus-button-next-page (&optional args more-args)
5733 "Go to the next page."
5735 (let ((win (selected-window)))
5736 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5737 (gnus-article-next-page)
5738 (select-window win)))
5740 (defun gnus-button-prev-page (&optional args more-args)
5741 "Go to the prev page."
5743 (let ((win (selected-window)))
5744 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5745 (gnus-article-prev-page)
5746 (select-window win)))
5748 (defun gnus-insert-next-page-button ()
5750 (buffer-read-only nil))
5751 (gnus-eval-format gnus-next-page-line-format nil
5752 `(,@(gnus-local-map-property gnus-next-page-map)
5754 gnus-callback gnus-article-button-next-page
5755 article-type annotation))
5756 (widget-convert-button
5758 :action 'gnus-button-next-page
5759 :button-keymap gnus-next-page-map)))
5761 (defun gnus-article-button-next-page (arg)
5762 "Go to the next page."
5764 (let ((win (selected-window)))
5765 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5766 (gnus-article-next-page)
5767 (select-window win)))
5769 (defun gnus-article-button-prev-page (arg)
5770 "Go to the prev page."
5772 (let ((win (selected-window)))
5773 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5774 (gnus-article-prev-page)
5775 (select-window win)))
5777 (defvar gnus-decode-header-methods
5778 '(mail-decode-encoded-word-region)
5779 "List of methods used to decode headers.
5781 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5782 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5783 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5784 whose names match REGEXP.
5787 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5788 mail-decode-encoded-word-region
5789 (\"chinese\" . rfc1843-decode-region))
5792 (defvar gnus-decode-header-methods-cache nil)
5794 (defun gnus-multi-decode-header (start end)
5795 "Apply the functions from `gnus-encoded-word-methods' that match."
5796 (unless (and gnus-decode-header-methods-cache
5797 (eq gnus-newsgroup-name
5798 (car gnus-decode-header-methods-cache)))
5799 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5802 (nconc gnus-decode-header-methods-cache (list x))
5803 (if (and gnus-newsgroup-name
5804 (string-match (car x) gnus-newsgroup-name))
5805 (nconc gnus-decode-header-methods-cache
5807 gnus-decode-header-methods))
5808 (let ((xlist gnus-decode-header-methods-cache))
5811 (narrow-to-region start end)
5813 (funcall (pop xlist) (point-min) (point-max))))))
5816 ;;; Treatment top-level handling.
5819 (defun gnus-treat-article (condition &optional part-number total-parts type)
5820 (let ((length (- (point-max) (point-min)))
5821 (alist gnus-treatment-function-alist)
5822 (article-goto-body-goes-to-point-min-p t)
5826 (let ((list gnus-article-treat-types))
5828 (when (string-match (pop list) type)
5829 (throw 'found t)))))))
5830 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5832 (gnus-run-hooks 'gnus-part-display-hook)
5833 (while (setq elem (pop alist))
5836 (if (gnus-buffer-live-p gnus-summary-buffer)
5837 (set-buffer gnus-summary-buffer))
5838 (symbol-value (car elem))))
5839 (when (and (or (consp val)
5841 (gnus-treat-predicate val)
5842 (or (not (get (car elem) 'highlight))
5845 (funcall (cadr elem)))))))
5847 ;; Dynamic variables.
5849 (defvar part-number)
5850 (defvar total-parts)
5855 (defun gnus-treat-predicate (val)
5860 (stringp (car val)))
5861 (apply 'gnus-or (mapcar `(lambda (s)
5862 (string-match s ,(or gnus-newsgroup-name "")))
5865 (let ((pred (pop val)))
5868 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5870 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5872 (not (gnus-treat-predicate (car val))))
5874 (equal (car val) type))
5876 (error "%S is not a valid predicate" pred)))))
5884 (eq part-number total-parts))
5888 (error "%S is not a valid value" val))))
5890 (defun gnus-article-encrypt-body (protocol &optional n)
5891 "Encrypt the article body."
5894 (or gnus-article-encrypt-protocol
5895 (completing-read "Encrypt protocol: "
5896 gnus-article-encrypt-protocol-alist
5898 current-prefix-arg))
5899 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5901 (error (format "Can't find the encrypt protocol %s" protocol)))
5902 (if (equal gnus-newsgroup-name "nndraft:drafts")
5903 (error "Can't encrypt the article in group nndraft:drafts"))
5904 (if (equal gnus-newsgroup-name "nndraft:queue")
5905 (error "Don't encrypt the article in group nndraft:queue"))
5906 (gnus-summary-iterate n
5908 (set-buffer gnus-summary-buffer)
5909 (let ((mail-parse-charset gnus-newsgroup-charset)
5910 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5911 (summary-buffer gnus-summary-buffer)
5913 (gnus-set-global-variables)
5914 (when (gnus-group-read-only-p)
5915 (error "The current newsgroup does not support article encrypt"))
5916 (gnus-summary-show-article t)
5918 (or (mail-header-references gnus-current-headers) ""))
5919 (set-buffer gnus-article-buffer)
5920 (let* ((buffer-read-only nil)
5922 (mapcar (lambda (field)
5923 (and (save-restriction
5924 (message-narrow-to-head)
5925 (goto-char (point-min))
5926 (search-forward field nil t))
5928 (message-narrow-to-field)
5929 (buffer-substring (point-min) (point-max))
5930 (delete-region (point-min) (point-max))
5932 '("Content-Type:" "Content-Transfer-Encoding:"
5933 "Content-Disposition:"))))
5934 (message-narrow-to-head)
5935 (message-remove-header "MIME-Version")
5936 (goto-char (point-max))
5937 (setq point (point))
5938 (insert (apply 'concat headers))
5940 (narrow-to-region point (point-max))
5941 (let ((message-options message-options))
5942 (message-options-set 'message-sender user-mail-address)
5943 (message-options-set 'message-recipients user-mail-address)
5944 (message-options-set 'message-sign-encrypt 'not)
5946 (goto-char (point-min))
5947 (insert "MIME-Version: 1.0\n")
5949 (gnus-summary-edit-article-done
5950 references nil summary-buffer t))
5951 (when gnus-keep-backlog
5952 (gnus-backlog-remove-article
5953 (car gnus-article-current) (cdr gnus-article-current)))
5955 (when (get-buffer gnus-original-article-buffer)
5956 (set-buffer gnus-original-article-buffer)
5957 (setq gnus-original-article nil)))
5958 (when gnus-use-cache
5959 (gnus-cache-update-article
5960 (car gnus-article-current) (cdr gnus-article-current))))))))
5962 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5963 "The following specs can be used:
5964 %t The security MIME type
5967 %D Details if button is pressed")
5969 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5970 "The following specs can be used:
5971 %t The security MIME type
5974 %D Details if button is pressed")
5976 (defvar gnus-mime-security-button-line-format-alist
5977 '((?t gnus-tmp-type ?s)
5978 (?i gnus-tmp-info ?s)
5979 (?d gnus-tmp-details ?s)
5980 (?D gnus-tmp-pressed-details ?s)))
5982 (defvar gnus-mime-security-button-map
5983 (let ((map (make-sparse-keymap)))
5984 (unless (>= (string-to-number emacs-version) 21)
5985 (set-keymap-parent map gnus-article-mode-map))
5986 (define-key map gnus-mouse-2 'gnus-article-push-button)
5987 (define-key map "\r" 'gnus-article-press-button)
5990 (defvar gnus-mime-security-details-buffer nil)
5992 (defvar gnus-mime-security-button-pressed nil)
5994 (defvar gnus-mime-security-show-details-inline t
5995 "If non-nil, show details in the article buffer.")
5997 (defun gnus-mime-security-verify-or-decrypt (handle)
5998 (mm-remove-parts (cdr handle))
5999 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6000 point buffer-read-only)
6002 (goto-char (car region)))
6004 (narrow-to-region (point) (point))
6005 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6006 (let* ((mm-verify-option 'known)
6007 (mm-decrypt-option 'known)
6008 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6009 (unless (eq nparts (cdr handle))
6010 (mm-destroy-parts (cdr handle))
6011 (setcdr handle nparts))))
6012 (setq point (point))
6013 (gnus-mime-display-security handle)
6014 (goto-char (point-max)))
6016 (delete-region (point) (cdr region))
6017 (set-marker (car region) nil)
6018 (set-marker (cdr region) nil))
6021 (defun gnus-mime-security-show-details (handle)
6022 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6024 (if gnus-mime-security-show-details-inline
6025 (let ((gnus-mime-security-button-pressed t)
6026 (gnus-mime-security-button-line-format
6027 (get-text-property (point) 'gnus-line-format))
6030 (while (eq (get-text-property (point) 'gnus-line-format)
6031 gnus-mime-security-button-line-format)
6035 (narrow-to-region (point) (point))
6036 (gnus-insert-mime-security-button handle))
6037 (delete-region (point)
6038 (or (text-property-not-all
6041 gnus-mime-security-button-line-format)
6043 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6044 (with-current-buffer gnus-mime-security-details-buffer
6047 (setq gnus-mime-security-details-buffer
6048 (gnus-get-buffer-create "*MIME Security Details*")))
6049 (with-current-buffer gnus-mime-security-details-buffer
6051 (goto-char (point-min)))
6052 (pop-to-buffer gnus-mime-security-details-buffer))
6053 (gnus-message 5 "No details."))))
6055 (defun gnus-mime-security-press-button (handle)
6056 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6057 (gnus-mime-security-show-details handle)
6058 (gnus-mime-security-verify-or-decrypt handle)))
6060 (defun gnus-insert-mime-security-button (handle &optional displayed)
6061 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6064 (or (nth 2 (assoc protocol mm-verify-function-alist))
6065 (nth 2 (assoc protocol mm-decrypt-function-alist))
6067 (if (equal (car handle) "multipart/signed")
6068 " Signed" " Encrypted")
6071 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6074 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6075 gnus-tmp-pressed-details
6077 (setq gnus-tmp-details
6078 (if gnus-tmp-details
6079 (concat "\n" gnus-tmp-details) ""))
6080 (setq gnus-tmp-pressed-details
6081 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6086 gnus-mime-security-button-line-format
6087 gnus-mime-security-button-line-format-alist
6088 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6089 gnus-callback gnus-mime-security-press-button
6090 gnus-line-format ,gnus-mime-security-button-line-format
6091 article-type annotation
6094 (widget-convert-button
6097 :action 'gnus-widget-press-button
6098 :button-keymap gnus-mime-security-button-map
6100 (lambda (widget/window &optional overlay pos)
6101 ;; Needed to properly clear the message due to a bug in
6102 ;; wid-edit (XEmacs only).
6103 (if (boundp 'help-echo-owns-message)
6104 (setq help-echo-owns-message t))
6107 (aref gnus-mouse-2 0))))))
6109 (defun gnus-mime-display-security (handle)
6111 (narrow-to-region (point) (point))
6112 (unless (gnus-unbuttonized-mime-type-p (car handle))
6113 (gnus-insert-mime-security-button handle))
6114 (gnus-mime-display-mixed (cdr handle))
6117 (unless (gnus-unbuttonized-mime-type-p (car handle))
6118 (let ((gnus-mime-security-button-line-format
6119 gnus-mime-security-button-end-line-format))
6120 (gnus-insert-mime-security-button handle)))
6121 (mm-set-handle-multipart-parameter
6123 (cons (set-marker (make-marker) (point-min))
6124 (set-marker (make-marker) (point-max))))))
6130 (run-hooks 'gnus-art-load-hook)
6132 ;;; gnus-art.el ends here