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
243 ,(if (featurep 'xemacs)
244 'gnus-xmas-article-display-xface
245 'gnus-article-display-xface))
248 :group 'gnus-article-washing)
250 (defcustom gnus-article-x-face-too-ugly nil
251 "Regexp matching posters whose face shouldn't be shown automatically."
252 :type '(choice regexp (const nil))
253 :group 'gnus-article-washing)
255 (defcustom gnus-article-banner-alist nil
256 "Banner alist for stripping.
258 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
260 :type '(repeat (cons symbol regexp))
261 :group 'gnus-article-washing)
263 (gnus-define-group-parameter
266 "Alist of regexps (to match group names) and banner."
267 :variable-group gnus-article-washing
269 '(choice :tag "Banner"
271 (const :tag "Remove signature" signature)
272 (symbol :tag "Item in `gnus-article-banner-alist'" none)
274 (const :tag "None" nil))
276 "If non-nil, specify how to remove `banners' from articles.
278 Symbol `signature' means to remove signatures delimited by
279 `gnus-signature-separator'. Any other symbol is used to look up a
280 regular expression to match the banner in `gnus-article-banner-alist'.
281 A string is used as a regular expression to match the banner
284 (defcustom gnus-emphasis-alist
286 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
288 '(("_" "_" underline)
291 ("_/" "/_" underline-italic)
292 ("_\\*" "\\*_" underline-bold)
293 ("\\*/" "/\\*" bold-italic)
294 ("_\\*/" "/\\*_" underline-bold-italic))))
295 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
296 2 3 gnus-emphasis-underline)
300 (format format (car spec) (cadr spec))
301 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
303 "*Alist that says how to fontify certain phrases.
304 Each item looks like this:
306 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
308 The first element is a regular expression to be matched. The second
309 is a number that says what regular expression grouping used to find
310 the entire emphasized word. The third is a number that says what
311 regexp grouping should be displayed and highlighted. The fourth
312 is the face used for highlighting."
313 :type '(repeat (list :value ("" 0 0 default)
315 (integer :tag "Match group")
316 (integer :tag "Emphasize group")
318 :group 'gnus-article-emphasis)
320 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
321 "A regexp to describe whitespace which should not be emphasized.
322 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
323 The former avoids underlining of leading and trailing whitespace,
324 and the latter avoids underlining any whitespace at all."
326 :group 'gnus-article-emphasis
329 (defface gnus-emphasis-bold '((t (:bold t)))
330 "Face used for displaying strong emphasized text (*word*)."
331 :group 'gnus-article-emphasis)
333 (defface gnus-emphasis-italic '((t (:italic t)))
334 "Face used for displaying italic emphasized text (/word/)."
335 :group 'gnus-article-emphasis)
337 (defface gnus-emphasis-underline '((t (:underline t)))
338 "Face used for displaying underlined emphasized text (_word_)."
339 :group 'gnus-article-emphasis)
341 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
342 "Face used for displaying underlined bold emphasized text (_*word*_)."
343 :group 'gnus-article-emphasis)
345 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
346 "Face used for displaying underlined italic emphasized text (_/word/_)."
347 :group 'gnus-article-emphasis)
349 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
350 "Face used for displaying bold italic emphasized text (/*word*/)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-underline-bold-italic
354 '((t (:bold t :italic t :underline t)))
355 "Face used for displaying underlined bold italic emphasized text.
356 Esample: (_/*word*/_)."
357 :group 'gnus-article-emphasis)
359 (defface gnus-emphasis-highlight-words
360 '((t (:background "black" :foreground "yellow")))
361 "Face used for displaying highlighted words."
362 :group 'gnus-article-emphasis)
364 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
365 "Format for display of Date headers in article bodies.
366 See `format-time-string' for the possible values.
368 The variable can also be function, which should return a complete Date
369 header. The function is called with one argument, the time, which can
370 be fed to `format-time-string'."
371 :type '(choice string symbol)
372 :link '(custom-manual "(gnus)Article Date")
373 :group 'gnus-article-washing)
376 (autoload 'mail-extract-address-components "mail-extr"))
378 (defcustom gnus-save-all-headers t
379 "*If non-nil, don't remove any headers before saving."
380 :group 'gnus-article-saving
383 (defcustom gnus-prompt-before-saving 'always
384 "*This variable says how much prompting is to be done when saving articles.
385 If it is nil, no prompting will be done, and the articles will be
386 saved to the default files. If this variable is `always', each and
387 every article that is saved will be preceded by a prompt, even when
388 saving large batches of articles. If this variable is neither nil not
389 `always', there the user will be prompted once for a file name for
390 each invocation of the saving commands."
391 :group 'gnus-article-saving
392 :type '(choice (item always)
393 (item :tag "never" nil)
394 (sexp :tag "once" :format "%t\n" :value t)))
396 (defcustom gnus-saved-headers gnus-visible-headers
397 "Headers to keep if `gnus-save-all-headers' is nil.
398 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
399 If that variable is nil, however, all headers that match this regexp
400 will be kept while the rest will be deleted before saving."
401 :group 'gnus-article-saving
404 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
405 "A function to save articles in your favourite format.
406 The function must be interactively callable (in other words, it must
407 be an Emacs command).
409 Gnus provides the following functions:
411 * gnus-summary-save-in-rmail (Rmail format)
412 * gnus-summary-save-in-mail (Unix mail format)
413 * gnus-summary-save-in-folder (MH folder)
414 * gnus-summary-save-in-file (article format)
415 * gnus-summary-save-body-in-file (article body)
416 * gnus-summary-save-in-vm (use VM's folder format)
417 * gnus-summary-write-to-file (article format -- overwrite)."
418 :group 'gnus-article-saving
419 :type '(radio (function-item gnus-summary-save-in-rmail)
420 (function-item gnus-summary-save-in-mail)
421 (function-item gnus-summary-save-in-folder)
422 (function-item gnus-summary-save-in-file)
423 (function-item gnus-summary-save-body-in-file)
424 (function-item gnus-summary-save-in-vm)
425 (function-item gnus-summary-write-to-file)))
427 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
428 "A function generating a file name to save articles in Rmail format.
429 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
430 :group 'gnus-article-saving
433 (defcustom gnus-mail-save-name 'gnus-plain-save-name
434 "A function generating a file name to save articles in Unix mail format.
435 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
436 :group 'gnus-article-saving
439 (defcustom gnus-folder-save-name 'gnus-folder-save-name
440 "A function generating a file name to save articles in MH folder.
441 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
442 :group 'gnus-article-saving
445 (defcustom gnus-file-save-name 'gnus-numeric-save-name
446 "A function generating a file name to save articles in article format.
447 The function is called with NEWSGROUP, HEADERS, and optional
449 :group 'gnus-article-saving
452 (defcustom gnus-split-methods
453 '((gnus-article-archive-name)
454 (gnus-article-nndoc-name))
455 "*Variable used to suggest where articles are to be saved.
456 For instance, if you would like to save articles related to Gnus in
457 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
458 you could set this variable to something like:
460 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
461 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
463 This variable is an alist where the where the key is the match and the
464 value is a list of possible files to save in if the match is non-nil.
466 If the match is a string, it is used as a regexp match on the
467 article. If the match is a symbol, that symbol will be funcalled
468 from the buffer of the article to be saved with the newsgroup as the
469 parameter. If it is a list, it will be evaled in the same buffer.
471 If this form or function returns a string, this string will be used as
472 a possible file name; and if it returns a non-nil list, that list will
473 be used as possible file names."
474 :group 'gnus-article-saving
475 :type '(repeat (choice (list :value (fun) function)
476 (cons :value ("" "") regexp (repeat string))
479 (defcustom gnus-page-delimiter "^\^L"
480 "*Regexp describing what to use as article page delimiters.
481 The default value is \"^\^L\", which is a form linefeed at the
482 beginning of a line."
484 :group 'gnus-article-various)
486 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
487 "*The format specification for the article mode line.
488 See `gnus-summary-mode-line-format' for a closer description.
490 The following additional specs are available:
492 %w The article washing status.
493 %m The number of MIME parts in the article."
495 :group 'gnus-article-various)
497 (defcustom gnus-article-mode-hook nil
498 "*A hook for Gnus article mode."
500 :group 'gnus-article-various)
502 (when (featurep 'xemacs)
503 ;; Extracted from gnus-xmas-define in order to preserve user settings
504 (when (fboundp 'turn-off-scroll-in-place)
505 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
506 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
507 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
509 (defcustom gnus-article-menu-hook nil
510 "*Hook run after the creation of the article mode menu."
512 :group 'gnus-article-various)
514 (defcustom gnus-article-prepare-hook nil
515 "*A hook called after an article has been prepared in the article buffer."
517 :group 'gnus-article-various)
519 (defcustom gnus-article-hide-pgp-hook nil
520 "*A hook called after successfully hiding a PGP signature."
522 :group 'gnus-article-various)
524 (defcustom gnus-article-button-face 'bold
525 "Face used for highlighting buttons in the article buffer.
527 An article button is a piece of text that you can activate by pressing
528 `RET' or `mouse-2' above it."
530 :group 'gnus-article-buttons)
532 (defcustom gnus-article-mouse-face 'highlight
533 "Face used for mouse highlighting in the article buffer.
535 Article buttons will be displayed in this face when the cursor is
538 :group 'gnus-article-buttons)
540 (defcustom gnus-signature-face 'gnus-signature-face
541 "Face used for highlighting a signature in the article buffer.
542 Obsolete; use the face `gnus-signature-face' for customizations instead."
544 :group 'gnus-article-highlight
545 :group 'gnus-article-signature)
547 (defface gnus-signature-face
550 "Face used for highlighting a signature in the article buffer."
551 :group 'gnus-article-highlight
552 :group 'gnus-article-signature)
554 (defface gnus-header-from-face
557 (:foreground "spring green"))
560 (:foreground "red3"))
563 "Face used for displaying from headers."
564 :group 'gnus-article-headers
565 :group 'gnus-article-highlight)
567 (defface gnus-header-subject-face
570 (:foreground "SeaGreen3"))
573 (:foreground "red4"))
575 (:bold t :italic t)))
576 "Face used for displaying subject headers."
577 :group 'gnus-article-headers
578 :group 'gnus-article-highlight)
580 (defface gnus-header-newsgroups-face
583 (:foreground "yellow" :italic t))
586 (:foreground "MidnightBlue" :italic t))
589 "Face used for displaying newsgroups headers."
590 :group 'gnus-article-headers
591 :group 'gnus-article-highlight)
593 (defface gnus-header-name-face
596 (:foreground "SeaGreen"))
599 (:foreground "maroon"))
602 "Face used for displaying header names."
603 :group 'gnus-article-headers
604 :group 'gnus-article-highlight)
606 (defface gnus-header-content-face
609 (:foreground "forest green" :italic t))
612 (:foreground "indianred4" :italic t))
614 (:italic t))) "Face used for displaying header content."
615 :group 'gnus-article-headers
616 :group 'gnus-article-highlight)
618 (defcustom gnus-header-face-alist
619 '(("From" nil gnus-header-from-face)
620 ("Subject" nil gnus-header-subject-face)
621 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
622 ("" gnus-header-name-face gnus-header-content-face))
623 "*Controls highlighting of article header.
625 An alist of the form (HEADER NAME CONTENT).
627 HEADER is a regular expression which should match the name of an
628 header header and NAME and CONTENT are either face names or nil.
630 The name of each header field will be displayed using the face
631 specified by the first element in the list where HEADER match the
632 header name and NAME is non-nil. Similarly, the content will be
633 displayed by the first non-nil matching CONTENT face."
634 :group 'gnus-article-headers
635 :group 'gnus-article-highlight
636 :type '(repeat (list (regexp :tag "Header")
638 (item :tag "skip" nil)
639 (face :value default))
640 (choice :tag "Content"
641 (item :tag "skip" nil)
642 (face :value default)))))
644 (defcustom gnus-article-decode-hook
645 '(article-decode-charset article-decode-encoded-words
646 article-decode-group-name)
647 "*Hook run to decode charsets in articles."
648 :group 'gnus-article-headers
651 (defcustom gnus-display-mime-function 'gnus-display-mime
652 "Function to display MIME articles."
653 :group 'gnus-article-mime
656 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
657 "Function used to decode headers.")
659 (defvar gnus-article-dumbquotes-map
678 "Table for MS-to-Latin1 translation.")
680 (defcustom gnus-ignored-mime-types nil
681 "List of MIME types that should be ignored by Gnus."
683 :group 'gnus-article-mime
684 :type '(repeat regexp))
686 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
687 "List of MIME types that should not be given buttons when rendered inline.
688 See also `gnus-buttonized-mime-types' which may override this variable."
690 :group 'gnus-article-mime
691 :type '(repeat regexp))
693 (defcustom gnus-buttonized-mime-types nil
694 "List of MIME types that should be given buttons when rendered inline.
695 If set, this variable overrides `gnus-unbuttonized-mime-types'.
696 To see e.g. security buttons you could set this to
697 `(\"multipart/signed\")'."
699 :group 'gnus-article-mime
700 :type '(repeat regexp))
702 (defcustom gnus-body-boundary-delimiter "_"
703 "String used to delimit header and body.
704 This variable is used by `gnus-article-treat-body-boundary' which can
705 be controlled by `gnus-treat-body-boundary'."
706 :group 'gnus-article-various
707 :type '(choice (item :tag "None" :value nil)
710 (defcustom gnus-article-mime-part-function nil
711 "Function called with a MIME handle as the argument.
712 This is meant for people who want to do something automatic based
713 on parts -- for instance, adding Vcard info to a database."
714 :group 'gnus-article-mime
717 (defcustom gnus-mime-multipart-functions nil
718 "An alist of MIME types to functions to display them."
720 :group 'gnus-article-mime
723 (defcustom gnus-article-date-lapsed-new-header nil
724 "Whether the X-Sent and Date headers can coexist.
725 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
726 either replace the old \"Date:\" header (if this variable is nil), or
727 be added below it (otherwise)."
729 :group 'gnus-article-headers
732 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
733 "Function called with a MIME handle as the argument.
734 This is meant for people who want to view first matched part.
735 For `undisplayed-alternative' (default), the first undisplayed
736 part or alternative part is used. For `undisplayed', the first
737 undisplayed part is used. For a function, the first part which
738 the function return `t' is used. For `nil', the first part is
741 :group 'gnus-article-mime
743 (item :tag "first" :value nil)
744 (item :tag "undisplayed" :value undisplayed)
745 (item :tag "undisplayed or alternative"
746 :value undisplayed-alternative)
749 (defcustom gnus-mime-action-alist
750 '(("save to file" . gnus-mime-save-part)
751 ("save and strip" . gnus-mime-save-part-and-strip)
752 ("display as text" . gnus-mime-inline-part)
753 ("view the part" . gnus-mime-view-part)
754 ("pipe to command" . gnus-mime-pipe-part)
755 ("toggle display" . gnus-article-press-button)
756 ("toggle display" . gnus-article-view-part-as-charset)
757 ("view as type" . gnus-mime-view-part-as-type)
758 ("internalize type" . gnus-mime-internalize-part)
759 ("externalize type" . gnus-mime-externalize-part))
760 "An alist of actions that run on the MIME attachment."
761 :group 'gnus-article-mime
762 :type '(repeat (cons (string :tag "name")
765 (defcustom gnus-mime-action-alist
766 '(("save to file" . gnus-mime-save-part)
767 ("display as text" . gnus-mime-inline-part)
768 ("view the part" . gnus-mime-view-part)
769 ("pipe to command" . gnus-mime-pipe-part)
770 ("toggle display" . gnus-article-press-button)
771 ("view as type" . gnus-mime-view-part-as-type)
772 ("internalize type" . gnus-mime-internalize-part)
773 ("externalize type" . gnus-mime-externalize-part))
774 "An alist of actions that run on the MIME attachment."
776 :group 'gnus-article-mime
777 :type '(repeat (cons (string :tag "name")
781 ;;; The treatment variables
784 (defvar gnus-part-display-hook nil
785 "Hook called on parts that are to receive treatment.")
787 (defvar gnus-article-treat-custom
788 '(choice (const :tag "Off" nil)
790 (const :tag "Header" head)
791 (const :tag "Last" last)
792 (integer :tag "Less")
793 (repeat :tag "Groups" regexp)
794 (sexp :tag "Predicate")))
796 (defvar gnus-article-treat-head-custom
797 '(choice (const :tag "Off" nil)
798 (const :tag "Header" head)))
800 (defvar gnus-article-treat-types '("text/plain")
803 (defvar gnus-inhibit-treatment nil
804 "Whether to inhibit treatment.")
806 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
807 "Highlight the signature.
808 Valid values are nil, t, `head', `last', an integer or a predicate.
809 See Info node `(gnus)Customizing Articles'."
810 :group 'gnus-article-treat
811 :type gnus-article-treat-custom)
812 (put 'gnus-treat-highlight-signature 'highlight t)
814 (defcustom gnus-treat-buttonize 100000
816 Valid values are nil, t, `head', `last', an integer or a predicate.
817 See Info node `(gnus)Customizing Articles'."
818 :group 'gnus-article-treat
819 :type gnus-article-treat-custom)
820 (put 'gnus-treat-buttonize 'highlight t)
822 (defcustom gnus-treat-buttonize-head 'head
823 "Add buttons to the head.
824 Valid values are nil, t, `head', `last', an integer or a predicate.
825 See Info node `(gnus)Customizing Articles' for details."
826 :group 'gnus-article-treat
827 :type gnus-article-treat-head-custom)
828 (put 'gnus-treat-buttonize-head 'highlight t)
830 (defcustom gnus-treat-emphasize
831 (and (or window-system
833 (>= (string-to-number emacs-version) 21))
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-custom)
840 (put 'gnus-treat-emphasize 'highlight t)
842 (defcustom gnus-treat-strip-cr nil
843 "Remove carriage returns.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles' for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
849 (defcustom gnus-treat-leading-whitespace nil
850 "Remove leading whitespace in headers.
851 Valid values are nil, t, `head', `last', an integer or a predicate.
852 See Info node `(gnus)Customizing Articles' for details."
853 :group 'gnus-article-treat
854 :type gnus-article-treat-custom)
856 (defcustom gnus-treat-hide-headers 'head
858 Valid values are nil, t, `head', `last', an integer or a predicate.
859 See Info node `(gnus)Customizing Articles' for details."
860 :group 'gnus-article-treat
861 :type gnus-article-treat-head-custom)
863 (defcustom gnus-treat-hide-boring-headers nil
864 "Hide boring headers.
865 Valid values are nil, t, `head', `last', an integer or a predicate.
866 See Info node `(gnus)Customizing Articles' for details."
867 :group 'gnus-article-treat
868 :type gnus-article-treat-head-custom)
870 (defcustom gnus-treat-hide-signature nil
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See Info node `(gnus)Customizing Articles' for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-fill-article nil
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles' for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-hide-citation nil
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See Info node `(gnus)Customizing Articles' for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 (defcustom gnus-treat-hide-citation-maybe nil
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles' for details."
895 :group 'gnus-article-treat
896 :type gnus-article-treat-custom)
898 (defcustom gnus-treat-strip-list-identifiers 'head
899 "Strip list identifiers from `gnus-list-identifiers`.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-strip-pgp t
907 "Strip PGP signatures.
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See Info node `(gnus)Customizing Articles' for details."
910 :group 'gnus-article-treat
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-strip-pem nil
914 "Strip PEM signatures.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See Info node `(gnus)Customizing Articles' for details."
917 :group 'gnus-article-treat
918 :type gnus-article-treat-custom)
920 (defcustom gnus-treat-strip-banner t
921 "Strip banners from articles.
922 The banner to be stripped is specified in the `banner' group parameter.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :type gnus-article-treat-custom)
928 (defcustom gnus-treat-highlight-headers 'head
929 "Highlight the headers.
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See Info node `(gnus)Customizing Articles' for details."
932 :group 'gnus-article-treat
933 :type gnus-article-treat-head-custom)
934 (put 'gnus-treat-highlight-headers 'highlight t)
936 (defcustom gnus-treat-highlight-citation t
937 "Highlight cited text.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :type gnus-article-treat-custom)
942 (put 'gnus-treat-highlight-citation 'highlight t)
944 (defcustom gnus-treat-date-ut nil
945 "Display the Date in UT (GMT).
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles' for details."
948 :group 'gnus-article-treat
949 :type gnus-article-treat-head-custom)
951 (defcustom gnus-treat-date-local nil
952 "Display the Date in the local timezone.
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See Info node `(gnus)Customizing Articles' for details."
955 :group 'gnus-article-treat
956 :type gnus-article-treat-head-custom)
958 (defcustom gnus-treat-date-english nil
959 "Display the Date in a format that can be read aloud in English.
960 Valid values are nil, t, `head', `last', an integer or a predicate.
961 See Info node `(gnus)Customizing Articles' for details."
962 :group 'gnus-article-treat
963 :type gnus-article-treat-head-custom)
965 (defcustom gnus-treat-date-lapsed nil
966 "Display the Date header in a way that says how much time has elapsed.
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles' for details."
969 :group 'gnus-article-treat
970 :type gnus-article-treat-head-custom)
972 (defcustom gnus-treat-date-original nil
973 "Display the date in the original timezone.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :type gnus-article-treat-head-custom)
979 (defcustom gnus-treat-date-iso8601 nil
980 "Display the date in the ISO8601 format.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :type gnus-article-treat-head-custom)
987 (defcustom gnus-treat-date-user-defined nil
988 "Display the date in a user-defined format.
989 The format is defined by the `gnus-article-time-format' variable.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :type gnus-article-treat-head-custom)
995 (defcustom gnus-treat-strip-headers-in-body t
996 "Strip the X-No-Archive header line from the beginning of the body.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :type gnus-article-treat-custom)
1003 (defcustom gnus-treat-strip-trailing-blank-lines nil
1004 "Strip trailing blank lines.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles' for details."
1007 :group 'gnus-article-treat
1008 :type gnus-article-treat-custom)
1010 (defcustom gnus-treat-strip-leading-blank-lines nil
1011 "Strip leading blank lines.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :type gnus-article-treat-custom)
1017 (defcustom gnus-treat-strip-multiple-blank-lines nil
1018 "Strip multiple blank lines.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :type gnus-article-treat-custom)
1024 (defcustom gnus-treat-unfold-headers 'head
1025 "Unfold folded header lines.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :type gnus-article-treat-custom)
1031 (defcustom gnus-treat-fold-headers nil
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-fold-newsgroups 'head
1039 "Fold the Newsgroups and Followup-To headers.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-overstrike t
1046 "Treat overstrike highlighting.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :type gnus-article-treat-custom)
1051 (put 'gnus-treat-overstrike 'highlight t)
1053 (defcustom gnus-treat-display-xface
1054 (and (or (and (fboundp 'image-type-available-p)
1055 (image-type-available-p 'xbm)
1056 (string-match "^0x" (shell-command-to-string "uncompface")))
1057 (and (featurep 'xemacs)
1060 "Display X-Face headers.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' and Info node
1063 `(gnus)X-Face' for details."
1064 :group 'gnus-article-treat
1066 :type gnus-article-treat-head-custom)
1067 (put 'gnus-treat-display-xface 'highlight t)
1069 (defcustom gnus-treat-display-smileys
1070 (if (or (and (featurep 'xemacs)
1072 (and (fboundp 'image-type-available-p)
1073 (image-type-available-p 'pbm)))
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' and Info node
1078 `(gnus)Smileys' for details."
1079 :group 'gnus-article-treat
1081 :type gnus-article-treat-custom)
1082 (put 'gnus-treat-display-smileys 'highlight t)
1084 (defcustom gnus-treat-from-picon
1085 (if (gnus-image-type-available-p 'xpm)
1087 "Display picons in the From header.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' and Info node
1090 `(gnus)Picons' for details."
1091 :group 'gnus-article-treat
1092 :type gnus-article-treat-head-custom)
1093 (put 'gnus-treat-from-picon 'highlight t)
1095 (defcustom gnus-treat-mail-picon
1096 (if (gnus-image-type-available-p 'xpm)
1098 "Display picons in To and Cc headers.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' and Info node
1101 `(gnus)Picons' for details."
1102 :group 'gnus-article-treat
1103 :type gnus-article-treat-head-custom)
1104 (put 'gnus-treat-mail-picon 'highlight t)
1106 (defcustom gnus-treat-newsgroups-picon
1107 (if (gnus-image-type-available-p 'xpm)
1109 "Display picons in the Newsgroups and Followup-To headers.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' and Info node
1112 `(gnus)Picons' for details."
1113 :group 'gnus-article-treat
1114 :type gnus-article-treat-head-custom)
1115 (put 'gnus-treat-newsgroups-picon 'highlight t)
1117 (defcustom gnus-treat-body-boundary
1118 (if (or gnus-treat-newsgroups-picon
1119 gnus-treat-mail-picon
1120 gnus-treat-from-picon)
1122 "Draw a boundary at the end of the headers.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :type gnus-article-treat-custom)
1129 (defcustom gnus-treat-capitalize-sentences nil
1130 "Capitalize sentence-starting words.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :type gnus-article-treat-custom)
1137 (defcustom gnus-treat-fill-long-lines nil
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :type gnus-article-treat-custom)
1144 (defcustom gnus-treat-play-sounds nil
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1149 :group 'gnus-article-treat
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-translate nil
1153 "Translate articles from one language to another.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1157 :group 'gnus-article-treat
1158 :type gnus-article-treat-custom)
1160 (defcustom gnus-treat-x-pgp-sig nil
1162 To automatically treat X-PGP-Sig, set it to head.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' for details."
1165 :group 'gnus-article-treat
1166 :group 'mime-security
1167 :type gnus-article-treat-custom)
1169 (defvar gnus-article-encrypt-protocol-alist
1170 '(("PGP" . mml2015-self-encrypt)))
1172 ;; Set to nil if more than one protocol added to
1173 ;; gnus-article-encrypt-protocol-alist.
1174 (defcustom gnus-article-encrypt-protocol "PGP"
1175 "The protocol used for encrypt articles.
1176 It is a string, such as \"PGP\". If nil, ask user."
1178 :group 'mime-security)
1180 ;;; Internal variables
1182 (defvar gnus-english-month-names
1183 '("January" "February" "March" "April" "May" "June" "July" "August"
1184 "September" "October" "November" "December"))
1186 (defvar article-goto-body-goes-to-point-min-p nil)
1187 (defvar gnus-article-wash-types nil)
1188 (defvar gnus-article-emphasis-alist nil)
1189 (defvar gnus-article-image-alist nil)
1191 (defvar gnus-article-mime-handle-alist-1 nil)
1192 (defvar gnus-treatment-function-alist
1193 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1194 (gnus-treat-strip-banner gnus-article-strip-banner)
1195 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1196 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1197 (gnus-treat-buttonize gnus-article-add-buttons)
1198 (gnus-treat-fill-article gnus-article-fill-cited-article)
1199 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1200 (gnus-treat-strip-cr gnus-article-remove-cr)
1201 (gnus-treat-date-ut gnus-article-date-ut)
1202 (gnus-treat-date-local gnus-article-date-local)
1203 (gnus-treat-date-english gnus-article-date-english)
1204 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1205 (gnus-treat-date-original gnus-article-date-original)
1206 (gnus-treat-date-user-defined gnus-article-date-user)
1207 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1208 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1209 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1210 (gnus-treat-hide-signature gnus-article-hide-signature)
1211 (gnus-treat-hide-citation gnus-article-hide-citation)
1212 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1213 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1214 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1215 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1216 (gnus-treat-strip-pem gnus-article-hide-pem)
1217 (gnus-treat-from-picon gnus-treat-from-picon)
1218 (gnus-treat-mail-picon gnus-treat-mail-picon)
1219 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1220 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1221 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1222 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1223 (gnus-treat-strip-trailing-blank-lines
1224 gnus-article-remove-trailing-blank-lines)
1225 (gnus-treat-strip-leading-blank-lines
1226 gnus-article-strip-leading-blank-lines)
1227 (gnus-treat-strip-multiple-blank-lines
1228 gnus-article-strip-multiple-blank-lines)
1229 (gnus-treat-overstrike gnus-article-treat-overstrike)
1230 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1231 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1232 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1233 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1234 (gnus-treat-display-smileys gnus-treat-smiley)
1235 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1236 (gnus-treat-emphasize gnus-article-emphasize)
1237 (gnus-treat-display-xface gnus-article-display-x-face)
1238 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1239 (gnus-treat-play-sounds gnus-earcon-display)))
1241 (defvar gnus-article-mime-handle-alist nil)
1242 (defvar article-lapsed-timer nil)
1243 (defvar gnus-article-current-summary nil)
1245 (defvar gnus-article-mode-syntax-table
1246 (let ((table (copy-syntax-table text-mode-syntax-table)))
1247 ;; This causes the citation match run O(2^n).
1248 ;; (modify-syntax-entry ?- "w" table)
1249 (modify-syntax-entry ?> ")" table)
1250 (modify-syntax-entry ?< "(" table)
1252 "Syntax table used in article mode buffers.
1253 Initialized from `text-mode-syntax-table.")
1255 (defvar gnus-save-article-buffer nil)
1257 (defvar gnus-article-mode-line-format-alist
1258 (nconc '((?w (gnus-article-wash-status) ?s)
1259 (?m (gnus-article-mime-part-status) ?s))
1260 gnus-summary-mode-line-format-alist))
1262 (defvar gnus-number-of-articles-to-be-saved nil)
1264 (defvar gnus-inhibit-hiding nil)
1266 ;;; Macros for dealing with the article buffer.
1268 (defmacro gnus-with-article-headers (&rest forms)
1270 (set-buffer gnus-article-buffer)
1272 (let ((buffer-read-only nil)
1273 (inhibit-point-motion-hooks t)
1274 (case-fold-search t))
1275 (article-narrow-to-head)
1278 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1279 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1281 (defmacro gnus-with-article-buffer (&rest forms)
1283 (set-buffer gnus-article-buffer)
1284 (let ((buffer-read-only nil))
1287 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1288 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1290 (defun gnus-article-goto-header (header)
1291 "Go to HEADER, which is a regular expression."
1292 (re-search-forward (concat "^\\(" header "\\):") nil t))
1294 (defsubst gnus-article-hide-text (b e props)
1295 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1296 (gnus-add-text-properties-when 'article-type nil b e props)
1297 (when (memq 'intangible props)
1299 (max (1- b) (point-min))
1300 b 'intangible (cddr (memq 'intangible props)))))
1302 (defsubst gnus-article-unhide-text (b e)
1303 "Remove hidden text properties from region between B and E."
1304 (remove-text-properties b e gnus-hidden-properties)
1305 (when (memq 'intangible gnus-hidden-properties)
1306 (put-text-property (max (1- b) (point-min))
1307 b 'intangible nil)))
1309 (defun gnus-article-hide-text-type (b e type)
1310 "Hide text of TYPE between B and E."
1311 (gnus-add-wash-type type)
1312 (gnus-article-hide-text
1313 b e (cons 'article-type (cons type gnus-hidden-properties))))
1315 (defun gnus-article-unhide-text-type (b e type)
1316 "Unhide text of TYPE between B and E."
1317 (gnus-delete-wash-type type)
1318 (remove-text-properties
1319 b e (cons 'article-type (cons type gnus-hidden-properties)))
1320 (when (memq 'intangible gnus-hidden-properties)
1321 (put-text-property (max (1- b) (point-min))
1322 b 'intangible nil)))
1324 (defun gnus-article-hide-text-of-type (type)
1325 "Hide text of TYPE in the current buffer."
1327 (let ((b (point-min))
1329 (while (setq b (text-property-any b e 'article-type type))
1330 (add-text-properties b (incf b) gnus-hidden-properties)))))
1332 (defun gnus-article-delete-text-of-type (type)
1333 "Delete text of TYPE in the current buffer."
1335 (let ((b (point-min)))
1336 (while (setq b (text-property-any b (point-max) 'article-type type))
1338 b (or (text-property-not-all b (point-max) 'article-type type)
1341 (defun gnus-article-delete-invisible-text ()
1342 "Delete all invisible text in the current buffer."
1344 (let ((b (point-min)))
1345 (while (setq b (text-property-any b (point-max) 'invisible t))
1347 b (or (text-property-not-all b (point-max) 'invisible t)
1350 (defun gnus-article-text-type-exists-p (type)
1351 "Say whether any text of type TYPE exists in the buffer."
1352 (text-property-any (point-min) (point-max) 'article-type type))
1354 (defsubst gnus-article-header-rank ()
1355 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1356 (let ((list gnus-sorted-header-list)
1359 (when (looking-at (car list))
1361 (setq list (cdr list))
1365 (defun article-hide-headers (&optional arg delete)
1366 "Hide unwanted headers and possibly sort them as well."
1368 ;; This function might be inhibited.
1369 (unless gnus-inhibit-hiding
1372 (let ((buffer-read-only nil)
1373 (case-fold-search t)
1374 (max (1+ (length gnus-sorted-header-list)))
1375 (ignored (when (not gnus-visible-headers)
1376 (cond ((stringp gnus-ignored-headers)
1377 gnus-ignored-headers)
1378 ((listp gnus-ignored-headers)
1379 (mapconcat 'identity gnus-ignored-headers
1382 (cond ((stringp gnus-visible-headers)
1383 gnus-visible-headers)
1384 ((and gnus-visible-headers
1385 (listp gnus-visible-headers))
1386 (mapconcat 'identity gnus-visible-headers "\\|"))))
1387 (inhibit-point-motion-hooks t)
1389 ;; First we narrow to just the headers.
1390 (article-narrow-to-head)
1391 ;; Hide any "From " lines at the beginning of (mail) articles.
1392 (while (looking-at "From ")
1395 (delete-region (point-min) (point)))
1396 ;; Then treat the rest of the header lines.
1397 ;; Then we use the two regular expressions
1398 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1399 ;; select which header lines is to remain visible in the
1401 (while (re-search-forward "^[^ \t:]*:" nil t)
1403 ;; Mark the rank of the header.
1405 (point) (1+ (point)) 'message-rank
1406 (if (or (and visible (looking-at visible))
1408 (not (looking-at ignored))))
1409 (gnus-article-header-rank)
1412 (message-sort-headers-1)
1413 (when (setq beg (text-property-any
1414 (point-min) (point-max) 'message-rank (+ 2 max)))
1415 ;; We delete the unwanted headers.
1416 (gnus-add-wash-type 'headers)
1417 (add-text-properties (point-min) (+ 5 (point-min))
1418 '(article-type headers dummy-invisible t))
1419 (delete-region beg (point-max))))))))
1421 (defun article-hide-boring-headers (&optional arg)
1422 "Toggle hiding of headers that aren't very interesting.
1423 If given a negative prefix, always show; if given a positive prefix,
1425 (interactive (gnus-article-hidden-arg))
1426 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1427 (not gnus-show-all-headers))
1430 (let ((buffer-read-only nil)
1431 (list gnus-boring-article-headers)
1432 (inhibit-point-motion-hooks t)
1434 (article-narrow-to-head)
1436 (setq elem (pop list))
1437 (goto-char (point-min))
1439 ;; Hide empty headers.
1441 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1443 (gnus-article-hide-text-type
1444 (progn (beginning-of-line) (point))
1447 (if (re-search-forward "^[^ \t]" nil t)
1451 ;; Hide boring Newsgroups header.
1452 ((eq elem 'newsgroups)
1453 (when (gnus-string-equal
1454 (gnus-fetch-field "newsgroups")
1455 (gnus-group-real-name
1456 (if (boundp 'gnus-newsgroup-name)
1459 (gnus-article-hide-header "newsgroups")))
1460 ((eq elem 'to-address)
1461 (let ((to (message-fetch-field "to"))
1463 (gnus-parameter-to-address
1464 (if (boundp 'gnus-newsgroup-name)
1465 gnus-newsgroup-name ""))))
1466 (when (and to to-address
1469 ;; only one address in To
1470 (nth 1 (mail-extract-address-components to))
1472 (gnus-article-hide-header "to"))))
1473 ((eq elem 'followup-to)
1474 (when (gnus-string-equal
1475 (message-fetch-field "followup-to")
1476 (message-fetch-field "newsgroups"))
1477 (gnus-article-hide-header "followup-to")))
1478 ((eq elem 'reply-to)
1479 (let ((from (message-fetch-field "from"))
1480 (reply-to (message-fetch-field "reply-to")))
1485 (nth 1 (mail-extract-address-components from))
1486 (nth 1 (mail-extract-address-components reply-to)))))
1487 (gnus-article-hide-header "reply-to"))))
1489 (let ((date (message-fetch-field "date")))
1491 (< (days-between (current-time-string) date)
1493 (gnus-article-hide-header "date"))))
1495 (let ((to (message-fetch-field "to"))
1496 (cc (message-fetch-field "cc")))
1497 (when (> (length to) 1024)
1498 (gnus-article-hide-header "to"))
1499 (when (> (length cc) 1024)
1500 (gnus-article-hide-header "cc"))))
1504 (goto-char (point-min))
1505 (while (re-search-forward "^to:" nil t)
1506 (setq to-count (1+ to-count)))
1507 (when (> to-count 1)
1508 (while (> to-count 0)
1509 (goto-char (point-min))
1511 (re-search-forward "^to:" nil nil to-count)
1513 (narrow-to-region (point) (point-max))
1514 (gnus-article-hide-header "to"))
1515 (setq to-count (1- to-count))))
1516 (goto-char (point-min))
1517 (while (re-search-forward "^cc:" nil t)
1518 (setq cc-count (1+ cc-count)))
1519 (when (> cc-count 1)
1520 (while (> cc-count 0)
1521 (goto-char (point-min))
1523 (re-search-forward "^cc:" nil nil cc-count)
1525 (narrow-to-region (point) (point-max))
1526 (gnus-article-hide-header "cc"))
1527 (setq cc-count (1- cc-count)))))))))))))
1529 (defun gnus-article-hide-header (header)
1531 (goto-char (point-min))
1532 (when (re-search-forward (concat "^" header ":") nil t)
1533 (gnus-article-hide-text-type
1534 (progn (beginning-of-line) (point))
1537 (if (re-search-forward "^[^ \t]" nil t)
1542 (defvar gnus-article-normalized-header-length 40
1543 "Length of normalized headers.")
1545 (defun article-normalize-headers ()
1546 "Make all header lines 40 characters long."
1548 (let ((buffer-read-only nil)
1552 (article-narrow-to-head)
1555 ((< (setq column (- (gnus-point-at-eol) (point)))
1556 gnus-article-normalized-header-length)
1558 (insert (make-string
1559 (- gnus-article-normalized-header-length column)
1561 ((> column gnus-article-normalized-header-length)
1562 (gnus-put-text-property
1564 (forward-char gnus-article-normalized-header-length)
1571 (forward-line 1))))))
1573 (defun article-treat-dumbquotes ()
1574 "Translate M****s*** sm*rtq**t*s into proper text.
1575 Note that this function guesses whether a character is a sm*rtq**t* or
1576 not, so it should only be used interactively.
1578 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1579 in an attempt to provide more quoting characters. If you see
1580 something like \\222 or \\264 where you're expecting some kind of
1581 apostrophe or quotation mark, then try this wash."
1583 (article-translate-strings gnus-article-dumbquotes-map))
1585 (defun article-translate-characters (from to)
1586 "Translate all characters in the body of the article according to FROM and TO.
1587 FROM is a string of characters to translate from; to is a string of
1588 characters to translate to."
1590 (when (article-goto-body)
1591 (let ((buffer-read-only nil)
1592 (x (make-string 225 ?x))
1594 (while (< (incf i) (length x))
1597 (while (< i (length from))
1598 (aset x (aref from i) (aref to i))
1600 (translate-region (point) (point-max) x)))))
1602 (defun article-translate-strings (map)
1603 "Translate all string in the body of the article according to MAP.
1604 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1606 (when (article-goto-body)
1607 (let ((buffer-read-only nil)
1609 (while (setq elem (pop map))
1611 (while (search-forward (car elem) nil t)
1612 (replace-match (cadr elem)))))))))
1614 (defun article-treat-overstrike ()
1615 "Translate overstrikes into bold text."
1618 (when (article-goto-body)
1619 (let ((buffer-read-only nil))
1620 (while (search-forward "\b" nil t)
1621 (let ((next (char-after))
1622 (previous (char-after (- (point) 2))))
1623 ;; We do the boldification/underlining by hiding the
1624 ;; overstrikes and putting the proper text property
1628 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1629 (put-text-property (point) (1+ (point)) 'face 'bold))
1631 (gnus-article-hide-text-type
1632 (1- (point)) (1+ (point)) 'overstrike)
1634 (- (point) 2) (1- (point)) 'face 'underline))
1636 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1638 (point) (1+ (point)) 'face 'underline)))))))))
1640 (defun gnus-article-treat-unfold-headers ()
1641 "Unfold folded message headers.
1642 Only the headers that fit into the current window width will be
1645 (gnus-with-article-headers
1649 (mail-header-narrow-to-field)
1650 (let ((header (buffer-substring (point-min) (point-max))))
1653 (goto-char (point-min))
1654 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1655 (replace-match " " t t)))
1656 (setq length (- (point-max) (point-min) 1)))
1657 (when (< length (window-width))
1658 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1659 (replace-match " " t t)))
1660 (goto-char (point-max)))))))
1662 (defun gnus-article-treat-fold-headers ()
1663 "Fold message headers."
1665 (gnus-with-article-headers
1668 (mail-header-narrow-to-field)
1669 (mail-header-fold-field)
1670 (goto-char (point-max))))))
1672 (defun gnus-treat-smiley ()
1673 "Display textual emoticons (\"smileys\") as small graphical icons."
1675 (gnus-with-article-buffer
1676 (if (memq 'smiley gnus-article-wash-types)
1677 (gnus-delete-images 'smiley)
1679 (let ((images (smiley-region (point) (point-max))))
1681 (gnus-add-wash-type 'smiley)
1682 (dolist (image images)
1683 (gnus-add-image 'smiley image)))))))
1685 (defun gnus-article-remove-images ()
1686 "Remove all images from the article buffer."
1688 (gnus-with-article-buffer
1689 (dolist (elem gnus-article-image-alist)
1690 (gnus-delete-images (car elem)))))
1692 (defun gnus-article-treat-fold-newsgroups ()
1693 "Unfold folded message headers.
1694 Only the headers that fit into the current window width will be
1697 (gnus-with-article-headers
1698 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1700 (mail-header-narrow-to-field)
1701 (while (re-search-forward ", *" nil t)
1702 (replace-match ", " t t))
1703 (mail-header-fold-field)
1704 (goto-char (point-max))))))
1706 (defun gnus-article-treat-body-boundary ()
1707 "Place a boundary line at the end of the headers."
1709 (when (and gnus-body-boundary-delimiter
1710 (> (length gnus-body-boundary-delimiter) 0))
1711 (gnus-with-article-headers
1712 (goto-char (point-max))
1713 (let ((start (point)))
1714 (insert "X-Boundary: ")
1715 (gnus-add-text-properties start (point) '(invisible t intangible t))
1717 (while (>= (1- (window-width)) (length str))
1718 (setq str (concat str gnus-body-boundary-delimiter)))
1719 (substring str 0 (1- (window-width))))
1722 (defun article-fill-long-lines ()
1723 "Fill lines that are wider than the window width."
1726 (let ((buffer-read-only nil)
1727 (width (window-width (get-buffer-window (current-buffer)))))
1730 (let ((adaptive-fill-mode nil)) ;Why? -sm
1733 (when (>= (current-column) (min fill-column width))
1734 (narrow-to-region (point) (gnus-point-at-bol))
1735 (fill-paragraph nil)
1736 (goto-char (point-max))
1738 (forward-line 1)))))))
1740 (defun article-capitalize-sentences ()
1741 "Capitalize the first word in each sentence."
1744 (let ((buffer-read-only nil)
1745 (paragraph-start "^[\n\^L]"))
1749 (forward-sentence)))))
1751 (defun article-remove-cr ()
1752 "Remove trailing CRs and then translate remaining CRs into LFs."
1755 (let ((buffer-read-only nil))
1756 (goto-char (point-min))
1757 (while (re-search-forward "\r+$" nil t)
1758 (replace-match "" t t))
1759 (goto-char (point-min))
1760 (while (search-forward "\r" nil t)
1761 (replace-match "\n" t t)))))
1763 (defun article-remove-trailing-blank-lines ()
1764 "Remove all trailing blank lines from the article."
1767 (let ((buffer-read-only nil))
1768 (goto-char (point-max))
1772 (while (and (not (bobp))
1773 (looking-at "^[ \t]*$")
1774 (not (gnus-annotation-in-region-p
1775 (point) (gnus-point-at-eol))))
1780 (defun article-display-x-face (&optional force)
1781 "Look for an X-Face header and display it if present."
1782 (interactive (list 'force))
1783 (gnus-with-article-headers
1784 ;; Delete the old process, if any.
1785 (when (process-status "article-x-face")
1786 (delete-process "article-x-face"))
1787 (if (memq 'xface gnus-article-wash-types)
1788 ;; We have already displayed X-Faces, so we remove them
1790 (gnus-delete-images 'xface)
1792 (let (x-faces from face grey)
1794 (set-buffer gnus-original-article-buffer)
1796 (mail-narrow-to-head)
1797 (while (gnus-article-goto-header "x-face\\(-[0-9]+\\)?")
1798 (when (match-beginning 2)
1800 (push (mail-header-field-value) x-faces))
1801 (setq from (message-fetch-field "from"))))
1803 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1806 (setq image (gnus-create-image xpm 'xpm t))
1807 (gnus-article-goto-header "from")
1808 (gnus-add-wash-type 'xface)
1809 (gnus-add-image 'xface image)
1810 (gnus-put-image image)))
1811 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1812 ;; single external face.
1813 (when (stringp gnus-article-x-face-command)
1814 (setq x-faces (list (car x-faces))))
1815 (while (and (setq face (pop x-faces))
1816 gnus-article-x-face-command
1818 ;; Check whether this face is censored.
1819 (not gnus-article-x-face-too-ugly)
1820 (and gnus-article-x-face-too-ugly from
1821 (not (string-match gnus-article-x-face-too-ugly
1823 ;; We display the face.
1824 (if (symbolp gnus-article-x-face-command)
1825 ;; The command is a lisp function, so we call it.
1826 (if (gnus-functionp gnus-article-x-face-command)
1827 (funcall gnus-article-x-face-command face)
1828 (error "%s is not a function" gnus-article-x-face-command))
1829 ;; The command is a string, so we interpret the command
1830 ;; as a, well, command, and fork it off.
1831 (let ((process-connection-type nil))
1832 (process-kill-without-query
1834 "article-x-face" nil shell-file-name shell-command-switch
1835 gnus-article-x-face-command))
1838 (process-send-region "article-x-face"
1839 (point-min) (point-max)))
1840 (process-send-eof "article-x-face")))))))))
1842 (defun article-decode-mime-words ()
1843 "Decode all MIME-encoded words in the article."
1846 (set-buffer gnus-article-buffer)
1847 (let ((inhibit-point-motion-hooks t)
1849 (mail-parse-charset gnus-newsgroup-charset)
1850 (mail-parse-ignored-charsets
1851 (save-excursion (set-buffer gnus-summary-buffer)
1852 gnus-newsgroup-ignored-charsets)))
1853 (mail-decode-encoded-word-region (point-min) (point-max)))))
1855 (defun article-decode-charset (&optional prompt)
1856 "Decode charset-encoded text in the article.
1857 If PROMPT (the prefix), prompt for a coding system to use."
1859 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1861 (mail-parse-charset gnus-newsgroup-charset)
1862 (mail-parse-ignored-charsets
1863 (save-excursion (condition-case nil
1864 (set-buffer gnus-summary-buffer)
1866 gnus-newsgroup-ignored-charsets))
1867 ct cte ctl charset format)
1870 (article-narrow-to-head)
1871 (setq ct (message-fetch-field "Content-Type" t)
1872 cte (message-fetch-field "Content-Transfer-Encoding" t)
1873 ctl (and ct (ignore-errors
1874 (mail-header-parse-content-type ct)))
1877 (mm-read-coding-system "Charset to decode: "))
1879 (mail-content-type-get ctl 'charset)))
1880 format (and ctl (mail-content-type-get ctl 'format)))
1882 (setq cte (mail-header-strip cte)))
1883 (if (and ctl (not (string-match "/" (car ctl))))
1885 (goto-char (point-max)))
1888 (narrow-to-region (point) (point-max))
1889 (when (and (eq mail-parse-charset 'gnus-decoded)
1890 (eq (mm-body-7-or-8) '8bit))
1891 ;; The text code could have been decoded.
1892 (setq charset mail-parse-charset))
1893 (when (and (or (not ctl)
1894 (equal (car ctl) "text/plain"))
1895 (not format)) ;; article with format will decode later.
1897 charset (and cte (intern (downcase
1898 (gnus-strip-whitespace cte))))
1901 (defun article-decode-encoded-words ()
1902 "Remove encoded-word encoding from headers."
1903 (let ((inhibit-point-motion-hooks t)
1904 (mail-parse-charset gnus-newsgroup-charset)
1905 (mail-parse-ignored-charsets
1906 (save-excursion (condition-case nil
1907 (set-buffer gnus-summary-buffer)
1909 gnus-newsgroup-ignored-charsets))
1912 (article-narrow-to-head)
1913 (funcall gnus-decode-header-function (point-min) (point-max)))))
1915 (defun article-decode-group-name ()
1916 "Decode group names in `Newsgroups:'."
1917 (let ((inhibit-point-motion-hooks t)
1919 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1920 (when (and (or gnus-group-name-charset-method-alist
1921 gnus-group-name-charset-group-alist)
1922 (gnus-buffer-live-p gnus-original-article-buffer))
1923 (when (nnmail-fetch-field "Newsgroups")
1924 (nnheader-replace-header "Newsgroups"
1925 (gnus-decode-newsgroups
1926 (with-current-buffer
1927 gnus-original-article-buffer
1928 (nnmail-fetch-field "Newsgroups"))
1929 gnus-newsgroup-name method)))
1930 (when (nnmail-fetch-field "Followup-To")
1931 (nnheader-replace-header "Followup-To"
1932 (gnus-decode-newsgroups
1933 (with-current-buffer
1934 gnus-original-article-buffer
1935 (nnmail-fetch-field "Followup-To"))
1936 gnus-newsgroup-name method))))))
1938 (defun article-de-quoted-unreadable (&optional force read-charset)
1939 "Translate a quoted-printable-encoded article.
1940 If FORCE, decode the article whether it is marked as quoted-printable
1942 If READ-CHARSET, ask for a coding system."
1943 (interactive (list 'force current-prefix-arg))
1945 (let ((buffer-read-only nil) type charset)
1946 (if (gnus-buffer-live-p gnus-original-article-buffer)
1947 (with-current-buffer gnus-original-article-buffer
1949 (gnus-fetch-field "content-transfer-encoding"))
1950 (let* ((ct (gnus-fetch-field "content-type"))
1953 (mail-header-parse-content-type ct)))))
1954 (setq charset (and ctl
1955 (mail-content-type-get ctl 'charset)))
1956 (if (stringp charset)
1957 (setq charset (intern (downcase charset)))))))
1959 (setq charset (mm-read-coding-system "Charset: " charset)))
1961 (setq charset gnus-newsgroup-charset))
1963 (and type (let ((case-fold-search t))
1964 (string-match "quoted-printable" type))))
1966 (quoted-printable-decode-region
1967 (point) (point-max) (mm-charset-to-coding-system charset))))))
1969 (defun article-de-base64-unreadable (&optional force read-charset)
1970 "Translate a base64 article.
1971 If FORCE, decode the article whether it is marked as base64 not.
1972 If READ-CHARSET, ask for a coding system."
1973 (interactive (list 'force current-prefix-arg))
1975 (let ((buffer-read-only nil) type charset)
1976 (if (gnus-buffer-live-p gnus-original-article-buffer)
1977 (with-current-buffer gnus-original-article-buffer
1979 (gnus-fetch-field "content-transfer-encoding"))
1980 (let* ((ct (gnus-fetch-field "content-type"))
1983 (mail-header-parse-content-type ct)))))
1984 (setq charset (and ctl
1985 (mail-content-type-get ctl 'charset)))
1986 (if (stringp charset)
1987 (setq charset (intern (downcase charset)))))))
1989 (setq charset (mm-read-coding-system "Charset: " charset)))
1991 (setq charset gnus-newsgroup-charset))
1993 (and type (let ((case-fold-search t))
1994 (string-match "base64" type))))
1997 (narrow-to-region (point) (point-max))
1998 (base64-decode-region (point-min) (point-max))
1999 (mm-decode-coding-region
2000 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2005 (defun article-decode-HZ ()
2006 "Translate a HZ-encoded article."
2010 (let ((buffer-read-only nil))
2011 (rfc1843-decode-region (point-min) (point-max)))))
2013 (defun article-wash-html (&optional read-charset)
2014 "Format an html article.
2015 If READ-CHARSET, ask for a coding system."
2018 (let ((buffer-read-only nil)
2020 (if (gnus-buffer-live-p gnus-original-article-buffer)
2021 (with-current-buffer gnus-original-article-buffer
2022 (let* ((ct (gnus-fetch-field "content-type"))
2025 (mail-header-parse-content-type ct)))))
2026 (setq charset (and ctl
2027 (mail-content-type-get ctl 'charset)))
2028 (if (stringp charset)
2029 (setq charset (intern (downcase charset)))))))
2031 (setq charset (mm-read-coding-system "Charset: " charset)))
2033 (setq charset gnus-newsgroup-charset))
2035 (save-window-excursion
2037 (narrow-to-region (point) (point-max))
2039 (let ((w3-strict-width (window-width))
2040 (url-standalone-mode t)
2041 (w3-honor-stylesheets nil)
2042 (w3-delay-image-loads t))
2044 (w3-region (point-min) (point-max))
2047 (defun article-hide-list-identifiers ()
2048 "Remove list identifies from the Subject header.
2049 The `gnus-list-identifiers' variable specifies what to do."
2051 (let ((inhibit-point-motion-hooks t)
2052 (regexp (if (consp gnus-list-identifiers)
2053 (mapconcat 'identity gnus-list-identifiers " *\\|")
2054 gnus-list-identifiers))
2059 (article-narrow-to-head)
2060 (goto-char (point-min))
2061 (while (re-search-forward
2062 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2064 (delete-region (match-beginning 2) (match-end 0))
2065 (beginning-of-line))
2066 (when (re-search-forward
2067 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2068 (delete-region (match-beginning 1) (match-end 1))))))))
2070 (defun article-hide-pgp ()
2071 "Remove any PGP headers and signatures in the current article."
2075 (let ((inhibit-point-motion-hooks t)
2076 buffer-read-only beg end)
2078 ;; Hide the "header".
2079 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2080 (gnus-add-wash-type 'pgp)
2081 (delete-region (match-beginning 0) (match-end 0))
2082 ;; Remove armor headers (rfc2440 6.2)
2083 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2086 ;; Hide the actual signature.
2087 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2088 (setq end (1+ (match-beginning 0)))
2091 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2093 ;; Perhaps we shouldn't hide to the end of the buffer
2094 ;; if there is no end to the signature?
2096 ;; Hide "- " PGP quotation markers.
2098 (narrow-to-region beg end)
2099 (goto-char (point-min))
2100 (while (re-search-forward "^- " nil t)
2102 (match-beginning 0) (match-end 0)))
2104 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2106 (defun article-hide-pem (&optional arg)
2107 "Toggle hiding of any PEM headers and signatures in the current article.
2108 If given a negative prefix, always show; if given a positive prefix,
2110 (interactive (gnus-article-hidden-arg))
2111 (unless (gnus-article-check-hidden-text 'pem arg)
2113 (let (buffer-read-only end)
2114 (goto-char (point-min))
2115 ;; Hide the horrendously ugly "header".
2116 (when (and (search-forward
2117 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2119 (setq end (1+ (match-beginning 0))))
2120 (gnus-add-wash-type 'pem)
2121 (gnus-article-hide-text-type
2123 (if (search-forward "\n\n" nil t)
2127 ;; Hide the trailer as well
2128 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2130 (gnus-article-hide-text-type
2131 (match-beginning 0) (match-end 0) 'pem)))))))
2133 (defun article-strip-banner ()
2134 "Strip the banner specified by the `banner' group parameter."
2138 (let ((inhibit-point-motion-hooks t)
2139 (banner (gnus-parameter-banner gnus-newsgroup-name))
2140 (gnus-signature-limit nil)
2141 buffer-read-only beg end)
2145 ((eq banner 'signature)
2146 (when (gnus-article-narrow-to-signature)
2149 (delete-region (point) (point-max))))
2151 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2152 (while (re-search-forward banner nil t)
2153 (delete-region (match-beginning 0) (match-end 0)))))
2155 (while (re-search-forward banner nil t)
2156 (delete-region (match-beginning 0) (match-end 0))))))))))
2158 (defun article-babel ()
2159 "Translate article using an online translation service."
2163 (set-buffer gnus-article-buffer)
2164 (when (article-goto-body)
2165 (let* ((buffer-read-only nil)
2168 (orig (buffer-substring start end))
2169 (trans (babel-as-string orig)))
2171 (narrow-to-region start end)
2172 (delete-region start end)
2175 (defun article-hide-signature (&optional arg)
2176 "Hide the signature in the current article.
2177 If given a negative prefix, always show; if given a positive prefix,
2179 (interactive (gnus-article-hidden-arg))
2180 (unless (gnus-article-check-hidden-text 'signature arg)
2183 (let ((buffer-read-only nil))
2184 (when (gnus-article-narrow-to-signature)
2185 (gnus-article-hide-text-type
2186 (point-min) (point-max) 'signature))))))
2187 (gnus-set-mode-line 'article))
2189 (defun article-strip-headers-in-body ()
2190 "Strip offensive headers from bodies."
2194 (let ((case-fold-search t))
2195 (when (looking-at "x-no-archive:")
2196 (gnus-delete-line)))))
2198 (defun article-strip-leading-blank-lines ()
2199 "Remove all blank lines from the beginning of the article."
2202 (let ((inhibit-point-motion-hooks t)
2204 (when (article-goto-body)
2205 (while (and (not (eobp))
2206 (looking-at "[ \t]*$"))
2207 (gnus-delete-line))))))
2209 (defun article-narrow-to-head ()
2210 "Narrow the buffer to the head of the message.
2211 Point is left at the beginning of the narrowed-to region."
2213 (goto-char (point-min))
2214 (if (search-forward "\n\n" nil 1)
2217 (goto-char (point-min)))
2219 (defun article-goto-body ()
2220 "Place point at the start of the body."
2221 (goto-char (point-min))
2223 ;; This variable is only bound when dealing with separate
2225 (article-goto-body-goes-to-point-min-p
2227 ((search-forward "\n\n" nil t)
2230 (goto-char (point-max))
2233 (defun article-strip-multiple-blank-lines ()
2234 "Replace consecutive blank lines with one empty line."
2237 (let ((inhibit-point-motion-hooks t)
2239 ;; First make all blank lines empty.
2241 (while (re-search-forward "^[ \t]+$" nil t)
2242 (unless (gnus-annotation-in-region-p
2243 (match-beginning 0) (match-end 0))
2244 (replace-match "" nil t)))
2245 ;; Then replace multiple empty lines with a single empty line.
2247 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2248 (unless (gnus-annotation-in-region-p
2249 (match-beginning 0) (match-end 0))
2250 (delete-region (match-beginning 1) (match-end 1)))))))
2252 (defun article-strip-leading-space ()
2253 "Remove all white space from the beginning of the lines in the article."
2256 (let ((inhibit-point-motion-hooks t)
2259 (while (re-search-forward "^[ \t]+" nil t)
2260 (replace-match "" t t)))))
2262 (defun article-strip-trailing-space ()
2263 "Remove all white space from the end of the lines in the article."
2266 (let ((inhibit-point-motion-hooks t)
2269 (while (re-search-forward "[ \t]+$" nil t)
2270 (replace-match "" t t)))))
2272 (defun article-strip-blank-lines ()
2273 "Strip leading, trailing and multiple blank lines."
2275 (article-strip-leading-blank-lines)
2276 (article-remove-trailing-blank-lines)
2277 (article-strip-multiple-blank-lines))
2279 (defun article-strip-all-blank-lines ()
2280 "Strip all blank lines."
2283 (let ((inhibit-point-motion-hooks t)
2286 (while (re-search-forward "^[ \t]*\n" nil t)
2287 (replace-match "" t t)))))
2289 (defun gnus-article-narrow-to-signature ()
2290 "Narrow to the signature; return t if a signature is found, else nil."
2291 (let ((inhibit-point-motion-hooks t))
2292 (when (gnus-article-search-signature)
2294 ;; Check whether we have some limits to what we consider
2295 ;; to be a signature.
2296 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2297 (list gnus-signature-limit)))
2299 (while (setq limit (pop limits))
2300 (if (or (and (integerp limit)
2301 (< (- (point-max) (point)) limit))
2303 (< (count-lines (point) (point-max)) limit))
2304 (and (gnus-functionp limit)
2306 (and (stringp limit)
2307 (not (re-search-forward limit nil t))))
2308 () ; This limit did not succeed.
2312 (narrow-to-region (point) (point-max))
2315 (defun gnus-article-search-signature ()
2316 "Search the current buffer for the signature separator.
2317 Put point at the beginning of the signature separator."
2318 (let ((cur (point)))
2319 (goto-char (point-max))
2320 (if (if (stringp gnus-signature-separator)
2321 (re-search-backward gnus-signature-separator nil t)
2322 (let ((seps gnus-signature-separator))
2324 (not (re-search-backward (car seps) nil t)))
2331 (defun gnus-article-hidden-arg ()
2332 "Return the current prefix arg as a number, or 0 if no prefix."
2333 (list (if current-prefix-arg
2334 (prefix-numeric-value current-prefix-arg)
2337 (defun gnus-article-check-hidden-text (type arg)
2338 "Return nil if hiding is necessary.
2339 Arg can be nil or a number. nil and positive means hide, negative
2340 means show, 0 means toggle."
2343 (let ((hide (gnus-article-hidden-text-p type)))
2349 (gnus-article-show-hidden-text type)
2352 (if (eq hide 'hidden)
2354 (gnus-article-show-hidden-text type)
2358 (defun gnus-article-hidden-text-p (type)
2359 "Say whether the current buffer contains hidden text of type TYPE."
2360 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2362 (not (get-text-property pos 'invisible))
2363 (not (get-text-property pos 'dummy-invisible)))
2365 (text-property-any (1+ pos) (point-max) 'article-type type)))
2370 (defun gnus-article-show-hidden-text (type &optional dummy)
2371 "Show all hidden text of type TYPE.
2372 Originally it is hide instead of DUMMY."
2373 (let ((buffer-read-only nil)
2374 (inhibit-point-motion-hooks t))
2375 (gnus-remove-text-properties-when
2377 (point-min) (point-max)
2378 (cons 'article-type (cons type
2379 gnus-hidden-properties)))
2380 (gnus-delete-wash-type type)))
2382 (defconst article-time-units
2383 `((year . ,(* 365.25 24 60 60))
2384 (week . ,(* 7 24 60 60))
2385 (day . ,(* 24 60 60))
2389 "Mapping from time units to seconds.")
2391 (defun article-date-ut (&optional type highlight header)
2392 "Convert DATE date to universal time in the current article.
2393 If TYPE is `local', convert to local time; if it is `lapsed', output
2394 how much time has lapsed since DATE. For `lapsed', the value of
2395 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2396 should replace the \"Date:\" one, or should be added below it."
2397 (interactive (list 'ut t))
2398 (let* ((header (or header
2399 (message-fetch-field "date")
2401 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2404 ((not gnus-article-date-lapsed-new-header)
2410 (date (if (vectorp header) (mail-header-date header)
2412 (inhibit-point-motion-hooks t)
2417 (article-narrow-to-head)
2418 (when (re-search-forward tdate-regexp nil t)
2419 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2420 date (or (get-text-property (gnus-point-at-bol)
2423 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2425 (when (and date (not (string= date "")))
2426 (goto-char (point-min))
2427 (let ((buffer-read-only nil))
2428 ;; Delete any old Date headers.
2429 (while (re-search-forward date-regexp nil t)
2431 (delete-region (progn (beginning-of-line) (point))
2432 (progn (forward-line 1) (point)))
2433 (delete-region (progn (beginning-of-line) (point))
2434 (progn (end-of-line) (point)))
2435 (setq pos (point))))
2436 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2438 (if pos (goto-char pos))
2439 (insert (article-make-date-line date (or type 'ut)))
2445 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2446 (put-text-property (match-beginning 1) (1+ (match-end 1))
2447 'original-date date)
2448 (put-text-property (match-beginning 1) (1+ (match-end 1))
2450 (put-text-property (match-beginning 2) (match-end 2)
2453 (defun article-make-date-line (date type)
2454 "Return a DATE line of TYPE."
2455 (unless (memq type '(local ut original user iso8601 lapsed english))
2456 (error "Unknown conversion type: %s" type))
2458 (let ((time (date-to-time date)))
2460 ;; Convert to the local timezone.
2462 (let ((tz (car (current-time-zone time))))
2463 (format "Date: %s %s%02d%02d" (current-time-string time)
2464 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2465 (/ (% (abs tz) 3600) 60))))
2466 ;; Convert to Universal Time.
2469 (current-time-string
2470 (let* ((e (parse-time-string date))
2471 (tm (apply 'encode-time e))
2473 (ls (- (cadr tm) (car (current-time-zone time)))))
2474 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2475 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2478 ;; Get the original date from the article.
2479 ((eq type 'original)
2480 (concat "Date: " (if (string-match "\n+$" date)
2481 (substring date 0 (match-beginning 0))
2483 ;; Let the user define the format.
2485 (if (gnus-functionp gnus-article-time-format)
2486 (funcall gnus-article-time-format time)
2489 (format-time-string gnus-article-time-format time))))
2492 (let ((tz (car (current-time-zone time))))
2495 (format-time-string "%Y%m%dT%H%M%S" time)
2496 (format "%s%02d%02d"
2497 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2498 (/ (% (abs tz) 3600) 60)))))
2499 ;; Do an X-Sent lapsed format.
2501 ;; If the date is seriously mangled, the timezone functions are
2502 ;; liable to bug out, so we ignore all errors.
2503 (let* ((now (current-time))
2504 (real-time (subtract-time now time))
2505 (real-sec (and real-time
2506 (+ (* (float (car real-time)) 65536)
2508 (sec (and real-time (abs real-sec)))
2518 ;; This is a bit convoluted, but basically we go
2519 ;; through the time units for years, weeks, etc,
2520 ;; and divide things to see whether that results
2521 ;; in positive answers.
2524 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2525 ;; The (remaining) seconds are too few to
2526 ;; be divided into this time unit.
2528 ;; It's big enough, so we output it.
2529 (setq sec (- sec (* num (cdr unit))))
2531 (concat (if prev ", " "") (int-to-string
2533 " " (symbol-name (car unit))
2534 (if (> num 1) "s" ""))
2536 article-time-units "")
2537 ;; If dates are odd, then it might appear like the
2538 ;; article was sent in the future.
2541 " in the future"))))))
2542 ;; Display the date in proper English
2544 (let ((dtime (decode-time time)))
2547 (number-to-string (nth 3 dtime))
2548 (let ((digit (% (nth 3 dtime) 10)))
2550 ((memq (nth 3 dtime) '(11 12 13)) "th")
2556 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2558 (number-to-string (nth 5 dtime))
2560 (format "%02d" (nth 2 dtime))
2562 (format "%02d" (nth 1 dtime)))))))
2564 (format "Date: %s (from Oort)" date))))
2566 (defun article-date-local (&optional highlight)
2567 "Convert the current article date to the local timezone."
2568 (interactive (list t))
2569 (article-date-ut 'local highlight))
2571 (defun article-date-english (&optional highlight)
2572 "Convert the current article date to something that is proper English."
2573 (interactive (list t))
2574 (article-date-ut 'english highlight))
2576 (defun article-date-original (&optional highlight)
2577 "Convert the current article date to what it was originally.
2578 This is only useful if you have used some other date conversion
2579 function and want to see what the date was before converting."
2580 (interactive (list t))
2581 (article-date-ut 'original highlight))
2583 (defun article-date-lapsed (&optional highlight)
2584 "Convert the current article date to time lapsed since it was sent."
2585 (interactive (list t))
2586 (article-date-ut 'lapsed highlight))
2588 (defun article-update-date-lapsed ()
2589 "Function to be run from a timer to update the lapsed time line."
2590 (let (deactivate-mark)
2595 (set-buffer (window-buffer w))
2596 (when (eq major-mode 'gnus-article-mode)
2597 (goto-char (point-min))
2598 (when (re-search-forward "^X-Sent:" nil t)
2599 (article-date-lapsed t))))
2602 (defun gnus-start-date-timer (&optional n)
2603 "Start a timer to update the X-Sent header in the article buffers.
2604 The numerical prefix says how frequently (in seconds) the function
2609 (gnus-stop-date-timer)
2610 (setq article-lapsed-timer
2611 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2613 (defun gnus-stop-date-timer ()
2614 "Stop the X-Sent timer."
2616 (when article-lapsed-timer
2617 (nnheader-cancel-timer article-lapsed-timer)
2618 (setq article-lapsed-timer nil)))
2620 (defun article-date-user (&optional highlight)
2621 "Convert the current article date to the user-defined format.
2622 This format is defined by the `gnus-article-time-format' variable."
2623 (interactive (list t))
2624 (article-date-ut 'user highlight))
2626 (defun article-date-iso8601 (&optional highlight)
2627 "Convert the current article date to ISO8601."
2628 (interactive (list t))
2629 (article-date-ut 'iso8601 highlight))
2631 (defun article-show-all ()
2632 "Show all hidden text in the article buffer."
2635 (let ((buffer-read-only nil))
2636 (gnus-article-unhide-text (point-min) (point-max)))))
2638 (defun article-remove-leading-whitespace ()
2639 "Remove excessive whitespace from all headers."
2643 (let ((buffer-read-only nil))
2644 (article-narrow-to-head)
2645 (goto-char (point-min))
2646 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2647 (delete-region (match-beginning 1) (match-end 1)))))))
2649 (defun article-emphasize (&optional arg)
2650 "Emphasize text according to `gnus-emphasis-alist'."
2651 (interactive (gnus-article-hidden-arg))
2652 (unless (gnus-article-check-hidden-text 'emphasis arg)
2656 (with-current-buffer gnus-summary-buffer
2657 gnus-article-emphasis-alist)
2659 gnus-emphasis-alist))
2660 (buffer-read-only nil)
2661 (props (append '(article-type emphasis)
2662 gnus-hidden-properties))
2663 regexp elem beg invisible visible face)
2666 (while (setq elem (pop alist))
2668 (setq regexp (car elem)
2669 invisible (nth 1 elem)
2670 visible (nth 2 elem)
2672 (while (re-search-forward regexp nil t)
2673 (when (and (match-beginning visible) (match-beginning invisible))
2674 (gnus-article-hide-text
2675 (match-beginning invisible) (match-end invisible) props)
2676 (gnus-article-unhide-text-type
2677 (match-beginning visible) (match-end visible) 'emphasis)
2678 (gnus-put-overlay-excluding-newlines
2679 (match-beginning visible) (match-end visible) 'face face)
2680 (gnus-add-wash-type 'emphasis)
2681 (goto-char (match-end invisible)))))))))
2683 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2684 "Setup newsgroup emphasis alist."
2685 (unless gnus-article-emphasis-alist
2686 (let ((name (and gnus-newsgroup-name
2687 (gnus-group-real-name gnus-newsgroup-name))))
2688 (make-local-variable 'gnus-article-emphasis-alist)
2689 (setq gnus-article-emphasis-alist
2691 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2692 (while (setq elem (pop alist))
2693 (when (and name (string-match (car elem) name))
2695 highlight (copy-sequence (cdr elem)))))
2697 (copy-sequence highlight-words)
2698 (if gnus-newsgroup-name
2699 (copy-sequence (gnus-group-find-parameter
2700 gnus-newsgroup-name 'highlight-words t)))
2701 gnus-emphasis-alist)))))
2704 (defvar gnus-summary-article-menu)
2705 (defvar gnus-summary-post-menu))
2707 ;;; Saving functions.
2709 (defun gnus-article-save (save-buffer file &optional num)
2710 "Save the currently selected article."
2711 (unless gnus-save-all-headers
2712 ;; Remove headers according to `gnus-saved-headers'.
2713 (let ((gnus-visible-headers
2714 (or gnus-saved-headers gnus-visible-headers))
2715 (gnus-article-buffer save-buffer))
2717 (set-buffer save-buffer)
2718 (article-hide-headers 1 t))))
2719 (save-window-excursion
2720 (if (not gnus-default-article-saver)
2721 (error "No default saver is defined")
2722 ;; !!! Magic! The saving functions all save
2723 ;; `gnus-save-article-buffer' (or so they think), but we
2724 ;; bind that variable to our save-buffer.
2725 (set-buffer gnus-article-buffer)
2726 (let* ((gnus-save-article-buffer save-buffer)
2729 ((not gnus-prompt-before-saving) 'default)
2730 ((eq gnus-prompt-before-saving 'always) nil)
2732 (gnus-number-of-articles-to-be-saved
2733 (when (eq gnus-prompt-before-saving t)
2735 (set-buffer gnus-article-current-summary)
2736 (funcall gnus-default-article-saver filename)))))
2738 (defun gnus-read-save-file-name (prompt &optional filename
2739 function group headers variable)
2741 (funcall function group headers (symbol-value variable)))
2746 ((eq filename 'default)
2752 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2755 (if (and gnus-number-of-articles-to-be-saved
2756 (> gnus-number-of-articles-to-be-saved 1))
2757 (format "these %d articles"
2758 gnus-number-of-articles-to-be-saved)
2761 ;; Let the split methods have their say.
2763 ;; No split name was found.
2766 (concat prompt " (default "
2767 (file-name-nondirectory default-name) ") ")
2768 (file-name-directory default-name)
2770 ;; A single group name is returned.
2771 ((stringp split-name)
2773 (funcall function split-name headers
2774 (symbol-value variable)))
2776 (concat prompt " (default "
2777 (file-name-nondirectory default-name) ") ")
2778 (file-name-directory default-name)
2780 ;; A single split name was found
2781 ((= 1 (length split-name))
2782 (let* ((name (expand-file-name
2784 gnus-article-save-directory))
2785 (dir (cond ((file-directory-p name)
2786 (file-name-as-directory name))
2787 ((file-exists-p name) name)
2788 (t gnus-article-save-directory))))
2790 (concat prompt " (default " name ") ")
2792 ;; A list of splits was found.
2794 (setq split-name (nreverse split-name))
2796 (let ((file-name-history
2797 (nconc split-name file-name-history)))
2801 (concat prompt " (`M-p' for defaults) ")
2802 gnus-article-save-directory
2804 gnus-article-save-directory)))
2805 (car (push result file-name-history)))))))
2806 ;; Create the directory.
2807 (gnus-make-directory (file-name-directory file))
2808 ;; If we have read a directory, we append the default file name.
2809 (when (file-directory-p file)
2810 (setq file (expand-file-name (file-name-nondirectory
2812 (file-name-as-directory file))))
2813 ;; Possibly translate some characters.
2814 (nnheader-translate-file-chars file))))))
2815 (gnus-make-directory (file-name-directory result))
2816 (set variable result)))
2818 (defun gnus-article-archive-name (group)
2819 "Return the first instance of an \"Archive-name\" in the current buffer."
2820 (let ((case-fold-search t))
2821 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2822 (nnheader-concat gnus-article-save-directory
2823 (match-string 1)))))
2825 (defun gnus-article-nndoc-name (group)
2826 "If GROUP is an nndoc group, return the name of the parent group."
2827 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2828 (gnus-group-get-parameter group 'save-article-group)))
2830 (defun gnus-summary-save-in-rmail (&optional filename)
2831 "Append this article to Rmail file.
2832 Optional argument FILENAME specifies file name.
2833 Directory to save to is default to `gnus-article-save-directory'."
2834 (setq filename (gnus-read-save-file-name
2835 "Save %s in rmail file:" filename
2836 gnus-rmail-save-name gnus-newsgroup-name
2837 gnus-current-headers 'gnus-newsgroup-last-rmail))
2838 (gnus-eval-in-buffer-window gnus-save-article-buffer
2842 (gnus-output-to-rmail filename))))
2845 (defun gnus-summary-save-in-mail (&optional filename)
2846 "Append this article to Unix mail file.
2847 Optional argument FILENAME specifies file name.
2848 Directory to save to is default to `gnus-article-save-directory'."
2849 (setq filename (gnus-read-save-file-name
2850 "Save %s in Unix mail file:" filename
2851 gnus-mail-save-name gnus-newsgroup-name
2852 gnus-current-headers 'gnus-newsgroup-last-mail))
2853 (gnus-eval-in-buffer-window gnus-save-article-buffer
2857 (if (and (file-readable-p filename)
2858 (mail-file-babyl-p filename))
2859 (rmail-output-to-rmail-file filename t)
2860 (gnus-output-to-mail filename)))))
2863 (defun gnus-summary-save-in-file (&optional filename overwrite)
2864 "Append this article to file.
2865 Optional argument FILENAME specifies file name.
2866 Directory to save to is default to `gnus-article-save-directory'."
2867 (setq filename (gnus-read-save-file-name
2868 "Save %s in file:" filename
2869 gnus-file-save-name gnus-newsgroup-name
2870 gnus-current-headers 'gnus-newsgroup-last-file))
2871 (gnus-eval-in-buffer-window gnus-save-article-buffer
2875 (when (and overwrite
2876 (file-exists-p filename))
2877 (delete-file filename))
2878 (gnus-output-to-file filename))))
2881 (defun gnus-summary-write-to-file (&optional filename)
2882 "Write this article to a file, overwriting it if the file exists.
2883 Optional argument FILENAME specifies file name.
2884 The directory to save in defaults to `gnus-article-save-directory'."
2885 (gnus-summary-save-in-file nil t))
2887 (defun gnus-summary-save-body-in-file (&optional filename)
2888 "Append this article body to a file.
2889 Optional argument FILENAME specifies file name.
2890 The directory to save in defaults to `gnus-article-save-directory'."
2891 (setq filename (gnus-read-save-file-name
2892 "Save %s body in file:" filename
2893 gnus-file-save-name gnus-newsgroup-name
2894 gnus-current-headers 'gnus-newsgroup-last-file))
2895 (gnus-eval-in-buffer-window gnus-save-article-buffer
2899 (when (article-goto-body)
2900 (narrow-to-region (point) (point-max)))
2901 (gnus-output-to-file filename))))
2904 (defun gnus-summary-save-in-pipe (&optional command)
2905 "Pipe this article to subprocess."
2907 (cond ((and (eq command 'default)
2908 gnus-last-shell-command)
2909 gnus-last-shell-command)
2914 "Shell command on %s: "
2915 (if (and gnus-number-of-articles-to-be-saved
2916 (> gnus-number-of-articles-to-be-saved 1))
2917 (format "these %d articles"
2918 gnus-number-of-articles-to-be-saved)
2920 gnus-last-shell-command))))
2921 (when (string-equal command "")
2922 (if gnus-last-shell-command
2923 (setq command gnus-last-shell-command)
2924 (error "A command is required")))
2925 (gnus-eval-in-buffer-window gnus-article-buffer
2928 (shell-command-on-region (point-min) (point-max) command nil)))
2929 (setq gnus-last-shell-command command))
2931 (defun gnus-summary-pipe-to-muttprint (&optional command)
2932 "Pipe this article to muttprint."
2933 (setq command (read-string
2934 "Print using command: " gnus-summary-muttprint-program
2935 nil gnus-summary-muttprint-program))
2936 (gnus-summary-save-in-pipe command))
2938 ;;; Article file names when saving.
2940 (defun gnus-capitalize-newsgroup (newsgroup)
2941 "Capitalize NEWSGROUP name."
2942 (when (not (zerop (length newsgroup)))
2943 (concat (char-to-string (upcase (aref newsgroup 0)))
2944 (substring newsgroup 1))))
2946 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2947 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2948 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2949 Otherwise, it is like ~/News/news/group/num."
2952 (concat (if (gnus-use-long-file-name 'not-save)
2953 (gnus-capitalize-newsgroup newsgroup)
2954 (gnus-newsgroup-directory-form newsgroup))
2955 "/" (int-to-string (mail-header-number headers)))
2956 gnus-article-save-directory)))
2958 (string-equal (file-name-directory default)
2959 (file-name-directory last-file))
2960 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2962 (or last-file default))))
2964 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2965 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2966 If variable `gnus-use-long-file-name' is non-nil, it is
2967 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2970 (concat (if (gnus-use-long-file-name 'not-save)
2972 (gnus-newsgroup-directory-form newsgroup))
2973 "/" (int-to-string (mail-header-number headers)))
2974 gnus-article-save-directory)))
2976 (string-equal (file-name-directory default)
2977 (file-name-directory last-file))
2978 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2980 (or last-file default))))
2982 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2983 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2984 If variable `gnus-use-long-file-name' is non-nil, it is
2985 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2988 (if (gnus-use-long-file-name 'not-save)
2991 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2993 gnus-article-save-directory)))
2995 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2996 "Generate file name from sender."
2997 (let ((from (mail-header-from headers)))
2999 (if (and from (string-match "\\([^ <]+\\)@" from))
3000 (match-string 1 from)
3002 gnus-article-save-directory)))
3004 (defun article-verify-x-pgp-sig ()
3007 (if (gnus-buffer-live-p gnus-original-article-buffer)
3008 (let ((sig (with-current-buffer gnus-original-article-buffer
3009 (gnus-fetch-field "X-PGP-Sig")))
3013 (mml2015-clear-verify-function))
3015 (insert-buffer gnus-original-article-buffer)
3016 (setq items (split-string sig))
3017 (message-narrow-to-head)
3018 (let ((inhibit-point-motion-hooks t)
3019 (case-fold-search t))
3020 ;; Don't verify multiple headers.
3021 (setq headers (mapconcat (lambda (header)
3023 (mail-fetch-field header) "\n"))
3024 (split-string (nth 1 items) ",") "")))
3025 (delete-region (point-min) (point-max))
3026 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3027 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3032 (if (looking-at "^-")
3035 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3036 (insert "Version: " (car items) "\n\n")
3037 (insert (mapconcat 'identity (cddr items) "\n"))
3038 (insert "\n-----END PGP SIGNATURE-----\n")
3039 (let ((mm-security-handle (list (format "multipart/signed"))))
3040 (mml2015-clean-buffer)
3041 (let ((coding-system-for-write (or gnus-newsgroup-charset
3043 (funcall (mml2015-clear-verify-function)))
3045 (or (mm-handle-multipart-ctl-parameter
3046 mm-security-handle 'gnus-details)
3047 (mm-handle-multipart-ctl-parameter
3048 mm-security-handle 'gnus-info)))))
3050 (let (buffer-read-only bface eface)
3052 (message-narrow-to-head)
3053 (goto-char (point-max))
3055 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3056 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3057 (message-remove-header "X-Gnus-PGP-Verify")
3058 (if (re-search-forward "^X-PGP-Sig:" nil t)
3060 (goto-char (point-max)))
3061 (narrow-to-region (point) (point))
3062 (insert "X-Gnus-PGP-Verify: " info "\n")
3063 (goto-char (point-min))
3066 (if (not (looking-at "^[ \t]"))
3070 (goto-char (point-min))
3071 (when (looking-at "\\([^:]+\\): *")
3072 (put-text-property (match-beginning 1) (1+ (match-end 1))
3074 (put-text-property (match-end 0) (point-max)
3075 'face eface)))))))))
3077 (defun article-verify-cancel-lock ()
3078 "Verify Cancel-Lock header."
3080 (if (gnus-buffer-live-p gnus-original-article-buffer)
3081 (canlock-verify gnus-original-article-buffer)))
3088 (setq afunc (car func)
3091 gfunc (intern (format "gnus-%s" func))))
3093 (when (fboundp afunc)
3094 `(lambda (&optional interactive &rest args)
3095 ,(documentation afunc t)
3096 (interactive (list t))
3098 (set-buffer gnus-article-buffer)
3100 (call-interactively ',afunc)
3101 (apply ',afunc args))))))))
3102 '(article-hide-headers
3103 article-verify-x-pgp-sig
3104 article-verify-cancel-lock
3105 article-hide-boring-headers
3106 article-treat-overstrike
3107 article-fill-long-lines
3108 article-capitalize-sentences
3110 article-remove-leading-whitespace
3111 article-display-x-face
3112 article-de-quoted-unreadable
3113 article-de-base64-unreadable
3116 article-hide-list-identifiers
3118 article-strip-banner
3121 article-hide-signature
3122 article-strip-headers-in-body
3123 article-remove-trailing-blank-lines
3124 article-strip-leading-blank-lines
3125 article-strip-multiple-blank-lines
3126 article-strip-leading-space
3127 article-strip-trailing-space
3128 article-strip-blank-lines
3129 article-strip-all-blank-lines
3130 article-replace-with-quoted-text
3132 article-date-english
3133 article-date-iso8601
3134 article-date-original
3136 article-decode-mime-words
3137 article-decode-charset
3138 article-decode-encoded-words
3142 article-treat-dumbquotes
3143 article-normalize-headers
3144 (article-show-all . gnus-article-show-all-headers))))
3147 ;;; Gnus article mode
3150 (put 'gnus-article-mode 'mode-class 'special)
3152 (set-keymap-parent gnus-article-mode-map widget-keymap)
3154 (gnus-define-keys gnus-article-mode-map
3155 " " gnus-article-goto-next-page
3156 "\177" gnus-article-goto-prev-page
3157 [delete] gnus-article-goto-prev-page
3158 [backspace] gnus-article-goto-prev-page
3159 "\C-c^" gnus-article-refer-article
3160 "h" gnus-article-show-summary
3161 "s" gnus-article-show-summary
3162 "\C-c\C-m" gnus-article-mail
3163 "?" gnus-article-describe-briefly
3164 "e" gnus-summary-edit-article
3165 "<" beginning-of-buffer
3167 "\C-c\C-i" gnus-info-find-node
3169 "R" gnus-article-reply-with-original
3170 "F" gnus-article-followup-with-original
3171 "\C-hk" gnus-article-describe-key
3172 "\C-hc" gnus-article-describe-key-briefly
3174 "\C-d" gnus-article-read-summary-keys
3175 "\M-*" gnus-article-read-summary-keys
3176 "\M-#" gnus-article-read-summary-keys
3177 "\M-^" gnus-article-read-summary-keys
3178 "\M-g" gnus-article-read-summary-keys)
3180 (substitute-key-definition
3181 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3183 (defun gnus-article-make-menu-bar ()
3184 (unless (boundp 'gnus-article-commands-menu)
3185 (gnus-summary-make-menu-bar))
3186 (gnus-turn-off-edit-menu 'article)
3187 (unless (boundp 'gnus-article-article-menu)
3189 gnus-article-article-menu gnus-article-mode-map ""
3191 ["Scroll forwards" gnus-article-goto-next-page t]
3192 ["Scroll backwards" gnus-article-goto-prev-page t]
3193 ["Show summary" gnus-article-show-summary t]
3194 ["Fetch Message-ID at point" gnus-article-refer-article t]
3195 ["Mail to address at point" gnus-article-mail t]
3196 ["Send a bug report" gnus-bug t]))
3199 gnus-article-treatment-menu gnus-article-mode-map ""
3200 ;; Fixme: this should use :active (and maybe :visible).
3202 ["Hide headers" gnus-article-hide-headers t]
3203 ["Hide signature" gnus-article-hide-signature t]
3204 ["Hide citation" gnus-article-hide-citation t]
3205 ["Treat overstrike" gnus-article-treat-overstrike t]
3206 ["Remove carriage return" gnus-article-remove-cr t]
3207 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3208 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3209 ["Remove base64" gnus-article-de-base64-unreadable t]
3210 ["Treat html" gnus-article-wash-html t]
3211 ["Decode HZ" gnus-article-decode-HZ t]))
3213 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3215 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3217 (gnus-run-hooks 'gnus-article-menu-hook)))
3219 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3222 (defun gnus-article-mode ()
3223 "Major mode for displaying an article.
3225 All normal editing commands are switched off.
3227 The following commands are available in addition to all summary mode
3229 \\<gnus-article-mode-map>
3230 \\[gnus-article-next-page]\t Scroll the article one page forwards
3231 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3232 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3233 \\[gnus-article-show-summary]\t Display the summary buffer
3234 \\[gnus-article-mail]\t Send a reply to the address near point
3235 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3236 \\[gnus-info-find-node]\t Go to the Gnus info node"
3238 (gnus-simplify-mode-line)
3239 (setq mode-name "Article")
3240 (setq major-mode 'gnus-article-mode)
3241 (make-local-variable 'minor-mode-alist)
3242 (use-local-map gnus-article-mode-map)
3243 (when (gnus-visual-p 'article-menu 'menu)
3244 (gnus-article-make-menu-bar))
3245 (gnus-update-format-specifications nil 'article-mode)
3246 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3247 (make-local-variable 'gnus-page-broken)
3248 (make-local-variable 'gnus-button-marker-list)
3249 (make-local-variable 'gnus-article-current-summary)
3250 (make-local-variable 'gnus-article-mime-handles)
3251 (make-local-variable 'gnus-article-decoded-p)
3252 (make-local-variable 'gnus-article-mime-handle-alist)
3253 (make-local-variable 'gnus-article-wash-types)
3254 (make-local-variable 'gnus-article-image-alist)
3255 (make-local-variable 'gnus-article-charset)
3256 (make-local-variable 'gnus-article-ignored-charsets)
3257 (gnus-set-default-directory)
3258 (buffer-disable-undo)
3259 (setq buffer-read-only t)
3260 (set-syntax-table gnus-article-mode-syntax-table)
3261 (mm-enable-multibyte)
3262 (gnus-run-hooks 'gnus-article-mode-hook))
3264 (defun gnus-article-setup-buffer ()
3265 "Initialize the article buffer."
3266 (let* ((name (if gnus-single-article-buffer "*Article*"
3267 (concat "*Article " gnus-newsgroup-name "*")))
3269 (progn (string-match "\\*Article" name)
3270 (concat " *Original Article"
3271 (substring name (match-end 0))))))
3272 (setq gnus-article-buffer name)
3273 (setq gnus-original-article-buffer original)
3274 (setq gnus-article-mime-handle-alist nil)
3275 ;; This might be a variable local to the summary buffer.
3276 (unless gnus-single-article-buffer
3278 (set-buffer gnus-summary-buffer)
3279 (setq gnus-article-buffer name)
3280 (setq gnus-original-article-buffer original)
3281 (gnus-set-global-variables)))
3282 (gnus-article-setup-highlight-words)
3283 ;; Init original article buffer.
3285 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3286 (mm-enable-multibyte)
3287 (setq major-mode 'gnus-original-article-mode)
3288 (make-local-variable 'gnus-original-article))
3289 (if (get-buffer name)
3292 (when gnus-article-mime-handles
3293 (mm-destroy-parts gnus-article-mime-handles)
3294 (setq gnus-article-mime-handles nil))
3295 ;; Set it to nil in article-buffer!
3296 (setq gnus-article-mime-handle-alist nil)
3297 (buffer-disable-undo)
3298 (setq buffer-read-only t)
3299 (unless (eq major-mode 'gnus-article-mode)
3300 (gnus-article-mode))
3303 (set-buffer (gnus-get-buffer-create name))
3305 (make-local-variable 'gnus-summary-buffer)
3306 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3307 (current-buffer)))))
3309 ;; Set article window start at LINE, where LINE is the number of lines
3310 ;; from the head of the article.
3311 (defun gnus-article-set-window-start (&optional line)
3313 (gnus-get-buffer-window gnus-article-buffer t)
3315 (set-buffer gnus-article-buffer)
3316 (goto-char (point-min))
3319 (gnus-message 6 "Moved to bookmark")
3320 (search-forward "\n\n" nil t)
3324 (defun gnus-article-prepare (article &optional all-headers header)
3325 "Prepare ARTICLE in article mode buffer.
3326 ARTICLE should either be an article number or a Message-ID.
3327 If ARTICLE is an id, HEADER should be the article headers.
3328 If ALL-HEADERS is non-nil, no headers are hidden."
3330 ;; Make sure we start in a summary buffer.
3331 (unless (eq major-mode 'gnus-summary-mode)
3332 (set-buffer gnus-summary-buffer))
3333 (setq gnus-summary-buffer (current-buffer))
3334 (let* ((gnus-article (if header (mail-header-number header) article))
3335 (summary-buffer (current-buffer))
3336 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3337 (group gnus-newsgroup-name)
3340 (gnus-article-setup-buffer)
3341 (set-buffer gnus-article-buffer)
3342 ;; Deactivate active regions.
3343 (when (and (boundp 'transient-mark-mode)
3344 transient-mark-mode)
3345 (setq mark-active nil))
3346 (if (not (setq result (let ((buffer-read-only nil))
3347 (gnus-request-article-this-buffer
3349 ;; There is no such article.
3351 (when (and (numberp article)
3352 (not (memq article gnus-newsgroup-sparse)))
3353 (setq gnus-article-current
3354 (cons gnus-newsgroup-name article))
3355 (set-buffer gnus-summary-buffer)
3356 (setq gnus-current-article article)
3357 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3359 (gnus-summary-set-agent-mark article)
3360 (message "Message marked for downloading"))
3361 (gnus-summary-mark-article article gnus-canceled-mark)
3362 (unless (memq article gnus-newsgroup-sparse)
3363 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3364 (if (or (eq result 'pseudo)
3365 (eq result 'nneething))
3368 (set-buffer summary-buffer)
3369 (push article gnus-newsgroup-history)
3370 (setq gnus-last-article gnus-current-article
3371 gnus-current-article 0
3372 gnus-current-headers nil
3373 gnus-article-current nil)
3374 (if (eq result 'nneething)
3375 (gnus-configure-windows 'summary)
3376 (gnus-configure-windows 'article))
3377 (gnus-set-global-variables))
3378 (let ((gnus-article-mime-handle-alist-1
3379 gnus-article-mime-handle-alist))
3380 (gnus-set-mode-line 'article)))
3381 ;; The result from the `request' was an actual article -
3382 ;; or at least some text that is now displayed in the
3384 (when (and (numberp article)
3385 (not (eq article gnus-current-article)))
3386 ;; Seems like a new article has been selected.
3387 ;; `gnus-current-article' must be an article number.
3389 (set-buffer summary-buffer)
3390 (push article gnus-newsgroup-history)
3391 (setq gnus-last-article gnus-current-article
3392 gnus-current-article article
3393 gnus-current-headers
3394 (gnus-summary-article-header gnus-current-article)
3395 gnus-article-current
3396 (cons gnus-newsgroup-name gnus-current-article))
3397 (unless (vectorp gnus-current-headers)
3398 (setq gnus-current-headers nil))
3399 (gnus-summary-goto-subject gnus-current-article)
3400 (when (gnus-summary-show-thread)
3401 ;; If the summary buffer really was folded, the
3402 ;; previous goto may not actually have gone to
3403 ;; the right article, but the thread root instead.
3405 (gnus-summary-goto-subject gnus-current-article))
3406 (gnus-run-hooks 'gnus-mark-article-hook)
3407 (gnus-set-mode-line 'summary)
3408 (when (gnus-visual-p 'article-highlight 'highlight)
3409 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3410 ;; Set the global newsgroup variables here.
3411 (gnus-set-global-variables)
3412 (setq gnus-have-all-headers
3413 (or all-headers gnus-show-all-headers))))
3415 (gnus-configure-windows 'article))
3416 (when (or (numberp article)
3418 (gnus-article-prepare-display)
3420 (goto-char (point-min))
3421 (setq gnus-page-broken
3422 (when gnus-break-pages
3423 (gnus-narrow-to-page)
3425 (let ((gnus-article-mime-handle-alist-1
3426 gnus-article-mime-handle-alist))
3427 (gnus-set-mode-line 'article))
3429 (set-window-point (get-buffer-window (current-buffer)) (point))
3430 (gnus-configure-windows 'article)
3434 (defun gnus-article-prepare-display ()
3435 "Make the current buffer look like a nice article."
3436 ;; Hooks for getting information from the article.
3437 ;; This hook must be called before being narrowed.
3438 (let ((gnus-article-buffer (current-buffer))
3440 (unless (eq major-mode 'gnus-article-mode)
3441 (gnus-article-mode))
3442 (setq buffer-read-only nil
3443 gnus-article-wash-types nil
3444 gnus-article-image-alist nil)
3445 (gnus-run-hooks 'gnus-tmp-internal-hook)
3446 (when gnus-display-mime-function
3447 (funcall gnus-display-mime-function))
3448 (gnus-run-hooks 'gnus-article-prepare-hook)))
3451 ;;; Gnus MIME viewing functions
3454 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3455 "Format of the MIME buttons.
3457 Valid specifiers include:
3459 %T MIME type, along with additional info
3460 %n The `name' parameter
3461 %d The description, if any
3462 %l The length of the encoded part
3463 %p The part identifier number
3464 %e Dots if the part isn't displayed
3466 General format specifiers can also be used. See
3467 (gnus)Formatting Variables.")
3469 (defvar gnus-mime-button-line-format-alist
3470 '((?t gnus-tmp-type ?s)
3471 (?T gnus-tmp-type-long ?s)
3472 (?n gnus-tmp-name ?s)
3473 (?d gnus-tmp-description ?s)
3475 (?l gnus-tmp-length ?d)
3476 (?e gnus-tmp-dots ?s)))
3478 (defvar gnus-mime-button-commands
3479 '((gnus-article-press-button "\r" "Toggle Display")
3480 (gnus-mime-view-part "v" "View Interactively...")
3481 (gnus-mime-view-part-as-type "t" "View As Type...")
3482 (gnus-mime-view-part-as-charset "C" "View As charset...")
3483 (gnus-mime-save-part "o" "Save...")
3484 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3485 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3486 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3487 (gnus-mime-internalize-part "E" "View Internally")
3488 (gnus-mime-externalize-part "e" "View Externally")
3489 (gnus-mime-print-part "p" "Print")
3490 (gnus-mime-pipe-part "|" "Pipe To Command...")
3491 (gnus-mime-action-on-part "." "Take action on the part")))
3493 (defun gnus-article-mime-part-status ()
3494 (if gnus-article-mime-handle-alist-1
3495 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3497 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3500 (defvar gnus-mime-button-map
3501 (let ((map (make-sparse-keymap)))
3502 (unless (>= (string-to-number emacs-version) 21)
3503 ;; XEmacs doesn't care.
3504 (set-keymap-parent map gnus-article-mode-map))
3505 (define-key map gnus-mouse-2 'gnus-article-push-button)
3506 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3507 (dolist (c gnus-mime-button-commands)
3508 (define-key map (cadr c) (car c)))
3511 (defun gnus-mime-button-menu (event)
3512 "Construct a context-sensitive menu of MIME commands."
3514 (save-window-excursion
3515 (let ((pos (event-start event)))
3516 (select-window (posn-window pos))
3517 (goto-char (posn-point pos))
3518 (gnus-article-check-buffer)
3519 (let ((response (x-popup-menu
3521 ("" ,@(mapcar (lambda (c)
3522 (cons (caddr c) (car c)))
3523 gnus-mime-button-commands))))))
3525 (call-interactively response))))))
3527 (defun gnus-mime-view-all-parts (&optional handles)
3528 "View all the MIME parts."
3530 (save-current-buffer
3531 (set-buffer gnus-article-buffer)
3532 (let ((handles (or handles gnus-article-mime-handles))
3533 (mail-parse-charset gnus-newsgroup-charset)
3534 (mail-parse-ignored-charsets
3535 (with-current-buffer gnus-summary-buffer
3536 gnus-newsgroup-ignored-charsets)))
3538 (mm-remove-parts handles)
3539 (goto-char (point-min))
3540 (or (search-forward "\n\n") (goto-char (point-max)))
3541 (let (buffer-read-only)
3542 (delete-region (point) (point-max))
3543 (mm-display-parts handles))))))
3545 (defun gnus-mime-save-part-and-strip ()
3546 "Save the MIME part under point then replace it with an external body."
3548 (gnus-article-check-buffer)
3549 (let* ((data (get-text-property (point) 'gnus-data))
3551 (handles gnus-article-mime-handles))
3552 (if (mm-multiple-handles gnus-article-mime-handles)
3553 (error "This function is not implemented"))
3554 (setq file (and data (mm-save-part data)))
3556 (with-current-buffer (mm-handle-buffer data)
3558 (insert "Content-Type: " (mm-handle-media-type data))
3559 (mml-insert-parameter-string (cdr (mm-handle-type data))
3562 (insert "Content-ID: " (message-make-message-id) "\n")
3563 (insert "Content-Transfer-Encoding: binary\n")
3566 (cdr (mm-make-handle nil
3567 `("message/external-body"
3568 (access-type . "LOCAL-FILE")
3570 (set-buffer gnus-summary-buffer)
3571 (gnus-article-edit-article
3574 (let ((mail-parse-charset (or gnus-article-charset
3575 ',gnus-newsgroup-charset))
3576 (mail-parse-ignored-charsets
3577 (or gnus-article-ignored-charsets
3578 ',gnus-newsgroup-ignored-charsets))
3579 (mbl mml-buffer-list))
3580 (setq mml-buffer-list nil)
3581 (insert-buffer gnus-original-article-buffer)
3582 (mime-to-mml ',handles)
3583 (setq gnus-article-mime-handles nil)
3584 (let ((mbl1 mml-buffer-list))
3585 (setq mml-buffer-list mbl)
3586 (set (make-local-variable 'mml-buffer-list) mbl1))
3587 ;; LOCAL argument of add-hook differs between GNU Emacs
3588 ;; and XEmacs. make-local-hook makes sure they are local.
3589 (make-local-hook 'kill-buffer-hook)
3590 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3591 `(lambda (no-highlight)
3592 (let ((mail-parse-charset (or gnus-article-charset
3593 ',gnus-newsgroup-charset))
3594 (message-options message-options)
3595 (message-options-set-recipient)
3596 (mail-parse-ignored-charsets
3597 (or gnus-article-ignored-charsets
3598 ',gnus-newsgroup-ignored-charsets)))
3600 (mml-destroy-buffers)
3601 (remove-hook 'kill-buffer-hook
3602 'mml-destroy-buffers t)
3603 (kill-local-variable 'mml-buffer-list))
3604 (gnus-summary-edit-article-done
3605 ,(or (mail-header-references gnus-current-headers) "")
3606 ,(gnus-group-read-only-p)
3607 ,gnus-summary-buffer no-highlight))))))
3609 (defun gnus-mime-save-part ()
3610 "Save the MIME part under point."
3612 (gnus-article-check-buffer)
3613 (let ((data (get-text-property (point) 'gnus-data)))
3615 (mm-save-part data))))
3617 (defun gnus-mime-pipe-part ()
3618 "Pipe the MIME part under point to a process."
3620 (gnus-article-check-buffer)
3621 (let ((data (get-text-property (point) 'gnus-data)))
3623 (mm-pipe-part data))))
3625 (defun gnus-mime-view-part ()
3626 "Interactively choose a viewing method for the MIME part under point."
3628 (gnus-article-check-buffer)
3629 (let ((data (get-text-property (point) 'gnus-data)))
3631 (setq gnus-article-mime-handles
3633 gnus-article-mime-handles (setq data (copy-sequence data))))
3634 (mm-interactively-view-part data))))
3636 (defun gnus-mime-view-part-as-type-internal ()
3637 (gnus-article-check-buffer)
3638 (let* ((name (mail-content-type-get
3639 (mm-handle-type (get-text-property (point) 'gnus-data))
3641 (def-type (and name (mm-default-file-encoding name))))
3642 (and def-type (cons def-type 0))))
3644 (defun gnus-mime-view-part-as-type (&optional mime-type)
3645 "Choose a MIME media type, and view the part as such."
3648 (setq mime-type (completing-read
3649 "View as MIME type: "
3650 (mapcar #'list (mailcap-mime-types))
3652 (gnus-mime-view-part-as-type-internal))))
3653 (gnus-article-check-buffer)
3654 (let ((handle (get-text-property (point) 'gnus-data)))
3657 (mm-make-handle (mm-handle-buffer handle)
3658 (cons mime-type (cdr (mm-handle-type handle)))
3659 (mm-handle-encoding handle)
3660 (mm-handle-undisplayer handle)
3661 (mm-handle-disposition handle)
3662 (mm-handle-description handle)
3664 (mm-handle-id handle)))
3665 (setq gnus-article-mime-handles
3666 (mm-merge-handles gnus-article-mime-handles handle))
3667 (gnus-mm-display-part handle))))
3669 (defun gnus-mime-copy-part (&optional handle)
3670 "Put the MIME part under point into a new buffer."
3672 (gnus-article-check-buffer)
3673 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3674 (contents (and handle (mm-get-part handle)))
3676 (file-name-nondirectory
3678 (mail-content-type-get (mm-handle-type handle) 'name)
3679 (mail-content-type-get (mm-handle-type handle)
3682 (buffer (and base (generate-new-buffer base))))
3684 (switch-to-buffer buffer)
3686 ;; We do it this way to make `normal-mode' set the appropriate mode.
3689 (setq buffer-file-name (expand-file-name base))
3691 (setq buffer-file-name nil))
3692 (goto-char (point-min)))))
3694 (defun gnus-mime-print-part (&optional handle)
3695 "Print the MIME part under point."
3697 (gnus-article-check-buffer)
3698 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3699 (contents (and handle (mm-get-part handle)))
3700 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3701 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3706 (with-temp-file file
3708 (call-process shell-file-name nil
3709 (generate-new-buffer " *mm*")
3711 shell-command-switch
3713 printer file (mm-handle-type handle))))
3717 (gnus-print-buffer))))))
3719 (defun gnus-mime-inline-part (&optional handle arg)
3720 "Insert the MIME part under point into the current buffer."
3721 (interactive (list nil current-prefix-arg))
3722 (gnus-article-check-buffer)
3723 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3728 (if (and (not arg) (mm-handle-undisplayer handle))
3729 (mm-remove-part handle)
3730 (setq contents (mm-get-part handle))
3733 (setq charset (or (mail-content-type-get
3734 (mm-handle-type handle) 'charset)
3735 gnus-newsgroup-charset)))
3737 (if (mm-handle-undisplayer handle)
3738 (mm-remove-part handle))
3741 gnus-summary-show-article-charset-alist))
3742 (mm-read-coding-system "Charset: ")))))
3744 (mm-insert-inline handle
3746 (setq charset (mm-charset-to-coding-system
3748 (not (eq charset 'ascii)))
3749 (mm-decode-coding-string contents charset)
3753 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3754 "Insert the MIME part under point into the current buffer using the
3756 (interactive (list nil current-prefix-arg))
3757 (gnus-article-check-buffer)
3758 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3763 (if (mm-handle-undisplayer handle)
3764 (mm-remove-part handle))
3765 (let ((gnus-newsgroup-charset
3767 gnus-summary-show-article-charset-alist))
3768 (mm-read-coding-system "Charset: ")))
3769 (gnus-newsgroup-ignored-charsets 'gnus-all))
3770 (gnus-article-press-button)))))
3772 (defun gnus-mime-externalize-part (&optional handle)
3773 "View the MIME part under point with an external viewer."
3775 (gnus-article-check-buffer)
3776 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3777 (mm-user-display-methods nil)
3778 (mm-inlined-types nil)
3779 (mail-parse-charset gnus-newsgroup-charset)
3780 (mail-parse-ignored-charsets
3781 (save-excursion (set-buffer gnus-summary-buffer)
3782 gnus-newsgroup-ignored-charsets)))
3784 (if (mm-handle-undisplayer handle)
3785 (mm-remove-part handle)
3786 (mm-display-part handle)))))
3788 (defun gnus-mime-internalize-part (&optional handle)
3789 "View the MIME part under point with an internal viewer.
3790 If no internal viewer is available, use an external viewer."
3792 (gnus-article-check-buffer)
3793 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3794 (mm-inlined-types '(".*"))
3795 (mm-inline-large-images t)
3796 (mail-parse-charset gnus-newsgroup-charset)
3797 (mail-parse-ignored-charsets
3798 (save-excursion (set-buffer gnus-summary-buffer)
3799 gnus-newsgroup-ignored-charsets)))
3801 (if (mm-handle-undisplayer handle)
3802 (mm-remove-part handle)
3803 (mm-display-part handle)))))
3805 (defun gnus-mime-action-on-part (&optional action)
3806 "Do something with the MIME attachment at \(point\)."
3808 (list (completing-read "Action: " gnus-mime-action-alist)))
3809 (gnus-article-check-buffer)
3810 (let ((action-pair (assoc action gnus-mime-action-alist)))
3812 (funcall (cdr action-pair)))))
3814 (defun gnus-article-part-wrapper (n function)
3815 (save-current-buffer
3816 (set-buffer gnus-article-buffer)
3817 (when (> n (length gnus-article-mime-handle-alist))
3818 (error "No such part"))
3819 (gnus-article-goto-part n)
3820 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3821 (funcall function handle))))
3823 (defun gnus-article-pipe-part (n)
3824 "Pipe MIME part N, which is the numerical prefix."
3826 (gnus-article-part-wrapper n 'mm-pipe-part))
3828 (defun gnus-article-save-part (n)
3829 "Save MIME part N, which is the numerical prefix."
3831 (gnus-article-part-wrapper n 'mm-save-part))
3833 (defun gnus-article-interactively-view-part (n)
3834 "View MIME part N interactively, which is the numerical prefix."
3836 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3838 (defun gnus-article-copy-part (n)
3839 "Copy MIME part N, which is the numerical prefix."
3841 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3843 (defun gnus-article-view-part-as-charset (n)
3844 "Copy MIME part N, which is the numerical prefix."
3846 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3848 (defun gnus-article-externalize-part (n)
3849 "View MIME part N externally, which is the numerical prefix."
3851 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3853 (defun gnus-article-inline-part (n)
3854 "Inline MIME part N, which is the numerical prefix."
3856 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3858 (defun gnus-article-mime-match-handle-first (condition)
3860 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3861 (while (setq ihandle (pop alist))
3863 ((functionp condition)
3864 (funcall condition (cdr ihandle)))
3865 ((eq condition 'undisplayed)
3866 (not (or (mm-handle-undisplayer (cdr ihandle))
3867 (equal (mm-handle-media-type (cdr ihandle))
3868 "multipart/alternative"))))
3869 ((eq condition 'undisplayed-alternative)
3870 (not (mm-handle-undisplayer (cdr ihandle))))
3872 (gnus-article-goto-part (car ihandle))
3873 (or (not n) (< (car ihandle) n)))
3874 (setq n (car ihandle))))
3878 (defun gnus-article-view-part (&optional n)
3879 "View MIME part N, which is the numerical prefix."
3881 (save-current-buffer
3882 (set-buffer gnus-article-buffer)
3883 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3884 gnus-article-mime-match-handle-function)))
3885 (when (> n (length gnus-article-mime-handle-alist))
3886 (error "No such part"))
3887 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3888 (when (gnus-article-goto-part n)
3889 (if (equal (car handle) "multipart/alternative")
3890 (gnus-article-press-button)
3891 (when (eq (gnus-mm-display-part handle) 'internal)
3892 (gnus-set-window-start)))))))
3894 (defsubst gnus-article-mime-total-parts ()
3895 (if (bufferp (car gnus-article-mime-handles))
3897 (1- (length gnus-article-mime-handles))))
3899 (defun gnus-mm-display-part (handle)
3900 "Display HANDLE and fix MIME button."
3901 (let ((id (get-text-property (point) 'gnus-part))
3906 (let ((window (selected-window))
3907 (mail-parse-charset gnus-newsgroup-charset)
3908 (mail-parse-ignored-charsets
3909 (save-excursion (set-buffer gnus-summary-buffer)
3910 gnus-newsgroup-ignored-charsets)))
3913 (let ((win (gnus-get-buffer-window (current-buffer) t))
3916 (select-window win))
3919 (if (mm-handle-displayed-p handle)
3920 ;; This will remove the part.
3921 (mm-display-part handle)
3923 (narrow-to-region (point)
3924 (if (eobp) (point) (1+ (point))))
3925 (mm-display-part handle)
3926 ;; We narrow to the part itself and
3927 ;; then call the treatment functions.
3928 (goto-char (point-min))
3930 (narrow-to-region (point) (point-max))
3933 (gnus-article-mime-total-parts)
3934 (mm-handle-media-type handle)))))
3935 (if (window-live-p window)
3936 (select-window window)))))
3938 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3939 (gnus-insert-mime-button
3940 handle id (list (mm-handle-displayed-p handle)))
3941 (goto-char point))))
3943 (defun gnus-article-goto-part (n)
3944 "Go to MIME part N."
3945 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3947 (goto-char point))))
3949 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3950 (let ((gnus-tmp-name
3951 (or (mail-content-type-get (mm-handle-type handle) 'name)
3952 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3953 (mail-content-type-get (mm-handle-type handle) 'url)
3955 (gnus-tmp-type (mm-handle-media-type handle))
3956 (gnus-tmp-description
3957 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3960 (if (if displayed (car displayed)
3961 (mm-handle-displayed-p handle))
3963 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3965 gnus-tmp-type-long b e)
3966 (when (string-match ".*/" gnus-tmp-name)
3967 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3968 (setq gnus-tmp-type-long (concat gnus-tmp-type
3969 (and (not (equal gnus-tmp-name ""))
3970 (concat "; " gnus-tmp-name))))
3971 (unless (equal gnus-tmp-description "")
3972 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3977 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3978 `(keymap ,gnus-mime-button-map
3979 ,@(if (>= (string-to-number emacs-version) 21)
3981 (list 'local-map gnus-mime-button-map))
3982 gnus-callback gnus-mm-display-part
3983 gnus-part ,gnus-tmp-id
3984 article-type annotation
3987 (widget-convert-button
3990 :action 'gnus-widget-press-button
3991 :button-keymap gnus-mime-button-map
3993 (lambda (widget/window &optional overlay pos)
3994 ;; Needed to properly clear the message due to a bug in
3995 ;; wid-edit (XEmacs only).
3996 (if (boundp 'help-echo-owns-message)
3997 (setq help-echo-owns-message t))
3999 "%S: %s the MIME part; %S: more options"
4000 (aref gnus-mouse-2 0)
4001 ;; XEmacs will get a single widget arg; Emacs 21 will get
4002 ;; window, overlay, position.
4003 (if (mm-handle-displayed-p
4005 (with-current-buffer (gnus-overlay-buffer overlay)
4006 (widget-get (widget-at (gnus-overlay-start overlay))
4008 (widget-get widget/window :mime-handle)))
4010 (aref gnus-down-mouse-3 0))))))
4012 (defun gnus-widget-press-button (elems el)
4013 (goto-char (widget-get elems :from))
4014 (gnus-article-press-button))
4016 (defvar gnus-displaying-mime nil)
4018 (defun gnus-display-mime (&optional ihandles)
4019 "Display the MIME parts."
4021 (save-selected-window
4022 (let ((window (get-buffer-window gnus-article-buffer))
4025 (select-window window)
4026 ;; We have to do this since selecting the window
4027 ;; may change the point. So we set the window point.
4028 (set-window-point window point)))
4029 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4030 buffer-read-only handle name type b e display)
4031 (when (and (not ihandles)
4032 (not gnus-displaying-mime))
4033 ;; Top-level call; we clean up.
4034 (when gnus-article-mime-handles
4035 (mm-destroy-parts gnus-article-mime-handles)
4036 (setq gnus-article-mime-handle-alist nil));; A trick.
4037 (setq gnus-article-mime-handles handles)
4038 ;; We allow users to glean info from the handles.
4039 (when gnus-article-mime-part-function
4040 (gnus-mime-part-function handles)))
4042 (or (not (stringp (car handles)))
4045 (when (and (not ihandles)
4046 (not gnus-displaying-mime))
4047 ;; Clean up for mime parts.
4049 (delete-region (point) (point-max)))
4050 (let ((gnus-displaying-mime t))
4051 (gnus-mime-display-part handles)))
4054 (narrow-to-region (point) (point-max))
4055 (gnus-treat-article nil 1 1)
4058 ;; Highlight the headers.
4062 (narrow-to-region (point-min) (point))
4063 (gnus-treat-article 'head))))))))
4065 (defvar gnus-mime-display-multipart-as-mixed nil)
4066 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4067 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4069 (defun gnus-mime-display-part (handle)
4072 ((not (stringp (car handle)))
4073 (gnus-mime-display-single handle))
4074 ;; User-defined multipart
4075 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4076 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4078 ;; multipart/alternative
4079 ((and (equal (car handle) "multipart/alternative")
4080 (not (or gnus-mime-display-multipart-as-mixed
4081 gnus-mime-display-multipart-alternative-as-mixed)))
4082 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4083 (push (cons id handle) gnus-article-mime-handle-alist)
4084 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4085 ;; multipart/related
4086 ((and (equal (car handle) "multipart/related")
4087 (not (or gnus-mime-display-multipart-as-mixed
4088 gnus-mime-display-multipart-related-as-mixed)))
4089 ;;;!!!We should find the start part, but we just default
4090 ;;;!!!to the first part.
4091 ;;(gnus-mime-display-part (cadr handle))
4092 ;;;!!! Most multipart/related is an HTML message plus images.
4093 ;;;!!! Unfortunately we are unable to let W3 display those
4094 ;;;!!! included images, so we just display it as a mixed multipart.
4095 ;;(gnus-mime-display-mixed (cdr handle))
4096 ;;;!!! No, w3 can display everything just fine.
4097 (gnus-mime-display-part (cadr handle)))
4098 ((equal (car handle) "multipart/signed")
4099 (gnus-add-wash-type 'signed)
4100 (gnus-mime-display-security handle))
4101 ((equal (car handle) "multipart/encrypted")
4102 (gnus-add-wash-type 'encrypted)
4103 (gnus-mime-display-security handle))
4104 ;; Other multiparts are handled like multipart/mixed.
4106 (gnus-mime-display-mixed (cdr handle)))))
4108 (defun gnus-mime-part-function (handles)
4109 (if (stringp (car handles))
4110 (mapcar 'gnus-mime-part-function (cdr handles))
4111 (funcall gnus-article-mime-part-function handles)))
4113 (defun gnus-mime-display-mixed (handles)
4114 (mapcar 'gnus-mime-display-part handles))
4116 (defun gnus-mime-display-single (handle)
4117 (let ((type (mm-handle-media-type handle))
4118 (ignored gnus-ignored-mime-types)
4125 (when (string-match (pop ignored) type)
4126 (throw 'ignored nil)))
4127 (if (and (setq not-attachment
4128 (and (not (mm-inline-override-p handle))
4129 (or (not (mm-handle-disposition handle))
4130 (equal (car (mm-handle-disposition handle))
4132 (mm-attachment-override-p handle))))
4133 (mm-automatic-display-p handle)
4135 (mm-inlinable-p handle)
4136 (mm-inlined-p handle))
4137 (mm-automatic-external-display-p type)))
4139 (when (equal (mm-handle-media-supertype handle) "text")
4141 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4143 (push (cons id handle) gnus-article-mime-handle-alist)
4144 (when (or (not display)
4145 (not (gnus-unbuttonized-mime-type-p type)))
4146 ;(gnus-article-insert-newline)
4147 (gnus-insert-mime-button
4148 handle id (list (or display (and not-attachment text))))
4149 (gnus-article-insert-newline)
4150 ;(gnus-article-insert-newline)
4151 ;; Remember modify the number of forward lines.
4159 (let ((mail-parse-charset gnus-newsgroup-charset)
4160 (mail-parse-ignored-charsets
4161 (save-excursion (condition-case ()
4162 (set-buffer gnus-summary-buffer)
4164 gnus-newsgroup-ignored-charsets)))
4165 (mm-display-part handle t))
4166 (goto-char (point-max)))
4167 ((and text not-attachment)
4171 (gnus-article-insert-newline)
4172 (mm-insert-inline handle (mm-get-part handle))
4173 (goto-char (point-max))))
4177 (narrow-to-region beg (point))
4180 (gnus-article-mime-total-parts)
4181 (mm-handle-media-type handle)))))))))
4183 (defun gnus-unbuttonized-mime-type-p (type)
4184 "Say whether TYPE is to be unbuttonized."
4185 (unless gnus-inhibit-mime-unbuttonizing
4187 (let ((types gnus-unbuttonized-mime-types))
4189 (when (string-match (pop types) type)
4190 (throw 'found t)))))
4192 (let ((types gnus-buttonized-mime-types))
4194 (when (string-match (pop types) type)
4195 (throw 'found t)))))))))
4197 (defun gnus-article-insert-newline ()
4198 "Insert a newline, but mark it as undeletable."
4199 (gnus-put-text-property
4200 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4202 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4203 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4206 handle buffer-read-only from props begend not-pref)
4207 (save-window-excursion
4210 (narrow-to-region (car ibegend)
4213 (goto-char (car ibegend))
4216 (delete-region (point-min) (point-max))
4217 (mm-remove-parts handles))
4218 (setq begend (list (point-marker)))
4220 (unless (setq not-pref (cadr (member preferred ihandles)))
4221 (setq not-pref (car ihandles)))
4224 (not (gnus-unbuttonized-mime-type-p
4225 "multipart/alternative")))
4226 (gnus-add-text-properties
4229 (insert (format "%d. " id))
4233 (unless ,(not ibegend)
4234 (setq gnus-article-mime-handle-alist
4235 ',gnus-article-mime-handle-alist))
4236 (gnus-mime-display-alternative
4237 ',ihandles ',not-pref ',begend ,id))
4238 ,@(if (>= (string-to-number emacs-version) 21)
4239 nil ;; XEmacs doesn't care
4240 (list 'local-map gnus-mime-button-map))
4241 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4242 face ,gnus-article-button-face
4243 keymap ,gnus-mime-button-map
4246 (widget-convert-button 'link from (point)
4247 :action 'gnus-widget-press-button
4248 :button-keymap gnus-widget-button-keymap)
4250 (while (setq handle (pop handles))
4251 (gnus-add-text-properties
4254 (insert (format "(%c) %-18s"
4255 (if (equal handle preferred) ?* ? )
4256 (mm-handle-media-type handle)))
4260 (unless ,(not ibegend)
4261 (setq gnus-article-mime-handle-alist
4262 ',gnus-article-mime-handle-alist))
4263 (gnus-mime-display-alternative
4264 ',ihandles ',handle ',begend ,id))
4265 ,@(if (>= (string-to-number emacs-version) 21)
4266 nil ;; XEmacs doesn't care
4267 (list 'local-map gnus-mime-button-map))
4268 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4269 face ,gnus-article-button-face
4270 keymap ,gnus-mime-button-map
4273 (widget-convert-button 'link from (point)
4274 :action 'gnus-widget-press-button
4275 :button-keymap gnus-widget-button-keymap)
4279 (if (stringp (car preferred))
4280 (gnus-display-mime preferred)
4281 (let ((mail-parse-charset gnus-newsgroup-charset)
4282 (mail-parse-ignored-charsets
4283 (save-excursion (set-buffer gnus-summary-buffer)
4284 gnus-newsgroup-ignored-charsets)))
4285 (mm-display-part preferred)
4289 (narrow-to-region (car begend) (point-max))
4291 nil (length gnus-article-mime-handle-alist)
4292 (gnus-article-mime-total-parts)
4293 (mm-handle-media-type handle))))))
4294 (goto-char (point-max))
4295 (setcdr begend (point-marker)))))
4297 (goto-char point))))
4299 (defconst gnus-article-wash-status-strings
4300 (let ((alist '((cite "c" "Possible hidden citation text"
4301 " " "All citation text visible")
4302 (headers "h" "Hidden headers"
4303 " " "All headers visible.")
4304 (pgp "p" "Encrypted or signed message status hidden"
4305 " " "No hidden encryption nor digital signature status")
4306 (signature "s" "Signature has been hidden"
4307 " " "Signature is visible")
4308 (overstrike "o" "Overstrike (^H) characters applied"
4309 " " "No overstrike characters applied")
4310 (emphasis "e" "/*_Emphasis_*/ characters applied"
4311 " " "No /*_emphasis_*/ characters applied")))
4313 (dolist (entry alist result)
4314 (let ((key (nth 0 entry))
4315 (on (copy-sequence (nth 1 entry)))
4316 (on-help (nth 2 entry))
4317 (off (copy-sequence (nth 3 entry)))
4318 (off-help (nth 4 entry)))
4319 (put-text-property 0 1 'help-echo on-help on)
4320 (put-text-property 0 1 'help-echo off-help off)
4321 (push (list key on off) result))))
4322 "Alist of strings describing wash status in the mode line.
4323 Each entry has the form (KEY ON OF), where the KEY is a symbol
4324 representing the particular washing function, ON is the string to use
4325 in the article mode line when the washing function is active, and OFF
4326 is the string to use when it is inactive.")
4328 (defun gnus-article-wash-status-entry (key value)
4329 (let ((entry (assoc key gnus-article-wash-status-strings)))
4330 (if value (nth 1 entry) (nth 2 entry))))
4332 (defun gnus-article-wash-status ()
4333 "Return a string which display status of article washing."
4335 (set-buffer gnus-article-buffer)
4336 (let ((cite (memq 'cite gnus-article-wash-types))
4337 (headers (memq 'headers gnus-article-wash-types))
4338 (boring (memq 'boring-headers gnus-article-wash-types))
4339 (pgp (memq 'pgp gnus-article-wash-types))
4340 (pem (memq 'pem gnus-article-wash-types))
4341 (signed (memq 'signed gnus-article-wash-types))
4342 (encrypted (memq 'encrypted gnus-article-wash-types))
4343 (signature (memq 'signature gnus-article-wash-types))
4344 (overstrike (memq 'overstrike gnus-article-wash-types))
4345 (emphasis (memq 'emphasis gnus-article-wash-types)))
4347 (gnus-article-wash-status-entry 'cite cite)
4348 (gnus-article-wash-status-entry 'headers (or headers boring))
4349 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4350 (gnus-article-wash-status-entry 'signature signature)
4351 (gnus-article-wash-status-entry 'overstrike overstrike)
4352 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4354 (defun gnus-add-wash-type (type)
4355 "Add a washing of TYPE to the current status."
4356 (push type gnus-article-wash-types))
4358 (defun gnus-delete-wash-type (type)
4359 "Add a washing of TYPE to the current status."
4360 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4362 (defun gnus-add-image (category image)
4363 "Add IMAGE of CATEGORY to the list of displayed images."
4364 (let ((entry (assq category gnus-article-image-alist)))
4366 (setq entry (list category))
4367 (push entry gnus-article-image-alist))
4368 (nconc entry (list image))))
4370 (defun gnus-delete-images (category)
4371 "Delete all images in CATEGORY."
4372 (let ((entry (assq category gnus-article-image-alist)))
4373 (dolist (image (cdr entry))
4374 (gnus-remove-image image))
4375 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4376 (gnus-delete-wash-type category)))
4378 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4380 (defun gnus-article-maybe-hide-headers ()
4381 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4382 Provided for backwards compatibility."
4383 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4384 (not (save-excursion (set-buffer gnus-summary-buffer)
4385 gnus-have-all-headers)))
4386 (not gnus-inhibit-hiding))
4387 (gnus-article-hide-headers)))
4391 (defun gnus-output-to-file (file-name)
4392 "Append the current article to a file named FILE-NAME."
4393 (let ((artbuf (current-buffer)))
4395 (insert-buffer-substring artbuf)
4396 ;; Append newline at end of the buffer as separator, and then
4398 (goto-char (point-max))
4400 (let ((file-name-coding-system nnmail-pathname-coding-system))
4401 (mm-append-to-file (point-min) (point-max) file-name))
4404 (defun gnus-narrow-to-page (&optional arg)
4405 "Narrow the article buffer to a page.
4406 If given a numerical ARG, move forward ARG pages."
4408 (setq arg (if arg (prefix-numeric-value arg) 0))
4410 (set-buffer gnus-article-buffer)
4411 (goto-char (point-min))
4413 ;; Remove any old next/prev buttons.
4414 (when (gnus-visual-p 'page-marker)
4415 (let ((buffer-read-only nil))
4416 (gnus-remove-text-with-property 'gnus-prev)
4417 (gnus-remove-text-with-property 'gnus-next)))
4420 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4422 (re-search-forward page-delimiter nil 'move arg)))
4423 (goto-char (match-end 0)))
4426 (if (re-search-forward page-delimiter nil 'move)
4429 (when (and (gnus-visual-p 'page-marker)
4430 (not (= (point-min) 1)))
4432 (goto-char (point-min))
4433 (gnus-insert-prev-page-button)))
4434 (when (and (gnus-visual-p 'page-marker)
4435 (< (+ (point-max) 2) (buffer-size)))
4437 (goto-char (point-max))
4438 (gnus-insert-next-page-button)))))
4440 ;; Article mode commands
4442 (defun gnus-article-goto-next-page ()
4443 "Show the next page of the article."
4445 (when (gnus-article-next-page)
4446 (goto-char (point-min))
4447 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4449 (defun gnus-article-goto-prev-page ()
4450 "Show the next page of the article."
4452 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4453 (gnus-article-prev-page nil)))
4455 (defun gnus-article-next-page (&optional lines)
4456 "Show the next page of the current article.
4457 If end of article, return non-nil. Otherwise return nil.
4458 Argument LINES specifies lines to be scrolled up."
4460 (move-to-window-line -1)
4463 (and (pos-visible-in-window-p) ;Not continuation line.
4465 ;; Nothing in this page.
4466 (if (or (not gnus-page-broken)
4469 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4471 (gnus-narrow-to-page 1) ;Go to next page.
4473 ;; More in this page.
4474 (let ((scroll-in-place nil))
4478 ;; Long lines may cause an end-of-buffer error.
4479 (goto-char (point-max)))))
4480 (move-to-window-line 0)
4483 (defun gnus-article-prev-page (&optional lines)
4484 "Show previous page of current article.
4485 Argument LINES specifies lines to be scrolled down."
4487 (move-to-window-line 0)
4488 (if (and gnus-page-broken
4490 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4492 (gnus-narrow-to-page -1) ;Go to previous page.
4493 (goto-char (point-max))
4495 (let ((scroll-in-place nil))
4499 (beginning-of-buffer
4500 (goto-char (point-min))))
4501 (move-to-window-line 0)))))
4503 (defun gnus-article-refer-article ()
4504 "Read article specified by message-id around point."
4506 (let ((point (point)))
4507 (search-forward ">" nil t) ;Move point to end of "<....>".
4508 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4509 (let ((message-id (match-string 1)))
4511 (set-buffer gnus-summary-buffer)
4512 (gnus-summary-refer-article message-id))
4514 (error "No references around point"))))
4516 (defun gnus-article-show-summary ()
4517 "Reconfigure windows to show summary buffer."
4519 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4520 (error "There is no summary buffer for this article buffer")
4521 (gnus-article-set-globals)
4522 (gnus-configure-windows 'article)
4523 (gnus-summary-goto-subject gnus-current-article)
4524 (gnus-summary-position-point)))
4526 (defun gnus-article-describe-briefly ()
4527 "Describe article mode commands briefly."
4529 (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")))
4531 (defun gnus-article-summary-command ()
4532 "Execute the last keystroke in the summary buffer."
4534 (let ((obuf (current-buffer))
4535 (owin (current-window-configuration))
4537 (switch-to-buffer gnus-article-current-summary 'norecord)
4538 (setq func (lookup-key (current-local-map) (this-command-keys)))
4539 (call-interactively func)
4541 (set-window-configuration owin)
4542 (set-window-point (get-buffer-window (current-buffer)) (point))))
4544 (defun gnus-article-summary-command-nosave ()
4545 "Execute the last keystroke in the summary buffer."
4548 (pop-to-buffer gnus-article-current-summary 'norecord)
4549 (setq func (lookup-key (current-local-map) (this-command-keys)))
4550 (call-interactively func)))
4552 (defun gnus-article-check-buffer ()
4553 "Beep if not in an article buffer."
4554 (unless (equal major-mode 'gnus-article-mode)
4555 (error "Command invoked outside of a Gnus article buffer")))
4557 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4558 "Read a summary buffer key sequence and execute it from the article buffer."
4560 (gnus-article-check-buffer)
4562 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4563 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4564 "=" "^" "\M-^" "|"))
4570 '("n" "Gn" "p" "Gp"))
4573 (set-buffer gnus-article-current-summary)
4574 (let (gnus-pick-mode)
4575 (push (or key last-command-event) unread-command-events)
4576 (setq keys (if (featurep 'xemacs)
4577 (events-to-keys (read-key-sequence nil))
4578 (read-key-sequence nil)))))
4582 (if (or (member keys nosaves)
4583 (member keys nosave-but-article)
4584 (member keys nosave-in-article))
4586 (save-window-excursion
4587 (pop-to-buffer gnus-article-current-summary 'norecord)
4588 ;; We disable the pick minor mode commands.
4589 (let (gnus-pick-mode)
4590 (setq func (lookup-key (current-local-map) keys))))
4594 (unless (member keys nosave-in-article)
4595 (set-buffer gnus-article-current-summary))
4596 (call-interactively func)
4597 (setq new-sum-point (point)))
4598 (when (member keys nosave-but-article)
4599 (pop-to-buffer gnus-article-buffer 'norecord)))
4600 ;; These commands should restore window configuration.
4601 (let ((obuf (current-buffer))
4602 (owin (current-window-configuration))
4604 (summary gnus-article-current-summary)
4605 func in-buffer selected)
4606 (if not-restore-window
4607 (pop-to-buffer summary 'norecord)
4608 (switch-to-buffer summary 'norecord))
4609 (setq in-buffer (current-buffer))
4610 ;; We disable the pick minor mode commands.
4611 (if (and (setq func (let (gnus-pick-mode)
4612 (lookup-key (current-local-map) keys)))
4615 (call-interactively func)
4616 (setq new-sum-point (point))
4617 (when (eq in-buffer (current-buffer))
4618 (setq selected (gnus-summary-select-article))
4620 (unless not-restore-window
4621 (set-window-configuration owin))
4622 (when (eq selected 'old)
4624 (set-window-start (get-buffer-window (current-buffer))
4626 (set-window-point (get-buffer-window (current-buffer))
4628 (let ((win (get-buffer-window gnus-article-current-summary)))
4630 (set-window-point win new-sum-point)))) )
4631 (switch-to-buffer gnus-article-buffer)
4634 (defun gnus-article-describe-key (key)
4635 "Display documentation of the function invoked by KEY. KEY is a string."
4636 (interactive "kDescribe key: ")
4637 (gnus-article-check-buffer)
4638 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4640 (set-buffer gnus-article-current-summary)
4641 (let (gnus-pick-mode)
4642 (if (featurep 'xemacs)
4644 (push (elt key 0) unread-command-events)
4645 (setq key (events-to-keys
4646 (read-key-sequence "Describe key: "))))
4647 (setq unread-command-events
4649 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4650 (string-to-list key)))
4651 (setq key (read-key-sequence "Describe key: "))))
4653 (describe-key key)))
4655 (defun gnus-article-describe-key-briefly (key &optional insert)
4656 "Display documentation of the function invoked by KEY. KEY is a string."
4657 (interactive "kDescribe key: \nP")
4658 (gnus-article-check-buffer)
4659 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4661 (set-buffer gnus-article-current-summary)
4662 (let (gnus-pick-mode)
4663 (if (featurep 'xemacs)
4665 (push (elt key 0) unread-command-events)
4666 (setq key (events-to-keys
4667 (read-key-sequence "Describe key: "))))
4668 (setq unread-command-events
4670 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4671 (string-to-list key)))
4672 (setq key (read-key-sequence "Describe key: "))))
4673 (describe-key-briefly key insert))
4674 (describe-key-briefly key insert)))
4676 (defun gnus-article-reply-with-original (&optional wide)
4677 "Start composing a reply mail to the current message.
4678 The text in the region will be yanked. If the region isn't active,
4679 the entire article will be yanked."
4681 (let ((article (cdr gnus-article-current)))
4682 (if (not mark-active)
4683 (gnus-summary-reply (list (list article)) wide)
4685 (list (list article (buffer-substring (point) (mark)))) wide))))
4687 (defun gnus-article-followup-with-original ()
4688 "Compose a followup to the current article.
4689 The text in the region will be yanked. If the region isn't active,
4690 the entire article will be yanked."
4692 (let ((article (cdr gnus-article-current)))
4693 (if (not mark-active)
4694 (gnus-summary-followup (list (list article)))
4695 (gnus-summary-followup
4696 (list (list article (buffer-substring (point) (mark))))))))
4698 (defun gnus-article-hide (&optional arg force)
4699 "Hide all the gruft in the current article.
4700 This means that PGP stuff, signatures, cited text and (some)
4701 headers will be hidden.
4702 If given a prefix, show the hidden text instead."
4703 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4704 (gnus-article-hide-headers arg)
4705 (gnus-article-hide-list-identifiers arg)
4706 (gnus-article-hide-pgp arg)
4707 (gnus-article-hide-citation-maybe arg force)
4708 (gnus-article-hide-signature arg))
4710 (defun gnus-article-maybe-highlight ()
4711 "Do some article highlighting if article highlighting is requested."
4712 (when (gnus-visual-p 'article-highlight 'highlight)
4713 (gnus-article-highlight-some)))
4715 (defun gnus-check-group-server ()
4716 ;; Make sure the connection to the server is alive.
4717 (unless (gnus-server-opened
4718 (gnus-find-method-for-group gnus-newsgroup-name))
4719 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4720 (gnus-request-group gnus-newsgroup-name t)))
4722 (defun gnus-request-article-this-buffer (article group)
4723 "Get an article and insert it into this buffer."
4724 (let (do-update-line sparse-header)
4728 (gnus-kill-all-overlays)
4729 (setq group (or group gnus-newsgroup-name))
4731 ;; Using `gnus-request-article' directly will insert the article into
4732 ;; `nntp-server-buffer' - so we'll save some time by not having to
4733 ;; copy it from the server buffer into the article buffer.
4735 ;; We only request an article by message-id when we do not have the
4736 ;; headers for it, so we'll have to get those.
4737 (when (stringp article)
4738 (gnus-read-header article))
4740 ;; If the article number is negative, that means that this article
4741 ;; doesn't belong in this newsgroup (possibly), so we find its
4742 ;; message-id and request it by id instead of number.
4743 (when (and (numberp article)
4745 (get-buffer gnus-summary-buffer)
4746 (gnus-buffer-exists-p gnus-summary-buffer))
4748 (set-buffer gnus-summary-buffer)
4749 (let ((header (gnus-summary-article-header article)))
4752 ((memq article gnus-newsgroup-sparse)
4753 ;; This is a sparse gap article.
4754 (setq do-update-line article)
4755 (setq article (mail-header-id header))
4756 (setq sparse-header (gnus-read-header article))
4757 (setq gnus-newsgroup-sparse
4758 (delq article gnus-newsgroup-sparse)))
4760 ;; It's a real article.
4761 (setq article (mail-header-id header)))
4763 ;; It is an extracted pseudo-article.
4764 (setq article 'pseudo)
4765 (gnus-request-pseudo-article header))))
4767 (let ((method (gnus-find-method-for-group
4768 gnus-newsgroup-name)))
4769 (when (and (eq (car method) 'nneething)
4771 (let ((dir (expand-file-name
4772 (mail-header-subject header)
4773 (file-name-as-directory
4774 (or (cadr (assq 'nneething-address method))
4776 (when (file-directory-p dir)
4777 (setq article 'nneething)
4778 (gnus-group-enter-directory dir))))))))
4781 ;; Refuse to select canceled articles.
4782 ((and (numberp article)
4784 (get-buffer gnus-summary-buffer)
4785 (gnus-buffer-exists-p gnus-summary-buffer)
4786 (eq (cdr (save-excursion
4787 (set-buffer gnus-summary-buffer)
4788 (assq article gnus-newsgroup-reads)))
4789 gnus-canceled-mark))
4791 ;; We first check `gnus-original-article-buffer'.
4792 ((and (get-buffer gnus-original-article-buffer)
4795 (set-buffer gnus-original-article-buffer)
4796 (and (equal (car gnus-original-article) group)
4797 (eq (cdr gnus-original-article) article))))
4798 (insert-buffer-substring gnus-original-article-buffer)
4800 ;; Check the backlog.
4801 ((and gnus-keep-backlog
4802 (gnus-backlog-request-article group article (current-buffer)))
4804 ;; Check asynchronous pre-fetch.
4805 ((gnus-async-request-fetched-article group article (current-buffer))
4806 (gnus-async-prefetch-next group article gnus-summary-buffer)
4807 (when (and (numberp article) gnus-keep-backlog)
4808 (gnus-backlog-enter-article group article (current-buffer)))
4811 ((and gnus-use-cache
4813 (gnus-cache-request-article article group))
4815 ;; Get the article and put into the article buffer.
4816 ((or (stringp article)
4818 (let ((gnus-override-method gnus-override-method)
4819 (methods (and (stringp article)
4820 gnus-refer-article-method))
4822 (buffer-read-only nil))
4823 (if (or (not (listp methods))
4824 (and (symbolp (car methods))
4825 (assq (car methods) nnoo-definition-alist)))
4826 (setq methods (list methods)))
4827 (when (and (null gnus-override-method)
4829 (setq gnus-override-method (pop methods)))
4831 (when (eq gnus-override-method 'current)
4832 (setq gnus-override-method
4833 (with-current-buffer gnus-summary-buffer
4834 gnus-current-select-method)))
4836 (gnus-kill-all-overlays)
4837 (let ((gnus-newsgroup-name group))
4838 (gnus-check-group-server))
4839 (when (gnus-request-article article group (current-buffer))
4840 (when (numberp article)
4841 (gnus-async-prefetch-next group article
4842 gnus-summary-buffer)
4843 (when gnus-keep-backlog
4844 (gnus-backlog-enter-article
4845 group article (current-buffer))))
4846 (setq result 'article))
4849 (setq gnus-override-method (pop methods))
4850 (setq result 'done))))
4851 (and (eq result 'article) 'article)))
4855 ;; Associate this article with the current summary buffer.
4856 (setq gnus-article-current-summary gnus-summary-buffer)
4858 ;; Take the article from the original article buffer
4859 ;; and place it in the buffer it's supposed to be in.
4860 (when (and (get-buffer gnus-article-buffer)
4861 (equal (buffer-name (current-buffer))
4862 (buffer-name (get-buffer gnus-article-buffer))))
4864 (if (get-buffer gnus-original-article-buffer)
4865 (set-buffer gnus-original-article-buffer)
4866 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4867 (buffer-disable-undo)
4868 (setq major-mode 'gnus-original-article-mode)
4869 (setq buffer-read-only t))
4870 (let (buffer-read-only)
4872 (insert-buffer-substring gnus-article-buffer))
4873 (setq gnus-original-article (cons group article)))
4876 (run-hooks 'gnus-article-decode-hook)
4877 ;; Mark article as decoded or not.
4878 (setq gnus-article-decoded-p gnus-article-decode-hook))
4880 ;; Update sparse articles.
4881 (when (and do-update-line
4882 (or (numberp article)
4884 (let ((buf (current-buffer)))
4885 (set-buffer gnus-summary-buffer)
4886 (gnus-summary-update-article do-update-line sparse-header)
4887 (gnus-summary-goto-subject do-update-line nil t)
4888 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4890 (set-buffer buf))))))
4896 (defcustom gnus-article-edit-mode-hook nil
4897 "Hook run in article edit mode buffers."
4898 :group 'gnus-article-various
4901 (defvar gnus-article-edit-done-function nil)
4903 (defvar gnus-article-edit-mode-map nil)
4905 ;; Should we be using derived.el for this?
4906 (unless gnus-article-edit-mode-map
4907 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4908 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4910 (gnus-define-keys gnus-article-edit-mode-map
4911 "\C-c\C-c" gnus-article-edit-done
4912 "\C-c\C-k" gnus-article-edit-exit)
4914 (gnus-define-keys (gnus-article-edit-wash-map
4915 "\C-c\C-w" gnus-article-edit-mode-map)
4916 "f" gnus-article-edit-full-stops))
4918 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4919 "Major mode for editing articles.
4920 This is an extended text-mode.
4922 \\{gnus-article-edit-mode-map}"
4923 (make-local-variable 'gnus-article-edit-done-function)
4924 (make-local-variable 'gnus-prev-winconf)
4925 (set (make-local-variable 'font-lock-defaults)
4926 '(message-font-lock-keywords t))
4927 (setq buffer-read-only nil)
4928 (buffer-enable-undo)
4931 (defun gnus-article-edit (&optional force)
4932 "Edit the current article.
4933 This will have permanent effect only in mail groups.
4934 If FORCE is non-nil, allow editing of articles even in read-only
4937 (when (and (not force)
4938 (gnus-group-read-only-p))
4939 (error "The current newsgroup does not support article editing"))
4940 (gnus-article-date-original)
4941 (gnus-article-edit-article
4943 `(lambda (no-highlight)
4945 (gnus-summary-edit-article-done
4946 ,(or (mail-header-references gnus-current-headers) "")
4947 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4949 (defun gnus-article-edit-article (start-func exit-func)
4950 "Start editing the contents of the current article buffer."
4951 (let ((winconf (current-window-configuration)))
4952 (set-buffer gnus-article-buffer)
4953 (gnus-article-edit-mode)
4954 (funcall start-func)
4955 (set-buffer-modified-p nil)
4956 (gnus-configure-windows 'edit-article)
4957 (setq gnus-article-edit-done-function exit-func)
4958 (setq gnus-prev-winconf winconf)
4959 (gnus-message 6 "C-c C-c to end edits")))
4961 (defun gnus-article-edit-done (&optional arg)
4962 "Update the article edits and exit."
4964 (let ((func gnus-article-edit-done-function)
4965 (buf (current-buffer))
4966 (start (window-start)))
4967 ;; We remove all text props from the article buffer.
4969 (buffer-substring-no-properties (point-min) (point-max)))
4973 (let ((winconf gnus-prev-winconf))
4975 (set-window-configuration winconf)
4976 ;; Tippy-toe some to make sure that point remains where it was.
4977 (save-current-buffer
4979 (set-window-start (get-buffer-window (current-buffer)) start)
4983 (let ((buffer-read-only nil))
4985 ;; The cache and backlog have to be flushed somewhat.
4986 (when gnus-keep-backlog
4987 (gnus-backlog-remove-article
4988 (car gnus-article-current) (cdr gnus-article-current)))
4989 ;; Flush original article as well.
4991 (when (get-buffer gnus-original-article-buffer)
4992 (set-buffer gnus-original-article-buffer)
4993 (setq gnus-original-article nil)))
4994 (when gnus-use-cache
4995 (gnus-cache-update-article
4996 (car gnus-article-current) (cdr gnus-article-current))))
4998 (set-window-start (get-buffer-window buf) start)
4999 (set-window-point (get-buffer-window buf) (point))))
5001 (defun gnus-article-edit-exit ()
5002 "Exit the article editing without updating."
5004 (when (or (not (buffer-modified-p))
5005 (yes-or-no-p "Article modified; kill anyway? "))
5006 (let ((curbuf (current-buffer))
5008 (window-start (window-start)))
5010 (if (gnus-buffer-live-p gnus-original-article-buffer)
5011 (insert-buffer gnus-original-article-buffer))
5012 (let ((winconf gnus-prev-winconf))
5014 (set-window-configuration winconf)
5015 ;; Tippy-toe some to make sure that point remains where it was.
5016 (save-current-buffer
5018 (set-window-start (get-buffer-window (current-buffer)) window-start)
5021 (defun gnus-article-edit-full-stops ()
5022 "Interactively repair spacing at end of sentences."
5025 (goto-char (point-min))
5026 (search-forward-regexp "^$" nil t)
5027 (let ((case-fold-search nil))
5028 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5031 ;;; Article highlights
5034 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5036 ;;; Internal Variables:
5038 (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\\)\\)"
5039 "Regular expression that matches URLs."
5040 :group 'gnus-article-buttons
5043 (defcustom gnus-button-alist
5044 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5045 0 t gnus-button-handle-news 3)
5046 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5047 gnus-button-handle-news 2)
5048 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5050 gnus-button-fetch-group 4)
5051 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5052 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5053 t gnus-button-message-id 3)
5054 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5055 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5056 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5058 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5059 gnus-button-handle-info 2)
5060 ;; This is how URLs _should_ be embedded in text...
5061 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5063 (,gnus-button-url-regexp 0 t browse-url 0))
5064 "*Alist of regexps matching buttons in article bodies.
5066 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5067 REGEXP: is the string matching text around the button,
5068 BUTTON: is the number of the regexp grouping actually matching the button,
5069 FORM: is a lisp expression which must eval to true for the button to
5071 CALLBACK: is the function to call when the user push this button, and each
5072 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5074 CALLBACK can also be a variable, in that case the value of that
5075 variable it the real callback function."
5076 :group 'gnus-article-buttons
5077 :type '(repeat (list regexp
5078 (integer :tag "Button")
5080 (function :tag "Callback")
5083 (integer :tag "Regexp group")))))
5085 (defcustom gnus-header-button-alist
5086 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5087 0 t gnus-button-message-id 0)
5088 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5089 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5090 0 t gnus-button-mailto 0)
5091 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5092 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5093 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5094 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5095 gnus-button-message-id 3))
5096 "*Alist of headers and regexps to match buttons in article heads.
5098 This alist is very similar to `gnus-button-alist', except that each
5099 alist has an additional HEADER element first in each entry:
5101 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5103 HEADER is a regexp to match a header. For a fuller explanation, see
5104 `gnus-button-alist'."
5105 :group 'gnus-article-buttons
5106 :group 'gnus-article-headers
5107 :type '(repeat (list (regexp :tag "Header")
5109 (integer :tag "Button")
5111 (function :tag "Callback")
5114 (integer :tag "Regexp group")))))
5116 (defvar gnus-button-regexp nil)
5117 (defvar gnus-button-marker-list nil)
5118 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5120 (defvar gnus-button-last nil)
5121 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5125 (defun gnus-article-push-button (event)
5126 "Check text under the mouse pointer for a callback function.
5127 If the text under the mouse pointer has a `gnus-callback' property,
5128 call it with the value of the `gnus-data' text property."
5130 (set-buffer (window-buffer (posn-window (event-start event))))
5131 (let* ((pos (posn-point (event-start event)))
5132 (data (get-text-property pos 'gnus-data))
5133 (fun (get-text-property pos 'gnus-callback)))
5136 (funcall fun data))))
5138 (defun gnus-article-press-button ()
5139 "Check text at point for a callback function.
5140 If the text at point has a `gnus-callback' property,
5141 call it with the value of the `gnus-data' text property."
5143 (let* ((data (get-text-property (point) 'gnus-data))
5144 (fun (get-text-property (point) 'gnus-callback)))
5146 (funcall fun data))))
5148 (defun gnus-article-highlight (&optional force)
5149 "Highlight current article.
5150 This function calls `gnus-article-highlight-headers',
5151 `gnus-article-highlight-citation',
5152 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5153 do the highlighting. See the documentation for those functions."
5154 (interactive (list 'force))
5155 (gnus-article-highlight-headers)
5156 (gnus-article-highlight-citation force)
5157 (gnus-article-highlight-signature)
5158 (gnus-article-add-buttons force)
5159 (gnus-article-add-buttons-to-head))
5161 (defun gnus-article-highlight-some (&optional force)
5162 "Highlight current article.
5163 This function calls `gnus-article-highlight-headers',
5164 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5165 do the highlighting. See the documentation for those functions."
5166 (interactive (list 'force))
5167 (gnus-article-highlight-headers)
5168 (gnus-article-highlight-signature)
5169 (gnus-article-add-buttons))
5171 (defun gnus-article-highlight-headers ()
5172 "Highlight article headers as specified by `gnus-header-face-alist'."
5175 (set-buffer gnus-article-buffer)
5177 (let ((alist gnus-header-face-alist)
5178 (buffer-read-only nil)
5179 (case-fold-search t)
5180 (inhibit-point-motion-hooks t)
5181 entry regexp header-face field-face from hpoints fpoints)
5182 (article-narrow-to-head)
5183 (while (setq entry (pop alist))
5184 (goto-char (point-min))
5185 (setq regexp (concat "^\\("
5186 (if (string-equal "" (nth 0 entry))
5190 header-face (nth 1 entry)
5191 field-face (nth 2 entry))
5192 (while (and (re-search-forward regexp nil t)
5196 (unless (search-forward ":" nil t)
5198 (when (and header-face
5199 (not (memq (point) hpoints)))
5200 (push (point) hpoints)
5201 (gnus-put-text-property from (point) 'face header-face))
5202 (when (and field-face
5203 (not (memq (setq from (point)) fpoints)))
5205 (if (re-search-forward "^[^ \t]" nil t)
5207 (goto-char (point-max)))
5208 (gnus-put-text-property from (point) 'face field-face))))))))
5210 (defun gnus-article-highlight-signature ()
5211 "Highlight the signature in an article.
5212 It does this by highlighting everything after
5213 `gnus-signature-separator' using `gnus-signature-face'."
5216 (set-buffer gnus-article-buffer)
5217 (let ((buffer-read-only nil)
5218 (inhibit-point-motion-hooks t))
5220 (when (and gnus-signature-face
5221 (gnus-article-narrow-to-signature))
5222 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5223 'face gnus-signature-face)
5225 (gnus-article-search-signature)
5226 (let ((start (match-beginning 0))
5227 (end (set-marker (make-marker) (1+ (match-end 0)))))
5228 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5231 (defun gnus-button-in-region-p (b e prop)
5232 "Say whether PROP exists in the region."
5233 (text-property-not-all b e prop nil))
5235 (defun gnus-article-add-buttons (&optional force)
5236 "Find external references in the article and make buttons of them.
5237 \"External references\" are things like Message-IDs and URLs, as
5238 specified by `gnus-button-alist'."
5239 (interactive (list 'force))
5241 (set-buffer gnus-article-buffer)
5242 (let ((buffer-read-only nil)
5243 (inhibit-point-motion-hooks t)
5244 (case-fold-search t)
5245 (alist gnus-button-alist)
5247 ;; Remove all old markers.
5248 (let (marker entry new-list)
5249 (while (setq marker (pop gnus-button-marker-list))
5250 (if (or (< marker (point-min)) (>= marker (point-max)))
5251 (push marker new-list)
5253 (when (setq entry (gnus-button-entry))
5254 (put-text-property (match-beginning (nth 1 entry))
5255 (match-end (nth 1 entry))
5256 'gnus-callback nil))
5257 (set-marker marker nil)))
5258 (setq gnus-button-marker-list new-list))
5259 ;; We skip the headers.
5262 (while (setq entry (pop alist))
5263 (setq regexp (car entry))
5265 (while (re-search-forward regexp nil t)
5266 (let* ((start (and entry (match-beginning (nth 1 entry))))
5267 (end (and entry (match-end (nth 1 entry))))
5268 (from (match-beginning 0)))
5269 (when (and (or (eq t (nth 2 entry))
5270 (eval (nth 2 entry)))
5271 (not (gnus-button-in-region-p
5272 start end 'gnus-callback)))
5273 ;; That optional form returned non-nil, so we add the
5275 (gnus-article-add-button
5276 start end 'gnus-button-push
5277 (car (push (set-marker (make-marker) from)
5278 gnus-button-marker-list))))))))))
5280 ;; Add buttons to the head of an article.
5281 (defun gnus-article-add-buttons-to-head ()
5282 "Add buttons to the head of the article."
5285 (set-buffer gnus-article-buffer)
5287 (let ((buffer-read-only nil)
5288 (inhibit-point-motion-hooks t)
5289 (case-fold-search t)
5290 (alist gnus-header-button-alist)
5292 (article-narrow-to-head)
5294 ;; Each alist entry.
5295 (setq entry (car alist)
5297 (goto-char (point-min))
5298 (while (re-search-forward (car entry) nil t)
5299 ;; Each header matching the entry.
5300 (setq beg (match-beginning 0))
5301 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5302 (match-beginning 0))
5305 (while (re-search-forward (nth 1 entry) end t)
5306 ;; Each match within a header.
5307 (let* ((entry (cdr entry))
5308 (start (match-beginning (nth 1 entry)))
5309 (end (match-end (nth 1 entry)))
5310 (form (nth 2 entry)))
5311 (goto-char (match-end 0))
5313 (gnus-article-add-button
5314 start end (nth 3 entry)
5315 (buffer-substring (match-beginning (nth 4 entry))
5316 (match-end (nth 4 entry)))))))
5317 (goto-char end)))))))
5319 ;;; External functions:
5321 (defun gnus-article-add-button (from to fun &optional data)
5322 "Create a button between FROM and TO with callback FUN and data DATA."
5323 (when gnus-article-button-face
5324 (gnus-overlay-put (gnus-make-overlay from to)
5325 'face gnus-article-button-face))
5326 (gnus-add-text-properties
5328 (nconc (and gnus-article-mouse-face
5329 (list gnus-mouse-face-prop gnus-article-mouse-face))
5330 (list 'gnus-callback fun)
5331 (and data (list 'gnus-data data))))
5332 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5333 :button-keymap gnus-widget-button-keymap))
5335 ;;; Internal functions:
5337 (defun gnus-article-set-globals ()
5339 (set-buffer gnus-summary-buffer)
5340 (gnus-set-global-variables)))
5342 (defun gnus-signature-toggle (end)
5344 (set-buffer gnus-article-buffer)
5345 (let ((buffer-read-only nil)
5346 (inhibit-point-motion-hooks t))
5347 (if (text-property-any end (point-max) 'article-type 'signature)
5349 (gnus-delete-wash-type 'signature)
5350 (gnus-remove-text-properties-when
5351 'article-type 'signature end (point-max)
5352 (cons 'article-type (cons 'signature
5353 gnus-hidden-properties))))
5354 (gnus-add-wash-type 'signature)
5355 (gnus-add-text-properties-when
5356 'article-type nil end (point-max)
5357 (cons 'article-type (cons 'signature
5358 gnus-hidden-properties)))))
5359 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5360 (gnus-set-mode-line 'article))))
5362 (defun gnus-button-entry ()
5363 ;; Return the first entry in `gnus-button-alist' matching this place.
5364 (let ((alist gnus-button-alist)
5367 (setq entry (pop alist))
5368 (if (looking-at (car entry))
5373 (defun gnus-button-push (marker)
5374 ;; Push button starting at MARKER.
5377 (let* ((entry (gnus-button-entry))
5378 (inhibit-point-motion-hooks t)
5380 (args (mapcar (lambda (group)
5381 (let ((string (match-string group)))
5382 (gnus-set-text-properties
5383 0 (length string) nil string)
5390 (fboundp (symbol-value fun)))
5391 (apply (symbol-value fun) args))
5393 (gnus-message 1 "You must define `%S' to use this button"
5394 (cons fun args)))))))
5396 (defun gnus-parse-news-url (url)
5397 (let (scheme server group message-id articles)
5400 (goto-char (point-min))
5401 (when (looking-at "\\([A-Za-z]+\\):")
5402 (setq scheme (match-string 1))
5403 (goto-char (match-end 0)))
5404 (when (looking-at "//\\([^/]+\\)/")
5405 (setq server (match-string 1))
5406 (goto-char (match-end 0)))
5409 ((looking-at "\\(.*@.*\\)")
5410 (setq message-id (match-string 1)))
5411 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5412 (setq group (match-string 1)
5413 articles (split-string (match-string 2) "-")))
5414 ((looking-at "\\([^/]+\\)/?")
5415 (setq group (match-string 1)))
5417 (error "Unknown news URL syntax"))))
5418 (list scheme server group message-id articles)))
5420 (defun gnus-button-handle-news (url)
5422 (destructuring-bind (scheme server group message-id articles)
5423 (gnus-parse-news-url url)
5427 (set-buffer gnus-summary-buffer)
5429 (let ((gnus-refer-article-method (list (list 'nntp server))))
5430 (gnus-summary-refer-article message-id))
5431 (gnus-summary-refer-article message-id))))
5433 (gnus-button-fetch-group url)))))
5435 (defun gnus-button-handle-info (url)
5436 "Fetch an info URL."
5438 "^\\([^:/]+\\)?/\\(.*\\)"
5440 (gnus-info-find-node
5441 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5444 (gnus-url-unhex-string (match-string 2 url))))
5445 (error "Can't parse %s" url)))
5447 (defun gnus-button-message-id (message-id)
5450 (set-buffer gnus-summary-buffer)
5451 (gnus-summary-refer-article message-id)))
5453 (defun gnus-button-fetch-group (address)
5454 "Fetch GROUP specified by ADDRESS."
5455 (if (not (string-match "[:/]" address))
5456 ;; This is just a simple group url.
5457 (gnus-group-read-ephemeral-group address gnus-select-method)
5460 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5462 (error "Can't parse %s" address)
5463 (gnus-group-read-ephemeral-group
5464 (match-string 4 address)
5465 `(nntp ,(match-string 1 address)
5466 (nntp-address ,(match-string 1 address))
5467 (nntp-port-number ,(if (match-end 3)
5468 (match-string 3 address)
5471 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5473 (defun gnus-url-parse-query-string (query &optional downcase)
5474 (let (retval pairs cur key val)
5475 (setq pairs (split-string query "&"))
5477 (setq cur (car pairs)
5479 (if (not (string-match "=" cur))
5481 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5482 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5484 (setq key (downcase key)))
5485 (setq cur (assoc key retval))
5487 (setcdr cur (cons val (cdr cur)))
5488 (setq retval (cons (list key val) retval)))))
5491 (defun gnus-url-mailto (url)
5492 ;; Send mail to someone
5493 (when (string-match "mailto:/*\\(.*\\)" url)
5494 (setq url (substring url (match-beginning 1) nil)))
5495 (let (to args subject func)
5496 (if (string-match (regexp-quote "?") url)
5497 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5498 args (gnus-url-parse-query-string
5499 (substring url (match-end 0) nil) t))
5500 (setq to (gnus-url-unhex-string url)))
5501 (setq args (cons (list "to" to) args)
5502 subject (cdr-safe (assoc "subject" args)))
5505 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5508 (message-position-on-field (caar args)))
5509 (insert (mapconcat 'identity (cdar args) ", "))
5510 (setq args (cdr args)))
5513 (message-goto-subject))))
5515 (defun gnus-button-embedded-url (address)
5516 "Activate ADDRESS with `browse-url'."
5517 (browse-url (gnus-strip-whitespace address)))
5519 ;;; Next/prev buttons in the article buffer.
5521 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5522 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5524 (defvar gnus-prev-page-map nil)
5525 (unless gnus-prev-page-map
5526 (setq gnus-prev-page-map (make-sparse-keymap))
5527 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5528 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5530 (defun gnus-insert-prev-page-button ()
5531 (let ((buffer-read-only nil))
5533 gnus-prev-page-line-format nil
5534 `(gnus-prev t local-map ,gnus-prev-page-map
5535 gnus-callback gnus-article-button-prev-page
5536 article-type annotation))))
5538 (defvar gnus-next-page-map nil)
5539 (unless gnus-next-page-map
5540 (setq gnus-next-page-map (make-keymap))
5541 (suppress-keymap gnus-prev-page-map)
5542 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5543 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5545 (defun gnus-button-next-page ()
5546 "Go to the next page."
5548 (let ((win (selected-window)))
5549 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5550 (gnus-article-next-page)
5551 (select-window win)))
5553 (defun gnus-button-prev-page ()
5554 "Go to the prev page."
5556 (let ((win (selected-window)))
5557 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5558 (gnus-article-prev-page)
5559 (select-window win)))
5561 (defun gnus-insert-next-page-button ()
5562 (let ((buffer-read-only nil))
5563 (gnus-eval-format gnus-next-page-line-format nil
5565 t local-map ,gnus-next-page-map
5566 gnus-callback gnus-article-button-next-page
5567 article-type annotation))))
5569 (defun gnus-article-button-next-page (arg)
5570 "Go to the next page."
5572 (let ((win (selected-window)))
5573 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5574 (gnus-article-next-page)
5575 (select-window win)))
5577 (defun gnus-article-button-prev-page (arg)
5578 "Go to the prev page."
5580 (let ((win (selected-window)))
5581 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5582 (gnus-article-prev-page)
5583 (select-window win)))
5585 (defvar gnus-decode-header-methods
5586 '(mail-decode-encoded-word-region)
5587 "List of methods used to decode headers.
5589 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5590 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5591 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5592 whose names match REGEXP.
5595 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5596 mail-decode-encoded-word-region
5597 (\"chinese\" . rfc1843-decode-region))
5600 (defvar gnus-decode-header-methods-cache nil)
5602 (defun gnus-multi-decode-header (start end)
5603 "Apply the functions from `gnus-encoded-word-methods' that match."
5604 (unless (and gnus-decode-header-methods-cache
5605 (eq gnus-newsgroup-name
5606 (car gnus-decode-header-methods-cache)))
5607 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5610 (nconc gnus-decode-header-methods-cache (list x))
5611 (if (and gnus-newsgroup-name
5612 (string-match (car x) gnus-newsgroup-name))
5613 (nconc gnus-decode-header-methods-cache
5615 gnus-decode-header-methods))
5616 (let ((xlist gnus-decode-header-methods-cache))
5619 (narrow-to-region start end)
5621 (funcall (pop xlist) (point-min) (point-max))))))
5624 ;;; Treatment top-level handling.
5627 (defun gnus-treat-article (condition &optional part-number total-parts type)
5628 (let ((length (- (point-max) (point-min)))
5629 (alist gnus-treatment-function-alist)
5630 (article-goto-body-goes-to-point-min-p t)
5634 (let ((list gnus-article-treat-types))
5636 (when (string-match (pop list) type)
5637 (throw 'found t)))))))
5638 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5640 (gnus-run-hooks 'gnus-part-display-hook)
5641 (while (setq elem (pop alist))
5644 (if (gnus-buffer-live-p gnus-summary-buffer)
5645 (set-buffer gnus-summary-buffer))
5646 (symbol-value (car elem))))
5647 (when (and (or (consp val)
5649 (gnus-treat-predicate val)
5650 (or (not (get (car elem) 'highlight))
5653 (funcall (cadr elem)))))))
5655 ;; Dynamic variables.
5657 (defvar part-number)
5658 (defvar total-parts)
5663 (defun gnus-treat-predicate (val)
5668 (stringp (car val)))
5669 (apply 'gnus-or (mapcar `(lambda (s)
5670 (string-match s ,(or gnus-newsgroup-name "")))
5673 (let ((pred (pop val)))
5676 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5678 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5680 (not (gnus-treat-predicate (car val))))
5682 (equal (car val) type))
5684 (error "%S is not a valid predicate" pred)))))
5692 (eq part-number total-parts))
5696 (error "%S is not a valid value" val))))
5698 (defun gnus-article-encrypt-body (protocol &optional n)
5699 "Encrypt the article body."
5702 (or gnus-article-encrypt-protocol
5703 (completing-read "Encrypt protocol: "
5704 gnus-article-encrypt-protocol-alist
5706 current-prefix-arg))
5707 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5709 (error (format "Can't find the encrypt protocol %s" protocol)))
5710 (if (equal gnus-newsgroup-name "nndraft:drafts")
5711 (error "Can't encrypt the article in group nndraft:drafts"))
5712 (if (equal gnus-newsgroup-name "nndraft:queue")
5713 (error "Don't encrypt the article in group nndraft:queue"))
5714 (gnus-summary-iterate n
5716 (set-buffer gnus-summary-buffer)
5717 (let ((mail-parse-charset gnus-newsgroup-charset)
5718 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5719 (summary-buffer gnus-summary-buffer)
5721 (gnus-set-global-variables)
5722 (when (gnus-group-read-only-p)
5723 (error "The current newsgroup does not support article encrypt"))
5724 (gnus-summary-show-article t)
5726 (or (mail-header-references gnus-current-headers) ""))
5727 (set-buffer gnus-article-buffer)
5728 (let* ((buffer-read-only nil)
5730 (mapcar (lambda (field)
5731 (and (save-restriction
5732 (message-narrow-to-head)
5733 (goto-char (point-min))
5734 (search-forward field nil t))
5736 (message-narrow-to-field)
5737 (buffer-substring (point-min) (point-max))
5738 (delete-region (point-min) (point-max))
5740 '("Content-Type:" "Content-Transfer-Encoding:"
5741 "Content-Disposition:"))))
5742 (message-narrow-to-head)
5743 (message-remove-header "MIME-Version")
5744 (goto-char (point-max))
5745 (setq point (point))
5746 (insert (apply 'concat headers))
5748 (narrow-to-region point (point-max))
5749 (let ((message-options message-options))
5750 (message-options-set 'message-sender user-mail-address)
5751 (message-options-set 'message-recipients user-mail-address)
5752 (message-options-set 'message-sign-encrypt 'not)
5754 (goto-char (point-min))
5755 (insert "MIME-Version: 1.0\n")
5757 (gnus-summary-edit-article-done
5758 references nil summary-buffer t))
5759 (when gnus-keep-backlog
5760 (gnus-backlog-remove-article
5761 (car gnus-article-current) (cdr gnus-article-current)))
5763 (when (get-buffer gnus-original-article-buffer)
5764 (set-buffer gnus-original-article-buffer)
5765 (setq gnus-original-article nil)))
5766 (when gnus-use-cache
5767 (gnus-cache-update-article
5768 (car gnus-article-current) (cdr gnus-article-current))))))))
5770 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5771 "The following specs can be used:
5772 %t The security MIME type
5775 %D Details if button is pressed")
5777 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5778 "The following specs can be used:
5779 %t The security MIME type
5782 %D Details if button is pressed")
5784 (defvar gnus-mime-security-button-line-format-alist
5785 '((?t gnus-tmp-type ?s)
5786 (?i gnus-tmp-info ?s)
5787 (?d gnus-tmp-details ?s)
5788 (?D gnus-tmp-pressed-details ?s)))
5790 (defvar gnus-mime-security-button-map
5791 (let ((map (make-sparse-keymap)))
5792 (unless (>= (string-to-number emacs-version) 21)
5793 (set-keymap-parent map gnus-article-mode-map))
5794 (define-key map gnus-mouse-2 'gnus-article-push-button)
5795 (define-key map "\r" 'gnus-article-press-button)
5798 (defvar gnus-mime-security-details-buffer nil)
5800 (defvar gnus-mime-security-button-pressed nil)
5802 (defvar gnus-mime-security-show-details-inline t
5803 "If non-nil, show details in the article buffer.")
5805 (defun gnus-mime-security-verify-or-decrypt (handle)
5806 (mm-remove-parts (cdr handle))
5807 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5808 point buffer-read-only)
5810 (goto-char (car region)))
5812 (narrow-to-region (point) (point))
5813 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5814 (let* ((mm-verify-option 'known)
5815 (mm-decrypt-option 'known)
5816 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5817 (unless (eq nparts (cdr handle))
5818 (mm-destroy-parts (cdr handle))
5819 (setcdr handle nparts))))
5820 (setq point (point))
5821 (gnus-mime-display-security handle)
5822 (goto-char (point-max)))
5824 (delete-region (point) (cdr region))
5825 (set-marker (car region) nil)
5826 (set-marker (cdr region) nil))
5829 (defun gnus-mime-security-show-details (handle)
5830 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5832 (if gnus-mime-security-show-details-inline
5833 (let ((gnus-mime-security-button-pressed t)
5834 (gnus-mime-security-button-line-format
5835 (get-text-property (point) 'gnus-line-format))
5838 (while (eq (get-text-property (point) 'gnus-line-format)
5839 gnus-mime-security-button-line-format)
5843 (narrow-to-region (point) (point))
5844 (gnus-insert-mime-security-button handle))
5845 (delete-region (point)
5846 (or (text-property-not-all
5849 gnus-mime-security-button-line-format)
5851 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5852 (with-current-buffer gnus-mime-security-details-buffer
5855 (setq gnus-mime-security-details-buffer
5856 (gnus-get-buffer-create "*MIME Security Details*")))
5857 (with-current-buffer gnus-mime-security-details-buffer
5859 (goto-char (point-min)))
5860 (pop-to-buffer gnus-mime-security-details-buffer))
5861 (gnus-message 5 "No details."))))
5863 (defun gnus-mime-security-press-button (handle)
5864 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5865 (gnus-mime-security-show-details handle)
5866 (gnus-mime-security-verify-or-decrypt handle)))
5868 (defun gnus-insert-mime-security-button (handle &optional displayed)
5869 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5872 (or (nth 2 (assoc protocol mm-verify-function-alist))
5873 (nth 2 (assoc protocol mm-decrypt-function-alist))
5875 (if (equal (car handle) "multipart/signed")
5876 " Signed" " Encrypted")
5879 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5882 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5883 gnus-tmp-pressed-details
5885 (setq gnus-tmp-details
5886 (if gnus-tmp-details
5887 (concat "\n" gnus-tmp-details) ""))
5888 (setq gnus-tmp-pressed-details
5889 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5894 gnus-mime-security-button-line-format
5895 gnus-mime-security-button-line-format-alist
5896 `(keymap ,gnus-mime-security-button-map
5897 ,@(if (>= (string-to-number emacs-version) 21)
5898 nil ;; XEmacs doesn't care
5899 (list 'local-map gnus-mime-security-button-map))
5900 gnus-callback gnus-mime-security-press-button
5901 gnus-line-format ,gnus-mime-security-button-line-format
5902 article-type annotation
5905 (widget-convert-button
5908 :action 'gnus-widget-press-button
5909 :button-keymap gnus-mime-security-button-map
5911 (lambda (widget/window &optional overlay pos)
5912 ;; Needed to properly clear the message due to a bug in
5913 ;; wid-edit (XEmacs only).
5914 (if (boundp 'help-echo-owns-message)
5915 (setq help-echo-owns-message t))
5918 (aref gnus-mouse-2 0))))))
5920 (defun gnus-mime-display-security (handle)
5922 (narrow-to-region (point) (point))
5923 (unless (gnus-unbuttonized-mime-type-p (car handle))
5924 (gnus-insert-mime-security-button handle))
5925 (gnus-mime-display-mixed (cdr handle))
5928 (unless (gnus-unbuttonized-mime-type-p (car handle))
5929 (let ((gnus-mime-security-button-line-format
5930 gnus-mime-security-button-end-line-format))
5931 (gnus-insert-mime-security-button handle)))
5932 (mm-set-handle-multipart-parameter
5934 (cons (set-marker (make-marker) (point-min))
5935 (set-marker (make-marker) (point-max))))))
5941 (run-hooks 'gnus-art-load-hook)
5943 ;;; gnus-art.el ends here