1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
245 :group 'gnus-article-washing)
247 (defcustom gnus-article-x-face-too-ugly nil
248 "Regexp matching posters whose face shouldn't be shown automatically."
249 :type '(choice regexp (const nil))
250 :group 'gnus-article-washing)
252 (defcustom gnus-article-banner-alist nil
253 "Banner alist for stripping.
255 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
257 :type '(repeat (cons symbol regexp))
258 :group 'gnus-article-washing)
260 (gnus-define-group-parameter
263 "Alist of regexps (to match group names) and banner."
264 :variable-group gnus-article-washing
266 '(choice :tag "Banner"
268 (const :tag "Remove signature" signature)
269 (symbol :tag "Item in `gnus-article-banner-alist'" none)
271 (const :tag "None" nil))
273 "If non-nil, specify how to remove `banners' from articles.
275 Symbol `signature' means to remove signatures delimited by
276 `gnus-signature-separator'. Any other symbol is used to look up a
277 regular expression to match the banner in `gnus-article-banner-alist'.
278 A string is used as a regular expression to match the banner
281 (defcustom gnus-emphasis-alist
283 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
288 ("_/" "/_" underline-italic)
289 ("_\\*" "\\*_" underline-bold)
290 ("\\*/" "/\\*" bold-italic)
291 ("_\\*/" "/\\*_" underline-bold-italic))))
295 (format format (car spec) (cadr spec))
296 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
298 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
299 2 3 gnus-emphasis-underline)))
300 "*Alist that says how to fontify certain phrases.
301 Each item looks like this:
303 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
305 The first element is a regular expression to be matched. The second
306 is a number that says what regular expression grouping used to find
307 the entire emphasized word. The third is a number that says what
308 regexp grouping should be displayed and highlighted. The fourth
309 is the face used for highlighting."
310 :type '(repeat (list :value ("" 0 0 default)
312 (integer :tag "Match group")
313 (integer :tag "Emphasize group")
315 :group 'gnus-article-emphasis)
317 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
318 "A regexp to describe whitespace which should not be emphasized.
319 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
320 The former avoids underlining of leading and trailing whitespace,
321 and the latter avoids underlining any whitespace at all."
323 :group 'gnus-article-emphasis
326 (defface gnus-emphasis-bold '((t (:bold t)))
327 "Face used for displaying strong emphasized text (*word*)."
328 :group 'gnus-article-emphasis)
330 (defface gnus-emphasis-italic '((t (:italic t)))
331 "Face used for displaying italic emphasized text (/word/)."
332 :group 'gnus-article-emphasis)
334 (defface gnus-emphasis-underline '((t (:underline t)))
335 "Face used for displaying underlined emphasized text (_word_)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
339 "Face used for displaying underlined bold emphasized text (_*word*_)."
340 :group 'gnus-article-emphasis)
342 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
343 "Face used for displaying underlined italic emphasized text (_/word/_)."
344 :group 'gnus-article-emphasis)
346 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
347 "Face used for displaying bold italic emphasized text (/*word*/)."
348 :group 'gnus-article-emphasis)
350 (defface gnus-emphasis-underline-bold-italic
351 '((t (:bold t :italic t :underline t)))
352 "Face used for displaying underlined bold italic emphasized text.
353 Esample: (_/*word*/_)."
354 :group 'gnus-article-emphasis)
356 (defface gnus-emphasis-highlight-words
357 '((t (:background "black" :foreground "yellow")))
358 "Face used for displaying highlighted words."
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
362 "Format for display of Date headers in article bodies.
363 See `format-time-string' for the possible values.
365 The variable can also be function, which should return a complete Date
366 header. The function is called with one argument, the time, which can
367 be fed to `format-time-string'."
368 :type '(choice string symbol)
369 :link '(custom-manual "(gnus)Article Date")
370 :group 'gnus-article-washing)
373 (autoload 'mail-extract-address-components "mail-extr"))
375 (defcustom gnus-save-all-headers t
376 "*If non-nil, don't remove any headers before saving."
377 :group 'gnus-article-saving
380 (defcustom gnus-prompt-before-saving 'always
381 "*This variable says how much prompting is to be done when saving articles.
382 If it is nil, no prompting will be done, and the articles will be
383 saved to the default files. If this variable is `always', each and
384 every article that is saved will be preceded by a prompt, even when
385 saving large batches of articles. If this variable is neither nil not
386 `always', there the user will be prompted once for a file name for
387 each invocation of the saving commands."
388 :group 'gnus-article-saving
389 :type '(choice (item always)
390 (item :tag "never" nil)
391 (sexp :tag "once" :format "%t\n" :value t)))
393 (defcustom gnus-saved-headers gnus-visible-headers
394 "Headers to keep if `gnus-save-all-headers' is nil.
395 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
396 If that variable is nil, however, all headers that match this regexp
397 will be kept while the rest will be deleted before saving."
398 :group 'gnus-article-saving
401 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
402 "A function to save articles in your favourite format.
403 The function must be interactively callable (in other words, it must
404 be an Emacs command).
406 Gnus provides the following functions:
408 * gnus-summary-save-in-rmail (Rmail format)
409 * gnus-summary-save-in-mail (Unix mail format)
410 * gnus-summary-save-in-folder (MH folder)
411 * gnus-summary-save-in-file (article format)
412 * gnus-summary-save-body-in-file (article body)
413 * gnus-summary-save-in-vm (use VM's folder format)
414 * gnus-summary-write-to-file (article format -- overwrite)."
415 :group 'gnus-article-saving
416 :type '(radio (function-item gnus-summary-save-in-rmail)
417 (function-item gnus-summary-save-in-mail)
418 (function-item gnus-summary-save-in-folder)
419 (function-item gnus-summary-save-in-file)
420 (function-item gnus-summary-save-body-in-file)
421 (function-item gnus-summary-save-in-vm)
422 (function-item gnus-summary-write-to-file)))
424 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
425 "A function generating a file name to save articles in Rmail format.
426 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
427 :group 'gnus-article-saving
430 (defcustom gnus-mail-save-name 'gnus-plain-save-name
431 "A function generating a file name to save articles in Unix mail format.
432 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
433 :group 'gnus-article-saving
436 (defcustom gnus-folder-save-name 'gnus-folder-save-name
437 "A function generating a file name to save articles in MH folder.
438 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
439 :group 'gnus-article-saving
442 (defcustom gnus-file-save-name 'gnus-numeric-save-name
443 "A function generating a file name to save articles in article format.
444 The function is called with NEWSGROUP, HEADERS, and optional
446 :group 'gnus-article-saving
449 (defcustom gnus-split-methods
450 '((gnus-article-archive-name)
451 (gnus-article-nndoc-name))
452 "*Variable used to suggest where articles are to be saved.
453 For instance, if you would like to save articles related to Gnus in
454 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
455 you could set this variable to something like:
457 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
458 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
460 This variable is an alist where the where the key is the match and the
461 value is a list of possible files to save in if the match is non-nil.
463 If the match is a string, it is used as a regexp match on the
464 article. If the match is a symbol, that symbol will be funcalled
465 from the buffer of the article to be saved with the newsgroup as the
466 parameter. If it is a list, it will be evaled in the same buffer.
468 If this form or function returns a string, this string will be used as
469 a possible file name; and if it returns a non-nil list, that list will
470 be used as possible file names."
471 :group 'gnus-article-saving
472 :type '(repeat (choice (list :value (fun) function)
473 (cons :value ("" "") regexp (repeat string))
476 (defcustom gnus-page-delimiter "^\^L"
477 "*Regexp describing what to use as article page delimiters.
478 The default value is \"^\^L\", which is a form linefeed at the
479 beginning of a line."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
484 "*The format specification for the article mode line.
485 See `gnus-summary-mode-line-format' for a closer description.
487 The following additional specs are available:
489 %w The article washing status.
490 %m The number of MIME parts in the article."
492 :group 'gnus-article-various)
494 (defcustom gnus-article-mode-hook nil
495 "*A hook for Gnus article mode."
497 :group 'gnus-article-various)
499 (when (featurep 'xemacs)
500 ;; Extracted from gnus-xmas-define in order to preserve user settings
501 (when (fboundp 'turn-off-scroll-in-place)
502 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
503 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
504 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
506 (defcustom gnus-article-menu-hook nil
507 "*Hook run after the creation of the article mode menu."
509 :group 'gnus-article-various)
511 (defcustom gnus-article-prepare-hook nil
512 "*A hook called after an article has been prepared in the article buffer."
514 :group 'gnus-article-various)
516 (defcustom gnus-article-hide-pgp-hook nil
517 "*A hook called after successfully hiding a PGP signature."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-button-face 'bold
522 "Face used for highlighting buttons in the article buffer.
524 An article button is a piece of text that you can activate by pressing
525 `RET' or `mouse-2' above it."
527 :group 'gnus-article-buttons)
529 (defcustom gnus-article-mouse-face 'highlight
530 "Face used for mouse highlighting in the article buffer.
532 Article buttons will be displayed in this face when the cursor is
535 :group 'gnus-article-buttons)
537 (defcustom gnus-signature-face 'gnus-signature-face
538 "Face used for highlighting a signature in the article buffer.
539 Obsolete; use the face `gnus-signature-face' for customizations instead."
541 :group 'gnus-article-highlight
542 :group 'gnus-article-signature)
544 (defface gnus-signature-face
547 "Face used for highlighting a signature in the article buffer."
548 :group 'gnus-article-highlight
549 :group 'gnus-article-signature)
551 (defface gnus-header-from-face
554 (:foreground "spring green"))
557 (:foreground "red3"))
560 "Face used for displaying from headers."
561 :group 'gnus-article-headers
562 :group 'gnus-article-highlight)
564 (defface gnus-header-subject-face
567 (:foreground "SeaGreen3"))
570 (:foreground "red4"))
572 (:bold t :italic t)))
573 "Face used for displaying subject headers."
574 :group 'gnus-article-headers
575 :group 'gnus-article-highlight)
577 (defface gnus-header-newsgroups-face
580 (:foreground "yellow" :italic t))
583 (:foreground "MidnightBlue" :italic t))
586 "Face used for displaying newsgroups headers."
587 :group 'gnus-article-headers
588 :group 'gnus-article-highlight)
590 (defface gnus-header-name-face
593 (:foreground "SeaGreen"))
596 (:foreground "maroon"))
599 "Face used for displaying header names."
600 :group 'gnus-article-headers
601 :group 'gnus-article-highlight)
603 (defface gnus-header-content-face
606 (:foreground "forest green" :italic t))
609 (:foreground "indianred4" :italic t))
611 (:italic t))) "Face used for displaying header content."
612 :group 'gnus-article-headers
613 :group 'gnus-article-highlight)
615 (defcustom gnus-header-face-alist
616 '(("From" nil gnus-header-from-face)
617 ("Subject" nil gnus-header-subject-face)
618 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
619 ("" gnus-header-name-face gnus-header-content-face))
620 "*Controls highlighting of article header.
622 An alist of the form (HEADER NAME CONTENT).
624 HEADER is a regular expression which should match the name of an
625 header header and NAME and CONTENT are either face names or nil.
627 The name of each header field will be displayed using the face
628 specified by the first element in the list where HEADER match the
629 header name and NAME is non-nil. Similarly, the content will be
630 displayed by the first non-nil matching CONTENT face."
631 :group 'gnus-article-headers
632 :group 'gnus-article-highlight
633 :type '(repeat (list (regexp :tag "Header")
635 (item :tag "skip" nil)
636 (face :value default))
637 (choice :tag "Content"
638 (item :tag "skip" nil)
639 (face :value default)))))
641 (defcustom gnus-article-decode-hook
642 '(article-decode-charset article-decode-encoded-words
643 article-decode-group-name)
644 "*Hook run to decode charsets in articles."
645 :group 'gnus-article-headers
648 (defcustom gnus-display-mime-function 'gnus-display-mime
649 "Function to display MIME articles."
650 :group 'gnus-article-mime
653 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
654 "Function used to decode headers.")
656 (defvar gnus-article-dumbquotes-map
675 "Table for MS-to-Latin1 translation.")
677 (defcustom gnus-ignored-mime-types nil
678 "List of MIME types that should be ignored by Gnus."
680 :group 'gnus-article-mime
681 :type '(repeat regexp))
683 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
684 "List of MIME types that should not be given buttons when rendered inline.
685 See also `gnus-buttonized-mime-types' which may override this variable."
687 :group 'gnus-article-mime
688 :type '(repeat regexp))
690 (defcustom gnus-buttonized-mime-types nil
691 "List of MIME types that should be given buttons when rendered inline.
692 If set, this variable overrides `gnus-unbuttonized-mime-types'.
693 To see e.g. security buttons you could set this to
694 `(\"multipart/signed\")'."
696 :group 'gnus-article-mime
697 :type '(repeat regexp))
699 (defcustom gnus-body-boundary-delimiter "_"
700 "String used to delimit header and body.
701 This variable is used by `gnus-article-treat-body-boundary' which can
702 be controlled by `gnus-treat-body-boundary'."
703 :group 'gnus-article-various
704 :type '(choice (item :tag "None" :value nil)
707 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
708 "*Defines the location of the faces database.
709 For information on obtaining this database of pretty pictures, please
710 see http://www.cs.indiana.edu/picons/ftp/index.html"
714 (defun gnus-picons-installed-p ()
715 "Say whether picons are installed on your machine."
716 (let ((installed nil))
717 (dolist (database gnus-picon-databases)
718 (when (file-exists-p database)
722 (defcustom gnus-article-mime-part-function nil
723 "Function called with a MIME handle as the argument.
724 This is meant for people who want to do something automatic based
725 on parts -- for instance, adding Vcard info to a database."
726 :group 'gnus-article-mime
729 (defcustom gnus-mime-multipart-functions nil
730 "An alist of MIME types to functions to display them."
732 :group 'gnus-article-mime
735 (defcustom gnus-article-date-lapsed-new-header nil
736 "Whether the X-Sent and Date headers can coexist.
737 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
738 either replace the old \"Date:\" header (if this variable is nil), or
739 be added below it (otherwise)."
741 :group 'gnus-article-headers
744 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
745 "Function called with a MIME handle as the argument.
746 This is meant for people who want to view first matched part.
747 For `undisplayed-alternative' (default), the first undisplayed
748 part or alternative part is used. For `undisplayed', the first
749 undisplayed part is used. For a function, the first part which
750 the function return `t' is used. For `nil', the first part is
753 :group 'gnus-article-mime
755 (item :tag "first" :value nil)
756 (item :tag "undisplayed" :value undisplayed)
757 (item :tag "undisplayed or alternative"
758 :value undisplayed-alternative)
761 (defcustom gnus-mime-action-alist
762 '(("save to file" . gnus-mime-save-part)
763 ("save and strip" . gnus-mime-save-part-and-strip)
764 ("display as text" . gnus-mime-inline-part)
765 ("view the part" . gnus-mime-view-part)
766 ("pipe to command" . gnus-mime-pipe-part)
767 ("toggle display" . gnus-article-press-button)
768 ("toggle display" . gnus-article-view-part-as-charset)
769 ("view as type" . gnus-mime-view-part-as-type)
770 ("internalize type" . gnus-mime-internalize-part)
771 ("externalize type" . gnus-mime-externalize-part))
772 "An alist of actions that run on the MIME attachment."
773 :group 'gnus-article-mime
774 :type '(repeat (cons (string :tag "name")
777 (defcustom gnus-mime-action-alist
778 '(("save to file" . gnus-mime-save-part)
779 ("display as text" . gnus-mime-inline-part)
780 ("view the part" . gnus-mime-view-part)
781 ("pipe to command" . gnus-mime-pipe-part)
782 ("toggle display" . gnus-article-press-button)
783 ("view as type" . gnus-mime-view-part-as-type)
784 ("internalize type" . gnus-mime-internalize-part)
785 ("externalize type" . gnus-mime-externalize-part))
786 "An alist of actions that run on the MIME attachment."
788 :group 'gnus-article-mime
789 :type '(repeat (cons (string :tag "name")
793 ;;; The treatment variables
796 (defvar gnus-part-display-hook nil
797 "Hook called on parts that are to receive treatment.")
799 (defvar gnus-article-treat-custom
800 '(choice (const :tag "Off" nil)
802 (const :tag "Header" head)
803 (const :tag "Last" last)
804 (integer :tag "Less")
805 (repeat :tag "Groups" regexp)
806 (sexp :tag "Predicate")))
808 (defvar gnus-article-treat-head-custom
809 '(choice (const :tag "Off" nil)
810 (const :tag "Header" head)))
812 (defvar gnus-article-treat-types '("text/plain")
815 (defvar gnus-inhibit-treatment nil
816 "Whether to inhibit treatment.")
818 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
819 "Highlight the signature.
820 Valid values are nil, t, `head', `last', an integer or a predicate.
821 See Info node `(gnus)Customizing Articles'."
822 :group 'gnus-article-treat
823 :type gnus-article-treat-custom)
824 (put 'gnus-treat-highlight-signature 'highlight t)
826 (defcustom gnus-treat-buttonize 100000
828 Valid values are nil, t, `head', `last', an integer or a predicate.
829 See Info node `(gnus)Customizing Articles'."
830 :group 'gnus-article-treat
831 :type gnus-article-treat-custom)
832 (put 'gnus-treat-buttonize 'highlight t)
834 (defcustom gnus-treat-buttonize-head 'head
835 "Add buttons to the head.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles' for details."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-head-custom)
840 (put 'gnus-treat-buttonize-head 'highlight t)
842 (defcustom gnus-treat-emphasize
843 (and (or window-system
845 (>= (string-to-number emacs-version) 21))
848 Valid values are nil, t, `head', `last', an integer or a predicate.
849 See Info node `(gnus)Customizing Articles' for details."
850 :group 'gnus-article-treat
851 :type gnus-article-treat-custom)
852 (put 'gnus-treat-emphasize 'highlight t)
854 (defcustom gnus-treat-strip-cr nil
855 "Remove carriage returns.
856 Valid values are nil, t, `head', `last', an integer or a predicate.
857 See Info node `(gnus)Customizing Articles' for details."
858 :group 'gnus-article-treat
859 :type gnus-article-treat-custom)
861 (defcustom gnus-treat-leading-whitespace nil
862 "Remove leading whitespace in headers.
863 Valid values are nil, t, `head', `last', an integer or a predicate.
864 See Info node `(gnus)Customizing Articles' for details."
865 :group 'gnus-article-treat
866 :type gnus-article-treat-custom)
868 (defcustom gnus-treat-hide-headers 'head
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles' for details."
872 :group 'gnus-article-treat
873 :type gnus-article-treat-head-custom)
875 (defcustom gnus-treat-hide-boring-headers nil
876 "Hide boring headers.
877 Valid values are nil, t, `head', `last', an integer or a predicate.
878 See Info node `(gnus)Customizing Articles' for details."
879 :group 'gnus-article-treat
880 :type gnus-article-treat-head-custom)
882 (defcustom gnus-treat-hide-signature nil
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :type gnus-article-treat-custom)
889 (defcustom gnus-treat-fill-article nil
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See Info node `(gnus)Customizing Articles' for details."
893 :group 'gnus-article-treat
894 :type gnus-article-treat-custom)
896 (defcustom gnus-treat-hide-citation nil
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-hide-citation-maybe nil
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :type gnus-article-treat-custom)
910 (defcustom gnus-treat-strip-list-identifiers 'head
911 "Strip list identifiers from `gnus-list-identifiers`.
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
918 (defcustom gnus-treat-strip-pgp t
919 "Strip PGP signatures.
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See Info node `(gnus)Customizing Articles' for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-custom)
925 (defcustom gnus-treat-strip-pem nil
926 "Strip PEM signatures.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-custom)
932 (defcustom gnus-treat-strip-banner t
933 "Strip banners from articles.
934 The banner to be stripped is specified in the `banner' group parameter.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
937 :group 'gnus-article-treat
938 :type gnus-article-treat-custom)
940 (defcustom gnus-treat-highlight-headers 'head
941 "Highlight the headers.
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :type gnus-article-treat-head-custom)
946 (put 'gnus-treat-highlight-headers 'highlight t)
948 (defcustom gnus-treat-highlight-citation t
949 "Highlight cited text.
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :type gnus-article-treat-custom)
954 (put 'gnus-treat-highlight-citation 'highlight t)
956 (defcustom gnus-treat-date-ut nil
957 "Display the Date in UT (GMT).
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-head-custom)
963 (defcustom gnus-treat-date-local nil
964 "Display the Date in the local timezone.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-head-custom)
970 (defcustom gnus-treat-date-english nil
971 "Display the Date in a format that can be read aloud in English.
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See Info node `(gnus)Customizing Articles' for details."
974 :group 'gnus-article-treat
975 :type gnus-article-treat-head-custom)
977 (defcustom gnus-treat-date-lapsed nil
978 "Display the Date header in a way that says how much time has elapsed.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :type gnus-article-treat-head-custom)
984 (defcustom gnus-treat-date-original nil
985 "Display the date in the original timezone.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :type gnus-article-treat-head-custom)
991 (defcustom gnus-treat-date-iso8601 nil
992 "Display the date in the ISO8601 format.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :type gnus-article-treat-head-custom)
999 (defcustom gnus-treat-date-user-defined nil
1000 "Display the date in a user-defined format.
1001 The format is defined by the `gnus-article-time-format' variable.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :type gnus-article-treat-head-custom)
1007 (defcustom gnus-treat-strip-headers-in-body t
1008 "Strip the X-No-Archive header line from the beginning of the body.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :type gnus-article-treat-custom)
1015 (defcustom gnus-treat-strip-trailing-blank-lines nil
1016 "Strip trailing blank lines.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-strip-leading-blank-lines nil
1023 "Strip leading blank lines.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :type gnus-article-treat-custom)
1029 (defcustom gnus-treat-strip-multiple-blank-lines nil
1030 "Strip multiple blank lines.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-unfold-headers 'head
1037 "Unfold folded header lines.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :type gnus-article-treat-custom)
1043 (defcustom gnus-treat-fold-headers nil
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-fold-newsgroups 'head
1051 "Fold the Newsgroups and Followup-To headers.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-overstrike t
1058 "Treat overstrike highlighting.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :type gnus-article-treat-custom)
1063 (put 'gnus-treat-overstrike 'highlight t)
1065 (defcustom gnus-treat-display-xface
1066 (and (or (and (fboundp 'image-type-available-p)
1067 (image-type-available-p 'xbm)
1068 (string-match "^0x" (shell-command-to-string "uncompface")))
1069 (and (featurep 'xemacs)
1072 "Display X-Face headers.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' and Info node
1075 `(gnus)X-Face' for details."
1076 :group 'gnus-article-treat
1078 :type gnus-article-treat-head-custom)
1079 (put 'gnus-treat-display-xface 'highlight t)
1081 (defcustom gnus-treat-display-smileys
1082 (if (or (and (featurep 'xemacs)
1084 (and (fboundp 'image-type-available-p)
1085 (image-type-available-p 'pbm)))
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)Smileys' for details."
1091 :group 'gnus-article-treat
1093 :type gnus-article-treat-custom)
1094 (put 'gnus-treat-display-smileys 'highlight t)
1096 (defcustom gnus-treat-from-picon
1097 (if (and (gnus-image-type-available-p 'xpm)
1098 (gnus-picons-installed-p))
1100 "Display picons in the From header.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' and Info node
1103 `(gnus)Picons' for details."
1104 :group 'gnus-article-treat
1105 :type gnus-article-treat-head-custom)
1106 (put 'gnus-treat-from-picon 'highlight t)
1108 (defcustom gnus-treat-mail-picon
1109 (if (and (gnus-image-type-available-p 'xpm)
1110 (gnus-picons-installed-p))
1112 "Display picons in To and Cc headers.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' and Info node
1115 `(gnus)Picons' for details."
1116 :group 'gnus-article-treat
1117 :type gnus-article-treat-head-custom)
1118 (put 'gnus-treat-mail-picon 'highlight t)
1120 (defcustom gnus-treat-newsgroups-picon
1121 (if (and (gnus-image-type-available-p 'xpm)
1122 (gnus-picons-installed-p))
1124 "Display picons in the Newsgroups and Followup-To headers.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' and Info node
1127 `(gnus)Picons' for details."
1128 :group 'gnus-article-treat
1129 :type gnus-article-treat-head-custom)
1130 (put 'gnus-treat-newsgroups-picon 'highlight t)
1132 (defcustom gnus-treat-body-boundary
1133 (if (or gnus-treat-newsgroups-picon
1134 gnus-treat-mail-picon
1135 gnus-treat-from-picon)
1137 "Draw a boundary at the end of the headers.
1138 Valid values are nil, t, `head', `last', an integer or a predicate.
1139 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :type gnus-article-treat-custom)
1144 (defcustom gnus-treat-capitalize-sentences nil
1145 "Capitalize sentence-starting words.
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-fill-long-lines nil
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :type gnus-article-treat-custom)
1159 (defcustom gnus-treat-play-sounds nil
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :type gnus-article-treat-custom)
1167 (defcustom gnus-treat-translate nil
1168 "Translate articles from one language to another.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :type gnus-article-treat-custom)
1175 (defcustom gnus-treat-x-pgp-sig nil
1177 To automatically treat X-PGP-Sig, set it to head.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :group 'mime-security
1182 :type gnus-article-treat-custom)
1184 (defvar gnus-article-encrypt-protocol-alist
1185 '(("PGP" . mml2015-self-encrypt)))
1187 ;; Set to nil if more than one protocol added to
1188 ;; gnus-article-encrypt-protocol-alist.
1189 (defcustom gnus-article-encrypt-protocol "PGP"
1190 "The protocol used for encrypt articles.
1191 It is a string, such as \"PGP\". If nil, ask user."
1193 :group 'mime-security)
1195 (defcustom gnus-article-wash-function
1196 (cond ((locate-library "w3")
1197 'gnus-article-wash-html-with-w3)
1198 ((locate-library "w3m")
1199 'gnus-article-wash-html-with-w3m))
1200 "Function used for converting HTML into text."
1201 :type '(radio (function-item gnus-article-wash-html-with-w3)
1202 (function-item gnus-article-wash-html-with-w3m))
1203 :group 'gnus-article)
1205 ;;; Internal variables
1207 (defvar gnus-english-month-names
1208 '("January" "February" "March" "April" "May" "June" "July" "August"
1209 "September" "October" "November" "December"))
1211 (defvar article-goto-body-goes-to-point-min-p nil)
1212 (defvar gnus-article-wash-types nil)
1213 (defvar gnus-article-emphasis-alist nil)
1214 (defvar gnus-article-image-alist nil)
1216 (defvar gnus-article-mime-handle-alist-1 nil)
1217 (defvar gnus-treatment-function-alist
1218 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1219 (gnus-treat-strip-banner gnus-article-strip-banner)
1220 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1221 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1222 (gnus-treat-buttonize gnus-article-add-buttons)
1223 (gnus-treat-fill-article gnus-article-fill-cited-article)
1224 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1225 (gnus-treat-strip-cr gnus-article-remove-cr)
1226 (gnus-treat-date-ut gnus-article-date-ut)
1227 (gnus-treat-date-local gnus-article-date-local)
1228 (gnus-treat-date-english gnus-article-date-english)
1229 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1230 (gnus-treat-date-original gnus-article-date-original)
1231 (gnus-treat-date-user-defined gnus-article-date-user)
1232 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1233 (gnus-treat-display-xface gnus-article-display-x-face)
1234 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1235 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1236 (gnus-treat-hide-signature gnus-article-hide-signature)
1237 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1238 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1239 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1240 (gnus-treat-strip-pem gnus-article-hide-pem)
1241 (gnus-treat-from-picon gnus-treat-from-picon)
1242 (gnus-treat-mail-picon gnus-treat-mail-picon)
1243 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1244 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1245 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1246 (gnus-treat-strip-trailing-blank-lines
1247 gnus-article-remove-trailing-blank-lines)
1248 (gnus-treat-strip-leading-blank-lines
1249 gnus-article-strip-leading-blank-lines)
1250 (gnus-treat-strip-multiple-blank-lines
1251 gnus-article-strip-multiple-blank-lines)
1252 (gnus-treat-overstrike gnus-article-treat-overstrike)
1253 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1254 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1255 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1256 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1257 (gnus-treat-display-smileys gnus-treat-smiley)
1258 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1259 (gnus-treat-emphasize gnus-article-emphasize)
1260 (gnus-treat-hide-citation gnus-article-hide-citation)
1261 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1262 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1263 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1264 (gnus-treat-play-sounds gnus-earcon-display)))
1266 (defvar gnus-article-mime-handle-alist nil)
1267 (defvar article-lapsed-timer nil)
1268 (defvar gnus-article-current-summary nil)
1270 (defvar gnus-article-mode-syntax-table
1271 (let ((table (copy-syntax-table text-mode-syntax-table)))
1272 ;; This causes the citation match run O(2^n).
1273 ;; (modify-syntax-entry ?- "w" table)
1274 (modify-syntax-entry ?> ")" table)
1275 (modify-syntax-entry ?< "(" table)
1277 "Syntax table used in article mode buffers.
1278 Initialized from `text-mode-syntax-table.")
1280 (defvar gnus-save-article-buffer nil)
1282 (defvar gnus-article-mode-line-format-alist
1283 (nconc '((?w (gnus-article-wash-status) ?s)
1284 (?m (gnus-article-mime-part-status) ?s))
1285 gnus-summary-mode-line-format-alist))
1287 (defvar gnus-number-of-articles-to-be-saved nil)
1289 (defvar gnus-inhibit-hiding nil)
1291 ;;; Macros for dealing with the article buffer.
1293 (defmacro gnus-with-article-headers (&rest forms)
1295 (set-buffer gnus-article-buffer)
1297 (let ((buffer-read-only nil)
1298 (inhibit-point-motion-hooks t)
1299 (case-fold-search t))
1300 (article-narrow-to-head)
1303 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1304 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1306 (defmacro gnus-with-article-buffer (&rest forms)
1308 (set-buffer gnus-article-buffer)
1309 (let ((buffer-read-only nil))
1312 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1313 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1315 (defun gnus-article-goto-header (header)
1316 "Go to HEADER, which is a regular expression."
1317 (re-search-forward (concat "^\\(" header "\\):") nil t))
1319 (defsubst gnus-article-hide-text (b e props)
1320 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1321 (gnus-add-text-properties-when 'article-type nil b e props)
1322 (when (memq 'intangible props)
1324 (max (1- b) (point-min))
1325 b 'intangible (cddr (memq 'intangible props)))))
1327 (defsubst gnus-article-unhide-text (b e)
1328 "Remove hidden text properties from region between B and E."
1329 (remove-text-properties b e gnus-hidden-properties)
1330 (when (memq 'intangible gnus-hidden-properties)
1331 (put-text-property (max (1- b) (point-min))
1332 b 'intangible nil)))
1334 (defun gnus-article-hide-text-type (b e type)
1335 "Hide text of TYPE between B and E."
1336 (gnus-add-wash-type type)
1337 (gnus-article-hide-text
1338 b e (cons 'article-type (cons type gnus-hidden-properties))))
1340 (defun gnus-article-unhide-text-type (b e type)
1341 "Unhide text of TYPE between B and E."
1342 (gnus-delete-wash-type type)
1343 (remove-text-properties
1344 b e (cons 'article-type (cons type gnus-hidden-properties)))
1345 (when (memq 'intangible gnus-hidden-properties)
1346 (put-text-property (max (1- b) (point-min))
1347 b 'intangible nil)))
1349 (defun gnus-article-hide-text-of-type (type)
1350 "Hide text of TYPE in the current buffer."
1352 (let ((b (point-min))
1354 (while (setq b (text-property-any b e 'article-type type))
1355 (add-text-properties b (incf b) gnus-hidden-properties)))))
1357 (defun gnus-article-delete-text-of-type (type)
1358 "Delete text of TYPE in the current buffer."
1360 (let ((b (point-min)))
1361 (while (setq b (text-property-any b (point-max) 'article-type type))
1363 b (or (text-property-not-all b (point-max) 'article-type type)
1366 (defun gnus-article-delete-invisible-text ()
1367 "Delete all invisible text in the current buffer."
1369 (let ((b (point-min)))
1370 (while (setq b (text-property-any b (point-max) 'invisible t))
1372 b (or (text-property-not-all b (point-max) 'invisible t)
1375 (defun gnus-article-text-type-exists-p (type)
1376 "Say whether any text of type TYPE exists in the buffer."
1377 (text-property-any (point-min) (point-max) 'article-type type))
1379 (defsubst gnus-article-header-rank ()
1380 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1381 (let ((list gnus-sorted-header-list)
1384 (when (looking-at (car list))
1386 (setq list (cdr list))
1390 (defun article-hide-headers (&optional arg delete)
1391 "Hide unwanted headers and possibly sort them as well."
1393 ;; This function might be inhibited.
1394 (unless gnus-inhibit-hiding
1397 (let ((buffer-read-only nil)
1398 (case-fold-search t)
1399 (max (1+ (length gnus-sorted-header-list)))
1400 (ignored (when (not gnus-visible-headers)
1401 (cond ((stringp gnus-ignored-headers)
1402 gnus-ignored-headers)
1403 ((listp gnus-ignored-headers)
1404 (mapconcat 'identity gnus-ignored-headers
1407 (cond ((stringp gnus-visible-headers)
1408 gnus-visible-headers)
1409 ((and gnus-visible-headers
1410 (listp gnus-visible-headers))
1411 (mapconcat 'identity gnus-visible-headers "\\|"))))
1412 (inhibit-point-motion-hooks t)
1414 ;; First we narrow to just the headers.
1415 (article-narrow-to-head)
1416 ;; Hide any "From " lines at the beginning of (mail) articles.
1417 (while (looking-at "From ")
1420 (delete-region (point-min) (point)))
1421 ;; Then treat the rest of the header lines.
1422 ;; Then we use the two regular expressions
1423 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1424 ;; select which header lines is to remain visible in the
1426 (while (re-search-forward "^[^ \t:]*:" nil t)
1428 ;; Mark the rank of the header.
1430 (point) (1+ (point)) 'message-rank
1431 (if (or (and visible (looking-at visible))
1433 (not (looking-at ignored))))
1434 (gnus-article-header-rank)
1437 (message-sort-headers-1)
1438 (when (setq beg (text-property-any
1439 (point-min) (point-max) 'message-rank (+ 2 max)))
1440 ;; We delete the unwanted headers.
1441 (gnus-add-wash-type 'headers)
1442 (add-text-properties (point-min) (+ 5 (point-min))
1443 '(article-type headers dummy-invisible t))
1444 (delete-region beg (point-max))))))))
1446 (defun article-hide-boring-headers (&optional arg)
1447 "Toggle hiding of headers that aren't very interesting.
1448 If given a negative prefix, always show; if given a positive prefix,
1450 (interactive (gnus-article-hidden-arg))
1451 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1452 (not gnus-show-all-headers))
1455 (let ((buffer-read-only nil)
1456 (list gnus-boring-article-headers)
1457 (inhibit-point-motion-hooks t)
1459 (article-narrow-to-head)
1461 (setq elem (pop list))
1462 (goto-char (point-min))
1464 ;; Hide empty headers.
1466 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1468 (gnus-article-hide-text-type
1469 (progn (beginning-of-line) (point))
1472 (if (re-search-forward "^[^ \t]" nil t)
1476 ;; Hide boring Newsgroups header.
1477 ((eq elem 'newsgroups)
1478 (when (gnus-string-equal
1479 (gnus-fetch-field "newsgroups")
1480 (gnus-group-real-name
1481 (if (boundp 'gnus-newsgroup-name)
1484 (gnus-article-hide-header "newsgroups")))
1485 ((eq elem 'to-address)
1486 (let ((to (message-fetch-field "to"))
1488 (gnus-parameter-to-address
1489 (if (boundp 'gnus-newsgroup-name)
1490 gnus-newsgroup-name ""))))
1491 (when (and to to-address
1494 ;; only one address in To
1495 (nth 1 (mail-extract-address-components to))
1497 (gnus-article-hide-header "to"))))
1498 ((eq elem 'followup-to)
1499 (when (gnus-string-equal
1500 (message-fetch-field "followup-to")
1501 (message-fetch-field "newsgroups"))
1502 (gnus-article-hide-header "followup-to")))
1503 ((eq elem 'reply-to)
1504 (let ((from (message-fetch-field "from"))
1505 (reply-to (message-fetch-field "reply-to")))
1510 (nth 1 (mail-extract-address-components from))
1511 (nth 1 (mail-extract-address-components reply-to)))))
1512 (gnus-article-hide-header "reply-to"))))
1514 (let ((date (message-fetch-field "date")))
1516 (< (days-between (current-time-string) date)
1518 (gnus-article-hide-header "date"))))
1520 (let ((to (message-fetch-field "to"))
1521 (cc (message-fetch-field "cc")))
1522 (when (> (length to) 1024)
1523 (gnus-article-hide-header "to"))
1524 (when (> (length cc) 1024)
1525 (gnus-article-hide-header "cc"))))
1529 (goto-char (point-min))
1530 (while (re-search-forward "^to:" nil t)
1531 (setq to-count (1+ to-count)))
1532 (when (> to-count 1)
1533 (while (> to-count 0)
1534 (goto-char (point-min))
1536 (re-search-forward "^to:" nil nil to-count)
1538 (narrow-to-region (point) (point-max))
1539 (gnus-article-hide-header "to"))
1540 (setq to-count (1- to-count))))
1541 (goto-char (point-min))
1542 (while (re-search-forward "^cc:" nil t)
1543 (setq cc-count (1+ cc-count)))
1544 (when (> cc-count 1)
1545 (while (> cc-count 0)
1546 (goto-char (point-min))
1548 (re-search-forward "^cc:" nil nil cc-count)
1550 (narrow-to-region (point) (point-max))
1551 (gnus-article-hide-header "cc"))
1552 (setq cc-count (1- cc-count)))))))))))))
1554 (defun gnus-article-hide-header (header)
1556 (goto-char (point-min))
1557 (when (re-search-forward (concat "^" header ":") nil t)
1558 (gnus-article-hide-text-type
1559 (progn (beginning-of-line) (point))
1562 (if (re-search-forward "^[^ \t]" nil t)
1567 (defvar gnus-article-normalized-header-length 40
1568 "Length of normalized headers.")
1570 (defun article-normalize-headers ()
1571 "Make all header lines 40 characters long."
1573 (let ((buffer-read-only nil)
1577 (article-narrow-to-head)
1580 ((< (setq column (- (gnus-point-at-eol) (point)))
1581 gnus-article-normalized-header-length)
1583 (insert (make-string
1584 (- gnus-article-normalized-header-length column)
1586 ((> column gnus-article-normalized-header-length)
1587 (gnus-put-text-property
1589 (forward-char gnus-article-normalized-header-length)
1596 (forward-line 1))))))
1598 (defun article-treat-dumbquotes ()
1599 "Translate M****s*** sm*rtq**t*s into proper text.
1600 Note that this function guesses whether a character is a sm*rtq**t* or
1601 not, so it should only be used interactively.
1603 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1604 in an attempt to provide more quoting characters. If you see
1605 something like \\222 or \\264 where you're expecting some kind of
1606 apostrophe or quotation mark, then try this wash."
1608 (article-translate-strings gnus-article-dumbquotes-map))
1610 (defun article-translate-characters (from to)
1611 "Translate all characters in the body of the article according to FROM and TO.
1612 FROM is a string of characters to translate from; to is a string of
1613 characters to translate to."
1615 (when (article-goto-body)
1616 (let ((buffer-read-only nil)
1617 (x (make-string 225 ?x))
1619 (while (< (incf i) (length x))
1622 (while (< i (length from))
1623 (aset x (aref from i) (aref to i))
1625 (translate-region (point) (point-max) x)))))
1627 (defun article-translate-strings (map)
1628 "Translate all string in the body of the article according to MAP.
1629 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1631 (when (article-goto-body)
1632 (let ((buffer-read-only nil)
1634 (while (setq elem (pop map))
1636 (while (search-forward (car elem) nil t)
1637 (replace-match (cadr elem)))))))))
1639 (defun article-treat-overstrike ()
1640 "Translate overstrikes into bold text."
1643 (when (article-goto-body)
1644 (let ((buffer-read-only nil))
1645 (while (search-forward "\b" nil t)
1646 (let ((next (char-after))
1647 (previous (char-after (- (point) 2))))
1648 ;; We do the boldification/underlining by hiding the
1649 ;; overstrikes and putting the proper text property
1653 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1654 (put-text-property (point) (1+ (point)) 'face 'bold))
1656 (gnus-article-hide-text-type
1657 (1- (point)) (1+ (point)) 'overstrike)
1659 (- (point) 2) (1- (point)) 'face 'underline))
1661 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1663 (point) (1+ (point)) 'face 'underline)))))))))
1665 (defun gnus-article-treat-unfold-headers ()
1666 "Unfold folded message headers.
1667 Only the headers that fit into the current window width will be
1670 (gnus-with-article-headers
1674 (mail-header-narrow-to-field)
1675 (let ((header (buffer-substring (point-min) (point-max))))
1678 (goto-char (point-min))
1679 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1680 (replace-match " " t t)))
1681 (setq length (- (point-max) (point-min) 1)))
1682 (when (< length (window-width))
1683 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1684 (replace-match " " t t)))
1685 (goto-char (point-max)))))))
1687 (defun gnus-article-treat-fold-headers ()
1688 "Fold message headers."
1690 (gnus-with-article-headers
1693 (mail-header-narrow-to-field)
1694 (mail-header-fold-field)
1695 (goto-char (point-max))))))
1697 (defun gnus-treat-smiley ()
1698 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1700 (gnus-with-article-buffer
1701 (if (memq 'smiley gnus-article-wash-types)
1702 (gnus-delete-images 'smiley)
1704 (let ((images (smiley-region (point) (point-max))))
1706 (gnus-add-wash-type 'smiley)
1707 (dolist (image images)
1708 (gnus-add-image 'smiley image)))))))
1710 (defun gnus-article-remove-images ()
1711 "Remove all images from the article buffer."
1713 (gnus-with-article-buffer
1714 (dolist (elem gnus-article-image-alist)
1715 (gnus-delete-images (car elem)))))
1717 (defun gnus-article-treat-fold-newsgroups ()
1718 "Unfold folded message headers.
1719 Only the headers that fit into the current window width will be
1722 (gnus-with-article-headers
1723 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1725 (mail-header-narrow-to-field)
1726 (while (re-search-forward ", *" nil t)
1727 (replace-match ", " t t))
1728 (mail-header-fold-field)
1729 (goto-char (point-max))))))
1731 (defun gnus-article-treat-body-boundary ()
1732 "Place a boundary line at the end of the headers."
1734 (when (and gnus-body-boundary-delimiter
1735 (> (length gnus-body-boundary-delimiter) 0))
1736 (gnus-with-article-headers
1737 (goto-char (point-max))
1738 (let ((start (point)))
1739 (insert "X-Boundary: ")
1740 (gnus-add-text-properties start (point) '(invisible t intangible t))
1742 (while (>= (1- (window-width)) (length str))
1743 (setq str (concat str gnus-body-boundary-delimiter)))
1744 (substring str 0 (1- (window-width))))
1747 (defun article-fill-long-lines ()
1748 "Fill lines that are wider than the window width."
1751 (let ((buffer-read-only nil)
1752 (width (window-width (get-buffer-window (current-buffer)))))
1755 (let ((adaptive-fill-mode nil)) ;Why? -sm
1758 (when (>= (current-column) (min fill-column width))
1759 (narrow-to-region (point) (gnus-point-at-bol))
1760 (fill-paragraph nil)
1761 (goto-char (point-max))
1763 (forward-line 1)))))))
1765 (defun article-capitalize-sentences ()
1766 "Capitalize the first word in each sentence."
1769 (let ((buffer-read-only nil)
1770 (paragraph-start "^[\n\^L]"))
1774 (forward-sentence)))))
1776 (defun article-remove-cr ()
1777 "Remove trailing CRs and then translate remaining CRs into LFs."
1780 (let ((buffer-read-only nil))
1781 (goto-char (point-min))
1782 (while (re-search-forward "\r+$" nil t)
1783 (replace-match "" t t))
1784 (goto-char (point-min))
1785 (while (search-forward "\r" nil t)
1786 (replace-match "\n" t t)))))
1788 (defun article-remove-trailing-blank-lines ()
1789 "Remove all trailing blank lines from the article."
1792 (let ((buffer-read-only nil))
1793 (goto-char (point-max))
1797 (while (and (not (bobp))
1798 (looking-at "^[ \t]*$")
1799 (not (gnus-annotation-in-region-p
1800 (point) (gnus-point-at-eol))))
1805 (defun article-display-x-face (&optional force)
1806 "Look for an X-Face header and display it if present."
1807 (interactive (list 'force))
1808 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1809 (gnus-with-article-headers
1810 ;; Delete the old process, if any.
1811 (when (process-status "article-x-face")
1812 (delete-process "article-x-face"))
1813 (if (memq 'xface gnus-article-wash-types)
1814 ;; We have already displayed X-Faces, so we remove them
1816 (gnus-delete-images 'xface)
1818 (let (x-faces from face grey)
1820 (when (and wash-face-p
1822 (goto-char (point-min))
1823 (not (re-search-forward
1824 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1825 (gnus-buffer-live-p gnus-original-article-buffer))
1826 ;; If type `W f', use gnus-original-article-buffer,
1827 ;; otherwise use the current buffer because displaying
1828 ;; RFC822 parts calls this function too.
1829 (set-buffer gnus-original-article-buffer))
1831 (mail-narrow-to-head)
1832 (while (gnus-article-goto-header "x-face\\(-[0-9]+\\)?")
1833 (when (match-beginning 2)
1835 (push (mail-header-field-value) x-faces))
1836 (setq from (message-fetch-field "from"))))
1838 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1841 (setq image (gnus-create-image xpm 'xpm t))
1842 (gnus-article-goto-header "from")
1844 (insert "From: [no `from' set]\n")
1846 (gnus-add-wash-type 'xface)
1847 (gnus-add-image 'xface image)
1848 (gnus-put-image image)))
1849 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1850 ;; single external face.
1851 (when (stringp gnus-article-x-face-command)
1852 (setq x-faces (list (car x-faces))))
1853 (while (and (setq face (pop x-faces))
1854 gnus-article-x-face-command
1856 ;; Check whether this face is censored.
1857 (not gnus-article-x-face-too-ugly)
1858 (and gnus-article-x-face-too-ugly from
1859 (not (string-match gnus-article-x-face-too-ugly
1861 ;; We display the face.
1862 (if (symbolp gnus-article-x-face-command)
1863 ;; The command is a lisp function, so we call it.
1864 (if (gnus-functionp gnus-article-x-face-command)
1865 (funcall gnus-article-x-face-command face)
1866 (error "%s is not a function" gnus-article-x-face-command))
1867 ;; The command is a string, so we interpret the command
1868 ;; as a, well, command, and fork it off.
1869 (let ((process-connection-type nil))
1870 (process-kill-without-query
1872 "article-x-face" nil shell-file-name shell-command-switch
1873 gnus-article-x-face-command))
1876 (process-send-region "article-x-face"
1877 (point-min) (point-max)))
1878 (process-send-eof "article-x-face"))))))))))
1880 (defun article-decode-mime-words ()
1881 "Decode all MIME-encoded words in the article."
1884 (set-buffer gnus-article-buffer)
1885 (let ((inhibit-point-motion-hooks t)
1887 (mail-parse-charset gnus-newsgroup-charset)
1888 (mail-parse-ignored-charsets
1889 (save-excursion (set-buffer gnus-summary-buffer)
1890 gnus-newsgroup-ignored-charsets)))
1891 (mail-decode-encoded-word-region (point-min) (point-max)))))
1893 (defun article-decode-charset (&optional prompt)
1894 "Decode charset-encoded text in the article.
1895 If PROMPT (the prefix), prompt for a coding system to use."
1897 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1899 (mail-parse-charset gnus-newsgroup-charset)
1900 (mail-parse-ignored-charsets
1901 (save-excursion (condition-case nil
1902 (set-buffer gnus-summary-buffer)
1904 gnus-newsgroup-ignored-charsets))
1905 ct cte ctl charset format)
1908 (article-narrow-to-head)
1909 (setq ct (message-fetch-field "Content-Type" t)
1910 cte (message-fetch-field "Content-Transfer-Encoding" t)
1911 ctl (and ct (ignore-errors
1912 (mail-header-parse-content-type ct)))
1915 (mm-read-coding-system "Charset to decode: "))
1917 (mail-content-type-get ctl 'charset)))
1918 format (and ctl (mail-content-type-get ctl 'format)))
1920 (setq cte (mail-header-strip cte)))
1921 (if (and ctl (not (string-match "/" (car ctl))))
1923 (goto-char (point-max)))
1926 (narrow-to-region (point) (point-max))
1927 (when (and (eq mail-parse-charset 'gnus-decoded)
1928 (eq (mm-body-7-or-8) '8bit))
1929 ;; The text code could have been decoded.
1930 (setq charset mail-parse-charset))
1931 (when (and (or (not ctl)
1932 (equal (car ctl) "text/plain"))
1933 (not format)) ;; article with format will decode later.
1935 charset (and cte (intern (downcase
1936 (gnus-strip-whitespace cte))))
1939 (defun article-decode-encoded-words ()
1940 "Remove encoded-word encoding from headers."
1941 (let ((inhibit-point-motion-hooks t)
1942 (mail-parse-charset gnus-newsgroup-charset)
1943 (mail-parse-ignored-charsets
1944 (save-excursion (condition-case nil
1945 (set-buffer gnus-summary-buffer)
1947 gnus-newsgroup-ignored-charsets))
1950 (article-narrow-to-head)
1951 (funcall gnus-decode-header-function (point-min) (point-max)))))
1953 (defun article-decode-group-name ()
1954 "Decode group names in `Newsgroups:'."
1955 (let ((inhibit-point-motion-hooks t)
1957 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1958 (when (and (or gnus-group-name-charset-method-alist
1959 gnus-group-name-charset-group-alist)
1960 (gnus-buffer-live-p gnus-original-article-buffer))
1961 (when (nnmail-fetch-field "Newsgroups")
1962 (nnheader-replace-header "Newsgroups"
1963 (gnus-decode-newsgroups
1964 (with-current-buffer
1965 gnus-original-article-buffer
1966 (nnmail-fetch-field "Newsgroups"))
1967 gnus-newsgroup-name method)))
1968 (when (nnmail-fetch-field "Followup-To")
1969 (nnheader-replace-header "Followup-To"
1970 (gnus-decode-newsgroups
1971 (with-current-buffer
1972 gnus-original-article-buffer
1973 (nnmail-fetch-field "Followup-To"))
1974 gnus-newsgroup-name method))))))
1976 (defun article-de-quoted-unreadable (&optional force read-charset)
1977 "Translate a quoted-printable-encoded article.
1978 If FORCE, decode the article whether it is marked as quoted-printable
1980 If READ-CHARSET, ask for a coding system."
1981 (interactive (list 'force current-prefix-arg))
1983 (let ((buffer-read-only nil) type charset)
1984 (if (gnus-buffer-live-p gnus-original-article-buffer)
1985 (with-current-buffer gnus-original-article-buffer
1987 (gnus-fetch-field "content-transfer-encoding"))
1988 (let* ((ct (gnus-fetch-field "content-type"))
1991 (mail-header-parse-content-type ct)))))
1992 (setq charset (and ctl
1993 (mail-content-type-get ctl 'charset)))
1994 (if (stringp charset)
1995 (setq charset (intern (downcase charset)))))))
1997 (setq charset (mm-read-coding-system "Charset: " charset)))
1999 (setq charset gnus-newsgroup-charset))
2001 (and type (let ((case-fold-search t))
2002 (string-match "quoted-printable" type))))
2004 (quoted-printable-decode-region
2005 (point) (point-max) (mm-charset-to-coding-system charset))))))
2007 (defun article-de-base64-unreadable (&optional force read-charset)
2008 "Translate a base64 article.
2009 If FORCE, decode the article whether it is marked as base64 not.
2010 If READ-CHARSET, ask for a coding system."
2011 (interactive (list 'force current-prefix-arg))
2013 (let ((buffer-read-only nil) type charset)
2014 (if (gnus-buffer-live-p gnus-original-article-buffer)
2015 (with-current-buffer gnus-original-article-buffer
2017 (gnus-fetch-field "content-transfer-encoding"))
2018 (let* ((ct (gnus-fetch-field "content-type"))
2021 (mail-header-parse-content-type ct)))))
2022 (setq charset (and ctl
2023 (mail-content-type-get ctl 'charset)))
2024 (if (stringp charset)
2025 (setq charset (intern (downcase charset)))))))
2027 (setq charset (mm-read-coding-system "Charset: " charset)))
2029 (setq charset gnus-newsgroup-charset))
2031 (and type (let ((case-fold-search t))
2032 (string-match "base64" type))))
2035 (narrow-to-region (point) (point-max))
2036 (base64-decode-region (point-min) (point-max))
2037 (mm-decode-coding-region
2038 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2043 (defun article-decode-HZ ()
2044 "Translate a HZ-encoded article."
2048 (let ((buffer-read-only nil))
2049 (rfc1843-decode-region (point-min) (point-max)))))
2051 (defun article-wash-html (&optional read-charset)
2052 "Format an html article.
2053 If READ-CHARSET, ask for a coding system."
2056 (let ((buffer-read-only nil)
2058 (if (gnus-buffer-live-p gnus-original-article-buffer)
2059 (with-current-buffer gnus-original-article-buffer
2060 (let* ((ct (gnus-fetch-field "content-type"))
2063 (mail-header-parse-content-type ct)))))
2064 (setq charset (and ctl
2065 (mail-content-type-get ctl 'charset)))
2066 (if (stringp charset)
2067 (setq charset (intern (downcase charset)))))))
2069 (setq charset (mm-read-coding-system "Charset: " charset)))
2071 (setq charset gnus-newsgroup-charset))
2073 (save-window-excursion
2075 (narrow-to-region (point) (point-max))
2076 (funcall gnus-article-wash-function))))))
2078 (defun gnus-article-wash-html-with-w3 ()
2079 "Wash the current buffer with w3."
2081 (let ((w3-strict-width (window-width))
2082 (url-standalone-mode t)
2083 (url-gateway-unplugged t)
2084 (w3-honor-stylesheets nil)
2085 (w3-delay-image-loads t))
2087 (w3-region (point-min) (point-max))
2090 (defun gnus-article-wash-html-with-w3m ()
2091 "Wash the current buffer with emacs-w3m."
2094 (narrow-to-region (point) (point-max))
2095 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2098 (w3m-display-inline-images mm-inline-text-html-with-images)
2099 w3m-force-redisplay)
2100 (w3m-region (point-min) (point-max)))
2101 (when mm-inline-text-html-with-w3m-keymap
2102 (add-text-properties
2103 (point-min) (point-max)
2104 (append '(mm-inline-text-html-with-w3m t)
2105 (gnus-local-map-property mm-w3m-mode-map))))))
2107 (defun article-hide-list-identifiers ()
2108 "Remove list identifies from the Subject header.
2109 The `gnus-list-identifiers' variable specifies what to do."
2111 (let ((inhibit-point-motion-hooks t)
2112 (regexp (if (consp gnus-list-identifiers)
2113 (mapconcat 'identity gnus-list-identifiers " *\\|")
2114 gnus-list-identifiers))
2119 (article-narrow-to-head)
2120 (goto-char (point-min))
2121 (while (re-search-forward
2122 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2124 (delete-region (match-beginning 2) (match-end 0))
2125 (beginning-of-line))
2126 (when (re-search-forward
2127 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2128 (delete-region (match-beginning 1) (match-end 1))))))))
2130 (defun article-hide-pgp ()
2131 "Remove any PGP headers and signatures in the current article."
2135 (let ((inhibit-point-motion-hooks t)
2136 buffer-read-only beg end)
2138 ;; Hide the "header".
2139 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2140 (gnus-add-wash-type 'pgp)
2141 (delete-region (match-beginning 0) (match-end 0))
2142 ;; Remove armor headers (rfc2440 6.2)
2143 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2146 ;; Hide the actual signature.
2147 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2148 (setq end (1+ (match-beginning 0)))
2151 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2153 ;; Perhaps we shouldn't hide to the end of the buffer
2154 ;; if there is no end to the signature?
2156 ;; Hide "- " PGP quotation markers.
2158 (narrow-to-region beg end)
2159 (goto-char (point-min))
2160 (while (re-search-forward "^- " nil t)
2162 (match-beginning 0) (match-end 0)))
2164 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2166 (defun article-hide-pem (&optional arg)
2167 "Toggle hiding of any PEM headers and signatures in the current article.
2168 If given a negative prefix, always show; if given a positive prefix,
2170 (interactive (gnus-article-hidden-arg))
2171 (unless (gnus-article-check-hidden-text 'pem arg)
2173 (let (buffer-read-only end)
2174 (goto-char (point-min))
2175 ;; Hide the horrendously ugly "header".
2176 (when (and (search-forward
2177 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2179 (setq end (1+ (match-beginning 0))))
2180 (gnus-add-wash-type 'pem)
2181 (gnus-article-hide-text-type
2183 (if (search-forward "\n\n" nil t)
2187 ;; Hide the trailer as well
2188 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2190 (gnus-article-hide-text-type
2191 (match-beginning 0) (match-end 0) 'pem)))))))
2193 (defun article-strip-banner ()
2194 "Strip the banner specified by the `banner' group parameter."
2198 (let ((inhibit-point-motion-hooks t)
2199 (banner (gnus-parameter-banner gnus-newsgroup-name))
2200 (gnus-signature-limit nil)
2201 buffer-read-only beg end)
2205 ((eq banner 'signature)
2206 (when (gnus-article-narrow-to-signature)
2209 (delete-region (point) (point-max))))
2211 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2212 (while (re-search-forward banner nil t)
2213 (delete-region (match-beginning 0) (match-end 0)))))
2215 (while (re-search-forward banner nil t)
2216 (delete-region (match-beginning 0) (match-end 0))))))))))
2218 (defun article-babel ()
2219 "Translate article using an online translation service."
2223 (set-buffer gnus-article-buffer)
2224 (when (article-goto-body)
2225 (let* ((buffer-read-only nil)
2228 (orig (buffer-substring start end))
2229 (trans (babel-as-string orig)))
2231 (narrow-to-region start end)
2232 (delete-region start end)
2235 (defun article-hide-signature (&optional arg)
2236 "Hide the signature in the current article.
2237 If given a negative prefix, always show; if given a positive prefix,
2239 (interactive (gnus-article-hidden-arg))
2240 (unless (gnus-article-check-hidden-text 'signature arg)
2243 (let ((buffer-read-only nil))
2244 (when (gnus-article-narrow-to-signature)
2245 (gnus-article-hide-text-type
2246 (point-min) (point-max) 'signature))))))
2247 (gnus-set-mode-line 'article))
2249 (defun article-strip-headers-in-body ()
2250 "Strip offensive headers from bodies."
2254 (let ((case-fold-search t))
2255 (when (looking-at "x-no-archive:")
2256 (gnus-delete-line)))))
2258 (defun article-strip-leading-blank-lines ()
2259 "Remove all blank lines from the beginning of the article."
2262 (let ((inhibit-point-motion-hooks t)
2264 (when (article-goto-body)
2265 (while (and (not (eobp))
2266 (looking-at "[ \t]*$"))
2267 (gnus-delete-line))))))
2269 (defun article-narrow-to-head ()
2270 "Narrow the buffer to the head of the message.
2271 Point is left at the beginning of the narrowed-to region."
2273 (goto-char (point-min))
2274 (if (search-forward "\n\n" nil 1)
2277 (goto-char (point-min)))
2279 (defun article-goto-body ()
2280 "Place point at the start of the body."
2281 (goto-char (point-min))
2283 ;; This variable is only bound when dealing with separate
2285 (article-goto-body-goes-to-point-min-p
2287 ((search-forward "\n\n" nil t)
2290 (goto-char (point-max))
2293 (defun article-strip-multiple-blank-lines ()
2294 "Replace consecutive blank lines with one empty line."
2297 (let ((inhibit-point-motion-hooks t)
2299 ;; First make all blank lines empty.
2301 (while (re-search-forward "^[ \t]+$" nil t)
2302 (unless (gnus-annotation-in-region-p
2303 (match-beginning 0) (match-end 0))
2304 (replace-match "" nil t)))
2305 ;; Then replace multiple empty lines with a single empty line.
2307 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2308 (unless (gnus-annotation-in-region-p
2309 (match-beginning 0) (match-end 0))
2310 (delete-region (match-beginning 1) (match-end 1)))))))
2312 (defun article-strip-leading-space ()
2313 "Remove all white space from the beginning of the lines in the article."
2316 (let ((inhibit-point-motion-hooks t)
2319 (while (re-search-forward "^[ \t]+" nil t)
2320 (replace-match "" t t)))))
2322 (defun article-strip-trailing-space ()
2323 "Remove all white space from the end of the lines in the article."
2326 (let ((inhibit-point-motion-hooks t)
2329 (while (re-search-forward "[ \t]+$" nil t)
2330 (replace-match "" t t)))))
2332 (defun article-strip-blank-lines ()
2333 "Strip leading, trailing and multiple blank lines."
2335 (article-strip-leading-blank-lines)
2336 (article-remove-trailing-blank-lines)
2337 (article-strip-multiple-blank-lines))
2339 (defun article-strip-all-blank-lines ()
2340 "Strip all blank lines."
2343 (let ((inhibit-point-motion-hooks t)
2346 (while (re-search-forward "^[ \t]*\n" nil t)
2347 (replace-match "" t t)))))
2349 (defun gnus-article-narrow-to-signature ()
2350 "Narrow to the signature; return t if a signature is found, else nil."
2351 (let ((inhibit-point-motion-hooks t))
2352 (when (gnus-article-search-signature)
2354 ;; Check whether we have some limits to what we consider
2355 ;; to be a signature.
2356 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2357 (list gnus-signature-limit)))
2359 (while (setq limit (pop limits))
2360 (if (or (and (integerp limit)
2361 (< (- (point-max) (point)) limit))
2363 (< (count-lines (point) (point-max)) limit))
2364 (and (gnus-functionp limit)
2366 (and (stringp limit)
2367 (not (re-search-forward limit nil t))))
2368 () ; This limit did not succeed.
2372 (narrow-to-region (point) (point-max))
2375 (defun gnus-article-search-signature ()
2376 "Search the current buffer for the signature separator.
2377 Put point at the beginning of the signature separator."
2378 (let ((cur (point)))
2379 (goto-char (point-max))
2380 (if (if (stringp gnus-signature-separator)
2381 (re-search-backward gnus-signature-separator nil t)
2382 (let ((seps gnus-signature-separator))
2384 (not (re-search-backward (car seps) nil t)))
2391 (defun gnus-article-hidden-arg ()
2392 "Return the current prefix arg as a number, or 0 if no prefix."
2393 (list (if current-prefix-arg
2394 (prefix-numeric-value current-prefix-arg)
2397 (defun gnus-article-check-hidden-text (type arg)
2398 "Return nil if hiding is necessary.
2399 Arg can be nil or a number. nil and positive means hide, negative
2400 means show, 0 means toggle."
2403 (let ((hide (gnus-article-hidden-text-p type)))
2409 (gnus-article-show-hidden-text type)
2412 (if (eq hide 'hidden)
2414 (gnus-article-show-hidden-text type)
2418 (defun gnus-article-hidden-text-p (type)
2419 "Say whether the current buffer contains hidden text of type TYPE."
2420 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2422 (not (get-text-property pos 'invisible))
2423 (not (get-text-property pos 'dummy-invisible)))
2425 (text-property-any (1+ pos) (point-max) 'article-type type)))
2430 (defun gnus-article-show-hidden-text (type &optional dummy)
2431 "Show all hidden text of type TYPE.
2432 Originally it is hide instead of DUMMY."
2433 (let ((buffer-read-only nil)
2434 (inhibit-point-motion-hooks t))
2435 (gnus-remove-text-properties-when
2437 (point-min) (point-max)
2438 (cons 'article-type (cons type
2439 gnus-hidden-properties)))
2440 (gnus-delete-wash-type type)))
2442 (defconst article-time-units
2443 `((year . ,(* 365.25 24 60 60))
2444 (week . ,(* 7 24 60 60))
2445 (day . ,(* 24 60 60))
2449 "Mapping from time units to seconds.")
2451 (defun article-date-ut (&optional type highlight header)
2452 "Convert DATE date to universal time in the current article.
2453 If TYPE is `local', convert to local time; if it is `lapsed', output
2454 how much time has lapsed since DATE. For `lapsed', the value of
2455 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2456 should replace the \"Date:\" one, or should be added below it."
2457 (interactive (list 'ut t))
2458 (let* ((header (or header
2459 (message-fetch-field "date")
2461 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2464 ((not gnus-article-date-lapsed-new-header)
2470 (date (if (vectorp header) (mail-header-date header)
2472 (inhibit-point-motion-hooks t)
2477 (article-narrow-to-head)
2478 (when (re-search-forward tdate-regexp nil t)
2479 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2480 date (or (get-text-property (gnus-point-at-bol)
2483 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2485 (when (and date (not (string= date "")))
2486 (goto-char (point-min))
2487 (let ((buffer-read-only nil))
2488 ;; Delete any old Date headers.
2489 (while (re-search-forward date-regexp nil t)
2491 (delete-region (progn (beginning-of-line) (point))
2492 (progn (forward-line 1) (point)))
2493 (delete-region (progn (beginning-of-line) (point))
2494 (progn (end-of-line) (point)))
2495 (setq pos (point))))
2496 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2498 (if pos (goto-char pos))
2499 (insert (article-make-date-line date (or type 'ut)))
2505 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2506 (put-text-property (match-beginning 1) (1+ (match-end 1))
2507 'original-date date)
2508 (put-text-property (match-beginning 1) (1+ (match-end 1))
2510 (put-text-property (match-beginning 2) (match-end 2)
2513 (defun article-make-date-line (date type)
2514 "Return a DATE line of TYPE."
2515 (unless (memq type '(local ut original user iso8601 lapsed english))
2516 (error "Unknown conversion type: %s" type))
2518 (let ((time (date-to-time date)))
2520 ;; Convert to the local timezone.
2522 (let ((tz (car (current-time-zone time))))
2523 (format "Date: %s %s%02d%02d" (current-time-string time)
2524 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2525 (/ (% (abs tz) 3600) 60))))
2526 ;; Convert to Universal Time.
2529 (current-time-string
2530 (let* ((e (parse-time-string date))
2531 (tm (apply 'encode-time e))
2533 (ls (- (cadr tm) (car (current-time-zone time)))))
2534 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2535 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2538 ;; Get the original date from the article.
2539 ((eq type 'original)
2540 (concat "Date: " (if (string-match "\n+$" date)
2541 (substring date 0 (match-beginning 0))
2543 ;; Let the user define the format.
2545 (if (gnus-functionp gnus-article-time-format)
2546 (funcall gnus-article-time-format time)
2549 (format-time-string gnus-article-time-format time))))
2552 (let ((tz (car (current-time-zone time))))
2555 (format-time-string "%Y%m%dT%H%M%S" time)
2556 (format "%s%02d%02d"
2557 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2558 (/ (% (abs tz) 3600) 60)))))
2559 ;; Do an X-Sent lapsed format.
2561 ;; If the date is seriously mangled, the timezone functions are
2562 ;; liable to bug out, so we ignore all errors.
2563 (let* ((now (current-time))
2564 (real-time (subtract-time now time))
2565 (real-sec (and real-time
2566 (+ (* (float (car real-time)) 65536)
2568 (sec (and real-time (abs real-sec)))
2578 ;; This is a bit convoluted, but basically we go
2579 ;; through the time units for years, weeks, etc,
2580 ;; and divide things to see whether that results
2581 ;; in positive answers.
2584 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2585 ;; The (remaining) seconds are too few to
2586 ;; be divided into this time unit.
2588 ;; It's big enough, so we output it.
2589 (setq sec (- sec (* num (cdr unit))))
2591 (concat (if prev ", " "") (int-to-string
2593 " " (symbol-name (car unit))
2594 (if (> num 1) "s" ""))
2596 article-time-units "")
2597 ;; If dates are odd, then it might appear like the
2598 ;; article was sent in the future.
2601 " in the future"))))))
2602 ;; Display the date in proper English
2604 (let ((dtime (decode-time time)))
2607 (number-to-string (nth 3 dtime))
2608 (let ((digit (% (nth 3 dtime) 10)))
2610 ((memq (nth 3 dtime) '(11 12 13)) "th")
2616 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2618 (number-to-string (nth 5 dtime))
2620 (format "%02d" (nth 2 dtime))
2622 (format "%02d" (nth 1 dtime)))))))
2624 (format "Date: %s (from Oort)" date))))
2626 (defun article-date-local (&optional highlight)
2627 "Convert the current article date to the local timezone."
2628 (interactive (list t))
2629 (article-date-ut 'local highlight))
2631 (defun article-date-english (&optional highlight)
2632 "Convert the current article date to something that is proper English."
2633 (interactive (list t))
2634 (article-date-ut 'english highlight))
2636 (defun article-date-original (&optional highlight)
2637 "Convert the current article date to what it was originally.
2638 This is only useful if you have used some other date conversion
2639 function and want to see what the date was before converting."
2640 (interactive (list t))
2641 (article-date-ut 'original highlight))
2643 (defun article-date-lapsed (&optional highlight)
2644 "Convert the current article date to time lapsed since it was sent."
2645 (interactive (list t))
2646 (article-date-ut 'lapsed highlight))
2648 (defun article-update-date-lapsed ()
2649 "Function to be run from a timer to update the lapsed time line."
2650 (let (deactivate-mark)
2655 (set-buffer (window-buffer w))
2656 (when (eq major-mode 'gnus-article-mode)
2657 (goto-char (point-min))
2658 (when (re-search-forward "^X-Sent:" nil t)
2659 (article-date-lapsed t))))
2662 (defun gnus-start-date-timer (&optional n)
2663 "Start a timer to update the X-Sent header in the article buffers.
2664 The numerical prefix says how frequently (in seconds) the function
2669 (gnus-stop-date-timer)
2670 (setq article-lapsed-timer
2671 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2673 (defun gnus-stop-date-timer ()
2674 "Stop the X-Sent timer."
2676 (when article-lapsed-timer
2677 (nnheader-cancel-timer article-lapsed-timer)
2678 (setq article-lapsed-timer nil)))
2680 (defun article-date-user (&optional highlight)
2681 "Convert the current article date to the user-defined format.
2682 This format is defined by the `gnus-article-time-format' variable."
2683 (interactive (list t))
2684 (article-date-ut 'user highlight))
2686 (defun article-date-iso8601 (&optional highlight)
2687 "Convert the current article date to ISO8601."
2688 (interactive (list t))
2689 (article-date-ut 'iso8601 highlight))
2691 ;; (defun article-show-all ()
2692 ;; "Show all hidden text in the article buffer."
2695 ;; (let ((buffer-read-only nil))
2696 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2698 (defun article-remove-leading-whitespace ()
2699 "Remove excessive whitespace from all headers."
2703 (let ((buffer-read-only nil))
2704 (article-narrow-to-head)
2705 (goto-char (point-min))
2706 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2707 (delete-region (match-beginning 1) (match-end 1)))))))
2709 (defun article-emphasize (&optional arg)
2710 "Emphasize text according to `gnus-emphasis-alist'."
2711 (interactive (gnus-article-hidden-arg))
2712 (unless (gnus-article-check-hidden-text 'emphasis arg)
2716 (with-current-buffer gnus-summary-buffer
2717 gnus-article-emphasis-alist)
2719 gnus-emphasis-alist))
2720 (buffer-read-only nil)
2721 (props (append '(article-type emphasis)
2722 gnus-hidden-properties))
2723 regexp elem beg invisible visible face)
2726 (while (setq elem (pop alist))
2728 (setq regexp (car elem)
2729 invisible (nth 1 elem)
2730 visible (nth 2 elem)
2732 (while (re-search-forward regexp nil t)
2733 (when (and (match-beginning visible) (match-beginning invisible))
2734 (gnus-article-hide-text
2735 (match-beginning invisible) (match-end invisible) props)
2736 (gnus-article-unhide-text-type
2737 (match-beginning visible) (match-end visible) 'emphasis)
2738 (gnus-put-overlay-excluding-newlines
2739 (match-beginning visible) (match-end visible) 'face face)
2740 (gnus-add-wash-type 'emphasis)
2741 (goto-char (match-end invisible)))))))))
2743 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2744 "Setup newsgroup emphasis alist."
2745 (unless gnus-article-emphasis-alist
2746 (let ((name (and gnus-newsgroup-name
2747 (gnus-group-real-name gnus-newsgroup-name))))
2748 (make-local-variable 'gnus-article-emphasis-alist)
2749 (setq gnus-article-emphasis-alist
2751 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2752 (while (setq elem (pop alist))
2753 (when (and name (string-match (car elem) name))
2755 highlight (copy-sequence (cdr elem)))))
2757 (copy-sequence highlight-words)
2758 (if gnus-newsgroup-name
2759 (copy-sequence (gnus-group-find-parameter
2760 gnus-newsgroup-name 'highlight-words t)))
2761 gnus-emphasis-alist)))))
2764 (defvar gnus-summary-article-menu)
2765 (defvar gnus-summary-post-menu))
2767 ;;; Saving functions.
2769 (defun gnus-article-save (save-buffer file &optional num)
2770 "Save the currently selected article."
2771 (unless gnus-save-all-headers
2772 ;; Remove headers according to `gnus-saved-headers'.
2773 (let ((gnus-visible-headers
2774 (or gnus-saved-headers gnus-visible-headers))
2775 (gnus-article-buffer save-buffer))
2777 (set-buffer save-buffer)
2778 (article-hide-headers 1 t))))
2779 (save-window-excursion
2780 (if (not gnus-default-article-saver)
2781 (error "No default saver is defined")
2782 ;; !!! Magic! The saving functions all save
2783 ;; `gnus-save-article-buffer' (or so they think), but we
2784 ;; bind that variable to our save-buffer.
2785 (set-buffer gnus-article-buffer)
2786 (let* ((gnus-save-article-buffer save-buffer)
2789 ((not gnus-prompt-before-saving) 'default)
2790 ((eq gnus-prompt-before-saving 'always) nil)
2792 (gnus-number-of-articles-to-be-saved
2793 (when (eq gnus-prompt-before-saving t)
2795 (set-buffer gnus-article-current-summary)
2796 (funcall gnus-default-article-saver filename)))))
2798 (defun gnus-read-save-file-name (prompt &optional filename
2799 function group headers variable)
2801 (funcall function group headers (symbol-value variable)))
2806 ((eq filename 'default)
2812 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2815 (if (and gnus-number-of-articles-to-be-saved
2816 (> gnus-number-of-articles-to-be-saved 1))
2817 (format "these %d articles"
2818 gnus-number-of-articles-to-be-saved)
2821 ;; Let the split methods have their say.
2823 ;; No split name was found.
2826 (concat prompt " (default "
2827 (file-name-nondirectory default-name) ") ")
2828 (file-name-directory default-name)
2830 ;; A single group name is returned.
2831 ((stringp split-name)
2833 (funcall function split-name headers
2834 (symbol-value variable)))
2836 (concat prompt " (default "
2837 (file-name-nondirectory default-name) ") ")
2838 (file-name-directory default-name)
2840 ;; A single split name was found
2841 ((= 1 (length split-name))
2842 (let* ((name (expand-file-name
2844 gnus-article-save-directory))
2845 (dir (cond ((file-directory-p name)
2846 (file-name-as-directory name))
2847 ((file-exists-p name) name)
2848 (t gnus-article-save-directory))))
2850 (concat prompt " (default " name ") ")
2852 ;; A list of splits was found.
2854 (setq split-name (nreverse split-name))
2856 (let ((file-name-history
2857 (nconc split-name file-name-history)))
2861 (concat prompt " (`M-p' for defaults) ")
2862 gnus-article-save-directory
2864 gnus-article-save-directory)))
2865 (car (push result file-name-history)))))))
2866 ;; Create the directory.
2867 (gnus-make-directory (file-name-directory file))
2868 ;; If we have read a directory, we append the default file name.
2869 (when (file-directory-p file)
2870 (setq file (expand-file-name (file-name-nondirectory
2872 (file-name-as-directory file))))
2873 ;; Possibly translate some characters.
2874 (nnheader-translate-file-chars file))))))
2875 (gnus-make-directory (file-name-directory result))
2876 (set variable result)))
2878 (defun gnus-article-archive-name (group)
2879 "Return the first instance of an \"Archive-name\" in the current buffer."
2880 (let ((case-fold-search t))
2881 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2882 (nnheader-concat gnus-article-save-directory
2883 (match-string 1)))))
2885 (defun gnus-article-nndoc-name (group)
2886 "If GROUP is an nndoc group, return the name of the parent group."
2887 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2888 (gnus-group-get-parameter group 'save-article-group)))
2890 (defun gnus-summary-save-in-rmail (&optional filename)
2891 "Append this article to Rmail file.
2892 Optional argument FILENAME specifies file name.
2893 Directory to save to is default to `gnus-article-save-directory'."
2894 (setq filename (gnus-read-save-file-name
2895 "Save %s in rmail file:" filename
2896 gnus-rmail-save-name gnus-newsgroup-name
2897 gnus-current-headers 'gnus-newsgroup-last-rmail))
2898 (gnus-eval-in-buffer-window gnus-save-article-buffer
2902 (gnus-output-to-rmail filename))))
2905 (defun gnus-summary-save-in-mail (&optional filename)
2906 "Append this article to Unix mail file.
2907 Optional argument FILENAME specifies file name.
2908 Directory to save to is default to `gnus-article-save-directory'."
2909 (setq filename (gnus-read-save-file-name
2910 "Save %s in Unix mail file:" filename
2911 gnus-mail-save-name gnus-newsgroup-name
2912 gnus-current-headers 'gnus-newsgroup-last-mail))
2913 (gnus-eval-in-buffer-window gnus-save-article-buffer
2917 (if (and (file-readable-p filename)
2918 (mail-file-babyl-p filename))
2919 (rmail-output-to-rmail-file filename t)
2920 (gnus-output-to-mail filename)))))
2923 (defun gnus-summary-save-in-file (&optional filename overwrite)
2924 "Append this article to file.
2925 Optional argument FILENAME specifies file name.
2926 Directory to save to is default to `gnus-article-save-directory'."
2927 (setq filename (gnus-read-save-file-name
2928 "Save %s in file:" filename
2929 gnus-file-save-name gnus-newsgroup-name
2930 gnus-current-headers 'gnus-newsgroup-last-file))
2931 (gnus-eval-in-buffer-window gnus-save-article-buffer
2935 (when (and overwrite
2936 (file-exists-p filename))
2937 (delete-file filename))
2938 (gnus-output-to-file filename))))
2941 (defun gnus-summary-write-to-file (&optional filename)
2942 "Write this article to a file, overwriting it if the file exists.
2943 Optional argument FILENAME specifies file name.
2944 The directory to save in defaults to `gnus-article-save-directory'."
2945 (gnus-summary-save-in-file nil t))
2947 (defun gnus-summary-save-body-in-file (&optional filename)
2948 "Append this article body to a file.
2949 Optional argument FILENAME specifies file name.
2950 The directory to save in defaults to `gnus-article-save-directory'."
2951 (setq filename (gnus-read-save-file-name
2952 "Save %s body in file:" filename
2953 gnus-file-save-name gnus-newsgroup-name
2954 gnus-current-headers 'gnus-newsgroup-last-file))
2955 (gnus-eval-in-buffer-window gnus-save-article-buffer
2959 (when (article-goto-body)
2960 (narrow-to-region (point) (point-max)))
2961 (gnus-output-to-file filename))))
2964 (defun gnus-summary-save-in-pipe (&optional command)
2965 "Pipe this article to subprocess."
2967 (cond ((and (eq command 'default)
2968 gnus-last-shell-command)
2969 gnus-last-shell-command)
2974 "Shell command on %s: "
2975 (if (and gnus-number-of-articles-to-be-saved
2976 (> gnus-number-of-articles-to-be-saved 1))
2977 (format "these %d articles"
2978 gnus-number-of-articles-to-be-saved)
2980 gnus-last-shell-command))))
2981 (when (string-equal command "")
2982 (if gnus-last-shell-command
2983 (setq command gnus-last-shell-command)
2984 (error "A command is required")))
2985 (gnus-eval-in-buffer-window gnus-article-buffer
2988 (shell-command-on-region (point-min) (point-max) command nil)))
2989 (setq gnus-last-shell-command command))
2991 (defun gnus-summary-pipe-to-muttprint (&optional command)
2992 "Pipe this article to muttprint."
2993 (setq command (read-string
2994 "Print using command: " gnus-summary-muttprint-program
2995 nil gnus-summary-muttprint-program))
2996 (gnus-summary-save-in-pipe command))
2998 ;;; Article file names when saving.
3000 (defun gnus-capitalize-newsgroup (newsgroup)
3001 "Capitalize NEWSGROUP name."
3002 (when (not (zerop (length newsgroup)))
3003 (concat (char-to-string (upcase (aref newsgroup 0)))
3004 (substring newsgroup 1))))
3006 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3007 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3008 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3009 Otherwise, it is like ~/News/news/group/num."
3012 (concat (if (gnus-use-long-file-name 'not-save)
3013 (gnus-capitalize-newsgroup newsgroup)
3014 (gnus-newsgroup-directory-form newsgroup))
3015 "/" (int-to-string (mail-header-number headers)))
3016 gnus-article-save-directory)))
3018 (string-equal (file-name-directory default)
3019 (file-name-directory last-file))
3020 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3022 (or last-file default))))
3024 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3025 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3026 If variable `gnus-use-long-file-name' is non-nil, it is
3027 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3030 (concat (if (gnus-use-long-file-name 'not-save)
3032 (gnus-newsgroup-directory-form newsgroup))
3033 "/" (int-to-string (mail-header-number headers)))
3034 gnus-article-save-directory)))
3036 (string-equal (file-name-directory default)
3037 (file-name-directory last-file))
3038 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3040 (or last-file default))))
3042 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3043 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3044 If variable `gnus-use-long-file-name' is non-nil, it is
3045 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3048 (if (gnus-use-long-file-name 'not-save)
3051 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3053 gnus-article-save-directory)))
3055 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3056 "Generate file name from sender."
3057 (let ((from (mail-header-from headers)))
3059 (if (and from (string-match "\\([^ <]+\\)@" from))
3060 (match-string 1 from)
3062 gnus-article-save-directory)))
3064 (defun article-verify-x-pgp-sig ()
3067 (if (gnus-buffer-live-p gnus-original-article-buffer)
3068 (let ((sig (with-current-buffer gnus-original-article-buffer
3069 (gnus-fetch-field "X-PGP-Sig")))
3073 (mml2015-clear-verify-function))
3075 (insert-buffer gnus-original-article-buffer)
3076 (setq items (split-string sig))
3077 (message-narrow-to-head)
3078 (let ((inhibit-point-motion-hooks t)
3079 (case-fold-search t))
3080 ;; Don't verify multiple headers.
3081 (setq headers (mapconcat (lambda (header)
3083 (mail-fetch-field header) "\n"))
3084 (split-string (nth 1 items) ",") "")))
3085 (delete-region (point-min) (point-max))
3086 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3087 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3092 (if (looking-at "^-")
3095 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3096 (insert "Version: " (car items) "\n\n")
3097 (insert (mapconcat 'identity (cddr items) "\n"))
3098 (insert "\n-----END PGP SIGNATURE-----\n")
3099 (let ((mm-security-handle (list (format "multipart/signed"))))
3100 (mml2015-clean-buffer)
3101 (let ((coding-system-for-write (or gnus-newsgroup-charset
3103 (funcall (mml2015-clear-verify-function)))
3105 (or (mm-handle-multipart-ctl-parameter
3106 mm-security-handle 'gnus-details)
3107 (mm-handle-multipart-ctl-parameter
3108 mm-security-handle 'gnus-info)))))
3110 (let (buffer-read-only bface eface)
3112 (message-narrow-to-head)
3113 (goto-char (point-max))
3115 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3116 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3117 (message-remove-header "X-Gnus-PGP-Verify")
3118 (if (re-search-forward "^X-PGP-Sig:" nil t)
3120 (goto-char (point-max)))
3121 (narrow-to-region (point) (point))
3122 (insert "X-Gnus-PGP-Verify: " info "\n")
3123 (goto-char (point-min))
3126 (if (not (looking-at "^[ \t]"))
3130 (goto-char (point-min))
3131 (when (looking-at "\\([^:]+\\): *")
3132 (put-text-property (match-beginning 1) (1+ (match-end 1))
3134 (put-text-property (match-end 0) (point-max)
3135 'face eface)))))))))
3137 (defun article-verify-cancel-lock ()
3138 "Verify Cancel-Lock header."
3140 (if (gnus-buffer-live-p gnus-original-article-buffer)
3141 (canlock-verify gnus-original-article-buffer)))
3148 (setq afunc (car func)
3151 gfunc (intern (format "gnus-%s" func))))
3153 (when (fboundp afunc)
3154 `(lambda (&optional interactive &rest args)
3155 ,(documentation afunc t)
3156 (interactive (list t))
3158 (set-buffer gnus-article-buffer)
3160 (call-interactively ',afunc)
3161 (apply ',afunc args))))))))
3162 '(article-hide-headers
3163 article-verify-x-pgp-sig
3164 article-verify-cancel-lock
3165 article-hide-boring-headers
3166 article-treat-overstrike
3167 article-fill-long-lines
3168 article-capitalize-sentences
3170 article-remove-leading-whitespace
3171 article-display-x-face
3172 article-de-quoted-unreadable
3173 article-de-base64-unreadable
3176 article-hide-list-identifiers
3178 article-strip-banner
3181 article-hide-signature
3182 article-strip-headers-in-body
3183 article-remove-trailing-blank-lines
3184 article-strip-leading-blank-lines
3185 article-strip-multiple-blank-lines
3186 article-strip-leading-space
3187 article-strip-trailing-space
3188 article-strip-blank-lines
3189 article-strip-all-blank-lines
3190 article-replace-with-quoted-text
3192 article-date-english
3193 article-date-iso8601
3194 article-date-original
3196 article-decode-mime-words
3197 article-decode-charset
3198 article-decode-encoded-words
3202 article-treat-dumbquotes
3203 article-normalize-headers
3204 ;; (article-show-all . gnus-article-show-all-headers)
3208 ;;; Gnus article mode
3211 (put 'gnus-article-mode 'mode-class 'special)
3213 (set-keymap-parent gnus-article-mode-map widget-keymap)
3215 (gnus-define-keys gnus-article-mode-map
3216 " " gnus-article-goto-next-page
3217 "\177" gnus-article-goto-prev-page
3218 [delete] gnus-article-goto-prev-page
3219 [backspace] gnus-article-goto-prev-page
3220 "\C-c^" gnus-article-refer-article
3221 "h" gnus-article-show-summary
3222 "s" gnus-article-show-summary
3223 "\C-c\C-m" gnus-article-mail
3224 "?" gnus-article-describe-briefly
3225 "e" gnus-summary-edit-article
3226 "<" beginning-of-buffer
3228 "\C-c\C-i" gnus-info-find-node
3230 "R" gnus-article-reply-with-original
3231 "F" gnus-article-followup-with-original
3232 "\C-hk" gnus-article-describe-key
3233 "\C-hc" gnus-article-describe-key-briefly
3235 "\C-d" gnus-article-read-summary-keys
3236 "\M-*" gnus-article-read-summary-keys
3237 "\M-#" gnus-article-read-summary-keys
3238 "\M-^" gnus-article-read-summary-keys
3239 "\M-g" gnus-article-read-summary-keys)
3241 (substitute-key-definition
3242 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3244 (defun gnus-article-make-menu-bar ()
3245 (unless (boundp 'gnus-article-commands-menu)
3246 (gnus-summary-make-menu-bar))
3247 (gnus-turn-off-edit-menu 'article)
3248 (unless (boundp 'gnus-article-article-menu)
3250 gnus-article-article-menu gnus-article-mode-map ""
3252 ["Scroll forwards" gnus-article-goto-next-page t]
3253 ["Scroll backwards" gnus-article-goto-prev-page t]
3254 ["Show summary" gnus-article-show-summary t]
3255 ["Fetch Message-ID at point" gnus-article-refer-article t]
3256 ["Mail to address at point" gnus-article-mail t]
3257 ["Send a bug report" gnus-bug t]))
3260 gnus-article-treatment-menu gnus-article-mode-map ""
3261 ;; Fixme: this should use :active (and maybe :visible).
3263 ["Hide headers" gnus-article-hide-headers t]
3264 ["Hide signature" gnus-article-hide-signature t]
3265 ["Hide citation" gnus-article-hide-citation t]
3266 ["Treat overstrike" gnus-article-treat-overstrike t]
3267 ["Remove carriage return" gnus-article-remove-cr t]
3268 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3269 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3270 ["Remove base64" gnus-article-de-base64-unreadable t]
3271 ["Treat html" gnus-article-wash-html t]
3272 ["Decode HZ" gnus-article-decode-HZ t]))
3274 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3276 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3278 (gnus-run-hooks 'gnus-article-menu-hook)))
3280 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3283 (defun gnus-article-mode ()
3284 "Major mode for displaying an article.
3286 All normal editing commands are switched off.
3288 The following commands are available in addition to all summary mode
3290 \\<gnus-article-mode-map>
3291 \\[gnus-article-next-page]\t Scroll the article one page forwards
3292 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3293 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3294 \\[gnus-article-show-summary]\t Display the summary buffer
3295 \\[gnus-article-mail]\t Send a reply to the address near point
3296 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3297 \\[gnus-info-find-node]\t Go to the Gnus info node"
3299 (gnus-simplify-mode-line)
3300 (setq mode-name "Article")
3301 (setq major-mode 'gnus-article-mode)
3302 (make-local-variable 'minor-mode-alist)
3303 (use-local-map gnus-article-mode-map)
3304 (when (gnus-visual-p 'article-menu 'menu)
3305 (gnus-article-make-menu-bar))
3306 (gnus-update-format-specifications nil 'article-mode)
3307 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3308 (make-local-variable 'gnus-page-broken)
3309 (make-local-variable 'gnus-button-marker-list)
3310 (make-local-variable 'gnus-article-current-summary)
3311 (make-local-variable 'gnus-article-mime-handles)
3312 (make-local-variable 'gnus-article-decoded-p)
3313 (make-local-variable 'gnus-article-mime-handle-alist)
3314 (make-local-variable 'gnus-article-wash-types)
3315 (make-local-variable 'gnus-article-image-alist)
3316 (make-local-variable 'gnus-article-charset)
3317 (make-local-variable 'gnus-article-ignored-charsets)
3318 (gnus-set-default-directory)
3319 (buffer-disable-undo)
3320 (setq buffer-read-only t)
3321 (set-syntax-table gnus-article-mode-syntax-table)
3322 (mm-enable-multibyte)
3323 (gnus-run-hooks 'gnus-article-mode-hook))
3325 (defun gnus-article-setup-buffer ()
3326 "Initialize the article buffer."
3327 (let* ((name (if gnus-single-article-buffer "*Article*"
3328 (concat "*Article " gnus-newsgroup-name "*")))
3330 (progn (string-match "\\*Article" name)
3331 (concat " *Original Article"
3332 (substring name (match-end 0))))))
3333 (setq gnus-article-buffer name)
3334 (setq gnus-original-article-buffer original)
3335 (setq gnus-article-mime-handle-alist nil)
3336 ;; This might be a variable local to the summary buffer.
3337 (unless gnus-single-article-buffer
3339 (set-buffer gnus-summary-buffer)
3340 (setq gnus-article-buffer name)
3341 (setq gnus-original-article-buffer original)
3342 (gnus-set-global-variables)))
3343 (gnus-article-setup-highlight-words)
3344 ;; Init original article buffer.
3346 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3347 (mm-enable-multibyte)
3348 (setq major-mode 'gnus-original-article-mode)
3349 (make-local-variable 'gnus-original-article))
3350 (if (get-buffer name)
3353 (when gnus-article-mime-handles
3354 (mm-destroy-parts gnus-article-mime-handles)
3355 (setq gnus-article-mime-handles nil))
3356 ;; Set it to nil in article-buffer!
3357 (setq gnus-article-mime-handle-alist nil)
3358 (buffer-disable-undo)
3359 (setq buffer-read-only t)
3360 (unless (eq major-mode 'gnus-article-mode)
3361 (gnus-article-mode))
3364 (set-buffer (gnus-get-buffer-create name))
3366 (make-local-variable 'gnus-summary-buffer)
3367 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3368 (current-buffer)))))
3370 ;; Set article window start at LINE, where LINE is the number of lines
3371 ;; from the head of the article.
3372 (defun gnus-article-set-window-start (&optional line)
3374 (gnus-get-buffer-window gnus-article-buffer t)
3376 (set-buffer gnus-article-buffer)
3377 (goto-char (point-min))
3380 (gnus-message 6 "Moved to bookmark")
3381 (search-forward "\n\n" nil t)
3385 (defun gnus-article-prepare (article &optional all-headers header)
3386 "Prepare ARTICLE in article mode buffer.
3387 ARTICLE should either be an article number or a Message-ID.
3388 If ARTICLE is an id, HEADER should be the article headers.
3389 If ALL-HEADERS is non-nil, no headers are hidden."
3391 ;; Make sure we start in a summary buffer.
3392 (unless (eq major-mode 'gnus-summary-mode)
3393 (set-buffer gnus-summary-buffer))
3394 (setq gnus-summary-buffer (current-buffer))
3395 (let* ((gnus-article (if header (mail-header-number header) article))
3396 (summary-buffer (current-buffer))
3397 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3398 (group gnus-newsgroup-name)
3401 (gnus-article-setup-buffer)
3402 (set-buffer gnus-article-buffer)
3403 ;; Deactivate active regions.
3404 (when (and (boundp 'transient-mark-mode)
3405 transient-mark-mode)
3406 (setq mark-active nil))
3407 (if (not (setq result (let ((buffer-read-only nil))
3408 (gnus-request-article-this-buffer
3410 ;; There is no such article.
3412 (when (and (numberp article)
3413 (not (memq article gnus-newsgroup-sparse)))
3414 (setq gnus-article-current
3415 (cons gnus-newsgroup-name article))
3416 (set-buffer gnus-summary-buffer)
3417 (setq gnus-current-article article)
3418 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3420 (gnus-summary-set-agent-mark article)
3421 (message "Message marked for downloading"))
3422 (gnus-summary-mark-article article gnus-canceled-mark)
3423 (unless (memq article gnus-newsgroup-sparse)
3424 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3425 (if (or (eq result 'pseudo)
3426 (eq result 'nneething))
3429 (set-buffer summary-buffer)
3430 (push article gnus-newsgroup-history)
3431 (setq gnus-last-article gnus-current-article
3432 gnus-current-article 0
3433 gnus-current-headers nil
3434 gnus-article-current nil)
3435 (if (eq result 'nneething)
3436 (gnus-configure-windows 'summary)
3437 (gnus-configure-windows 'article))
3438 (gnus-set-global-variables))
3439 (let ((gnus-article-mime-handle-alist-1
3440 gnus-article-mime-handle-alist))
3441 (gnus-set-mode-line 'article)))
3442 ;; The result from the `request' was an actual article -
3443 ;; or at least some text that is now displayed in the
3445 (when (and (numberp article)
3446 (not (eq article gnus-current-article)))
3447 ;; Seems like a new article has been selected.
3448 ;; `gnus-current-article' must be an article number.
3450 (set-buffer summary-buffer)
3451 (push article gnus-newsgroup-history)
3452 (setq gnus-last-article gnus-current-article
3453 gnus-current-article article
3454 gnus-current-headers
3455 (gnus-summary-article-header gnus-current-article)
3456 gnus-article-current
3457 (cons gnus-newsgroup-name gnus-current-article))
3458 (unless (vectorp gnus-current-headers)
3459 (setq gnus-current-headers nil))
3460 (gnus-summary-goto-subject gnus-current-article)
3461 (when (gnus-summary-show-thread)
3462 ;; If the summary buffer really was folded, the
3463 ;; previous goto may not actually have gone to
3464 ;; the right article, but the thread root instead.
3466 (gnus-summary-goto-subject gnus-current-article))
3467 (gnus-run-hooks 'gnus-mark-article-hook)
3468 (gnus-set-mode-line 'summary)
3469 (when (gnus-visual-p 'article-highlight 'highlight)
3470 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3471 ;; Set the global newsgroup variables here.
3472 (gnus-set-global-variables)
3473 (setq gnus-have-all-headers
3474 (or all-headers gnus-show-all-headers))))
3476 (gnus-configure-windows 'article))
3477 (when (or (numberp article)
3479 (gnus-article-prepare-display)
3481 (goto-char (point-min))
3482 (setq gnus-page-broken
3483 (when gnus-break-pages
3484 (gnus-narrow-to-page)
3486 (let ((gnus-article-mime-handle-alist-1
3487 gnus-article-mime-handle-alist))
3488 (gnus-set-mode-line 'article))
3490 (set-window-point (get-buffer-window (current-buffer)) (point))
3491 (gnus-configure-windows 'article)
3495 (defun gnus-article-prepare-display ()
3496 "Make the current buffer look like a nice article."
3497 ;; Hooks for getting information from the article.
3498 ;; This hook must be called before being narrowed.
3499 (let ((gnus-article-buffer (current-buffer))
3501 (unless (eq major-mode 'gnus-article-mode)
3502 (gnus-article-mode))
3503 (setq buffer-read-only nil
3504 gnus-article-wash-types nil
3505 gnus-article-image-alist nil)
3506 (gnus-run-hooks 'gnus-tmp-internal-hook)
3507 (when gnus-display-mime-function
3508 (funcall gnus-display-mime-function))
3509 (gnus-run-hooks 'gnus-article-prepare-hook)))
3512 ;;; Gnus MIME viewing functions
3515 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3516 "Format of the MIME buttons.
3518 Valid specifiers include:
3520 %T MIME type, along with additional info
3521 %n The `name' parameter
3522 %d The description, if any
3523 %l The length of the encoded part
3524 %p The part identifier number
3525 %e Dots if the part isn't displayed
3527 General format specifiers can also be used. See
3528 (gnus)Formatting Variables.")
3530 (defvar gnus-mime-button-line-format-alist
3531 '((?t gnus-tmp-type ?s)
3532 (?T gnus-tmp-type-long ?s)
3533 (?n gnus-tmp-name ?s)
3534 (?d gnus-tmp-description ?s)
3536 (?l gnus-tmp-length ?d)
3537 (?e gnus-tmp-dots ?s)))
3539 (defvar gnus-mime-button-commands
3540 '((gnus-article-press-button "\r" "Toggle Display")
3541 (gnus-mime-view-part "v" "View Interactively...")
3542 (gnus-mime-view-part-as-type "t" "View As Type...")
3543 (gnus-mime-view-part-as-charset "C" "View As charset...")
3544 (gnus-mime-save-part "o" "Save...")
3545 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3546 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3547 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3548 (gnus-mime-internalize-part "E" "View Internally")
3549 (gnus-mime-externalize-part "e" "View Externally")
3550 (gnus-mime-print-part "p" "Print")
3551 (gnus-mime-pipe-part "|" "Pipe To Command...")
3552 (gnus-mime-action-on-part "." "Take action on the part")))
3554 (defun gnus-article-mime-part-status ()
3555 (if gnus-article-mime-handle-alist-1
3556 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3558 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3561 (defvar gnus-mime-button-map
3562 (let ((map (make-sparse-keymap)))
3563 (unless (>= (string-to-number emacs-version) 21)
3564 ;; XEmacs doesn't care.
3565 (set-keymap-parent map gnus-article-mode-map))
3566 (define-key map gnus-mouse-2 'gnus-article-push-button)
3567 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3568 (dolist (c gnus-mime-button-commands)
3569 (define-key map (cadr c) (car c)))
3572 (defun gnus-mime-button-menu (event)
3573 "Construct a context-sensitive menu of MIME commands."
3575 (save-window-excursion
3576 (let ((pos (event-start event)))
3577 (select-window (posn-window pos))
3578 (goto-char (posn-point pos))
3579 (gnus-article-check-buffer)
3580 (let ((response (x-popup-menu
3582 ("" ,@(mapcar (lambda (c)
3583 (cons (caddr c) (car c)))
3584 gnus-mime-button-commands))))))
3586 (call-interactively response))))))
3588 (defun gnus-mime-view-all-parts (&optional handles)
3589 "View all the MIME parts."
3591 (save-current-buffer
3592 (set-buffer gnus-article-buffer)
3593 (let ((handles (or handles gnus-article-mime-handles))
3594 (mail-parse-charset gnus-newsgroup-charset)
3595 (mail-parse-ignored-charsets
3596 (with-current-buffer gnus-summary-buffer
3597 gnus-newsgroup-ignored-charsets)))
3599 (mm-remove-parts handles)
3600 (goto-char (point-min))
3601 (or (search-forward "\n\n") (goto-char (point-max)))
3602 (let (buffer-read-only)
3603 (delete-region (point) (point-max))
3604 (mm-display-parts handles))))))
3606 (defun gnus-mime-save-part-and-strip ()
3607 "Save the MIME part under point then replace it with an external body."
3609 (gnus-article-check-buffer)
3610 (let* ((data (get-text-property (point) 'gnus-data))
3612 (handles gnus-article-mime-handles))
3613 (if (mm-multiple-handles gnus-article-mime-handles)
3614 (error "This function is not implemented"))
3615 (setq file (and data (mm-save-part data)))
3617 (with-current-buffer (mm-handle-buffer data)
3619 (insert "Content-Type: " (mm-handle-media-type data))
3620 (mml-insert-parameter-string (cdr (mm-handle-type data))
3623 (insert "Content-ID: " (message-make-message-id) "\n")
3624 (insert "Content-Transfer-Encoding: binary\n")
3627 (cdr (mm-make-handle nil
3628 `("message/external-body"
3629 (access-type . "LOCAL-FILE")
3631 (set-buffer gnus-summary-buffer)
3632 (gnus-article-edit-article
3635 (let ((mail-parse-charset (or gnus-article-charset
3636 ',gnus-newsgroup-charset))
3637 (mail-parse-ignored-charsets
3638 (or gnus-article-ignored-charsets
3639 ',gnus-newsgroup-ignored-charsets))
3640 (mbl mml-buffer-list))
3641 (setq mml-buffer-list nil)
3642 (insert-buffer gnus-original-article-buffer)
3643 (mime-to-mml ',handles)
3644 (setq gnus-article-mime-handles nil)
3645 (let ((mbl1 mml-buffer-list))
3646 (setq mml-buffer-list mbl)
3647 (set (make-local-variable 'mml-buffer-list) mbl1))
3648 ;; LOCAL argument of add-hook differs between GNU Emacs
3649 ;; and XEmacs. make-local-hook makes sure they are local.
3650 (make-local-hook 'kill-buffer-hook)
3651 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3652 `(lambda (no-highlight)
3653 (let ((mail-parse-charset (or gnus-article-charset
3654 ',gnus-newsgroup-charset))
3655 (message-options message-options)
3656 (message-options-set-recipient)
3657 (mail-parse-ignored-charsets
3658 (or gnus-article-ignored-charsets
3659 ',gnus-newsgroup-ignored-charsets)))
3661 (mml-destroy-buffers)
3662 (remove-hook 'kill-buffer-hook
3663 'mml-destroy-buffers t)
3664 (kill-local-variable 'mml-buffer-list))
3665 (gnus-summary-edit-article-done
3666 ,(or (mail-header-references gnus-current-headers) "")
3667 ,(gnus-group-read-only-p)
3668 ,gnus-summary-buffer no-highlight))))))
3670 (defun gnus-mime-save-part ()
3671 "Save the MIME part under point."
3673 (gnus-article-check-buffer)
3674 (let ((data (get-text-property (point) 'gnus-data)))
3676 (mm-save-part data))))
3678 (defun gnus-mime-pipe-part ()
3679 "Pipe the MIME part under point to a process."
3681 (gnus-article-check-buffer)
3682 (let ((data (get-text-property (point) 'gnus-data)))
3684 (mm-pipe-part data))))
3686 (defun gnus-mime-view-part ()
3687 "Interactively choose a viewing method for the MIME part under point."
3689 (gnus-article-check-buffer)
3690 (let ((data (get-text-property (point) 'gnus-data)))
3692 (setq gnus-article-mime-handles
3694 gnus-article-mime-handles (setq data (copy-sequence data))))
3695 (mm-interactively-view-part data))))
3697 (defun gnus-mime-view-part-as-type-internal ()
3698 (gnus-article-check-buffer)
3699 (let* ((name (mail-content-type-get
3700 (mm-handle-type (get-text-property (point) 'gnus-data))
3702 (def-type (and name (mm-default-file-encoding name))))
3703 (and def-type (cons def-type 0))))
3705 (defun gnus-mime-view-part-as-type (&optional mime-type)
3706 "Choose a MIME media type, and view the part as such."
3709 (setq mime-type (completing-read
3710 "View as MIME type: "
3711 (mapcar #'list (mailcap-mime-types))
3713 (gnus-mime-view-part-as-type-internal))))
3714 (gnus-article-check-buffer)
3715 (let ((handle (get-text-property (point) 'gnus-data)))
3718 (mm-make-handle (mm-handle-buffer handle)
3719 (cons mime-type (cdr (mm-handle-type handle)))
3720 (mm-handle-encoding handle)
3721 (mm-handle-undisplayer handle)
3722 (mm-handle-disposition handle)
3723 (mm-handle-description handle)
3725 (mm-handle-id handle)))
3726 (setq gnus-article-mime-handles
3727 (mm-merge-handles gnus-article-mime-handles handle))
3728 (gnus-mm-display-part handle))))
3730 (defun gnus-mime-copy-part (&optional handle)
3731 "Put the MIME part under point into a new buffer."
3733 (gnus-article-check-buffer)
3734 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3735 (contents (and handle (mm-get-part handle)))
3737 (file-name-nondirectory
3739 (mail-content-type-get (mm-handle-type handle) 'name)
3740 (mail-content-type-get (mm-handle-type handle)
3743 (buffer (and base (generate-new-buffer base))))
3745 (switch-to-buffer buffer)
3747 ;; We do it this way to make `normal-mode' set the appropriate mode.
3750 (setq buffer-file-name (expand-file-name base))
3752 (setq buffer-file-name nil))
3753 (goto-char (point-min)))))
3755 (defun gnus-mime-print-part (&optional handle filename)
3756 "Print the MIME part under point."
3757 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3758 (gnus-article-check-buffer)
3759 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3760 (contents (and handle (mm-get-part handle)))
3761 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3762 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3767 (with-temp-file file
3769 (call-process shell-file-name nil
3770 (generate-new-buffer " *mm*")
3772 shell-command-switch
3774 printer file (mm-handle-type handle))))
3778 (gnus-print-buffer))
3779 (ps-despool filename)))))
3781 (defun gnus-mime-inline-part (&optional handle arg)
3782 "Insert the MIME part under point into the current buffer."
3783 (interactive (list nil current-prefix-arg))
3784 (gnus-article-check-buffer)
3785 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3790 (if (and (not arg) (mm-handle-undisplayer handle))
3791 (mm-remove-part handle)
3792 (setq contents (mm-get-part handle))
3795 (setq charset (or (mail-content-type-get
3796 (mm-handle-type handle) 'charset)
3797 gnus-newsgroup-charset)))
3799 (if (mm-handle-undisplayer handle)
3800 (mm-remove-part handle))
3803 gnus-summary-show-article-charset-alist))
3804 (mm-read-coding-system "Charset: ")))))
3806 (mm-insert-inline handle
3808 (setq charset (mm-charset-to-coding-system
3810 (not (eq charset 'ascii)))
3811 (mm-decode-coding-string contents charset)
3815 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3816 "Insert the MIME part under point into the current buffer using the
3818 (interactive (list nil current-prefix-arg))
3819 (gnus-article-check-buffer)
3820 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3825 (if (mm-handle-undisplayer handle)
3826 (mm-remove-part handle))
3827 (let ((gnus-newsgroup-charset
3829 gnus-summary-show-article-charset-alist))
3830 (mm-read-coding-system "Charset: ")))
3831 (gnus-newsgroup-ignored-charsets 'gnus-all))
3832 (gnus-article-press-button)))))
3834 (defun gnus-mime-externalize-part (&optional handle)
3835 "View the MIME part under point with an external viewer."
3837 (gnus-article-check-buffer)
3838 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3839 (mm-user-display-methods nil)
3840 (mm-inlined-types nil)
3841 (mail-parse-charset gnus-newsgroup-charset)
3842 (mail-parse-ignored-charsets
3843 (save-excursion (set-buffer gnus-summary-buffer)
3844 gnus-newsgroup-ignored-charsets)))
3846 (if (mm-handle-undisplayer handle)
3847 (mm-remove-part handle)
3848 (mm-display-part handle)))))
3850 (defun gnus-mime-internalize-part (&optional handle)
3851 "View the MIME part under point with an internal viewer.
3852 If no internal viewer is available, use an external viewer."
3854 (gnus-article-check-buffer)
3855 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3856 (mm-inlined-types '(".*"))
3857 (mm-inline-large-images t)
3858 (mail-parse-charset gnus-newsgroup-charset)
3859 (mail-parse-ignored-charsets
3860 (save-excursion (set-buffer gnus-summary-buffer)
3861 gnus-newsgroup-ignored-charsets)))
3863 (if (mm-handle-undisplayer handle)
3864 (mm-remove-part handle)
3865 (mm-display-part handle)))))
3867 (defun gnus-mime-action-on-part (&optional action)
3868 "Do something with the MIME attachment at \(point\)."
3870 (list (completing-read "Action: " gnus-mime-action-alist)))
3871 (gnus-article-check-buffer)
3872 (let ((action-pair (assoc action gnus-mime-action-alist)))
3874 (funcall (cdr action-pair)))))
3876 (defun gnus-article-part-wrapper (n function)
3877 (save-current-buffer
3878 (set-buffer gnus-article-buffer)
3879 (when (> n (length gnus-article-mime-handle-alist))
3880 (error "No such part"))
3881 (gnus-article-goto-part n)
3882 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3883 (funcall function handle))))
3885 (defun gnus-article-pipe-part (n)
3886 "Pipe MIME part N, which is the numerical prefix."
3888 (gnus-article-part-wrapper n 'mm-pipe-part))
3890 (defun gnus-article-save-part (n)
3891 "Save MIME part N, which is the numerical prefix."
3893 (gnus-article-part-wrapper n 'mm-save-part))
3895 (defun gnus-article-interactively-view-part (n)
3896 "View MIME part N interactively, which is the numerical prefix."
3898 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3900 (defun gnus-article-copy-part (n)
3901 "Copy MIME part N, which is the numerical prefix."
3903 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3905 (defun gnus-article-view-part-as-charset (n)
3906 "Copy MIME part N, which is the numerical prefix."
3908 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3910 (defun gnus-article-externalize-part (n)
3911 "View MIME part N externally, which is the numerical prefix."
3913 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3915 (defun gnus-article-inline-part (n)
3916 "Inline MIME part N, which is the numerical prefix."
3918 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3920 (defun gnus-article-mime-match-handle-first (condition)
3922 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3923 (while (setq ihandle (pop alist))
3925 ((functionp condition)
3926 (funcall condition (cdr ihandle)))
3927 ((eq condition 'undisplayed)
3928 (not (or (mm-handle-undisplayer (cdr ihandle))
3929 (equal (mm-handle-media-type (cdr ihandle))
3930 "multipart/alternative"))))
3931 ((eq condition 'undisplayed-alternative)
3932 (not (mm-handle-undisplayer (cdr ihandle))))
3934 (gnus-article-goto-part (car ihandle))
3935 (or (not n) (< (car ihandle) n)))
3936 (setq n (car ihandle))))
3940 (defun gnus-article-view-part (&optional n)
3941 "View MIME part N, which is the numerical prefix."
3943 (save-current-buffer
3944 (set-buffer gnus-article-buffer)
3945 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3946 gnus-article-mime-match-handle-function)))
3947 (when (> n (length gnus-article-mime-handle-alist))
3948 (error "No such part"))
3949 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3950 (when (gnus-article-goto-part n)
3951 (if (equal (car handle) "multipart/alternative")
3952 (gnus-article-press-button)
3953 (when (eq (gnus-mm-display-part handle) 'internal)
3954 (gnus-set-window-start)))))))
3956 (defsubst gnus-article-mime-total-parts ()
3957 (if (bufferp (car gnus-article-mime-handles))
3959 (1- (length gnus-article-mime-handles))))
3961 (defun gnus-mm-display-part (handle)
3962 "Display HANDLE and fix MIME button."
3963 (let ((id (get-text-property (point) 'gnus-part))
3968 (let ((window (selected-window))
3969 (mail-parse-charset gnus-newsgroup-charset)
3970 (mail-parse-ignored-charsets
3971 (if (gnus-buffer-live-p gnus-summary-buffer)
3973 (set-buffer gnus-summary-buffer)
3974 gnus-newsgroup-ignored-charsets)
3978 (let ((win (gnus-get-buffer-window (current-buffer) t))
3981 (select-window win))
3984 (if (mm-handle-displayed-p handle)
3985 ;; This will remove the part.
3986 (mm-display-part handle)
3988 (narrow-to-region (point)
3989 (if (eobp) (point) (1+ (point))))
3990 (mm-display-part handle)
3991 ;; We narrow to the part itself and
3992 ;; then call the treatment functions.
3993 (goto-char (point-min))
3995 (narrow-to-region (point) (point-max))
3998 (gnus-article-mime-total-parts)
3999 (mm-handle-media-type handle)))))
4000 (if (window-live-p window)
4001 (select-window window)))))
4003 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4004 (gnus-insert-mime-button
4005 handle id (list (mm-handle-displayed-p handle)))
4006 (goto-char point))))
4008 (defun gnus-article-goto-part (n)
4009 "Go to MIME part N."
4010 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4012 (goto-char point))))
4014 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4015 (let ((gnus-tmp-name
4016 (or (mail-content-type-get (mm-handle-type handle) 'name)
4017 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4018 (mail-content-type-get (mm-handle-type handle) 'url)
4020 (gnus-tmp-type (mm-handle-media-type handle))
4021 (gnus-tmp-description
4022 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4025 (if (if displayed (car displayed)
4026 (mm-handle-displayed-p handle))
4028 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4030 gnus-tmp-type-long b e)
4031 (when (string-match ".*/" gnus-tmp-name)
4032 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4033 (setq gnus-tmp-type-long (concat gnus-tmp-type
4034 (and (not (equal gnus-tmp-name ""))
4035 (concat "; " gnus-tmp-name))))
4036 (unless (equal gnus-tmp-description "")
4037 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4042 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4043 `(,@(gnus-local-map-property gnus-mime-button-map)
4044 gnus-callback gnus-mm-display-part
4045 gnus-part ,gnus-tmp-id
4046 article-type annotation
4049 (widget-convert-button
4052 :action 'gnus-widget-press-button
4053 :button-keymap gnus-mime-button-map
4055 (lambda (widget/window &optional overlay pos)
4056 ;; Needed to properly clear the message due to a bug in
4057 ;; wid-edit (XEmacs only).
4058 (if (boundp 'help-echo-owns-message)
4059 (setq help-echo-owns-message t))
4061 "%S: %s the MIME part; %S: more options"
4062 (aref gnus-mouse-2 0)
4063 ;; XEmacs will get a single widget arg; Emacs 21 will get
4064 ;; window, overlay, position.
4065 (if (mm-handle-displayed-p
4067 (with-current-buffer (gnus-overlay-buffer overlay)
4068 (widget-get (widget-at (gnus-overlay-start overlay))
4070 (widget-get widget/window :mime-handle)))
4072 (aref gnus-down-mouse-3 0))))))
4074 (defun gnus-widget-press-button (elems el)
4075 (goto-char (widget-get elems :from))
4076 (gnus-article-press-button))
4078 (defvar gnus-displaying-mime nil)
4080 (defun gnus-display-mime (&optional ihandles)
4081 "Display the MIME parts."
4083 (save-selected-window
4084 (let ((window (get-buffer-window gnus-article-buffer))
4087 (select-window window)
4088 ;; We have to do this since selecting the window
4089 ;; may change the point. So we set the window point.
4090 (set-window-point window point)))
4091 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4092 buffer-read-only handle name type b e display)
4093 (when (and (not ihandles)
4094 (not gnus-displaying-mime))
4095 ;; Top-level call; we clean up.
4096 (when gnus-article-mime-handles
4097 (mm-destroy-parts gnus-article-mime-handles)
4098 (setq gnus-article-mime-handle-alist nil));; A trick.
4099 (setq gnus-article-mime-handles handles)
4100 ;; We allow users to glean info from the handles.
4101 (when gnus-article-mime-part-function
4102 (gnus-mime-part-function handles)))
4104 (or (not (stringp (car handles)))
4107 (when (and (not ihandles)
4108 (not gnus-displaying-mime))
4109 ;; Clean up for mime parts.
4111 (delete-region (point) (point-max)))
4112 (let ((gnus-displaying-mime t))
4113 (gnus-mime-display-part handles)))
4116 (narrow-to-region (point) (point-max))
4117 (gnus-treat-article nil 1 1)
4120 ;; Highlight the headers.
4124 (narrow-to-region (point-min) (point))
4125 (gnus-treat-article 'head))))))))
4127 (defvar gnus-mime-display-multipart-as-mixed nil)
4128 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4129 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4131 (defun gnus-mime-display-part (handle)
4134 ((not (stringp (car handle)))
4135 (gnus-mime-display-single handle))
4136 ;; User-defined multipart
4137 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4138 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4140 ;; multipart/alternative
4141 ((and (equal (car handle) "multipart/alternative")
4142 (not (or gnus-mime-display-multipart-as-mixed
4143 gnus-mime-display-multipart-alternative-as-mixed)))
4144 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4145 (push (cons id handle) gnus-article-mime-handle-alist)
4146 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4147 ;; multipart/related
4148 ((and (equal (car handle) "multipart/related")
4149 (not (or gnus-mime-display-multipart-as-mixed
4150 gnus-mime-display-multipart-related-as-mixed)))
4151 ;;;!!!We should find the start part, but we just default
4152 ;;;!!!to the first part.
4153 ;;(gnus-mime-display-part (cadr handle))
4154 ;;;!!! Most multipart/related is an HTML message plus images.
4155 ;;;!!! Unfortunately we are unable to let W3 display those
4156 ;;;!!! included images, so we just display it as a mixed multipart.
4157 ;;(gnus-mime-display-mixed (cdr handle))
4158 ;;;!!! No, w3 can display everything just fine.
4159 (gnus-mime-display-part (cadr handle)))
4160 ((equal (car handle) "multipart/signed")
4161 (gnus-add-wash-type 'signed)
4162 (gnus-mime-display-security handle))
4163 ((equal (car handle) "multipart/encrypted")
4164 (gnus-add-wash-type 'encrypted)
4165 (gnus-mime-display-security handle))
4166 ;; Other multiparts are handled like multipart/mixed.
4168 (gnus-mime-display-mixed (cdr handle)))))
4170 (defun gnus-mime-part-function (handles)
4171 (if (stringp (car handles))
4172 (mapcar 'gnus-mime-part-function (cdr handles))
4173 (funcall gnus-article-mime-part-function handles)))
4175 (defun gnus-mime-display-mixed (handles)
4176 (mapcar 'gnus-mime-display-part handles))
4178 (defun gnus-mime-display-single (handle)
4179 (let ((type (mm-handle-media-type handle))
4180 (ignored gnus-ignored-mime-types)
4187 (when (string-match (pop ignored) type)
4188 (throw 'ignored nil)))
4189 (if (and (setq not-attachment
4190 (and (not (mm-inline-override-p handle))
4191 (or (not (mm-handle-disposition handle))
4192 (equal (car (mm-handle-disposition handle))
4194 (mm-attachment-override-p handle))))
4195 (mm-automatic-display-p handle)
4197 (mm-inlinable-p handle)
4198 (mm-inlined-p handle))
4199 (mm-automatic-external-display-p type)))
4201 (when (equal (mm-handle-media-supertype handle) "text")
4203 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4205 (push (cons id handle) gnus-article-mime-handle-alist)
4206 (when (or (not display)
4207 (not (gnus-unbuttonized-mime-type-p type)))
4208 ;(gnus-article-insert-newline)
4209 (gnus-insert-mime-button
4210 handle id (list (or display (and not-attachment text))))
4211 (gnus-article-insert-newline)
4212 ;(gnus-article-insert-newline)
4213 ;; Remember modify the number of forward lines.
4221 (let ((mail-parse-charset gnus-newsgroup-charset)
4222 (mail-parse-ignored-charsets
4223 (save-excursion (condition-case ()
4224 (set-buffer gnus-summary-buffer)
4226 gnus-newsgroup-ignored-charsets)))
4227 (mm-display-part handle t))
4228 (goto-char (point-max)))
4229 ((and text not-attachment)
4233 (gnus-article-insert-newline)
4234 (mm-insert-inline handle (mm-get-part handle))
4235 (goto-char (point-max))))
4239 (narrow-to-region beg (point))
4242 (gnus-article-mime-total-parts)
4243 (mm-handle-media-type handle)))))))))
4245 (defun gnus-unbuttonized-mime-type-p (type)
4246 "Say whether TYPE is to be unbuttonized."
4247 (unless gnus-inhibit-mime-unbuttonizing
4249 (let ((types gnus-unbuttonized-mime-types))
4251 (when (string-match (pop types) type)
4252 (throw 'found t)))))
4254 (let ((types gnus-buttonized-mime-types))
4256 (when (string-match (pop types) type)
4257 (throw 'found t)))))))))
4259 (defun gnus-article-insert-newline ()
4260 "Insert a newline, but mark it as undeletable."
4261 (gnus-put-text-property
4262 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4264 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4265 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4268 handle buffer-read-only from props begend not-pref)
4269 (save-window-excursion
4272 (narrow-to-region (car ibegend)
4275 (goto-char (car ibegend))
4278 (delete-region (point-min) (point-max))
4279 (mm-remove-parts handles))
4280 (setq begend (list (point-marker)))
4282 (unless (setq not-pref (cadr (member preferred ihandles)))
4283 (setq not-pref (car ihandles)))
4286 (not (gnus-unbuttonized-mime-type-p
4287 "multipart/alternative")))
4288 (gnus-add-text-properties
4291 (insert (format "%d. " id))
4295 (unless ,(not ibegend)
4296 (setq gnus-article-mime-handle-alist
4297 ',gnus-article-mime-handle-alist))
4298 (gnus-mime-display-alternative
4299 ',ihandles ',not-pref ',begend ,id))
4300 ,@(gnus-local-map-property gnus-mime-button-map)
4301 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4302 face ,gnus-article-button-face
4305 (widget-convert-button 'link from (point)
4306 :action 'gnus-widget-press-button
4307 :button-keymap gnus-widget-button-keymap)
4309 (while (setq handle (pop handles))
4310 (gnus-add-text-properties
4313 (insert (format "(%c) %-18s"
4314 (if (equal handle preferred) ?* ? )
4315 (mm-handle-media-type handle)))
4319 (unless ,(not ibegend)
4320 (setq gnus-article-mime-handle-alist
4321 ',gnus-article-mime-handle-alist))
4322 (gnus-mime-display-alternative
4323 ',ihandles ',handle ',begend ,id))
4324 ,@(gnus-local-map-property gnus-mime-button-map)
4325 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4326 face ,gnus-article-button-face
4329 (widget-convert-button 'link from (point)
4330 :action 'gnus-widget-press-button
4331 :button-keymap gnus-widget-button-keymap)
4335 (if (stringp (car preferred))
4336 (gnus-display-mime preferred)
4337 (let ((mail-parse-charset gnus-newsgroup-charset)
4338 (mail-parse-ignored-charsets
4339 (save-excursion (set-buffer gnus-summary-buffer)
4340 gnus-newsgroup-ignored-charsets)))
4341 (mm-display-part preferred)
4345 (narrow-to-region (car begend) (point-max))
4347 nil (length gnus-article-mime-handle-alist)
4348 (gnus-article-mime-total-parts)
4349 (mm-handle-media-type handle))))))
4350 (goto-char (point-max))
4351 (setcdr begend (point-marker)))))
4353 (goto-char point))))
4355 (defconst gnus-article-wash-status-strings
4356 (let ((alist '((cite "c" "Possible hidden citation text"
4357 " " "All citation text visible")
4358 (headers "h" "Hidden headers"
4359 " " "All headers visible.")
4360 (pgp "p" "Encrypted or signed message status hidden"
4361 " " "No hidden encryption nor digital signature status")
4362 (signature "s" "Signature has been hidden"
4363 " " "Signature is visible")
4364 (overstrike "o" "Overstrike (^H) characters applied"
4365 " " "No overstrike characters applied")
4366 (emphasis "e" "/*_Emphasis_*/ characters applied"
4367 " " "No /*_emphasis_*/ characters applied")))
4369 (dolist (entry alist result)
4370 (let ((key (nth 0 entry))
4371 (on (copy-sequence (nth 1 entry)))
4372 (on-help (nth 2 entry))
4373 (off (copy-sequence (nth 3 entry)))
4374 (off-help (nth 4 entry)))
4375 (put-text-property 0 1 'help-echo on-help on)
4376 (put-text-property 0 1 'help-echo off-help off)
4377 (push (list key on off) result))))
4378 "Alist of strings describing wash status in the mode line.
4379 Each entry has the form (KEY ON OF), where the KEY is a symbol
4380 representing the particular washing function, ON is the string to use
4381 in the article mode line when the washing function is active, and OFF
4382 is the string to use when it is inactive.")
4384 (defun gnus-article-wash-status-entry (key value)
4385 (let ((entry (assoc key gnus-article-wash-status-strings)))
4386 (if value (nth 1 entry) (nth 2 entry))))
4388 (defun gnus-article-wash-status ()
4389 "Return a string which display status of article washing."
4391 (set-buffer gnus-article-buffer)
4392 (let ((cite (memq 'cite gnus-article-wash-types))
4393 (headers (memq 'headers gnus-article-wash-types))
4394 (boring (memq 'boring-headers gnus-article-wash-types))
4395 (pgp (memq 'pgp gnus-article-wash-types))
4396 (pem (memq 'pem gnus-article-wash-types))
4397 (signed (memq 'signed gnus-article-wash-types))
4398 (encrypted (memq 'encrypted gnus-article-wash-types))
4399 (signature (memq 'signature gnus-article-wash-types))
4400 (overstrike (memq 'overstrike gnus-article-wash-types))
4401 (emphasis (memq 'emphasis gnus-article-wash-types)))
4403 (gnus-article-wash-status-entry 'cite cite)
4404 (gnus-article-wash-status-entry 'headers (or headers boring))
4405 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4406 (gnus-article-wash-status-entry 'signature signature)
4407 (gnus-article-wash-status-entry 'overstrike overstrike)
4408 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4410 (defun gnus-add-wash-type (type)
4411 "Add a washing of TYPE to the current status."
4412 (add-to-list 'gnus-article-wash-types type))
4414 (defun gnus-delete-wash-type (type)
4415 "Add a washing of TYPE to the current status."
4416 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4418 (defun gnus-add-image (category image)
4419 "Add IMAGE of CATEGORY to the list of displayed images."
4420 (let ((entry (assq category gnus-article-image-alist)))
4422 (setq entry (list category))
4423 (push entry gnus-article-image-alist))
4424 (nconc entry (list image))))
4426 (defun gnus-delete-images (category)
4427 "Delete all images in CATEGORY."
4428 (let ((entry (assq category gnus-article-image-alist)))
4429 (dolist (image (cdr entry))
4430 (gnus-remove-image image))
4431 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4432 (gnus-delete-wash-type category)))
4434 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4436 (defun gnus-article-maybe-hide-headers ()
4437 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4438 Provided for backwards compatibility."
4439 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4440 (not (save-excursion (set-buffer gnus-summary-buffer)
4441 gnus-have-all-headers)))
4442 (not gnus-inhibit-hiding))
4443 (gnus-article-hide-headers)))
4447 (defun gnus-output-to-file (file-name)
4448 "Append the current article to a file named FILE-NAME."
4449 (let ((artbuf (current-buffer)))
4451 (insert-buffer-substring artbuf)
4452 ;; Append newline at end of the buffer as separator, and then
4454 (goto-char (point-max))
4456 (let ((file-name-coding-system nnmail-pathname-coding-system))
4457 (mm-append-to-file (point-min) (point-max) file-name))
4460 (defun gnus-narrow-to-page (&optional arg)
4461 "Narrow the article buffer to a page.
4462 If given a numerical ARG, move forward ARG pages."
4464 (setq arg (if arg (prefix-numeric-value arg) 0))
4466 (set-buffer gnus-article-buffer)
4467 (goto-char (point-min))
4469 ;; Remove any old next/prev buttons.
4470 (when (gnus-visual-p 'page-marker)
4471 (let ((buffer-read-only nil))
4472 (gnus-remove-text-with-property 'gnus-prev)
4473 (gnus-remove-text-with-property 'gnus-next)))
4476 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4478 (re-search-forward page-delimiter nil 'move arg)))
4479 (goto-char (match-end 0)))
4482 (if (re-search-forward page-delimiter nil 'move)
4485 (when (and (gnus-visual-p 'page-marker)
4486 (not (= (point-min) 1)))
4488 (goto-char (point-min))
4489 (gnus-insert-prev-page-button)))
4490 (when (and (gnus-visual-p 'page-marker)
4491 (< (+ (point-max) 2) (buffer-size)))
4493 (goto-char (point-max))
4494 (gnus-insert-next-page-button)))))
4496 ;; Article mode commands
4498 (defun gnus-article-goto-next-page ()
4499 "Show the next page of the article."
4501 (when (gnus-article-next-page)
4502 (goto-char (point-min))
4503 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4505 (defun gnus-article-goto-prev-page ()
4506 "Show the next page of the article."
4508 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4509 (gnus-article-prev-page nil)))
4511 (defun gnus-article-next-page (&optional lines)
4512 "Show the next page of the current article.
4513 If end of article, return non-nil. Otherwise return nil.
4514 Argument LINES specifies lines to be scrolled up."
4516 (move-to-window-line -1)
4519 (and (pos-visible-in-window-p) ;Not continuation line.
4521 ;; Nothing in this page.
4522 (if (or (not gnus-page-broken)
4525 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4527 (gnus-narrow-to-page 1) ;Go to next page.
4529 ;; More in this page.
4530 (let ((scroll-in-place nil))
4534 ;; Long lines may cause an end-of-buffer error.
4535 (goto-char (point-max)))))
4536 (move-to-window-line 0)
4539 (defun gnus-article-prev-page (&optional lines)
4540 "Show previous page of current article.
4541 Argument LINES specifies lines to be scrolled down."
4543 (move-to-window-line 0)
4544 (if (and gnus-page-broken
4546 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4548 (gnus-narrow-to-page -1) ;Go to previous page.
4549 (goto-char (point-max))
4551 (let ((scroll-in-place nil))
4555 (beginning-of-buffer
4556 (goto-char (point-min))))
4557 (move-to-window-line 0)))))
4559 (defun gnus-article-refer-article ()
4560 "Read article specified by message-id around point."
4562 (let ((point (point)))
4563 (search-forward ">" nil t) ;Move point to end of "<....>".
4564 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4565 (let ((message-id (match-string 1)))
4567 (set-buffer gnus-summary-buffer)
4568 (gnus-summary-refer-article message-id))
4570 (error "No references around point"))))
4572 (defun gnus-article-show-summary ()
4573 "Reconfigure windows to show summary buffer."
4575 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4576 (error "There is no summary buffer for this article buffer")
4577 (gnus-article-set-globals)
4578 (gnus-configure-windows 'article)
4579 (gnus-summary-goto-subject gnus-current-article)
4580 (gnus-summary-position-point)))
4582 (defun gnus-article-describe-briefly ()
4583 "Describe article mode commands briefly."
4585 (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")))
4587 (defun gnus-article-summary-command ()
4588 "Execute the last keystroke in the summary buffer."
4590 (let ((obuf (current-buffer))
4591 (owin (current-window-configuration))
4593 (switch-to-buffer gnus-article-current-summary 'norecord)
4594 (setq func (lookup-key (current-local-map) (this-command-keys)))
4595 (call-interactively func)
4597 (set-window-configuration owin)
4598 (set-window-point (get-buffer-window (current-buffer)) (point))))
4600 (defun gnus-article-summary-command-nosave ()
4601 "Execute the last keystroke in the summary buffer."
4604 (pop-to-buffer gnus-article-current-summary 'norecord)
4605 (setq func (lookup-key (current-local-map) (this-command-keys)))
4606 (call-interactively func)))
4608 (defun gnus-article-check-buffer ()
4609 "Beep if not in an article buffer."
4610 (unless (equal major-mode 'gnus-article-mode)
4611 (error "Command invoked outside of a Gnus article buffer")))
4613 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4614 "Read a summary buffer key sequence and execute it from the article buffer."
4616 (gnus-article-check-buffer)
4618 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4619 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4620 "=" "^" "\M-^" "|"))
4626 '("n" "Gn" "p" "Gp"))
4629 (set-buffer gnus-article-current-summary)
4630 (let (gnus-pick-mode)
4631 (push (or key last-command-event) unread-command-events)
4632 (setq keys (if (featurep 'xemacs)
4633 (events-to-keys (read-key-sequence nil))
4634 (read-key-sequence nil)))))
4638 (if (or (member keys nosaves)
4639 (member keys nosave-but-article)
4640 (member keys nosave-in-article))
4642 (save-window-excursion
4643 (pop-to-buffer gnus-article-current-summary 'norecord)
4644 ;; We disable the pick minor mode commands.
4645 (let (gnus-pick-mode)
4646 (setq func (lookup-key (current-local-map) keys))))
4650 (unless (member keys nosave-in-article)
4651 (set-buffer gnus-article-current-summary))
4652 (call-interactively func)
4653 (setq new-sum-point (point)))
4654 (when (member keys nosave-but-article)
4655 (pop-to-buffer gnus-article-buffer 'norecord)))
4656 ;; These commands should restore window configuration.
4657 (let ((obuf (current-buffer))
4658 (owin (current-window-configuration))
4660 (summary gnus-article-current-summary)
4661 func in-buffer selected)
4662 (if not-restore-window
4663 (pop-to-buffer summary 'norecord)
4664 (switch-to-buffer summary 'norecord))
4665 (setq in-buffer (current-buffer))
4666 ;; We disable the pick minor mode commands.
4667 (if (and (setq func (let (gnus-pick-mode)
4668 (lookup-key (current-local-map) keys)))
4671 (call-interactively func)
4672 (setq new-sum-point (point))
4673 (when (eq in-buffer (current-buffer))
4674 (setq selected (gnus-summary-select-article))
4676 (unless not-restore-window
4677 (set-window-configuration owin))
4678 (when (eq selected 'old)
4680 (set-window-start (get-buffer-window (current-buffer))
4682 (set-window-point (get-buffer-window (current-buffer))
4684 (let ((win (get-buffer-window gnus-article-current-summary)))
4686 (set-window-point win new-sum-point)))) )
4687 (switch-to-buffer gnus-article-buffer)
4690 (defun gnus-article-describe-key (key)
4691 "Display documentation of the function invoked by KEY. KEY is a string."
4692 (interactive "kDescribe key: ")
4693 (gnus-article-check-buffer)
4694 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4696 (set-buffer gnus-article-current-summary)
4697 (let (gnus-pick-mode)
4698 (if (featurep 'xemacs)
4700 (push (elt key 0) unread-command-events)
4701 (setq key (events-to-keys
4702 (read-key-sequence "Describe key: "))))
4703 (setq unread-command-events
4705 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4706 (string-to-list key)))
4707 (setq key (read-key-sequence "Describe key: "))))
4709 (describe-key key)))
4711 (defun gnus-article-describe-key-briefly (key &optional insert)
4712 "Display documentation of the function invoked by KEY. KEY is a string."
4713 (interactive "kDescribe key: \nP")
4714 (gnus-article-check-buffer)
4715 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4717 (set-buffer gnus-article-current-summary)
4718 (let (gnus-pick-mode)
4719 (if (featurep 'xemacs)
4721 (push (elt key 0) unread-command-events)
4722 (setq key (events-to-keys
4723 (read-key-sequence "Describe key: "))))
4724 (setq unread-command-events
4726 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4727 (string-to-list key)))
4728 (setq key (read-key-sequence "Describe key: "))))
4729 (describe-key-briefly key insert))
4730 (describe-key-briefly key insert)))
4732 (defun gnus-article-reply-with-original (&optional wide)
4733 "Start composing a reply mail to the current message.
4734 The text in the region will be yanked. If the region isn't active,
4735 the entire article will be yanked."
4737 (let ((article (cdr gnus-article-current)) cont)
4739 (gnus-summary-reply (list (list article)) wide)
4740 (setq cont (buffer-substring (point) (mark t)))
4741 ;; Deactivate active regions.
4742 (when (and (boundp 'transient-mark-mode)
4743 transient-mark-mode)
4744 (setq mark-active nil))
4746 (list (list article cont)) wide))))
4748 (defun gnus-article-followup-with-original ()
4749 "Compose a followup to the current article.
4750 The text in the region will be yanked. If the region isn't active,
4751 the entire article will be yanked."
4753 (let ((article (cdr gnus-article-current))
4756 (gnus-summary-followup (list (list article)))
4757 (setq cont (buffer-substring (point) (mark t)))
4758 ;; Deactivate active regions.
4759 (when (and (boundp 'transient-mark-mode)
4760 transient-mark-mode)
4761 (setq mark-active nil))
4762 (gnus-summary-followup
4763 (list (list article cont))))))
4765 (defun gnus-article-hide (&optional arg force)
4766 "Hide all the gruft in the current article.
4767 This means that PGP stuff, signatures, cited text and (some)
4768 headers will be hidden.
4769 If given a prefix, show the hidden text instead."
4770 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4771 (gnus-article-hide-headers arg)
4772 (gnus-article-hide-list-identifiers arg)
4773 (gnus-article-hide-pgp arg)
4774 (gnus-article-hide-citation-maybe arg force)
4775 (gnus-article-hide-signature arg))
4777 (defun gnus-article-maybe-highlight ()
4778 "Do some article highlighting if article highlighting is requested."
4779 (when (gnus-visual-p 'article-highlight 'highlight)
4780 (gnus-article-highlight-some)))
4782 (defun gnus-check-group-server ()
4783 ;; Make sure the connection to the server is alive.
4784 (unless (gnus-server-opened
4785 (gnus-find-method-for-group gnus-newsgroup-name))
4786 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4787 (gnus-request-group gnus-newsgroup-name t)))
4790 (autoload 'nneething-get-file-name "nneething"))
4792 (defun gnus-request-article-this-buffer (article group)
4793 "Get an article and insert it into this buffer."
4794 (let (do-update-line sparse-header)
4798 (gnus-kill-all-overlays)
4799 (setq group (or group gnus-newsgroup-name))
4801 ;; Using `gnus-request-article' directly will insert the article into
4802 ;; `nntp-server-buffer' - so we'll save some time by not having to
4803 ;; copy it from the server buffer into the article buffer.
4805 ;; We only request an article by message-id when we do not have the
4806 ;; headers for it, so we'll have to get those.
4807 (when (stringp article)
4808 (gnus-read-header article))
4810 ;; If the article number is negative, that means that this article
4811 ;; doesn't belong in this newsgroup (possibly), so we find its
4812 ;; message-id and request it by id instead of number.
4813 (when (and (numberp article)
4815 (get-buffer gnus-summary-buffer)
4816 (gnus-buffer-exists-p gnus-summary-buffer))
4818 (set-buffer gnus-summary-buffer)
4819 (let ((header (gnus-summary-article-header article)))
4822 ((memq article gnus-newsgroup-sparse)
4823 ;; This is a sparse gap article.
4824 (setq do-update-line article)
4825 (setq article (mail-header-id header))
4826 (setq sparse-header (gnus-read-header article))
4827 (setq gnus-newsgroup-sparse
4828 (delq article gnus-newsgroup-sparse)))
4830 ;; It's a real article.
4831 (setq article (mail-header-id header)))
4833 ;; It is an extracted pseudo-article.
4834 (setq article 'pseudo)
4835 (gnus-request-pseudo-article header))))
4837 (let ((method (gnus-find-method-for-group
4838 gnus-newsgroup-name)))
4839 (when (and (eq (car method) 'nneething)
4841 (let ((dir (nneething-get-file-name
4842 (mail-header-id header))))
4843 (when (and (stringp dir)
4844 (file-directory-p dir))
4845 (setq article 'nneething)
4846 (gnus-group-enter-directory dir))))))))
4849 ;; Refuse to select canceled articles.
4850 ((and (numberp article)
4852 (get-buffer gnus-summary-buffer)
4853 (gnus-buffer-exists-p gnus-summary-buffer)
4854 (eq (cdr (save-excursion
4855 (set-buffer gnus-summary-buffer)
4856 (assq article gnus-newsgroup-reads)))
4857 gnus-canceled-mark))
4859 ;; We first check `gnus-original-article-buffer'.
4860 ((and (get-buffer gnus-original-article-buffer)
4863 (set-buffer gnus-original-article-buffer)
4864 (and (equal (car gnus-original-article) group)
4865 (eq (cdr gnus-original-article) article))))
4866 (insert-buffer-substring gnus-original-article-buffer)
4868 ;; Check the backlog.
4869 ((and gnus-keep-backlog
4870 (gnus-backlog-request-article group article (current-buffer)))
4872 ;; Check asynchronous pre-fetch.
4873 ((gnus-async-request-fetched-article group article (current-buffer))
4874 (gnus-async-prefetch-next group article gnus-summary-buffer)
4875 (when (and (numberp article) gnus-keep-backlog)
4876 (gnus-backlog-enter-article group article (current-buffer)))
4879 ((and gnus-use-cache
4881 (gnus-cache-request-article article group))
4883 ;; Check the agent cache.
4884 ((and gnus-agent gnus-agent-cache gnus-plugged
4886 (gnus-agent-request-article article group))
4888 ;; Get the article and put into the article buffer.
4889 ((or (stringp article)
4891 (let ((gnus-override-method gnus-override-method)
4892 (methods (and (stringp article)
4893 gnus-refer-article-method))
4895 (buffer-read-only nil))
4896 (if (or (not (listp methods))
4897 (and (symbolp (car methods))
4898 (assq (car methods) nnoo-definition-alist)))
4899 (setq methods (list methods)))
4900 (when (and (null gnus-override-method)
4902 (setq gnus-override-method (pop methods)))
4904 (when (eq gnus-override-method 'current)
4905 (setq gnus-override-method
4906 (with-current-buffer gnus-summary-buffer
4907 gnus-current-select-method)))
4909 (gnus-kill-all-overlays)
4910 (let ((gnus-newsgroup-name group))
4911 (gnus-check-group-server))
4912 (when (gnus-request-article article group (current-buffer))
4913 (when (numberp article)
4914 (gnus-async-prefetch-next group article
4915 gnus-summary-buffer)
4916 (when gnus-keep-backlog
4917 (gnus-backlog-enter-article
4918 group article (current-buffer))))
4919 (setq result 'article))
4922 (setq gnus-override-method (pop methods))
4923 (setq result 'done))))
4924 (and (eq result 'article) 'article)))
4928 ;; Associate this article with the current summary buffer.
4929 (setq gnus-article-current-summary gnus-summary-buffer)
4931 ;; Take the article from the original article buffer
4932 ;; and place it in the buffer it's supposed to be in.
4933 (when (and (get-buffer gnus-article-buffer)
4934 (equal (buffer-name (current-buffer))
4935 (buffer-name (get-buffer gnus-article-buffer))))
4937 (if (get-buffer gnus-original-article-buffer)
4938 (set-buffer gnus-original-article-buffer)
4939 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4940 (buffer-disable-undo)
4941 (setq major-mode 'gnus-original-article-mode)
4942 (setq buffer-read-only t))
4943 (let (buffer-read-only)
4945 (insert-buffer-substring gnus-article-buffer))
4946 (setq gnus-original-article (cons group article)))
4949 (run-hooks 'gnus-article-decode-hook)
4950 ;; Mark article as decoded or not.
4951 (setq gnus-article-decoded-p gnus-article-decode-hook))
4953 ;; Update sparse articles.
4954 (when (and do-update-line
4955 (or (numberp article)
4957 (let ((buf (current-buffer)))
4958 (set-buffer gnus-summary-buffer)
4959 (gnus-summary-update-article do-update-line sparse-header)
4960 (gnus-summary-goto-subject do-update-line nil t)
4961 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4963 (set-buffer buf))))))
4969 (defcustom gnus-article-edit-mode-hook nil
4970 "Hook run in article edit mode buffers."
4971 :group 'gnus-article-various
4974 (defvar gnus-article-edit-done-function nil)
4976 (defvar gnus-article-edit-mode-map nil)
4978 ;; Should we be using derived.el for this?
4979 (unless gnus-article-edit-mode-map
4980 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4981 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4983 (gnus-define-keys gnus-article-edit-mode-map
4984 "\C-c\C-c" gnus-article-edit-done
4985 "\C-c\C-k" gnus-article-edit-exit)
4987 (gnus-define-keys (gnus-article-edit-wash-map
4988 "\C-c\C-w" gnus-article-edit-mode-map)
4989 "f" gnus-article-edit-full-stops))
4991 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4992 "Major mode for editing articles.
4993 This is an extended text-mode.
4995 \\{gnus-article-edit-mode-map}"
4996 (make-local-variable 'gnus-article-edit-done-function)
4997 (make-local-variable 'gnus-prev-winconf)
4998 (set (make-local-variable 'font-lock-defaults)
4999 '(message-font-lock-keywords t))
5000 (setq buffer-read-only nil)
5001 (buffer-enable-undo)
5004 (defun gnus-article-edit (&optional force)
5005 "Edit the current article.
5006 This will have permanent effect only in mail groups.
5007 If FORCE is non-nil, allow editing of articles even in read-only
5010 (when (and (not force)
5011 (gnus-group-read-only-p))
5012 (error "The current newsgroup does not support article editing"))
5013 (gnus-article-date-original)
5014 (gnus-article-edit-article
5016 `(lambda (no-highlight)
5018 (gnus-summary-edit-article-done
5019 ,(or (mail-header-references gnus-current-headers) "")
5020 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5022 (defun gnus-article-edit-article (start-func exit-func)
5023 "Start editing the contents of the current article buffer."
5024 (let ((winconf (current-window-configuration)))
5025 (set-buffer gnus-article-buffer)
5026 (gnus-article-edit-mode)
5027 (funcall start-func)
5028 (set-buffer-modified-p nil)
5029 (gnus-configure-windows 'edit-article)
5030 (setq gnus-article-edit-done-function exit-func)
5031 (setq gnus-prev-winconf winconf)
5032 (gnus-message 6 "C-c C-c to end edits")))
5034 (defun gnus-article-edit-done (&optional arg)
5035 "Update the article edits and exit."
5037 (let ((func gnus-article-edit-done-function)
5038 (buf (current-buffer))
5039 (start (window-start)))
5040 ;; We remove all text props from the article buffer.
5042 (buffer-substring-no-properties (point-min) (point-max)))
5046 (let ((winconf gnus-prev-winconf))
5048 (set-window-configuration winconf)
5049 ;; Tippy-toe some to make sure that point remains where it was.
5050 (save-current-buffer
5052 (set-window-start (get-buffer-window (current-buffer)) start)
5056 (let ((buffer-read-only nil))
5058 ;; The cache and backlog have to be flushed somewhat.
5059 (when gnus-keep-backlog
5060 (gnus-backlog-remove-article
5061 (car gnus-article-current) (cdr gnus-article-current)))
5062 ;; Flush original article as well.
5064 (when (get-buffer gnus-original-article-buffer)
5065 (set-buffer gnus-original-article-buffer)
5066 (setq gnus-original-article nil)))
5067 (when gnus-use-cache
5068 (gnus-cache-update-article
5069 (car gnus-article-current) (cdr gnus-article-current))))
5071 (set-window-start (get-buffer-window buf) start)
5072 (set-window-point (get-buffer-window buf) (point))))
5074 (defun gnus-article-edit-exit ()
5075 "Exit the article editing without updating."
5077 (when (or (not (buffer-modified-p))
5078 (yes-or-no-p "Article modified; kill anyway? "))
5079 (let ((curbuf (current-buffer))
5081 (window-start (window-start)))
5083 (if (gnus-buffer-live-p gnus-original-article-buffer)
5084 (insert-buffer gnus-original-article-buffer))
5085 (let ((winconf gnus-prev-winconf))
5087 (set-window-configuration winconf)
5088 ;; Tippy-toe some to make sure that point remains where it was.
5089 (save-current-buffer
5091 (set-window-start (get-buffer-window (current-buffer)) window-start)
5094 (defun gnus-article-edit-full-stops ()
5095 "Interactively repair spacing at end of sentences."
5098 (goto-char (point-min))
5099 (search-forward-regexp "^$" nil t)
5100 (let ((case-fold-search nil))
5101 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5104 ;;; Article highlights
5107 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5109 ;;; Internal Variables:
5111 (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\\)\\)"
5112 "Regular expression that matches URLs."
5113 :group 'gnus-article-buttons
5116 (defcustom gnus-button-alist
5117 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5118 0 t gnus-button-handle-news 3)
5119 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5120 gnus-button-handle-news 2)
5121 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5123 gnus-button-fetch-group 4)
5124 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5125 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5126 t gnus-button-message-id 3)
5127 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5128 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5129 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5131 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5132 gnus-button-handle-info 2)
5133 ;; This is how URLs _should_ be embedded in text...
5134 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5136 (,gnus-button-url-regexp 0 t browse-url 0))
5137 "*Alist of regexps matching buttons in article bodies.
5139 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5140 REGEXP: is the string matching text around the button,
5141 BUTTON: is the number of the regexp grouping actually matching the button,
5142 FORM: is a lisp expression which must eval to true for the button to
5144 CALLBACK: is the function to call when the user push this button, and each
5145 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5147 CALLBACK can also be a variable, in that case the value of that
5148 variable it the real callback function."
5149 :group 'gnus-article-buttons
5150 :type '(repeat (list regexp
5151 (integer :tag "Button")
5153 (function :tag "Callback")
5156 (integer :tag "Regexp group")))))
5158 (defcustom gnus-header-button-alist
5159 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5160 0 t gnus-button-message-id 0)
5161 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5162 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5163 0 t gnus-button-mailto 0)
5164 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5165 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5166 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5167 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5168 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5169 gnus-button-message-id 3))
5170 "*Alist of headers and regexps to match buttons in article heads.
5172 This alist is very similar to `gnus-button-alist', except that each
5173 alist has an additional HEADER element first in each entry:
5175 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5177 HEADER is a regexp to match a header. For a fuller explanation, see
5178 `gnus-button-alist'."
5179 :group 'gnus-article-buttons
5180 :group 'gnus-article-headers
5181 :type '(repeat (list (regexp :tag "Header")
5183 (integer :tag "Button")
5185 (function :tag "Callback")
5188 (integer :tag "Regexp group")))))
5190 (defvar gnus-button-regexp nil)
5191 (defvar gnus-button-marker-list nil)
5192 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5194 (defvar gnus-button-last nil)
5195 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5199 (defun gnus-article-push-button (event)
5200 "Check text under the mouse pointer for a callback function.
5201 If the text under the mouse pointer has a `gnus-callback' property,
5202 call it with the value of the `gnus-data' text property."
5204 (set-buffer (window-buffer (posn-window (event-start event))))
5205 (let* ((pos (posn-point (event-start event)))
5206 (data (get-text-property pos 'gnus-data))
5207 (fun (get-text-property pos 'gnus-callback)))
5210 (funcall fun data))))
5212 (defun gnus-article-press-button ()
5213 "Check text at point for a callback function.
5214 If the text at point has a `gnus-callback' property,
5215 call it with the value of the `gnus-data' text property."
5217 (let* ((data (get-text-property (point) 'gnus-data))
5218 (fun (get-text-property (point) 'gnus-callback)))
5220 (funcall fun data))))
5222 (defun gnus-article-highlight (&optional force)
5223 "Highlight current article.
5224 This function calls `gnus-article-highlight-headers',
5225 `gnus-article-highlight-citation',
5226 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5227 do the highlighting. See the documentation for those functions."
5228 (interactive (list 'force))
5229 (gnus-article-highlight-headers)
5230 (gnus-article-highlight-citation force)
5231 (gnus-article-highlight-signature)
5232 (gnus-article-add-buttons force)
5233 (gnus-article-add-buttons-to-head))
5235 (defun gnus-article-highlight-some (&optional force)
5236 "Highlight current article.
5237 This function calls `gnus-article-highlight-headers',
5238 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5239 do the highlighting. See the documentation for those functions."
5240 (interactive (list 'force))
5241 (gnus-article-highlight-headers)
5242 (gnus-article-highlight-signature)
5243 (gnus-article-add-buttons))
5245 (defun gnus-article-highlight-headers ()
5246 "Highlight article headers as specified by `gnus-header-face-alist'."
5249 (set-buffer gnus-article-buffer)
5251 (let ((alist gnus-header-face-alist)
5252 (buffer-read-only nil)
5253 (case-fold-search t)
5254 (inhibit-point-motion-hooks t)
5255 entry regexp header-face field-face from hpoints fpoints)
5256 (article-narrow-to-head)
5257 (while (setq entry (pop alist))
5258 (goto-char (point-min))
5259 (setq regexp (concat "^\\("
5260 (if (string-equal "" (nth 0 entry))
5264 header-face (nth 1 entry)
5265 field-face (nth 2 entry))
5266 (while (and (re-search-forward regexp nil t)
5270 (unless (search-forward ":" nil t)
5272 (when (and header-face
5273 (not (memq (point) hpoints)))
5274 (push (point) hpoints)
5275 (gnus-put-text-property from (point) 'face header-face))
5276 (when (and field-face
5277 (not (memq (setq from (point)) fpoints)))
5279 (if (re-search-forward "^[^ \t]" nil t)
5281 (goto-char (point-max)))
5282 (gnus-put-text-property from (point) 'face field-face))))))))
5284 (defun gnus-article-highlight-signature ()
5285 "Highlight the signature in an article.
5286 It does this by highlighting everything after
5287 `gnus-signature-separator' using `gnus-signature-face'."
5290 (set-buffer gnus-article-buffer)
5291 (let ((buffer-read-only nil)
5292 (inhibit-point-motion-hooks t))
5294 (when (and gnus-signature-face
5295 (gnus-article-narrow-to-signature))
5296 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5297 'face gnus-signature-face)
5299 (gnus-article-search-signature)
5300 (let ((start (match-beginning 0))
5301 (end (set-marker (make-marker) (1+ (match-end 0)))))
5302 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5305 (defun gnus-button-in-region-p (b e prop)
5306 "Say whether PROP exists in the region."
5307 (text-property-not-all b e prop nil))
5309 (defun gnus-article-add-buttons (&optional force)
5310 "Find external references in the article and make buttons of them.
5311 \"External references\" are things like Message-IDs and URLs, as
5312 specified by `gnus-button-alist'."
5313 (interactive (list 'force))
5315 (set-buffer gnus-article-buffer)
5316 (let ((buffer-read-only nil)
5317 (inhibit-point-motion-hooks t)
5318 (case-fold-search t)
5319 (alist gnus-button-alist)
5321 ;; Remove all old markers.
5322 (let (marker entry new-list)
5323 (while (setq marker (pop gnus-button-marker-list))
5324 (if (or (< marker (point-min)) (>= marker (point-max)))
5325 (push marker new-list)
5327 (when (setq entry (gnus-button-entry))
5328 (put-text-property (match-beginning (nth 1 entry))
5329 (match-end (nth 1 entry))
5330 'gnus-callback nil))
5331 (set-marker marker nil)))
5332 (setq gnus-button-marker-list new-list))
5333 ;; We skip the headers.
5336 (while (setq entry (pop alist))
5337 (setq regexp (car entry))
5339 (while (re-search-forward regexp nil t)
5340 (let* ((start (and entry (match-beginning (nth 1 entry))))
5341 (end (and entry (match-end (nth 1 entry))))
5342 (from (match-beginning 0)))
5343 (when (and (or (eq t (nth 2 entry))
5344 (eval (nth 2 entry)))
5345 (not (gnus-button-in-region-p
5346 start end 'gnus-callback)))
5347 ;; That optional form returned non-nil, so we add the
5349 (gnus-article-add-button
5350 start end 'gnus-button-push
5351 (car (push (set-marker (make-marker) from)
5352 gnus-button-marker-list))))))))))
5354 ;; Add buttons to the head of an article.
5355 (defun gnus-article-add-buttons-to-head ()
5356 "Add buttons to the head of the article."
5359 (set-buffer gnus-article-buffer)
5361 (let ((buffer-read-only nil)
5362 (inhibit-point-motion-hooks t)
5363 (case-fold-search t)
5364 (alist gnus-header-button-alist)
5366 (article-narrow-to-head)
5368 ;; Each alist entry.
5369 (setq entry (car alist)
5371 (goto-char (point-min))
5372 (while (re-search-forward (car entry) nil t)
5373 ;; Each header matching the entry.
5374 (setq beg (match-beginning 0))
5375 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5376 (match-beginning 0))
5379 (while (re-search-forward (nth 1 entry) end t)
5380 ;; Each match within a header.
5381 (let* ((entry (cdr entry))
5382 (start (match-beginning (nth 1 entry)))
5383 (end (match-end (nth 1 entry)))
5384 (form (nth 2 entry)))
5385 (goto-char (match-end 0))
5387 (gnus-article-add-button
5388 start end (nth 3 entry)
5389 (buffer-substring (match-beginning (nth 4 entry))
5390 (match-end (nth 4 entry)))))))
5391 (goto-char end)))))))
5393 ;;; External functions:
5395 (defun gnus-article-add-button (from to fun &optional data)
5396 "Create a button between FROM and TO with callback FUN and data DATA."
5397 (when gnus-article-button-face
5398 (gnus-overlay-put (gnus-make-overlay from to)
5399 'face gnus-article-button-face))
5400 (gnus-add-text-properties
5402 (nconc (and gnus-article-mouse-face
5403 (list gnus-mouse-face-prop gnus-article-mouse-face))
5404 (list 'gnus-callback fun)
5405 (and data (list 'gnus-data data))))
5406 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5407 :button-keymap gnus-widget-button-keymap))
5409 ;;; Internal functions:
5411 (defun gnus-article-set-globals ()
5413 (set-buffer gnus-summary-buffer)
5414 (gnus-set-global-variables)))
5416 (defun gnus-signature-toggle (end)
5418 (set-buffer gnus-article-buffer)
5419 (let ((buffer-read-only nil)
5420 (inhibit-point-motion-hooks t))
5421 (if (text-property-any end (point-max) 'article-type 'signature)
5423 (gnus-delete-wash-type 'signature)
5424 (gnus-remove-text-properties-when
5425 'article-type 'signature end (point-max)
5426 (cons 'article-type (cons 'signature
5427 gnus-hidden-properties))))
5428 (gnus-add-wash-type 'signature)
5429 (gnus-add-text-properties-when
5430 'article-type nil end (point-max)
5431 (cons 'article-type (cons 'signature
5432 gnus-hidden-properties)))))
5433 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5434 (gnus-set-mode-line 'article))))
5436 (defun gnus-button-entry ()
5437 ;; Return the first entry in `gnus-button-alist' matching this place.
5438 (let ((alist gnus-button-alist)
5441 (setq entry (pop alist))
5442 (if (looking-at (car entry))
5447 (defun gnus-button-push (marker)
5448 ;; Push button starting at MARKER.
5451 (let* ((entry (gnus-button-entry))
5452 (inhibit-point-motion-hooks t)
5454 (args (mapcar (lambda (group)
5455 (let ((string (match-string group)))
5456 (gnus-set-text-properties
5457 0 (length string) nil string)
5464 (fboundp (symbol-value fun)))
5465 (apply (symbol-value fun) args))
5467 (gnus-message 1 "You must define `%S' to use this button"
5468 (cons fun args)))))))
5470 (defun gnus-parse-news-url (url)
5471 (let (scheme server group message-id articles)
5474 (goto-char (point-min))
5475 (when (looking-at "\\([A-Za-z]+\\):")
5476 (setq scheme (match-string 1))
5477 (goto-char (match-end 0)))
5478 (when (looking-at "//\\([^/]+\\)/")
5479 (setq server (match-string 1))
5480 (goto-char (match-end 0)))
5483 ((looking-at "\\(.*@.*\\)")
5484 (setq message-id (match-string 1)))
5485 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5486 (setq group (match-string 1)
5487 articles (split-string (match-string 2) "-")))
5488 ((looking-at "\\([^/]+\\)/?")
5489 (setq group (match-string 1)))
5491 (error "Unknown news URL syntax"))))
5492 (list scheme server group message-id articles)))
5494 (defun gnus-button-handle-news (url)
5496 (destructuring-bind (scheme server group message-id articles)
5497 (gnus-parse-news-url url)
5501 (set-buffer gnus-summary-buffer)
5503 (let ((gnus-refer-article-method (list (list 'nntp server))))
5504 (gnus-summary-refer-article message-id))
5505 (gnus-summary-refer-article message-id))))
5507 (gnus-button-fetch-group url)))))
5509 (defun gnus-button-handle-info (url)
5510 "Fetch an info URL."
5512 "^\\([^:/]+\\)?/\\(.*\\)"
5514 (gnus-info-find-node
5515 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5518 (gnus-url-unhex-string (match-string 2 url))))
5519 (error "Can't parse %s" url)))
5521 (defun gnus-button-message-id (message-id)
5524 (set-buffer gnus-summary-buffer)
5525 (gnus-summary-refer-article message-id)))
5527 (defun gnus-button-fetch-group (address)
5528 "Fetch GROUP specified by ADDRESS."
5529 (if (not (string-match "[:/]" address))
5530 ;; This is just a simple group url.
5531 (gnus-group-read-ephemeral-group address gnus-select-method)
5534 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5536 (error "Can't parse %s" address)
5537 (gnus-group-read-ephemeral-group
5538 (match-string 4 address)
5539 `(nntp ,(match-string 1 address)
5540 (nntp-address ,(match-string 1 address))
5541 (nntp-port-number ,(if (match-end 3)
5542 (match-string 3 address)
5545 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5547 (defun gnus-url-parse-query-string (query &optional downcase)
5548 (let (retval pairs cur key val)
5549 (setq pairs (split-string query "&"))
5551 (setq cur (car pairs)
5553 (if (not (string-match "=" cur))
5555 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5556 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5558 (setq key (downcase key)))
5559 (setq cur (assoc key retval))
5561 (setcdr cur (cons val (cdr cur)))
5562 (setq retval (cons (list key val) retval)))))
5565 (defun gnus-url-mailto (url)
5566 ;; Send mail to someone
5567 (when (string-match "mailto:/*\\(.*\\)" url)
5568 (setq url (substring url (match-beginning 1) nil)))
5569 (let (to args subject func)
5570 (if (string-match (regexp-quote "?") url)
5571 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5572 args (gnus-url-parse-query-string
5573 (substring url (match-end 0) nil) t))
5574 (setq to (gnus-url-unhex-string url)))
5575 (setq args (cons (list "to" to) args)
5576 subject (cdr-safe (assoc "subject" args)))
5579 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5582 (message-position-on-field (caar args)))
5583 (insert (mapconcat 'identity (cdar args) ", "))
5584 (setq args (cdr args)))
5587 (message-goto-subject))))
5589 (defun gnus-button-embedded-url (address)
5590 "Activate ADDRESS with `browse-url'."
5591 (browse-url (gnus-strip-whitespace address)))
5593 ;;; Next/prev buttons in the article buffer.
5595 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5596 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5598 (defvar gnus-prev-page-map
5599 (let ((map (make-sparse-keymap)))
5600 (unless (>= emacs-major-version 21)
5601 ;; XEmacs doesn't care.
5602 (set-keymap-parent map gnus-article-mode-map))
5603 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5604 (define-key map "\r" 'gnus-button-prev-page)
5607 (defun gnus-insert-prev-page-button ()
5609 (buffer-read-only nil))
5611 gnus-prev-page-line-format nil
5612 `(,@(gnus-local-map-property gnus-prev-page-map)
5614 gnus-callback gnus-article-button-prev-page
5615 article-type annotation))
5616 (widget-convert-button
5618 :action 'gnus-button-prev-page
5619 :button-keymap gnus-prev-page-map)))
5621 (defvar gnus-prev-page-map
5622 (let ((map (make-sparse-keymap)))
5623 (unless (>= emacs-major-version 21)
5624 ;; XEmacs doesn't care.
5625 (set-keymap-parent map gnus-article-mode-map))
5626 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5627 (define-key map "\r" 'gnus-button-prev-page)
5630 (defvar gnus-next-page-map
5631 (let ((map (make-sparse-keymap)))
5632 (unless (>= emacs-major-version 21)
5633 ;; XEmacs doesn't care.
5634 (set-keymap-parent map gnus-article-mode-map))
5635 (define-key map gnus-mouse-2 'gnus-button-next-page)
5636 (define-key map "\r" 'gnus-button-next-page)
5639 (defun gnus-button-next-page (&optional args more-args)
5640 "Go to the next page."
5642 (let ((win (selected-window)))
5643 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5644 (gnus-article-next-page)
5645 (select-window win)))
5647 (defun gnus-button-prev-page (&optional args more-args)
5648 "Go to the prev page."
5650 (let ((win (selected-window)))
5651 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5652 (gnus-article-prev-page)
5653 (select-window win)))
5655 (defun gnus-insert-next-page-button ()
5657 (buffer-read-only nil))
5658 (gnus-eval-format gnus-next-page-line-format nil
5659 `(,@(gnus-local-map-property gnus-next-page-map)
5661 gnus-callback gnus-article-button-next-page
5662 article-type annotation))
5663 (widget-convert-button
5665 :action 'gnus-button-next-page
5666 :button-keymap gnus-next-page-map)))
5668 (defun gnus-article-button-next-page (arg)
5669 "Go to the next page."
5671 (let ((win (selected-window)))
5672 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5673 (gnus-article-next-page)
5674 (select-window win)))
5676 (defun gnus-article-button-prev-page (arg)
5677 "Go to the prev page."
5679 (let ((win (selected-window)))
5680 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5681 (gnus-article-prev-page)
5682 (select-window win)))
5684 (defvar gnus-decode-header-methods
5685 '(mail-decode-encoded-word-region)
5686 "List of methods used to decode headers.
5688 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5689 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5690 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5691 whose names match REGEXP.
5694 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5695 mail-decode-encoded-word-region
5696 (\"chinese\" . rfc1843-decode-region))
5699 (defvar gnus-decode-header-methods-cache nil)
5701 (defun gnus-multi-decode-header (start end)
5702 "Apply the functions from `gnus-encoded-word-methods' that match."
5703 (unless (and gnus-decode-header-methods-cache
5704 (eq gnus-newsgroup-name
5705 (car gnus-decode-header-methods-cache)))
5706 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5709 (nconc gnus-decode-header-methods-cache (list x))
5710 (if (and gnus-newsgroup-name
5711 (string-match (car x) gnus-newsgroup-name))
5712 (nconc gnus-decode-header-methods-cache
5714 gnus-decode-header-methods))
5715 (let ((xlist gnus-decode-header-methods-cache))
5718 (narrow-to-region start end)
5720 (funcall (pop xlist) (point-min) (point-max))))))
5723 ;;; Treatment top-level handling.
5726 (defun gnus-treat-article (condition &optional part-number total-parts type)
5727 (let ((length (- (point-max) (point-min)))
5728 (alist gnus-treatment-function-alist)
5729 (article-goto-body-goes-to-point-min-p t)
5733 (let ((list gnus-article-treat-types))
5735 (when (string-match (pop list) type)
5736 (throw 'found t)))))))
5737 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5739 (gnus-run-hooks 'gnus-part-display-hook)
5740 (while (setq elem (pop alist))
5743 (if (gnus-buffer-live-p gnus-summary-buffer)
5744 (set-buffer gnus-summary-buffer))
5745 (symbol-value (car elem))))
5746 (when (and (or (consp val)
5748 (gnus-treat-predicate val)
5749 (or (not (get (car elem) 'highlight))
5752 (funcall (cadr elem)))))))
5754 ;; Dynamic variables.
5756 (defvar part-number)
5757 (defvar total-parts)
5762 (defun gnus-treat-predicate (val)
5767 (stringp (car val)))
5768 (apply 'gnus-or (mapcar `(lambda (s)
5769 (string-match s ,(or gnus-newsgroup-name "")))
5772 (let ((pred (pop val)))
5775 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5777 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5779 (not (gnus-treat-predicate (car val))))
5781 (equal (car val) type))
5783 (error "%S is not a valid predicate" pred)))))
5791 (eq part-number total-parts))
5795 (error "%S is not a valid value" val))))
5797 (defun gnus-article-encrypt-body (protocol &optional n)
5798 "Encrypt the article body."
5801 (or gnus-article-encrypt-protocol
5802 (completing-read "Encrypt protocol: "
5803 gnus-article-encrypt-protocol-alist
5805 current-prefix-arg))
5806 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5808 (error (format "Can't find the encrypt protocol %s" protocol)))
5809 (if (equal gnus-newsgroup-name "nndraft:drafts")
5810 (error "Can't encrypt the article in group nndraft:drafts"))
5811 (if (equal gnus-newsgroup-name "nndraft:queue")
5812 (error "Don't encrypt the article in group nndraft:queue"))
5813 (gnus-summary-iterate n
5815 (set-buffer gnus-summary-buffer)
5816 (let ((mail-parse-charset gnus-newsgroup-charset)
5817 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5818 (summary-buffer gnus-summary-buffer)
5820 (gnus-set-global-variables)
5821 (when (gnus-group-read-only-p)
5822 (error "The current newsgroup does not support article encrypt"))
5823 (gnus-summary-show-article t)
5825 (or (mail-header-references gnus-current-headers) ""))
5826 (set-buffer gnus-article-buffer)
5827 (let* ((buffer-read-only nil)
5829 (mapcar (lambda (field)
5830 (and (save-restriction
5831 (message-narrow-to-head)
5832 (goto-char (point-min))
5833 (search-forward field nil t))
5835 (message-narrow-to-field)
5836 (buffer-substring (point-min) (point-max))
5837 (delete-region (point-min) (point-max))
5839 '("Content-Type:" "Content-Transfer-Encoding:"
5840 "Content-Disposition:"))))
5841 (message-narrow-to-head)
5842 (message-remove-header "MIME-Version")
5843 (goto-char (point-max))
5844 (setq point (point))
5845 (insert (apply 'concat headers))
5847 (narrow-to-region point (point-max))
5848 (let ((message-options message-options))
5849 (message-options-set 'message-sender user-mail-address)
5850 (message-options-set 'message-recipients user-mail-address)
5851 (message-options-set 'message-sign-encrypt 'not)
5853 (goto-char (point-min))
5854 (insert "MIME-Version: 1.0\n")
5856 (gnus-summary-edit-article-done
5857 references nil summary-buffer t))
5858 (when gnus-keep-backlog
5859 (gnus-backlog-remove-article
5860 (car gnus-article-current) (cdr gnus-article-current)))
5862 (when (get-buffer gnus-original-article-buffer)
5863 (set-buffer gnus-original-article-buffer)
5864 (setq gnus-original-article nil)))
5865 (when gnus-use-cache
5866 (gnus-cache-update-article
5867 (car gnus-article-current) (cdr gnus-article-current))))))))
5869 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5870 "The following specs can be used:
5871 %t The security MIME type
5874 %D Details if button is pressed")
5876 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5877 "The following specs can be used:
5878 %t The security MIME type
5881 %D Details if button is pressed")
5883 (defvar gnus-mime-security-button-line-format-alist
5884 '((?t gnus-tmp-type ?s)
5885 (?i gnus-tmp-info ?s)
5886 (?d gnus-tmp-details ?s)
5887 (?D gnus-tmp-pressed-details ?s)))
5889 (defvar gnus-mime-security-button-map
5890 (let ((map (make-sparse-keymap)))
5891 (unless (>= (string-to-number emacs-version) 21)
5892 (set-keymap-parent map gnus-article-mode-map))
5893 (define-key map gnus-mouse-2 'gnus-article-push-button)
5894 (define-key map "\r" 'gnus-article-press-button)
5897 (defvar gnus-mime-security-details-buffer nil)
5899 (defvar gnus-mime-security-button-pressed nil)
5901 (defvar gnus-mime-security-show-details-inline t
5902 "If non-nil, show details in the article buffer.")
5904 (defun gnus-mime-security-verify-or-decrypt (handle)
5905 (mm-remove-parts (cdr handle))
5906 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5907 point buffer-read-only)
5909 (goto-char (car region)))
5911 (narrow-to-region (point) (point))
5912 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5913 (let* ((mm-verify-option 'known)
5914 (mm-decrypt-option 'known)
5915 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5916 (unless (eq nparts (cdr handle))
5917 (mm-destroy-parts (cdr handle))
5918 (setcdr handle nparts))))
5919 (setq point (point))
5920 (gnus-mime-display-security handle)
5921 (goto-char (point-max)))
5923 (delete-region (point) (cdr region))
5924 (set-marker (car region) nil)
5925 (set-marker (cdr region) nil))
5928 (defun gnus-mime-security-show-details (handle)
5929 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5931 (if gnus-mime-security-show-details-inline
5932 (let ((gnus-mime-security-button-pressed t)
5933 (gnus-mime-security-button-line-format
5934 (get-text-property (point) 'gnus-line-format))
5937 (while (eq (get-text-property (point) 'gnus-line-format)
5938 gnus-mime-security-button-line-format)
5942 (narrow-to-region (point) (point))
5943 (gnus-insert-mime-security-button handle))
5944 (delete-region (point)
5945 (or (text-property-not-all
5948 gnus-mime-security-button-line-format)
5950 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5951 (with-current-buffer gnus-mime-security-details-buffer
5954 (setq gnus-mime-security-details-buffer
5955 (gnus-get-buffer-create "*MIME Security Details*")))
5956 (with-current-buffer gnus-mime-security-details-buffer
5958 (goto-char (point-min)))
5959 (pop-to-buffer gnus-mime-security-details-buffer))
5960 (gnus-message 5 "No details."))))
5962 (defun gnus-mime-security-press-button (handle)
5963 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5964 (gnus-mime-security-show-details handle)
5965 (gnus-mime-security-verify-or-decrypt handle)))
5967 (defun gnus-insert-mime-security-button (handle &optional displayed)
5968 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5971 (or (nth 2 (assoc protocol mm-verify-function-alist))
5972 (nth 2 (assoc protocol mm-decrypt-function-alist))
5974 (if (equal (car handle) "multipart/signed")
5975 " Signed" " Encrypted")
5978 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5981 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5982 gnus-tmp-pressed-details
5984 (setq gnus-tmp-details
5985 (if gnus-tmp-details
5986 (concat "\n" gnus-tmp-details) ""))
5987 (setq gnus-tmp-pressed-details
5988 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5993 gnus-mime-security-button-line-format
5994 gnus-mime-security-button-line-format-alist
5995 `(,@(gnus-local-map-property gnus-mime-security-button-map)
5996 gnus-callback gnus-mime-security-press-button
5997 gnus-line-format ,gnus-mime-security-button-line-format
5998 article-type annotation
6001 (widget-convert-button
6004 :action 'gnus-widget-press-button
6005 :button-keymap gnus-mime-security-button-map
6007 (lambda (widget/window &optional overlay pos)
6008 ;; Needed to properly clear the message due to a bug in
6009 ;; wid-edit (XEmacs only).
6010 (if (boundp 'help-echo-owns-message)
6011 (setq help-echo-owns-message t))
6014 (aref gnus-mouse-2 0))))))
6016 (defun gnus-mime-display-security (handle)
6018 (narrow-to-region (point) (point))
6019 (unless (gnus-unbuttonized-mime-type-p (car handle))
6020 (gnus-insert-mime-security-button handle))
6021 (gnus-mime-display-mixed (cdr handle))
6024 (unless (gnus-unbuttonized-mime-type-p (car handle))
6025 (let ((gnus-mime-security-button-line-format
6026 gnus-mime-security-button-end-line-format))
6027 (gnus-insert-mime-security-button handle)))
6028 (mm-set-handle-multipart-parameter
6030 (cons (set-marker (make-marker) (point-min))
6031 (set-marker (make-marker) (point-max))))))
6037 (run-hooks 'gnus-art-load-hook)
6039 ;;; gnus-art.el ends here