1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
245 :group 'gnus-article-washing)
247 (defcustom gnus-article-x-face-too-ugly nil
248 "Regexp matching posters whose face shouldn't be shown automatically."
249 :type '(choice regexp (const nil))
250 :group 'gnus-article-washing)
252 (defcustom gnus-article-banner-alist nil
253 "Banner alist for stripping.
255 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
257 :type '(repeat (cons symbol regexp))
258 :group 'gnus-article-washing)
260 (gnus-define-group-parameter
263 "Alist of regexps (to match group names) and banner."
264 :variable-group gnus-article-washing
266 '(choice :tag "Banner"
268 (const :tag "Remove signature" signature)
269 (symbol :tag "Item in `gnus-article-banner-alist'" none)
271 (const :tag "None" nil))
273 "If non-nil, specify how to remove `banners' from articles.
275 Symbol `signature' means to remove signatures delimited by
276 `gnus-signature-separator'. Any other symbol is used to look up a
277 regular expression to match the banner in `gnus-article-banner-alist'.
278 A string is used as a regular expression to match the banner
281 (defcustom gnus-emphasis-alist
283 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
288 ("_/" "/_" underline-italic)
289 ("_\\*" "\\*_" underline-bold)
290 ("\\*/" "/\\*" bold-italic)
291 ("_\\*/" "/\\*_" underline-bold-italic))))
295 (format format (car spec) (cadr spec))
296 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
298 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
299 2 3 gnus-emphasis-underline)))
300 "*Alist that says how to fontify certain phrases.
301 Each item looks like this:
303 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
305 The first element is a regular expression to be matched. The second
306 is a number that says what regular expression grouping used to find
307 the entire emphasized word. The third is a number that says what
308 regexp grouping should be displayed and highlighted. The fourth
309 is the face used for highlighting."
310 :type '(repeat (list :value ("" 0 0 default)
312 (integer :tag "Match group")
313 (integer :tag "Emphasize group")
315 :group 'gnus-article-emphasis)
317 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
318 "A regexp to describe whitespace which should not be emphasized.
319 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
320 The former avoids underlining of leading and trailing whitespace,
321 and the latter avoids underlining any whitespace at all."
323 :group 'gnus-article-emphasis
326 (defface gnus-emphasis-bold '((t (:bold t)))
327 "Face used for displaying strong emphasized text (*word*)."
328 :group 'gnus-article-emphasis)
330 (defface gnus-emphasis-italic '((t (:italic t)))
331 "Face used for displaying italic emphasized text (/word/)."
332 :group 'gnus-article-emphasis)
334 (defface gnus-emphasis-underline '((t (:underline t)))
335 "Face used for displaying underlined emphasized text (_word_)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
339 "Face used for displaying underlined bold emphasized text (_*word*_)."
340 :group 'gnus-article-emphasis)
342 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
343 "Face used for displaying underlined italic emphasized text (_/word/_)."
344 :group 'gnus-article-emphasis)
346 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
347 "Face used for displaying bold italic emphasized text (/*word*/)."
348 :group 'gnus-article-emphasis)
350 (defface gnus-emphasis-underline-bold-italic
351 '((t (:bold t :italic t :underline t)))
352 "Face used for displaying underlined bold italic emphasized text.
353 Esample: (_/*word*/_)."
354 :group 'gnus-article-emphasis)
356 (defface gnus-emphasis-highlight-words
357 '((t (:background "black" :foreground "yellow")))
358 "Face used for displaying highlighted words."
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
362 "Format for display of Date headers in article bodies.
363 See `format-time-string' for the possible values.
365 The variable can also be function, which should return a complete Date
366 header. The function is called with one argument, the time, which can
367 be fed to `format-time-string'."
368 :type '(choice string symbol)
369 :link '(custom-manual "(gnus)Article Date")
370 :group 'gnus-article-washing)
373 (autoload 'mail-extract-address-components "mail-extr"))
375 (defcustom gnus-save-all-headers t
376 "*If non-nil, don't remove any headers before saving."
377 :group 'gnus-article-saving
380 (defcustom gnus-prompt-before-saving 'always
381 "*This variable says how much prompting is to be done when saving articles.
382 If it is nil, no prompting will be done, and the articles will be
383 saved to the default files. If this variable is `always', each and
384 every article that is saved will be preceded by a prompt, even when
385 saving large batches of articles. If this variable is neither nil not
386 `always', there the user will be prompted once for a file name for
387 each invocation of the saving commands."
388 :group 'gnus-article-saving
389 :type '(choice (item always)
390 (item :tag "never" nil)
391 (sexp :tag "once" :format "%t\n" :value t)))
393 (defcustom gnus-saved-headers gnus-visible-headers
394 "Headers to keep if `gnus-save-all-headers' is nil.
395 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
396 If that variable is nil, however, all headers that match this regexp
397 will be kept while the rest will be deleted before saving."
398 :group 'gnus-article-saving
401 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
402 "A function to save articles in your favourite format.
403 The function must be interactively callable (in other words, it must
404 be an Emacs command).
406 Gnus provides the following functions:
408 * gnus-summary-save-in-rmail (Rmail format)
409 * gnus-summary-save-in-mail (Unix mail format)
410 * gnus-summary-save-in-folder (MH folder)
411 * gnus-summary-save-in-file (article format)
412 * gnus-summary-save-body-in-file (article body)
413 * gnus-summary-save-in-vm (use VM's folder format)
414 * gnus-summary-write-to-file (article format -- overwrite)."
415 :group 'gnus-article-saving
416 :type '(radio (function-item gnus-summary-save-in-rmail)
417 (function-item gnus-summary-save-in-mail)
418 (function-item gnus-summary-save-in-folder)
419 (function-item gnus-summary-save-in-file)
420 (function-item gnus-summary-save-body-in-file)
421 (function-item gnus-summary-save-in-vm)
422 (function-item gnus-summary-write-to-file)))
424 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
425 "A function generating a file name to save articles in Rmail format.
426 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
427 :group 'gnus-article-saving
430 (defcustom gnus-mail-save-name 'gnus-plain-save-name
431 "A function generating a file name to save articles in Unix mail format.
432 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
433 :group 'gnus-article-saving
436 (defcustom gnus-folder-save-name 'gnus-folder-save-name
437 "A function generating a file name to save articles in MH folder.
438 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
439 :group 'gnus-article-saving
442 (defcustom gnus-file-save-name 'gnus-numeric-save-name
443 "A function generating a file name to save articles in article format.
444 The function is called with NEWSGROUP, HEADERS, and optional
446 :group 'gnus-article-saving
449 (defcustom gnus-split-methods
450 '((gnus-article-archive-name)
451 (gnus-article-nndoc-name))
452 "*Variable used to suggest where articles are to be saved.
453 For instance, if you would like to save articles related to Gnus in
454 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
455 you could set this variable to something like:
457 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
458 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
460 This variable is an alist where the where the key is the match and the
461 value is a list of possible files to save in if the match is non-nil.
463 If the match is a string, it is used as a regexp match on the
464 article. If the match is a symbol, that symbol will be funcalled
465 from the buffer of the article to be saved with the newsgroup as the
466 parameter. If it is a list, it will be evaled in the same buffer.
468 If this form or function returns a string, this string will be used as
469 a possible file name; and if it returns a non-nil list, that list will
470 be used as possible file names."
471 :group 'gnus-article-saving
472 :type '(repeat (choice (list :value (fun) function)
473 (cons :value ("" "") regexp (repeat string))
476 (defcustom gnus-page-delimiter "^\^L"
477 "*Regexp describing what to use as article page delimiters.
478 The default value is \"^\^L\", which is a form linefeed at the
479 beginning of a line."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
484 "*The format specification for the article mode line.
485 See `gnus-summary-mode-line-format' for a closer description.
487 The following additional specs are available:
489 %w The article washing status.
490 %m The number of MIME parts in the article."
492 :group 'gnus-article-various)
494 (defcustom gnus-article-mode-hook nil
495 "*A hook for Gnus article mode."
497 :group 'gnus-article-various)
499 (when (featurep 'xemacs)
500 ;; Extracted from gnus-xmas-define in order to preserve user settings
501 (when (fboundp 'turn-off-scroll-in-place)
502 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
503 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
504 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
506 (defcustom gnus-article-menu-hook nil
507 "*Hook run after the creation of the article mode menu."
509 :group 'gnus-article-various)
511 (defcustom gnus-article-prepare-hook nil
512 "*A hook called after an article has been prepared in the article buffer."
514 :group 'gnus-article-various)
516 (defcustom gnus-article-hide-pgp-hook nil
517 "*A hook called after successfully hiding a PGP signature."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-button-face 'bold
522 "Face used for highlighting buttons in the article buffer.
524 An article button is a piece of text that you can activate by pressing
525 `RET' or `mouse-2' above it."
527 :group 'gnus-article-buttons)
529 (defcustom gnus-article-mouse-face 'highlight
530 "Face used for mouse highlighting in the article buffer.
532 Article buttons will be displayed in this face when the cursor is
535 :group 'gnus-article-buttons)
537 (defcustom gnus-signature-face 'gnus-signature-face
538 "Face used for highlighting a signature in the article buffer.
539 Obsolete; use the face `gnus-signature-face' for customizations instead."
541 :group 'gnus-article-highlight
542 :group 'gnus-article-signature)
544 (defface gnus-signature-face
547 "Face used for highlighting a signature in the article buffer."
548 :group 'gnus-article-highlight
549 :group 'gnus-article-signature)
551 (defface gnus-header-from-face
554 (:foreground "spring green"))
557 (:foreground "red3"))
560 "Face used for displaying from headers."
561 :group 'gnus-article-headers
562 :group 'gnus-article-highlight)
564 (defface gnus-header-subject-face
567 (:foreground "SeaGreen3"))
570 (:foreground "red4"))
572 (:bold t :italic t)))
573 "Face used for displaying subject headers."
574 :group 'gnus-article-headers
575 :group 'gnus-article-highlight)
577 (defface gnus-header-newsgroups-face
580 (:foreground "yellow" :italic t))
583 (:foreground "MidnightBlue" :italic t))
586 "Face used for displaying newsgroups headers."
587 :group 'gnus-article-headers
588 :group 'gnus-article-highlight)
590 (defface gnus-header-name-face
593 (:foreground "SeaGreen"))
596 (:foreground "maroon"))
599 "Face used for displaying header names."
600 :group 'gnus-article-headers
601 :group 'gnus-article-highlight)
603 (defface gnus-header-content-face
606 (:foreground "forest green" :italic t))
609 (:foreground "indianred4" :italic t))
611 (:italic t))) "Face used for displaying header content."
612 :group 'gnus-article-headers
613 :group 'gnus-article-highlight)
615 (defcustom gnus-header-face-alist
616 '(("From" nil gnus-header-from-face)
617 ("Subject" nil gnus-header-subject-face)
618 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
619 ("" gnus-header-name-face gnus-header-content-face))
620 "*Controls highlighting of article header.
622 An alist of the form (HEADER NAME CONTENT).
624 HEADER is a regular expression which should match the name of an
625 header header and NAME and CONTENT are either face names or nil.
627 The name of each header field will be displayed using the face
628 specified by the first element in the list where HEADER match the
629 header name and NAME is non-nil. Similarly, the content will be
630 displayed by the first non-nil matching CONTENT face."
631 :group 'gnus-article-headers
632 :group 'gnus-article-highlight
633 :type '(repeat (list (regexp :tag "Header")
635 (item :tag "skip" nil)
636 (face :value default))
637 (choice :tag "Content"
638 (item :tag "skip" nil)
639 (face :value default)))))
641 (defcustom gnus-article-decode-hook
642 '(article-decode-charset article-decode-encoded-words
643 article-decode-group-name)
644 "*Hook run to decode charsets in articles."
645 :group 'gnus-article-headers
648 (defcustom gnus-display-mime-function 'gnus-display-mime
649 "Function to display MIME articles."
650 :group 'gnus-article-mime
653 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
654 "Function used to decode headers.")
656 (defvar gnus-article-dumbquotes-map
675 "Table for MS-to-Latin1 translation.")
677 (defcustom gnus-ignored-mime-types nil
678 "List of MIME types that should be ignored by Gnus."
680 :group 'gnus-article-mime
681 :type '(repeat regexp))
683 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
684 "List of MIME types that should not be given buttons when rendered inline.
685 See also `gnus-buttonized-mime-types' which may override this variable."
687 :group 'gnus-article-mime
688 :type '(repeat regexp))
690 (defcustom gnus-buttonized-mime-types nil
691 "List of MIME types that should be given buttons when rendered inline.
692 If set, this variable overrides `gnus-unbuttonized-mime-types'.
693 To see e.g. security buttons you could set this to
694 `(\"multipart/signed\")'."
696 :group 'gnus-article-mime
697 :type '(repeat regexp))
699 (defcustom gnus-body-boundary-delimiter "_"
700 "String used to delimit header and body.
701 This variable is used by `gnus-article-treat-body-boundary' which can
702 be controlled by `gnus-treat-body-boundary'."
703 :group 'gnus-article-various
704 :type '(choice (item :tag "None" :value nil)
707 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
708 "*Defines the location of the faces database.
709 For information on obtaining this database of pretty pictures, please
710 see http://www.cs.indiana.edu/picons/ftp/index.html"
714 (defun gnus-picons-installed-p ()
715 "Say whether picons are installed on your machine."
716 (let ((installed nil))
717 (dolist (database gnus-picon-databases)
718 (when (file-exists-p database)
722 (defcustom gnus-article-mime-part-function nil
723 "Function called with a MIME handle as the argument.
724 This is meant for people who want to do something automatic based
725 on parts -- for instance, adding Vcard info to a database."
726 :group 'gnus-article-mime
729 (defcustom gnus-mime-multipart-functions nil
730 "An alist of MIME types to functions to display them."
732 :group 'gnus-article-mime
735 (defcustom gnus-article-date-lapsed-new-header nil
736 "Whether the X-Sent and Date headers can coexist.
737 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
738 either replace the old \"Date:\" header (if this variable is nil), or
739 be added below it (otherwise)."
741 :group 'gnus-article-headers
744 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
745 "Function called with a MIME handle as the argument.
746 This is meant for people who want to view first matched part.
747 For `undisplayed-alternative' (default), the first undisplayed
748 part or alternative part is used. For `undisplayed', the first
749 undisplayed part is used. For a function, the first part which
750 the function return `t' is used. For `nil', the first part is
753 :group 'gnus-article-mime
755 (item :tag "first" :value nil)
756 (item :tag "undisplayed" :value undisplayed)
757 (item :tag "undisplayed or alternative"
758 :value undisplayed-alternative)
761 (defcustom gnus-mime-action-alist
762 '(("save to file" . gnus-mime-save-part)
763 ("save and strip" . gnus-mime-save-part-and-strip)
764 ("display as text" . gnus-mime-inline-part)
765 ("view the part" . gnus-mime-view-part)
766 ("pipe to command" . gnus-mime-pipe-part)
767 ("toggle display" . gnus-article-press-button)
768 ("toggle display" . gnus-article-view-part-as-charset)
769 ("view as type" . gnus-mime-view-part-as-type)
770 ("internalize type" . gnus-mime-internalize-part)
771 ("externalize type" . gnus-mime-externalize-part))
772 "An alist of actions that run on the MIME attachment."
773 :group 'gnus-article-mime
774 :type '(repeat (cons (string :tag "name")
777 (defcustom gnus-mime-action-alist
778 '(("save to file" . gnus-mime-save-part)
779 ("display as text" . gnus-mime-inline-part)
780 ("view the part" . gnus-mime-view-part)
781 ("pipe to command" . gnus-mime-pipe-part)
782 ("toggle display" . gnus-article-press-button)
783 ("view as type" . gnus-mime-view-part-as-type)
784 ("internalize type" . gnus-mime-internalize-part)
785 ("externalize type" . gnus-mime-externalize-part))
786 "An alist of actions that run on the MIME attachment."
788 :group 'gnus-article-mime
789 :type '(repeat (cons (string :tag "name")
793 ;;; The treatment variables
796 (defvar gnus-part-display-hook nil
797 "Hook called on parts that are to receive treatment.")
799 (defvar gnus-article-treat-custom
800 '(choice (const :tag "Off" nil)
802 (const :tag "Header" head)
803 (const :tag "Last" last)
804 (integer :tag "Less")
805 (repeat :tag "Groups" regexp)
806 (sexp :tag "Predicate")))
808 (defvar gnus-article-treat-head-custom
809 '(choice (const :tag "Off" nil)
810 (const :tag "Header" head)))
812 (defvar gnus-article-treat-types '("text/plain")
815 (defvar gnus-inhibit-treatment nil
816 "Whether to inhibit treatment.")
818 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
819 "Highlight the signature.
820 Valid values are nil, t, `head', `last', an integer or a predicate.
821 See Info node `(gnus)Customizing Articles'."
822 :group 'gnus-article-treat
823 :type gnus-article-treat-custom)
824 (put 'gnus-treat-highlight-signature 'highlight t)
826 (defcustom gnus-treat-buttonize 100000
828 Valid values are nil, t, `head', `last', an integer or a predicate.
829 See Info node `(gnus)Customizing Articles'."
830 :group 'gnus-article-treat
831 :type gnus-article-treat-custom)
832 (put 'gnus-treat-buttonize 'highlight t)
834 (defcustom gnus-treat-buttonize-head 'head
835 "Add buttons to the head.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles' for details."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-head-custom)
840 (put 'gnus-treat-buttonize-head 'highlight t)
842 (defcustom gnus-treat-emphasize
843 (and (or window-system
845 (>= (string-to-number emacs-version) 21))
848 Valid values are nil, t, `head', `last', an integer or a predicate.
849 See Info node `(gnus)Customizing Articles' for details."
850 :group 'gnus-article-treat
851 :type gnus-article-treat-custom)
852 (put 'gnus-treat-emphasize 'highlight t)
854 (defcustom gnus-treat-strip-cr nil
855 "Remove carriage returns.
856 Valid values are nil, t, `head', `last', an integer or a predicate.
857 See Info node `(gnus)Customizing Articles' for details."
858 :group 'gnus-article-treat
859 :type gnus-article-treat-custom)
861 (defcustom gnus-treat-unsplit-urls nil
862 "Remove newlines from within URLs.
863 Valid values are nil, t, `head', `last', an integer or a predicate.
864 See Info node `(gnus)Customizing Articles' for details."
865 :group 'gnus-article-treat
866 :type gnus-article-treat-custom)
868 (defcustom gnus-treat-leading-whitespace nil
869 "Remove leading whitespace in headers.
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles' for details."
872 :group 'gnus-article-treat
873 :type gnus-article-treat-custom)
875 (defcustom gnus-treat-hide-headers 'head
877 Valid values are nil, t, `head', `last', an integer or a predicate.
878 See Info node `(gnus)Customizing Articles' for details."
879 :group 'gnus-article-treat
880 :type gnus-article-treat-head-custom)
882 (defcustom gnus-treat-hide-boring-headers nil
883 "Hide boring headers.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :type gnus-article-treat-head-custom)
889 (defcustom gnus-treat-hide-signature nil
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See Info node `(gnus)Customizing Articles' for details."
893 :group 'gnus-article-treat
894 :type gnus-article-treat-custom)
896 (defcustom gnus-treat-fill-article nil
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-hide-citation nil
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :type gnus-article-treat-custom)
910 (defcustom gnus-treat-hide-citation-maybe nil
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-custom)
917 (defcustom gnus-treat-strip-list-identifiers 'head
918 "Strip list identifiers from `gnus-list-identifiers`.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See Info node `(gnus)Customizing Articles' for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-custom)
925 (defcustom gnus-treat-strip-pgp t
926 "Strip PGP signatures.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-custom)
932 (defcustom gnus-treat-strip-pem nil
933 "Strip PEM signatures.
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See Info node `(gnus)Customizing Articles' for details."
936 :group 'gnus-article-treat
937 :type gnus-article-treat-custom)
939 (defcustom gnus-treat-strip-banner t
940 "Strip banners from articles.
941 The banner to be stripped is specified in the `banner' group parameter.
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :type gnus-article-treat-custom)
947 (defcustom gnus-treat-highlight-headers 'head
948 "Highlight the headers.
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :type gnus-article-treat-head-custom)
953 (put 'gnus-treat-highlight-headers 'highlight t)
955 (defcustom gnus-treat-highlight-citation t
956 "Highlight cited text.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :type gnus-article-treat-custom)
961 (put 'gnus-treat-highlight-citation 'highlight t)
963 (defcustom gnus-treat-date-ut nil
964 "Display the Date in UT (GMT).
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-head-custom)
970 (defcustom gnus-treat-date-local nil
971 "Display the Date in the local timezone.
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See Info node `(gnus)Customizing Articles' for details."
974 :group 'gnus-article-treat
975 :type gnus-article-treat-head-custom)
977 (defcustom gnus-treat-date-english nil
978 "Display the Date in a format that can be read aloud in English.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :type gnus-article-treat-head-custom)
984 (defcustom gnus-treat-date-lapsed nil
985 "Display the Date header in a way that says how much time has elapsed.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :type gnus-article-treat-head-custom)
991 (defcustom gnus-treat-date-original nil
992 "Display the date in the original timezone.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :type gnus-article-treat-head-custom)
998 (defcustom gnus-treat-date-iso8601 nil
999 "Display the date in the ISO8601 format.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1003 :group 'gnus-article-treat
1004 :type gnus-article-treat-head-custom)
1006 (defcustom gnus-treat-date-user-defined nil
1007 "Display the date in a user-defined format.
1008 The format is defined by the `gnus-article-time-format' variable.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-strip-headers-in-body t
1015 "Strip the X-No-Archive header line from the beginning of the body.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-strip-trailing-blank-lines nil
1023 "Strip trailing blank lines.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :type gnus-article-treat-custom)
1029 (defcustom gnus-treat-strip-leading-blank-lines nil
1030 "Strip leading blank lines.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-strip-multiple-blank-lines nil
1037 "Strip multiple blank lines.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :type gnus-article-treat-custom)
1043 (defcustom gnus-treat-unfold-headers 'head
1044 "Unfold folded header lines.
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-fold-headers nil
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-fold-newsgroups 'head
1058 "Fold the Newsgroups and Followup-To headers.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :type gnus-article-treat-custom)
1064 (defcustom gnus-treat-overstrike t
1065 "Treat overstrike highlighting.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :type gnus-article-treat-custom)
1070 (put 'gnus-treat-overstrike 'highlight t)
1072 (defcustom gnus-treat-display-xface
1073 (and (not noninteractive)
1074 (or (and (fboundp 'image-type-available-p)
1075 (image-type-available-p 'xbm)
1076 (string-match "^0x" (shell-command-to-string "uncompface")))
1077 (and (featurep 'xemacs)
1080 "Display X-Face headers.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' and Info node
1083 `(gnus)X-Face' for details."
1084 :group 'gnus-article-treat
1086 :type gnus-article-treat-head-custom)
1087 (put 'gnus-treat-display-xface 'highlight t)
1089 (defcustom gnus-treat-display-grey-xface
1090 (and (not noninteractive)
1091 (string-match "^0x" (shell-command-to-string "uncompface"))
1093 "Display grey X-Face headers.
1094 Valid values are nil, t."
1095 :group 'gnus-article-treat
1098 (put 'gnus-treat-display-grey-xface 'highlight t)
1100 (defcustom gnus-treat-display-smileys
1101 (if (or (and (featurep 'xemacs)
1103 (and (fboundp 'image-type-available-p)
1104 (image-type-available-p 'pbm)))
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' and Info node
1109 `(gnus)Smileys' for details."
1110 :group 'gnus-article-treat
1112 :type gnus-article-treat-custom)
1113 (put 'gnus-treat-display-smileys 'highlight t)
1115 (defcustom gnus-treat-from-picon
1116 (if (and (gnus-image-type-available-p 'xpm)
1117 (gnus-picons-installed-p))
1119 "Display picons in the From header.
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' and Info node
1122 `(gnus)Picons' for details."
1123 :group 'gnus-article-treat
1124 :type gnus-article-treat-head-custom)
1125 (put 'gnus-treat-from-picon 'highlight t)
1127 (defcustom gnus-treat-mail-picon
1128 (if (and (gnus-image-type-available-p 'xpm)
1129 (gnus-picons-installed-p))
1131 "Display picons in To and Cc headers.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' and Info node
1134 `(gnus)Picons' for details."
1135 :group 'gnus-article-treat
1136 :type gnus-article-treat-head-custom)
1137 (put 'gnus-treat-mail-picon 'highlight t)
1139 (defcustom gnus-treat-newsgroups-picon
1140 (if (and (gnus-image-type-available-p 'xpm)
1141 (gnus-picons-installed-p))
1143 "Display picons in the Newsgroups and Followup-To headers.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' and Info node
1146 `(gnus)Picons' for details."
1147 :group 'gnus-article-treat
1148 :type gnus-article-treat-head-custom)
1149 (put 'gnus-treat-newsgroups-picon 'highlight t)
1151 (defcustom gnus-treat-body-boundary
1152 (if (or gnus-treat-newsgroups-picon
1153 gnus-treat-mail-picon
1154 gnus-treat-from-picon)
1156 "Draw a boundary at the end of the headers.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' for details."
1160 :group 'gnus-article-treat
1161 :type gnus-article-treat-custom)
1163 (defcustom gnus-treat-capitalize-sentences nil
1164 "Capitalize sentence-starting words.
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1168 :group 'gnus-article-treat
1169 :type gnus-article-treat-custom)
1171 (defcustom gnus-treat-fill-long-lines nil
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :type gnus-article-treat-custom)
1178 (defcustom gnus-treat-play-sounds nil
1180 Valid values are nil, t, `head', `last', an integer or a predicate.
1181 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :type gnus-article-treat-custom)
1186 (defcustom gnus-treat-translate nil
1187 "Translate articles from one language to another.
1188 Valid values are nil, t, `head', `last', an integer or a predicate.
1189 See Info node `(gnus)Customizing Articles' for details."
1191 :group 'gnus-article-treat
1192 :type gnus-article-treat-custom)
1194 (defcustom gnus-treat-x-pgp-sig nil
1196 To automatically treat X-PGP-Sig, set it to head.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' for details."
1199 :group 'gnus-article-treat
1200 :group 'mime-security
1201 :type gnus-article-treat-custom)
1203 (defvar gnus-article-encrypt-protocol-alist
1204 '(("PGP" . mml2015-self-encrypt)))
1206 ;; Set to nil if more than one protocol added to
1207 ;; gnus-article-encrypt-protocol-alist.
1208 (defcustom gnus-article-encrypt-protocol "PGP"
1209 "The protocol used for encrypt articles.
1210 It is a string, such as \"PGP\". If nil, ask user."
1212 :group 'mime-security)
1214 (defcustom gnus-article-wash-function
1215 (cond ((locate-library "w3")
1216 'gnus-article-wash-html-with-w3)
1217 ((locate-library "w3m")
1218 'gnus-article-wash-html-with-w3m))
1219 "Function used for converting HTML into text."
1220 :type '(radio (function-item gnus-article-wash-html-with-w3)
1221 (function-item gnus-article-wash-html-with-w3m))
1222 :group 'gnus-article)
1224 ;;; Internal variables
1226 (defvar gnus-english-month-names
1227 '("January" "February" "March" "April" "May" "June" "July" "August"
1228 "September" "October" "November" "December"))
1230 (defvar article-goto-body-goes-to-point-min-p nil)
1231 (defvar gnus-article-wash-types nil)
1232 (defvar gnus-article-emphasis-alist nil)
1233 (defvar gnus-article-image-alist nil)
1235 (defvar gnus-article-mime-handle-alist-1 nil)
1236 (defvar gnus-treatment-function-alist
1237 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1238 (gnus-treat-strip-banner gnus-article-strip-banner)
1239 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1240 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1241 (gnus-treat-buttonize gnus-article-add-buttons)
1242 (gnus-treat-fill-article gnus-article-fill-cited-article)
1243 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1244 (gnus-treat-strip-cr gnus-article-remove-cr)
1245 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1246 (gnus-treat-date-ut gnus-article-date-ut)
1247 (gnus-treat-date-local gnus-article-date-local)
1248 (gnus-treat-date-english gnus-article-date-english)
1249 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1250 (gnus-treat-date-original gnus-article-date-original)
1251 (gnus-treat-date-user-defined gnus-article-date-user)
1252 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1253 (gnus-treat-display-xface gnus-article-display-x-face)
1254 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1255 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1256 (gnus-treat-hide-signature gnus-article-hide-signature)
1257 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1258 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1259 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1260 (gnus-treat-strip-pem gnus-article-hide-pem)
1261 (gnus-treat-from-picon gnus-treat-from-picon)
1262 (gnus-treat-mail-picon gnus-treat-mail-picon)
1263 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1264 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1265 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1266 (gnus-treat-strip-trailing-blank-lines
1267 gnus-article-remove-trailing-blank-lines)
1268 (gnus-treat-strip-leading-blank-lines
1269 gnus-article-strip-leading-blank-lines)
1270 (gnus-treat-strip-multiple-blank-lines
1271 gnus-article-strip-multiple-blank-lines)
1272 (gnus-treat-overstrike gnus-article-treat-overstrike)
1273 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1274 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1275 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1276 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1277 (gnus-treat-display-smileys gnus-treat-smiley)
1278 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1279 (gnus-treat-emphasize gnus-article-emphasize)
1280 (gnus-treat-hide-citation gnus-article-hide-citation)
1281 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1282 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1283 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1284 (gnus-treat-play-sounds gnus-earcon-display)))
1286 (defvar gnus-article-mime-handle-alist nil)
1287 (defvar article-lapsed-timer nil)
1288 (defvar gnus-article-current-summary nil)
1290 (defvar gnus-article-mode-syntax-table
1291 (let ((table (copy-syntax-table text-mode-syntax-table)))
1292 ;; This causes the citation match run O(2^n).
1293 ;; (modify-syntax-entry ?- "w" table)
1294 (modify-syntax-entry ?> ")" table)
1295 (modify-syntax-entry ?< "(" table)
1297 "Syntax table used in article mode buffers.
1298 Initialized from `text-mode-syntax-table.")
1300 (defvar gnus-save-article-buffer nil)
1302 (defvar gnus-article-mode-line-format-alist
1303 (nconc '((?w (gnus-article-wash-status) ?s)
1304 (?m (gnus-article-mime-part-status) ?s))
1305 gnus-summary-mode-line-format-alist))
1307 (defvar gnus-number-of-articles-to-be-saved nil)
1309 (defvar gnus-inhibit-hiding nil)
1311 ;;; Macros for dealing with the article buffer.
1313 (defmacro gnus-with-article-headers (&rest forms)
1315 (set-buffer gnus-article-buffer)
1317 (let ((buffer-read-only nil)
1318 (inhibit-point-motion-hooks t)
1319 (case-fold-search t))
1320 (article-narrow-to-head)
1323 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1324 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1326 (defmacro gnus-with-article-buffer (&rest forms)
1328 (set-buffer gnus-article-buffer)
1329 (let ((buffer-read-only nil))
1332 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1333 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1335 (defun gnus-article-goto-header (header)
1336 "Go to HEADER, which is a regular expression."
1337 (re-search-forward (concat "^\\(" header "\\):") nil t))
1339 (defsubst gnus-article-hide-text (b e props)
1340 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1341 (gnus-add-text-properties-when 'article-type nil b e props)
1342 (when (memq 'intangible props)
1344 (max (1- b) (point-min))
1345 b 'intangible (cddr (memq 'intangible props)))))
1347 (defsubst gnus-article-unhide-text (b e)
1348 "Remove hidden text properties from region between B and E."
1349 (remove-text-properties b e gnus-hidden-properties)
1350 (when (memq 'intangible gnus-hidden-properties)
1351 (put-text-property (max (1- b) (point-min))
1352 b 'intangible nil)))
1354 (defun gnus-article-hide-text-type (b e type)
1355 "Hide text of TYPE between B and E."
1356 (gnus-add-wash-type type)
1357 (gnus-article-hide-text
1358 b e (cons 'article-type (cons type gnus-hidden-properties))))
1360 (defun gnus-article-unhide-text-type (b e type)
1361 "Unhide text of TYPE between B and E."
1362 (gnus-delete-wash-type type)
1363 (remove-text-properties
1364 b e (cons 'article-type (cons type gnus-hidden-properties)))
1365 (when (memq 'intangible gnus-hidden-properties)
1366 (put-text-property (max (1- b) (point-min))
1367 b 'intangible nil)))
1369 (defun gnus-article-hide-text-of-type (type)
1370 "Hide text of TYPE in the current buffer."
1372 (let ((b (point-min))
1374 (while (setq b (text-property-any b e 'article-type type))
1375 (add-text-properties b (incf b) gnus-hidden-properties)))))
1377 (defun gnus-article-delete-text-of-type (type)
1378 "Delete text of TYPE in the current buffer."
1380 (let ((b (point-min)))
1381 (while (setq b (text-property-any b (point-max) 'article-type type))
1383 b (or (text-property-not-all b (point-max) 'article-type type)
1386 (defun gnus-article-delete-invisible-text ()
1387 "Delete all invisible text in the current buffer."
1389 (let ((b (point-min)))
1390 (while (setq b (text-property-any b (point-max) 'invisible t))
1392 b (or (text-property-not-all b (point-max) 'invisible t)
1395 (defun gnus-article-text-type-exists-p (type)
1396 "Say whether any text of type TYPE exists in the buffer."
1397 (text-property-any (point-min) (point-max) 'article-type type))
1399 (defsubst gnus-article-header-rank ()
1400 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1401 (let ((list gnus-sorted-header-list)
1404 (when (looking-at (car list))
1406 (setq list (cdr list))
1410 (defun article-hide-headers (&optional arg delete)
1411 "Hide unwanted headers and possibly sort them as well."
1413 ;; This function might be inhibited.
1414 (unless gnus-inhibit-hiding
1417 (let ((buffer-read-only nil)
1418 (case-fold-search t)
1419 (max (1+ (length gnus-sorted-header-list)))
1420 (ignored (when (not gnus-visible-headers)
1421 (cond ((stringp gnus-ignored-headers)
1422 gnus-ignored-headers)
1423 ((listp gnus-ignored-headers)
1424 (mapconcat 'identity gnus-ignored-headers
1427 (cond ((stringp gnus-visible-headers)
1428 gnus-visible-headers)
1429 ((and gnus-visible-headers
1430 (listp gnus-visible-headers))
1431 (mapconcat 'identity gnus-visible-headers "\\|"))))
1432 (inhibit-point-motion-hooks t)
1434 ;; First we narrow to just the headers.
1435 (article-narrow-to-head)
1436 ;; Hide any "From " lines at the beginning of (mail) articles.
1437 (while (looking-at "From ")
1440 (delete-region (point-min) (point)))
1441 ;; Then treat the rest of the header lines.
1442 ;; Then we use the two regular expressions
1443 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1444 ;; select which header lines is to remain visible in the
1446 (while (re-search-forward "^[^ \t:]*:" nil t)
1448 ;; Mark the rank of the header.
1450 (point) (1+ (point)) 'message-rank
1451 (if (or (and visible (looking-at visible))
1453 (not (looking-at ignored))))
1454 (gnus-article-header-rank)
1457 (message-sort-headers-1)
1458 (when (setq beg (text-property-any
1459 (point-min) (point-max) 'message-rank (+ 2 max)))
1460 ;; We delete the unwanted headers.
1461 (gnus-add-wash-type 'headers)
1462 (add-text-properties (point-min) (+ 5 (point-min))
1463 '(article-type headers dummy-invisible t))
1464 (delete-region beg (point-max))))))))
1466 (defun article-hide-boring-headers (&optional arg)
1467 "Toggle hiding of headers that aren't very interesting.
1468 If given a negative prefix, always show; if given a positive prefix,
1470 (interactive (gnus-article-hidden-arg))
1471 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1472 (not gnus-show-all-headers))
1475 (let ((buffer-read-only nil)
1476 (list gnus-boring-article-headers)
1477 (inhibit-point-motion-hooks t)
1479 (article-narrow-to-head)
1481 (setq elem (pop list))
1482 (goto-char (point-min))
1484 ;; Hide empty headers.
1486 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1488 (gnus-article-hide-text-type
1489 (progn (beginning-of-line) (point))
1492 (if (re-search-forward "^[^ \t]" nil t)
1496 ;; Hide boring Newsgroups header.
1497 ((eq elem 'newsgroups)
1498 (when (gnus-string-equal
1499 (gnus-fetch-field "newsgroups")
1500 (gnus-group-real-name
1501 (if (boundp 'gnus-newsgroup-name)
1504 (gnus-article-hide-header "newsgroups")))
1505 ((eq elem 'to-address)
1506 (let ((to (message-fetch-field "to"))
1508 (gnus-parameter-to-address
1509 (if (boundp 'gnus-newsgroup-name)
1510 gnus-newsgroup-name ""))))
1511 (when (and to to-address
1514 ;; only one address in To
1515 (nth 1 (mail-extract-address-components to))
1517 (gnus-article-hide-header "to"))))
1518 ((eq elem 'followup-to)
1519 (when (gnus-string-equal
1520 (message-fetch-field "followup-to")
1521 (message-fetch-field "newsgroups"))
1522 (gnus-article-hide-header "followup-to")))
1523 ((eq elem 'reply-to)
1524 (let ((from (message-fetch-field "from"))
1525 (reply-to (message-fetch-field "reply-to")))
1530 (nth 1 (mail-extract-address-components from))
1531 (nth 1 (mail-extract-address-components reply-to)))))
1532 (gnus-article-hide-header "reply-to"))))
1534 (let ((date (message-fetch-field "date")))
1536 (< (days-between (current-time-string) date)
1538 (gnus-article-hide-header "date"))))
1540 (let ((to (message-fetch-field "to"))
1541 (cc (message-fetch-field "cc")))
1542 (when (> (length to) 1024)
1543 (gnus-article-hide-header "to"))
1544 (when (> (length cc) 1024)
1545 (gnus-article-hide-header "cc"))))
1549 (goto-char (point-min))
1550 (while (re-search-forward "^to:" nil t)
1551 (setq to-count (1+ to-count)))
1552 (when (> to-count 1)
1553 (while (> to-count 0)
1554 (goto-char (point-min))
1556 (re-search-forward "^to:" nil nil to-count)
1558 (narrow-to-region (point) (point-max))
1559 (gnus-article-hide-header "to"))
1560 (setq to-count (1- to-count))))
1561 (goto-char (point-min))
1562 (while (re-search-forward "^cc:" nil t)
1563 (setq cc-count (1+ cc-count)))
1564 (when (> cc-count 1)
1565 (while (> cc-count 0)
1566 (goto-char (point-min))
1568 (re-search-forward "^cc:" nil nil cc-count)
1570 (narrow-to-region (point) (point-max))
1571 (gnus-article-hide-header "cc"))
1572 (setq cc-count (1- cc-count)))))))))))))
1574 (defun gnus-article-hide-header (header)
1576 (goto-char (point-min))
1577 (when (re-search-forward (concat "^" header ":") nil t)
1578 (gnus-article-hide-text-type
1579 (progn (beginning-of-line) (point))
1582 (if (re-search-forward "^[^ \t]" nil t)
1587 (defvar gnus-article-normalized-header-length 40
1588 "Length of normalized headers.")
1590 (defun article-normalize-headers ()
1591 "Make all header lines 40 characters long."
1593 (let ((buffer-read-only nil)
1597 (article-narrow-to-head)
1600 ((< (setq column (- (gnus-point-at-eol) (point)))
1601 gnus-article-normalized-header-length)
1603 (insert (make-string
1604 (- gnus-article-normalized-header-length column)
1606 ((> column gnus-article-normalized-header-length)
1607 (gnus-put-text-property
1609 (forward-char gnus-article-normalized-header-length)
1616 (forward-line 1))))))
1618 (defun article-treat-dumbquotes ()
1619 "Translate M****s*** sm*rtq**t*s into proper text.
1620 Note that this function guesses whether a character is a sm*rtq**t* or
1621 not, so it should only be used interactively.
1623 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1624 in an attempt to provide more quoting characters. If you see
1625 something like \\222 or \\264 where you're expecting some kind of
1626 apostrophe or quotation mark, then try this wash."
1628 (article-translate-strings gnus-article-dumbquotes-map))
1630 (defun article-translate-characters (from to)
1631 "Translate all characters in the body of the article according to FROM and TO.
1632 FROM is a string of characters to translate from; to is a string of
1633 characters to translate to."
1635 (when (article-goto-body)
1636 (let ((buffer-read-only nil)
1637 (x (make-string 225 ?x))
1639 (while (< (incf i) (length x))
1642 (while (< i (length from))
1643 (aset x (aref from i) (aref to i))
1645 (translate-region (point) (point-max) x)))))
1647 (defun article-translate-strings (map)
1648 "Translate all string in the body of the article according to MAP.
1649 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1651 (when (article-goto-body)
1652 (let ((buffer-read-only nil)
1654 (while (setq elem (pop map))
1656 (while (search-forward (car elem) nil t)
1657 (replace-match (cadr elem)))))))))
1659 (defun article-treat-overstrike ()
1660 "Translate overstrikes into bold text."
1663 (when (article-goto-body)
1664 (let ((buffer-read-only nil))
1665 (while (search-forward "\b" nil t)
1666 (let ((next (char-after))
1667 (previous (char-after (- (point) 2))))
1668 ;; We do the boldification/underlining by hiding the
1669 ;; overstrikes and putting the proper text property
1673 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1674 (put-text-property (point) (1+ (point)) 'face 'bold))
1676 (gnus-article-hide-text-type
1677 (1- (point)) (1+ (point)) 'overstrike)
1679 (- (point) 2) (1- (point)) 'face 'underline))
1681 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1683 (point) (1+ (point)) 'face 'underline)))))))))
1685 (defun gnus-article-treat-unfold-headers ()
1686 "Unfold folded message headers.
1687 Only the headers that fit into the current window width will be
1690 (gnus-with-article-headers
1694 (mail-header-narrow-to-field)
1695 (let ((header (buffer-substring (point-min) (point-max))))
1698 (goto-char (point-min))
1699 (while (re-search-forward "\n[\t ]" nil t)
1700 (replace-match " " t t)))
1701 (setq length (- (point-max) (point-min) 1)))
1702 (when (< length (window-width))
1703 (while (re-search-forward "\n[\t ]" nil t)
1704 (replace-match " " t t)))
1705 (goto-char (point-max)))))))
1707 (defun gnus-article-treat-fold-headers ()
1708 "Fold message headers."
1710 (gnus-with-article-headers
1713 (mail-header-narrow-to-field)
1714 (mail-header-fold-field)
1715 (goto-char (point-max))))))
1717 (defun gnus-treat-smiley ()
1718 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1720 (gnus-with-article-buffer
1721 (if (memq 'smiley gnus-article-wash-types)
1722 (gnus-delete-images 'smiley)
1724 (let ((images (smiley-region (point) (point-max))))
1726 (gnus-add-wash-type 'smiley)
1727 (dolist (image images)
1728 (gnus-add-image 'smiley image)))))))
1730 (defun gnus-article-remove-images ()
1731 "Remove all images from the article buffer."
1733 (gnus-with-article-buffer
1734 (dolist (elem gnus-article-image-alist)
1735 (gnus-delete-images (car elem)))))
1737 (defun gnus-article-treat-fold-newsgroups ()
1738 "Unfold folded message headers.
1739 Only the headers that fit into the current window width will be
1742 (gnus-with-article-headers
1743 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1745 (mail-header-narrow-to-field)
1746 (while (re-search-forward ", *" nil t)
1747 (replace-match ", " t t))
1748 (mail-header-fold-field)
1749 (goto-char (point-max))))))
1751 (defun gnus-article-treat-body-boundary ()
1752 "Place a boundary line at the end of the headers."
1754 (when (and gnus-body-boundary-delimiter
1755 (> (length gnus-body-boundary-delimiter) 0))
1756 (gnus-with-article-headers
1757 (goto-char (point-max))
1758 (let ((start (point)))
1759 (insert "X-Boundary: ")
1760 (gnus-add-text-properties start (point) '(invisible t intangible t))
1762 (while (>= (1- (window-width)) (length str))
1763 (setq str (concat str gnus-body-boundary-delimiter)))
1764 (substring str 0 (1- (window-width))))
1766 (gnus-add-text-properties start (point) '(gnus-decoration 'header))))))
1768 (defun article-fill-long-lines ()
1769 "Fill lines that are wider than the window width."
1772 (let ((buffer-read-only nil)
1773 (width (window-width (get-buffer-window (current-buffer)))))
1776 (let ((adaptive-fill-mode nil)) ;Why? -sm
1779 (when (>= (current-column) (min fill-column width))
1780 (narrow-to-region (point) (gnus-point-at-bol))
1781 (fill-paragraph nil)
1782 (goto-char (point-max))
1784 (forward-line 1)))))))
1786 (defun article-capitalize-sentences ()
1787 "Capitalize the first word in each sentence."
1790 (let ((buffer-read-only nil)
1791 (paragraph-start "^[\n\^L]"))
1795 (forward-sentence)))))
1797 (defun article-remove-cr ()
1798 "Remove trailing CRs and then translate remaining CRs into LFs."
1801 (let ((buffer-read-only nil))
1802 (goto-char (point-min))
1803 (while (re-search-forward "\r+$" nil t)
1804 (replace-match "" t t))
1805 (goto-char (point-min))
1806 (while (search-forward "\r" nil t)
1807 (replace-match "\n" t t)))))
1809 (defun article-remove-trailing-blank-lines ()
1810 "Remove all trailing blank lines from the article."
1813 (let ((buffer-read-only nil))
1814 (goto-char (point-max))
1818 (while (and (not (bobp))
1819 (looking-at "^[ \t]*$")
1820 (not (gnus-annotation-in-region-p
1821 (point) (gnus-point-at-eol))))
1826 (defun article-display-x-face (&optional force)
1827 "Look for an X-Face header and display it if present."
1828 (interactive (list 'force))
1829 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1830 (gnus-with-article-headers
1831 ;; Delete the old process, if any.
1832 (when (process-status "article-x-face")
1833 (delete-process "article-x-face"))
1834 (if (memq 'xface gnus-article-wash-types)
1835 ;; We have already displayed X-Faces, so we remove them
1837 (gnus-delete-images 'xface)
1839 (let (x-faces from face grey)
1841 (when (and wash-face-p
1843 (goto-char (point-min))
1844 (not (re-search-forward
1845 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1846 (gnus-buffer-live-p gnus-original-article-buffer))
1847 ;; If type `W f', use gnus-original-article-buffer,
1848 ;; otherwise use the current buffer because displaying
1849 ;; RFC822 parts calls this function too.
1850 (set-buffer gnus-original-article-buffer))
1852 (mail-narrow-to-head)
1854 (if gnus-treat-display-grey-xface
1855 "x-face\\(-[0-9]+\\)?"
1857 (while (gnus-article-goto-header regexp)
1858 (when (match-beginning 2)
1860 (push (mail-header-field-value) x-faces)))
1861 (setq from (message-fetch-field "from"))))
1863 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1866 (setq image (gnus-create-image xpm 'xpm t))
1867 (gnus-article-goto-header "from")
1869 (insert "From: [no `from' set]\n")
1871 (gnus-add-wash-type 'xface)
1872 (gnus-add-image 'xface image)
1873 (gnus-put-image image)))
1874 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1875 ;; single external face.
1876 (when (stringp gnus-article-x-face-command)
1877 (setq x-faces (list (car x-faces))))
1878 (while (and (setq face (pop x-faces))
1879 gnus-article-x-face-command
1881 ;; Check whether this face is censored.
1882 (not gnus-article-x-face-too-ugly)
1883 (and gnus-article-x-face-too-ugly from
1884 (not (string-match gnus-article-x-face-too-ugly
1886 ;; We display the face.
1887 (if (symbolp gnus-article-x-face-command)
1888 ;; The command is a lisp function, so we call it.
1889 (if (gnus-functionp gnus-article-x-face-command)
1890 (funcall gnus-article-x-face-command face)
1891 (error "%s is not a function" gnus-article-x-face-command))
1892 ;; The command is a string, so we interpret the command
1893 ;; as a, well, command, and fork it off.
1894 (let ((process-connection-type nil))
1895 (process-kill-without-query
1897 "article-x-face" nil shell-file-name shell-command-switch
1898 gnus-article-x-face-command))
1901 (process-send-region "article-x-face"
1902 (point-min) (point-max)))
1903 (process-send-eof "article-x-face"))))))))))
1905 (defun article-decode-mime-words ()
1906 "Decode all MIME-encoded words in the article."
1909 (set-buffer gnus-article-buffer)
1910 (let ((inhibit-point-motion-hooks t)
1912 (mail-parse-charset gnus-newsgroup-charset)
1913 (mail-parse-ignored-charsets
1914 (save-excursion (set-buffer gnus-summary-buffer)
1915 gnus-newsgroup-ignored-charsets)))
1916 (mail-decode-encoded-word-region (point-min) (point-max)))))
1918 (defun article-decode-charset (&optional prompt)
1919 "Decode charset-encoded text in the article.
1920 If PROMPT (the prefix), prompt for a coding system to use."
1922 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1924 (mail-parse-charset gnus-newsgroup-charset)
1925 (mail-parse-ignored-charsets
1926 (save-excursion (condition-case nil
1927 (set-buffer gnus-summary-buffer)
1929 gnus-newsgroup-ignored-charsets))
1930 ct cte ctl charset format)
1933 (article-narrow-to-head)
1934 (setq ct (message-fetch-field "Content-Type" t)
1935 cte (message-fetch-field "Content-Transfer-Encoding" t)
1936 ctl (and ct (ignore-errors
1937 (mail-header-parse-content-type ct)))
1940 (mm-read-coding-system "Charset to decode: "))
1942 (mail-content-type-get ctl 'charset)))
1943 format (and ctl (mail-content-type-get ctl 'format)))
1945 (setq cte (mail-header-strip cte)))
1946 (if (and ctl (not (string-match "/" (car ctl))))
1948 (goto-char (point-max)))
1951 (narrow-to-region (point) (point-max))
1952 (when (and (eq mail-parse-charset 'gnus-decoded)
1953 (eq (mm-body-7-or-8) '8bit))
1954 ;; The text code could have been decoded.
1955 (setq charset mail-parse-charset))
1956 (when (and (or (not ctl)
1957 (equal (car ctl) "text/plain"))
1958 (not format)) ;; article with format will decode later.
1960 charset (and cte (intern (downcase
1961 (gnus-strip-whitespace cte))))
1964 (defun article-decode-encoded-words ()
1965 "Remove encoded-word encoding from headers."
1966 (let ((inhibit-point-motion-hooks t)
1967 (mail-parse-charset gnus-newsgroup-charset)
1968 (mail-parse-ignored-charsets
1969 (save-excursion (condition-case nil
1970 (set-buffer gnus-summary-buffer)
1972 gnus-newsgroup-ignored-charsets))
1975 (article-narrow-to-head)
1976 (funcall gnus-decode-header-function (point-min) (point-max)))))
1978 (defun article-decode-group-name ()
1979 "Decode group names in `Newsgroups:'."
1980 (let ((inhibit-point-motion-hooks t)
1982 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1983 (when (and (or gnus-group-name-charset-method-alist
1984 gnus-group-name-charset-group-alist)
1985 (gnus-buffer-live-p gnus-original-article-buffer))
1986 (when (nnmail-fetch-field "Newsgroups")
1987 (nnheader-replace-header "Newsgroups"
1988 (gnus-decode-newsgroups
1989 (with-current-buffer
1990 gnus-original-article-buffer
1991 (nnmail-fetch-field "Newsgroups"))
1992 gnus-newsgroup-name method)))
1993 (when (nnmail-fetch-field "Followup-To")
1994 (nnheader-replace-header "Followup-To"
1995 (gnus-decode-newsgroups
1996 (with-current-buffer
1997 gnus-original-article-buffer
1998 (nnmail-fetch-field "Followup-To"))
1999 gnus-newsgroup-name method))))))
2001 (defun article-de-quoted-unreadable (&optional force read-charset)
2002 "Translate a quoted-printable-encoded article.
2003 If FORCE, decode the article whether it is marked as quoted-printable
2005 If READ-CHARSET, ask for a coding system."
2006 (interactive (list 'force current-prefix-arg))
2008 (let ((buffer-read-only nil) type charset)
2009 (if (gnus-buffer-live-p gnus-original-article-buffer)
2010 (with-current-buffer gnus-original-article-buffer
2012 (gnus-fetch-field "content-transfer-encoding"))
2013 (let* ((ct (gnus-fetch-field "content-type"))
2016 (mail-header-parse-content-type ct)))))
2017 (setq charset (and ctl
2018 (mail-content-type-get ctl 'charset)))
2019 (if (stringp charset)
2020 (setq charset (intern (downcase charset)))))))
2022 (setq charset (mm-read-coding-system "Charset: " charset)))
2024 (setq charset gnus-newsgroup-charset))
2026 (and type (let ((case-fold-search t))
2027 (string-match "quoted-printable" type))))
2029 (quoted-printable-decode-region
2030 (point) (point-max) (mm-charset-to-coding-system charset))))))
2032 (defun article-de-base64-unreadable (&optional force read-charset)
2033 "Translate a base64 article.
2034 If FORCE, decode the article whether it is marked as base64 not.
2035 If READ-CHARSET, ask for a coding system."
2036 (interactive (list 'force current-prefix-arg))
2038 (let ((buffer-read-only nil) type charset)
2039 (if (gnus-buffer-live-p gnus-original-article-buffer)
2040 (with-current-buffer gnus-original-article-buffer
2042 (gnus-fetch-field "content-transfer-encoding"))
2043 (let* ((ct (gnus-fetch-field "content-type"))
2046 (mail-header-parse-content-type ct)))))
2047 (setq charset (and ctl
2048 (mail-content-type-get ctl 'charset)))
2049 (if (stringp charset)
2050 (setq charset (intern (downcase charset)))))))
2052 (setq charset (mm-read-coding-system "Charset: " charset)))
2054 (setq charset gnus-newsgroup-charset))
2056 (and type (let ((case-fold-search t))
2057 (string-match "base64" type))))
2060 (narrow-to-region (point) (point-max))
2061 (base64-decode-region (point-min) (point-max))
2062 (mm-decode-coding-region
2063 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2068 (defun article-decode-HZ ()
2069 "Translate a HZ-encoded article."
2073 (let ((buffer-read-only nil))
2074 (rfc1843-decode-region (point-min) (point-max)))))
2076 (defun article-unsplit-urls ()
2077 "Remove the newlines that some other mailers insert into URLs."
2080 (let ((buffer-read-only nil))
2081 (goto-char (point-min))
2082 (while (re-search-forward
2083 "^\\(\\(https?\\|ftp\\)://\\S-+\\)\n\\(\\S-+\\)" nil t)
2084 (replace-match "\\1\\3" t)))))
2086 (defun article-wash-html (&optional read-charset)
2087 "Format an html article.
2088 If READ-CHARSET, ask for a coding system."
2091 (let ((buffer-read-only nil)
2093 (if (gnus-buffer-live-p gnus-original-article-buffer)
2094 (with-current-buffer gnus-original-article-buffer
2095 (let* ((ct (gnus-fetch-field "content-type"))
2098 (mail-header-parse-content-type ct)))))
2099 (setq charset (and ctl
2100 (mail-content-type-get ctl 'charset)))
2101 (if (stringp charset)
2102 (setq charset (intern (downcase charset)))))))
2104 (setq charset (mm-read-coding-system "Charset: " charset)))
2106 (setq charset gnus-newsgroup-charset))
2108 (save-window-excursion
2110 (narrow-to-region (point) (point-max))
2111 (funcall gnus-article-wash-function))))))
2113 (defun gnus-article-wash-html-with-w3 ()
2114 "Wash the current buffer with w3."
2116 (let ((w3-strict-width (window-width))
2117 (url-standalone-mode t)
2118 (url-gateway-unplugged t)
2119 (w3-honor-stylesheets nil)
2120 (w3-delay-image-loads t))
2122 (w3-region (point-min) (point-max))
2125 (defun gnus-article-wash-html-with-w3m ()
2126 "Wash the current buffer with emacs-w3m."
2129 (narrow-to-region (point) (point-max))
2130 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2133 (w3m-display-inline-images mm-inline-text-html-with-images)
2134 w3m-force-redisplay)
2135 (w3m-region (point-min) (point-max)))
2136 (when mm-inline-text-html-with-w3m-keymap
2137 (add-text-properties
2138 (point-min) (point-max)
2139 (append '(mm-inline-text-html-with-w3m t)
2140 (gnus-local-map-property mm-w3m-mode-map))))))
2142 (defun article-hide-list-identifiers ()
2143 "Remove list identifies from the Subject header.
2144 The `gnus-list-identifiers' variable specifies what to do."
2146 (let ((inhibit-point-motion-hooks t)
2147 (regexp (if (consp gnus-list-identifiers)
2148 (mapconcat 'identity gnus-list-identifiers " *\\|")
2149 gnus-list-identifiers))
2154 (article-narrow-to-head)
2155 (goto-char (point-min))
2156 (while (re-search-forward
2157 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2159 (delete-region (match-beginning 2) (match-end 0))
2160 (beginning-of-line))
2161 (when (re-search-forward
2162 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2163 (delete-region (match-beginning 1) (match-end 1))))))))
2165 (defun article-hide-pgp ()
2166 "Remove any PGP headers and signatures in the current article."
2170 (let ((inhibit-point-motion-hooks t)
2171 buffer-read-only beg end)
2173 ;; Hide the "header".
2174 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2175 (gnus-add-wash-type 'pgp)
2176 (delete-region (match-beginning 0) (match-end 0))
2177 ;; Remove armor headers (rfc2440 6.2)
2178 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2181 ;; Hide the actual signature.
2182 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2183 (setq end (1+ (match-beginning 0)))
2186 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2188 ;; Perhaps we shouldn't hide to the end of the buffer
2189 ;; if there is no end to the signature?
2191 ;; Hide "- " PGP quotation markers.
2193 (narrow-to-region beg end)
2194 (goto-char (point-min))
2195 (while (re-search-forward "^- " nil t)
2197 (match-beginning 0) (match-end 0)))
2199 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2201 (defun article-hide-pem (&optional arg)
2202 "Toggle hiding of any PEM headers and signatures in the current article.
2203 If given a negative prefix, always show; if given a positive prefix,
2205 (interactive (gnus-article-hidden-arg))
2206 (unless (gnus-article-check-hidden-text 'pem arg)
2208 (let (buffer-read-only end)
2209 (goto-char (point-min))
2210 ;; Hide the horrendously ugly "header".
2211 (when (and (search-forward
2212 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2214 (setq end (1+ (match-beginning 0))))
2215 (gnus-add-wash-type 'pem)
2216 (gnus-article-hide-text-type
2218 (if (search-forward "\n\n" nil t)
2222 ;; Hide the trailer as well
2223 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2225 (gnus-article-hide-text-type
2226 (match-beginning 0) (match-end 0) 'pem)))))))
2228 (defun article-strip-banner ()
2229 "Strip the banner specified by the `banner' group parameter."
2233 (let ((inhibit-point-motion-hooks t)
2234 (banner (gnus-parameter-banner gnus-newsgroup-name))
2235 (gnus-signature-limit nil)
2236 buffer-read-only beg end)
2240 ((eq banner 'signature)
2241 (when (gnus-article-narrow-to-signature)
2244 (delete-region (point) (point-max))))
2246 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2247 (while (re-search-forward banner nil t)
2248 (delete-region (match-beginning 0) (match-end 0)))))
2250 (while (re-search-forward banner nil t)
2251 (delete-region (match-beginning 0) (match-end 0))))))))))
2253 (defun article-babel ()
2254 "Translate article using an online translation service."
2258 (set-buffer gnus-article-buffer)
2259 (when (article-goto-body)
2260 (let* ((buffer-read-only nil)
2263 (orig (buffer-substring start end))
2264 (trans (babel-as-string orig)))
2266 (narrow-to-region start end)
2267 (delete-region start end)
2270 (defun article-hide-signature (&optional arg)
2271 "Hide the signature in the current article.
2272 If given a negative prefix, always show; if given a positive prefix,
2274 (interactive (gnus-article-hidden-arg))
2275 (unless (gnus-article-check-hidden-text 'signature arg)
2278 (let ((buffer-read-only nil))
2279 (when (gnus-article-narrow-to-signature)
2280 (gnus-article-hide-text-type
2281 (point-min) (point-max) 'signature))))))
2282 (gnus-set-mode-line 'article))
2284 (defun article-strip-headers-in-body ()
2285 "Strip offensive headers from bodies."
2289 (let ((case-fold-search t))
2290 (when (looking-at "x-no-archive:")
2291 (gnus-delete-line)))))
2293 (defun article-strip-leading-blank-lines ()
2294 "Remove all blank lines from the beginning of the article."
2297 (let ((inhibit-point-motion-hooks t)
2299 (when (article-goto-body)
2300 (while (and (not (eobp))
2301 (looking-at "[ \t]*$"))
2302 (gnus-delete-line))))))
2304 (defun article-narrow-to-head ()
2305 "Narrow the buffer to the head of the message.
2306 Point is left at the beginning of the narrowed-to region."
2308 (goto-char (point-min))
2309 (if (search-forward "\n\n" nil 1)
2312 (goto-char (point-min)))
2314 (defun article-goto-body ()
2315 "Place point at the start of the body."
2316 (goto-char (point-min))
2318 ;; This variable is only bound when dealing with separate
2320 (article-goto-body-goes-to-point-min-p
2322 ((search-forward "\n\n" nil t)
2325 (goto-char (point-max))
2328 (defun article-strip-multiple-blank-lines ()
2329 "Replace consecutive blank lines with one empty line."
2332 (let ((inhibit-point-motion-hooks t)
2334 ;; First make all blank lines empty.
2336 (while (re-search-forward "^[ \t]+$" nil t)
2337 (unless (gnus-annotation-in-region-p
2338 (match-beginning 0) (match-end 0))
2339 (replace-match "" nil t)))
2340 ;; Then replace multiple empty lines with a single empty line.
2342 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2343 (unless (gnus-annotation-in-region-p
2344 (match-beginning 0) (match-end 0))
2345 (delete-region (match-beginning 1) (match-end 1)))))))
2347 (defun article-strip-leading-space ()
2348 "Remove all white space from the beginning of the lines in the article."
2351 (let ((inhibit-point-motion-hooks t)
2354 (while (re-search-forward "^[ \t]+" nil t)
2355 (replace-match "" t t)))))
2357 (defun article-strip-trailing-space ()
2358 "Remove all white space from the end of the lines in the article."
2361 (let ((inhibit-point-motion-hooks t)
2364 (while (re-search-forward "[ \t]+$" nil t)
2365 (replace-match "" t t)))))
2367 (defun article-strip-blank-lines ()
2368 "Strip leading, trailing and multiple blank lines."
2370 (article-strip-leading-blank-lines)
2371 (article-remove-trailing-blank-lines)
2372 (article-strip-multiple-blank-lines))
2374 (defun article-strip-all-blank-lines ()
2375 "Strip all blank lines."
2378 (let ((inhibit-point-motion-hooks t)
2381 (while (re-search-forward "^[ \t]*\n" nil t)
2382 (replace-match "" t t)))))
2384 (defun gnus-article-narrow-to-signature ()
2385 "Narrow to the signature; return t if a signature is found, else nil."
2386 (let ((inhibit-point-motion-hooks t))
2387 (when (gnus-article-search-signature)
2389 ;; Check whether we have some limits to what we consider
2390 ;; to be a signature.
2391 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2392 (list gnus-signature-limit)))
2394 (while (setq limit (pop limits))
2395 (if (or (and (integerp limit)
2396 (< (- (point-max) (point)) limit))
2398 (< (count-lines (point) (point-max)) limit))
2399 (and (gnus-functionp limit)
2401 (and (stringp limit)
2402 (not (re-search-forward limit nil t))))
2403 () ; This limit did not succeed.
2407 (narrow-to-region (point) (point-max))
2410 (defun gnus-article-search-signature ()
2411 "Search the current buffer for the signature separator.
2412 Put point at the beginning of the signature separator."
2413 (let ((cur (point)))
2414 (goto-char (point-max))
2415 (if (if (stringp gnus-signature-separator)
2416 (re-search-backward gnus-signature-separator nil t)
2417 (let ((seps gnus-signature-separator))
2419 (not (re-search-backward (car seps) nil t)))
2426 (defun gnus-article-hidden-arg ()
2427 "Return the current prefix arg as a number, or 0 if no prefix."
2428 (list (if current-prefix-arg
2429 (prefix-numeric-value current-prefix-arg)
2432 (defun gnus-article-check-hidden-text (type arg)
2433 "Return nil if hiding is necessary.
2434 Arg can be nil or a number. nil and positive means hide, negative
2435 means show, 0 means toggle."
2438 (let ((hide (gnus-article-hidden-text-p type)))
2444 (gnus-article-show-hidden-text type)
2447 (if (eq hide 'hidden)
2449 (gnus-article-show-hidden-text type)
2453 (defun gnus-article-hidden-text-p (type)
2454 "Say whether the current buffer contains hidden text of type TYPE."
2455 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2457 (not (get-text-property pos 'invisible))
2458 (not (get-text-property pos 'dummy-invisible)))
2460 (text-property-any (1+ pos) (point-max) 'article-type type)))
2465 (defun gnus-article-show-hidden-text (type &optional dummy)
2466 "Show all hidden text of type TYPE.
2467 Originally it is hide instead of DUMMY."
2468 (let ((buffer-read-only nil)
2469 (inhibit-point-motion-hooks t))
2470 (gnus-remove-text-properties-when
2472 (point-min) (point-max)
2473 (cons 'article-type (cons type
2474 gnus-hidden-properties)))
2475 (gnus-delete-wash-type type)))
2477 (defconst article-time-units
2478 `((year . ,(* 365.25 24 60 60))
2479 (week . ,(* 7 24 60 60))
2480 (day . ,(* 24 60 60))
2484 "Mapping from time units to seconds.")
2486 (defun article-date-ut (&optional type highlight header)
2487 "Convert DATE date to universal time in the current article.
2488 If TYPE is `local', convert to local time; if it is `lapsed', output
2489 how much time has lapsed since DATE. For `lapsed', the value of
2490 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2491 should replace the \"Date:\" one, or should be added below it."
2492 (interactive (list 'ut t))
2493 (let* ((header (or header
2494 (message-fetch-field "date")
2496 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2499 ((not gnus-article-date-lapsed-new-header)
2505 (date (if (vectorp header) (mail-header-date header)
2507 (inhibit-point-motion-hooks t)
2512 (article-narrow-to-head)
2513 (when (re-search-forward tdate-regexp nil t)
2514 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2515 date (or (get-text-property (gnus-point-at-bol)
2518 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2520 (when (and date (not (string= date "")))
2521 (goto-char (point-min))
2522 (let ((buffer-read-only nil))
2523 ;; Delete any old Date headers.
2524 (while (re-search-forward date-regexp nil t)
2526 (delete-region (progn (beginning-of-line) (point))
2527 (progn (forward-line 1) (point)))
2528 (delete-region (progn (beginning-of-line) (point))
2529 (progn (end-of-line) (point)))
2530 (setq pos (point))))
2531 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2533 (if pos (goto-char pos))
2534 (insert (article-make-date-line date (or type 'ut)))
2540 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2541 (put-text-property (match-beginning 1) (1+ (match-end 1))
2542 'original-date date)
2543 (put-text-property (match-beginning 1) (1+ (match-end 1))
2545 (put-text-property (match-beginning 2) (match-end 2)
2548 (defun article-make-date-line (date type)
2549 "Return a DATE line of TYPE."
2550 (unless (memq type '(local ut original user iso8601 lapsed english))
2551 (error "Unknown conversion type: %s" type))
2553 (let ((time (date-to-time date)))
2555 ;; Convert to the local timezone.
2557 (let ((tz (car (current-time-zone time))))
2558 (format "Date: %s %s%02d%02d" (current-time-string time)
2559 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2560 (/ (% (abs tz) 3600) 60))))
2561 ;; Convert to Universal Time.
2564 (current-time-string
2565 (let* ((e (parse-time-string date))
2566 (tm (apply 'encode-time e))
2568 (ls (- (cadr tm) (car (current-time-zone time)))))
2569 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2570 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2573 ;; Get the original date from the article.
2574 ((eq type 'original)
2575 (concat "Date: " (if (string-match "\n+$" date)
2576 (substring date 0 (match-beginning 0))
2578 ;; Let the user define the format.
2580 (if (gnus-functionp gnus-article-time-format)
2581 (funcall gnus-article-time-format time)
2584 (format-time-string gnus-article-time-format time))))
2587 (let ((tz (car (current-time-zone time))))
2590 (format-time-string "%Y%m%dT%H%M%S" time)
2591 (format "%s%02d%02d"
2592 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2593 (/ (% (abs tz) 3600) 60)))))
2594 ;; Do an X-Sent lapsed format.
2596 ;; If the date is seriously mangled, the timezone functions are
2597 ;; liable to bug out, so we ignore all errors.
2598 (let* ((now (current-time))
2599 (real-time (subtract-time now time))
2600 (real-sec (and real-time
2601 (+ (* (float (car real-time)) 65536)
2603 (sec (and real-time (abs real-sec)))
2613 ;; This is a bit convoluted, but basically we go
2614 ;; through the time units for years, weeks, etc,
2615 ;; and divide things to see whether that results
2616 ;; in positive answers.
2619 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2620 ;; The (remaining) seconds are too few to
2621 ;; be divided into this time unit.
2623 ;; It's big enough, so we output it.
2624 (setq sec (- sec (* num (cdr unit))))
2626 (concat (if prev ", " "") (int-to-string
2628 " " (symbol-name (car unit))
2629 (if (> num 1) "s" ""))
2631 article-time-units "")
2632 ;; If dates are odd, then it might appear like the
2633 ;; article was sent in the future.
2636 " in the future"))))))
2637 ;; Display the date in proper English
2639 (let ((dtime (decode-time time)))
2642 (number-to-string (nth 3 dtime))
2643 (let ((digit (% (nth 3 dtime) 10)))
2645 ((memq (nth 3 dtime) '(11 12 13)) "th")
2651 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2653 (number-to-string (nth 5 dtime))
2655 (format "%02d" (nth 2 dtime))
2657 (format "%02d" (nth 1 dtime)))))))
2659 (format "Date: %s (from Oort)" date))))
2661 (defun article-date-local (&optional highlight)
2662 "Convert the current article date to the local timezone."
2663 (interactive (list t))
2664 (article-date-ut 'local highlight))
2666 (defun article-date-english (&optional highlight)
2667 "Convert the current article date to something that is proper English."
2668 (interactive (list t))
2669 (article-date-ut 'english highlight))
2671 (defun article-date-original (&optional highlight)
2672 "Convert the current article date to what it was originally.
2673 This is only useful if you have used some other date conversion
2674 function and want to see what the date was before converting."
2675 (interactive (list t))
2676 (article-date-ut 'original highlight))
2678 (defun article-date-lapsed (&optional highlight)
2679 "Convert the current article date to time lapsed since it was sent."
2680 (interactive (list t))
2681 (article-date-ut 'lapsed highlight))
2683 (defun article-update-date-lapsed ()
2684 "Function to be run from a timer to update the lapsed time line."
2685 (let (deactivate-mark)
2690 (set-buffer (window-buffer w))
2691 (when (eq major-mode 'gnus-article-mode)
2692 (goto-char (point-min))
2693 (when (re-search-forward "^X-Sent:" nil t)
2694 (article-date-lapsed t))))
2697 (defun gnus-start-date-timer (&optional n)
2698 "Start a timer to update the X-Sent header in the article buffers.
2699 The numerical prefix says how frequently (in seconds) the function
2704 (gnus-stop-date-timer)
2705 (setq article-lapsed-timer
2706 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2708 (defun gnus-stop-date-timer ()
2709 "Stop the X-Sent timer."
2711 (when article-lapsed-timer
2712 (nnheader-cancel-timer article-lapsed-timer)
2713 (setq article-lapsed-timer nil)))
2715 (defun article-date-user (&optional highlight)
2716 "Convert the current article date to the user-defined format.
2717 This format is defined by the `gnus-article-time-format' variable."
2718 (interactive (list t))
2719 (article-date-ut 'user highlight))
2721 (defun article-date-iso8601 (&optional highlight)
2722 "Convert the current article date to ISO8601."
2723 (interactive (list t))
2724 (article-date-ut 'iso8601 highlight))
2726 ;; (defun article-show-all ()
2727 ;; "Show all hidden text in the article buffer."
2730 ;; (let ((buffer-read-only nil))
2731 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2733 (defun article-remove-leading-whitespace ()
2734 "Remove excessive whitespace from all headers."
2738 (let ((buffer-read-only nil))
2739 (article-narrow-to-head)
2740 (goto-char (point-min))
2741 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2742 (delete-region (match-beginning 1) (match-end 1)))))))
2744 (defun article-emphasize (&optional arg)
2745 "Emphasize text according to `gnus-emphasis-alist'."
2746 (interactive (gnus-article-hidden-arg))
2747 (unless (gnus-article-check-hidden-text 'emphasis arg)
2751 (with-current-buffer gnus-summary-buffer
2752 gnus-article-emphasis-alist)
2754 gnus-emphasis-alist))
2755 (buffer-read-only nil)
2756 (props (append '(article-type emphasis)
2757 gnus-hidden-properties))
2758 regexp elem beg invisible visible face)
2761 (while (setq elem (pop alist))
2763 (setq regexp (car elem)
2764 invisible (nth 1 elem)
2765 visible (nth 2 elem)
2767 (while (re-search-forward regexp nil t)
2768 (when (and (match-beginning visible) (match-beginning invisible))
2769 (gnus-article-hide-text
2770 (match-beginning invisible) (match-end invisible) props)
2771 (gnus-article-unhide-text-type
2772 (match-beginning visible) (match-end visible) 'emphasis)
2773 (gnus-put-overlay-excluding-newlines
2774 (match-beginning visible) (match-end visible) 'face face)
2775 (gnus-add-wash-type 'emphasis)
2776 (goto-char (match-end invisible)))))))))
2778 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2779 "Setup newsgroup emphasis alist."
2780 (unless gnus-article-emphasis-alist
2781 (let ((name (and gnus-newsgroup-name
2782 (gnus-group-real-name gnus-newsgroup-name))))
2783 (make-local-variable 'gnus-article-emphasis-alist)
2784 (setq gnus-article-emphasis-alist
2786 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2787 (while (setq elem (pop alist))
2788 (when (and name (string-match (car elem) name))
2790 highlight (copy-sequence (cdr elem)))))
2792 (copy-sequence highlight-words)
2793 (if gnus-newsgroup-name
2794 (copy-sequence (gnus-group-find-parameter
2795 gnus-newsgroup-name 'highlight-words t)))
2796 gnus-emphasis-alist)))))
2799 (defvar gnus-summary-article-menu)
2800 (defvar gnus-summary-post-menu))
2802 ;;; Saving functions.
2804 (defun gnus-article-save (save-buffer file &optional num)
2805 "Save the currently selected article."
2806 (unless gnus-save-all-headers
2807 ;; Remove headers according to `gnus-saved-headers'.
2808 (let ((gnus-visible-headers
2809 (or gnus-saved-headers gnus-visible-headers))
2810 (gnus-article-buffer save-buffer))
2812 (set-buffer save-buffer)
2813 (article-hide-headers 1 t))))
2814 (save-window-excursion
2815 (if (not gnus-default-article-saver)
2816 (error "No default saver is defined")
2817 ;; !!! Magic! The saving functions all save
2818 ;; `gnus-save-article-buffer' (or so they think), but we
2819 ;; bind that variable to our save-buffer.
2820 (set-buffer gnus-article-buffer)
2821 (let* ((gnus-save-article-buffer save-buffer)
2824 ((not gnus-prompt-before-saving) 'default)
2825 ((eq gnus-prompt-before-saving 'always) nil)
2827 (gnus-number-of-articles-to-be-saved
2828 (when (eq gnus-prompt-before-saving t)
2830 (set-buffer gnus-article-current-summary)
2831 (funcall gnus-default-article-saver filename)))))
2833 (defun gnus-read-save-file-name (prompt &optional filename
2834 function group headers variable)
2836 (funcall function group headers (symbol-value variable)))
2841 ((eq filename 'default)
2847 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2850 (if (and gnus-number-of-articles-to-be-saved
2851 (> gnus-number-of-articles-to-be-saved 1))
2852 (format "these %d articles"
2853 gnus-number-of-articles-to-be-saved)
2856 ;; Let the split methods have their say.
2858 ;; No split name was found.
2861 (concat prompt " (default "
2862 (file-name-nondirectory default-name) ") ")
2863 (file-name-directory default-name)
2865 ;; A single group name is returned.
2866 ((stringp split-name)
2868 (funcall function split-name headers
2869 (symbol-value variable)))
2871 (concat prompt " (default "
2872 (file-name-nondirectory default-name) ") ")
2873 (file-name-directory default-name)
2875 ;; A single split name was found
2876 ((= 1 (length split-name))
2877 (let* ((name (expand-file-name
2879 gnus-article-save-directory))
2880 (dir (cond ((file-directory-p name)
2881 (file-name-as-directory name))
2882 ((file-exists-p name) name)
2883 (t gnus-article-save-directory))))
2885 (concat prompt " (default " name ") ")
2887 ;; A list of splits was found.
2889 (setq split-name (nreverse split-name))
2891 (let ((file-name-history
2892 (nconc split-name file-name-history)))
2896 (concat prompt " (`M-p' for defaults) ")
2897 gnus-article-save-directory
2899 gnus-article-save-directory)))
2900 (car (push result file-name-history)))))))
2901 ;; Create the directory.
2902 (gnus-make-directory (file-name-directory file))
2903 ;; If we have read a directory, we append the default file name.
2904 (when (file-directory-p file)
2905 (setq file (expand-file-name (file-name-nondirectory
2907 (file-name-as-directory file))))
2908 ;; Possibly translate some characters.
2909 (nnheader-translate-file-chars file))))))
2910 (gnus-make-directory (file-name-directory result))
2911 (set variable result)))
2913 (defun gnus-article-archive-name (group)
2914 "Return the first instance of an \"Archive-name\" in the current buffer."
2915 (let ((case-fold-search t))
2916 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2917 (nnheader-concat gnus-article-save-directory
2918 (match-string 1)))))
2920 (defun gnus-article-nndoc-name (group)
2921 "If GROUP is an nndoc group, return the name of the parent group."
2922 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2923 (gnus-group-get-parameter group 'save-article-group)))
2925 (defun gnus-summary-save-in-rmail (&optional filename)
2926 "Append this article to Rmail file.
2927 Optional argument FILENAME specifies file name.
2928 Directory to save to is default to `gnus-article-save-directory'."
2929 (setq filename (gnus-read-save-file-name
2930 "Save %s in rmail file:" filename
2931 gnus-rmail-save-name gnus-newsgroup-name
2932 gnus-current-headers 'gnus-newsgroup-last-rmail))
2933 (gnus-eval-in-buffer-window gnus-save-article-buffer
2937 (gnus-output-to-rmail filename))))
2940 (defun gnus-summary-save-in-mail (&optional filename)
2941 "Append this article to Unix mail file.
2942 Optional argument FILENAME specifies file name.
2943 Directory to save to is default to `gnus-article-save-directory'."
2944 (setq filename (gnus-read-save-file-name
2945 "Save %s in Unix mail file:" filename
2946 gnus-mail-save-name gnus-newsgroup-name
2947 gnus-current-headers 'gnus-newsgroup-last-mail))
2948 (gnus-eval-in-buffer-window gnus-save-article-buffer
2952 (if (and (file-readable-p filename)
2953 (mail-file-babyl-p filename))
2954 (rmail-output-to-rmail-file filename t)
2955 (gnus-output-to-mail filename)))))
2958 (defun gnus-summary-save-in-file (&optional filename overwrite)
2959 "Append this article to file.
2960 Optional argument FILENAME specifies file name.
2961 Directory to save to is default to `gnus-article-save-directory'."
2962 (setq filename (gnus-read-save-file-name
2963 "Save %s in file:" filename
2964 gnus-file-save-name gnus-newsgroup-name
2965 gnus-current-headers 'gnus-newsgroup-last-file))
2966 (gnus-eval-in-buffer-window gnus-save-article-buffer
2970 (when (and overwrite
2971 (file-exists-p filename))
2972 (delete-file filename))
2973 (gnus-output-to-file filename))))
2976 (defun gnus-summary-write-to-file (&optional filename)
2977 "Write this article to a file, overwriting it if the file exists.
2978 Optional argument FILENAME specifies file name.
2979 The directory to save in defaults to `gnus-article-save-directory'."
2980 (gnus-summary-save-in-file nil t))
2982 (defun gnus-summary-save-body-in-file (&optional filename)
2983 "Append this article body to a file.
2984 Optional argument FILENAME specifies file name.
2985 The directory to save in defaults to `gnus-article-save-directory'."
2986 (setq filename (gnus-read-save-file-name
2987 "Save %s body in file:" filename
2988 gnus-file-save-name gnus-newsgroup-name
2989 gnus-current-headers 'gnus-newsgroup-last-file))
2990 (gnus-eval-in-buffer-window gnus-save-article-buffer
2994 (when (article-goto-body)
2995 (narrow-to-region (point) (point-max)))
2996 (gnus-output-to-file filename))))
2999 (defun gnus-summary-save-in-pipe (&optional command)
3000 "Pipe this article to subprocess."
3002 (cond ((and (eq command 'default)
3003 gnus-last-shell-command)
3004 gnus-last-shell-command)
3009 "Shell command on %s: "
3010 (if (and gnus-number-of-articles-to-be-saved
3011 (> gnus-number-of-articles-to-be-saved 1))
3012 (format "these %d articles"
3013 gnus-number-of-articles-to-be-saved)
3015 gnus-last-shell-command))))
3016 (when (string-equal command "")
3017 (if gnus-last-shell-command
3018 (setq command gnus-last-shell-command)
3019 (error "A command is required")))
3020 (gnus-eval-in-buffer-window gnus-article-buffer
3023 (shell-command-on-region (point-min) (point-max) command nil)))
3024 (setq gnus-last-shell-command command))
3026 (defun gnus-summary-pipe-to-muttprint (&optional command)
3027 "Pipe this article to muttprint."
3028 (setq command (read-string
3029 "Print using command: " gnus-summary-muttprint-program
3030 nil gnus-summary-muttprint-program))
3031 (gnus-summary-save-in-pipe command))
3033 ;;; Article file names when saving.
3035 (defun gnus-capitalize-newsgroup (newsgroup)
3036 "Capitalize NEWSGROUP name."
3037 (when (not (zerop (length newsgroup)))
3038 (concat (char-to-string (upcase (aref newsgroup 0)))
3039 (substring newsgroup 1))))
3041 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3042 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3043 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3044 Otherwise, it is like ~/News/news/group/num."
3047 (concat (if (gnus-use-long-file-name 'not-save)
3048 (gnus-capitalize-newsgroup newsgroup)
3049 (gnus-newsgroup-directory-form newsgroup))
3050 "/" (int-to-string (mail-header-number headers)))
3051 gnus-article-save-directory)))
3053 (string-equal (file-name-directory default)
3054 (file-name-directory last-file))
3055 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3057 (or last-file default))))
3059 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3060 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3061 If variable `gnus-use-long-file-name' is non-nil, it is
3062 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3065 (concat (if (gnus-use-long-file-name 'not-save)
3067 (gnus-newsgroup-directory-form newsgroup))
3068 "/" (int-to-string (mail-header-number headers)))
3069 gnus-article-save-directory)))
3071 (string-equal (file-name-directory default)
3072 (file-name-directory last-file))
3073 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3075 (or last-file default))))
3077 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3078 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3079 If variable `gnus-use-long-file-name' is non-nil, it is
3080 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3083 (if (gnus-use-long-file-name 'not-save)
3086 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3088 gnus-article-save-directory)))
3090 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3091 "Generate file name from sender."
3092 (let ((from (mail-header-from headers)))
3094 (if (and from (string-match "\\([^ <]+\\)@" from))
3095 (match-string 1 from)
3097 gnus-article-save-directory)))
3099 (defun article-verify-x-pgp-sig ()
3102 (if (gnus-buffer-live-p gnus-original-article-buffer)
3103 (let ((sig (with-current-buffer gnus-original-article-buffer
3104 (gnus-fetch-field "X-PGP-Sig")))
3108 (mml2015-clear-verify-function))
3110 (insert-buffer gnus-original-article-buffer)
3111 (setq items (split-string sig))
3112 (message-narrow-to-head)
3113 (let ((inhibit-point-motion-hooks t)
3114 (case-fold-search t))
3115 ;; Don't verify multiple headers.
3116 (setq headers (mapconcat (lambda (header)
3118 (mail-fetch-field header) "\n"))
3119 (split-string (nth 1 items) ",") "")))
3120 (delete-region (point-min) (point-max))
3121 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3122 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3127 (if (looking-at "^-")
3130 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3131 (insert "Version: " (car items) "\n\n")
3132 (insert (mapconcat 'identity (cddr items) "\n"))
3133 (insert "\n-----END PGP SIGNATURE-----\n")
3134 (let ((mm-security-handle (list (format "multipart/signed"))))
3135 (mml2015-clean-buffer)
3136 (let ((coding-system-for-write (or gnus-newsgroup-charset
3138 (funcall (mml2015-clear-verify-function)))
3140 (or (mm-handle-multipart-ctl-parameter
3141 mm-security-handle 'gnus-details)
3142 (mm-handle-multipart-ctl-parameter
3143 mm-security-handle 'gnus-info)))))
3145 (let (buffer-read-only bface eface)
3147 (message-narrow-to-head)
3148 (goto-char (point-max))
3150 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3151 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3152 (message-remove-header "X-Gnus-PGP-Verify")
3153 (if (re-search-forward "^X-PGP-Sig:" nil t)
3155 (goto-char (point-max)))
3156 (narrow-to-region (point) (point))
3157 (insert "X-Gnus-PGP-Verify: " info "\n")
3158 (goto-char (point-min))
3161 (if (not (looking-at "^[ \t]"))
3165 (goto-char (point-min))
3166 (when (looking-at "\\([^:]+\\): *")
3167 (put-text-property (match-beginning 1) (1+ (match-end 1))
3169 (put-text-property (match-end 0) (point-max)
3170 'face eface)))))))))
3172 (defun article-verify-cancel-lock ()
3173 "Verify Cancel-Lock header."
3175 (if (gnus-buffer-live-p gnus-original-article-buffer)
3176 (canlock-verify gnus-original-article-buffer)))
3183 (setq afunc (car func)
3186 gfunc (intern (format "gnus-%s" func))))
3188 (when (fboundp afunc)
3189 `(lambda (&optional interactive &rest args)
3190 ,(documentation afunc t)
3191 (interactive (list t))
3193 (set-buffer gnus-article-buffer)
3195 (call-interactively ',afunc)
3196 (apply ',afunc args))))))))
3197 '(article-hide-headers
3198 article-verify-x-pgp-sig
3199 article-verify-cancel-lock
3200 article-hide-boring-headers
3201 article-treat-overstrike
3202 article-fill-long-lines
3203 article-capitalize-sentences
3205 article-remove-leading-whitespace
3206 article-display-x-face
3207 article-de-quoted-unreadable
3208 article-de-base64-unreadable
3211 article-unsplit-urls
3212 article-hide-list-identifiers
3214 article-strip-banner
3217 article-hide-signature
3218 article-strip-headers-in-body
3219 article-remove-trailing-blank-lines
3220 article-strip-leading-blank-lines
3221 article-strip-multiple-blank-lines
3222 article-strip-leading-space
3223 article-strip-trailing-space
3224 article-strip-blank-lines
3225 article-strip-all-blank-lines
3226 article-replace-with-quoted-text
3228 article-date-english
3229 article-date-iso8601
3230 article-date-original
3232 article-decode-mime-words
3233 article-decode-charset
3234 article-decode-encoded-words
3238 article-treat-dumbquotes
3239 article-normalize-headers
3240 ;; (article-show-all . gnus-article-show-all-headers)
3244 ;;; Gnus article mode
3247 (put 'gnus-article-mode 'mode-class 'special)
3249 (set-keymap-parent gnus-article-mode-map widget-keymap)
3251 (gnus-define-keys gnus-article-mode-map
3252 " " gnus-article-goto-next-page
3253 "\177" gnus-article-goto-prev-page
3254 [delete] gnus-article-goto-prev-page
3255 [backspace] gnus-article-goto-prev-page
3256 "\C-c^" gnus-article-refer-article
3257 "h" gnus-article-show-summary
3258 "s" gnus-article-show-summary
3259 "\C-c\C-m" gnus-article-mail
3260 "?" gnus-article-describe-briefly
3261 "e" gnus-summary-edit-article
3262 "<" beginning-of-buffer
3264 "\C-c\C-i" gnus-info-find-node
3266 "R" gnus-article-reply-with-original
3267 "F" gnus-article-followup-with-original
3268 "\C-hk" gnus-article-describe-key
3269 "\C-hc" gnus-article-describe-key-briefly
3271 "\C-d" gnus-article-read-summary-keys
3272 "\M-*" gnus-article-read-summary-keys
3273 "\M-#" gnus-article-read-summary-keys
3274 "\M-^" gnus-article-read-summary-keys
3275 "\M-g" gnus-article-read-summary-keys)
3277 (substitute-key-definition
3278 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3280 (defun gnus-article-make-menu-bar ()
3281 (unless (boundp 'gnus-article-commands-menu)
3282 (gnus-summary-make-menu-bar))
3283 (gnus-turn-off-edit-menu 'article)
3284 (unless (boundp 'gnus-article-article-menu)
3286 gnus-article-article-menu gnus-article-mode-map ""
3288 ["Scroll forwards" gnus-article-goto-next-page t]
3289 ["Scroll backwards" gnus-article-goto-prev-page t]
3290 ["Show summary" gnus-article-show-summary t]
3291 ["Fetch Message-ID at point" gnus-article-refer-article t]
3292 ["Mail to address at point" gnus-article-mail t]
3293 ["Send a bug report" gnus-bug t]))
3296 gnus-article-treatment-menu gnus-article-mode-map ""
3297 ;; Fixme: this should use :active (and maybe :visible).
3299 ["Hide headers" gnus-article-hide-headers t]
3300 ["Hide signature" gnus-article-hide-signature t]
3301 ["Hide citation" gnus-article-hide-citation t]
3302 ["Treat overstrike" gnus-article-treat-overstrike t]
3303 ["Remove carriage return" gnus-article-remove-cr t]
3304 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3305 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3306 ["Remove base64" gnus-article-de-base64-unreadable t]
3307 ["Treat html" gnus-article-wash-html t]
3308 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3309 ["Decode HZ" gnus-article-decode-HZ t]))
3311 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3313 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3315 (gnus-run-hooks 'gnus-article-menu-hook)))
3317 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3320 (defun gnus-article-mode ()
3321 "Major mode for displaying an article.
3323 All normal editing commands are switched off.
3325 The following commands are available in addition to all summary mode
3327 \\<gnus-article-mode-map>
3328 \\[gnus-article-next-page]\t Scroll the article one page forwards
3329 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3330 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3331 \\[gnus-article-show-summary]\t Display the summary buffer
3332 \\[gnus-article-mail]\t Send a reply to the address near point
3333 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3334 \\[gnus-info-find-node]\t Go to the Gnus info node"
3336 (gnus-simplify-mode-line)
3337 (setq mode-name "Article")
3338 (setq major-mode 'gnus-article-mode)
3339 (make-local-variable 'minor-mode-alist)
3340 (use-local-map gnus-article-mode-map)
3341 (when (gnus-visual-p 'article-menu 'menu)
3342 (gnus-article-make-menu-bar))
3343 (gnus-update-format-specifications nil 'article-mode)
3344 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3345 (make-local-variable 'gnus-page-broken)
3346 (make-local-variable 'gnus-button-marker-list)
3347 (make-local-variable 'gnus-article-current-summary)
3348 (make-local-variable 'gnus-article-mime-handles)
3349 (make-local-variable 'gnus-article-decoded-p)
3350 (make-local-variable 'gnus-article-mime-handle-alist)
3351 (make-local-variable 'gnus-article-wash-types)
3352 (make-local-variable 'gnus-article-image-alist)
3353 (make-local-variable 'gnus-article-charset)
3354 (make-local-variable 'gnus-article-ignored-charsets)
3355 (gnus-set-default-directory)
3356 (buffer-disable-undo)
3357 (setq buffer-read-only t)
3358 (set-syntax-table gnus-article-mode-syntax-table)
3359 (mm-enable-multibyte)
3360 (gnus-run-hooks 'gnus-article-mode-hook))
3362 (defun gnus-article-setup-buffer ()
3363 "Initialize the article buffer."
3364 (let* ((name (if gnus-single-article-buffer "*Article*"
3365 (concat "*Article " gnus-newsgroup-name "*")))
3367 (progn (string-match "\\*Article" name)
3368 (concat " *Original Article"
3369 (substring name (match-end 0))))))
3370 (setq gnus-article-buffer name)
3371 (setq gnus-original-article-buffer original)
3372 (setq gnus-article-mime-handle-alist nil)
3373 ;; This might be a variable local to the summary buffer.
3374 (unless gnus-single-article-buffer
3376 (set-buffer gnus-summary-buffer)
3377 (setq gnus-article-buffer name)
3378 (setq gnus-original-article-buffer original)
3379 (gnus-set-global-variables)))
3380 (gnus-article-setup-highlight-words)
3381 ;; Init original article buffer.
3383 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3384 (mm-enable-multibyte)
3385 (setq major-mode 'gnus-original-article-mode)
3386 (make-local-variable 'gnus-original-article))
3387 (if (get-buffer name)
3390 (when gnus-article-mime-handles
3391 (mm-destroy-parts gnus-article-mime-handles)
3392 (setq gnus-article-mime-handles nil))
3393 ;; Set it to nil in article-buffer!
3394 (setq gnus-article-mime-handle-alist nil)
3395 (buffer-disable-undo)
3396 (setq buffer-read-only t)
3397 (unless (eq major-mode 'gnus-article-mode)
3398 (gnus-article-mode))
3401 (set-buffer (gnus-get-buffer-create name))
3403 (make-local-variable 'gnus-summary-buffer)
3404 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3405 (current-buffer)))))
3407 ;; Set article window start at LINE, where LINE is the number of lines
3408 ;; from the head of the article.
3409 (defun gnus-article-set-window-start (&optional line)
3411 (gnus-get-buffer-window gnus-article-buffer t)
3413 (set-buffer gnus-article-buffer)
3414 (goto-char (point-min))
3417 (gnus-message 6 "Moved to bookmark")
3418 (search-forward "\n\n" nil t)
3422 (defun gnus-article-prepare (article &optional all-headers header)
3423 "Prepare ARTICLE in article mode buffer.
3424 ARTICLE should either be an article number or a Message-ID.
3425 If ARTICLE is an id, HEADER should be the article headers.
3426 If ALL-HEADERS is non-nil, no headers are hidden."
3428 ;; Make sure we start in a summary buffer.
3429 (unless (eq major-mode 'gnus-summary-mode)
3430 (set-buffer gnus-summary-buffer))
3431 (setq gnus-summary-buffer (current-buffer))
3432 (let* ((gnus-article (if header (mail-header-number header) article))
3433 (summary-buffer (current-buffer))
3434 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3435 (group gnus-newsgroup-name)
3438 (gnus-article-setup-buffer)
3439 (set-buffer gnus-article-buffer)
3440 ;; Deactivate active regions.
3441 (when (and (boundp 'transient-mark-mode)
3442 transient-mark-mode)
3443 (setq mark-active nil))
3444 (if (not (setq result (let ((buffer-read-only nil))
3445 (gnus-request-article-this-buffer
3447 ;; There is no such article.
3449 (when (and (numberp article)
3450 (not (memq article gnus-newsgroup-sparse)))
3451 (setq gnus-article-current
3452 (cons gnus-newsgroup-name article))
3453 (set-buffer gnus-summary-buffer)
3454 (setq gnus-current-article article)
3455 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3457 (gnus-summary-set-agent-mark article)
3458 (message "Message marked for downloading"))
3459 (gnus-summary-mark-article article gnus-canceled-mark)
3460 (unless (memq article gnus-newsgroup-sparse)
3461 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3462 (if (or (eq result 'pseudo)
3463 (eq result 'nneething))
3466 (set-buffer summary-buffer)
3467 (push article gnus-newsgroup-history)
3468 (setq gnus-last-article gnus-current-article
3469 gnus-current-article 0
3470 gnus-current-headers nil
3471 gnus-article-current nil)
3472 (if (eq result 'nneething)
3473 (gnus-configure-windows 'summary)
3474 (gnus-configure-windows 'article))
3475 (gnus-set-global-variables))
3476 (let ((gnus-article-mime-handle-alist-1
3477 gnus-article-mime-handle-alist))
3478 (gnus-set-mode-line 'article)))
3479 ;; The result from the `request' was an actual article -
3480 ;; or at least some text that is now displayed in the
3482 (when (and (numberp article)
3483 (not (eq article gnus-current-article)))
3484 ;; Seems like a new article has been selected.
3485 ;; `gnus-current-article' must be an article number.
3487 (set-buffer summary-buffer)
3488 (push article gnus-newsgroup-history)
3489 (setq gnus-last-article gnus-current-article
3490 gnus-current-article article
3491 gnus-current-headers
3492 (gnus-summary-article-header gnus-current-article)
3493 gnus-article-current
3494 (cons gnus-newsgroup-name gnus-current-article))
3495 (unless (vectorp gnus-current-headers)
3496 (setq gnus-current-headers nil))
3497 (gnus-summary-goto-subject gnus-current-article)
3498 (when (gnus-summary-show-thread)
3499 ;; If the summary buffer really was folded, the
3500 ;; previous goto may not actually have gone to
3501 ;; the right article, but the thread root instead.
3503 (gnus-summary-goto-subject gnus-current-article))
3504 (gnus-run-hooks 'gnus-mark-article-hook)
3505 (gnus-set-mode-line 'summary)
3506 (when (gnus-visual-p 'article-highlight 'highlight)
3507 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3508 ;; Set the global newsgroup variables here.
3509 (gnus-set-global-variables)
3510 (setq gnus-have-all-headers
3511 (or all-headers gnus-show-all-headers))))
3513 (gnus-configure-windows 'article))
3514 (when (or (numberp article)
3516 (gnus-article-prepare-display)
3518 (goto-char (point-min))
3519 (setq gnus-page-broken
3520 (when gnus-break-pages
3521 (gnus-narrow-to-page)
3523 (let ((gnus-article-mime-handle-alist-1
3524 gnus-article-mime-handle-alist))
3525 (gnus-set-mode-line 'article))
3527 (set-window-point (get-buffer-window (current-buffer)) (point))
3528 (gnus-configure-windows 'article)
3532 (defun gnus-article-prepare-display ()
3533 "Make the current buffer look like a nice article."
3534 ;; Hooks for getting information from the article.
3535 ;; This hook must be called before being narrowed.
3536 (let ((gnus-article-buffer (current-buffer))
3538 (unless (eq major-mode 'gnus-article-mode)
3539 (gnus-article-mode))
3540 (setq buffer-read-only nil
3541 gnus-article-wash-types nil
3542 gnus-article-image-alist nil)
3543 (gnus-run-hooks 'gnus-tmp-internal-hook)
3544 (when gnus-display-mime-function
3545 (funcall gnus-display-mime-function))
3546 (gnus-run-hooks 'gnus-article-prepare-hook)))
3549 ;;; Gnus MIME viewing functions
3552 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3553 "Format of the MIME buttons.
3555 Valid specifiers include:
3557 %T MIME type, along with additional info
3558 %n The `name' parameter
3559 %d The description, if any
3560 %l The length of the encoded part
3561 %p The part identifier number
3562 %e Dots if the part isn't displayed
3564 General format specifiers can also be used. See
3565 (gnus)Formatting Variables.")
3567 (defvar gnus-mime-button-line-format-alist
3568 '((?t gnus-tmp-type ?s)
3569 (?T gnus-tmp-type-long ?s)
3570 (?n gnus-tmp-name ?s)
3571 (?d gnus-tmp-description ?s)
3573 (?l gnus-tmp-length ?d)
3574 (?e gnus-tmp-dots ?s)))
3576 (defvar gnus-mime-button-commands
3577 '((gnus-article-press-button "\r" "Toggle Display")
3578 (gnus-mime-view-part "v" "View Interactively...")
3579 (gnus-mime-view-part-as-type "t" "View As Type...")
3580 (gnus-mime-view-part-as-charset "C" "View As charset...")
3581 (gnus-mime-save-part "o" "Save...")
3582 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3583 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3584 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3585 (gnus-mime-internalize-part "E" "View Internally")
3586 (gnus-mime-externalize-part "e" "View Externally")
3587 (gnus-mime-print-part "p" "Print")
3588 (gnus-mime-pipe-part "|" "Pipe To Command...")
3589 (gnus-mime-action-on-part "." "Take action on the part")))
3591 (defun gnus-article-mime-part-status ()
3592 (if gnus-article-mime-handle-alist-1
3593 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3595 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3598 (defvar gnus-mime-button-map
3599 (let ((map (make-sparse-keymap)))
3600 (unless (>= (string-to-number emacs-version) 21)
3601 ;; XEmacs doesn't care.
3602 (set-keymap-parent map gnus-article-mode-map))
3603 (define-key map gnus-mouse-2 'gnus-article-push-button)
3604 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3605 (dolist (c gnus-mime-button-commands)
3606 (define-key map (cadr c) (car c)))
3609 (defun gnus-mime-button-menu (event)
3610 "Construct a context-sensitive menu of MIME commands."
3612 (save-window-excursion
3613 (let ((pos (event-start event)))
3614 (select-window (posn-window pos))
3615 (goto-char (posn-point pos))
3616 (gnus-article-check-buffer)
3617 (let ((response (x-popup-menu
3619 ("" ,@(mapcar (lambda (c)
3620 (cons (caddr c) (car c)))
3621 gnus-mime-button-commands))))))
3623 (call-interactively response))))))
3625 (defun gnus-mime-view-all-parts (&optional handles)
3626 "View all the MIME parts."
3628 (save-current-buffer
3629 (set-buffer gnus-article-buffer)
3630 (let ((handles (or handles gnus-article-mime-handles))
3631 (mail-parse-charset gnus-newsgroup-charset)
3632 (mail-parse-ignored-charsets
3633 (with-current-buffer gnus-summary-buffer
3634 gnus-newsgroup-ignored-charsets)))
3636 (mm-remove-parts handles)
3637 (goto-char (point-min))
3638 (or (search-forward "\n\n") (goto-char (point-max)))
3639 (let (buffer-read-only)
3640 (delete-region (point) (point-max))
3641 (mm-display-parts handles))))))
3643 (defun gnus-mime-save-part-and-strip ()
3644 "Save the MIME part under point then replace it with an external body."
3646 (gnus-article-check-buffer)
3647 (let* ((data (get-text-property (point) 'gnus-data))
3649 (handles gnus-article-mime-handles))
3650 (if (mm-multiple-handles gnus-article-mime-handles)
3651 (error "This function is not implemented"))
3652 (setq file (and data (mm-save-part data)))
3654 (with-current-buffer (mm-handle-buffer data)
3656 (insert "Content-Type: " (mm-handle-media-type data))
3657 (mml-insert-parameter-string (cdr (mm-handle-type data))
3660 (insert "Content-ID: " (message-make-message-id) "\n")
3661 (insert "Content-Transfer-Encoding: binary\n")
3664 (cdr (mm-make-handle nil
3665 `("message/external-body"
3666 (access-type . "LOCAL-FILE")
3668 (set-buffer gnus-summary-buffer)
3669 (gnus-article-edit-article
3672 (let ((mail-parse-charset (or gnus-article-charset
3673 ',gnus-newsgroup-charset))
3674 (mail-parse-ignored-charsets
3675 (or gnus-article-ignored-charsets
3676 ',gnus-newsgroup-ignored-charsets))
3677 (mbl mml-buffer-list))
3678 (setq mml-buffer-list nil)
3679 (insert-buffer gnus-original-article-buffer)
3680 (mime-to-mml ',handles)
3681 (setq gnus-article-mime-handles nil)
3682 (let ((mbl1 mml-buffer-list))
3683 (setq mml-buffer-list mbl)
3684 (set (make-local-variable 'mml-buffer-list) mbl1))
3685 ;; LOCAL argument of add-hook differs between GNU Emacs
3686 ;; and XEmacs. make-local-hook makes sure they are local.
3687 (make-local-hook 'kill-buffer-hook)
3688 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3689 `(lambda (no-highlight)
3690 (let ((mail-parse-charset (or gnus-article-charset
3691 ',gnus-newsgroup-charset))
3692 (message-options message-options)
3693 (message-options-set-recipient)
3694 (mail-parse-ignored-charsets
3695 (or gnus-article-ignored-charsets
3696 ',gnus-newsgroup-ignored-charsets)))
3698 (mml-destroy-buffers)
3699 (remove-hook 'kill-buffer-hook
3700 'mml-destroy-buffers t)
3701 (kill-local-variable 'mml-buffer-list))
3702 (gnus-summary-edit-article-done
3703 ,(or (mail-header-references gnus-current-headers) "")
3704 ,(gnus-group-read-only-p)
3705 ,gnus-summary-buffer no-highlight))))))
3707 (defun gnus-mime-save-part ()
3708 "Save the MIME part under point."
3710 (gnus-article-check-buffer)
3711 (let ((data (get-text-property (point) 'gnus-data)))
3713 (mm-save-part data))))
3715 (defun gnus-mime-pipe-part ()
3716 "Pipe the MIME part under point to a process."
3718 (gnus-article-check-buffer)
3719 (let ((data (get-text-property (point) 'gnus-data)))
3721 (mm-pipe-part data))))
3723 (defun gnus-mime-view-part ()
3724 "Interactively choose a viewing method for the MIME part under point."
3726 (gnus-article-check-buffer)
3727 (let ((data (get-text-property (point) 'gnus-data)))
3729 (setq gnus-article-mime-handles
3731 gnus-article-mime-handles (setq data (copy-sequence data))))
3732 (mm-interactively-view-part data))))
3734 (defun gnus-mime-view-part-as-type-internal ()
3735 (gnus-article-check-buffer)
3736 (let* ((name (mail-content-type-get
3737 (mm-handle-type (get-text-property (point) 'gnus-data))
3739 (def-type (and name (mm-default-file-encoding name))))
3740 (and def-type (cons def-type 0))))
3742 (defun gnus-mime-view-part-as-type (&optional mime-type)
3743 "Choose a MIME media type, and view the part as such."
3746 (setq mime-type (completing-read
3747 "View as MIME type: "
3748 (mapcar #'list (mailcap-mime-types))
3750 (gnus-mime-view-part-as-type-internal))))
3751 (gnus-article-check-buffer)
3752 (let ((handle (get-text-property (point) 'gnus-data)))
3755 (mm-make-handle (mm-handle-buffer handle)
3756 (cons mime-type (cdr (mm-handle-type handle)))
3757 (mm-handle-encoding handle)
3758 (mm-handle-undisplayer handle)
3759 (mm-handle-disposition handle)
3760 (mm-handle-description handle)
3762 (mm-handle-id handle)))
3763 (setq gnus-article-mime-handles
3764 (mm-merge-handles gnus-article-mime-handles handle))
3765 (gnus-mm-display-part handle))))
3767 (defun gnus-mime-copy-part (&optional handle)
3768 "Put the MIME part under point into a new buffer."
3770 (gnus-article-check-buffer)
3771 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3772 (contents (and handle (mm-get-part handle)))
3774 (file-name-nondirectory
3776 (mail-content-type-get (mm-handle-type handle) 'name)
3777 (mail-content-type-get (mm-handle-type handle)
3780 (buffer (and base (generate-new-buffer base))))
3782 (switch-to-buffer buffer)
3784 ;; We do it this way to make `normal-mode' set the appropriate mode.
3787 (setq buffer-file-name (expand-file-name base))
3789 (setq buffer-file-name nil))
3790 (goto-char (point-min)))))
3792 (defun gnus-mime-print-part (&optional handle filename)
3793 "Print the MIME part under point."
3794 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3795 (gnus-article-check-buffer)
3796 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3797 (contents (and handle (mm-get-part handle)))
3798 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3799 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3804 (with-temp-file file
3806 (call-process shell-file-name nil
3807 (generate-new-buffer " *mm*")
3809 shell-command-switch
3811 printer file (mm-handle-type handle))))
3815 (gnus-print-buffer))
3816 (ps-despool filename)))))
3818 (defun gnus-mime-inline-part (&optional handle arg)
3819 "Insert the MIME part under point into the current buffer."
3820 (interactive (list nil current-prefix-arg))
3821 (gnus-article-check-buffer)
3822 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3827 (if (and (not arg) (mm-handle-undisplayer handle))
3828 (mm-remove-part handle)
3829 (setq contents (mm-get-part handle))
3832 (setq charset (or (mail-content-type-get
3833 (mm-handle-type handle) 'charset)
3834 gnus-newsgroup-charset)))
3836 (if (mm-handle-undisplayer handle)
3837 (mm-remove-part handle))
3840 gnus-summary-show-article-charset-alist))
3841 (mm-read-coding-system "Charset: ")))))
3843 (mm-insert-inline handle
3845 (setq charset (mm-charset-to-coding-system
3847 (not (eq charset 'ascii)))
3848 (mm-decode-coding-string contents charset)
3852 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3853 "Insert the MIME part under point into the current buffer using the
3855 (interactive (list nil current-prefix-arg))
3856 (gnus-article-check-buffer)
3857 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3862 (if (mm-handle-undisplayer handle)
3863 (mm-remove-part handle))
3864 (let ((gnus-newsgroup-charset
3866 gnus-summary-show-article-charset-alist))
3867 (mm-read-coding-system "Charset: ")))
3868 (gnus-newsgroup-ignored-charsets 'gnus-all))
3869 (gnus-article-press-button)))))
3871 (defun gnus-mime-externalize-part (&optional handle)
3872 "View the MIME part under point with an external viewer."
3874 (gnus-article-check-buffer)
3875 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3876 (mm-user-display-methods nil)
3877 (mm-inlined-types nil)
3878 (mail-parse-charset gnus-newsgroup-charset)
3879 (mail-parse-ignored-charsets
3880 (save-excursion (set-buffer gnus-summary-buffer)
3881 gnus-newsgroup-ignored-charsets)))
3883 (if (mm-handle-undisplayer handle)
3884 (mm-remove-part handle)
3885 (mm-display-part handle)))))
3887 (defun gnus-mime-internalize-part (&optional handle)
3888 "View the MIME part under point with an internal viewer.
3889 If no internal viewer is available, use an external viewer."
3891 (gnus-article-check-buffer)
3892 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3893 (mm-inlined-types '(".*"))
3894 (mm-inline-large-images t)
3895 (mail-parse-charset gnus-newsgroup-charset)
3896 (mail-parse-ignored-charsets
3897 (save-excursion (set-buffer gnus-summary-buffer)
3898 gnus-newsgroup-ignored-charsets)))
3900 (if (mm-handle-undisplayer handle)
3901 (mm-remove-part handle)
3902 (mm-display-part handle)))))
3904 (defun gnus-mime-action-on-part (&optional action)
3905 "Do something with the MIME attachment at \(point\)."
3907 (list (completing-read "Action: " gnus-mime-action-alist)))
3908 (gnus-article-check-buffer)
3909 (let ((action-pair (assoc action gnus-mime-action-alist)))
3911 (funcall (cdr action-pair)))))
3913 (defun gnus-article-part-wrapper (n function)
3914 (save-current-buffer
3915 (set-buffer gnus-article-buffer)
3916 (when (> n (length gnus-article-mime-handle-alist))
3917 (error "No such part"))
3918 (gnus-article-goto-part n)
3919 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3920 (funcall function handle))))
3922 (defun gnus-article-pipe-part (n)
3923 "Pipe MIME part N, which is the numerical prefix."
3925 (gnus-article-part-wrapper n 'mm-pipe-part))
3927 (defun gnus-article-save-part (n)
3928 "Save MIME part N, which is the numerical prefix."
3930 (gnus-article-part-wrapper n 'mm-save-part))
3932 (defun gnus-article-interactively-view-part (n)
3933 "View MIME part N interactively, which is the numerical prefix."
3935 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3937 (defun gnus-article-copy-part (n)
3938 "Copy MIME part N, which is the numerical prefix."
3940 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3942 (defun gnus-article-view-part-as-charset (n)
3943 "Copy MIME part N, which is the numerical prefix."
3945 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3947 (defun gnus-article-externalize-part (n)
3948 "View MIME part N externally, which is the numerical prefix."
3950 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3952 (defun gnus-article-inline-part (n)
3953 "Inline MIME part N, which is the numerical prefix."
3955 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3957 (defun gnus-article-mime-match-handle-first (condition)
3959 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3960 (while (setq ihandle (pop alist))
3962 ((functionp condition)
3963 (funcall condition (cdr ihandle)))
3964 ((eq condition 'undisplayed)
3965 (not (or (mm-handle-undisplayer (cdr ihandle))
3966 (equal (mm-handle-media-type (cdr ihandle))
3967 "multipart/alternative"))))
3968 ((eq condition 'undisplayed-alternative)
3969 (not (mm-handle-undisplayer (cdr ihandle))))
3971 (gnus-article-goto-part (car ihandle))
3972 (or (not n) (< (car ihandle) n)))
3973 (setq n (car ihandle))))
3977 (defun gnus-article-view-part (&optional n)
3978 "View MIME part N, which is the numerical prefix."
3980 (save-current-buffer
3981 (set-buffer gnus-article-buffer)
3982 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3983 gnus-article-mime-match-handle-function)))
3984 (when (> n (length gnus-article-mime-handle-alist))
3985 (error "No such part"))
3986 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3987 (when (gnus-article-goto-part n)
3988 (if (equal (car handle) "multipart/alternative")
3989 (gnus-article-press-button)
3990 (when (eq (gnus-mm-display-part handle) 'internal)
3991 (gnus-set-window-start)))))))
3993 (defsubst gnus-article-mime-total-parts ()
3994 (if (bufferp (car gnus-article-mime-handles))
3996 (1- (length gnus-article-mime-handles))))
3998 (defun gnus-mm-display-part (handle)
3999 "Display HANDLE and fix MIME button."
4000 (let ((id (get-text-property (point) 'gnus-part))
4005 (let ((window (selected-window))
4006 (mail-parse-charset gnus-newsgroup-charset)
4007 (mail-parse-ignored-charsets
4008 (if (gnus-buffer-live-p gnus-summary-buffer)
4010 (set-buffer gnus-summary-buffer)
4011 gnus-newsgroup-ignored-charsets)
4015 (let ((win (gnus-get-buffer-window (current-buffer) t))
4018 (select-window win))
4021 (if (mm-handle-displayed-p handle)
4022 ;; This will remove the part.
4023 (mm-display-part handle)
4025 (narrow-to-region (point)
4026 (if (eobp) (point) (1+ (point))))
4027 (mm-display-part handle)
4028 ;; We narrow to the part itself and
4029 ;; then call the treatment functions.
4030 (goto-char (point-min))
4032 (narrow-to-region (point) (point-max))
4035 (gnus-article-mime-total-parts)
4036 (mm-handle-media-type handle)))))
4037 (if (window-live-p window)
4038 (select-window window)))))
4040 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4041 (gnus-insert-mime-button
4042 handle id (list (mm-handle-displayed-p handle)))
4043 (goto-char point))))
4045 (defun gnus-article-goto-part (n)
4046 "Go to MIME part N."
4047 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4049 (goto-char point))))
4051 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4052 (let ((gnus-tmp-name
4053 (or (mail-content-type-get (mm-handle-type handle) 'name)
4054 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4055 (mail-content-type-get (mm-handle-type handle) 'url)
4057 (gnus-tmp-type (mm-handle-media-type handle))
4058 (gnus-tmp-description
4059 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4062 (if (if displayed (car displayed)
4063 (mm-handle-displayed-p handle))
4065 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4067 gnus-tmp-type-long b e)
4068 (when (string-match ".*/" gnus-tmp-name)
4069 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4070 (setq gnus-tmp-type-long (concat gnus-tmp-type
4071 (and (not (equal gnus-tmp-name ""))
4072 (concat "; " gnus-tmp-name))))
4073 (unless (equal gnus-tmp-description "")
4074 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4079 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4080 `(,@(gnus-local-map-property gnus-mime-button-map)
4081 gnus-callback gnus-mm-display-part
4082 gnus-part ,gnus-tmp-id
4083 article-type annotation
4086 (widget-convert-button
4089 :action 'gnus-widget-press-button
4090 :button-keymap gnus-mime-button-map
4092 (lambda (widget/window &optional overlay pos)
4093 ;; Needed to properly clear the message due to a bug in
4094 ;; wid-edit (XEmacs only).
4095 (if (boundp 'help-echo-owns-message)
4096 (setq help-echo-owns-message t))
4098 "%S: %s the MIME part; %S: more options"
4099 (aref gnus-mouse-2 0)
4100 ;; XEmacs will get a single widget arg; Emacs 21 will get
4101 ;; window, overlay, position.
4102 (if (mm-handle-displayed-p
4104 (with-current-buffer (gnus-overlay-buffer overlay)
4105 (widget-get (widget-at (gnus-overlay-start overlay))
4107 (widget-get widget/window :mime-handle)))
4109 (aref gnus-down-mouse-3 0))))))
4111 (defun gnus-widget-press-button (elems el)
4112 (goto-char (widget-get elems :from))
4113 (gnus-article-press-button))
4115 (defvar gnus-displaying-mime nil)
4117 (defun gnus-display-mime (&optional ihandles)
4118 "Display the MIME parts."
4120 (save-selected-window
4121 (let ((window (get-buffer-window gnus-article-buffer))
4124 (select-window window)
4125 ;; We have to do this since selecting the window
4126 ;; may change the point. So we set the window point.
4127 (set-window-point window point)))
4128 (let* ((handles (or ihandles (mm-dissect-buffer
4129 gnus-article-no-strict-mime)
4131 buffer-read-only handle name type b e display)
4132 (when (and (not ihandles)
4133 (not gnus-displaying-mime))
4134 ;; Top-level call; we clean up.
4135 (when gnus-article-mime-handles
4136 (mm-destroy-parts gnus-article-mime-handles)
4137 (setq gnus-article-mime-handle-alist nil));; A trick.
4138 (setq gnus-article-mime-handles handles)
4139 ;; We allow users to glean info from the handles.
4140 (when gnus-article-mime-part-function
4141 (gnus-mime-part-function handles)))
4143 (or (not (stringp (car handles)))
4146 (when (and (not ihandles)
4147 (not gnus-displaying-mime))
4148 ;; Clean up for mime parts.
4150 (delete-region (point) (point-max)))
4151 (let ((gnus-displaying-mime t))
4152 (gnus-mime-display-part handles)))
4155 (narrow-to-region (point) (point-max))
4156 (gnus-treat-article nil 1 1)
4159 ;; Highlight the headers.
4163 (narrow-to-region (point-min) (point))
4164 (gnus-treat-article 'head))))))))
4166 (defvar gnus-mime-display-multipart-as-mixed nil)
4167 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4168 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4170 (defun gnus-mime-display-part (handle)
4173 ((not (stringp (car handle)))
4174 (gnus-mime-display-single handle))
4175 ;; User-defined multipart
4176 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4177 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4179 ;; multipart/alternative
4180 ((and (equal (car handle) "multipart/alternative")
4181 (not (or gnus-mime-display-multipart-as-mixed
4182 gnus-mime-display-multipart-alternative-as-mixed)))
4183 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4184 (push (cons id handle) gnus-article-mime-handle-alist)
4185 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4186 ;; multipart/related
4187 ((and (equal (car handle) "multipart/related")
4188 (not (or gnus-mime-display-multipart-as-mixed
4189 gnus-mime-display-multipart-related-as-mixed)))
4190 ;;;!!!We should find the start part, but we just default
4191 ;;;!!!to the first part.
4192 ;;(gnus-mime-display-part (cadr handle))
4193 ;;;!!! Most multipart/related is an HTML message plus images.
4194 ;;;!!! Unfortunately we are unable to let W3 display those
4195 ;;;!!! included images, so we just display it as a mixed multipart.
4196 ;;(gnus-mime-display-mixed (cdr handle))
4197 ;;;!!! No, w3 can display everything just fine.
4198 (gnus-mime-display-part (cadr handle)))
4199 ((equal (car handle) "multipart/signed")
4200 (gnus-add-wash-type 'signed)
4201 (gnus-mime-display-security handle))
4202 ((equal (car handle) "multipart/encrypted")
4203 (gnus-add-wash-type 'encrypted)
4204 (gnus-mime-display-security handle))
4205 ;; Other multiparts are handled like multipart/mixed.
4207 (gnus-mime-display-mixed (cdr handle)))))
4209 (defun gnus-mime-part-function (handles)
4210 (if (stringp (car handles))
4211 (mapcar 'gnus-mime-part-function (cdr handles))
4212 (funcall gnus-article-mime-part-function handles)))
4214 (defun gnus-mime-display-mixed (handles)
4215 (mapcar 'gnus-mime-display-part handles))
4217 (defun gnus-mime-display-single (handle)
4218 (let ((type (mm-handle-media-type handle))
4219 (ignored gnus-ignored-mime-types)
4226 (when (string-match (pop ignored) type)
4227 (throw 'ignored nil)))
4228 (if (and (setq not-attachment
4229 (and (not (mm-inline-override-p handle))
4230 (or (not (mm-handle-disposition handle))
4231 (equal (car (mm-handle-disposition handle))
4233 (mm-attachment-override-p handle))))
4234 (mm-automatic-display-p handle)
4236 (mm-inlinable-p handle)
4237 (mm-inlined-p handle))
4238 (mm-automatic-external-display-p type)))
4240 (when (equal (mm-handle-media-supertype handle) "text")
4242 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4244 (push (cons id handle) gnus-article-mime-handle-alist)
4245 (when (or (not display)
4246 (not (gnus-unbuttonized-mime-type-p type)))
4247 ;(gnus-article-insert-newline)
4248 (gnus-insert-mime-button
4249 handle id (list (or display (and not-attachment text))))
4250 (gnus-article-insert-newline)
4251 ;(gnus-article-insert-newline)
4252 ;; Remember modify the number of forward lines.
4260 (let ((mail-parse-charset gnus-newsgroup-charset)
4261 (mail-parse-ignored-charsets
4262 (save-excursion (condition-case ()
4263 (set-buffer gnus-summary-buffer)
4265 gnus-newsgroup-ignored-charsets)))
4266 (mm-display-part handle t))
4267 (goto-char (point-max)))
4268 ((and text not-attachment)
4272 (gnus-article-insert-newline)
4273 (mm-insert-inline handle (mm-get-part handle))
4274 (goto-char (point-max))))
4278 (narrow-to-region beg (point))
4281 (gnus-article-mime-total-parts)
4282 (mm-handle-media-type handle)))))))))
4284 (defun gnus-unbuttonized-mime-type-p (type)
4285 "Say whether TYPE is to be unbuttonized."
4286 (unless gnus-inhibit-mime-unbuttonizing
4288 (let ((types gnus-unbuttonized-mime-types))
4290 (when (string-match (pop types) type)
4291 (throw 'found t)))))
4293 (let ((types gnus-buttonized-mime-types))
4295 (when (string-match (pop types) type)
4296 (throw 'found t)))))))))
4298 (defun gnus-article-insert-newline ()
4299 "Insert a newline, but mark it as undeletable."
4300 (gnus-put-text-property
4301 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4303 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4304 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4307 handle buffer-read-only from props begend not-pref)
4308 (save-window-excursion
4311 (narrow-to-region (car ibegend)
4314 (goto-char (car ibegend))
4317 (delete-region (point-min) (point-max))
4318 (mm-remove-parts handles))
4319 (setq begend (list (point-marker)))
4321 (unless (setq not-pref (cadr (member preferred ihandles)))
4322 (setq not-pref (car ihandles)))
4325 (not (gnus-unbuttonized-mime-type-p
4326 "multipart/alternative")))
4327 (gnus-add-text-properties
4330 (insert (format "%d. " id))
4334 (unless ,(not ibegend)
4335 (setq gnus-article-mime-handle-alist
4336 ',gnus-article-mime-handle-alist))
4337 (gnus-mime-display-alternative
4338 ',ihandles ',not-pref ',begend ,id))
4339 ,@(gnus-local-map-property gnus-mime-button-map)
4340 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4341 face ,gnus-article-button-face
4344 (widget-convert-button 'link from (point)
4345 :action 'gnus-widget-press-button
4346 :button-keymap gnus-widget-button-keymap)
4348 (while (setq handle (pop handles))
4349 (gnus-add-text-properties
4352 (insert (format "(%c) %-18s"
4353 (if (equal handle preferred) ?* ? )
4354 (mm-handle-media-type handle)))
4358 (unless ,(not ibegend)
4359 (setq gnus-article-mime-handle-alist
4360 ',gnus-article-mime-handle-alist))
4361 (gnus-mime-display-alternative
4362 ',ihandles ',handle ',begend ,id))
4363 ,@(gnus-local-map-property gnus-mime-button-map)
4364 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4365 face ,gnus-article-button-face
4368 (widget-convert-button 'link from (point)
4369 :action 'gnus-widget-press-button
4370 :button-keymap gnus-widget-button-keymap)
4374 (if (stringp (car preferred))
4375 (gnus-display-mime preferred)
4376 (let ((mail-parse-charset gnus-newsgroup-charset)
4377 (mail-parse-ignored-charsets
4378 (save-excursion (set-buffer gnus-summary-buffer)
4379 gnus-newsgroup-ignored-charsets)))
4380 (mm-display-part preferred)
4384 (narrow-to-region (car begend) (point-max))
4386 nil (length gnus-article-mime-handle-alist)
4387 (gnus-article-mime-total-parts)
4388 (mm-handle-media-type handle))))))
4389 (goto-char (point-max))
4390 (setcdr begend (point-marker)))))
4392 (goto-char point))))
4394 (defconst gnus-article-wash-status-strings
4395 (let ((alist '((cite "c" "Possible hidden citation text"
4396 " " "All citation text visible")
4397 (headers "h" "Hidden headers"
4398 " " "All headers visible.")
4399 (pgp "p" "Encrypted or signed message status hidden"
4400 " " "No hidden encryption nor digital signature status")
4401 (signature "s" "Signature has been hidden"
4402 " " "Signature is visible")
4403 (overstrike "o" "Overstrike (^H) characters applied"
4404 " " "No overstrike characters applied")
4405 (emphasis "e" "/*_Emphasis_*/ characters applied"
4406 " " "No /*_emphasis_*/ characters applied")))
4408 (dolist (entry alist result)
4409 (let ((key (nth 0 entry))
4410 (on (copy-sequence (nth 1 entry)))
4411 (on-help (nth 2 entry))
4412 (off (copy-sequence (nth 3 entry)))
4413 (off-help (nth 4 entry)))
4414 (put-text-property 0 1 'help-echo on-help on)
4415 (put-text-property 0 1 'help-echo off-help off)
4416 (push (list key on off) result))))
4417 "Alist of strings describing wash status in the mode line.
4418 Each entry has the form (KEY ON OF), where the KEY is a symbol
4419 representing the particular washing function, ON is the string to use
4420 in the article mode line when the washing function is active, and OFF
4421 is the string to use when it is inactive.")
4423 (defun gnus-article-wash-status-entry (key value)
4424 (let ((entry (assoc key gnus-article-wash-status-strings)))
4425 (if value (nth 1 entry) (nth 2 entry))))
4427 (defun gnus-article-wash-status ()
4428 "Return a string which display status of article washing."
4430 (set-buffer gnus-article-buffer)
4431 (let ((cite (memq 'cite gnus-article-wash-types))
4432 (headers (memq 'headers gnus-article-wash-types))
4433 (boring (memq 'boring-headers gnus-article-wash-types))
4434 (pgp (memq 'pgp gnus-article-wash-types))
4435 (pem (memq 'pem gnus-article-wash-types))
4436 (signed (memq 'signed gnus-article-wash-types))
4437 (encrypted (memq 'encrypted gnus-article-wash-types))
4438 (signature (memq 'signature gnus-article-wash-types))
4439 (overstrike (memq 'overstrike gnus-article-wash-types))
4440 (emphasis (memq 'emphasis gnus-article-wash-types)))
4442 (gnus-article-wash-status-entry 'cite cite)
4443 (gnus-article-wash-status-entry 'headers (or headers boring))
4444 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4445 (gnus-article-wash-status-entry 'signature signature)
4446 (gnus-article-wash-status-entry 'overstrike overstrike)
4447 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4449 (defun gnus-add-wash-type (type)
4450 "Add a washing of TYPE to the current status."
4451 (add-to-list 'gnus-article-wash-types type))
4453 (defun gnus-delete-wash-type (type)
4454 "Add a washing of TYPE to the current status."
4455 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4457 (defun gnus-add-image (category image)
4458 "Add IMAGE of CATEGORY to the list of displayed images."
4459 (let ((entry (assq category gnus-article-image-alist)))
4461 (setq entry (list category))
4462 (push entry gnus-article-image-alist))
4463 (nconc entry (list image))))
4465 (defun gnus-delete-images (category)
4466 "Delete all images in CATEGORY."
4467 (let ((entry (assq category gnus-article-image-alist)))
4468 (dolist (image (cdr entry))
4469 (gnus-remove-image image))
4470 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4471 (gnus-delete-wash-type category)))
4473 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4475 (defun gnus-article-maybe-hide-headers ()
4476 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4477 Provided for backwards compatibility."
4478 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4479 (not (save-excursion (set-buffer gnus-summary-buffer)
4480 gnus-have-all-headers)))
4481 (not gnus-inhibit-hiding))
4482 (gnus-article-hide-headers)))
4486 (defun gnus-output-to-file (file-name)
4487 "Append the current article to a file named FILE-NAME."
4488 (let ((artbuf (current-buffer)))
4490 (insert-buffer-substring artbuf)
4491 ;; Append newline at end of the buffer as separator, and then
4493 (goto-char (point-max))
4495 (let ((file-name-coding-system nnmail-pathname-coding-system))
4496 (mm-append-to-file (point-min) (point-max) file-name))
4499 (defun gnus-narrow-to-page (&optional arg)
4500 "Narrow the article buffer to a page.
4501 If given a numerical ARG, move forward ARG pages."
4503 (setq arg (if arg (prefix-numeric-value arg) 0))
4505 (set-buffer gnus-article-buffer)
4506 (goto-char (point-min))
4508 ;; Remove any old next/prev buttons.
4509 (when (gnus-visual-p 'page-marker)
4510 (let ((buffer-read-only nil))
4511 (gnus-remove-text-with-property 'gnus-prev)
4512 (gnus-remove-text-with-property 'gnus-next)))
4515 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4517 (re-search-forward page-delimiter nil 'move arg)))
4518 (goto-char (match-end 0)))
4521 (if (re-search-forward page-delimiter nil 'move)
4524 (when (and (gnus-visual-p 'page-marker)
4525 (not (= (point-min) 1)))
4527 (goto-char (point-min))
4528 (gnus-insert-prev-page-button)))
4529 (when (and (gnus-visual-p 'page-marker)
4530 (< (+ (point-max) 2) (buffer-size)))
4532 (goto-char (point-max))
4533 (gnus-insert-next-page-button)))))
4535 ;; Article mode commands
4537 (defun gnus-article-goto-next-page ()
4538 "Show the next page of the article."
4540 (when (gnus-article-next-page)
4541 (goto-char (point-min))
4542 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4544 (defun gnus-article-goto-prev-page ()
4545 "Show the next page of the article."
4547 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4548 (gnus-article-prev-page nil)))
4550 (defun gnus-article-next-page (&optional lines)
4551 "Show the next page of the current article.
4552 If end of article, return non-nil. Otherwise return nil.
4553 Argument LINES specifies lines to be scrolled up."
4555 (move-to-window-line -1)
4558 (and (pos-visible-in-window-p) ;Not continuation line.
4560 ;; Nothing in this page.
4561 (if (or (not gnus-page-broken)
4564 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4566 (gnus-narrow-to-page 1) ;Go to next page.
4568 ;; More in this page.
4569 (let ((scroll-in-place nil))
4573 ;; Long lines may cause an end-of-buffer error.
4574 (goto-char (point-max)))))
4575 (move-to-window-line 0)
4578 (defun gnus-article-prev-page (&optional lines)
4579 "Show previous page of current article.
4580 Argument LINES specifies lines to be scrolled down."
4582 (move-to-window-line 0)
4583 (if (and gnus-page-broken
4585 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4587 (gnus-narrow-to-page -1) ;Go to previous page.
4588 (goto-char (point-max))
4590 (let ((scroll-in-place nil))
4594 (beginning-of-buffer
4595 (goto-char (point-min))))
4596 (move-to-window-line 0)))))
4598 (defun gnus-article-refer-article ()
4599 "Read article specified by message-id around point."
4601 (let ((point (point)))
4602 (search-forward ">" nil t) ;Move point to end of "<....>".
4603 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4604 (let ((message-id (match-string 1)))
4606 (set-buffer gnus-summary-buffer)
4607 (gnus-summary-refer-article message-id))
4609 (error "No references around point"))))
4611 (defun gnus-article-show-summary ()
4612 "Reconfigure windows to show summary buffer."
4614 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4615 (error "There is no summary buffer for this article buffer")
4616 (gnus-article-set-globals)
4617 (gnus-configure-windows 'article)
4618 (gnus-summary-goto-subject gnus-current-article)
4619 (gnus-summary-position-point)))
4621 (defun gnus-article-describe-briefly ()
4622 "Describe article mode commands briefly."
4624 (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")))
4626 (defun gnus-article-summary-command ()
4627 "Execute the last keystroke in the summary buffer."
4629 (let ((obuf (current-buffer))
4630 (owin (current-window-configuration))
4632 (switch-to-buffer gnus-article-current-summary 'norecord)
4633 (setq func (lookup-key (current-local-map) (this-command-keys)))
4634 (call-interactively func)
4636 (set-window-configuration owin)
4637 (set-window-point (get-buffer-window (current-buffer)) (point))))
4639 (defun gnus-article-summary-command-nosave ()
4640 "Execute the last keystroke in the summary buffer."
4643 (pop-to-buffer gnus-article-current-summary 'norecord)
4644 (setq func (lookup-key (current-local-map) (this-command-keys)))
4645 (call-interactively func)))
4647 (defun gnus-article-check-buffer ()
4648 "Beep if not in an article buffer."
4649 (unless (equal major-mode 'gnus-article-mode)
4650 (error "Command invoked outside of a Gnus article buffer")))
4652 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4653 "Read a summary buffer key sequence and execute it from the article buffer."
4655 (gnus-article-check-buffer)
4657 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4658 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4659 "=" "^" "\M-^" "|"))
4665 '("n" "Gn" "p" "Gp"))
4668 (set-buffer gnus-article-current-summary)
4669 (let (gnus-pick-mode)
4670 (push (or key last-command-event) unread-command-events)
4671 (setq keys (if (featurep 'xemacs)
4672 (events-to-keys (read-key-sequence nil))
4673 (read-key-sequence nil)))))
4677 (if (or (member keys nosaves)
4678 (member keys nosave-but-article)
4679 (member keys nosave-in-article))
4681 (save-window-excursion
4682 (pop-to-buffer gnus-article-current-summary 'norecord)
4683 ;; We disable the pick minor mode commands.
4684 (let (gnus-pick-mode)
4685 (setq func (lookup-key (current-local-map) keys))))
4689 (unless (member keys nosave-in-article)
4690 (set-buffer gnus-article-current-summary))
4691 (call-interactively func)
4692 (setq new-sum-point (point)))
4693 (when (member keys nosave-but-article)
4694 (pop-to-buffer gnus-article-buffer 'norecord)))
4695 ;; These commands should restore window configuration.
4696 (let ((obuf (current-buffer))
4697 (owin (current-window-configuration))
4699 (summary gnus-article-current-summary)
4700 func in-buffer selected)
4701 (if not-restore-window
4702 (pop-to-buffer summary 'norecord)
4703 (switch-to-buffer summary 'norecord))
4704 (setq in-buffer (current-buffer))
4705 ;; We disable the pick minor mode commands.
4706 (if (and (setq func (let (gnus-pick-mode)
4707 (lookup-key (current-local-map) keys)))
4710 (call-interactively func)
4711 (setq new-sum-point (point))
4712 (when (eq in-buffer (current-buffer))
4713 (setq selected (gnus-summary-select-article))
4715 (unless not-restore-window
4716 (set-window-configuration owin))
4717 (when (eq selected 'old)
4719 (set-window-start (get-buffer-window (current-buffer))
4721 (set-window-point (get-buffer-window (current-buffer))
4723 (let ((win (get-buffer-window gnus-article-current-summary)))
4725 (set-window-point win new-sum-point)))) )
4726 (switch-to-buffer gnus-article-buffer)
4729 (defun gnus-article-describe-key (key)
4730 "Display documentation of the function invoked by KEY. KEY is a string."
4731 (interactive "kDescribe key: ")
4732 (gnus-article-check-buffer)
4733 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4735 (set-buffer gnus-article-current-summary)
4736 (let (gnus-pick-mode)
4737 (if (featurep 'xemacs)
4739 (push (elt key 0) unread-command-events)
4740 (setq key (events-to-keys
4741 (read-key-sequence "Describe key: "))))
4742 (setq unread-command-events
4744 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4745 (string-to-list key)))
4746 (setq key (read-key-sequence "Describe key: "))))
4748 (describe-key key)))
4750 (defun gnus-article-describe-key-briefly (key &optional insert)
4751 "Display documentation of the function invoked by KEY. KEY is a string."
4752 (interactive "kDescribe key: \nP")
4753 (gnus-article-check-buffer)
4754 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4756 (set-buffer gnus-article-current-summary)
4757 (let (gnus-pick-mode)
4758 (if (featurep 'xemacs)
4760 (push (elt key 0) unread-command-events)
4761 (setq key (events-to-keys
4762 (read-key-sequence "Describe key: "))))
4763 (setq unread-command-events
4765 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4766 (string-to-list key)))
4767 (setq key (read-key-sequence "Describe key: "))))
4768 (describe-key-briefly key insert))
4769 (describe-key-briefly key insert)))
4771 (defun gnus-article-reply-with-original (&optional wide)
4772 "Start composing a reply mail to the current message.
4773 The text in the region will be yanked. If the region isn't active,
4774 the entire article will be yanked."
4776 (let ((article (cdr gnus-article-current)) cont)
4778 (gnus-summary-reply (list (list article)) wide)
4779 (setq cont (buffer-substring (point) (mark t)))
4780 ;; Deactivate active regions.
4781 (when (and (boundp 'transient-mark-mode)
4782 transient-mark-mode)
4783 (setq mark-active nil))
4785 (list (list article cont)) wide))))
4787 (defun gnus-article-followup-with-original ()
4788 "Compose a followup to the current article.
4789 The text in the region will be yanked. If the region isn't active,
4790 the entire article will be yanked."
4792 (let ((article (cdr gnus-article-current))
4795 (gnus-summary-followup (list (list article)))
4796 (setq cont (buffer-substring (point) (mark t)))
4797 ;; Deactivate active regions.
4798 (when (and (boundp 'transient-mark-mode)
4799 transient-mark-mode)
4800 (setq mark-active nil))
4801 (gnus-summary-followup
4802 (list (list article cont))))))
4804 (defun gnus-article-hide (&optional arg force)
4805 "Hide all the gruft in the current article.
4806 This means that PGP stuff, signatures, cited text and (some)
4807 headers will be hidden.
4808 If given a prefix, show the hidden text instead."
4809 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4810 (gnus-article-hide-headers arg)
4811 (gnus-article-hide-list-identifiers arg)
4812 (gnus-article-hide-pgp arg)
4813 (gnus-article-hide-citation-maybe arg force)
4814 (gnus-article-hide-signature arg))
4816 (defun gnus-article-maybe-highlight ()
4817 "Do some article highlighting if article highlighting is requested."
4818 (when (gnus-visual-p 'article-highlight 'highlight)
4819 (gnus-article-highlight-some)))
4821 (defun gnus-check-group-server ()
4822 ;; Make sure the connection to the server is alive.
4823 (unless (gnus-server-opened
4824 (gnus-find-method-for-group gnus-newsgroup-name))
4825 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4826 (gnus-request-group gnus-newsgroup-name t)))
4829 (autoload 'nneething-get-file-name "nneething"))
4831 (defun gnus-request-article-this-buffer (article group)
4832 "Get an article and insert it into this buffer."
4833 (let (do-update-line sparse-header)
4837 (gnus-kill-all-overlays)
4838 (setq group (or group gnus-newsgroup-name))
4840 ;; Using `gnus-request-article' directly will insert the article into
4841 ;; `nntp-server-buffer' - so we'll save some time by not having to
4842 ;; copy it from the server buffer into the article buffer.
4844 ;; We only request an article by message-id when we do not have the
4845 ;; headers for it, so we'll have to get those.
4846 (when (stringp article)
4847 (gnus-read-header article))
4849 ;; If the article number is negative, that means that this article
4850 ;; doesn't belong in this newsgroup (possibly), so we find its
4851 ;; message-id and request it by id instead of number.
4852 (when (and (numberp article)
4854 (get-buffer gnus-summary-buffer)
4855 (gnus-buffer-exists-p gnus-summary-buffer))
4857 (set-buffer gnus-summary-buffer)
4858 (let ((header (gnus-summary-article-header article)))
4861 ((memq article gnus-newsgroup-sparse)
4862 ;; This is a sparse gap article.
4863 (setq do-update-line article)
4864 (setq article (mail-header-id header))
4865 (setq sparse-header (gnus-read-header article))
4866 (setq gnus-newsgroup-sparse
4867 (delq article gnus-newsgroup-sparse)))
4869 ;; It's a real article.
4870 (setq article (mail-header-id header)))
4872 ;; It is an extracted pseudo-article.
4873 (setq article 'pseudo)
4874 (gnus-request-pseudo-article header))))
4876 (let ((method (gnus-find-method-for-group
4877 gnus-newsgroup-name)))
4878 (when (and (eq (car method) 'nneething)
4880 (let ((dir (nneething-get-file-name
4881 (mail-header-id header))))
4882 (when (and (stringp dir)
4883 (file-directory-p dir))
4884 (setq article 'nneething)
4885 (gnus-group-enter-directory dir))))))))
4888 ;; Refuse to select canceled articles.
4889 ((and (numberp article)
4891 (get-buffer gnus-summary-buffer)
4892 (gnus-buffer-exists-p gnus-summary-buffer)
4893 (eq (cdr (save-excursion
4894 (set-buffer gnus-summary-buffer)
4895 (assq article gnus-newsgroup-reads)))
4896 gnus-canceled-mark))
4898 ;; We first check `gnus-original-article-buffer'.
4899 ((and (get-buffer gnus-original-article-buffer)
4902 (set-buffer gnus-original-article-buffer)
4903 (and (equal (car gnus-original-article) group)
4904 (eq (cdr gnus-original-article) article))))
4905 (insert-buffer-substring gnus-original-article-buffer)
4907 ;; Check the backlog.
4908 ((and gnus-keep-backlog
4909 (gnus-backlog-request-article group article (current-buffer)))
4911 ;; Check asynchronous pre-fetch.
4912 ((gnus-async-request-fetched-article group article (current-buffer))
4913 (gnus-async-prefetch-next group article gnus-summary-buffer)
4914 (when (and (numberp article) gnus-keep-backlog)
4915 (gnus-backlog-enter-article group article (current-buffer)))
4918 ((and gnus-use-cache
4920 (gnus-cache-request-article article group))
4922 ;; Check the agent cache.
4923 ((and gnus-agent gnus-agent-cache gnus-plugged
4925 (gnus-agent-request-article article group))
4927 ;; Get the article and put into the article buffer.
4928 ((or (stringp article)
4930 (let ((gnus-override-method gnus-override-method)
4931 (methods (and (stringp article)
4932 gnus-refer-article-method))
4934 (buffer-read-only nil))
4935 (if (or (not (listp methods))
4936 (and (symbolp (car methods))
4937 (assq (car methods) nnoo-definition-alist)))
4938 (setq methods (list methods)))
4939 (when (and (null gnus-override-method)
4941 (setq gnus-override-method (pop methods)))
4943 (when (eq gnus-override-method 'current)
4944 (setq gnus-override-method
4945 (with-current-buffer gnus-summary-buffer
4946 gnus-current-select-method)))
4948 (gnus-kill-all-overlays)
4949 (let ((gnus-newsgroup-name group))
4950 (gnus-check-group-server))
4951 (when (gnus-request-article article group (current-buffer))
4952 (when (numberp article)
4953 (gnus-async-prefetch-next group article
4954 gnus-summary-buffer)
4955 (when gnus-keep-backlog
4956 (gnus-backlog-enter-article
4957 group article (current-buffer))))
4958 (setq result 'article))
4961 (setq gnus-override-method (pop methods))
4962 (setq result 'done))))
4963 (and (eq result 'article) 'article)))
4967 ;; Associate this article with the current summary buffer.
4968 (setq gnus-article-current-summary gnus-summary-buffer)
4970 ;; Take the article from the original article buffer
4971 ;; and place it in the buffer it's supposed to be in.
4972 (when (and (get-buffer gnus-article-buffer)
4973 (equal (buffer-name (current-buffer))
4974 (buffer-name (get-buffer gnus-article-buffer))))
4976 (if (get-buffer gnus-original-article-buffer)
4977 (set-buffer gnus-original-article-buffer)
4978 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4979 (buffer-disable-undo)
4980 (setq major-mode 'gnus-original-article-mode)
4981 (setq buffer-read-only t))
4982 (let (buffer-read-only)
4984 (insert-buffer-substring gnus-article-buffer))
4985 (setq gnus-original-article (cons group article)))
4988 (run-hooks 'gnus-article-decode-hook)
4989 ;; Mark article as decoded or not.
4990 (setq gnus-article-decoded-p gnus-article-decode-hook))
4992 ;; Update sparse articles.
4993 (when (and do-update-line
4994 (or (numberp article)
4996 (let ((buf (current-buffer)))
4997 (set-buffer gnus-summary-buffer)
4998 (gnus-summary-update-article do-update-line sparse-header)
4999 (gnus-summary-goto-subject do-update-line nil t)
5000 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5002 (set-buffer buf))))))
5008 (defcustom gnus-article-edit-mode-hook nil
5009 "Hook run in article edit mode buffers."
5010 :group 'gnus-article-various
5013 (defvar gnus-article-edit-done-function nil)
5015 (defvar gnus-article-edit-mode-map nil)
5017 ;; Should we be using derived.el for this?
5018 (unless gnus-article-edit-mode-map
5019 (setq gnus-article-edit-mode-map (make-sparse-keymap))
5020 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5022 (gnus-define-keys gnus-article-edit-mode-map
5023 "\C-c\C-c" gnus-article-edit-done
5024 "\C-c\C-k" gnus-article-edit-exit)
5026 (gnus-define-keys (gnus-article-edit-wash-map
5027 "\C-c\C-w" gnus-article-edit-mode-map)
5028 "f" gnus-article-edit-full-stops))
5030 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5031 "Major mode for editing articles.
5032 This is an extended text-mode.
5034 \\{gnus-article-edit-mode-map}"
5035 (make-local-variable 'gnus-article-edit-done-function)
5036 (make-local-variable 'gnus-prev-winconf)
5037 (set (make-local-variable 'font-lock-defaults)
5038 '(message-font-lock-keywords t))
5039 (setq buffer-read-only nil)
5040 (buffer-enable-undo)
5043 (defun gnus-article-edit (&optional force)
5044 "Edit the current article.
5045 This will have permanent effect only in mail groups.
5046 If FORCE is non-nil, allow editing of articles even in read-only
5049 (when (and (not force)
5050 (gnus-group-read-only-p))
5051 (error "The current newsgroup does not support article editing"))
5052 (gnus-article-date-original)
5053 (gnus-article-edit-article
5055 `(lambda (no-highlight)
5057 (gnus-summary-edit-article-done
5058 ,(or (mail-header-references gnus-current-headers) "")
5059 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5061 (defun gnus-article-edit-article (start-func exit-func)
5062 "Start editing the contents of the current article buffer."
5063 (let ((winconf (current-window-configuration)))
5064 (set-buffer gnus-article-buffer)
5065 (gnus-article-edit-mode)
5066 (funcall start-func)
5067 (set-buffer-modified-p nil)
5068 (gnus-configure-windows 'edit-article)
5069 (setq gnus-article-edit-done-function exit-func)
5070 (setq gnus-prev-winconf winconf)
5071 (gnus-message 6 "C-c C-c to end edits")))
5073 (defun gnus-article-edit-done (&optional arg)
5074 "Update the article edits and exit."
5076 (let ((func gnus-article-edit-done-function)
5077 (buf (current-buffer))
5078 (start (window-start)))
5079 ;; We remove all text props from the article buffer.
5081 (buffer-substring-no-properties (point-min) (point-max)))
5085 (let ((winconf gnus-prev-winconf))
5087 (set-window-configuration winconf)
5088 ;; Tippy-toe some to make sure that point remains where it was.
5089 (save-current-buffer
5091 (set-window-start (get-buffer-window (current-buffer)) start)
5095 (let ((buffer-read-only nil))
5097 ;; The cache and backlog have to be flushed somewhat.
5098 (when gnus-keep-backlog
5099 (gnus-backlog-remove-article
5100 (car gnus-article-current) (cdr gnus-article-current)))
5101 ;; Flush original article as well.
5103 (when (get-buffer gnus-original-article-buffer)
5104 (set-buffer gnus-original-article-buffer)
5105 (setq gnus-original-article nil)))
5106 (when gnus-use-cache
5107 (gnus-cache-update-article
5108 (car gnus-article-current) (cdr gnus-article-current))))
5110 (set-window-start (get-buffer-window buf) start)
5111 (set-window-point (get-buffer-window buf) (point))))
5113 (defun gnus-article-edit-exit ()
5114 "Exit the article editing without updating."
5116 (when (or (not (buffer-modified-p))
5117 (yes-or-no-p "Article modified; kill anyway? "))
5118 (let ((curbuf (current-buffer))
5120 (window-start (window-start)))
5122 (if (gnus-buffer-live-p gnus-original-article-buffer)
5123 (insert-buffer gnus-original-article-buffer))
5124 (let ((winconf gnus-prev-winconf))
5126 (set-window-configuration winconf)
5127 ;; Tippy-toe some to make sure that point remains where it was.
5128 (save-current-buffer
5130 (set-window-start (get-buffer-window (current-buffer)) window-start)
5133 (defun gnus-article-edit-full-stops ()
5134 "Interactively repair spacing at end of sentences."
5137 (goto-char (point-min))
5138 (search-forward-regexp "^$" nil t)
5139 (let ((case-fold-search nil))
5140 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5143 ;;; Article highlights
5146 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5148 ;;; Internal Variables:
5150 (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\\)\\)"
5151 "Regular expression that matches URLs."
5152 :group 'gnus-article-buttons
5155 (defcustom gnus-button-alist
5156 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5157 0 t gnus-button-handle-news 3)
5158 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5159 gnus-button-handle-news 2)
5160 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5162 gnus-button-fetch-group 4)
5163 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5164 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5165 t gnus-button-message-id 3)
5166 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5167 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5168 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5170 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5171 gnus-button-handle-info 2)
5172 ;; This is how URLs _should_ be embedded in text...
5173 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5175 (,gnus-button-url-regexp 0 t browse-url 0))
5176 "*Alist of regexps matching buttons in article bodies.
5178 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5179 REGEXP: is the string matching text around the button,
5180 BUTTON: is the number of the regexp grouping actually matching the button,
5181 FORM: is a lisp expression which must eval to true for the button to
5183 CALLBACK: is the function to call when the user push this button, and each
5184 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5186 CALLBACK can also be a variable, in that case the value of that
5187 variable it the real callback function."
5188 :group 'gnus-article-buttons
5189 :type '(repeat (list regexp
5190 (integer :tag "Button")
5192 (function :tag "Callback")
5195 (integer :tag "Regexp group")))))
5197 (defcustom gnus-header-button-alist
5198 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5199 0 t gnus-button-message-id 0)
5200 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5201 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5202 0 t gnus-button-mailto 0)
5203 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5204 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5205 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5206 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5207 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5208 gnus-button-message-id 3))
5209 "*Alist of headers and regexps to match buttons in article heads.
5211 This alist is very similar to `gnus-button-alist', except that each
5212 alist has an additional HEADER element first in each entry:
5214 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5216 HEADER is a regexp to match a header. For a fuller explanation, see
5217 `gnus-button-alist'."
5218 :group 'gnus-article-buttons
5219 :group 'gnus-article-headers
5220 :type '(repeat (list (regexp :tag "Header")
5222 (integer :tag "Button")
5224 (function :tag "Callback")
5227 (integer :tag "Regexp group")))))
5229 (defvar gnus-button-regexp nil)
5230 (defvar gnus-button-marker-list nil)
5231 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5233 (defvar gnus-button-last nil)
5234 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5238 (defun gnus-article-push-button (event)
5239 "Check text under the mouse pointer for a callback function.
5240 If the text under the mouse pointer has a `gnus-callback' property,
5241 call it with the value of the `gnus-data' text property."
5243 (set-buffer (window-buffer (posn-window (event-start event))))
5244 (let* ((pos (posn-point (event-start event)))
5245 (data (get-text-property pos 'gnus-data))
5246 (fun (get-text-property pos 'gnus-callback)))
5249 (funcall fun data))))
5251 (defun gnus-article-press-button ()
5252 "Check text at point for a callback function.
5253 If the text at point has a `gnus-callback' property,
5254 call it with the value of the `gnus-data' text property."
5256 (let* ((data (get-text-property (point) 'gnus-data))
5257 (fun (get-text-property (point) 'gnus-callback)))
5259 (funcall fun data))))
5261 (defun gnus-article-highlight (&optional force)
5262 "Highlight current article.
5263 This function calls `gnus-article-highlight-headers',
5264 `gnus-article-highlight-citation',
5265 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5266 do the highlighting. See the documentation for those functions."
5267 (interactive (list 'force))
5268 (gnus-article-highlight-headers)
5269 (gnus-article-highlight-citation force)
5270 (gnus-article-highlight-signature)
5271 (gnus-article-add-buttons force)
5272 (gnus-article-add-buttons-to-head))
5274 (defun gnus-article-highlight-some (&optional force)
5275 "Highlight current article.
5276 This function calls `gnus-article-highlight-headers',
5277 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5278 do the highlighting. See the documentation for those functions."
5279 (interactive (list 'force))
5280 (gnus-article-highlight-headers)
5281 (gnus-article-highlight-signature)
5282 (gnus-article-add-buttons))
5284 (defun gnus-article-highlight-headers ()
5285 "Highlight article headers as specified by `gnus-header-face-alist'."
5288 (set-buffer gnus-article-buffer)
5290 (let ((alist gnus-header-face-alist)
5291 (buffer-read-only nil)
5292 (case-fold-search t)
5293 (inhibit-point-motion-hooks t)
5294 entry regexp header-face field-face from hpoints fpoints)
5295 (article-narrow-to-head)
5296 (while (setq entry (pop alist))
5297 (goto-char (point-min))
5298 (setq regexp (concat "^\\("
5299 (if (string-equal "" (nth 0 entry))
5303 header-face (nth 1 entry)
5304 field-face (nth 2 entry))
5305 (while (and (re-search-forward regexp nil t)
5309 (unless (search-forward ":" nil t)
5311 (when (and header-face
5312 (not (memq (point) hpoints)))
5313 (push (point) hpoints)
5314 (gnus-put-text-property from (point) 'face header-face))
5315 (when (and field-face
5316 (not (memq (setq from (point)) fpoints)))
5318 (if (re-search-forward "^[^ \t]" nil t)
5320 (goto-char (point-max)))
5321 (gnus-put-text-property from (point) 'face field-face))))))))
5323 (defun gnus-article-highlight-signature ()
5324 "Highlight the signature in an article.
5325 It does this by highlighting everything after
5326 `gnus-signature-separator' using `gnus-signature-face'."
5329 (set-buffer gnus-article-buffer)
5330 (let ((buffer-read-only nil)
5331 (inhibit-point-motion-hooks t))
5333 (when (and gnus-signature-face
5334 (gnus-article-narrow-to-signature))
5335 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5336 'face gnus-signature-face)
5338 (gnus-article-search-signature)
5339 (let ((start (match-beginning 0))
5340 (end (set-marker (make-marker) (1+ (match-end 0)))))
5341 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5344 (defun gnus-button-in-region-p (b e prop)
5345 "Say whether PROP exists in the region."
5346 (text-property-not-all b e prop nil))
5348 (defun gnus-article-add-buttons (&optional force)
5349 "Find external references in the article and make buttons of them.
5350 \"External references\" are things like Message-IDs and URLs, as
5351 specified by `gnus-button-alist'."
5352 (interactive (list 'force))
5354 (set-buffer gnus-article-buffer)
5355 (let ((buffer-read-only nil)
5356 (inhibit-point-motion-hooks t)
5357 (case-fold-search t)
5358 (alist gnus-button-alist)
5360 ;; Remove all old markers.
5361 (let (marker entry new-list)
5362 (while (setq marker (pop gnus-button-marker-list))
5363 (if (or (< marker (point-min)) (>= marker (point-max)))
5364 (push marker new-list)
5366 (when (setq entry (gnus-button-entry))
5367 (put-text-property (match-beginning (nth 1 entry))
5368 (match-end (nth 1 entry))
5369 'gnus-callback nil))
5370 (set-marker marker nil)))
5371 (setq gnus-button-marker-list new-list))
5372 ;; We skip the headers.
5375 (while (setq entry (pop alist))
5376 (setq regexp (car entry))
5378 (while (re-search-forward regexp nil t)
5379 (let* ((start (and entry (match-beginning (nth 1 entry))))
5380 (end (and entry (match-end (nth 1 entry))))
5381 (from (match-beginning 0)))
5382 (when (and (or (eq t (nth 2 entry))
5383 (eval (nth 2 entry)))
5384 (not (gnus-button-in-region-p
5385 start end 'gnus-callback)))
5386 ;; That optional form returned non-nil, so we add the
5388 (gnus-article-add-button
5389 start end 'gnus-button-push
5390 (car (push (set-marker (make-marker) from)
5391 gnus-button-marker-list))))))))))
5393 ;; Add buttons to the head of an article.
5394 (defun gnus-article-add-buttons-to-head ()
5395 "Add buttons to the head of the article."
5398 (set-buffer gnus-article-buffer)
5400 (let ((buffer-read-only nil)
5401 (inhibit-point-motion-hooks t)
5402 (case-fold-search t)
5403 (alist gnus-header-button-alist)
5405 (article-narrow-to-head)
5407 ;; Each alist entry.
5408 (setq entry (car alist)
5410 (goto-char (point-min))
5411 (while (re-search-forward (car entry) nil t)
5412 ;; Each header matching the entry.
5413 (setq beg (match-beginning 0))
5414 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5415 (match-beginning 0))
5418 (while (re-search-forward (nth 1 entry) end t)
5419 ;; Each match within a header.
5420 (let* ((entry (cdr entry))
5421 (start (match-beginning (nth 1 entry)))
5422 (end (match-end (nth 1 entry)))
5423 (form (nth 2 entry)))
5424 (goto-char (match-end 0))
5426 (gnus-article-add-button
5427 start end (nth 3 entry)
5428 (buffer-substring (match-beginning (nth 4 entry))
5429 (match-end (nth 4 entry)))))))
5430 (goto-char end)))))))
5432 ;;; External functions:
5434 (defun gnus-article-add-button (from to fun &optional data)
5435 "Create a button between FROM and TO with callback FUN and data DATA."
5436 (when gnus-article-button-face
5437 (gnus-overlay-put (gnus-make-overlay from to)
5438 'face gnus-article-button-face))
5439 (gnus-add-text-properties
5441 (nconc (and gnus-article-mouse-face
5442 (list gnus-mouse-face-prop gnus-article-mouse-face))
5443 (list 'gnus-callback fun)
5444 (and data (list 'gnus-data data))))
5445 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5446 :button-keymap gnus-widget-button-keymap))
5448 ;;; Internal functions:
5450 (defun gnus-article-set-globals ()
5452 (set-buffer gnus-summary-buffer)
5453 (gnus-set-global-variables)))
5455 (defun gnus-signature-toggle (end)
5457 (set-buffer gnus-article-buffer)
5458 (let ((buffer-read-only nil)
5459 (inhibit-point-motion-hooks t))
5460 (if (text-property-any end (point-max) 'article-type 'signature)
5462 (gnus-delete-wash-type 'signature)
5463 (gnus-remove-text-properties-when
5464 'article-type 'signature end (point-max)
5465 (cons 'article-type (cons 'signature
5466 gnus-hidden-properties))))
5467 (gnus-add-wash-type 'signature)
5468 (gnus-add-text-properties-when
5469 'article-type nil end (point-max)
5470 (cons 'article-type (cons 'signature
5471 gnus-hidden-properties)))))
5472 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5473 (gnus-set-mode-line 'article))))
5475 (defun gnus-button-entry ()
5476 ;; Return the first entry in `gnus-button-alist' matching this place.
5477 (let ((alist gnus-button-alist)
5480 (setq entry (pop alist))
5481 (if (looking-at (car entry))
5486 (defun gnus-button-push (marker)
5487 ;; Push button starting at MARKER.
5490 (let* ((entry (gnus-button-entry))
5491 (inhibit-point-motion-hooks t)
5493 (args (mapcar (lambda (group)
5494 (let ((string (match-string group)))
5495 (gnus-set-text-properties
5496 0 (length string) nil string)
5503 (fboundp (symbol-value fun)))
5504 (apply (symbol-value fun) args))
5506 (gnus-message 1 "You must define `%S' to use this button"
5507 (cons fun args)))))))
5509 (defun gnus-parse-news-url (url)
5510 (let (scheme server group message-id articles)
5513 (goto-char (point-min))
5514 (when (looking-at "\\([A-Za-z]+\\):")
5515 (setq scheme (match-string 1))
5516 (goto-char (match-end 0)))
5517 (when (looking-at "//\\([^/]+\\)/")
5518 (setq server (match-string 1))
5519 (goto-char (match-end 0)))
5522 ((looking-at "\\(.*@.*\\)")
5523 (setq message-id (match-string 1)))
5524 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5525 (setq group (match-string 1)
5526 articles (split-string (match-string 2) "-")))
5527 ((looking-at "\\([^/]+\\)/?")
5528 (setq group (match-string 1)))
5530 (error "Unknown news URL syntax"))))
5531 (list scheme server group message-id articles)))
5533 (defun gnus-button-handle-news (url)
5535 (destructuring-bind (scheme server group message-id articles)
5536 (gnus-parse-news-url url)
5540 (set-buffer gnus-summary-buffer)
5542 (let ((gnus-refer-article-method (list (list 'nntp server))))
5543 (gnus-summary-refer-article message-id))
5544 (gnus-summary-refer-article message-id))))
5546 (gnus-button-fetch-group url)))))
5548 (defun gnus-button-handle-info (url)
5549 "Fetch an info URL."
5551 "^\\([^:/]+\\)?/\\(.*\\)"
5553 (gnus-info-find-node
5554 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5557 (gnus-url-unhex-string (match-string 2 url))))
5558 (error "Can't parse %s" url)))
5560 (defun gnus-button-message-id (message-id)
5563 (set-buffer gnus-summary-buffer)
5564 (gnus-summary-refer-article message-id)))
5566 (defun gnus-button-fetch-group (address)
5567 "Fetch GROUP specified by ADDRESS."
5568 (if (not (string-match "[:/]" address))
5569 ;; This is just a simple group url.
5570 (gnus-group-read-ephemeral-group address gnus-select-method)
5573 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5575 (error "Can't parse %s" address)
5576 (gnus-group-read-ephemeral-group
5577 (match-string 4 address)
5578 `(nntp ,(match-string 1 address)
5579 (nntp-address ,(match-string 1 address))
5580 (nntp-port-number ,(if (match-end 3)
5581 (match-string 3 address)
5584 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5586 (defun gnus-url-parse-query-string (query &optional downcase)
5587 (let (retval pairs cur key val)
5588 (setq pairs (split-string query "&"))
5590 (setq cur (car pairs)
5592 (if (not (string-match "=" cur))
5594 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5595 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5597 (setq key (downcase key)))
5598 (setq cur (assoc key retval))
5600 (setcdr cur (cons val (cdr cur)))
5601 (setq retval (cons (list key val) retval)))))
5604 (defun gnus-url-mailto (url)
5605 ;; Send mail to someone
5606 (when (string-match "mailto:/*\\(.*\\)" url)
5607 (setq url (substring url (match-beginning 1) nil)))
5608 (let (to args subject func)
5609 (if (string-match (regexp-quote "?") url)
5610 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5611 args (gnus-url-parse-query-string
5612 (substring url (match-end 0) nil) t))
5613 (setq to (gnus-url-unhex-string url)))
5614 (setq args (cons (list "to" to) args)
5615 subject (cdr-safe (assoc "subject" args)))
5618 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5621 (message-position-on-field (caar args)))
5622 (insert (mapconcat 'identity (cdar args) ", "))
5623 (setq args (cdr args)))
5626 (message-goto-subject))))
5628 (defun gnus-button-embedded-url (address)
5629 "Activate ADDRESS with `browse-url'."
5630 (browse-url (gnus-strip-whitespace address)))
5632 ;;; Next/prev buttons in the article buffer.
5634 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5635 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5637 (defvar gnus-prev-page-map
5638 (let ((map (make-sparse-keymap)))
5639 (unless (>= emacs-major-version 21)
5640 ;; XEmacs doesn't care.
5641 (set-keymap-parent map gnus-article-mode-map))
5642 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5643 (define-key map "\r" 'gnus-button-prev-page)
5646 (defun gnus-insert-prev-page-button ()
5648 (buffer-read-only nil))
5650 gnus-prev-page-line-format nil
5651 `(,@(gnus-local-map-property gnus-prev-page-map)
5653 gnus-callback gnus-article-button-prev-page
5654 article-type annotation))
5655 (widget-convert-button
5657 :action 'gnus-button-prev-page
5658 :button-keymap gnus-prev-page-map)))
5660 (defvar gnus-prev-page-map
5661 (let ((map (make-sparse-keymap)))
5662 (unless (>= emacs-major-version 21)
5663 ;; XEmacs doesn't care.
5664 (set-keymap-parent map gnus-article-mode-map))
5665 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5666 (define-key map "\r" 'gnus-button-prev-page)
5669 (defvar gnus-next-page-map
5670 (let ((map (make-sparse-keymap)))
5671 (unless (>= emacs-major-version 21)
5672 ;; XEmacs doesn't care.
5673 (set-keymap-parent map gnus-article-mode-map))
5674 (define-key map gnus-mouse-2 'gnus-button-next-page)
5675 (define-key map "\r" 'gnus-button-next-page)
5678 (defun gnus-button-next-page (&optional args more-args)
5679 "Go to the next page."
5681 (let ((win (selected-window)))
5682 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5683 (gnus-article-next-page)
5684 (select-window win)))
5686 (defun gnus-button-prev-page (&optional args more-args)
5687 "Go to the prev page."
5689 (let ((win (selected-window)))
5690 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5691 (gnus-article-prev-page)
5692 (select-window win)))
5694 (defun gnus-insert-next-page-button ()
5696 (buffer-read-only nil))
5697 (gnus-eval-format gnus-next-page-line-format nil
5698 `(,@(gnus-local-map-property gnus-next-page-map)
5700 gnus-callback gnus-article-button-next-page
5701 article-type annotation))
5702 (widget-convert-button
5704 :action 'gnus-button-next-page
5705 :button-keymap gnus-next-page-map)))
5707 (defun gnus-article-button-next-page (arg)
5708 "Go to the next page."
5710 (let ((win (selected-window)))
5711 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5712 (gnus-article-next-page)
5713 (select-window win)))
5715 (defun gnus-article-button-prev-page (arg)
5716 "Go to the prev page."
5718 (let ((win (selected-window)))
5719 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5720 (gnus-article-prev-page)
5721 (select-window win)))
5723 (defvar gnus-decode-header-methods
5724 '(mail-decode-encoded-word-region)
5725 "List of methods used to decode headers.
5727 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5728 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5729 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5730 whose names match REGEXP.
5733 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5734 mail-decode-encoded-word-region
5735 (\"chinese\" . rfc1843-decode-region))
5738 (defvar gnus-decode-header-methods-cache nil)
5740 (defun gnus-multi-decode-header (start end)
5741 "Apply the functions from `gnus-encoded-word-methods' that match."
5742 (unless (and gnus-decode-header-methods-cache
5743 (eq gnus-newsgroup-name
5744 (car gnus-decode-header-methods-cache)))
5745 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5748 (nconc gnus-decode-header-methods-cache (list x))
5749 (if (and gnus-newsgroup-name
5750 (string-match (car x) gnus-newsgroup-name))
5751 (nconc gnus-decode-header-methods-cache
5753 gnus-decode-header-methods))
5754 (let ((xlist gnus-decode-header-methods-cache))
5757 (narrow-to-region start end)
5759 (funcall (pop xlist) (point-min) (point-max))))))
5762 ;;; Treatment top-level handling.
5765 (defun gnus-treat-article (condition &optional part-number total-parts type)
5766 (let ((length (- (point-max) (point-min)))
5767 (alist gnus-treatment-function-alist)
5768 (article-goto-body-goes-to-point-min-p t)
5772 (let ((list gnus-article-treat-types))
5774 (when (string-match (pop list) type)
5775 (throw 'found t)))))))
5776 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5778 (gnus-run-hooks 'gnus-part-display-hook)
5779 (while (setq elem (pop alist))
5782 (if (gnus-buffer-live-p gnus-summary-buffer)
5783 (set-buffer gnus-summary-buffer))
5784 (symbol-value (car elem))))
5785 (when (and (or (consp val)
5787 (gnus-treat-predicate val)
5788 (or (not (get (car elem) 'highlight))
5791 (funcall (cadr elem)))))))
5793 ;; Dynamic variables.
5795 (defvar part-number)
5796 (defvar total-parts)
5801 (defun gnus-treat-predicate (val)
5806 (stringp (car val)))
5807 (apply 'gnus-or (mapcar `(lambda (s)
5808 (string-match s ,(or gnus-newsgroup-name "")))
5811 (let ((pred (pop val)))
5814 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5816 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5818 (not (gnus-treat-predicate (car val))))
5820 (equal (car val) type))
5822 (error "%S is not a valid predicate" pred)))))
5830 (eq part-number total-parts))
5834 (error "%S is not a valid value" val))))
5836 (defun gnus-article-encrypt-body (protocol &optional n)
5837 "Encrypt the article body."
5840 (or gnus-article-encrypt-protocol
5841 (completing-read "Encrypt protocol: "
5842 gnus-article-encrypt-protocol-alist
5844 current-prefix-arg))
5845 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5847 (error (format "Can't find the encrypt protocol %s" protocol)))
5848 (if (equal gnus-newsgroup-name "nndraft:drafts")
5849 (error "Can't encrypt the article in group nndraft:drafts"))
5850 (if (equal gnus-newsgroup-name "nndraft:queue")
5851 (error "Don't encrypt the article in group nndraft:queue"))
5852 (gnus-summary-iterate n
5854 (set-buffer gnus-summary-buffer)
5855 (let ((mail-parse-charset gnus-newsgroup-charset)
5856 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5857 (summary-buffer gnus-summary-buffer)
5859 (gnus-set-global-variables)
5860 (when (gnus-group-read-only-p)
5861 (error "The current newsgroup does not support article encrypt"))
5862 (gnus-summary-show-article t)
5864 (or (mail-header-references gnus-current-headers) ""))
5865 (set-buffer gnus-article-buffer)
5866 (let* ((buffer-read-only nil)
5868 (mapcar (lambda (field)
5869 (and (save-restriction
5870 (message-narrow-to-head)
5871 (goto-char (point-min))
5872 (search-forward field nil t))
5874 (message-narrow-to-field)
5875 (buffer-substring (point-min) (point-max))
5876 (delete-region (point-min) (point-max))
5878 '("Content-Type:" "Content-Transfer-Encoding:"
5879 "Content-Disposition:"))))
5880 (message-narrow-to-head)
5881 (message-remove-header "MIME-Version")
5882 (goto-char (point-max))
5883 (setq point (point))
5884 (insert (apply 'concat headers))
5886 (narrow-to-region point (point-max))
5887 (let ((message-options message-options))
5888 (message-options-set 'message-sender user-mail-address)
5889 (message-options-set 'message-recipients user-mail-address)
5890 (message-options-set 'message-sign-encrypt 'not)
5892 (goto-char (point-min))
5893 (insert "MIME-Version: 1.0\n")
5895 (gnus-summary-edit-article-done
5896 references nil summary-buffer t))
5897 (when gnus-keep-backlog
5898 (gnus-backlog-remove-article
5899 (car gnus-article-current) (cdr gnus-article-current)))
5901 (when (get-buffer gnus-original-article-buffer)
5902 (set-buffer gnus-original-article-buffer)
5903 (setq gnus-original-article nil)))
5904 (when gnus-use-cache
5905 (gnus-cache-update-article
5906 (car gnus-article-current) (cdr gnus-article-current))))))))
5908 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5909 "The following specs can be used:
5910 %t The security MIME type
5913 %D Details if button is pressed")
5915 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5916 "The following specs can be used:
5917 %t The security MIME type
5920 %D Details if button is pressed")
5922 (defvar gnus-mime-security-button-line-format-alist
5923 '((?t gnus-tmp-type ?s)
5924 (?i gnus-tmp-info ?s)
5925 (?d gnus-tmp-details ?s)
5926 (?D gnus-tmp-pressed-details ?s)))
5928 (defvar gnus-mime-security-button-map
5929 (let ((map (make-sparse-keymap)))
5930 (unless (>= (string-to-number emacs-version) 21)
5931 (set-keymap-parent map gnus-article-mode-map))
5932 (define-key map gnus-mouse-2 'gnus-article-push-button)
5933 (define-key map "\r" 'gnus-article-press-button)
5936 (defvar gnus-mime-security-details-buffer nil)
5938 (defvar gnus-mime-security-button-pressed nil)
5940 (defvar gnus-mime-security-show-details-inline t
5941 "If non-nil, show details in the article buffer.")
5943 (defun gnus-mime-security-verify-or-decrypt (handle)
5944 (mm-remove-parts (cdr handle))
5945 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5946 point buffer-read-only)
5948 (goto-char (car region)))
5950 (narrow-to-region (point) (point))
5951 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5952 (let* ((mm-verify-option 'known)
5953 (mm-decrypt-option 'known)
5954 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5955 (unless (eq nparts (cdr handle))
5956 (mm-destroy-parts (cdr handle))
5957 (setcdr handle nparts))))
5958 (setq point (point))
5959 (gnus-mime-display-security handle)
5960 (goto-char (point-max)))
5962 (delete-region (point) (cdr region))
5963 (set-marker (car region) nil)
5964 (set-marker (cdr region) nil))
5967 (defun gnus-mime-security-show-details (handle)
5968 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5970 (if gnus-mime-security-show-details-inline
5971 (let ((gnus-mime-security-button-pressed t)
5972 (gnus-mime-security-button-line-format
5973 (get-text-property (point) 'gnus-line-format))
5976 (while (eq (get-text-property (point) 'gnus-line-format)
5977 gnus-mime-security-button-line-format)
5981 (narrow-to-region (point) (point))
5982 (gnus-insert-mime-security-button handle))
5983 (delete-region (point)
5984 (or (text-property-not-all
5987 gnus-mime-security-button-line-format)
5989 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5990 (with-current-buffer gnus-mime-security-details-buffer
5993 (setq gnus-mime-security-details-buffer
5994 (gnus-get-buffer-create "*MIME Security Details*")))
5995 (with-current-buffer gnus-mime-security-details-buffer
5997 (goto-char (point-min)))
5998 (pop-to-buffer gnus-mime-security-details-buffer))
5999 (gnus-message 5 "No details."))))
6001 (defun gnus-mime-security-press-button (handle)
6002 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6003 (gnus-mime-security-show-details handle)
6004 (gnus-mime-security-verify-or-decrypt handle)))
6006 (defun gnus-insert-mime-security-button (handle &optional displayed)
6007 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6010 (or (nth 2 (assoc protocol mm-verify-function-alist))
6011 (nth 2 (assoc protocol mm-decrypt-function-alist))
6013 (if (equal (car handle) "multipart/signed")
6014 " Signed" " Encrypted")
6017 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6020 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6021 gnus-tmp-pressed-details
6023 (setq gnus-tmp-details
6024 (if gnus-tmp-details
6025 (concat "\n" gnus-tmp-details) ""))
6026 (setq gnus-tmp-pressed-details
6027 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6032 gnus-mime-security-button-line-format
6033 gnus-mime-security-button-line-format-alist
6034 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6035 gnus-callback gnus-mime-security-press-button
6036 gnus-line-format ,gnus-mime-security-button-line-format
6037 article-type annotation
6040 (widget-convert-button
6043 :action 'gnus-widget-press-button
6044 :button-keymap gnus-mime-security-button-map
6046 (lambda (widget/window &optional overlay pos)
6047 ;; Needed to properly clear the message due to a bug in
6048 ;; wid-edit (XEmacs only).
6049 (if (boundp 'help-echo-owns-message)
6050 (setq help-echo-owns-message t))
6053 (aref gnus-mouse-2 0))))))
6055 (defun gnus-mime-display-security (handle)
6057 (narrow-to-region (point) (point))
6058 (unless (gnus-unbuttonized-mime-type-p (car handle))
6059 (gnus-insert-mime-security-button handle))
6060 (gnus-mime-display-mixed (cdr handle))
6063 (unless (gnus-unbuttonized-mime-type-p (car handle))
6064 (let ((gnus-mime-security-button-line-format
6065 gnus-mime-security-button-end-line-format))
6066 (gnus-insert-mime-security-button handle)))
6067 (mm-set-handle-multipart-parameter
6069 (cons (set-marker (make-marker) (point-min))
6070 (set-marker (make-marker) (point-max))))))
6076 (run-hooks 'gnus-art-load-hook)
6078 ;;; gnus-art.el ends here