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 (or (and (fboundp 'image-type-available-p)
1074 (image-type-available-p 'xbm)
1075 (string-match "^0x" (shell-command-to-string "uncompface")))
1076 (and (featurep 'xemacs)
1079 "Display X-Face headers.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' and Info node
1082 `(gnus)X-Face' for details."
1083 :group 'gnus-article-treat
1085 :type gnus-article-treat-head-custom)
1086 (put 'gnus-treat-display-xface 'highlight t)
1088 (defcustom gnus-treat-display-smileys
1089 (if (or (and (featurep 'xemacs)
1091 (and (fboundp 'image-type-available-p)
1092 (image-type-available-p 'pbm)))
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' and Info node
1097 `(gnus)Smileys' for details."
1098 :group 'gnus-article-treat
1100 :type gnus-article-treat-custom)
1101 (put 'gnus-treat-display-smileys 'highlight t)
1103 (defcustom gnus-treat-from-picon
1104 (if (and (gnus-image-type-available-p 'xpm)
1105 (gnus-picons-installed-p))
1107 "Display picons in the From header.
1108 Valid values are nil, t, `head', `last', an integer or a predicate.
1109 See Info node `(gnus)Customizing Articles' and Info node
1110 `(gnus)Picons' for details."
1111 :group 'gnus-article-treat
1112 :type gnus-article-treat-head-custom)
1113 (put 'gnus-treat-from-picon 'highlight t)
1115 (defcustom gnus-treat-mail-picon
1116 (if (and (gnus-image-type-available-p 'xpm)
1117 (gnus-picons-installed-p))
1119 "Display picons in To and Cc headers.
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-mail-picon 'highlight t)
1127 (defcustom gnus-treat-newsgroups-picon
1128 (if (and (gnus-image-type-available-p 'xpm)
1129 (gnus-picons-installed-p))
1131 "Display picons in the Newsgroups and Followup-To 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-newsgroups-picon 'highlight t)
1139 (defcustom gnus-treat-body-boundary
1140 (if (or gnus-treat-newsgroups-picon
1141 gnus-treat-mail-picon
1142 gnus-treat-from-picon)
1144 "Draw a boundary at the end of the headers.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :type gnus-article-treat-custom)
1151 (defcustom gnus-treat-capitalize-sentences nil
1152 "Capitalize sentence-starting words.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :type gnus-article-treat-custom)
1159 (defcustom gnus-treat-fill-long-lines nil
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group 'gnus-article-treat
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-play-sounds nil
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1171 :group 'gnus-article-treat
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-translate nil
1175 "Translate articles from one language to another.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1179 :group 'gnus-article-treat
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-x-pgp-sig nil
1184 To automatically treat X-PGP-Sig, set it to head.
1185 Valid values are nil, t, `head', `last', an integer or a predicate.
1186 See Info node `(gnus)Customizing Articles' for details."
1187 :group 'gnus-article-treat
1188 :group 'mime-security
1189 :type gnus-article-treat-custom)
1191 (defvar gnus-article-encrypt-protocol-alist
1192 '(("PGP" . mml2015-self-encrypt)))
1194 ;; Set to nil if more than one protocol added to
1195 ;; gnus-article-encrypt-protocol-alist.
1196 (defcustom gnus-article-encrypt-protocol "PGP"
1197 "The protocol used for encrypt articles.
1198 It is a string, such as \"PGP\". If nil, ask user."
1200 :group 'mime-security)
1202 (defcustom gnus-article-wash-function
1203 (cond ((locate-library "w3")
1204 'gnus-article-wash-html-with-w3)
1205 ((locate-library "w3m")
1206 'gnus-article-wash-html-with-w3m))
1207 "Function used for converting HTML into text."
1208 :type '(radio (function-item gnus-article-wash-html-with-w3)
1209 (function-item gnus-article-wash-html-with-w3m))
1210 :group 'gnus-article)
1212 ;;; Internal variables
1214 (defvar gnus-english-month-names
1215 '("January" "February" "March" "April" "May" "June" "July" "August"
1216 "September" "October" "November" "December"))
1218 (defvar article-goto-body-goes-to-point-min-p nil)
1219 (defvar gnus-article-wash-types nil)
1220 (defvar gnus-article-emphasis-alist nil)
1221 (defvar gnus-article-image-alist nil)
1223 (defvar gnus-article-mime-handle-alist-1 nil)
1224 (defvar gnus-treatment-function-alist
1225 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1226 (gnus-treat-strip-banner gnus-article-strip-banner)
1227 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1228 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1229 (gnus-treat-buttonize gnus-article-add-buttons)
1230 (gnus-treat-fill-article gnus-article-fill-cited-article)
1231 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1232 (gnus-treat-strip-cr gnus-article-remove-cr)
1233 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1234 (gnus-treat-date-ut gnus-article-date-ut)
1235 (gnus-treat-date-local gnus-article-date-local)
1236 (gnus-treat-date-english gnus-article-date-english)
1237 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1238 (gnus-treat-date-original gnus-article-date-original)
1239 (gnus-treat-date-user-defined gnus-article-date-user)
1240 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1241 (gnus-treat-display-xface gnus-article-display-x-face)
1242 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1243 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1244 (gnus-treat-hide-signature gnus-article-hide-signature)
1245 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1246 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1247 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1248 (gnus-treat-strip-pem gnus-article-hide-pem)
1249 (gnus-treat-from-picon gnus-treat-from-picon)
1250 (gnus-treat-mail-picon gnus-treat-mail-picon)
1251 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1252 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1253 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1254 (gnus-treat-strip-trailing-blank-lines
1255 gnus-article-remove-trailing-blank-lines)
1256 (gnus-treat-strip-leading-blank-lines
1257 gnus-article-strip-leading-blank-lines)
1258 (gnus-treat-strip-multiple-blank-lines
1259 gnus-article-strip-multiple-blank-lines)
1260 (gnus-treat-overstrike gnus-article-treat-overstrike)
1261 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1262 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1263 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1264 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1265 (gnus-treat-display-smileys gnus-treat-smiley)
1266 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1267 (gnus-treat-emphasize gnus-article-emphasize)
1268 (gnus-treat-hide-citation gnus-article-hide-citation)
1269 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1270 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1271 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1272 (gnus-treat-play-sounds gnus-earcon-display)))
1274 (defvar gnus-article-mime-handle-alist nil)
1275 (defvar article-lapsed-timer nil)
1276 (defvar gnus-article-current-summary nil)
1278 (defvar gnus-article-mode-syntax-table
1279 (let ((table (copy-syntax-table text-mode-syntax-table)))
1280 ;; This causes the citation match run O(2^n).
1281 ;; (modify-syntax-entry ?- "w" table)
1282 (modify-syntax-entry ?> ")" table)
1283 (modify-syntax-entry ?< "(" table)
1285 "Syntax table used in article mode buffers.
1286 Initialized from `text-mode-syntax-table.")
1288 (defvar gnus-save-article-buffer nil)
1290 (defvar gnus-article-mode-line-format-alist
1291 (nconc '((?w (gnus-article-wash-status) ?s)
1292 (?m (gnus-article-mime-part-status) ?s))
1293 gnus-summary-mode-line-format-alist))
1295 (defvar gnus-number-of-articles-to-be-saved nil)
1297 (defvar gnus-inhibit-hiding nil)
1299 ;;; Macros for dealing with the article buffer.
1301 (defmacro gnus-with-article-headers (&rest forms)
1303 (set-buffer gnus-article-buffer)
1305 (let ((buffer-read-only nil)
1306 (inhibit-point-motion-hooks t)
1307 (case-fold-search t))
1308 (article-narrow-to-head)
1311 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1312 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1314 (defmacro gnus-with-article-buffer (&rest forms)
1316 (set-buffer gnus-article-buffer)
1317 (let ((buffer-read-only nil))
1320 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1321 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1323 (defun gnus-article-goto-header (header)
1324 "Go to HEADER, which is a regular expression."
1325 (re-search-forward (concat "^\\(" header "\\):") nil t))
1327 (defsubst gnus-article-hide-text (b e props)
1328 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1329 (gnus-add-text-properties-when 'article-type nil b e props)
1330 (when (memq 'intangible props)
1332 (max (1- b) (point-min))
1333 b 'intangible (cddr (memq 'intangible props)))))
1335 (defsubst gnus-article-unhide-text (b e)
1336 "Remove hidden text properties from region between B and E."
1337 (remove-text-properties b e gnus-hidden-properties)
1338 (when (memq 'intangible gnus-hidden-properties)
1339 (put-text-property (max (1- b) (point-min))
1340 b 'intangible nil)))
1342 (defun gnus-article-hide-text-type (b e type)
1343 "Hide text of TYPE between B and E."
1344 (gnus-add-wash-type type)
1345 (gnus-article-hide-text
1346 b e (cons 'article-type (cons type gnus-hidden-properties))))
1348 (defun gnus-article-unhide-text-type (b e type)
1349 "Unhide text of TYPE between B and E."
1350 (gnus-delete-wash-type type)
1351 (remove-text-properties
1352 b e (cons 'article-type (cons type gnus-hidden-properties)))
1353 (when (memq 'intangible gnus-hidden-properties)
1354 (put-text-property (max (1- b) (point-min))
1355 b 'intangible nil)))
1357 (defun gnus-article-hide-text-of-type (type)
1358 "Hide text of TYPE in the current buffer."
1360 (let ((b (point-min))
1362 (while (setq b (text-property-any b e 'article-type type))
1363 (add-text-properties b (incf b) gnus-hidden-properties)))))
1365 (defun gnus-article-delete-text-of-type (type)
1366 "Delete text of TYPE in the current buffer."
1368 (let ((b (point-min)))
1369 (while (setq b (text-property-any b (point-max) 'article-type type))
1371 b (or (text-property-not-all b (point-max) 'article-type type)
1374 (defun gnus-article-delete-invisible-text ()
1375 "Delete all invisible text in the current buffer."
1377 (let ((b (point-min)))
1378 (while (setq b (text-property-any b (point-max) 'invisible t))
1380 b (or (text-property-not-all b (point-max) 'invisible t)
1383 (defun gnus-article-text-type-exists-p (type)
1384 "Say whether any text of type TYPE exists in the buffer."
1385 (text-property-any (point-min) (point-max) 'article-type type))
1387 (defsubst gnus-article-header-rank ()
1388 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1389 (let ((list gnus-sorted-header-list)
1392 (when (looking-at (car list))
1394 (setq list (cdr list))
1398 (defun article-hide-headers (&optional arg delete)
1399 "Hide unwanted headers and possibly sort them as well."
1401 ;; This function might be inhibited.
1402 (unless gnus-inhibit-hiding
1405 (let ((buffer-read-only nil)
1406 (case-fold-search t)
1407 (max (1+ (length gnus-sorted-header-list)))
1408 (ignored (when (not gnus-visible-headers)
1409 (cond ((stringp gnus-ignored-headers)
1410 gnus-ignored-headers)
1411 ((listp gnus-ignored-headers)
1412 (mapconcat 'identity gnus-ignored-headers
1415 (cond ((stringp gnus-visible-headers)
1416 gnus-visible-headers)
1417 ((and gnus-visible-headers
1418 (listp gnus-visible-headers))
1419 (mapconcat 'identity gnus-visible-headers "\\|"))))
1420 (inhibit-point-motion-hooks t)
1422 ;; First we narrow to just the headers.
1423 (article-narrow-to-head)
1424 ;; Hide any "From " lines at the beginning of (mail) articles.
1425 (while (looking-at "From ")
1428 (delete-region (point-min) (point)))
1429 ;; Then treat the rest of the header lines.
1430 ;; Then we use the two regular expressions
1431 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1432 ;; select which header lines is to remain visible in the
1434 (while (re-search-forward "^[^ \t:]*:" nil t)
1436 ;; Mark the rank of the header.
1438 (point) (1+ (point)) 'message-rank
1439 (if (or (and visible (looking-at visible))
1441 (not (looking-at ignored))))
1442 (gnus-article-header-rank)
1445 (message-sort-headers-1)
1446 (when (setq beg (text-property-any
1447 (point-min) (point-max) 'message-rank (+ 2 max)))
1448 ;; We delete the unwanted headers.
1449 (gnus-add-wash-type 'headers)
1450 (add-text-properties (point-min) (+ 5 (point-min))
1451 '(article-type headers dummy-invisible t))
1452 (delete-region beg (point-max))))))))
1454 (defun article-hide-boring-headers (&optional arg)
1455 "Toggle hiding of headers that aren't very interesting.
1456 If given a negative prefix, always show; if given a positive prefix,
1458 (interactive (gnus-article-hidden-arg))
1459 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1460 (not gnus-show-all-headers))
1463 (let ((buffer-read-only nil)
1464 (list gnus-boring-article-headers)
1465 (inhibit-point-motion-hooks t)
1467 (article-narrow-to-head)
1469 (setq elem (pop list))
1470 (goto-char (point-min))
1472 ;; Hide empty headers.
1474 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1476 (gnus-article-hide-text-type
1477 (progn (beginning-of-line) (point))
1480 (if (re-search-forward "^[^ \t]" nil t)
1484 ;; Hide boring Newsgroups header.
1485 ((eq elem 'newsgroups)
1486 (when (gnus-string-equal
1487 (gnus-fetch-field "newsgroups")
1488 (gnus-group-real-name
1489 (if (boundp 'gnus-newsgroup-name)
1492 (gnus-article-hide-header "newsgroups")))
1493 ((eq elem 'to-address)
1494 (let ((to (message-fetch-field "to"))
1496 (gnus-parameter-to-address
1497 (if (boundp 'gnus-newsgroup-name)
1498 gnus-newsgroup-name ""))))
1499 (when (and to to-address
1502 ;; only one address in To
1503 (nth 1 (mail-extract-address-components to))
1505 (gnus-article-hide-header "to"))))
1506 ((eq elem 'followup-to)
1507 (when (gnus-string-equal
1508 (message-fetch-field "followup-to")
1509 (message-fetch-field "newsgroups"))
1510 (gnus-article-hide-header "followup-to")))
1511 ((eq elem 'reply-to)
1512 (let ((from (message-fetch-field "from"))
1513 (reply-to (message-fetch-field "reply-to")))
1518 (nth 1 (mail-extract-address-components from))
1519 (nth 1 (mail-extract-address-components reply-to)))))
1520 (gnus-article-hide-header "reply-to"))))
1522 (let ((date (message-fetch-field "date")))
1524 (< (days-between (current-time-string) date)
1526 (gnus-article-hide-header "date"))))
1528 (let ((to (message-fetch-field "to"))
1529 (cc (message-fetch-field "cc")))
1530 (when (> (length to) 1024)
1531 (gnus-article-hide-header "to"))
1532 (when (> (length cc) 1024)
1533 (gnus-article-hide-header "cc"))))
1537 (goto-char (point-min))
1538 (while (re-search-forward "^to:" nil t)
1539 (setq to-count (1+ to-count)))
1540 (when (> to-count 1)
1541 (while (> to-count 0)
1542 (goto-char (point-min))
1544 (re-search-forward "^to:" nil nil to-count)
1546 (narrow-to-region (point) (point-max))
1547 (gnus-article-hide-header "to"))
1548 (setq to-count (1- to-count))))
1549 (goto-char (point-min))
1550 (while (re-search-forward "^cc:" nil t)
1551 (setq cc-count (1+ cc-count)))
1552 (when (> cc-count 1)
1553 (while (> cc-count 0)
1554 (goto-char (point-min))
1556 (re-search-forward "^cc:" nil nil cc-count)
1558 (narrow-to-region (point) (point-max))
1559 (gnus-article-hide-header "cc"))
1560 (setq cc-count (1- cc-count)))))))))))))
1562 (defun gnus-article-hide-header (header)
1564 (goto-char (point-min))
1565 (when (re-search-forward (concat "^" header ":") nil t)
1566 (gnus-article-hide-text-type
1567 (progn (beginning-of-line) (point))
1570 (if (re-search-forward "^[^ \t]" nil t)
1575 (defvar gnus-article-normalized-header-length 40
1576 "Length of normalized headers.")
1578 (defun article-normalize-headers ()
1579 "Make all header lines 40 characters long."
1581 (let ((buffer-read-only nil)
1585 (article-narrow-to-head)
1588 ((< (setq column (- (gnus-point-at-eol) (point)))
1589 gnus-article-normalized-header-length)
1591 (insert (make-string
1592 (- gnus-article-normalized-header-length column)
1594 ((> column gnus-article-normalized-header-length)
1595 (gnus-put-text-property
1597 (forward-char gnus-article-normalized-header-length)
1604 (forward-line 1))))))
1606 (defun article-treat-dumbquotes ()
1607 "Translate M****s*** sm*rtq**t*s into proper text.
1608 Note that this function guesses whether a character is a sm*rtq**t* or
1609 not, so it should only be used interactively.
1611 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1612 in an attempt to provide more quoting characters. If you see
1613 something like \\222 or \\264 where you're expecting some kind of
1614 apostrophe or quotation mark, then try this wash."
1616 (article-translate-strings gnus-article-dumbquotes-map))
1618 (defun article-translate-characters (from to)
1619 "Translate all characters in the body of the article according to FROM and TO.
1620 FROM is a string of characters to translate from; to is a string of
1621 characters to translate to."
1623 (when (article-goto-body)
1624 (let ((buffer-read-only nil)
1625 (x (make-string 225 ?x))
1627 (while (< (incf i) (length x))
1630 (while (< i (length from))
1631 (aset x (aref from i) (aref to i))
1633 (translate-region (point) (point-max) x)))))
1635 (defun article-translate-strings (map)
1636 "Translate all string in the body of the article according to MAP.
1637 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1639 (when (article-goto-body)
1640 (let ((buffer-read-only nil)
1642 (while (setq elem (pop map))
1644 (while (search-forward (car elem) nil t)
1645 (replace-match (cadr elem)))))))))
1647 (defun article-treat-overstrike ()
1648 "Translate overstrikes into bold text."
1651 (when (article-goto-body)
1652 (let ((buffer-read-only nil))
1653 (while (search-forward "\b" nil t)
1654 (let ((next (char-after))
1655 (previous (char-after (- (point) 2))))
1656 ;; We do the boldification/underlining by hiding the
1657 ;; overstrikes and putting the proper text property
1661 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1662 (put-text-property (point) (1+ (point)) 'face 'bold))
1664 (gnus-article-hide-text-type
1665 (1- (point)) (1+ (point)) 'overstrike)
1667 (- (point) 2) (1- (point)) 'face 'underline))
1669 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1671 (point) (1+ (point)) 'face 'underline)))))))))
1673 (defun gnus-article-treat-unfold-headers ()
1674 "Unfold folded message headers.
1675 Only the headers that fit into the current window width will be
1678 (gnus-with-article-headers
1682 (mail-header-narrow-to-field)
1683 (let ((header (buffer-substring (point-min) (point-max))))
1686 (goto-char (point-min))
1687 (while (re-search-forward "\n[\t ]" nil t)
1688 (replace-match " " t t)))
1689 (setq length (- (point-max) (point-min) 1)))
1690 (when (< length (window-width))
1691 (while (re-search-forward "\n[\t ]" nil t)
1692 (replace-match " " t t)))
1693 (goto-char (point-max)))))))
1695 (defun gnus-article-treat-fold-headers ()
1696 "Fold message headers."
1698 (gnus-with-article-headers
1701 (mail-header-narrow-to-field)
1702 (mail-header-fold-field)
1703 (goto-char (point-max))))))
1705 (defun gnus-treat-smiley ()
1706 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1708 (gnus-with-article-buffer
1709 (if (memq 'smiley gnus-article-wash-types)
1710 (gnus-delete-images 'smiley)
1712 (let ((images (smiley-region (point) (point-max))))
1714 (gnus-add-wash-type 'smiley)
1715 (dolist (image images)
1716 (gnus-add-image 'smiley image)))))))
1718 (defun gnus-article-remove-images ()
1719 "Remove all images from the article buffer."
1721 (gnus-with-article-buffer
1722 (dolist (elem gnus-article-image-alist)
1723 (gnus-delete-images (car elem)))))
1725 (defun gnus-article-treat-fold-newsgroups ()
1726 "Unfold folded message headers.
1727 Only the headers that fit into the current window width will be
1730 (gnus-with-article-headers
1731 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1733 (mail-header-narrow-to-field)
1734 (while (re-search-forward ", *" nil t)
1735 (replace-match ", " t t))
1736 (mail-header-fold-field)
1737 (goto-char (point-max))))))
1739 (defun gnus-article-treat-body-boundary ()
1740 "Place a boundary line at the end of the headers."
1742 (when (and gnus-body-boundary-delimiter
1743 (> (length gnus-body-boundary-delimiter) 0))
1744 (gnus-with-article-headers
1745 (goto-char (point-max))
1746 (let ((start (point)))
1747 (insert "X-Boundary: ")
1748 (gnus-add-text-properties start (point) '(invisible t intangible t))
1750 (while (>= (1- (window-width)) (length str))
1751 (setq str (concat str gnus-body-boundary-delimiter)))
1752 (substring str 0 (1- (window-width))))
1754 (gnus-add-text-properties start (point) '(gnus-decoration 'header))))))
1756 (defun article-fill-long-lines ()
1757 "Fill lines that are wider than the window width."
1760 (let ((buffer-read-only nil)
1761 (width (window-width (get-buffer-window (current-buffer)))))
1764 (let ((adaptive-fill-mode nil)) ;Why? -sm
1767 (when (>= (current-column) (min fill-column width))
1768 (narrow-to-region (point) (gnus-point-at-bol))
1769 (fill-paragraph nil)
1770 (goto-char (point-max))
1772 (forward-line 1)))))))
1774 (defun article-capitalize-sentences ()
1775 "Capitalize the first word in each sentence."
1778 (let ((buffer-read-only nil)
1779 (paragraph-start "^[\n\^L]"))
1783 (forward-sentence)))))
1785 (defun article-remove-cr ()
1786 "Remove trailing CRs and then translate remaining CRs into LFs."
1789 (let ((buffer-read-only nil))
1790 (goto-char (point-min))
1791 (while (re-search-forward "\r+$" nil t)
1792 (replace-match "" t t))
1793 (goto-char (point-min))
1794 (while (search-forward "\r" nil t)
1795 (replace-match "\n" t t)))))
1797 (defun article-remove-trailing-blank-lines ()
1798 "Remove all trailing blank lines from the article."
1801 (let ((buffer-read-only nil))
1802 (goto-char (point-max))
1806 (while (and (not (bobp))
1807 (looking-at "^[ \t]*$")
1808 (not (gnus-annotation-in-region-p
1809 (point) (gnus-point-at-eol))))
1814 (defun article-display-x-face (&optional force)
1815 "Look for an X-Face header and display it if present."
1816 (interactive (list 'force))
1817 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1818 (gnus-with-article-headers
1819 ;; Delete the old process, if any.
1820 (when (process-status "article-x-face")
1821 (delete-process "article-x-face"))
1822 (if (memq 'xface gnus-article-wash-types)
1823 ;; We have already displayed X-Faces, so we remove them
1825 (gnus-delete-images 'xface)
1827 (let (x-faces from face grey)
1829 (when (and wash-face-p
1831 (goto-char (point-min))
1832 (not (re-search-forward
1833 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1834 (gnus-buffer-live-p gnus-original-article-buffer))
1835 ;; If type `W f', use gnus-original-article-buffer,
1836 ;; otherwise use the current buffer because displaying
1837 ;; RFC822 parts calls this function too.
1838 (set-buffer gnus-original-article-buffer))
1840 (mail-narrow-to-head)
1841 (while (gnus-article-goto-header "x-face\\(-[0-9]+\\)?")
1842 (when (match-beginning 2)
1844 (push (mail-header-field-value) x-faces))
1845 (setq from (message-fetch-field "from"))))
1847 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1850 (setq image (gnus-create-image xpm 'xpm t))
1851 (gnus-article-goto-header "from")
1853 (insert "From: [no `from' set]\n")
1855 (gnus-add-wash-type 'xface)
1856 (gnus-add-image 'xface image)
1857 (gnus-put-image image)))
1858 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1859 ;; single external face.
1860 (when (stringp gnus-article-x-face-command)
1861 (setq x-faces (list (car x-faces))))
1862 (while (and (setq face (pop x-faces))
1863 gnus-article-x-face-command
1865 ;; Check whether this face is censored.
1866 (not gnus-article-x-face-too-ugly)
1867 (and gnus-article-x-face-too-ugly from
1868 (not (string-match gnus-article-x-face-too-ugly
1870 ;; We display the face.
1871 (if (symbolp gnus-article-x-face-command)
1872 ;; The command is a lisp function, so we call it.
1873 (if (gnus-functionp gnus-article-x-face-command)
1874 (funcall gnus-article-x-face-command face)
1875 (error "%s is not a function" gnus-article-x-face-command))
1876 ;; The command is a string, so we interpret the command
1877 ;; as a, well, command, and fork it off.
1878 (let ((process-connection-type nil))
1879 (process-kill-without-query
1881 "article-x-face" nil shell-file-name shell-command-switch
1882 gnus-article-x-face-command))
1885 (process-send-region "article-x-face"
1886 (point-min) (point-max)))
1887 (process-send-eof "article-x-face"))))))))))
1889 (defun article-decode-mime-words ()
1890 "Decode all MIME-encoded words in the article."
1893 (set-buffer gnus-article-buffer)
1894 (let ((inhibit-point-motion-hooks t)
1896 (mail-parse-charset gnus-newsgroup-charset)
1897 (mail-parse-ignored-charsets
1898 (save-excursion (set-buffer gnus-summary-buffer)
1899 gnus-newsgroup-ignored-charsets)))
1900 (mail-decode-encoded-word-region (point-min) (point-max)))))
1902 (defun article-decode-charset (&optional prompt)
1903 "Decode charset-encoded text in the article.
1904 If PROMPT (the prefix), prompt for a coding system to use."
1906 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1908 (mail-parse-charset gnus-newsgroup-charset)
1909 (mail-parse-ignored-charsets
1910 (save-excursion (condition-case nil
1911 (set-buffer gnus-summary-buffer)
1913 gnus-newsgroup-ignored-charsets))
1914 ct cte ctl charset format)
1917 (article-narrow-to-head)
1918 (setq ct (message-fetch-field "Content-Type" t)
1919 cte (message-fetch-field "Content-Transfer-Encoding" t)
1920 ctl (and ct (ignore-errors
1921 (mail-header-parse-content-type ct)))
1924 (mm-read-coding-system "Charset to decode: "))
1926 (mail-content-type-get ctl 'charset)))
1927 format (and ctl (mail-content-type-get ctl 'format)))
1929 (setq cte (mail-header-strip cte)))
1930 (if (and ctl (not (string-match "/" (car ctl))))
1932 (goto-char (point-max)))
1935 (narrow-to-region (point) (point-max))
1936 (when (and (eq mail-parse-charset 'gnus-decoded)
1937 (eq (mm-body-7-or-8) '8bit))
1938 ;; The text code could have been decoded.
1939 (setq charset mail-parse-charset))
1940 (when (and (or (not ctl)
1941 (equal (car ctl) "text/plain"))
1942 (not format)) ;; article with format will decode later.
1944 charset (and cte (intern (downcase
1945 (gnus-strip-whitespace cte))))
1948 (defun article-decode-encoded-words ()
1949 "Remove encoded-word encoding from headers."
1950 (let ((inhibit-point-motion-hooks t)
1951 (mail-parse-charset gnus-newsgroup-charset)
1952 (mail-parse-ignored-charsets
1953 (save-excursion (condition-case nil
1954 (set-buffer gnus-summary-buffer)
1956 gnus-newsgroup-ignored-charsets))
1959 (article-narrow-to-head)
1960 (funcall gnus-decode-header-function (point-min) (point-max)))))
1962 (defun article-decode-group-name ()
1963 "Decode group names in `Newsgroups:'."
1964 (let ((inhibit-point-motion-hooks t)
1966 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1967 (when (and (or gnus-group-name-charset-method-alist
1968 gnus-group-name-charset-group-alist)
1969 (gnus-buffer-live-p gnus-original-article-buffer))
1970 (when (nnmail-fetch-field "Newsgroups")
1971 (nnheader-replace-header "Newsgroups"
1972 (gnus-decode-newsgroups
1973 (with-current-buffer
1974 gnus-original-article-buffer
1975 (nnmail-fetch-field "Newsgroups"))
1976 gnus-newsgroup-name method)))
1977 (when (nnmail-fetch-field "Followup-To")
1978 (nnheader-replace-header "Followup-To"
1979 (gnus-decode-newsgroups
1980 (with-current-buffer
1981 gnus-original-article-buffer
1982 (nnmail-fetch-field "Followup-To"))
1983 gnus-newsgroup-name method))))))
1985 (defun article-de-quoted-unreadable (&optional force read-charset)
1986 "Translate a quoted-printable-encoded article.
1987 If FORCE, decode the article whether it is marked as quoted-printable
1989 If READ-CHARSET, ask for a coding system."
1990 (interactive (list 'force current-prefix-arg))
1992 (let ((buffer-read-only nil) type charset)
1993 (if (gnus-buffer-live-p gnus-original-article-buffer)
1994 (with-current-buffer gnus-original-article-buffer
1996 (gnus-fetch-field "content-transfer-encoding"))
1997 (let* ((ct (gnus-fetch-field "content-type"))
2000 (mail-header-parse-content-type ct)))))
2001 (setq charset (and ctl
2002 (mail-content-type-get ctl 'charset)))
2003 (if (stringp charset)
2004 (setq charset (intern (downcase charset)))))))
2006 (setq charset (mm-read-coding-system "Charset: " charset)))
2008 (setq charset gnus-newsgroup-charset))
2010 (and type (let ((case-fold-search t))
2011 (string-match "quoted-printable" type))))
2013 (quoted-printable-decode-region
2014 (point) (point-max) (mm-charset-to-coding-system charset))))))
2016 (defun article-de-base64-unreadable (&optional force read-charset)
2017 "Translate a base64 article.
2018 If FORCE, decode the article whether it is marked as base64 not.
2019 If READ-CHARSET, ask for a coding system."
2020 (interactive (list 'force current-prefix-arg))
2022 (let ((buffer-read-only nil) type charset)
2023 (if (gnus-buffer-live-p gnus-original-article-buffer)
2024 (with-current-buffer gnus-original-article-buffer
2026 (gnus-fetch-field "content-transfer-encoding"))
2027 (let* ((ct (gnus-fetch-field "content-type"))
2030 (mail-header-parse-content-type ct)))))
2031 (setq charset (and ctl
2032 (mail-content-type-get ctl 'charset)))
2033 (if (stringp charset)
2034 (setq charset (intern (downcase charset)))))))
2036 (setq charset (mm-read-coding-system "Charset: " charset)))
2038 (setq charset gnus-newsgroup-charset))
2040 (and type (let ((case-fold-search t))
2041 (string-match "base64" type))))
2044 (narrow-to-region (point) (point-max))
2045 (base64-decode-region (point-min) (point-max))
2046 (mm-decode-coding-region
2047 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2052 (defun article-decode-HZ ()
2053 "Translate a HZ-encoded article."
2057 (let ((buffer-read-only nil))
2058 (rfc1843-decode-region (point-min) (point-max)))))
2060 (defun article-unsplit-urls ()
2061 "Remove the newlines that some other mailers insert into URLs."
2064 (let ((buffer-read-only nil))
2065 (goto-char (point-min))
2066 (while (re-search-forward
2067 "^\\(\\(https?\\|ftp\\)://\\S-+\\)\n\\(\\S-+\\)" nil t)
2068 (replace-match "\\1\\3" t)))))
2070 (defun article-wash-html (&optional read-charset)
2071 "Format an html article.
2072 If READ-CHARSET, ask for a coding system."
2075 (let ((buffer-read-only nil)
2077 (if (gnus-buffer-live-p gnus-original-article-buffer)
2078 (with-current-buffer gnus-original-article-buffer
2079 (let* ((ct (gnus-fetch-field "content-type"))
2082 (mail-header-parse-content-type ct)))))
2083 (setq charset (and ctl
2084 (mail-content-type-get ctl 'charset)))
2085 (if (stringp charset)
2086 (setq charset (intern (downcase charset)))))))
2088 (setq charset (mm-read-coding-system "Charset: " charset)))
2090 (setq charset gnus-newsgroup-charset))
2092 (save-window-excursion
2094 (narrow-to-region (point) (point-max))
2095 (funcall gnus-article-wash-function))))))
2097 (defun gnus-article-wash-html-with-w3 ()
2098 "Wash the current buffer with w3."
2100 (let ((w3-strict-width (window-width))
2101 (url-standalone-mode t)
2102 (url-gateway-unplugged t)
2103 (w3-honor-stylesheets nil)
2104 (w3-delay-image-loads t))
2106 (w3-region (point-min) (point-max))
2109 (defun gnus-article-wash-html-with-w3m ()
2110 "Wash the current buffer with emacs-w3m."
2113 (narrow-to-region (point) (point-max))
2114 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2117 (w3m-display-inline-images mm-inline-text-html-with-images)
2118 w3m-force-redisplay)
2119 (w3m-region (point-min) (point-max)))
2120 (when mm-inline-text-html-with-w3m-keymap
2121 (add-text-properties
2122 (point-min) (point-max)
2123 (append '(mm-inline-text-html-with-w3m t)
2124 (gnus-local-map-property mm-w3m-mode-map))))))
2126 (defun article-hide-list-identifiers ()
2127 "Remove list identifies from the Subject header.
2128 The `gnus-list-identifiers' variable specifies what to do."
2130 (let ((inhibit-point-motion-hooks t)
2131 (regexp (if (consp gnus-list-identifiers)
2132 (mapconcat 'identity gnus-list-identifiers " *\\|")
2133 gnus-list-identifiers))
2138 (article-narrow-to-head)
2139 (goto-char (point-min))
2140 (while (re-search-forward
2141 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2143 (delete-region (match-beginning 2) (match-end 0))
2144 (beginning-of-line))
2145 (when (re-search-forward
2146 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2147 (delete-region (match-beginning 1) (match-end 1))))))))
2149 (defun article-hide-pgp ()
2150 "Remove any PGP headers and signatures in the current article."
2154 (let ((inhibit-point-motion-hooks t)
2155 buffer-read-only beg end)
2157 ;; Hide the "header".
2158 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2159 (gnus-add-wash-type 'pgp)
2160 (delete-region (match-beginning 0) (match-end 0))
2161 ;; Remove armor headers (rfc2440 6.2)
2162 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2165 ;; Hide the actual signature.
2166 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2167 (setq end (1+ (match-beginning 0)))
2170 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2172 ;; Perhaps we shouldn't hide to the end of the buffer
2173 ;; if there is no end to the signature?
2175 ;; Hide "- " PGP quotation markers.
2177 (narrow-to-region beg end)
2178 (goto-char (point-min))
2179 (while (re-search-forward "^- " nil t)
2181 (match-beginning 0) (match-end 0)))
2183 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2185 (defun article-hide-pem (&optional arg)
2186 "Toggle hiding of any PEM headers and signatures in the current article.
2187 If given a negative prefix, always show; if given a positive prefix,
2189 (interactive (gnus-article-hidden-arg))
2190 (unless (gnus-article-check-hidden-text 'pem arg)
2192 (let (buffer-read-only end)
2193 (goto-char (point-min))
2194 ;; Hide the horrendously ugly "header".
2195 (when (and (search-forward
2196 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2198 (setq end (1+ (match-beginning 0))))
2199 (gnus-add-wash-type 'pem)
2200 (gnus-article-hide-text-type
2202 (if (search-forward "\n\n" nil t)
2206 ;; Hide the trailer as well
2207 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2209 (gnus-article-hide-text-type
2210 (match-beginning 0) (match-end 0) 'pem)))))))
2212 (defun article-strip-banner ()
2213 "Strip the banner specified by the `banner' group parameter."
2217 (let ((inhibit-point-motion-hooks t)
2218 (banner (gnus-parameter-banner gnus-newsgroup-name))
2219 (gnus-signature-limit nil)
2220 buffer-read-only beg end)
2224 ((eq banner 'signature)
2225 (when (gnus-article-narrow-to-signature)
2228 (delete-region (point) (point-max))))
2230 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2231 (while (re-search-forward banner nil t)
2232 (delete-region (match-beginning 0) (match-end 0)))))
2234 (while (re-search-forward banner nil t)
2235 (delete-region (match-beginning 0) (match-end 0))))))))))
2237 (defun article-babel ()
2238 "Translate article using an online translation service."
2242 (set-buffer gnus-article-buffer)
2243 (when (article-goto-body)
2244 (let* ((buffer-read-only nil)
2247 (orig (buffer-substring start end))
2248 (trans (babel-as-string orig)))
2250 (narrow-to-region start end)
2251 (delete-region start end)
2254 (defun article-hide-signature (&optional arg)
2255 "Hide the signature in the current article.
2256 If given a negative prefix, always show; if given a positive prefix,
2258 (interactive (gnus-article-hidden-arg))
2259 (unless (gnus-article-check-hidden-text 'signature arg)
2262 (let ((buffer-read-only nil))
2263 (when (gnus-article-narrow-to-signature)
2264 (gnus-article-hide-text-type
2265 (point-min) (point-max) 'signature))))))
2266 (gnus-set-mode-line 'article))
2268 (defun article-strip-headers-in-body ()
2269 "Strip offensive headers from bodies."
2273 (let ((case-fold-search t))
2274 (when (looking-at "x-no-archive:")
2275 (gnus-delete-line)))))
2277 (defun article-strip-leading-blank-lines ()
2278 "Remove all blank lines from the beginning of the article."
2281 (let ((inhibit-point-motion-hooks t)
2283 (when (article-goto-body)
2284 (while (and (not (eobp))
2285 (looking-at "[ \t]*$"))
2286 (gnus-delete-line))))))
2288 (defun article-narrow-to-head ()
2289 "Narrow the buffer to the head of the message.
2290 Point is left at the beginning of the narrowed-to region."
2292 (goto-char (point-min))
2293 (if (search-forward "\n\n" nil 1)
2296 (goto-char (point-min)))
2298 (defun article-goto-body ()
2299 "Place point at the start of the body."
2300 (goto-char (point-min))
2302 ;; This variable is only bound when dealing with separate
2304 (article-goto-body-goes-to-point-min-p
2306 ((search-forward "\n\n" nil t)
2309 (goto-char (point-max))
2312 (defun article-strip-multiple-blank-lines ()
2313 "Replace consecutive blank lines with one empty line."
2316 (let ((inhibit-point-motion-hooks t)
2318 ;; First make all blank lines empty.
2320 (while (re-search-forward "^[ \t]+$" nil t)
2321 (unless (gnus-annotation-in-region-p
2322 (match-beginning 0) (match-end 0))
2323 (replace-match "" nil t)))
2324 ;; Then replace multiple empty lines with a single empty line.
2326 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2327 (unless (gnus-annotation-in-region-p
2328 (match-beginning 0) (match-end 0))
2329 (delete-region (match-beginning 1) (match-end 1)))))))
2331 (defun article-strip-leading-space ()
2332 "Remove all white space from the beginning of the lines in the article."
2335 (let ((inhibit-point-motion-hooks t)
2338 (while (re-search-forward "^[ \t]+" nil t)
2339 (replace-match "" t t)))))
2341 (defun article-strip-trailing-space ()
2342 "Remove all white space from the end of the lines in the article."
2345 (let ((inhibit-point-motion-hooks t)
2348 (while (re-search-forward "[ \t]+$" nil t)
2349 (replace-match "" t t)))))
2351 (defun article-strip-blank-lines ()
2352 "Strip leading, trailing and multiple blank lines."
2354 (article-strip-leading-blank-lines)
2355 (article-remove-trailing-blank-lines)
2356 (article-strip-multiple-blank-lines))
2358 (defun article-strip-all-blank-lines ()
2359 "Strip all blank lines."
2362 (let ((inhibit-point-motion-hooks t)
2365 (while (re-search-forward "^[ \t]*\n" nil t)
2366 (replace-match "" t t)))))
2368 (defun gnus-article-narrow-to-signature ()
2369 "Narrow to the signature; return t if a signature is found, else nil."
2370 (let ((inhibit-point-motion-hooks t))
2371 (when (gnus-article-search-signature)
2373 ;; Check whether we have some limits to what we consider
2374 ;; to be a signature.
2375 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2376 (list gnus-signature-limit)))
2378 (while (setq limit (pop limits))
2379 (if (or (and (integerp limit)
2380 (< (- (point-max) (point)) limit))
2382 (< (count-lines (point) (point-max)) limit))
2383 (and (gnus-functionp limit)
2385 (and (stringp limit)
2386 (not (re-search-forward limit nil t))))
2387 () ; This limit did not succeed.
2391 (narrow-to-region (point) (point-max))
2394 (defun gnus-article-search-signature ()
2395 "Search the current buffer for the signature separator.
2396 Put point at the beginning of the signature separator."
2397 (let ((cur (point)))
2398 (goto-char (point-max))
2399 (if (if (stringp gnus-signature-separator)
2400 (re-search-backward gnus-signature-separator nil t)
2401 (let ((seps gnus-signature-separator))
2403 (not (re-search-backward (car seps) nil t)))
2410 (defun gnus-article-hidden-arg ()
2411 "Return the current prefix arg as a number, or 0 if no prefix."
2412 (list (if current-prefix-arg
2413 (prefix-numeric-value current-prefix-arg)
2416 (defun gnus-article-check-hidden-text (type arg)
2417 "Return nil if hiding is necessary.
2418 Arg can be nil or a number. nil and positive means hide, negative
2419 means show, 0 means toggle."
2422 (let ((hide (gnus-article-hidden-text-p type)))
2428 (gnus-article-show-hidden-text type)
2431 (if (eq hide 'hidden)
2433 (gnus-article-show-hidden-text type)
2437 (defun gnus-article-hidden-text-p (type)
2438 "Say whether the current buffer contains hidden text of type TYPE."
2439 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2441 (not (get-text-property pos 'invisible))
2442 (not (get-text-property pos 'dummy-invisible)))
2444 (text-property-any (1+ pos) (point-max) 'article-type type)))
2449 (defun gnus-article-show-hidden-text (type &optional dummy)
2450 "Show all hidden text of type TYPE.
2451 Originally it is hide instead of DUMMY."
2452 (let ((buffer-read-only nil)
2453 (inhibit-point-motion-hooks t))
2454 (gnus-remove-text-properties-when
2456 (point-min) (point-max)
2457 (cons 'article-type (cons type
2458 gnus-hidden-properties)))
2459 (gnus-delete-wash-type type)))
2461 (defconst article-time-units
2462 `((year . ,(* 365.25 24 60 60))
2463 (week . ,(* 7 24 60 60))
2464 (day . ,(* 24 60 60))
2468 "Mapping from time units to seconds.")
2470 (defun article-date-ut (&optional type highlight header)
2471 "Convert DATE date to universal time in the current article.
2472 If TYPE is `local', convert to local time; if it is `lapsed', output
2473 how much time has lapsed since DATE. For `lapsed', the value of
2474 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2475 should replace the \"Date:\" one, or should be added below it."
2476 (interactive (list 'ut t))
2477 (let* ((header (or header
2478 (message-fetch-field "date")
2480 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2483 ((not gnus-article-date-lapsed-new-header)
2489 (date (if (vectorp header) (mail-header-date header)
2491 (inhibit-point-motion-hooks t)
2496 (article-narrow-to-head)
2497 (when (re-search-forward tdate-regexp nil t)
2498 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2499 date (or (get-text-property (gnus-point-at-bol)
2502 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2504 (when (and date (not (string= date "")))
2505 (goto-char (point-min))
2506 (let ((buffer-read-only nil))
2507 ;; Delete any old Date headers.
2508 (while (re-search-forward date-regexp nil t)
2510 (delete-region (progn (beginning-of-line) (point))
2511 (progn (forward-line 1) (point)))
2512 (delete-region (progn (beginning-of-line) (point))
2513 (progn (end-of-line) (point)))
2514 (setq pos (point))))
2515 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2517 (if pos (goto-char pos))
2518 (insert (article-make-date-line date (or type 'ut)))
2524 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2525 (put-text-property (match-beginning 1) (1+ (match-end 1))
2526 'original-date date)
2527 (put-text-property (match-beginning 1) (1+ (match-end 1))
2529 (put-text-property (match-beginning 2) (match-end 2)
2532 (defun article-make-date-line (date type)
2533 "Return a DATE line of TYPE."
2534 (unless (memq type '(local ut original user iso8601 lapsed english))
2535 (error "Unknown conversion type: %s" type))
2537 (let ((time (date-to-time date)))
2539 ;; Convert to the local timezone.
2541 (let ((tz (car (current-time-zone time))))
2542 (format "Date: %s %s%02d%02d" (current-time-string time)
2543 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2544 (/ (% (abs tz) 3600) 60))))
2545 ;; Convert to Universal Time.
2548 (current-time-string
2549 (let* ((e (parse-time-string date))
2550 (tm (apply 'encode-time e))
2552 (ls (- (cadr tm) (car (current-time-zone time)))))
2553 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2554 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2557 ;; Get the original date from the article.
2558 ((eq type 'original)
2559 (concat "Date: " (if (string-match "\n+$" date)
2560 (substring date 0 (match-beginning 0))
2562 ;; Let the user define the format.
2564 (if (gnus-functionp gnus-article-time-format)
2565 (funcall gnus-article-time-format time)
2568 (format-time-string gnus-article-time-format time))))
2571 (let ((tz (car (current-time-zone time))))
2574 (format-time-string "%Y%m%dT%H%M%S" time)
2575 (format "%s%02d%02d"
2576 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2577 (/ (% (abs tz) 3600) 60)))))
2578 ;; Do an X-Sent lapsed format.
2580 ;; If the date is seriously mangled, the timezone functions are
2581 ;; liable to bug out, so we ignore all errors.
2582 (let* ((now (current-time))
2583 (real-time (subtract-time now time))
2584 (real-sec (and real-time
2585 (+ (* (float (car real-time)) 65536)
2587 (sec (and real-time (abs real-sec)))
2597 ;; This is a bit convoluted, but basically we go
2598 ;; through the time units for years, weeks, etc,
2599 ;; and divide things to see whether that results
2600 ;; in positive answers.
2603 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2604 ;; The (remaining) seconds are too few to
2605 ;; be divided into this time unit.
2607 ;; It's big enough, so we output it.
2608 (setq sec (- sec (* num (cdr unit))))
2610 (concat (if prev ", " "") (int-to-string
2612 " " (symbol-name (car unit))
2613 (if (> num 1) "s" ""))
2615 article-time-units "")
2616 ;; If dates are odd, then it might appear like the
2617 ;; article was sent in the future.
2620 " in the future"))))))
2621 ;; Display the date in proper English
2623 (let ((dtime (decode-time time)))
2626 (number-to-string (nth 3 dtime))
2627 (let ((digit (% (nth 3 dtime) 10)))
2629 ((memq (nth 3 dtime) '(11 12 13)) "th")
2635 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2637 (number-to-string (nth 5 dtime))
2639 (format "%02d" (nth 2 dtime))
2641 (format "%02d" (nth 1 dtime)))))))
2643 (format "Date: %s (from Oort)" date))))
2645 (defun article-date-local (&optional highlight)
2646 "Convert the current article date to the local timezone."
2647 (interactive (list t))
2648 (article-date-ut 'local highlight))
2650 (defun article-date-english (&optional highlight)
2651 "Convert the current article date to something that is proper English."
2652 (interactive (list t))
2653 (article-date-ut 'english highlight))
2655 (defun article-date-original (&optional highlight)
2656 "Convert the current article date to what it was originally.
2657 This is only useful if you have used some other date conversion
2658 function and want to see what the date was before converting."
2659 (interactive (list t))
2660 (article-date-ut 'original highlight))
2662 (defun article-date-lapsed (&optional highlight)
2663 "Convert the current article date to time lapsed since it was sent."
2664 (interactive (list t))
2665 (article-date-ut 'lapsed highlight))
2667 (defun article-update-date-lapsed ()
2668 "Function to be run from a timer to update the lapsed time line."
2669 (let (deactivate-mark)
2674 (set-buffer (window-buffer w))
2675 (when (eq major-mode 'gnus-article-mode)
2676 (goto-char (point-min))
2677 (when (re-search-forward "^X-Sent:" nil t)
2678 (article-date-lapsed t))))
2681 (defun gnus-start-date-timer (&optional n)
2682 "Start a timer to update the X-Sent header in the article buffers.
2683 The numerical prefix says how frequently (in seconds) the function
2688 (gnus-stop-date-timer)
2689 (setq article-lapsed-timer
2690 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2692 (defun gnus-stop-date-timer ()
2693 "Stop the X-Sent timer."
2695 (when article-lapsed-timer
2696 (nnheader-cancel-timer article-lapsed-timer)
2697 (setq article-lapsed-timer nil)))
2699 (defun article-date-user (&optional highlight)
2700 "Convert the current article date to the user-defined format.
2701 This format is defined by the `gnus-article-time-format' variable."
2702 (interactive (list t))
2703 (article-date-ut 'user highlight))
2705 (defun article-date-iso8601 (&optional highlight)
2706 "Convert the current article date to ISO8601."
2707 (interactive (list t))
2708 (article-date-ut 'iso8601 highlight))
2710 ;; (defun article-show-all ()
2711 ;; "Show all hidden text in the article buffer."
2714 ;; (let ((buffer-read-only nil))
2715 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2717 (defun article-remove-leading-whitespace ()
2718 "Remove excessive whitespace from all headers."
2722 (let ((buffer-read-only nil))
2723 (article-narrow-to-head)
2724 (goto-char (point-min))
2725 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2726 (delete-region (match-beginning 1) (match-end 1)))))))
2728 (defun article-emphasize (&optional arg)
2729 "Emphasize text according to `gnus-emphasis-alist'."
2730 (interactive (gnus-article-hidden-arg))
2731 (unless (gnus-article-check-hidden-text 'emphasis arg)
2735 (with-current-buffer gnus-summary-buffer
2736 gnus-article-emphasis-alist)
2738 gnus-emphasis-alist))
2739 (buffer-read-only nil)
2740 (props (append '(article-type emphasis)
2741 gnus-hidden-properties))
2742 regexp elem beg invisible visible face)
2745 (while (setq elem (pop alist))
2747 (setq regexp (car elem)
2748 invisible (nth 1 elem)
2749 visible (nth 2 elem)
2751 (while (re-search-forward regexp nil t)
2752 (when (and (match-beginning visible) (match-beginning invisible))
2753 (gnus-article-hide-text
2754 (match-beginning invisible) (match-end invisible) props)
2755 (gnus-article-unhide-text-type
2756 (match-beginning visible) (match-end visible) 'emphasis)
2757 (gnus-put-overlay-excluding-newlines
2758 (match-beginning visible) (match-end visible) 'face face)
2759 (gnus-add-wash-type 'emphasis)
2760 (goto-char (match-end invisible)))))))))
2762 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2763 "Setup newsgroup emphasis alist."
2764 (unless gnus-article-emphasis-alist
2765 (let ((name (and gnus-newsgroup-name
2766 (gnus-group-real-name gnus-newsgroup-name))))
2767 (make-local-variable 'gnus-article-emphasis-alist)
2768 (setq gnus-article-emphasis-alist
2770 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2771 (while (setq elem (pop alist))
2772 (when (and name (string-match (car elem) name))
2774 highlight (copy-sequence (cdr elem)))))
2776 (copy-sequence highlight-words)
2777 (if gnus-newsgroup-name
2778 (copy-sequence (gnus-group-find-parameter
2779 gnus-newsgroup-name 'highlight-words t)))
2780 gnus-emphasis-alist)))))
2783 (defvar gnus-summary-article-menu)
2784 (defvar gnus-summary-post-menu))
2786 ;;; Saving functions.
2788 (defun gnus-article-save (save-buffer file &optional num)
2789 "Save the currently selected article."
2790 (unless gnus-save-all-headers
2791 ;; Remove headers according to `gnus-saved-headers'.
2792 (let ((gnus-visible-headers
2793 (or gnus-saved-headers gnus-visible-headers))
2794 (gnus-article-buffer save-buffer))
2796 (set-buffer save-buffer)
2797 (article-hide-headers 1 t))))
2798 (save-window-excursion
2799 (if (not gnus-default-article-saver)
2800 (error "No default saver is defined")
2801 ;; !!! Magic! The saving functions all save
2802 ;; `gnus-save-article-buffer' (or so they think), but we
2803 ;; bind that variable to our save-buffer.
2804 (set-buffer gnus-article-buffer)
2805 (let* ((gnus-save-article-buffer save-buffer)
2808 ((not gnus-prompt-before-saving) 'default)
2809 ((eq gnus-prompt-before-saving 'always) nil)
2811 (gnus-number-of-articles-to-be-saved
2812 (when (eq gnus-prompt-before-saving t)
2814 (set-buffer gnus-article-current-summary)
2815 (funcall gnus-default-article-saver filename)))))
2817 (defun gnus-read-save-file-name (prompt &optional filename
2818 function group headers variable)
2820 (funcall function group headers (symbol-value variable)))
2825 ((eq filename 'default)
2831 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2834 (if (and gnus-number-of-articles-to-be-saved
2835 (> gnus-number-of-articles-to-be-saved 1))
2836 (format "these %d articles"
2837 gnus-number-of-articles-to-be-saved)
2840 ;; Let the split methods have their say.
2842 ;; No split name was found.
2845 (concat prompt " (default "
2846 (file-name-nondirectory default-name) ") ")
2847 (file-name-directory default-name)
2849 ;; A single group name is returned.
2850 ((stringp split-name)
2852 (funcall function split-name headers
2853 (symbol-value variable)))
2855 (concat prompt " (default "
2856 (file-name-nondirectory default-name) ") ")
2857 (file-name-directory default-name)
2859 ;; A single split name was found
2860 ((= 1 (length split-name))
2861 (let* ((name (expand-file-name
2863 gnus-article-save-directory))
2864 (dir (cond ((file-directory-p name)
2865 (file-name-as-directory name))
2866 ((file-exists-p name) name)
2867 (t gnus-article-save-directory))))
2869 (concat prompt " (default " name ") ")
2871 ;; A list of splits was found.
2873 (setq split-name (nreverse split-name))
2875 (let ((file-name-history
2876 (nconc split-name file-name-history)))
2880 (concat prompt " (`M-p' for defaults) ")
2881 gnus-article-save-directory
2883 gnus-article-save-directory)))
2884 (car (push result file-name-history)))))))
2885 ;; Create the directory.
2886 (gnus-make-directory (file-name-directory file))
2887 ;; If we have read a directory, we append the default file name.
2888 (when (file-directory-p file)
2889 (setq file (expand-file-name (file-name-nondirectory
2891 (file-name-as-directory file))))
2892 ;; Possibly translate some characters.
2893 (nnheader-translate-file-chars file))))))
2894 (gnus-make-directory (file-name-directory result))
2895 (set variable result)))
2897 (defun gnus-article-archive-name (group)
2898 "Return the first instance of an \"Archive-name\" in the current buffer."
2899 (let ((case-fold-search t))
2900 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2901 (nnheader-concat gnus-article-save-directory
2902 (match-string 1)))))
2904 (defun gnus-article-nndoc-name (group)
2905 "If GROUP is an nndoc group, return the name of the parent group."
2906 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2907 (gnus-group-get-parameter group 'save-article-group)))
2909 (defun gnus-summary-save-in-rmail (&optional filename)
2910 "Append this article to Rmail file.
2911 Optional argument FILENAME specifies file name.
2912 Directory to save to is default to `gnus-article-save-directory'."
2913 (setq filename (gnus-read-save-file-name
2914 "Save %s in rmail file:" filename
2915 gnus-rmail-save-name gnus-newsgroup-name
2916 gnus-current-headers 'gnus-newsgroup-last-rmail))
2917 (gnus-eval-in-buffer-window gnus-save-article-buffer
2921 (gnus-output-to-rmail filename))))
2924 (defun gnus-summary-save-in-mail (&optional filename)
2925 "Append this article to Unix mail file.
2926 Optional argument FILENAME specifies file name.
2927 Directory to save to is default to `gnus-article-save-directory'."
2928 (setq filename (gnus-read-save-file-name
2929 "Save %s in Unix mail file:" filename
2930 gnus-mail-save-name gnus-newsgroup-name
2931 gnus-current-headers 'gnus-newsgroup-last-mail))
2932 (gnus-eval-in-buffer-window gnus-save-article-buffer
2936 (if (and (file-readable-p filename)
2937 (mail-file-babyl-p filename))
2938 (rmail-output-to-rmail-file filename t)
2939 (gnus-output-to-mail filename)))))
2942 (defun gnus-summary-save-in-file (&optional filename overwrite)
2943 "Append this article to file.
2944 Optional argument FILENAME specifies file name.
2945 Directory to save to is default to `gnus-article-save-directory'."
2946 (setq filename (gnus-read-save-file-name
2947 "Save %s in file:" filename
2948 gnus-file-save-name gnus-newsgroup-name
2949 gnus-current-headers 'gnus-newsgroup-last-file))
2950 (gnus-eval-in-buffer-window gnus-save-article-buffer
2954 (when (and overwrite
2955 (file-exists-p filename))
2956 (delete-file filename))
2957 (gnus-output-to-file filename))))
2960 (defun gnus-summary-write-to-file (&optional filename)
2961 "Write this article to a file, overwriting it if the file exists.
2962 Optional argument FILENAME specifies file name.
2963 The directory to save in defaults to `gnus-article-save-directory'."
2964 (gnus-summary-save-in-file nil t))
2966 (defun gnus-summary-save-body-in-file (&optional filename)
2967 "Append this article body to a file.
2968 Optional argument FILENAME specifies file name.
2969 The directory to save in defaults to `gnus-article-save-directory'."
2970 (setq filename (gnus-read-save-file-name
2971 "Save %s body in file:" filename
2972 gnus-file-save-name gnus-newsgroup-name
2973 gnus-current-headers 'gnus-newsgroup-last-file))
2974 (gnus-eval-in-buffer-window gnus-save-article-buffer
2978 (when (article-goto-body)
2979 (narrow-to-region (point) (point-max)))
2980 (gnus-output-to-file filename))))
2983 (defun gnus-summary-save-in-pipe (&optional command)
2984 "Pipe this article to subprocess."
2986 (cond ((and (eq command 'default)
2987 gnus-last-shell-command)
2988 gnus-last-shell-command)
2993 "Shell command on %s: "
2994 (if (and gnus-number-of-articles-to-be-saved
2995 (> gnus-number-of-articles-to-be-saved 1))
2996 (format "these %d articles"
2997 gnus-number-of-articles-to-be-saved)
2999 gnus-last-shell-command))))
3000 (when (string-equal command "")
3001 (if gnus-last-shell-command
3002 (setq command gnus-last-shell-command)
3003 (error "A command is required")))
3004 (gnus-eval-in-buffer-window gnus-article-buffer
3007 (shell-command-on-region (point-min) (point-max) command nil)))
3008 (setq gnus-last-shell-command command))
3010 (defun gnus-summary-pipe-to-muttprint (&optional command)
3011 "Pipe this article to muttprint."
3012 (setq command (read-string
3013 "Print using command: " gnus-summary-muttprint-program
3014 nil gnus-summary-muttprint-program))
3015 (gnus-summary-save-in-pipe command))
3017 ;;; Article file names when saving.
3019 (defun gnus-capitalize-newsgroup (newsgroup)
3020 "Capitalize NEWSGROUP name."
3021 (when (not (zerop (length newsgroup)))
3022 (concat (char-to-string (upcase (aref newsgroup 0)))
3023 (substring newsgroup 1))))
3025 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3026 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3027 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3028 Otherwise, it is like ~/News/news/group/num."
3031 (concat (if (gnus-use-long-file-name 'not-save)
3032 (gnus-capitalize-newsgroup newsgroup)
3033 (gnus-newsgroup-directory-form newsgroup))
3034 "/" (int-to-string (mail-header-number headers)))
3035 gnus-article-save-directory)))
3037 (string-equal (file-name-directory default)
3038 (file-name-directory last-file))
3039 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3041 (or last-file default))))
3043 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3044 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3045 If variable `gnus-use-long-file-name' is non-nil, it is
3046 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3049 (concat (if (gnus-use-long-file-name 'not-save)
3051 (gnus-newsgroup-directory-form newsgroup))
3052 "/" (int-to-string (mail-header-number headers)))
3053 gnus-article-save-directory)))
3055 (string-equal (file-name-directory default)
3056 (file-name-directory last-file))
3057 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3059 (or last-file default))))
3061 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3062 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3063 If variable `gnus-use-long-file-name' is non-nil, it is
3064 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3067 (if (gnus-use-long-file-name 'not-save)
3070 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3072 gnus-article-save-directory)))
3074 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3075 "Generate file name from sender."
3076 (let ((from (mail-header-from headers)))
3078 (if (and from (string-match "\\([^ <]+\\)@" from))
3079 (match-string 1 from)
3081 gnus-article-save-directory)))
3083 (defun article-verify-x-pgp-sig ()
3086 (if (gnus-buffer-live-p gnus-original-article-buffer)
3087 (let ((sig (with-current-buffer gnus-original-article-buffer
3088 (gnus-fetch-field "X-PGP-Sig")))
3092 (mml2015-clear-verify-function))
3094 (insert-buffer gnus-original-article-buffer)
3095 (setq items (split-string sig))
3096 (message-narrow-to-head)
3097 (let ((inhibit-point-motion-hooks t)
3098 (case-fold-search t))
3099 ;; Don't verify multiple headers.
3100 (setq headers (mapconcat (lambda (header)
3102 (mail-fetch-field header) "\n"))
3103 (split-string (nth 1 items) ",") "")))
3104 (delete-region (point-min) (point-max))
3105 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3106 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3111 (if (looking-at "^-")
3114 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3115 (insert "Version: " (car items) "\n\n")
3116 (insert (mapconcat 'identity (cddr items) "\n"))
3117 (insert "\n-----END PGP SIGNATURE-----\n")
3118 (let ((mm-security-handle (list (format "multipart/signed"))))
3119 (mml2015-clean-buffer)
3120 (let ((coding-system-for-write (or gnus-newsgroup-charset
3122 (funcall (mml2015-clear-verify-function)))
3124 (or (mm-handle-multipart-ctl-parameter
3125 mm-security-handle 'gnus-details)
3126 (mm-handle-multipart-ctl-parameter
3127 mm-security-handle 'gnus-info)))))
3129 (let (buffer-read-only bface eface)
3131 (message-narrow-to-head)
3132 (goto-char (point-max))
3134 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3135 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3136 (message-remove-header "X-Gnus-PGP-Verify")
3137 (if (re-search-forward "^X-PGP-Sig:" nil t)
3139 (goto-char (point-max)))
3140 (narrow-to-region (point) (point))
3141 (insert "X-Gnus-PGP-Verify: " info "\n")
3142 (goto-char (point-min))
3145 (if (not (looking-at "^[ \t]"))
3149 (goto-char (point-min))
3150 (when (looking-at "\\([^:]+\\): *")
3151 (put-text-property (match-beginning 1) (1+ (match-end 1))
3153 (put-text-property (match-end 0) (point-max)
3154 'face eface)))))))))
3156 (defun article-verify-cancel-lock ()
3157 "Verify Cancel-Lock header."
3159 (if (gnus-buffer-live-p gnus-original-article-buffer)
3160 (canlock-verify gnus-original-article-buffer)))
3167 (setq afunc (car func)
3170 gfunc (intern (format "gnus-%s" func))))
3172 (when (fboundp afunc)
3173 `(lambda (&optional interactive &rest args)
3174 ,(documentation afunc t)
3175 (interactive (list t))
3177 (set-buffer gnus-article-buffer)
3179 (call-interactively ',afunc)
3180 (apply ',afunc args))))))))
3181 '(article-hide-headers
3182 article-verify-x-pgp-sig
3183 article-verify-cancel-lock
3184 article-hide-boring-headers
3185 article-treat-overstrike
3186 article-fill-long-lines
3187 article-capitalize-sentences
3189 article-remove-leading-whitespace
3190 article-display-x-face
3191 article-de-quoted-unreadable
3192 article-de-base64-unreadable
3195 article-unsplit-urls
3196 article-hide-list-identifiers
3198 article-strip-banner
3201 article-hide-signature
3202 article-strip-headers-in-body
3203 article-remove-trailing-blank-lines
3204 article-strip-leading-blank-lines
3205 article-strip-multiple-blank-lines
3206 article-strip-leading-space
3207 article-strip-trailing-space
3208 article-strip-blank-lines
3209 article-strip-all-blank-lines
3210 article-replace-with-quoted-text
3212 article-date-english
3213 article-date-iso8601
3214 article-date-original
3216 article-decode-mime-words
3217 article-decode-charset
3218 article-decode-encoded-words
3222 article-treat-dumbquotes
3223 article-normalize-headers
3224 ;; (article-show-all . gnus-article-show-all-headers)
3228 ;;; Gnus article mode
3231 (put 'gnus-article-mode 'mode-class 'special)
3233 (set-keymap-parent gnus-article-mode-map widget-keymap)
3235 (gnus-define-keys gnus-article-mode-map
3236 " " gnus-article-goto-next-page
3237 "\177" gnus-article-goto-prev-page
3238 [delete] gnus-article-goto-prev-page
3239 [backspace] gnus-article-goto-prev-page
3240 "\C-c^" gnus-article-refer-article
3241 "h" gnus-article-show-summary
3242 "s" gnus-article-show-summary
3243 "\C-c\C-m" gnus-article-mail
3244 "?" gnus-article-describe-briefly
3245 "e" gnus-summary-edit-article
3246 "<" beginning-of-buffer
3248 "\C-c\C-i" gnus-info-find-node
3250 "R" gnus-article-reply-with-original
3251 "F" gnus-article-followup-with-original
3252 "\C-hk" gnus-article-describe-key
3253 "\C-hc" gnus-article-describe-key-briefly
3255 "\C-d" gnus-article-read-summary-keys
3256 "\M-*" gnus-article-read-summary-keys
3257 "\M-#" gnus-article-read-summary-keys
3258 "\M-^" gnus-article-read-summary-keys
3259 "\M-g" gnus-article-read-summary-keys)
3261 (substitute-key-definition
3262 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3264 (defun gnus-article-make-menu-bar ()
3265 (unless (boundp 'gnus-article-commands-menu)
3266 (gnus-summary-make-menu-bar))
3267 (gnus-turn-off-edit-menu 'article)
3268 (unless (boundp 'gnus-article-article-menu)
3270 gnus-article-article-menu gnus-article-mode-map ""
3272 ["Scroll forwards" gnus-article-goto-next-page t]
3273 ["Scroll backwards" gnus-article-goto-prev-page t]
3274 ["Show summary" gnus-article-show-summary t]
3275 ["Fetch Message-ID at point" gnus-article-refer-article t]
3276 ["Mail to address at point" gnus-article-mail t]
3277 ["Send a bug report" gnus-bug t]))
3280 gnus-article-treatment-menu gnus-article-mode-map ""
3281 ;; Fixme: this should use :active (and maybe :visible).
3283 ["Hide headers" gnus-article-hide-headers t]
3284 ["Hide signature" gnus-article-hide-signature t]
3285 ["Hide citation" gnus-article-hide-citation t]
3286 ["Treat overstrike" gnus-article-treat-overstrike t]
3287 ["Remove carriage return" gnus-article-remove-cr t]
3288 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3289 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3290 ["Remove base64" gnus-article-de-base64-unreadable t]
3291 ["Treat html" gnus-article-wash-html t]
3292 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3293 ["Decode HZ" gnus-article-decode-HZ t]))
3295 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3297 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3299 (gnus-run-hooks 'gnus-article-menu-hook)))
3301 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3304 (defun gnus-article-mode ()
3305 "Major mode for displaying an article.
3307 All normal editing commands are switched off.
3309 The following commands are available in addition to all summary mode
3311 \\<gnus-article-mode-map>
3312 \\[gnus-article-next-page]\t Scroll the article one page forwards
3313 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3314 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3315 \\[gnus-article-show-summary]\t Display the summary buffer
3316 \\[gnus-article-mail]\t Send a reply to the address near point
3317 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3318 \\[gnus-info-find-node]\t Go to the Gnus info node"
3320 (gnus-simplify-mode-line)
3321 (setq mode-name "Article")
3322 (setq major-mode 'gnus-article-mode)
3323 (make-local-variable 'minor-mode-alist)
3324 (use-local-map gnus-article-mode-map)
3325 (when (gnus-visual-p 'article-menu 'menu)
3326 (gnus-article-make-menu-bar))
3327 (gnus-update-format-specifications nil 'article-mode)
3328 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3329 (make-local-variable 'gnus-page-broken)
3330 (make-local-variable 'gnus-button-marker-list)
3331 (make-local-variable 'gnus-article-current-summary)
3332 (make-local-variable 'gnus-article-mime-handles)
3333 (make-local-variable 'gnus-article-decoded-p)
3334 (make-local-variable 'gnus-article-mime-handle-alist)
3335 (make-local-variable 'gnus-article-wash-types)
3336 (make-local-variable 'gnus-article-image-alist)
3337 (make-local-variable 'gnus-article-charset)
3338 (make-local-variable 'gnus-article-ignored-charsets)
3339 (gnus-set-default-directory)
3340 (buffer-disable-undo)
3341 (setq buffer-read-only t)
3342 (set-syntax-table gnus-article-mode-syntax-table)
3343 (mm-enable-multibyte)
3344 (gnus-run-hooks 'gnus-article-mode-hook))
3346 (defun gnus-article-setup-buffer ()
3347 "Initialize the article buffer."
3348 (let* ((name (if gnus-single-article-buffer "*Article*"
3349 (concat "*Article " gnus-newsgroup-name "*")))
3351 (progn (string-match "\\*Article" name)
3352 (concat " *Original Article"
3353 (substring name (match-end 0))))))
3354 (setq gnus-article-buffer name)
3355 (setq gnus-original-article-buffer original)
3356 (setq gnus-article-mime-handle-alist nil)
3357 ;; This might be a variable local to the summary buffer.
3358 (unless gnus-single-article-buffer
3360 (set-buffer gnus-summary-buffer)
3361 (setq gnus-article-buffer name)
3362 (setq gnus-original-article-buffer original)
3363 (gnus-set-global-variables)))
3364 (gnus-article-setup-highlight-words)
3365 ;; Init original article buffer.
3367 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3368 (mm-enable-multibyte)
3369 (setq major-mode 'gnus-original-article-mode)
3370 (make-local-variable 'gnus-original-article))
3371 (if (get-buffer name)
3374 (when gnus-article-mime-handles
3375 (mm-destroy-parts gnus-article-mime-handles)
3376 (setq gnus-article-mime-handles nil))
3377 ;; Set it to nil in article-buffer!
3378 (setq gnus-article-mime-handle-alist nil)
3379 (buffer-disable-undo)
3380 (setq buffer-read-only t)
3381 (unless (eq major-mode 'gnus-article-mode)
3382 (gnus-article-mode))
3385 (set-buffer (gnus-get-buffer-create name))
3387 (make-local-variable 'gnus-summary-buffer)
3388 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3389 (current-buffer)))))
3391 ;; Set article window start at LINE, where LINE is the number of lines
3392 ;; from the head of the article.
3393 (defun gnus-article-set-window-start (&optional line)
3395 (gnus-get-buffer-window gnus-article-buffer t)
3397 (set-buffer gnus-article-buffer)
3398 (goto-char (point-min))
3401 (gnus-message 6 "Moved to bookmark")
3402 (search-forward "\n\n" nil t)
3406 (defun gnus-article-prepare (article &optional all-headers header)
3407 "Prepare ARTICLE in article mode buffer.
3408 ARTICLE should either be an article number or a Message-ID.
3409 If ARTICLE is an id, HEADER should be the article headers.
3410 If ALL-HEADERS is non-nil, no headers are hidden."
3412 ;; Make sure we start in a summary buffer.
3413 (unless (eq major-mode 'gnus-summary-mode)
3414 (set-buffer gnus-summary-buffer))
3415 (setq gnus-summary-buffer (current-buffer))
3416 (let* ((gnus-article (if header (mail-header-number header) article))
3417 (summary-buffer (current-buffer))
3418 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3419 (group gnus-newsgroup-name)
3422 (gnus-article-setup-buffer)
3423 (set-buffer gnus-article-buffer)
3424 ;; Deactivate active regions.
3425 (when (and (boundp 'transient-mark-mode)
3426 transient-mark-mode)
3427 (setq mark-active nil))
3428 (if (not (setq result (let ((buffer-read-only nil))
3429 (gnus-request-article-this-buffer
3431 ;; There is no such article.
3433 (when (and (numberp article)
3434 (not (memq article gnus-newsgroup-sparse)))
3435 (setq gnus-article-current
3436 (cons gnus-newsgroup-name article))
3437 (set-buffer gnus-summary-buffer)
3438 (setq gnus-current-article article)
3439 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3441 (gnus-summary-set-agent-mark article)
3442 (message "Message marked for downloading"))
3443 (gnus-summary-mark-article article gnus-canceled-mark)
3444 (unless (memq article gnus-newsgroup-sparse)
3445 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3446 (if (or (eq result 'pseudo)
3447 (eq result 'nneething))
3450 (set-buffer summary-buffer)
3451 (push article gnus-newsgroup-history)
3452 (setq gnus-last-article gnus-current-article
3453 gnus-current-article 0
3454 gnus-current-headers nil
3455 gnus-article-current nil)
3456 (if (eq result 'nneething)
3457 (gnus-configure-windows 'summary)
3458 (gnus-configure-windows 'article))
3459 (gnus-set-global-variables))
3460 (let ((gnus-article-mime-handle-alist-1
3461 gnus-article-mime-handle-alist))
3462 (gnus-set-mode-line 'article)))
3463 ;; The result from the `request' was an actual article -
3464 ;; or at least some text that is now displayed in the
3466 (when (and (numberp article)
3467 (not (eq article gnus-current-article)))
3468 ;; Seems like a new article has been selected.
3469 ;; `gnus-current-article' must be an article number.
3471 (set-buffer summary-buffer)
3472 (push article gnus-newsgroup-history)
3473 (setq gnus-last-article gnus-current-article
3474 gnus-current-article article
3475 gnus-current-headers
3476 (gnus-summary-article-header gnus-current-article)
3477 gnus-article-current
3478 (cons gnus-newsgroup-name gnus-current-article))
3479 (unless (vectorp gnus-current-headers)
3480 (setq gnus-current-headers nil))
3481 (gnus-summary-goto-subject gnus-current-article)
3482 (when (gnus-summary-show-thread)
3483 ;; If the summary buffer really was folded, the
3484 ;; previous goto may not actually have gone to
3485 ;; the right article, but the thread root instead.
3487 (gnus-summary-goto-subject gnus-current-article))
3488 (gnus-run-hooks 'gnus-mark-article-hook)
3489 (gnus-set-mode-line 'summary)
3490 (when (gnus-visual-p 'article-highlight 'highlight)
3491 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3492 ;; Set the global newsgroup variables here.
3493 (gnus-set-global-variables)
3494 (setq gnus-have-all-headers
3495 (or all-headers gnus-show-all-headers))))
3497 (gnus-configure-windows 'article))
3498 (when (or (numberp article)
3500 (gnus-article-prepare-display)
3502 (goto-char (point-min))
3503 (setq gnus-page-broken
3504 (when gnus-break-pages
3505 (gnus-narrow-to-page)
3507 (let ((gnus-article-mime-handle-alist-1
3508 gnus-article-mime-handle-alist))
3509 (gnus-set-mode-line 'article))
3511 (set-window-point (get-buffer-window (current-buffer)) (point))
3512 (gnus-configure-windows 'article)
3516 (defun gnus-article-prepare-display ()
3517 "Make the current buffer look like a nice article."
3518 ;; Hooks for getting information from the article.
3519 ;; This hook must be called before being narrowed.
3520 (let ((gnus-article-buffer (current-buffer))
3522 (unless (eq major-mode 'gnus-article-mode)
3523 (gnus-article-mode))
3524 (setq buffer-read-only nil
3525 gnus-article-wash-types nil
3526 gnus-article-image-alist nil)
3527 (gnus-run-hooks 'gnus-tmp-internal-hook)
3528 (when gnus-display-mime-function
3529 (funcall gnus-display-mime-function))
3530 (gnus-run-hooks 'gnus-article-prepare-hook)))
3533 ;;; Gnus MIME viewing functions
3536 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3537 "Format of the MIME buttons.
3539 Valid specifiers include:
3541 %T MIME type, along with additional info
3542 %n The `name' parameter
3543 %d The description, if any
3544 %l The length of the encoded part
3545 %p The part identifier number
3546 %e Dots if the part isn't displayed
3548 General format specifiers can also be used. See
3549 (gnus)Formatting Variables.")
3551 (defvar gnus-mime-button-line-format-alist
3552 '((?t gnus-tmp-type ?s)
3553 (?T gnus-tmp-type-long ?s)
3554 (?n gnus-tmp-name ?s)
3555 (?d gnus-tmp-description ?s)
3557 (?l gnus-tmp-length ?d)
3558 (?e gnus-tmp-dots ?s)))
3560 (defvar gnus-mime-button-commands
3561 '((gnus-article-press-button "\r" "Toggle Display")
3562 (gnus-mime-view-part "v" "View Interactively...")
3563 (gnus-mime-view-part-as-type "t" "View As Type...")
3564 (gnus-mime-view-part-as-charset "C" "View As charset...")
3565 (gnus-mime-save-part "o" "Save...")
3566 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3567 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3568 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3569 (gnus-mime-internalize-part "E" "View Internally")
3570 (gnus-mime-externalize-part "e" "View Externally")
3571 (gnus-mime-print-part "p" "Print")
3572 (gnus-mime-pipe-part "|" "Pipe To Command...")
3573 (gnus-mime-action-on-part "." "Take action on the part")))
3575 (defun gnus-article-mime-part-status ()
3576 (if gnus-article-mime-handle-alist-1
3577 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3579 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3582 (defvar gnus-mime-button-map
3583 (let ((map (make-sparse-keymap)))
3584 (unless (>= (string-to-number emacs-version) 21)
3585 ;; XEmacs doesn't care.
3586 (set-keymap-parent map gnus-article-mode-map))
3587 (define-key map gnus-mouse-2 'gnus-article-push-button)
3588 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3589 (dolist (c gnus-mime-button-commands)
3590 (define-key map (cadr c) (car c)))
3593 (defun gnus-mime-button-menu (event)
3594 "Construct a context-sensitive menu of MIME commands."
3596 (save-window-excursion
3597 (let ((pos (event-start event)))
3598 (select-window (posn-window pos))
3599 (goto-char (posn-point pos))
3600 (gnus-article-check-buffer)
3601 (let ((response (x-popup-menu
3603 ("" ,@(mapcar (lambda (c)
3604 (cons (caddr c) (car c)))
3605 gnus-mime-button-commands))))))
3607 (call-interactively response))))))
3609 (defun gnus-mime-view-all-parts (&optional handles)
3610 "View all the MIME parts."
3612 (save-current-buffer
3613 (set-buffer gnus-article-buffer)
3614 (let ((handles (or handles gnus-article-mime-handles))
3615 (mail-parse-charset gnus-newsgroup-charset)
3616 (mail-parse-ignored-charsets
3617 (with-current-buffer gnus-summary-buffer
3618 gnus-newsgroup-ignored-charsets)))
3620 (mm-remove-parts handles)
3621 (goto-char (point-min))
3622 (or (search-forward "\n\n") (goto-char (point-max)))
3623 (let (buffer-read-only)
3624 (delete-region (point) (point-max))
3625 (mm-display-parts handles))))))
3627 (defun gnus-mime-save-part-and-strip ()
3628 "Save the MIME part under point then replace it with an external body."
3630 (gnus-article-check-buffer)
3631 (let* ((data (get-text-property (point) 'gnus-data))
3633 (handles gnus-article-mime-handles))
3634 (if (mm-multiple-handles gnus-article-mime-handles)
3635 (error "This function is not implemented"))
3636 (setq file (and data (mm-save-part data)))
3638 (with-current-buffer (mm-handle-buffer data)
3640 (insert "Content-Type: " (mm-handle-media-type data))
3641 (mml-insert-parameter-string (cdr (mm-handle-type data))
3644 (insert "Content-ID: " (message-make-message-id) "\n")
3645 (insert "Content-Transfer-Encoding: binary\n")
3648 (cdr (mm-make-handle nil
3649 `("message/external-body"
3650 (access-type . "LOCAL-FILE")
3652 (set-buffer gnus-summary-buffer)
3653 (gnus-article-edit-article
3656 (let ((mail-parse-charset (or gnus-article-charset
3657 ',gnus-newsgroup-charset))
3658 (mail-parse-ignored-charsets
3659 (or gnus-article-ignored-charsets
3660 ',gnus-newsgroup-ignored-charsets))
3661 (mbl mml-buffer-list))
3662 (setq mml-buffer-list nil)
3663 (insert-buffer gnus-original-article-buffer)
3664 (mime-to-mml ',handles)
3665 (setq gnus-article-mime-handles nil)
3666 (let ((mbl1 mml-buffer-list))
3667 (setq mml-buffer-list mbl)
3668 (set (make-local-variable 'mml-buffer-list) mbl1))
3669 ;; LOCAL argument of add-hook differs between GNU Emacs
3670 ;; and XEmacs. make-local-hook makes sure they are local.
3671 (make-local-hook 'kill-buffer-hook)
3672 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3673 `(lambda (no-highlight)
3674 (let ((mail-parse-charset (or gnus-article-charset
3675 ',gnus-newsgroup-charset))
3676 (message-options message-options)
3677 (message-options-set-recipient)
3678 (mail-parse-ignored-charsets
3679 (or gnus-article-ignored-charsets
3680 ',gnus-newsgroup-ignored-charsets)))
3682 (mml-destroy-buffers)
3683 (remove-hook 'kill-buffer-hook
3684 'mml-destroy-buffers t)
3685 (kill-local-variable 'mml-buffer-list))
3686 (gnus-summary-edit-article-done
3687 ,(or (mail-header-references gnus-current-headers) "")
3688 ,(gnus-group-read-only-p)
3689 ,gnus-summary-buffer no-highlight))))))
3691 (defun gnus-mime-save-part ()
3692 "Save the MIME part under point."
3694 (gnus-article-check-buffer)
3695 (let ((data (get-text-property (point) 'gnus-data)))
3697 (mm-save-part data))))
3699 (defun gnus-mime-pipe-part ()
3700 "Pipe the MIME part under point to a process."
3702 (gnus-article-check-buffer)
3703 (let ((data (get-text-property (point) 'gnus-data)))
3705 (mm-pipe-part data))))
3707 (defun gnus-mime-view-part ()
3708 "Interactively choose a viewing method for the MIME part under point."
3710 (gnus-article-check-buffer)
3711 (let ((data (get-text-property (point) 'gnus-data)))
3713 (setq gnus-article-mime-handles
3715 gnus-article-mime-handles (setq data (copy-sequence data))))
3716 (mm-interactively-view-part data))))
3718 (defun gnus-mime-view-part-as-type-internal ()
3719 (gnus-article-check-buffer)
3720 (let* ((name (mail-content-type-get
3721 (mm-handle-type (get-text-property (point) 'gnus-data))
3723 (def-type (and name (mm-default-file-encoding name))))
3724 (and def-type (cons def-type 0))))
3726 (defun gnus-mime-view-part-as-type (&optional mime-type)
3727 "Choose a MIME media type, and view the part as such."
3730 (setq mime-type (completing-read
3731 "View as MIME type: "
3732 (mapcar #'list (mailcap-mime-types))
3734 (gnus-mime-view-part-as-type-internal))))
3735 (gnus-article-check-buffer)
3736 (let ((handle (get-text-property (point) 'gnus-data)))
3739 (mm-make-handle (mm-handle-buffer handle)
3740 (cons mime-type (cdr (mm-handle-type handle)))
3741 (mm-handle-encoding handle)
3742 (mm-handle-undisplayer handle)
3743 (mm-handle-disposition handle)
3744 (mm-handle-description handle)
3746 (mm-handle-id handle)))
3747 (setq gnus-article-mime-handles
3748 (mm-merge-handles gnus-article-mime-handles handle))
3749 (gnus-mm-display-part handle))))
3751 (defun gnus-mime-copy-part (&optional handle)
3752 "Put the MIME part under point into a new buffer."
3754 (gnus-article-check-buffer)
3755 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3756 (contents (and handle (mm-get-part handle)))
3758 (file-name-nondirectory
3760 (mail-content-type-get (mm-handle-type handle) 'name)
3761 (mail-content-type-get (mm-handle-type handle)
3764 (buffer (and base (generate-new-buffer base))))
3766 (switch-to-buffer buffer)
3768 ;; We do it this way to make `normal-mode' set the appropriate mode.
3771 (setq buffer-file-name (expand-file-name base))
3773 (setq buffer-file-name nil))
3774 (goto-char (point-min)))))
3776 (defun gnus-mime-print-part (&optional handle filename)
3777 "Print the MIME part under point."
3778 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3779 (gnus-article-check-buffer)
3780 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3781 (contents (and handle (mm-get-part handle)))
3782 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3783 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3788 (with-temp-file file
3790 (call-process shell-file-name nil
3791 (generate-new-buffer " *mm*")
3793 shell-command-switch
3795 printer file (mm-handle-type handle))))
3799 (gnus-print-buffer))
3800 (ps-despool filename)))))
3802 (defun gnus-mime-inline-part (&optional handle arg)
3803 "Insert the MIME part under point into the current buffer."
3804 (interactive (list nil current-prefix-arg))
3805 (gnus-article-check-buffer)
3806 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3811 (if (and (not arg) (mm-handle-undisplayer handle))
3812 (mm-remove-part handle)
3813 (setq contents (mm-get-part handle))
3816 (setq charset (or (mail-content-type-get
3817 (mm-handle-type handle) 'charset)
3818 gnus-newsgroup-charset)))
3820 (if (mm-handle-undisplayer handle)
3821 (mm-remove-part handle))
3824 gnus-summary-show-article-charset-alist))
3825 (mm-read-coding-system "Charset: ")))))
3827 (mm-insert-inline handle
3829 (setq charset (mm-charset-to-coding-system
3831 (not (eq charset 'ascii)))
3832 (mm-decode-coding-string contents charset)
3836 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3837 "Insert the MIME part under point into the current buffer using the
3839 (interactive (list nil current-prefix-arg))
3840 (gnus-article-check-buffer)
3841 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3846 (if (mm-handle-undisplayer handle)
3847 (mm-remove-part handle))
3848 (let ((gnus-newsgroup-charset
3850 gnus-summary-show-article-charset-alist))
3851 (mm-read-coding-system "Charset: ")))
3852 (gnus-newsgroup-ignored-charsets 'gnus-all))
3853 (gnus-article-press-button)))))
3855 (defun gnus-mime-externalize-part (&optional handle)
3856 "View the MIME part under point with an external viewer."
3858 (gnus-article-check-buffer)
3859 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3860 (mm-user-display-methods nil)
3861 (mm-inlined-types nil)
3862 (mail-parse-charset gnus-newsgroup-charset)
3863 (mail-parse-ignored-charsets
3864 (save-excursion (set-buffer gnus-summary-buffer)
3865 gnus-newsgroup-ignored-charsets)))
3867 (if (mm-handle-undisplayer handle)
3868 (mm-remove-part handle)
3869 (mm-display-part handle)))))
3871 (defun gnus-mime-internalize-part (&optional handle)
3872 "View the MIME part under point with an internal viewer.
3873 If no internal viewer is available, use an external viewer."
3875 (gnus-article-check-buffer)
3876 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3877 (mm-inlined-types '(".*"))
3878 (mm-inline-large-images t)
3879 (mail-parse-charset gnus-newsgroup-charset)
3880 (mail-parse-ignored-charsets
3881 (save-excursion (set-buffer gnus-summary-buffer)
3882 gnus-newsgroup-ignored-charsets)))
3884 (if (mm-handle-undisplayer handle)
3885 (mm-remove-part handle)
3886 (mm-display-part handle)))))
3888 (defun gnus-mime-action-on-part (&optional action)
3889 "Do something with the MIME attachment at \(point\)."
3891 (list (completing-read "Action: " gnus-mime-action-alist)))
3892 (gnus-article-check-buffer)
3893 (let ((action-pair (assoc action gnus-mime-action-alist)))
3895 (funcall (cdr action-pair)))))
3897 (defun gnus-article-part-wrapper (n function)
3898 (save-current-buffer
3899 (set-buffer gnus-article-buffer)
3900 (when (> n (length gnus-article-mime-handle-alist))
3901 (error "No such part"))
3902 (gnus-article-goto-part n)
3903 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3904 (funcall function handle))))
3906 (defun gnus-article-pipe-part (n)
3907 "Pipe MIME part N, which is the numerical prefix."
3909 (gnus-article-part-wrapper n 'mm-pipe-part))
3911 (defun gnus-article-save-part (n)
3912 "Save MIME part N, which is the numerical prefix."
3914 (gnus-article-part-wrapper n 'mm-save-part))
3916 (defun gnus-article-interactively-view-part (n)
3917 "View MIME part N interactively, which is the numerical prefix."
3919 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3921 (defun gnus-article-copy-part (n)
3922 "Copy MIME part N, which is the numerical prefix."
3924 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3926 (defun gnus-article-view-part-as-charset (n)
3927 "Copy MIME part N, which is the numerical prefix."
3929 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3931 (defun gnus-article-externalize-part (n)
3932 "View MIME part N externally, which is the numerical prefix."
3934 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3936 (defun gnus-article-inline-part (n)
3937 "Inline MIME part N, which is the numerical prefix."
3939 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3941 (defun gnus-article-mime-match-handle-first (condition)
3943 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3944 (while (setq ihandle (pop alist))
3946 ((functionp condition)
3947 (funcall condition (cdr ihandle)))
3948 ((eq condition 'undisplayed)
3949 (not (or (mm-handle-undisplayer (cdr ihandle))
3950 (equal (mm-handle-media-type (cdr ihandle))
3951 "multipart/alternative"))))
3952 ((eq condition 'undisplayed-alternative)
3953 (not (mm-handle-undisplayer (cdr ihandle))))
3955 (gnus-article-goto-part (car ihandle))
3956 (or (not n) (< (car ihandle) n)))
3957 (setq n (car ihandle))))
3961 (defun gnus-article-view-part (&optional n)
3962 "View MIME part N, which is the numerical prefix."
3964 (save-current-buffer
3965 (set-buffer gnus-article-buffer)
3966 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3967 gnus-article-mime-match-handle-function)))
3968 (when (> n (length gnus-article-mime-handle-alist))
3969 (error "No such part"))
3970 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3971 (when (gnus-article-goto-part n)
3972 (if (equal (car handle) "multipart/alternative")
3973 (gnus-article-press-button)
3974 (when (eq (gnus-mm-display-part handle) 'internal)
3975 (gnus-set-window-start)))))))
3977 (defsubst gnus-article-mime-total-parts ()
3978 (if (bufferp (car gnus-article-mime-handles))
3980 (1- (length gnus-article-mime-handles))))
3982 (defun gnus-mm-display-part (handle)
3983 "Display HANDLE and fix MIME button."
3984 (let ((id (get-text-property (point) 'gnus-part))
3989 (let ((window (selected-window))
3990 (mail-parse-charset gnus-newsgroup-charset)
3991 (mail-parse-ignored-charsets
3992 (if (gnus-buffer-live-p gnus-summary-buffer)
3994 (set-buffer gnus-summary-buffer)
3995 gnus-newsgroup-ignored-charsets)
3999 (let ((win (gnus-get-buffer-window (current-buffer) t))
4002 (select-window win))
4005 (if (mm-handle-displayed-p handle)
4006 ;; This will remove the part.
4007 (mm-display-part handle)
4009 (narrow-to-region (point)
4010 (if (eobp) (point) (1+ (point))))
4011 (mm-display-part handle)
4012 ;; We narrow to the part itself and
4013 ;; then call the treatment functions.
4014 (goto-char (point-min))
4016 (narrow-to-region (point) (point-max))
4019 (gnus-article-mime-total-parts)
4020 (mm-handle-media-type handle)))))
4021 (if (window-live-p window)
4022 (select-window window)))))
4024 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4025 (gnus-insert-mime-button
4026 handle id (list (mm-handle-displayed-p handle)))
4027 (goto-char point))))
4029 (defun gnus-article-goto-part (n)
4030 "Go to MIME part N."
4031 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4033 (goto-char point))))
4035 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4036 (let ((gnus-tmp-name
4037 (or (mail-content-type-get (mm-handle-type handle) 'name)
4038 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4039 (mail-content-type-get (mm-handle-type handle) 'url)
4041 (gnus-tmp-type (mm-handle-media-type handle))
4042 (gnus-tmp-description
4043 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4046 (if (if displayed (car displayed)
4047 (mm-handle-displayed-p handle))
4049 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4051 gnus-tmp-type-long b e)
4052 (when (string-match ".*/" gnus-tmp-name)
4053 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4054 (setq gnus-tmp-type-long (concat gnus-tmp-type
4055 (and (not (equal gnus-tmp-name ""))
4056 (concat "; " gnus-tmp-name))))
4057 (unless (equal gnus-tmp-description "")
4058 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4063 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4064 `(,@(gnus-local-map-property gnus-mime-button-map)
4065 gnus-callback gnus-mm-display-part
4066 gnus-part ,gnus-tmp-id
4067 article-type annotation
4070 (widget-convert-button
4073 :action 'gnus-widget-press-button
4074 :button-keymap gnus-mime-button-map
4076 (lambda (widget/window &optional overlay pos)
4077 ;; Needed to properly clear the message due to a bug in
4078 ;; wid-edit (XEmacs only).
4079 (if (boundp 'help-echo-owns-message)
4080 (setq help-echo-owns-message t))
4082 "%S: %s the MIME part; %S: more options"
4083 (aref gnus-mouse-2 0)
4084 ;; XEmacs will get a single widget arg; Emacs 21 will get
4085 ;; window, overlay, position.
4086 (if (mm-handle-displayed-p
4088 (with-current-buffer (gnus-overlay-buffer overlay)
4089 (widget-get (widget-at (gnus-overlay-start overlay))
4091 (widget-get widget/window :mime-handle)))
4093 (aref gnus-down-mouse-3 0))))))
4095 (defun gnus-widget-press-button (elems el)
4096 (goto-char (widget-get elems :from))
4097 (gnus-article-press-button))
4099 (defvar gnus-displaying-mime nil)
4101 (defun gnus-display-mime (&optional ihandles)
4102 "Display the MIME parts."
4104 (save-selected-window
4105 (let ((window (get-buffer-window gnus-article-buffer))
4108 (select-window window)
4109 ;; We have to do this since selecting the window
4110 ;; may change the point. So we set the window point.
4111 (set-window-point window point)))
4112 (let* ((handles (or ihandles (mm-dissect-buffer
4113 gnus-article-no-strict-mime)
4115 buffer-read-only handle name type b e display)
4116 (when (and (not ihandles)
4117 (not gnus-displaying-mime))
4118 ;; Top-level call; we clean up.
4119 (when gnus-article-mime-handles
4120 (mm-destroy-parts gnus-article-mime-handles)
4121 (setq gnus-article-mime-handle-alist nil));; A trick.
4122 (setq gnus-article-mime-handles handles)
4123 ;; We allow users to glean info from the handles.
4124 (when gnus-article-mime-part-function
4125 (gnus-mime-part-function handles)))
4127 (or (not (stringp (car handles)))
4130 (when (and (not ihandles)
4131 (not gnus-displaying-mime))
4132 ;; Clean up for mime parts.
4134 (delete-region (point) (point-max)))
4135 (let ((gnus-displaying-mime t))
4136 (gnus-mime-display-part handles)))
4139 (narrow-to-region (point) (point-max))
4140 (gnus-treat-article nil 1 1)
4143 ;; Highlight the headers.
4147 (narrow-to-region (point-min) (point))
4148 (gnus-treat-article 'head))))))))
4150 (defvar gnus-mime-display-multipart-as-mixed nil)
4151 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4152 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4154 (defun gnus-mime-display-part (handle)
4157 ((not (stringp (car handle)))
4158 (gnus-mime-display-single handle))
4159 ;; User-defined multipart
4160 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4161 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4163 ;; multipart/alternative
4164 ((and (equal (car handle) "multipart/alternative")
4165 (not (or gnus-mime-display-multipart-as-mixed
4166 gnus-mime-display-multipart-alternative-as-mixed)))
4167 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4168 (push (cons id handle) gnus-article-mime-handle-alist)
4169 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4170 ;; multipart/related
4171 ((and (equal (car handle) "multipart/related")
4172 (not (or gnus-mime-display-multipart-as-mixed
4173 gnus-mime-display-multipart-related-as-mixed)))
4174 ;;;!!!We should find the start part, but we just default
4175 ;;;!!!to the first part.
4176 ;;(gnus-mime-display-part (cadr handle))
4177 ;;;!!! Most multipart/related is an HTML message plus images.
4178 ;;;!!! Unfortunately we are unable to let W3 display those
4179 ;;;!!! included images, so we just display it as a mixed multipart.
4180 ;;(gnus-mime-display-mixed (cdr handle))
4181 ;;;!!! No, w3 can display everything just fine.
4182 (gnus-mime-display-part (cadr handle)))
4183 ((equal (car handle) "multipart/signed")
4184 (gnus-add-wash-type 'signed)
4185 (gnus-mime-display-security handle))
4186 ((equal (car handle) "multipart/encrypted")
4187 (gnus-add-wash-type 'encrypted)
4188 (gnus-mime-display-security handle))
4189 ;; Other multiparts are handled like multipart/mixed.
4191 (gnus-mime-display-mixed (cdr handle)))))
4193 (defun gnus-mime-part-function (handles)
4194 (if (stringp (car handles))
4195 (mapcar 'gnus-mime-part-function (cdr handles))
4196 (funcall gnus-article-mime-part-function handles)))
4198 (defun gnus-mime-display-mixed (handles)
4199 (mapcar 'gnus-mime-display-part handles))
4201 (defun gnus-mime-display-single (handle)
4202 (let ((type (mm-handle-media-type handle))
4203 (ignored gnus-ignored-mime-types)
4210 (when (string-match (pop ignored) type)
4211 (throw 'ignored nil)))
4212 (if (and (setq not-attachment
4213 (and (not (mm-inline-override-p handle))
4214 (or (not (mm-handle-disposition handle))
4215 (equal (car (mm-handle-disposition handle))
4217 (mm-attachment-override-p handle))))
4218 (mm-automatic-display-p handle)
4220 (mm-inlinable-p handle)
4221 (mm-inlined-p handle))
4222 (mm-automatic-external-display-p type)))
4224 (when (equal (mm-handle-media-supertype handle) "text")
4226 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4228 (push (cons id handle) gnus-article-mime-handle-alist)
4229 (when (or (not display)
4230 (not (gnus-unbuttonized-mime-type-p type)))
4231 ;(gnus-article-insert-newline)
4232 (gnus-insert-mime-button
4233 handle id (list (or display (and not-attachment text))))
4234 (gnus-article-insert-newline)
4235 ;(gnus-article-insert-newline)
4236 ;; Remember modify the number of forward lines.
4244 (let ((mail-parse-charset gnus-newsgroup-charset)
4245 (mail-parse-ignored-charsets
4246 (save-excursion (condition-case ()
4247 (set-buffer gnus-summary-buffer)
4249 gnus-newsgroup-ignored-charsets)))
4250 (mm-display-part handle t))
4251 (goto-char (point-max)))
4252 ((and text not-attachment)
4256 (gnus-article-insert-newline)
4257 (mm-insert-inline handle (mm-get-part handle))
4258 (goto-char (point-max))))
4262 (narrow-to-region beg (point))
4265 (gnus-article-mime-total-parts)
4266 (mm-handle-media-type handle)))))))))
4268 (defun gnus-unbuttonized-mime-type-p (type)
4269 "Say whether TYPE is to be unbuttonized."
4270 (unless gnus-inhibit-mime-unbuttonizing
4272 (let ((types gnus-unbuttonized-mime-types))
4274 (when (string-match (pop types) type)
4275 (throw 'found t)))))
4277 (let ((types gnus-buttonized-mime-types))
4279 (when (string-match (pop types) type)
4280 (throw 'found t)))))))))
4282 (defun gnus-article-insert-newline ()
4283 "Insert a newline, but mark it as undeletable."
4284 (gnus-put-text-property
4285 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4287 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4288 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4291 handle buffer-read-only from props begend not-pref)
4292 (save-window-excursion
4295 (narrow-to-region (car ibegend)
4298 (goto-char (car ibegend))
4301 (delete-region (point-min) (point-max))
4302 (mm-remove-parts handles))
4303 (setq begend (list (point-marker)))
4305 (unless (setq not-pref (cadr (member preferred ihandles)))
4306 (setq not-pref (car ihandles)))
4309 (not (gnus-unbuttonized-mime-type-p
4310 "multipart/alternative")))
4311 (gnus-add-text-properties
4314 (insert (format "%d. " id))
4318 (unless ,(not ibegend)
4319 (setq gnus-article-mime-handle-alist
4320 ',gnus-article-mime-handle-alist))
4321 (gnus-mime-display-alternative
4322 ',ihandles ',not-pref ',begend ,id))
4323 ,@(gnus-local-map-property gnus-mime-button-map)
4324 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4325 face ,gnus-article-button-face
4328 (widget-convert-button 'link from (point)
4329 :action 'gnus-widget-press-button
4330 :button-keymap gnus-widget-button-keymap)
4332 (while (setq handle (pop handles))
4333 (gnus-add-text-properties
4336 (insert (format "(%c) %-18s"
4337 (if (equal handle preferred) ?* ? )
4338 (mm-handle-media-type handle)))
4342 (unless ,(not ibegend)
4343 (setq gnus-article-mime-handle-alist
4344 ',gnus-article-mime-handle-alist))
4345 (gnus-mime-display-alternative
4346 ',ihandles ',handle ',begend ,id))
4347 ,@(gnus-local-map-property gnus-mime-button-map)
4348 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4349 face ,gnus-article-button-face
4352 (widget-convert-button 'link from (point)
4353 :action 'gnus-widget-press-button
4354 :button-keymap gnus-widget-button-keymap)
4358 (if (stringp (car preferred))
4359 (gnus-display-mime preferred)
4360 (let ((mail-parse-charset gnus-newsgroup-charset)
4361 (mail-parse-ignored-charsets
4362 (save-excursion (set-buffer gnus-summary-buffer)
4363 gnus-newsgroup-ignored-charsets)))
4364 (mm-display-part preferred)
4368 (narrow-to-region (car begend) (point-max))
4370 nil (length gnus-article-mime-handle-alist)
4371 (gnus-article-mime-total-parts)
4372 (mm-handle-media-type handle))))))
4373 (goto-char (point-max))
4374 (setcdr begend (point-marker)))))
4376 (goto-char point))))
4378 (defconst gnus-article-wash-status-strings
4379 (let ((alist '((cite "c" "Possible hidden citation text"
4380 " " "All citation text visible")
4381 (headers "h" "Hidden headers"
4382 " " "All headers visible.")
4383 (pgp "p" "Encrypted or signed message status hidden"
4384 " " "No hidden encryption nor digital signature status")
4385 (signature "s" "Signature has been hidden"
4386 " " "Signature is visible")
4387 (overstrike "o" "Overstrike (^H) characters applied"
4388 " " "No overstrike characters applied")
4389 (emphasis "e" "/*_Emphasis_*/ characters applied"
4390 " " "No /*_emphasis_*/ characters applied")))
4392 (dolist (entry alist result)
4393 (let ((key (nth 0 entry))
4394 (on (copy-sequence (nth 1 entry)))
4395 (on-help (nth 2 entry))
4396 (off (copy-sequence (nth 3 entry)))
4397 (off-help (nth 4 entry)))
4398 (put-text-property 0 1 'help-echo on-help on)
4399 (put-text-property 0 1 'help-echo off-help off)
4400 (push (list key on off) result))))
4401 "Alist of strings describing wash status in the mode line.
4402 Each entry has the form (KEY ON OF), where the KEY is a symbol
4403 representing the particular washing function, ON is the string to use
4404 in the article mode line when the washing function is active, and OFF
4405 is the string to use when it is inactive.")
4407 (defun gnus-article-wash-status-entry (key value)
4408 (let ((entry (assoc key gnus-article-wash-status-strings)))
4409 (if value (nth 1 entry) (nth 2 entry))))
4411 (defun gnus-article-wash-status ()
4412 "Return a string which display status of article washing."
4414 (set-buffer gnus-article-buffer)
4415 (let ((cite (memq 'cite gnus-article-wash-types))
4416 (headers (memq 'headers gnus-article-wash-types))
4417 (boring (memq 'boring-headers gnus-article-wash-types))
4418 (pgp (memq 'pgp gnus-article-wash-types))
4419 (pem (memq 'pem gnus-article-wash-types))
4420 (signed (memq 'signed gnus-article-wash-types))
4421 (encrypted (memq 'encrypted gnus-article-wash-types))
4422 (signature (memq 'signature gnus-article-wash-types))
4423 (overstrike (memq 'overstrike gnus-article-wash-types))
4424 (emphasis (memq 'emphasis gnus-article-wash-types)))
4426 (gnus-article-wash-status-entry 'cite cite)
4427 (gnus-article-wash-status-entry 'headers (or headers boring))
4428 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4429 (gnus-article-wash-status-entry 'signature signature)
4430 (gnus-article-wash-status-entry 'overstrike overstrike)
4431 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4433 (defun gnus-add-wash-type (type)
4434 "Add a washing of TYPE to the current status."
4435 (add-to-list 'gnus-article-wash-types type))
4437 (defun gnus-delete-wash-type (type)
4438 "Add a washing of TYPE to the current status."
4439 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4441 (defun gnus-add-image (category image)
4442 "Add IMAGE of CATEGORY to the list of displayed images."
4443 (let ((entry (assq category gnus-article-image-alist)))
4445 (setq entry (list category))
4446 (push entry gnus-article-image-alist))
4447 (nconc entry (list image))))
4449 (defun gnus-delete-images (category)
4450 "Delete all images in CATEGORY."
4451 (let ((entry (assq category gnus-article-image-alist)))
4452 (dolist (image (cdr entry))
4453 (gnus-remove-image image))
4454 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4455 (gnus-delete-wash-type category)))
4457 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4459 (defun gnus-article-maybe-hide-headers ()
4460 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4461 Provided for backwards compatibility."
4462 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4463 (not (save-excursion (set-buffer gnus-summary-buffer)
4464 gnus-have-all-headers)))
4465 (not gnus-inhibit-hiding))
4466 (gnus-article-hide-headers)))
4470 (defun gnus-output-to-file (file-name)
4471 "Append the current article to a file named FILE-NAME."
4472 (let ((artbuf (current-buffer)))
4474 (insert-buffer-substring artbuf)
4475 ;; Append newline at end of the buffer as separator, and then
4477 (goto-char (point-max))
4479 (let ((file-name-coding-system nnmail-pathname-coding-system))
4480 (mm-append-to-file (point-min) (point-max) file-name))
4483 (defun gnus-narrow-to-page (&optional arg)
4484 "Narrow the article buffer to a page.
4485 If given a numerical ARG, move forward ARG pages."
4487 (setq arg (if arg (prefix-numeric-value arg) 0))
4489 (set-buffer gnus-article-buffer)
4490 (goto-char (point-min))
4492 ;; Remove any old next/prev buttons.
4493 (when (gnus-visual-p 'page-marker)
4494 (let ((buffer-read-only nil))
4495 (gnus-remove-text-with-property 'gnus-prev)
4496 (gnus-remove-text-with-property 'gnus-next)))
4499 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4501 (re-search-forward page-delimiter nil 'move arg)))
4502 (goto-char (match-end 0)))
4505 (if (re-search-forward page-delimiter nil 'move)
4508 (when (and (gnus-visual-p 'page-marker)
4509 (not (= (point-min) 1)))
4511 (goto-char (point-min))
4512 (gnus-insert-prev-page-button)))
4513 (when (and (gnus-visual-p 'page-marker)
4514 (< (+ (point-max) 2) (buffer-size)))
4516 (goto-char (point-max))
4517 (gnus-insert-next-page-button)))))
4519 ;; Article mode commands
4521 (defun gnus-article-goto-next-page ()
4522 "Show the next page of the article."
4524 (when (gnus-article-next-page)
4525 (goto-char (point-min))
4526 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4528 (defun gnus-article-goto-prev-page ()
4529 "Show the next page of the article."
4531 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4532 (gnus-article-prev-page nil)))
4534 (defun gnus-article-next-page (&optional lines)
4535 "Show the next page of the current article.
4536 If end of article, return non-nil. Otherwise return nil.
4537 Argument LINES specifies lines to be scrolled up."
4539 (move-to-window-line -1)
4542 (and (pos-visible-in-window-p) ;Not continuation line.
4544 ;; Nothing in this page.
4545 (if (or (not gnus-page-broken)
4548 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4550 (gnus-narrow-to-page 1) ;Go to next page.
4552 ;; More in this page.
4553 (let ((scroll-in-place nil))
4557 ;; Long lines may cause an end-of-buffer error.
4558 (goto-char (point-max)))))
4559 (move-to-window-line 0)
4562 (defun gnus-article-prev-page (&optional lines)
4563 "Show previous page of current article.
4564 Argument LINES specifies lines to be scrolled down."
4566 (move-to-window-line 0)
4567 (if (and gnus-page-broken
4569 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4571 (gnus-narrow-to-page -1) ;Go to previous page.
4572 (goto-char (point-max))
4574 (let ((scroll-in-place nil))
4578 (beginning-of-buffer
4579 (goto-char (point-min))))
4580 (move-to-window-line 0)))))
4582 (defun gnus-article-refer-article ()
4583 "Read article specified by message-id around point."
4585 (let ((point (point)))
4586 (search-forward ">" nil t) ;Move point to end of "<....>".
4587 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4588 (let ((message-id (match-string 1)))
4590 (set-buffer gnus-summary-buffer)
4591 (gnus-summary-refer-article message-id))
4593 (error "No references around point"))))
4595 (defun gnus-article-show-summary ()
4596 "Reconfigure windows to show summary buffer."
4598 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4599 (error "There is no summary buffer for this article buffer")
4600 (gnus-article-set-globals)
4601 (gnus-configure-windows 'article)
4602 (gnus-summary-goto-subject gnus-current-article)
4603 (gnus-summary-position-point)))
4605 (defun gnus-article-describe-briefly ()
4606 "Describe article mode commands briefly."
4608 (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")))
4610 (defun gnus-article-summary-command ()
4611 "Execute the last keystroke in the summary buffer."
4613 (let ((obuf (current-buffer))
4614 (owin (current-window-configuration))
4616 (switch-to-buffer gnus-article-current-summary 'norecord)
4617 (setq func (lookup-key (current-local-map) (this-command-keys)))
4618 (call-interactively func)
4620 (set-window-configuration owin)
4621 (set-window-point (get-buffer-window (current-buffer)) (point))))
4623 (defun gnus-article-summary-command-nosave ()
4624 "Execute the last keystroke in the summary buffer."
4627 (pop-to-buffer gnus-article-current-summary 'norecord)
4628 (setq func (lookup-key (current-local-map) (this-command-keys)))
4629 (call-interactively func)))
4631 (defun gnus-article-check-buffer ()
4632 "Beep if not in an article buffer."
4633 (unless (equal major-mode 'gnus-article-mode)
4634 (error "Command invoked outside of a Gnus article buffer")))
4636 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4637 "Read a summary buffer key sequence and execute it from the article buffer."
4639 (gnus-article-check-buffer)
4641 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4642 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4643 "=" "^" "\M-^" "|"))
4649 '("n" "Gn" "p" "Gp"))
4652 (set-buffer gnus-article-current-summary)
4653 (let (gnus-pick-mode)
4654 (push (or key last-command-event) unread-command-events)
4655 (setq keys (if (featurep 'xemacs)
4656 (events-to-keys (read-key-sequence nil))
4657 (read-key-sequence nil)))))
4661 (if (or (member keys nosaves)
4662 (member keys nosave-but-article)
4663 (member keys nosave-in-article))
4665 (save-window-excursion
4666 (pop-to-buffer gnus-article-current-summary 'norecord)
4667 ;; We disable the pick minor mode commands.
4668 (let (gnus-pick-mode)
4669 (setq func (lookup-key (current-local-map) keys))))
4673 (unless (member keys nosave-in-article)
4674 (set-buffer gnus-article-current-summary))
4675 (call-interactively func)
4676 (setq new-sum-point (point)))
4677 (when (member keys nosave-but-article)
4678 (pop-to-buffer gnus-article-buffer 'norecord)))
4679 ;; These commands should restore window configuration.
4680 (let ((obuf (current-buffer))
4681 (owin (current-window-configuration))
4683 (summary gnus-article-current-summary)
4684 func in-buffer selected)
4685 (if not-restore-window
4686 (pop-to-buffer summary 'norecord)
4687 (switch-to-buffer summary 'norecord))
4688 (setq in-buffer (current-buffer))
4689 ;; We disable the pick minor mode commands.
4690 (if (and (setq func (let (gnus-pick-mode)
4691 (lookup-key (current-local-map) keys)))
4694 (call-interactively func)
4695 (setq new-sum-point (point))
4696 (when (eq in-buffer (current-buffer))
4697 (setq selected (gnus-summary-select-article))
4699 (unless not-restore-window
4700 (set-window-configuration owin))
4701 (when (eq selected 'old)
4703 (set-window-start (get-buffer-window (current-buffer))
4705 (set-window-point (get-buffer-window (current-buffer))
4707 (let ((win (get-buffer-window gnus-article-current-summary)))
4709 (set-window-point win new-sum-point)))) )
4710 (switch-to-buffer gnus-article-buffer)
4713 (defun gnus-article-describe-key (key)
4714 "Display documentation of the function invoked by KEY. KEY is a string."
4715 (interactive "kDescribe key: ")
4716 (gnus-article-check-buffer)
4717 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4719 (set-buffer gnus-article-current-summary)
4720 (let (gnus-pick-mode)
4721 (if (featurep 'xemacs)
4723 (push (elt key 0) unread-command-events)
4724 (setq key (events-to-keys
4725 (read-key-sequence "Describe key: "))))
4726 (setq unread-command-events
4728 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4729 (string-to-list key)))
4730 (setq key (read-key-sequence "Describe key: "))))
4732 (describe-key key)))
4734 (defun gnus-article-describe-key-briefly (key &optional insert)
4735 "Display documentation of the function invoked by KEY. KEY is a string."
4736 (interactive "kDescribe key: \nP")
4737 (gnus-article-check-buffer)
4738 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4740 (set-buffer gnus-article-current-summary)
4741 (let (gnus-pick-mode)
4742 (if (featurep 'xemacs)
4744 (push (elt key 0) unread-command-events)
4745 (setq key (events-to-keys
4746 (read-key-sequence "Describe key: "))))
4747 (setq unread-command-events
4749 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4750 (string-to-list key)))
4751 (setq key (read-key-sequence "Describe key: "))))
4752 (describe-key-briefly key insert))
4753 (describe-key-briefly key insert)))
4755 (defun gnus-article-reply-with-original (&optional wide)
4756 "Start composing a reply mail to the current message.
4757 The text in the region will be yanked. If the region isn't active,
4758 the entire article will be yanked."
4760 (let ((article (cdr gnus-article-current)) cont)
4762 (gnus-summary-reply (list (list article)) wide)
4763 (setq cont (buffer-substring (point) (mark t)))
4764 ;; Deactivate active regions.
4765 (when (and (boundp 'transient-mark-mode)
4766 transient-mark-mode)
4767 (setq mark-active nil))
4769 (list (list article cont)) wide))))
4771 (defun gnus-article-followup-with-original ()
4772 "Compose a followup to the current article.
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))
4779 (gnus-summary-followup (list (list article)))
4780 (setq cont (buffer-substring (point) (mark t)))
4781 ;; Deactivate active regions.
4782 (when (and (boundp 'transient-mark-mode)
4783 transient-mark-mode)
4784 (setq mark-active nil))
4785 (gnus-summary-followup
4786 (list (list article cont))))))
4788 (defun gnus-article-hide (&optional arg force)
4789 "Hide all the gruft in the current article.
4790 This means that PGP stuff, signatures, cited text and (some)
4791 headers will be hidden.
4792 If given a prefix, show the hidden text instead."
4793 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4794 (gnus-article-hide-headers arg)
4795 (gnus-article-hide-list-identifiers arg)
4796 (gnus-article-hide-pgp arg)
4797 (gnus-article-hide-citation-maybe arg force)
4798 (gnus-article-hide-signature arg))
4800 (defun gnus-article-maybe-highlight ()
4801 "Do some article highlighting if article highlighting is requested."
4802 (when (gnus-visual-p 'article-highlight 'highlight)
4803 (gnus-article-highlight-some)))
4805 (defun gnus-check-group-server ()
4806 ;; Make sure the connection to the server is alive.
4807 (unless (gnus-server-opened
4808 (gnus-find-method-for-group gnus-newsgroup-name))
4809 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4810 (gnus-request-group gnus-newsgroup-name t)))
4813 (autoload 'nneething-get-file-name "nneething"))
4815 (defun gnus-request-article-this-buffer (article group)
4816 "Get an article and insert it into this buffer."
4817 (let (do-update-line sparse-header)
4821 (gnus-kill-all-overlays)
4822 (setq group (or group gnus-newsgroup-name))
4824 ;; Using `gnus-request-article' directly will insert the article into
4825 ;; `nntp-server-buffer' - so we'll save some time by not having to
4826 ;; copy it from the server buffer into the article buffer.
4828 ;; We only request an article by message-id when we do not have the
4829 ;; headers for it, so we'll have to get those.
4830 (when (stringp article)
4831 (gnus-read-header article))
4833 ;; If the article number is negative, that means that this article
4834 ;; doesn't belong in this newsgroup (possibly), so we find its
4835 ;; message-id and request it by id instead of number.
4836 (when (and (numberp article)
4838 (get-buffer gnus-summary-buffer)
4839 (gnus-buffer-exists-p gnus-summary-buffer))
4841 (set-buffer gnus-summary-buffer)
4842 (let ((header (gnus-summary-article-header article)))
4845 ((memq article gnus-newsgroup-sparse)
4846 ;; This is a sparse gap article.
4847 (setq do-update-line article)
4848 (setq article (mail-header-id header))
4849 (setq sparse-header (gnus-read-header article))
4850 (setq gnus-newsgroup-sparse
4851 (delq article gnus-newsgroup-sparse)))
4853 ;; It's a real article.
4854 (setq article (mail-header-id header)))
4856 ;; It is an extracted pseudo-article.
4857 (setq article 'pseudo)
4858 (gnus-request-pseudo-article header))))
4860 (let ((method (gnus-find-method-for-group
4861 gnus-newsgroup-name)))
4862 (when (and (eq (car method) 'nneething)
4864 (let ((dir (nneething-get-file-name
4865 (mail-header-id header))))
4866 (when (and (stringp dir)
4867 (file-directory-p dir))
4868 (setq article 'nneething)
4869 (gnus-group-enter-directory dir))))))))
4872 ;; Refuse to select canceled articles.
4873 ((and (numberp article)
4875 (get-buffer gnus-summary-buffer)
4876 (gnus-buffer-exists-p gnus-summary-buffer)
4877 (eq (cdr (save-excursion
4878 (set-buffer gnus-summary-buffer)
4879 (assq article gnus-newsgroup-reads)))
4880 gnus-canceled-mark))
4882 ;; We first check `gnus-original-article-buffer'.
4883 ((and (get-buffer gnus-original-article-buffer)
4886 (set-buffer gnus-original-article-buffer)
4887 (and (equal (car gnus-original-article) group)
4888 (eq (cdr gnus-original-article) article))))
4889 (insert-buffer-substring gnus-original-article-buffer)
4891 ;; Check the backlog.
4892 ((and gnus-keep-backlog
4893 (gnus-backlog-request-article group article (current-buffer)))
4895 ;; Check asynchronous pre-fetch.
4896 ((gnus-async-request-fetched-article group article (current-buffer))
4897 (gnus-async-prefetch-next group article gnus-summary-buffer)
4898 (when (and (numberp article) gnus-keep-backlog)
4899 (gnus-backlog-enter-article group article (current-buffer)))
4902 ((and gnus-use-cache
4904 (gnus-cache-request-article article group))
4906 ;; Check the agent cache.
4907 ((and gnus-agent gnus-agent-cache gnus-plugged
4909 (gnus-agent-request-article article group))
4911 ;; Get the article and put into the article buffer.
4912 ((or (stringp article)
4914 (let ((gnus-override-method gnus-override-method)
4915 (methods (and (stringp article)
4916 gnus-refer-article-method))
4918 (buffer-read-only nil))
4919 (if (or (not (listp methods))
4920 (and (symbolp (car methods))
4921 (assq (car methods) nnoo-definition-alist)))
4922 (setq methods (list methods)))
4923 (when (and (null gnus-override-method)
4925 (setq gnus-override-method (pop methods)))
4927 (when (eq gnus-override-method 'current)
4928 (setq gnus-override-method
4929 (with-current-buffer gnus-summary-buffer
4930 gnus-current-select-method)))
4932 (gnus-kill-all-overlays)
4933 (let ((gnus-newsgroup-name group))
4934 (gnus-check-group-server))
4935 (when (gnus-request-article article group (current-buffer))
4936 (when (numberp article)
4937 (gnus-async-prefetch-next group article
4938 gnus-summary-buffer)
4939 (when gnus-keep-backlog
4940 (gnus-backlog-enter-article
4941 group article (current-buffer))))
4942 (setq result 'article))
4945 (setq gnus-override-method (pop methods))
4946 (setq result 'done))))
4947 (and (eq result 'article) 'article)))
4951 ;; Associate this article with the current summary buffer.
4952 (setq gnus-article-current-summary gnus-summary-buffer)
4954 ;; Take the article from the original article buffer
4955 ;; and place it in the buffer it's supposed to be in.
4956 (when (and (get-buffer gnus-article-buffer)
4957 (equal (buffer-name (current-buffer))
4958 (buffer-name (get-buffer gnus-article-buffer))))
4960 (if (get-buffer gnus-original-article-buffer)
4961 (set-buffer gnus-original-article-buffer)
4962 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4963 (buffer-disable-undo)
4964 (setq major-mode 'gnus-original-article-mode)
4965 (setq buffer-read-only t))
4966 (let (buffer-read-only)
4968 (insert-buffer-substring gnus-article-buffer))
4969 (setq gnus-original-article (cons group article)))
4972 (run-hooks 'gnus-article-decode-hook)
4973 ;; Mark article as decoded or not.
4974 (setq gnus-article-decoded-p gnus-article-decode-hook))
4976 ;; Update sparse articles.
4977 (when (and do-update-line
4978 (or (numberp article)
4980 (let ((buf (current-buffer)))
4981 (set-buffer gnus-summary-buffer)
4982 (gnus-summary-update-article do-update-line sparse-header)
4983 (gnus-summary-goto-subject do-update-line nil t)
4984 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4986 (set-buffer buf))))))
4992 (defcustom gnus-article-edit-mode-hook nil
4993 "Hook run in article edit mode buffers."
4994 :group 'gnus-article-various
4997 (defvar gnus-article-edit-done-function nil)
4999 (defvar gnus-article-edit-mode-map nil)
5001 ;; Should we be using derived.el for this?
5002 (unless gnus-article-edit-mode-map
5003 (setq gnus-article-edit-mode-map (make-sparse-keymap))
5004 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5006 (gnus-define-keys gnus-article-edit-mode-map
5007 "\C-c\C-c" gnus-article-edit-done
5008 "\C-c\C-k" gnus-article-edit-exit)
5010 (gnus-define-keys (gnus-article-edit-wash-map
5011 "\C-c\C-w" gnus-article-edit-mode-map)
5012 "f" gnus-article-edit-full-stops))
5014 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5015 "Major mode for editing articles.
5016 This is an extended text-mode.
5018 \\{gnus-article-edit-mode-map}"
5019 (make-local-variable 'gnus-article-edit-done-function)
5020 (make-local-variable 'gnus-prev-winconf)
5021 (set (make-local-variable 'font-lock-defaults)
5022 '(message-font-lock-keywords t))
5023 (setq buffer-read-only nil)
5024 (buffer-enable-undo)
5027 (defun gnus-article-edit (&optional force)
5028 "Edit the current article.
5029 This will have permanent effect only in mail groups.
5030 If FORCE is non-nil, allow editing of articles even in read-only
5033 (when (and (not force)
5034 (gnus-group-read-only-p))
5035 (error "The current newsgroup does not support article editing"))
5036 (gnus-article-date-original)
5037 (gnus-article-edit-article
5039 `(lambda (no-highlight)
5041 (gnus-summary-edit-article-done
5042 ,(or (mail-header-references gnus-current-headers) "")
5043 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5045 (defun gnus-article-edit-article (start-func exit-func)
5046 "Start editing the contents of the current article buffer."
5047 (let ((winconf (current-window-configuration)))
5048 (set-buffer gnus-article-buffer)
5049 (gnus-article-edit-mode)
5050 (funcall start-func)
5051 (set-buffer-modified-p nil)
5052 (gnus-configure-windows 'edit-article)
5053 (setq gnus-article-edit-done-function exit-func)
5054 (setq gnus-prev-winconf winconf)
5055 (gnus-message 6 "C-c C-c to end edits")))
5057 (defun gnus-article-edit-done (&optional arg)
5058 "Update the article edits and exit."
5060 (let ((func gnus-article-edit-done-function)
5061 (buf (current-buffer))
5062 (start (window-start)))
5063 ;; We remove all text props from the article buffer.
5065 (buffer-substring-no-properties (point-min) (point-max)))
5069 (let ((winconf gnus-prev-winconf))
5071 (set-window-configuration winconf)
5072 ;; Tippy-toe some to make sure that point remains where it was.
5073 (save-current-buffer
5075 (set-window-start (get-buffer-window (current-buffer)) start)
5079 (let ((buffer-read-only nil))
5081 ;; The cache and backlog have to be flushed somewhat.
5082 (when gnus-keep-backlog
5083 (gnus-backlog-remove-article
5084 (car gnus-article-current) (cdr gnus-article-current)))
5085 ;; Flush original article as well.
5087 (when (get-buffer gnus-original-article-buffer)
5088 (set-buffer gnus-original-article-buffer)
5089 (setq gnus-original-article nil)))
5090 (when gnus-use-cache
5091 (gnus-cache-update-article
5092 (car gnus-article-current) (cdr gnus-article-current))))
5094 (set-window-start (get-buffer-window buf) start)
5095 (set-window-point (get-buffer-window buf) (point))))
5097 (defun gnus-article-edit-exit ()
5098 "Exit the article editing without updating."
5100 (when (or (not (buffer-modified-p))
5101 (yes-or-no-p "Article modified; kill anyway? "))
5102 (let ((curbuf (current-buffer))
5104 (window-start (window-start)))
5106 (if (gnus-buffer-live-p gnus-original-article-buffer)
5107 (insert-buffer gnus-original-article-buffer))
5108 (let ((winconf gnus-prev-winconf))
5110 (set-window-configuration winconf)
5111 ;; Tippy-toe some to make sure that point remains where it was.
5112 (save-current-buffer
5114 (set-window-start (get-buffer-window (current-buffer)) window-start)
5117 (defun gnus-article-edit-full-stops ()
5118 "Interactively repair spacing at end of sentences."
5121 (goto-char (point-min))
5122 (search-forward-regexp "^$" nil t)
5123 (let ((case-fold-search nil))
5124 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5127 ;;; Article highlights
5130 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5132 ;;; Internal Variables:
5134 (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\\)\\)"
5135 "Regular expression that matches URLs."
5136 :group 'gnus-article-buttons
5139 (defcustom gnus-button-alist
5140 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5141 0 t gnus-button-handle-news 3)
5142 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5143 gnus-button-handle-news 2)
5144 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5146 gnus-button-fetch-group 4)
5147 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5148 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5149 t gnus-button-message-id 3)
5150 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5151 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5152 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5154 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5155 gnus-button-handle-info 2)
5156 ;; This is how URLs _should_ be embedded in text...
5157 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5159 (,gnus-button-url-regexp 0 t browse-url 0))
5160 "*Alist of regexps matching buttons in article bodies.
5162 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5163 REGEXP: is the string matching text around the button,
5164 BUTTON: is the number of the regexp grouping actually matching the button,
5165 FORM: is a lisp expression which must eval to true for the button to
5167 CALLBACK: is the function to call when the user push this button, and each
5168 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5170 CALLBACK can also be a variable, in that case the value of that
5171 variable it the real callback function."
5172 :group 'gnus-article-buttons
5173 :type '(repeat (list regexp
5174 (integer :tag "Button")
5176 (function :tag "Callback")
5179 (integer :tag "Regexp group")))))
5181 (defcustom gnus-header-button-alist
5182 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5183 0 t gnus-button-message-id 0)
5184 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5185 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5186 0 t gnus-button-mailto 0)
5187 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5188 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5189 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5190 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5191 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5192 gnus-button-message-id 3))
5193 "*Alist of headers and regexps to match buttons in article heads.
5195 This alist is very similar to `gnus-button-alist', except that each
5196 alist has an additional HEADER element first in each entry:
5198 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5200 HEADER is a regexp to match a header. For a fuller explanation, see
5201 `gnus-button-alist'."
5202 :group 'gnus-article-buttons
5203 :group 'gnus-article-headers
5204 :type '(repeat (list (regexp :tag "Header")
5206 (integer :tag "Button")
5208 (function :tag "Callback")
5211 (integer :tag "Regexp group")))))
5213 (defvar gnus-button-regexp nil)
5214 (defvar gnus-button-marker-list nil)
5215 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5217 (defvar gnus-button-last nil)
5218 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5222 (defun gnus-article-push-button (event)
5223 "Check text under the mouse pointer for a callback function.
5224 If the text under the mouse pointer has a `gnus-callback' property,
5225 call it with the value of the `gnus-data' text property."
5227 (set-buffer (window-buffer (posn-window (event-start event))))
5228 (let* ((pos (posn-point (event-start event)))
5229 (data (get-text-property pos 'gnus-data))
5230 (fun (get-text-property pos 'gnus-callback)))
5233 (funcall fun data))))
5235 (defun gnus-article-press-button ()
5236 "Check text at point for a callback function.
5237 If the text at point has a `gnus-callback' property,
5238 call it with the value of the `gnus-data' text property."
5240 (let* ((data (get-text-property (point) 'gnus-data))
5241 (fun (get-text-property (point) 'gnus-callback)))
5243 (funcall fun data))))
5245 (defun gnus-article-highlight (&optional force)
5246 "Highlight current article.
5247 This function calls `gnus-article-highlight-headers',
5248 `gnus-article-highlight-citation',
5249 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5250 do the highlighting. See the documentation for those functions."
5251 (interactive (list 'force))
5252 (gnus-article-highlight-headers)
5253 (gnus-article-highlight-citation force)
5254 (gnus-article-highlight-signature)
5255 (gnus-article-add-buttons force)
5256 (gnus-article-add-buttons-to-head))
5258 (defun gnus-article-highlight-some (&optional force)
5259 "Highlight current article.
5260 This function calls `gnus-article-highlight-headers',
5261 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5262 do the highlighting. See the documentation for those functions."
5263 (interactive (list 'force))
5264 (gnus-article-highlight-headers)
5265 (gnus-article-highlight-signature)
5266 (gnus-article-add-buttons))
5268 (defun gnus-article-highlight-headers ()
5269 "Highlight article headers as specified by `gnus-header-face-alist'."
5272 (set-buffer gnus-article-buffer)
5274 (let ((alist gnus-header-face-alist)
5275 (buffer-read-only nil)
5276 (case-fold-search t)
5277 (inhibit-point-motion-hooks t)
5278 entry regexp header-face field-face from hpoints fpoints)
5279 (article-narrow-to-head)
5280 (while (setq entry (pop alist))
5281 (goto-char (point-min))
5282 (setq regexp (concat "^\\("
5283 (if (string-equal "" (nth 0 entry))
5287 header-face (nth 1 entry)
5288 field-face (nth 2 entry))
5289 (while (and (re-search-forward regexp nil t)
5293 (unless (search-forward ":" nil t)
5295 (when (and header-face
5296 (not (memq (point) hpoints)))
5297 (push (point) hpoints)
5298 (gnus-put-text-property from (point) 'face header-face))
5299 (when (and field-face
5300 (not (memq (setq from (point)) fpoints)))
5302 (if (re-search-forward "^[^ \t]" nil t)
5304 (goto-char (point-max)))
5305 (gnus-put-text-property from (point) 'face field-face))))))))
5307 (defun gnus-article-highlight-signature ()
5308 "Highlight the signature in an article.
5309 It does this by highlighting everything after
5310 `gnus-signature-separator' using `gnus-signature-face'."
5313 (set-buffer gnus-article-buffer)
5314 (let ((buffer-read-only nil)
5315 (inhibit-point-motion-hooks t))
5317 (when (and gnus-signature-face
5318 (gnus-article-narrow-to-signature))
5319 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5320 'face gnus-signature-face)
5322 (gnus-article-search-signature)
5323 (let ((start (match-beginning 0))
5324 (end (set-marker (make-marker) (1+ (match-end 0)))))
5325 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5328 (defun gnus-button-in-region-p (b e prop)
5329 "Say whether PROP exists in the region."
5330 (text-property-not-all b e prop nil))
5332 (defun gnus-article-add-buttons (&optional force)
5333 "Find external references in the article and make buttons of them.
5334 \"External references\" are things like Message-IDs and URLs, as
5335 specified by `gnus-button-alist'."
5336 (interactive (list 'force))
5338 (set-buffer gnus-article-buffer)
5339 (let ((buffer-read-only nil)
5340 (inhibit-point-motion-hooks t)
5341 (case-fold-search t)
5342 (alist gnus-button-alist)
5344 ;; Remove all old markers.
5345 (let (marker entry new-list)
5346 (while (setq marker (pop gnus-button-marker-list))
5347 (if (or (< marker (point-min)) (>= marker (point-max)))
5348 (push marker new-list)
5350 (when (setq entry (gnus-button-entry))
5351 (put-text-property (match-beginning (nth 1 entry))
5352 (match-end (nth 1 entry))
5353 'gnus-callback nil))
5354 (set-marker marker nil)))
5355 (setq gnus-button-marker-list new-list))
5356 ;; We skip the headers.
5359 (while (setq entry (pop alist))
5360 (setq regexp (car entry))
5362 (while (re-search-forward regexp nil t)
5363 (let* ((start (and entry (match-beginning (nth 1 entry))))
5364 (end (and entry (match-end (nth 1 entry))))
5365 (from (match-beginning 0)))
5366 (when (and (or (eq t (nth 2 entry))
5367 (eval (nth 2 entry)))
5368 (not (gnus-button-in-region-p
5369 start end 'gnus-callback)))
5370 ;; That optional form returned non-nil, so we add the
5372 (gnus-article-add-button
5373 start end 'gnus-button-push
5374 (car (push (set-marker (make-marker) from)
5375 gnus-button-marker-list))))))))))
5377 ;; Add buttons to the head of an article.
5378 (defun gnus-article-add-buttons-to-head ()
5379 "Add buttons to the head of the article."
5382 (set-buffer gnus-article-buffer)
5384 (let ((buffer-read-only nil)
5385 (inhibit-point-motion-hooks t)
5386 (case-fold-search t)
5387 (alist gnus-header-button-alist)
5389 (article-narrow-to-head)
5391 ;; Each alist entry.
5392 (setq entry (car alist)
5394 (goto-char (point-min))
5395 (while (re-search-forward (car entry) nil t)
5396 ;; Each header matching the entry.
5397 (setq beg (match-beginning 0))
5398 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5399 (match-beginning 0))
5402 (while (re-search-forward (nth 1 entry) end t)
5403 ;; Each match within a header.
5404 (let* ((entry (cdr entry))
5405 (start (match-beginning (nth 1 entry)))
5406 (end (match-end (nth 1 entry)))
5407 (form (nth 2 entry)))
5408 (goto-char (match-end 0))
5410 (gnus-article-add-button
5411 start end (nth 3 entry)
5412 (buffer-substring (match-beginning (nth 4 entry))
5413 (match-end (nth 4 entry)))))))
5414 (goto-char end)))))))
5416 ;;; External functions:
5418 (defun gnus-article-add-button (from to fun &optional data)
5419 "Create a button between FROM and TO with callback FUN and data DATA."
5420 (when gnus-article-button-face
5421 (gnus-overlay-put (gnus-make-overlay from to)
5422 'face gnus-article-button-face))
5423 (gnus-add-text-properties
5425 (nconc (and gnus-article-mouse-face
5426 (list gnus-mouse-face-prop gnus-article-mouse-face))
5427 (list 'gnus-callback fun)
5428 (and data (list 'gnus-data data))))
5429 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5430 :button-keymap gnus-widget-button-keymap))
5432 ;;; Internal functions:
5434 (defun gnus-article-set-globals ()
5436 (set-buffer gnus-summary-buffer)
5437 (gnus-set-global-variables)))
5439 (defun gnus-signature-toggle (end)
5441 (set-buffer gnus-article-buffer)
5442 (let ((buffer-read-only nil)
5443 (inhibit-point-motion-hooks t))
5444 (if (text-property-any end (point-max) 'article-type 'signature)
5446 (gnus-delete-wash-type 'signature)
5447 (gnus-remove-text-properties-when
5448 'article-type 'signature end (point-max)
5449 (cons 'article-type (cons 'signature
5450 gnus-hidden-properties))))
5451 (gnus-add-wash-type 'signature)
5452 (gnus-add-text-properties-when
5453 'article-type nil end (point-max)
5454 (cons 'article-type (cons 'signature
5455 gnus-hidden-properties)))))
5456 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5457 (gnus-set-mode-line 'article))))
5459 (defun gnus-button-entry ()
5460 ;; Return the first entry in `gnus-button-alist' matching this place.
5461 (let ((alist gnus-button-alist)
5464 (setq entry (pop alist))
5465 (if (looking-at (car entry))
5470 (defun gnus-button-push (marker)
5471 ;; Push button starting at MARKER.
5474 (let* ((entry (gnus-button-entry))
5475 (inhibit-point-motion-hooks t)
5477 (args (mapcar (lambda (group)
5478 (let ((string (match-string group)))
5479 (gnus-set-text-properties
5480 0 (length string) nil string)
5487 (fboundp (symbol-value fun)))
5488 (apply (symbol-value fun) args))
5490 (gnus-message 1 "You must define `%S' to use this button"
5491 (cons fun args)))))))
5493 (defun gnus-parse-news-url (url)
5494 (let (scheme server group message-id articles)
5497 (goto-char (point-min))
5498 (when (looking-at "\\([A-Za-z]+\\):")
5499 (setq scheme (match-string 1))
5500 (goto-char (match-end 0)))
5501 (when (looking-at "//\\([^/]+\\)/")
5502 (setq server (match-string 1))
5503 (goto-char (match-end 0)))
5506 ((looking-at "\\(.*@.*\\)")
5507 (setq message-id (match-string 1)))
5508 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5509 (setq group (match-string 1)
5510 articles (split-string (match-string 2) "-")))
5511 ((looking-at "\\([^/]+\\)/?")
5512 (setq group (match-string 1)))
5514 (error "Unknown news URL syntax"))))
5515 (list scheme server group message-id articles)))
5517 (defun gnus-button-handle-news (url)
5519 (destructuring-bind (scheme server group message-id articles)
5520 (gnus-parse-news-url url)
5524 (set-buffer gnus-summary-buffer)
5526 (let ((gnus-refer-article-method (list (list 'nntp server))))
5527 (gnus-summary-refer-article message-id))
5528 (gnus-summary-refer-article message-id))))
5530 (gnus-button-fetch-group url)))))
5532 (defun gnus-button-handle-info (url)
5533 "Fetch an info URL."
5535 "^\\([^:/]+\\)?/\\(.*\\)"
5537 (gnus-info-find-node
5538 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5541 (gnus-url-unhex-string (match-string 2 url))))
5542 (error "Can't parse %s" url)))
5544 (defun gnus-button-message-id (message-id)
5547 (set-buffer gnus-summary-buffer)
5548 (gnus-summary-refer-article message-id)))
5550 (defun gnus-button-fetch-group (address)
5551 "Fetch GROUP specified by ADDRESS."
5552 (if (not (string-match "[:/]" address))
5553 ;; This is just a simple group url.
5554 (gnus-group-read-ephemeral-group address gnus-select-method)
5557 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5559 (error "Can't parse %s" address)
5560 (gnus-group-read-ephemeral-group
5561 (match-string 4 address)
5562 `(nntp ,(match-string 1 address)
5563 (nntp-address ,(match-string 1 address))
5564 (nntp-port-number ,(if (match-end 3)
5565 (match-string 3 address)
5568 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5570 (defun gnus-url-parse-query-string (query &optional downcase)
5571 (let (retval pairs cur key val)
5572 (setq pairs (split-string query "&"))
5574 (setq cur (car pairs)
5576 (if (not (string-match "=" cur))
5578 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5579 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5581 (setq key (downcase key)))
5582 (setq cur (assoc key retval))
5584 (setcdr cur (cons val (cdr cur)))
5585 (setq retval (cons (list key val) retval)))))
5588 (defun gnus-url-mailto (url)
5589 ;; Send mail to someone
5590 (when (string-match "mailto:/*\\(.*\\)" url)
5591 (setq url (substring url (match-beginning 1) nil)))
5592 (let (to args subject func)
5593 (if (string-match (regexp-quote "?") url)
5594 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5595 args (gnus-url-parse-query-string
5596 (substring url (match-end 0) nil) t))
5597 (setq to (gnus-url-unhex-string url)))
5598 (setq args (cons (list "to" to) args)
5599 subject (cdr-safe (assoc "subject" args)))
5602 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5605 (message-position-on-field (caar args)))
5606 (insert (mapconcat 'identity (cdar args) ", "))
5607 (setq args (cdr args)))
5610 (message-goto-subject))))
5612 (defun gnus-button-embedded-url (address)
5613 "Activate ADDRESS with `browse-url'."
5614 (browse-url (gnus-strip-whitespace address)))
5616 ;;; Next/prev buttons in the article buffer.
5618 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5619 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5621 (defvar gnus-prev-page-map
5622 (let ((map (make-sparse-keymap)))
5623 (unless (>= emacs-major-version 21)
5624 ;; XEmacs doesn't care.
5625 (set-keymap-parent map gnus-article-mode-map))
5626 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5627 (define-key map "\r" 'gnus-button-prev-page)
5630 (defun gnus-insert-prev-page-button ()
5632 (buffer-read-only nil))
5634 gnus-prev-page-line-format nil
5635 `(,@(gnus-local-map-property gnus-prev-page-map)
5637 gnus-callback gnus-article-button-prev-page
5638 article-type annotation))
5639 (widget-convert-button
5641 :action 'gnus-button-prev-page
5642 :button-keymap gnus-prev-page-map)))
5644 (defvar gnus-prev-page-map
5645 (let ((map (make-sparse-keymap)))
5646 (unless (>= emacs-major-version 21)
5647 ;; XEmacs doesn't care.
5648 (set-keymap-parent map gnus-article-mode-map))
5649 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5650 (define-key map "\r" 'gnus-button-prev-page)
5653 (defvar gnus-next-page-map
5654 (let ((map (make-sparse-keymap)))
5655 (unless (>= emacs-major-version 21)
5656 ;; XEmacs doesn't care.
5657 (set-keymap-parent map gnus-article-mode-map))
5658 (define-key map gnus-mouse-2 'gnus-button-next-page)
5659 (define-key map "\r" 'gnus-button-next-page)
5662 (defun gnus-button-next-page (&optional args more-args)
5663 "Go to the next page."
5665 (let ((win (selected-window)))
5666 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5667 (gnus-article-next-page)
5668 (select-window win)))
5670 (defun gnus-button-prev-page (&optional args more-args)
5671 "Go to the prev page."
5673 (let ((win (selected-window)))
5674 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5675 (gnus-article-prev-page)
5676 (select-window win)))
5678 (defun gnus-insert-next-page-button ()
5680 (buffer-read-only nil))
5681 (gnus-eval-format gnus-next-page-line-format nil
5682 `(,@(gnus-local-map-property gnus-next-page-map)
5684 gnus-callback gnus-article-button-next-page
5685 article-type annotation))
5686 (widget-convert-button
5688 :action 'gnus-button-next-page
5689 :button-keymap gnus-next-page-map)))
5691 (defun gnus-article-button-next-page (arg)
5692 "Go to the next page."
5694 (let ((win (selected-window)))
5695 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5696 (gnus-article-next-page)
5697 (select-window win)))
5699 (defun gnus-article-button-prev-page (arg)
5700 "Go to the prev page."
5702 (let ((win (selected-window)))
5703 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5704 (gnus-article-prev-page)
5705 (select-window win)))
5707 (defvar gnus-decode-header-methods
5708 '(mail-decode-encoded-word-region)
5709 "List of methods used to decode headers.
5711 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5712 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5713 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5714 whose names match REGEXP.
5717 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5718 mail-decode-encoded-word-region
5719 (\"chinese\" . rfc1843-decode-region))
5722 (defvar gnus-decode-header-methods-cache nil)
5724 (defun gnus-multi-decode-header (start end)
5725 "Apply the functions from `gnus-encoded-word-methods' that match."
5726 (unless (and gnus-decode-header-methods-cache
5727 (eq gnus-newsgroup-name
5728 (car gnus-decode-header-methods-cache)))
5729 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5732 (nconc gnus-decode-header-methods-cache (list x))
5733 (if (and gnus-newsgroup-name
5734 (string-match (car x) gnus-newsgroup-name))
5735 (nconc gnus-decode-header-methods-cache
5737 gnus-decode-header-methods))
5738 (let ((xlist gnus-decode-header-methods-cache))
5741 (narrow-to-region start end)
5743 (funcall (pop xlist) (point-min) (point-max))))))
5746 ;;; Treatment top-level handling.
5749 (defun gnus-treat-article (condition &optional part-number total-parts type)
5750 (let ((length (- (point-max) (point-min)))
5751 (alist gnus-treatment-function-alist)
5752 (article-goto-body-goes-to-point-min-p t)
5756 (let ((list gnus-article-treat-types))
5758 (when (string-match (pop list) type)
5759 (throw 'found t)))))))
5760 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5762 (gnus-run-hooks 'gnus-part-display-hook)
5763 (while (setq elem (pop alist))
5766 (if (gnus-buffer-live-p gnus-summary-buffer)
5767 (set-buffer gnus-summary-buffer))
5768 (symbol-value (car elem))))
5769 (when (and (or (consp val)
5771 (gnus-treat-predicate val)
5772 (or (not (get (car elem) 'highlight))
5775 (funcall (cadr elem)))))))
5777 ;; Dynamic variables.
5779 (defvar part-number)
5780 (defvar total-parts)
5785 (defun gnus-treat-predicate (val)
5790 (stringp (car val)))
5791 (apply 'gnus-or (mapcar `(lambda (s)
5792 (string-match s ,(or gnus-newsgroup-name "")))
5795 (let ((pred (pop val)))
5798 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5800 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5802 (not (gnus-treat-predicate (car val))))
5804 (equal (car val) type))
5806 (error "%S is not a valid predicate" pred)))))
5814 (eq part-number total-parts))
5818 (error "%S is not a valid value" val))))
5820 (defun gnus-article-encrypt-body (protocol &optional n)
5821 "Encrypt the article body."
5824 (or gnus-article-encrypt-protocol
5825 (completing-read "Encrypt protocol: "
5826 gnus-article-encrypt-protocol-alist
5828 current-prefix-arg))
5829 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5831 (error (format "Can't find the encrypt protocol %s" protocol)))
5832 (if (equal gnus-newsgroup-name "nndraft:drafts")
5833 (error "Can't encrypt the article in group nndraft:drafts"))
5834 (if (equal gnus-newsgroup-name "nndraft:queue")
5835 (error "Don't encrypt the article in group nndraft:queue"))
5836 (gnus-summary-iterate n
5838 (set-buffer gnus-summary-buffer)
5839 (let ((mail-parse-charset gnus-newsgroup-charset)
5840 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5841 (summary-buffer gnus-summary-buffer)
5843 (gnus-set-global-variables)
5844 (when (gnus-group-read-only-p)
5845 (error "The current newsgroup does not support article encrypt"))
5846 (gnus-summary-show-article t)
5848 (or (mail-header-references gnus-current-headers) ""))
5849 (set-buffer gnus-article-buffer)
5850 (let* ((buffer-read-only nil)
5852 (mapcar (lambda (field)
5853 (and (save-restriction
5854 (message-narrow-to-head)
5855 (goto-char (point-min))
5856 (search-forward field nil t))
5858 (message-narrow-to-field)
5859 (buffer-substring (point-min) (point-max))
5860 (delete-region (point-min) (point-max))
5862 '("Content-Type:" "Content-Transfer-Encoding:"
5863 "Content-Disposition:"))))
5864 (message-narrow-to-head)
5865 (message-remove-header "MIME-Version")
5866 (goto-char (point-max))
5867 (setq point (point))
5868 (insert (apply 'concat headers))
5870 (narrow-to-region point (point-max))
5871 (let ((message-options message-options))
5872 (message-options-set 'message-sender user-mail-address)
5873 (message-options-set 'message-recipients user-mail-address)
5874 (message-options-set 'message-sign-encrypt 'not)
5876 (goto-char (point-min))
5877 (insert "MIME-Version: 1.0\n")
5879 (gnus-summary-edit-article-done
5880 references nil summary-buffer t))
5881 (when gnus-keep-backlog
5882 (gnus-backlog-remove-article
5883 (car gnus-article-current) (cdr gnus-article-current)))
5885 (when (get-buffer gnus-original-article-buffer)
5886 (set-buffer gnus-original-article-buffer)
5887 (setq gnus-original-article nil)))
5888 (when gnus-use-cache
5889 (gnus-cache-update-article
5890 (car gnus-article-current) (cdr gnus-article-current))))))))
5892 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5893 "The following specs can be used:
5894 %t The security MIME type
5897 %D Details if button is pressed")
5899 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5900 "The following specs can be used:
5901 %t The security MIME type
5904 %D Details if button is pressed")
5906 (defvar gnus-mime-security-button-line-format-alist
5907 '((?t gnus-tmp-type ?s)
5908 (?i gnus-tmp-info ?s)
5909 (?d gnus-tmp-details ?s)
5910 (?D gnus-tmp-pressed-details ?s)))
5912 (defvar gnus-mime-security-button-map
5913 (let ((map (make-sparse-keymap)))
5914 (unless (>= (string-to-number emacs-version) 21)
5915 (set-keymap-parent map gnus-article-mode-map))
5916 (define-key map gnus-mouse-2 'gnus-article-push-button)
5917 (define-key map "\r" 'gnus-article-press-button)
5920 (defvar gnus-mime-security-details-buffer nil)
5922 (defvar gnus-mime-security-button-pressed nil)
5924 (defvar gnus-mime-security-show-details-inline t
5925 "If non-nil, show details in the article buffer.")
5927 (defun gnus-mime-security-verify-or-decrypt (handle)
5928 (mm-remove-parts (cdr handle))
5929 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5930 point buffer-read-only)
5932 (goto-char (car region)))
5934 (narrow-to-region (point) (point))
5935 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5936 (let* ((mm-verify-option 'known)
5937 (mm-decrypt-option 'known)
5938 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5939 (unless (eq nparts (cdr handle))
5940 (mm-destroy-parts (cdr handle))
5941 (setcdr handle nparts))))
5942 (setq point (point))
5943 (gnus-mime-display-security handle)
5944 (goto-char (point-max)))
5946 (delete-region (point) (cdr region))
5947 (set-marker (car region) nil)
5948 (set-marker (cdr region) nil))
5951 (defun gnus-mime-security-show-details (handle)
5952 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5954 (if gnus-mime-security-show-details-inline
5955 (let ((gnus-mime-security-button-pressed t)
5956 (gnus-mime-security-button-line-format
5957 (get-text-property (point) 'gnus-line-format))
5960 (while (eq (get-text-property (point) 'gnus-line-format)
5961 gnus-mime-security-button-line-format)
5965 (narrow-to-region (point) (point))
5966 (gnus-insert-mime-security-button handle))
5967 (delete-region (point)
5968 (or (text-property-not-all
5971 gnus-mime-security-button-line-format)
5973 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5974 (with-current-buffer gnus-mime-security-details-buffer
5977 (setq gnus-mime-security-details-buffer
5978 (gnus-get-buffer-create "*MIME Security Details*")))
5979 (with-current-buffer gnus-mime-security-details-buffer
5981 (goto-char (point-min)))
5982 (pop-to-buffer gnus-mime-security-details-buffer))
5983 (gnus-message 5 "No details."))))
5985 (defun gnus-mime-security-press-button (handle)
5986 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5987 (gnus-mime-security-show-details handle)
5988 (gnus-mime-security-verify-or-decrypt handle)))
5990 (defun gnus-insert-mime-security-button (handle &optional displayed)
5991 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5994 (or (nth 2 (assoc protocol mm-verify-function-alist))
5995 (nth 2 (assoc protocol mm-decrypt-function-alist))
5997 (if (equal (car handle) "multipart/signed")
5998 " Signed" " Encrypted")
6001 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6004 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6005 gnus-tmp-pressed-details
6007 (setq gnus-tmp-details
6008 (if gnus-tmp-details
6009 (concat "\n" gnus-tmp-details) ""))
6010 (setq gnus-tmp-pressed-details
6011 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6016 gnus-mime-security-button-line-format
6017 gnus-mime-security-button-line-format-alist
6018 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6019 gnus-callback gnus-mime-security-press-button
6020 gnus-line-format ,gnus-mime-security-button-line-format
6021 article-type annotation
6024 (widget-convert-button
6027 :action 'gnus-widget-press-button
6028 :button-keymap gnus-mime-security-button-map
6030 (lambda (widget/window &optional overlay pos)
6031 ;; Needed to properly clear the message due to a bug in
6032 ;; wid-edit (XEmacs only).
6033 (if (boundp 'help-echo-owns-message)
6034 (setq help-echo-owns-message t))
6037 (aref gnus-mouse-2 0))))))
6039 (defun gnus-mime-display-security (handle)
6041 (narrow-to-region (point) (point))
6042 (unless (gnus-unbuttonized-mime-type-p (car handle))
6043 (gnus-insert-mime-security-button handle))
6044 (gnus-mime-display-mixed (cdr handle))
6047 (unless (gnus-unbuttonized-mime-type-p (car handle))
6048 (let ((gnus-mime-security-button-line-format
6049 gnus-mime-security-button-end-line-format))
6050 (gnus-insert-mime-security-button handle)))
6051 (mm-set-handle-multipart-parameter
6053 (cons (set-marker (make-marker) (point-min))
6054 (set-marker (make-marker) (point-max))))))
6060 (run-hooks 'gnus-art-load-hook)
6062 ;;; gnus-art.el ends here