]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-art.el
(mouse-drag-track): Renamed, from `mouse-drag-region-1'. Includes
[gnu-emacs] / lisp / gnus / gnus-art.el
1 ;;; gnus-art.el --- article mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31 (require 'cl)
32 (defvar tool-bar-map)
33 (defvar w3m-minor-mode-map))
34
35 (require 'gnus)
36 (require 'gnus-sum)
37 (require 'gnus-spec)
38 (require 'gnus-int)
39 (require 'gnus-win)
40 (require 'mm-bodies)
41 (require 'mail-parse)
42 (require 'mm-decode)
43 (require 'mm-view)
44 (require 'wid-edit)
45 (require 'mm-uu)
46 (require 'message)
47
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
52
53 (defgroup gnus-article nil
54 "Article display."
55 :link '(custom-manual "(gnus)Article Buffer")
56 :group 'gnus)
57
58 (defgroup gnus-article-treat nil
59 "Treating article parts."
60 :link '(custom-manual "(gnus)Article Hiding")
61 :group 'gnus-article)
62
63 (defgroup gnus-article-hiding nil
64 "Hiding article parts."
65 :link '(custom-manual "(gnus)Article Hiding")
66 :group 'gnus-article)
67
68 (defgroup gnus-article-highlight nil
69 "Article highlighting."
70 :link '(custom-manual "(gnus)Article Highlighting")
71 :group 'gnus-article
72 :group 'gnus-visual)
73
74 (defgroup gnus-article-signature nil
75 "Article signatures."
76 :link '(custom-manual "(gnus)Article Signature")
77 :group 'gnus-article)
78
79 (defgroup gnus-article-headers nil
80 "Article headers."
81 :link '(custom-manual "(gnus)Hiding Headers")
82 :group 'gnus-article)
83
84 (defgroup gnus-article-washing nil
85 "Special commands on articles."
86 :link '(custom-manual "(gnus)Article Washing")
87 :group 'gnus-article)
88
89 (defgroup gnus-article-emphasis nil
90 "Fontisizing articles."
91 :link '(custom-manual "(gnus)Article Fontisizing")
92 :group 'gnus-article)
93
94 (defgroup gnus-article-saving nil
95 "Saving articles."
96 :link '(custom-manual "(gnus)Saving Articles")
97 :group 'gnus-article)
98
99 (defgroup gnus-article-mime nil
100 "Worshiping the MIME wonder."
101 :link '(custom-manual "(gnus)Using MIME")
102 :group 'gnus-article)
103
104 (defgroup gnus-article-buttons nil
105 "Pushable buttons in the article buffer."
106 :link '(custom-manual "(gnus)Article Buttons")
107 :group 'gnus-article)
108
109 (defgroup gnus-article-various nil
110 "Other article options."
111 :link '(custom-manual "(gnus)Misc Article")
112 :group 'gnus-article)
113
114 (defcustom gnus-ignored-headers
115 (mapcar
116 (lambda (header)
117 (concat "^" header ":"))
118 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
119 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
120 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
121 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
122 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
123 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
124 "X-Attribution" "X-Originating-IP" "Delivered-To"
125 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
126 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
127 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
128 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
129 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
130 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
131 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
132 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
133 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
134 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
135 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
136 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
137 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
138 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
139 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
140 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
141 "List-[A-Za-z]+" "X-Listprocessor-Version"
142 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
143 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
144 "X-Received" "Content-length" "X-precedence"
145 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
146 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
147 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
148 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
149 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
150 "X-Content-length" "X-Posting-Agent" "Original-Received"
151 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
152 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
153 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
154 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
155 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
156 "*All headers that start with this regexp will be hidden.
157 This variable can also be a list of regexps of headers to be ignored.
158 If `gnus-visible-headers' is non-nil, this variable will be ignored."
159 :type '(choice :custom-show nil
160 regexp
161 (repeat regexp))
162 :group 'gnus-article-hiding)
163
164 (defcustom gnus-visible-headers
165 "^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:"
166 "*All headers that do not match this regexp will be hidden.
167 This variable can also be a list of regexp of headers to remain visible.
168 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
169 :type '(repeat :value-to-internal (lambda (widget value)
170 (custom-split-regexp-maybe value))
171 :match (lambda (widget value)
172 (or (stringp value)
173 (widget-editable-list-match widget value)))
174 regexp)
175 :group 'gnus-article-hiding)
176
177 (defcustom gnus-sorted-header-list
178 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
179 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
180 "*This variable is a list of regular expressions.
181 If it is non-nil, headers that match the regular expressions will
182 be placed first in the article buffer in the sequence specified by
183 this list."
184 :type '(repeat regexp)
185 :group 'gnus-article-hiding)
186
187 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
188 "Headers that are only to be displayed if they have interesting data.
189 Possible values in this list are:
190
191 'empty Headers with no content.
192 'newsgroups Newsgroup identical to Gnus group.
193 'to-address To identical to To-address.
194 'to-list To identical to To-list.
195 'cc-list CC identical to To-list.
196 'followup-to Followup-to identical to Newsgroups.
197 'reply-to Reply-to identical to From.
198 'date Date less than four days old.
199 'long-to To and/or Cc longer than 1024 characters.
200 'many-to Multiple To and/or Cc."
201 :type '(set (const :tag "Headers with no content." empty)
202 (const :tag "Newsgroups identical to Gnus group." newsgroups)
203 (const :tag "To identical to To-address." to-address)
204 (const :tag "To identical to To-list." to-list)
205 (const :tag "CC identical to To-list." cc-list)
206 (const :tag "Followup-to identical to Newsgroups." followup-to)
207 (const :tag "Reply-to identical to From." reply-to)
208 (const :tag "Date less than four days old." date)
209 (const :tag "To and/or Cc longer than 1024 characters." long-to)
210 (const :tag "Multiple To and/or Cc headers." many-to))
211 :group 'gnus-article-hiding)
212
213 (defcustom gnus-article-skip-boring nil
214 "Skip over text that is not worth reading.
215 By default, if you set this t, then Gnus will display citations and
216 signatures, but will never scroll down to show you a page consisting
217 only of boring text. Boring text is controlled by
218 `gnus-article-boring-faces'."
219 :version "22.1"
220 :type 'boolean
221 :group 'gnus-article-hiding)
222
223 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
224 "Regexp matching signature separator.
225 This can also be a list of regexps. In that case, it will be checked
226 from head to tail looking for a separator. Searches will be done from
227 the end of the buffer."
228 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
229 (regexp)
230 (repeat :tag "List of regexp" regexp))
231 :group 'gnus-article-signature)
232
233 (defcustom gnus-signature-limit nil
234 "Provide a limit to what is considered a signature.
235 If it is a number, no signature may not be longer (in characters) than
236 that number. If it is a floating point number, no signature may be
237 longer (in lines) than that number. If it is a function, the function
238 will be called without any parameters, and if it returns nil, there is
239 no signature in the buffer. If it is a string, it will be used as a
240 regexp. If it matches, the text in question is not a signature."
241 :type '(choice (const nil)
242 (integer :value 200)
243 (number :value 4.0)
244 (function :value fun)
245 (regexp :value ".*"))
246 :group 'gnus-article-signature)
247
248 (defcustom gnus-hidden-properties '(invisible t intangible t)
249 "Property list to use for hiding text."
250 :type 'sexp
251 :group 'gnus-article-hiding)
252
253 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
254 ;; frames in a session.
255 (defcustom gnus-article-x-face-command
256 (if (featurep 'xemacs)
257 (if (or (gnus-image-type-available-p 'xface)
258 (gnus-image-type-available-p 'pbm))
259 'gnus-display-x-face-in-from
260 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
261 (if (gnus-image-type-available-p 'pbm)
262 'gnus-display-x-face-in-from
263 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
264 display -"))
265 "*String or function to be executed to display an X-Face header.
266 If it is a string, the command will be executed in a sub-shell
267 asynchronously. The compressed face will be piped to this command."
268 :type `(choice string
269 (function-item gnus-display-x-face-in-from)
270 function)
271 :version "21.1"
272 :group 'gnus-picon
273 :group 'gnus-article-washing)
274
275 (defcustom gnus-article-x-face-too-ugly nil
276 "Regexp matching posters whose face shouldn't be shown automatically."
277 :type '(choice regexp (const nil))
278 :group 'gnus-article-washing)
279
280 (defcustom gnus-article-banner-alist nil
281 "Banner alist for stripping.
282 For example,
283 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
284 :version "21.1"
285 :type '(repeat (cons symbol regexp))
286 :group 'gnus-article-washing)
287
288 (gnus-define-group-parameter
289 banner
290 :variable-document
291 "Alist of regexps (to match group names) and banner."
292 :variable-group gnus-article-washing
293 :parameter-type
294 '(choice :tag "Banner"
295 :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
298 regexp
299 (const :tag "None" nil))
300 :parameter-document
301 "If non-nil, specify how to remove `banners' from articles.
302
303 Symbol `signature' means to remove signatures delimited by
304 `gnus-signature-separator'. Any other symbol is used to look up a
305 regular expression to match the banner in `gnus-article-banner-alist'.
306 A string is used as a regular expression to match the banner
307 directly.")
308
309 (defcustom gnus-article-address-banner-alist nil
310 "Alist of mail addresses and banners.
311 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
312 to match a mail address in the From: header, BANNER is one of a symbol
313 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
314 If ADDRESS matches author's mail address, it will remove things like
315 advertisements. For example:
316
317 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
318 "
319 :type '(repeat
320 (cons
321 (regexp :tag "Address")
322 (choice :tag "Banner" :value nil
323 (const :tag "Remove signature" signature)
324 (symbol :tag "Item in `gnus-article-banner-alist'" none)
325 regexp
326 (const :tag "None" nil))))
327 :version "22.1"
328 :group 'gnus-article-washing)
329
330 (defmacro gnus-emphasis-custom-with-format (&rest body)
331 `(let ((format "\
332 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
333 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
334 ,@body))
335
336 (defun gnus-emphasis-custom-value-to-external (value)
337 (gnus-emphasis-custom-with-format
338 (if (consp (car value))
339 (list (format format (car (car value)) (cdr (car value)))
340 2
341 (if (nth 1 value) 2 3)
342 (nth 2 value))
343 value)))
344
345 (defun gnus-emphasis-custom-value-to-internal (value)
346 (gnus-emphasis-custom-with-format
347 (let ((regexp (concat "\\`"
348 (format (regexp-quote format)
349 "\\([^()]+\\)" "\\([^()]+\\)")
350 "\\'"))
351 pattern)
352 (if (string-match regexp (setq pattern (car value)))
353 (list (cons (match-string 1 pattern) (match-string 2 pattern))
354 (= (nth 2 value) 2)
355 (nth 3 value))
356 value))))
357
358 (defcustom gnus-emphasis-alist
359 (let ((types
360 '(("\\*" "\\*" bold nil 2)
361 ("_" "_" underline)
362 ("/" "/" italic)
363 ("_/" "/_" underline-italic)
364 ("_\\*" "\\*_" underline-bold)
365 ("\\*/" "/\\*" bold-italic)
366 ("_\\*/" "/\\*_" underline-bold-italic))))
367 (nconc
368 (gnus-emphasis-custom-with-format
369 (mapcar (lambda (spec)
370 (list (format format (car spec) (cadr spec))
371 (or (nth 3 spec) 2)
372 (or (nth 4 spec) 3)
373 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
374 types))
375 '(;; I've never seen anyone use this strikethru convention whereas I've
376 ;; several times seen it triggered by normal text. --Stef
377 ;; Miles suggests that this form is sometimes used but for italics,
378 ;; so maybe we should map it to `italic'.
379 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
380 ;; 2 3 gnus-emphasis-strikethru)
381 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
382 2 3 gnus-emphasis-underline))))
383 "*Alist that says how to fontify certain phrases.
384 Each item looks like this:
385
386 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
387
388 The first element is a regular expression to be matched. The second
389 is a number that says what regular expression grouping used to find
390 the entire emphasized word. The third is a number that says what
391 regexp grouping should be displayed and highlighted. The fourth
392 is the face used for highlighting."
393 :type
394 '(repeat
395 (menu-choice
396 :format "%[Customizing Style%]\n%v"
397 :indent 2
398 (group :tag "Default"
399 :value ("" 0 0 default)
400 :value-create
401 (lambda (widget)
402 (let ((value (widget-get
403 (cadr (widget-get (widget-get widget :parent)
404 :args))
405 :value)))
406 (if (not (eq (nth 2 value) 'default))
407 (widget-put
408 widget
409 :value
410 (gnus-emphasis-custom-value-to-external value))))
411 (widget-group-value-create widget))
412 regexp
413 (integer :format "Match group: %v")
414 (integer :format "Emphasize group: %v")
415 face)
416 (group :tag "Simple"
417 :value (("_" . "_") nil default)
418 (cons :format "%v"
419 (regexp :format "Start regexp: %v")
420 (regexp :format "End regexp: %v"))
421 (boolean :format "Show start and end patterns: %[%v%]\n"
422 :on " On " :off " Off ")
423 face)))
424 :get (lambda (symbol)
425 (mapcar 'gnus-emphasis-custom-value-to-internal
426 (default-value symbol)))
427 :set (lambda (symbol value)
428 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
429 value)))
430 :group 'gnus-article-emphasis)
431
432 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
433 "A regexp to describe whitespace which should not be emphasized.
434 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
435 The former avoids underlining of leading and trailing whitespace,
436 and the latter avoids underlining any whitespace at all."
437 :version "21.1"
438 :group 'gnus-article-emphasis
439 :type 'regexp)
440
441 (defface gnus-emphasis-bold '((t (:bold t)))
442 "Face used for displaying strong emphasized text (*word*)."
443 :group 'gnus-article-emphasis)
444
445 (defface gnus-emphasis-italic '((t (:italic t)))
446 "Face used for displaying italic emphasized text (/word/)."
447 :group 'gnus-article-emphasis)
448
449 (defface gnus-emphasis-underline '((t (:underline t)))
450 "Face used for displaying underlined emphasized text (_word_)."
451 :group 'gnus-article-emphasis)
452
453 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
454 "Face used for displaying underlined bold emphasized text (_*word*_)."
455 :group 'gnus-article-emphasis)
456
457 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
458 "Face used for displaying underlined italic emphasized text (_/word/_)."
459 :group 'gnus-article-emphasis)
460
461 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
462 "Face used for displaying bold italic emphasized text (/*word*/)."
463 :group 'gnus-article-emphasis)
464
465 (defface gnus-emphasis-underline-bold-italic
466 '((t (:bold t :italic t :underline t)))
467 "Face used for displaying underlined bold italic emphasized text.
468 Example: (_/*word*/_)."
469 :group 'gnus-article-emphasis)
470
471 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
472 '((t (:strikethru t)))
473 '((t (:strike-through t))))
474 "Face used for displaying strike-through text (-word-)."
475 :group 'gnus-article-emphasis)
476
477 (defface gnus-emphasis-highlight-words
478 '((t (:background "black" :foreground "yellow")))
479 "Face used for displaying highlighted words."
480 :group 'gnus-article-emphasis)
481
482 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
483 "Format for display of Date headers in article bodies.
484 See `format-time-string' for the possible values.
485
486 The variable can also be function, which should return a complete Date
487 header. The function is called with one argument, the time, which can
488 be fed to `format-time-string'."
489 :type '(choice string symbol)
490 :link '(custom-manual "(gnus)Article Date")
491 :group 'gnus-article-washing)
492
493 (defcustom gnus-save-all-headers t
494 "*If non-nil, don't remove any headers before saving."
495 :group 'gnus-article-saving
496 :type 'boolean)
497
498 (defcustom gnus-prompt-before-saving 'always
499 "*This variable says how much prompting is to be done when saving articles.
500 If it is nil, no prompting will be done, and the articles will be
501 saved to the default files. If this variable is `always', each and
502 every article that is saved will be preceded by a prompt, even when
503 saving large batches of articles. If this variable is neither nil not
504 `always', there the user will be prompted once for a file name for
505 each invocation of the saving commands."
506 :group 'gnus-article-saving
507 :type '(choice (item always)
508 (item :tag "never" nil)
509 (sexp :tag "once" :format "%t\n" :value t)))
510
511 (defcustom gnus-saved-headers gnus-visible-headers
512 "Headers to keep if `gnus-save-all-headers' is nil.
513 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
514 If that variable is nil, however, all headers that match this regexp
515 will be kept while the rest will be deleted before saving."
516 :group 'gnus-article-saving
517 :type 'regexp)
518
519 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
520 "A function to save articles in your favourite format.
521 The function must be interactively callable (in other words, it must
522 be an Emacs command).
523
524 Gnus provides the following functions:
525
526 * gnus-summary-save-in-rmail (Rmail format)
527 * gnus-summary-save-in-mail (Unix mail format)
528 * gnus-summary-save-in-folder (MH folder)
529 * gnus-summary-save-in-file (article format)
530 * gnus-summary-save-body-in-file (article body)
531 * gnus-summary-save-in-vm (use VM's folder format)
532 * gnus-summary-write-to-file (article format -- overwrite)."
533 :group 'gnus-article-saving
534 :type '(radio (function-item gnus-summary-save-in-rmail)
535 (function-item gnus-summary-save-in-mail)
536 (function-item gnus-summary-save-in-folder)
537 (function-item gnus-summary-save-in-file)
538 (function-item gnus-summary-save-body-in-file)
539 (function-item gnus-summary-save-in-vm)
540 (function-item gnus-summary-write-to-file)
541 (function)))
542
543 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
544 "A function generating a file name to save articles in Rmail format.
545 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
546 :group 'gnus-article-saving
547 :type 'function)
548
549 (defcustom gnus-mail-save-name 'gnus-plain-save-name
550 "A function generating a file name to save articles in Unix mail format.
551 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
552 :group 'gnus-article-saving
553 :type 'function)
554
555 (defcustom gnus-folder-save-name 'gnus-folder-save-name
556 "A function generating a file name to save articles in MH folder.
557 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
558 :group 'gnus-article-saving
559 :type 'function)
560
561 (defcustom gnus-file-save-name 'gnus-numeric-save-name
562 "A function generating a file name to save articles in article format.
563 The function is called with NEWSGROUP, HEADERS, and optional
564 LAST-FILE."
565 :group 'gnus-article-saving
566 :type 'function)
567
568 (defcustom gnus-split-methods
569 '((gnus-article-archive-name)
570 (gnus-article-nndoc-name))
571 "*Variable used to suggest where articles are to be saved.
572 For instance, if you would like to save articles related to Gnus in
573 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
574 you could set this variable to something like:
575
576 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
577 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
578
579 This variable is an alist where the where the key is the match and the
580 value is a list of possible files to save in if the match is non-nil.
581
582 If the match is a string, it is used as a regexp match on the
583 article. If the match is a symbol, that symbol will be funcalled
584 from the buffer of the article to be saved with the newsgroup as the
585 parameter. If it is a list, it will be evaled in the same buffer.
586
587 If this form or function returns a string, this string will be used as
588 a possible file name; and if it returns a non-nil list, that list will
589 be used as possible file names."
590 :group 'gnus-article-saving
591 :type '(repeat (choice (list :value (fun) function)
592 (cons :value ("" "") regexp (repeat string))
593 (sexp :value nil))))
594
595 (defcustom gnus-page-delimiter "^\^L"
596 "*Regexp describing what to use as article page delimiters.
597 The default value is \"^\^L\", which is a form linefeed at the
598 beginning of a line."
599 :type 'regexp
600 :group 'gnus-article-various)
601
602 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
603 "*The format specification for the article mode line.
604 See `gnus-summary-mode-line-format' for a closer description.
605
606 The following additional specs are available:
607
608 %w The article washing status.
609 %m The number of MIME parts in the article."
610 :type 'string
611 :group 'gnus-article-various)
612
613 (defcustom gnus-article-mode-hook nil
614 "*A hook for Gnus article mode."
615 :type 'hook
616 :group 'gnus-article-various)
617
618 (when (featurep 'xemacs)
619 ;; Extracted from gnus-xmas-define in order to preserve user settings
620 (when (fboundp 'turn-off-scroll-in-place)
621 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
622 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
623 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
624
625 (defcustom gnus-article-menu-hook nil
626 "*Hook run after the creation of the article mode menu."
627 :type 'hook
628 :group 'gnus-article-various)
629
630 (defcustom gnus-article-prepare-hook nil
631 "*A hook called after an article has been prepared in the article buffer."
632 :type 'hook
633 :group 'gnus-article-various)
634
635 (make-obsolete-variable 'gnus-article-hide-pgp-hook
636 "This variable is obsolete in Gnus 5.10.")
637
638 (defcustom gnus-article-button-face 'bold
639 "Face used for highlighting buttons in the article buffer.
640
641 An article button is a piece of text that you can activate by pressing
642 `RET' or `mouse-2' above it."
643 :type 'face
644 :group 'gnus-article-buttons)
645
646 (defcustom gnus-article-mouse-face 'highlight
647 "Face used for mouse highlighting in the article buffer.
648
649 Article buttons will be displayed in this face when the cursor is
650 above them."
651 :type 'face
652 :group 'gnus-article-buttons)
653
654 (defcustom gnus-signature-face 'gnus-signature
655 "Face used for highlighting a signature in the article buffer.
656 Obsolete; use the face `gnus-signature' for customizations instead."
657 :type 'face
658 :group 'gnus-article-highlight
659 :group 'gnus-article-signature)
660
661 (defface gnus-signature
662 '((t
663 (:italic t)))
664 "Face used for highlighting a signature in the article buffer."
665 :group 'gnus-article-highlight
666 :group 'gnus-article-signature)
667 ;; backward-compatibility alias
668 (put 'gnus-signature-face 'face-alias 'gnus-signature)
669
670 (defface gnus-header-from
671 '((((class color)
672 (background dark))
673 (:foreground "spring green"))
674 (((class color)
675 (background light))
676 (:foreground "red3"))
677 (t
678 (:italic t)))
679 "Face used for displaying from headers."
680 :group 'gnus-article-headers
681 :group 'gnus-article-highlight)
682 ;; backward-compatibility alias
683 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
684
685 (defface gnus-header-subject
686 '((((class color)
687 (background dark))
688 (:foreground "SeaGreen3"))
689 (((class color)
690 (background light))
691 (:foreground "red4"))
692 (t
693 (:bold t :italic t)))
694 "Face used for displaying subject headers."
695 :group 'gnus-article-headers
696 :group 'gnus-article-highlight)
697 ;; backward-compatibility alias
698 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
699
700 (defface gnus-header-newsgroups
701 '((((class color)
702 (background dark))
703 (:foreground "yellow" :italic t))
704 (((class color)
705 (background light))
706 (:foreground "MidnightBlue" :italic t))
707 (t
708 (:italic t)))
709 "Face used for displaying newsgroups headers.
710 In the default setup this face is only used for crossposted
711 articles."
712 :group 'gnus-article-headers
713 :group 'gnus-article-highlight)
714 ;; backward-compatibility alias
715 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
716
717 (defface gnus-header-name
718 '((((class color)
719 (background dark))
720 (:foreground "SeaGreen"))
721 (((class color)
722 (background light))
723 (:foreground "maroon"))
724 (t
725 (:bold t)))
726 "Face used for displaying header names."
727 :group 'gnus-article-headers
728 :group 'gnus-article-highlight)
729 ;; backward-compatibility alias
730 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
731
732 (defface gnus-header-content
733 '((((class color)
734 (background dark))
735 (:foreground "forest green" :italic t))
736 (((class color)
737 (background light))
738 (:foreground "indianred4" :italic t))
739 (t
740 (:italic t))) "Face used for displaying header content."
741 :group 'gnus-article-headers
742 :group 'gnus-article-highlight)
743 ;; backward-compatibility alias
744 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
745
746 (defcustom gnus-header-face-alist
747 '(("From" nil gnus-header-from)
748 ("Subject" nil gnus-header-subject)
749 ("Newsgroups:.*," nil gnus-header-newsgroups)
750 ("" gnus-header-name gnus-header-content))
751 "*Controls highlighting of article headers.
752
753 An alist of the form (HEADER NAME CONTENT).
754
755 HEADER is a regular expression which should match the name of a
756 header and NAME and CONTENT are either face names or nil.
757
758 The name of each header field will be displayed using the face
759 specified by the first element in the list where HEADER matches
760 the header name and NAME is non-nil. Similarly, the content will
761 be displayed by the first non-nil matching CONTENT face."
762 :group 'gnus-article-headers
763 :group 'gnus-article-highlight
764 :type '(repeat (list (regexp :tag "Header")
765 (choice :tag "Name"
766 (item :tag "skip" nil)
767 (face :value default))
768 (choice :tag "Content"
769 (item :tag "skip" nil)
770 (face :value default)))))
771
772 (defcustom gnus-article-decode-hook
773 '(article-decode-charset article-decode-encoded-words
774 article-decode-group-name article-decode-idna-rhs)
775 "*Hook run to decode charsets in articles."
776 :group 'gnus-article-headers
777 :type 'hook)
778
779 (defcustom gnus-display-mime-function 'gnus-display-mime
780 "Function to display MIME articles."
781 :group 'gnus-article-mime
782 :type 'function)
783
784 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
785 "Function used to decode headers.")
786
787 (defvar gnus-article-dumbquotes-map
788 '(("\200" "EUR")
789 ("\202" ",")
790 ("\203" "f")
791 ("\204" ",,")
792 ("\205" "...")
793 ("\213" "<")
794 ("\214" "OE")
795 ("\221" "`")
796 ("\222" "'")
797 ("\223" "``")
798 ("\224" "\"")
799 ("\225" "*")
800 ("\226" "-")
801 ("\227" "--")
802 ("\230" "~")
803 ("\231" "(TM)")
804 ("\233" ">")
805 ("\234" "oe")
806 ("\264" "'"))
807 "Table for MS-to-Latin1 translation.")
808
809 (defcustom gnus-ignored-mime-types nil
810 "List of MIME types that should be ignored by Gnus."
811 :version "21.1"
812 :group 'gnus-article-mime
813 :type '(repeat regexp))
814
815 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
816 "List of MIME types that should not be given buttons when rendered inline.
817 See also `gnus-buttonized-mime-types' which may override this variable.
818 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
819 :version "21.1"
820 :group 'gnus-article-mime
821 :type '(repeat regexp))
822
823 (defcustom gnus-buttonized-mime-types nil
824 "List of MIME types that should be given buttons when rendered inline.
825 If set, this variable overrides `gnus-unbuttonized-mime-types'.
826 To see e.g. security buttons you could set this to
827 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
828 this list to display radio buttons that allow you to choose one of two
829 media types those mails include. See also `mm-discouraged-alternatives'.
830 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
831 :version "22.1"
832 :group 'gnus-article-mime
833 :type '(repeat regexp))
834
835 (defcustom gnus-inhibit-mime-unbuttonizing nil
836 "If non-nil, all MIME parts get buttons.
837 When nil (the default value), then some MIME parts do not get buttons,
838 as described by the variables `gnus-buttonized-mime-types' and
839 `gnus-unbuttonized-mime-types'."
840 :version "22.1"
841 :group 'gnus-article-mime
842 :type 'boolean)
843
844 (defcustom gnus-body-boundary-delimiter "_"
845 "String used to delimit header and body.
846 This variable is used by `gnus-article-treat-body-boundary' which can
847 be controlled by `gnus-treat-body-boundary'."
848 :version "22.1"
849 :group 'gnus-article-various
850 :type '(choice (item :tag "None" :value nil)
851 string))
852
853 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
854 "/usr/share/picons")
855 "Defines the location of the faces database.
856 For information on obtaining this database of pretty pictures, please
857 see http://www.cs.indiana.edu/picons/ftp/index.html"
858 :version "22.1"
859 :type '(repeat directory)
860 :link '(url-link :tag "download"
861 "http://www.cs.indiana.edu/picons/ftp/index.html")
862 :link '(custom-manual "(gnus)Picons")
863 :group 'gnus-picon)
864
865 (defun gnus-picons-installed-p ()
866 "Say whether picons are installed on your machine."
867 (let ((installed nil))
868 (dolist (database gnus-picon-databases)
869 (when (file-exists-p database)
870 (setq installed t)))
871 installed))
872
873 (defcustom gnus-article-mime-part-function nil
874 "Function called with a MIME handle as the argument.
875 This is meant for people who want to do something automatic based
876 on parts -- for instance, adding Vcard info to a database."
877 :group 'gnus-article-mime
878 :type '(choice (const nil)
879 function))
880
881 (defcustom gnus-mime-multipart-functions nil
882 "An alist of MIME types to functions to display them."
883 :version "21.1"
884 :group 'gnus-article-mime
885 :type 'alist)
886
887 (defcustom gnus-article-date-lapsed-new-header nil
888 "Whether the X-Sent and Date headers can coexist.
889 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
890 either replace the old \"Date:\" header (if this variable is nil), or
891 be added below it (otherwise)."
892 :version "21.1"
893 :group 'gnus-article-headers
894 :type 'boolean)
895
896 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
897 "Function called with a MIME handle as the argument.
898 This is meant for people who want to view first matched part.
899 For `undisplayed-alternative' (default), the first undisplayed
900 part or alternative part is used. For `undisplayed', the first
901 undisplayed part is used. For a function, the first part which
902 the function return t is used. For nil, the first part is
903 used."
904 :version "21.1"
905 :group 'gnus-article-mime
906 :type '(choice
907 (item :tag "first" :value nil)
908 (item :tag "undisplayed" :value undisplayed)
909 (item :tag "undisplayed or alternative"
910 :value undisplayed-alternative)
911 (function)))
912
913 (defcustom gnus-mime-action-alist
914 '(("save to file" . gnus-mime-save-part)
915 ("save and strip" . gnus-mime-save-part-and-strip)
916 ("delete part" . gnus-mime-delete-part)
917 ("display as text" . gnus-mime-inline-part)
918 ("view the part" . gnus-mime-view-part)
919 ("pipe to command" . gnus-mime-pipe-part)
920 ("toggle display" . gnus-article-press-button)
921 ("toggle display" . gnus-article-view-part-as-charset)
922 ("view as type" . gnus-mime-view-part-as-type)
923 ("view internally" . gnus-mime-view-part-internally)
924 ("view externally" . gnus-mime-view-part-externally))
925 "An alist of actions that run on the MIME attachment."
926 :group 'gnus-article-mime
927 :type '(repeat (cons (string :tag "name")
928 (function))))
929
930 ;;;
931 ;;; The treatment variables
932 ;;;
933
934 (defvar gnus-part-display-hook nil
935 "Hook called on parts that are to receive treatment.")
936
937 (defvar gnus-article-treat-custom
938 '(choice (const :tag "Off" nil)
939 (const :tag "On" t)
940 (const :tag "Header" head)
941 (const :tag "Last" last)
942 (integer :tag "Less")
943 (repeat :tag "Groups" regexp)
944 (sexp :tag "Predicate")))
945
946 (defvar gnus-article-treat-head-custom
947 '(choice (const :tag "Off" nil)
948 (const :tag "Header" head)))
949
950 (defvar gnus-article-treat-types '("text/plain")
951 "Parts to treat.")
952
953 (defvar gnus-inhibit-treatment nil
954 "Whether to inhibit treatment.")
955
956 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
957 "Highlight the signature.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles'."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
963 (put 'gnus-treat-highlight-signature 'highlight t)
964
965 (defcustom gnus-treat-buttonize 100000
966 "Add buttons.
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles'."
969 :group 'gnus-article-treat
970 :link '(custom-manual "(gnus)Customizing Articles")
971 :type gnus-article-treat-custom)
972 (put 'gnus-treat-buttonize 'highlight t)
973
974 (defcustom gnus-treat-buttonize-head 'head
975 "Add buttons to the head.
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See Info node `(gnus)Customizing Articles' for details."
978 :group 'gnus-article-treat
979 :link '(custom-manual "(gnus)Customizing Articles")
980 :type gnus-article-treat-head-custom)
981 (put 'gnus-treat-buttonize-head 'highlight t)
982
983 (defcustom gnus-treat-emphasize
984 (and (or window-system
985 (featurep 'xemacs)
986 (>= (string-to-number emacs-version) 21))
987 50000)
988 "Emphasize text.
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
994 (put 'gnus-treat-emphasize 'highlight t)
995
996 (defcustom gnus-treat-strip-cr nil
997 "Remove carriage returns.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :version "22.1"
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004
1005 (defcustom gnus-treat-unsplit-urls nil
1006 "Remove newlines from within URLs.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :version "22.1"
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-custom)
1013
1014 (defcustom gnus-treat-leading-whitespace nil
1015 "Remove leading whitespace in headers.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :version "22.1"
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-custom)
1022
1023 (defcustom gnus-treat-hide-headers 'head
1024 "Hide headers.
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :link '(custom-manual "(gnus)Customizing Articles")
1029 :type gnus-article-treat-head-custom)
1030
1031 (defcustom gnus-treat-hide-boring-headers nil
1032 "Hide boring headers.
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-head-custom)
1038
1039 (defcustom gnus-treat-hide-signature nil
1040 "Hide the signature.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :link '(custom-manual "(gnus)Customizing Articles")
1045 :type gnus-article-treat-custom)
1046
1047 (defcustom gnus-treat-fill-article nil
1048 "Fill the article.
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-custom)
1054
1055 (defcustom gnus-treat-hide-citation nil
1056 "Hide cited text.
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-custom)
1062
1063 (defcustom gnus-treat-hide-citation-maybe nil
1064 "Hide cited text.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-custom)
1070
1071 (defcustom gnus-treat-strip-list-identifiers 'head
1072 "Strip list identifiers from `gnus-list-identifiers`.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :version "21.1"
1076 :group 'gnus-article-treat
1077 :link '(custom-manual "(gnus)Customizing Articles")
1078 :type gnus-article-treat-custom)
1079
1080 (make-obsolete-variable 'gnus-treat-strip-pgp
1081 "This option is obsolete in Gnus 5.10.")
1082
1083 (defcustom gnus-treat-strip-pem nil
1084 "Strip PEM signatures.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1090
1091 (defcustom gnus-treat-strip-banner t
1092 "Strip banners from articles.
1093 The banner to be stripped is specified in the `banner' group parameter.
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group 'gnus-article-treat
1097 :link '(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-custom)
1099
1100 (defcustom gnus-treat-highlight-headers 'head
1101 "Highlight the headers.
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-head-custom)
1107 (put 'gnus-treat-highlight-headers 'highlight t)
1108
1109 (defcustom gnus-treat-highlight-citation t
1110 "Highlight cited text.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1116 (put 'gnus-treat-highlight-citation 'highlight t)
1117
1118 (defcustom gnus-treat-date-ut nil
1119 "Display the Date in UT (GMT).
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' for details."
1122 :group 'gnus-article-treat
1123 :link '(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-head-custom)
1125
1126 (defcustom gnus-treat-date-local nil
1127 "Display the Date in the local timezone.
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-head-custom)
1133
1134 (defcustom gnus-treat-date-english nil
1135 "Display the Date in a format that can be read aloud in English.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' for details."
1138 :version "22.1"
1139 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-head-custom)
1142
1143 (defcustom gnus-treat-date-lapsed nil
1144 "Display the Date header in a way that says how much time has elapsed.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1147 :group 'gnus-article-treat
1148 :link '(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-head-custom)
1150
1151 (defcustom gnus-treat-date-original nil
1152 "Display the date in the original timezone.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-head-custom)
1158
1159 (defcustom gnus-treat-date-iso8601 nil
1160 "Display the date in the ISO8601 format.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :version "21.1"
1164 :group 'gnus-article-treat
1165 :link '(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-head-custom)
1167
1168 (defcustom gnus-treat-date-user-defined nil
1169 "Display the date in a user-defined format.
1170 The format is defined by the `gnus-article-time-format' variable.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' for details."
1173 :group 'gnus-article-treat
1174 :link '(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-head-custom)
1176
1177 (defcustom gnus-treat-strip-headers-in-body t
1178 "Strip the X-No-Archive header line from the beginning of the body.
1179 Valid values are nil, t, `head', `last', an integer or a predicate.
1180 See Info node `(gnus)Customizing Articles' for details."
1181 :version "21.1"
1182 :group 'gnus-article-treat
1183 :link '(custom-manual "(gnus)Customizing Articles")
1184 :type gnus-article-treat-custom)
1185
1186 (defcustom gnus-treat-strip-trailing-blank-lines nil
1187 "Strip trailing blank lines.
1188 Valid values are nil, t, `head', `last', an integer or a predicate.
1189 See Info node `(gnus)Customizing Articles' for details.
1190
1191 When set to t, it also strips trailing blanks in all MIME parts.
1192 Consider to use `last' instead."
1193 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :type gnus-article-treat-custom)
1196
1197 (defcustom gnus-treat-strip-leading-blank-lines nil
1198 "Strip leading blank lines.
1199 Valid values are nil, t, `head', `last', an integer or a predicate.
1200 See Info node `(gnus)Customizing Articles' for details.
1201
1202 When set to t, it also strips trailing blanks in all MIME parts."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1206
1207 (defcustom gnus-treat-strip-multiple-blank-lines nil
1208 "Strip multiple blank lines.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1214
1215 (defcustom gnus-treat-unfold-headers 'head
1216 "Unfold folded header lines.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 See Info node `(gnus)Customizing Articles' for details."
1219 :version "22.1"
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1223
1224 (defcustom gnus-treat-fold-headers nil
1225 "Fold headers.
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' for details."
1228 :version "22.1"
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1232
1233 (defcustom gnus-treat-fold-newsgroups 'head
1234 "Fold the Newsgroups and Followup-To headers.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1237 :version "22.1"
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1241
1242 (defcustom gnus-treat-overstrike t
1243 "Treat overstrike highlighting.
1244 Valid values are nil, t, `head', `last', an integer or a predicate.
1245 See Info node `(gnus)Customizing Articles' for details."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-custom)
1249 (put 'gnus-treat-overstrike 'highlight t)
1250
1251 (make-obsolete-variable 'gnus-treat-display-xface
1252 'gnus-treat-display-x-face)
1253
1254 (defcustom gnus-treat-display-x-face
1255 (and (not noninteractive)
1256 (or (and (fboundp 'image-type-available-p)
1257 (image-type-available-p 'xbm)
1258 (string-match "^0x" (shell-command-to-string "uncompface"))
1259 (executable-find "icontopbm"))
1260 (and (featurep 'xemacs)
1261 (featurep 'xface)))
1262 'head)
1263 "Display X-Face headers.
1264 Valid values are nil, t, `head', `last', an integer or a predicate.
1265 See Info node `(gnus)Customizing Articles' and Info node
1266 `(gnus)X-Face' for details."
1267 :group 'gnus-article-treat
1268 :version "21.1"
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :link '(custom-manual "(gnus)X-Face")
1271 :type gnus-article-treat-head-custom
1272 :set (lambda (symbol value)
1273 (set-default
1274 symbol
1275 (cond ((or (boundp symbol) (get symbol 'saved-value))
1276 value)
1277 ((boundp 'gnus-treat-display-xface)
1278 (message "\
1279 ** gnus-treat-display-xface is an obsolete variable;\
1280 use gnus-treat-display-x-face instead")
1281 (default-value 'gnus-treat-display-xface))
1282 ((get 'gnus-treat-display-xface 'saved-value)
1283 (message "\
1284 ** gnus-treat-display-xface is an obsolete variable;\
1285 use gnus-treat-display-x-face instead")
1286 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1287 (t
1288 value)))))
1289 (put 'gnus-treat-display-x-face 'highlight t)
1290
1291 (defcustom gnus-treat-display-face
1292 (and (not noninteractive)
1293 (or (and (fboundp 'image-type-available-p)
1294 (image-type-available-p 'png))
1295 (and (featurep 'xemacs)
1296 (featurep 'png)))
1297 'head)
1298 "Display Face headers.
1299 Valid values are nil, t, `head', `last', an integer or a predicate.
1300 See Info node `(gnus)Customizing Articles' and Info node
1301 `(gnus)X-Face' for details."
1302 :group 'gnus-article-treat
1303 :version "22.1"
1304 :link '(custom-manual "(gnus)Customizing Articles")
1305 :link '(custom-manual "(gnus)X-Face")
1306 :type gnus-article-treat-head-custom)
1307 (put 'gnus-treat-display-face 'highlight t)
1308
1309 (defcustom gnus-treat-display-smileys
1310 (if (or (and (featurep 'xemacs)
1311 (featurep 'xpm))
1312 (and (fboundp 'image-type-available-p)
1313 (image-type-available-p 'pbm)))
1314 t nil)
1315 "Display smileys.
1316 Valid values are nil, t, `head', `last', an integer or a predicate.
1317 See Info node `(gnus)Customizing Articles' and Info node
1318 `(gnus)Smileys' for details."
1319 :group 'gnus-article-treat
1320 :version "21.1"
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :link '(custom-manual "(gnus)Smileys")
1323 :type gnus-article-treat-custom)
1324 (put 'gnus-treat-display-smileys 'highlight t)
1325
1326 (defcustom gnus-treat-from-picon
1327 (if (and (gnus-image-type-available-p 'xpm)
1328 (gnus-picons-installed-p))
1329 'head nil)
1330 "Display picons in the From header.
1331 Valid values are nil, t, `head', `last', an integer or a predicate.
1332 See Info node `(gnus)Customizing Articles' and Info node
1333 `(gnus)Picons' for details."
1334 :version "22.1"
1335 :group 'gnus-article-treat
1336 :group 'gnus-picon
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :link '(custom-manual "(gnus)Picons")
1339 :type gnus-article-treat-head-custom)
1340 (put 'gnus-treat-from-picon 'highlight t)
1341
1342 (defcustom gnus-treat-mail-picon
1343 (if (and (gnus-image-type-available-p 'xpm)
1344 (gnus-picons-installed-p))
1345 'head nil)
1346 "Display picons in To and Cc headers.
1347 Valid values are nil, t, `head', `last', an integer or a predicate.
1348 See Info node `(gnus)Customizing Articles' and Info node
1349 `(gnus)Picons' for details."
1350 :version "22.1"
1351 :group 'gnus-article-treat
1352 :group 'gnus-picon
1353 :link '(custom-manual "(gnus)Customizing Articles")
1354 :link '(custom-manual "(gnus)Picons")
1355 :type gnus-article-treat-head-custom)
1356 (put 'gnus-treat-mail-picon 'highlight t)
1357
1358 (defcustom gnus-treat-newsgroups-picon
1359 (if (and (gnus-image-type-available-p 'xpm)
1360 (gnus-picons-installed-p))
1361 'head nil)
1362 "Display picons in the Newsgroups and Followup-To headers.
1363 Valid values are nil, t, `head', `last', an integer or a predicate.
1364 See Info node `(gnus)Customizing Articles' and Info node
1365 `(gnus)Picons' for details."
1366 :version "22.1"
1367 :group 'gnus-article-treat
1368 :group 'gnus-picon
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :link '(custom-manual "(gnus)Picons")
1371 :type gnus-article-treat-head-custom)
1372 (put 'gnus-treat-newsgroups-picon 'highlight t)
1373
1374 (defcustom gnus-treat-body-boundary
1375 (if (or gnus-treat-newsgroups-picon
1376 gnus-treat-mail-picon
1377 gnus-treat-from-picon)
1378 'head nil)
1379 "Draw a boundary at the end of the headers.
1380 Valid values are nil and `head'.
1381 See Info node `(gnus)Customizing Articles' for details."
1382 :version "22.1"
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-head-custom)
1386
1387 (defcustom gnus-treat-capitalize-sentences nil
1388 "Capitalize sentence-starting words.
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' for details."
1391 :version "21.1"
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1395
1396 (defcustom gnus-treat-wash-html nil
1397 "Format as HTML.
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1400 :version "22.1"
1401 :group 'gnus-article-treat
1402 :link '(custom-manual "(gnus)Customizing Articles")
1403 :type gnus-article-treat-custom)
1404
1405 (defcustom gnus-treat-fill-long-lines nil
1406 "Fill long lines.
1407 Valid values are nil, t, `head', `last', an integer or a predicate.
1408 See Info node `(gnus)Customizing Articles' for details."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1412
1413 (defcustom gnus-treat-play-sounds nil
1414 "Play sounds.
1415 Valid values are nil, t, `head', `last', an integer or a predicate.
1416 See Info node `(gnus)Customizing Articles' for details."
1417 :version "21.1"
1418 :group 'gnus-article-treat
1419 :link '(custom-manual "(gnus)Customizing Articles")
1420 :type gnus-article-treat-custom)
1421
1422 (defcustom gnus-treat-translate nil
1423 "Translate articles from one language to another.
1424 Valid values are nil, t, `head', `last', an integer or a predicate.
1425 See Info node `(gnus)Customizing Articles' for details."
1426 :version "21.1"
1427 :group 'gnus-article-treat
1428 :link '(custom-manual "(gnus)Customizing Articles")
1429 :type gnus-article-treat-custom)
1430
1431 (defcustom gnus-treat-x-pgp-sig nil
1432 "Verify X-PGP-Sig.
1433 To automatically treat X-PGP-Sig, set it to head.
1434 Valid values are nil, t, `head', `last', an integer or a predicate.
1435 See Info node `(gnus)Customizing Articles' for details."
1436 :version "22.1"
1437 :group 'gnus-article-treat
1438 :group 'mime-security
1439 :link '(custom-manual "(gnus)Customizing Articles")
1440 :type gnus-article-treat-custom)
1441
1442 (defvar gnus-article-encrypt-protocol-alist
1443 '(("PGP" . mml2015-self-encrypt)))
1444
1445 ;; Set to nil if more than one protocol added to
1446 ;; gnus-article-encrypt-protocol-alist.
1447 (defcustom gnus-article-encrypt-protocol "PGP"
1448 "The protocol used for encrypt articles.
1449 It is a string, such as \"PGP\". If nil, ask user."
1450 :version "22.1"
1451 :type 'string
1452 :group 'mime-security)
1453
1454 (defvar gnus-article-wash-function nil
1455 "Function used for converting HTML into text.")
1456
1457 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1458 (mm-coding-system-p 'utf-8)
1459 (executable-find idna-program))
1460 "Whether IDNA decoding of headers is used when viewing messages.
1461 This requires GNU Libidn, and by default only enabled if it is found."
1462 :version "22.1"
1463 :group 'gnus-article-headers
1464 :type 'boolean)
1465
1466 (defcustom gnus-article-over-scroll nil
1467 "If non-nil, allow scrolling the article buffer even when there no more text."
1468 :version "22.1"
1469 :group 'gnus-article
1470 :type 'boolean)
1471
1472 ;;; Internal variables
1473
1474 (defvar gnus-english-month-names
1475 '("January" "February" "March" "April" "May" "June" "July" "August"
1476 "September" "October" "November" "December"))
1477
1478 (defvar article-goto-body-goes-to-point-min-p nil)
1479 (defvar gnus-article-wash-types nil)
1480 (defvar gnus-article-emphasis-alist nil)
1481 (defvar gnus-article-image-alist nil)
1482
1483 (defvar gnus-article-mime-handle-alist-1 nil)
1484 (defvar gnus-treatment-function-alist
1485 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1486 (gnus-treat-strip-banner gnus-article-strip-banner)
1487 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1488 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1489 (gnus-treat-buttonize gnus-article-add-buttons)
1490 (gnus-treat-fill-article gnus-article-fill-cited-article)
1491 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1492 (gnus-treat-strip-cr gnus-article-remove-cr)
1493 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1494 (gnus-treat-date-ut gnus-article-date-ut)
1495 (gnus-treat-date-local gnus-article-date-local)
1496 (gnus-treat-date-english gnus-article-date-english)
1497 (gnus-treat-date-original gnus-article-date-original)
1498 (gnus-treat-date-user-defined gnus-article-date-user)
1499 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1500 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1501 (gnus-treat-display-x-face gnus-article-display-x-face)
1502 (gnus-treat-display-face gnus-article-display-face)
1503 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1504 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1505 (gnus-treat-hide-signature gnus-article-hide-signature)
1506 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1507 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1508 (gnus-treat-strip-pem gnus-article-hide-pem)
1509 (gnus-treat-from-picon gnus-treat-from-picon)
1510 (gnus-treat-mail-picon gnus-treat-mail-picon)
1511 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1512 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1513 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1514 (gnus-treat-strip-trailing-blank-lines
1515 gnus-article-remove-trailing-blank-lines)
1516 (gnus-treat-strip-leading-blank-lines
1517 gnus-article-strip-leading-blank-lines)
1518 (gnus-treat-strip-multiple-blank-lines
1519 gnus-article-strip-multiple-blank-lines)
1520 (gnus-treat-overstrike gnus-article-treat-overstrike)
1521 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1522 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1523 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1524 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1525 (gnus-treat-display-smileys gnus-treat-smiley)
1526 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1527 (gnus-treat-wash-html gnus-article-wash-html)
1528 (gnus-treat-emphasize gnus-article-emphasize)
1529 (gnus-treat-hide-citation gnus-article-hide-citation)
1530 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1531 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1532 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1533 (gnus-treat-play-sounds gnus-earcon-display)))
1534
1535 (defvar gnus-article-mime-handle-alist nil)
1536 (defvar article-lapsed-timer nil)
1537 (defvar gnus-article-current-summary nil)
1538
1539 (defvar gnus-article-mode-syntax-table
1540 (let ((table (copy-syntax-table text-mode-syntax-table)))
1541 ;; This causes the citation match run O(2^n).
1542 ;; (modify-syntax-entry ?- "w" table)
1543 (modify-syntax-entry ?> ")<" table)
1544 (modify-syntax-entry ?< "(>" table)
1545 ;; make M-. in article buffers work for `foo' strings
1546 (modify-syntax-entry ?' " " table)
1547 (modify-syntax-entry ?` " " table)
1548 table)
1549 "Syntax table used in article mode buffers.
1550 Initialized from `text-mode-syntax-table.")
1551
1552 (defvar gnus-save-article-buffer nil)
1553
1554 (defvar gnus-article-mode-line-format-alist
1555 (nconc '((?w (gnus-article-wash-status) ?s)
1556 (?m (gnus-article-mime-part-status) ?s))
1557 gnus-summary-mode-line-format-alist))
1558
1559 (defvar gnus-number-of-articles-to-be-saved nil)
1560
1561 (defvar gnus-inhibit-hiding nil)
1562
1563 (defvar gnus-article-edit-mode nil)
1564
1565 ;;; Macros for dealing with the article buffer.
1566
1567 (defmacro gnus-with-article-headers (&rest forms)
1568 `(save-excursion
1569 (set-buffer gnus-article-buffer)
1570 (save-restriction
1571 (let ((inhibit-read-only t)
1572 (inhibit-point-motion-hooks t)
1573 (case-fold-search t))
1574 (article-narrow-to-head)
1575 ,@forms))))
1576
1577 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1578 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1579
1580 (defmacro gnus-with-article-buffer (&rest forms)
1581 `(save-excursion
1582 (set-buffer gnus-article-buffer)
1583 (let ((inhibit-read-only t))
1584 ,@forms)))
1585
1586 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1587 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1588
1589 (defun gnus-article-goto-header (header)
1590 "Go to HEADER, which is a regular expression."
1591 (re-search-forward (concat "^\\(" header "\\):") nil t))
1592
1593 (defsubst gnus-article-hide-text (b e props)
1594 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1595 (gnus-add-text-properties-when 'article-type nil b e props)
1596 (when (memq 'intangible props)
1597 (put-text-property
1598 (max (1- b) (point-min))
1599 b 'intangible (cddr (memq 'intangible props)))))
1600
1601 (defsubst gnus-article-unhide-text (b e)
1602 "Remove hidden text properties from region between B and E."
1603 (remove-text-properties b e gnus-hidden-properties)
1604 (when (memq 'intangible gnus-hidden-properties)
1605 (put-text-property (max (1- b) (point-min))
1606 b 'intangible nil)))
1607
1608 (defun gnus-article-hide-text-type (b e type)
1609 "Hide text of TYPE between B and E."
1610 (gnus-add-wash-type type)
1611 (gnus-article-hide-text
1612 b e (cons 'article-type (cons type gnus-hidden-properties))))
1613
1614 (defun gnus-article-unhide-text-type (b e type)
1615 "Unhide text of TYPE between B and E."
1616 (gnus-delete-wash-type type)
1617 (remove-text-properties
1618 b e (cons 'article-type (cons type gnus-hidden-properties)))
1619 (when (memq 'intangible gnus-hidden-properties)
1620 (put-text-property (max (1- b) (point-min))
1621 b 'intangible nil)))
1622
1623 (defun gnus-article-hide-text-of-type (type)
1624 "Hide text of TYPE in the current buffer."
1625 (save-excursion
1626 (let ((b (point-min))
1627 (e (point-max)))
1628 (while (setq b (text-property-any b e 'article-type type))
1629 (add-text-properties b (incf b) gnus-hidden-properties)))))
1630
1631 (defun gnus-article-delete-text-of-type (type)
1632 "Delete text of TYPE in the current buffer."
1633 (save-excursion
1634 (let ((b (point-min)))
1635 (while (setq b (text-property-any b (point-max) 'article-type type))
1636 (delete-region
1637 b (or (text-property-not-all b (point-max) 'article-type type)
1638 (point-max)))))))
1639
1640 (defun gnus-article-delete-invisible-text ()
1641 "Delete all invisible text in the current buffer."
1642 (save-excursion
1643 (let ((b (point-min)))
1644 (while (setq b (text-property-any b (point-max) 'invisible t))
1645 (delete-region
1646 b (or (text-property-not-all b (point-max) 'invisible t)
1647 (point-max)))))))
1648
1649 (defun gnus-article-text-type-exists-p (type)
1650 "Say whether any text of type TYPE exists in the buffer."
1651 (text-property-any (point-min) (point-max) 'article-type type))
1652
1653 (defsubst gnus-article-header-rank ()
1654 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1655 (let ((list gnus-sorted-header-list)
1656 (i 1))
1657 (while list
1658 (if (looking-at (car list))
1659 (setq list nil)
1660 (setq list (cdr list))
1661 (incf i)))
1662 i))
1663
1664 (defun article-hide-headers (&optional arg delete)
1665 "Hide unwanted headers and possibly sort them as well."
1666 (interactive)
1667 ;; This function might be inhibited.
1668 (unless gnus-inhibit-hiding
1669 (let ((inhibit-read-only nil)
1670 (case-fold-search t)
1671 (max (1+ (length gnus-sorted-header-list)))
1672 (inhibit-point-motion-hooks t)
1673 (cur (current-buffer))
1674 ignored visible beg)
1675 (save-excursion
1676 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1677 ;; group parameters, so we should go to the summary buffer.
1678 (when (prog1
1679 (condition-case nil
1680 (progn (set-buffer gnus-summary-buffer) t)
1681 (error nil))
1682 (setq ignored (when (not gnus-visible-headers)
1683 (cond ((stringp gnus-ignored-headers)
1684 gnus-ignored-headers)
1685 ((listp gnus-ignored-headers)
1686 (mapconcat 'identity
1687 gnus-ignored-headers
1688 "\\|"))))
1689 visible (cond ((stringp gnus-visible-headers)
1690 gnus-visible-headers)
1691 ((and gnus-visible-headers
1692 (listp gnus-visible-headers))
1693 (mapconcat 'identity
1694 gnus-visible-headers
1695 "\\|")))))
1696 (set-buffer cur))
1697 (save-restriction
1698 ;; First we narrow to just the headers.
1699 (article-narrow-to-head)
1700 ;; Hide any "From " lines at the beginning of (mail) articles.
1701 (while (looking-at "From ")
1702 (forward-line 1))
1703 (unless (bobp)
1704 (delete-region (point-min) (point)))
1705 ;; Then treat the rest of the header lines.
1706 ;; Then we use the two regular expressions
1707 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1708 ;; select which header lines is to remain visible in the
1709 ;; article buffer.
1710 (while (re-search-forward "^[^ \t:]*:" nil t)
1711 (beginning-of-line)
1712 ;; Mark the rank of the header.
1713 (put-text-property
1714 (point) (1+ (point)) 'message-rank
1715 (if (or (and visible (looking-at visible))
1716 (and ignored
1717 (not (looking-at ignored))))
1718 (gnus-article-header-rank)
1719 (+ 2 max)))
1720 (forward-line 1))
1721 (message-sort-headers-1)
1722 (when (setq beg (text-property-any
1723 (point-min) (point-max) 'message-rank (+ 2 max)))
1724 ;; We delete the unwanted headers.
1725 (gnus-add-wash-type 'headers)
1726 (add-text-properties (point-min) (+ 5 (point-min))
1727 '(article-type headers dummy-invisible t))
1728 (delete-region beg (point-max))))))))
1729
1730 (defun article-hide-boring-headers (&optional arg)
1731 "Toggle hiding of headers that aren't very interesting.
1732 If given a negative prefix, always show; if given a positive prefix,
1733 always hide."
1734 (interactive (gnus-article-hidden-arg))
1735 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1736 (not gnus-show-all-headers))
1737 (save-excursion
1738 (save-restriction
1739 (let ((inhibit-read-only t)
1740 (list gnus-boring-article-headers)
1741 (inhibit-point-motion-hooks t)
1742 elem)
1743 (article-narrow-to-head)
1744 (while list
1745 (setq elem (pop list))
1746 (goto-char (point-min))
1747 (cond
1748 ;; Hide empty headers.
1749 ((eq elem 'empty)
1750 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1751 (forward-line -1)
1752 (gnus-article-hide-text-type
1753 (gnus-point-at-bol)
1754 (progn
1755 (end-of-line)
1756 (if (re-search-forward "^[^ \t]" nil t)
1757 (match-beginning 0)
1758 (point-max)))
1759 'boring-headers)))
1760 ;; Hide boring Newsgroups header.
1761 ((eq elem 'newsgroups)
1762 (when (gnus-string-equal
1763 (gnus-fetch-field "newsgroups")
1764 (gnus-group-real-name
1765 (if (boundp 'gnus-newsgroup-name)
1766 gnus-newsgroup-name
1767 "")))
1768 (gnus-article-hide-header "newsgroups")))
1769 ((eq elem 'to-address)
1770 (let ((to (message-fetch-field "to"))
1771 (to-address
1772 (gnus-parameter-to-address
1773 (if (boundp 'gnus-newsgroup-name)
1774 gnus-newsgroup-name ""))))
1775 (when (and to to-address
1776 (ignore-errors
1777 (gnus-string-equal
1778 ;; only one address in To
1779 (nth 1 (mail-extract-address-components to))
1780 to-address)))
1781 (gnus-article-hide-header "to"))))
1782 ((eq elem 'to-list)
1783 (let ((to (message-fetch-field "to"))
1784 (to-list
1785 (gnus-parameter-to-list
1786 (if (boundp 'gnus-newsgroup-name)
1787 gnus-newsgroup-name ""))))
1788 (when (and to to-list
1789 (ignore-errors
1790 (gnus-string-equal
1791 ;; only one address in To
1792 (nth 1 (mail-extract-address-components to))
1793 to-list)))
1794 (gnus-article-hide-header "to"))))
1795 ((eq elem 'cc-list)
1796 (let ((cc (message-fetch-field "cc"))
1797 (to-list
1798 (gnus-parameter-to-list
1799 (if (boundp 'gnus-newsgroup-name)
1800 gnus-newsgroup-name ""))))
1801 (when (and cc to-list
1802 (ignore-errors
1803 (gnus-string-equal
1804 ;; only one address in CC
1805 (nth 1 (mail-extract-address-components cc))
1806 to-list)))
1807 (gnus-article-hide-header "cc"))))
1808 ((eq elem 'followup-to)
1809 (when (gnus-string-equal
1810 (message-fetch-field "followup-to")
1811 (message-fetch-field "newsgroups"))
1812 (gnus-article-hide-header "followup-to")))
1813 ((eq elem 'reply-to)
1814 (if (gnus-group-find-parameter
1815 gnus-newsgroup-name 'broken-reply-to)
1816 (gnus-article-hide-header "reply-to")
1817 (let ((from (message-fetch-field "from"))
1818 (reply-to (message-fetch-field "reply-to")))
1819 (when
1820 (and
1821 from reply-to
1822 (ignore-errors
1823 (equal
1824 (sort (mapcar
1825 (lambda (x) (downcase (cadr x)))
1826 (mail-extract-address-components from t))
1827 'string<)
1828 (sort (mapcar
1829 (lambda (x) (downcase (cadr x)))
1830 (mail-extract-address-components reply-to t))
1831 'string<))))
1832 (gnus-article-hide-header "reply-to")))))
1833 ((eq elem 'date)
1834 (let ((date (message-fetch-field "date")))
1835 (when (and date
1836 (< (days-between (current-time-string) date)
1837 4))
1838 (gnus-article-hide-header "date"))))
1839 ((eq elem 'long-to)
1840 (let ((to (message-fetch-field "to"))
1841 (cc (message-fetch-field "cc")))
1842 (when (> (length to) 1024)
1843 (gnus-article-hide-header "to"))
1844 (when (> (length cc) 1024)
1845 (gnus-article-hide-header "cc"))))
1846 ((eq elem 'many-to)
1847 (let ((to-count 0)
1848 (cc-count 0))
1849 (goto-char (point-min))
1850 (while (re-search-forward "^to:" nil t)
1851 (setq to-count (1+ to-count)))
1852 (when (> to-count 1)
1853 (while (> to-count 0)
1854 (goto-char (point-min))
1855 (save-restriction
1856 (re-search-forward "^to:" nil nil to-count)
1857 (forward-line -1)
1858 (narrow-to-region (point) (point-max))
1859 (gnus-article-hide-header "to"))
1860 (setq to-count (1- to-count))))
1861 (goto-char (point-min))
1862 (while (re-search-forward "^cc:" nil t)
1863 (setq cc-count (1+ cc-count)))
1864 (when (> cc-count 1)
1865 (while (> cc-count 0)
1866 (goto-char (point-min))
1867 (save-restriction
1868 (re-search-forward "^cc:" nil nil cc-count)
1869 (forward-line -1)
1870 (narrow-to-region (point) (point-max))
1871 (gnus-article-hide-header "cc"))
1872 (setq cc-count (1- cc-count)))))))))))))
1873
1874 (defun gnus-article-hide-header (header)
1875 (save-excursion
1876 (goto-char (point-min))
1877 (when (re-search-forward (concat "^" header ":") nil t)
1878 (gnus-article-hide-text-type
1879 (gnus-point-at-bol)
1880 (progn
1881 (end-of-line)
1882 (if (re-search-forward "^[^ \t]" nil t)
1883 (match-beginning 0)
1884 (point-max)))
1885 'boring-headers))))
1886
1887 (defvar gnus-article-normalized-header-length 40
1888 "Length of normalized headers.")
1889
1890 (defun article-normalize-headers ()
1891 "Make all header lines 40 characters long."
1892 (interactive)
1893 (let ((inhibit-read-only t)
1894 column)
1895 (save-excursion
1896 (save-restriction
1897 (article-narrow-to-head)
1898 (while (not (eobp))
1899 (cond
1900 ((< (setq column (- (gnus-point-at-eol) (point)))
1901 gnus-article-normalized-header-length)
1902 (end-of-line)
1903 (insert (make-string
1904 (- gnus-article-normalized-header-length column)
1905 ? )))
1906 ((> column gnus-article-normalized-header-length)
1907 (gnus-put-text-property
1908 (progn
1909 (forward-char gnus-article-normalized-header-length)
1910 (point))
1911 (gnus-point-at-eol)
1912 'invisible t))
1913 (t
1914 ;; Do nothing.
1915 ))
1916 (forward-line 1))))))
1917
1918 (defun article-treat-dumbquotes ()
1919 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1920 Note that this function guesses whether a character is a sm*rtq**t* or
1921 not, so it should only be used interactively.
1922
1923 Sm*rtq**t*s are M****s***'s unilateral extension to the
1924 iso-8859-1 character map in an attempt to provide more quoting
1925 characters. If you see something like \\222 or \\264 where
1926 you're expecting some kind of apostrophe or quotation mark, then
1927 try this wash."
1928 (interactive)
1929 (article-translate-strings gnus-article-dumbquotes-map))
1930
1931 (defun article-translate-characters (from to)
1932 "Translate all characters in the body of the article according to FROM and TO.
1933 FROM is a string of characters to translate from; to is a string of
1934 characters to translate to."
1935 (save-excursion
1936 (when (article-goto-body)
1937 (let ((inhibit-read-only t)
1938 (x (make-string 225 ?x))
1939 (i -1))
1940 (while (< (incf i) (length x))
1941 (aset x i i))
1942 (setq i 0)
1943 (while (< i (length from))
1944 (aset x (aref from i) (aref to i))
1945 (incf i))
1946 (translate-region (point) (point-max) x)))))
1947
1948 (defun article-translate-strings (map)
1949 "Translate all string in the body of the article according to MAP.
1950 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1951 (save-excursion
1952 (when (article-goto-body)
1953 (let ((inhibit-read-only t)
1954 elem)
1955 (while (setq elem (pop map))
1956 (save-excursion
1957 (while (search-forward (car elem) nil t)
1958 (replace-match (cadr elem)))))))))
1959
1960 (defun article-treat-overstrike ()
1961 "Translate overstrikes into bold text."
1962 (interactive)
1963 (save-excursion
1964 (when (article-goto-body)
1965 (let ((inhibit-read-only t))
1966 (while (search-forward "\b" nil t)
1967 (let ((next (char-after))
1968 (previous (char-after (- (point) 2))))
1969 ;; We do the boldification/underlining by hiding the
1970 ;; overstrikes and putting the proper text property
1971 ;; on the letters.
1972 (cond
1973 ((eq next previous)
1974 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1975 (put-text-property (point) (1+ (point)) 'face 'bold))
1976 ((eq next ?_)
1977 (gnus-article-hide-text-type
1978 (1- (point)) (1+ (point)) 'overstrike)
1979 (put-text-property
1980 (- (point) 2) (1- (point)) 'face 'underline))
1981 ((eq previous ?_)
1982 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1983 (put-text-property
1984 (point) (1+ (point)) 'face 'underline)))))))))
1985
1986 (defun gnus-article-treat-unfold-headers ()
1987 "Unfold folded message headers.
1988 Only the headers that fit into the current window width will be
1989 unfolded."
1990 (interactive)
1991 (gnus-with-article-headers
1992 (let (length)
1993 (while (not (eobp))
1994 (save-restriction
1995 (mail-header-narrow-to-field)
1996 (let ((header (buffer-string)))
1997 (with-temp-buffer
1998 (insert header)
1999 (goto-char (point-min))
2000 (while (re-search-forward "\n[\t ]" nil t)
2001 (replace-match " " t t)))
2002 (setq length (- (point-max) (point-min) 1)))
2003 (when (< length (window-width))
2004 (while (re-search-forward "\n[\t ]" nil t)
2005 (replace-match " " t t)))
2006 (goto-char (point-max)))))))
2007
2008 (defun gnus-article-treat-fold-headers ()
2009 "Fold message headers."
2010 (interactive)
2011 (gnus-with-article-headers
2012 (while (not (eobp))
2013 (save-restriction
2014 (mail-header-narrow-to-field)
2015 (mail-header-fold-field)
2016 (goto-char (point-max))))))
2017
2018 (defun gnus-treat-smiley ()
2019 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2020 (interactive)
2021 (gnus-with-article-buffer
2022 (if (memq 'smiley gnus-article-wash-types)
2023 (gnus-delete-images 'smiley)
2024 (article-goto-body)
2025 (let ((images (smiley-region (point) (point-max))))
2026 (when images
2027 (gnus-add-wash-type 'smiley)
2028 (dolist (image images)
2029 (gnus-add-image 'smiley image)))))))
2030
2031 (defun gnus-article-remove-images ()
2032 "Remove all images from the article buffer."
2033 (interactive)
2034 (gnus-with-article-buffer
2035 (dolist (elem gnus-article-image-alist)
2036 (gnus-delete-images (car elem)))))
2037
2038 (defun gnus-article-treat-fold-newsgroups ()
2039 "Unfold folded message headers.
2040 Only the headers that fit into the current window width will be
2041 unfolded."
2042 (interactive)
2043 (gnus-with-article-headers
2044 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2045 (save-restriction
2046 (mail-header-narrow-to-field)
2047 (while (re-search-forward ", *" nil t)
2048 (replace-match ", " t t))
2049 (mail-header-fold-field)
2050 (goto-char (point-max))))))
2051
2052 (defun gnus-article-treat-body-boundary ()
2053 "Place a boundary line at the end of the headers."
2054 (interactive)
2055 (when (and gnus-body-boundary-delimiter
2056 (> (length gnus-body-boundary-delimiter) 0))
2057 (gnus-with-article-headers
2058 (goto-char (point-max))
2059 (let ((start (point)))
2060 (insert "X-Boundary: ")
2061 (gnus-add-text-properties start (point) '(invisible t intangible t))
2062 (insert (let (str)
2063 (while (>= (1- (window-width)) (length str))
2064 (setq str (concat str gnus-body-boundary-delimiter)))
2065 (substring str 0 (1- (window-width))))
2066 "\n")
2067 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2068
2069 (defun article-fill-long-lines ()
2070 "Fill lines that are wider than the window width."
2071 (interactive)
2072 (save-excursion
2073 (let ((inhibit-read-only t)
2074 (width (window-width (get-buffer-window (current-buffer)))))
2075 (save-restriction
2076 (article-goto-body)
2077 (let ((adaptive-fill-mode nil)) ;Why? -sm
2078 (while (not (eobp))
2079 (end-of-line)
2080 (when (>= (current-column) (min fill-column width))
2081 (narrow-to-region (min (1+ (point)) (point-max))
2082 (gnus-point-at-bol))
2083 (let ((goback (point-marker)))
2084 (fill-paragraph nil)
2085 (goto-char (marker-position goback)))
2086 (widen))
2087 (forward-line 1)))))))
2088
2089 (defun article-capitalize-sentences ()
2090 "Capitalize the first word in each sentence."
2091 (interactive)
2092 (save-excursion
2093 (let ((inhibit-read-only t)
2094 (paragraph-start "^[\n\^L]"))
2095 (article-goto-body)
2096 (while (not (eobp))
2097 (capitalize-word 1)
2098 (forward-sentence)))))
2099
2100 (defun article-remove-cr ()
2101 "Remove trailing CRs and then translate remaining CRs into LFs."
2102 (interactive)
2103 (save-excursion
2104 (let ((inhibit-read-only t))
2105 (goto-char (point-min))
2106 (while (re-search-forward "\r+$" nil t)
2107 (replace-match "" t t))
2108 (goto-char (point-min))
2109 (while (search-forward "\r" nil t)
2110 (replace-match "\n" t t)))))
2111
2112 (defun article-remove-trailing-blank-lines ()
2113 "Remove all trailing blank lines from the article."
2114 (interactive)
2115 (save-excursion
2116 (let ((inhibit-read-only t))
2117 (goto-char (point-max))
2118 (delete-region
2119 (point)
2120 (progn
2121 (while (and (not (bobp))
2122 (looking-at "^[ \t]*$")
2123 (not (gnus-annotation-in-region-p
2124 (point) (gnus-point-at-eol))))
2125 (forward-line -1))
2126 (forward-line 1)
2127 (point))))))
2128
2129 (defun article-display-face ()
2130 "Display any Face headers in the header."
2131 (interactive)
2132 (let ((wash-face-p buffer-read-only))
2133 (gnus-with-article-headers
2134 ;; When displaying parts, this function can be called several times on
2135 ;; the same article, without any intended toggle semantic (as typing `W
2136 ;; D d' would have). So face deletion must occur only when we come from
2137 ;; an interactive command, that is when the *Article* buffer is
2138 ;; read-only.
2139 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2140 (gnus-delete-images 'face)
2141 (let (face faces from)
2142 (save-current-buffer
2143 (when (and wash-face-p
2144 (gnus-buffer-live-p gnus-original-article-buffer)
2145 (not (re-search-forward "^Face:[\t ]*" nil t)))
2146 (set-buffer gnus-original-article-buffer))
2147 (save-restriction
2148 (mail-narrow-to-head)
2149 (while (gnus-article-goto-header "Face")
2150 (push (mail-header-field-value) faces))))
2151 (when faces
2152 (goto-char (point-min))
2153 (let ((from (gnus-article-goto-header "from"))
2154 png image)
2155 (unless from
2156 (insert "From:")
2157 (setq from (point))
2158 (insert "[no `from' set]\n"))
2159 (while faces
2160 (when (setq png (gnus-convert-face-to-png (pop faces)))
2161 (setq image (gnus-create-image png 'png t))
2162 (goto-char from)
2163 (gnus-add-wash-type 'face)
2164 (gnus-add-image 'face image)
2165 (gnus-put-image image nil 'face))))))))))
2166
2167 (defun article-display-x-face (&optional force)
2168 "Look for an X-Face header and display it if present."
2169 (interactive (list 'force))
2170 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2171 (gnus-with-article-headers
2172 ;; Delete the old process, if any.
2173 (when (process-status "article-x-face")
2174 (delete-process "article-x-face"))
2175 ;; See the comment in `article-display-face'.
2176 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2177 ;; We have already displayed X-Faces, so we remove them
2178 ;; instead.
2179 (gnus-delete-images 'xface)
2180 ;; Display X-Faces.
2181 (let (x-faces from face)
2182 (save-current-buffer
2183 (when (and wash-face-p
2184 (gnus-buffer-live-p gnus-original-article-buffer)
2185 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2186 ;; If type `W f', use gnus-original-article-buffer,
2187 ;; otherwise use the current buffer because displaying
2188 ;; RFC822 parts calls this function too.
2189 (set-buffer gnus-original-article-buffer))
2190 (save-restriction
2191 (mail-narrow-to-head)
2192 (while (gnus-article-goto-header "X-Face")
2193 (push (mail-header-field-value) x-faces))
2194 (setq from (message-fetch-field "from"))))
2195 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2196 ;; single external face.
2197 (when (stringp gnus-article-x-face-command)
2198 (setq x-faces (list (car x-faces))))
2199 (when (and x-faces
2200 gnus-article-x-face-command
2201 (or force
2202 ;; Check whether this face is censored.
2203 (not gnus-article-x-face-too-ugly)
2204 (and from
2205 (not (string-match gnus-article-x-face-too-ugly
2206 from)))))
2207 (while (setq face (pop x-faces))
2208 ;; We display the face.
2209 (cond ((stringp gnus-article-x-face-command)
2210 ;; The command is a string, so we interpret the command
2211 ;; as a, well, command, and fork it off.
2212 (let ((process-connection-type nil))
2213 (gnus-set-process-query-on-exit-flag
2214 (start-process
2215 "article-x-face" nil shell-file-name
2216 shell-command-switch gnus-article-x-face-command)
2217 nil)
2218 (with-temp-buffer
2219 (insert face)
2220 (process-send-region "article-x-face"
2221 (point-min) (point-max)))
2222 (process-send-eof "article-x-face")))
2223 ((functionp gnus-article-x-face-command)
2224 ;; The command is a lisp function, so we call it.
2225 (funcall gnus-article-x-face-command face))
2226 (t
2227 (error "%s is not a function"
2228 gnus-article-x-face-command))))))))))
2229
2230 (defun article-decode-mime-words ()
2231 "Decode all MIME-encoded words in the article."
2232 (interactive)
2233 (save-excursion
2234 (set-buffer gnus-article-buffer)
2235 (let ((inhibit-point-motion-hooks t)
2236 (inhibit-read-only t)
2237 (mail-parse-charset gnus-newsgroup-charset)
2238 (mail-parse-ignored-charsets
2239 (save-excursion (set-buffer gnus-summary-buffer)
2240 gnus-newsgroup-ignored-charsets)))
2241 (mail-decode-encoded-word-region (point-min) (point-max)))))
2242
2243 (defun article-decode-charset (&optional prompt)
2244 "Decode charset-encoded text in the article.
2245 If PROMPT (the prefix), prompt for a coding system to use."
2246 (interactive "P")
2247 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2248 (inhibit-read-only t)
2249 (mail-parse-charset gnus-newsgroup-charset)
2250 (mail-parse-ignored-charsets
2251 (save-excursion (condition-case nil
2252 (set-buffer gnus-summary-buffer)
2253 (error))
2254 gnus-newsgroup-ignored-charsets))
2255 ct cte ctl charset format)
2256 (save-excursion
2257 (save-restriction
2258 (article-narrow-to-head)
2259 (setq ct (message-fetch-field "Content-Type" t)
2260 cte (message-fetch-field "Content-Transfer-Encoding" t)
2261 ctl (and ct (ignore-errors
2262 (mail-header-parse-content-type ct)))
2263 charset (cond
2264 (prompt
2265 (mm-read-coding-system "Charset to decode: "))
2266 (ctl
2267 (mail-content-type-get ctl 'charset)))
2268 format (and ctl (mail-content-type-get ctl 'format)))
2269 (when cte
2270 (setq cte (mail-header-strip cte)))
2271 (if (and ctl (not (string-match "/" (car ctl))))
2272 (setq ctl nil))
2273 (goto-char (point-max)))
2274 (forward-line 1)
2275 (save-restriction
2276 (narrow-to-region (point) (point-max))
2277 (when (and (eq mail-parse-charset 'gnus-decoded)
2278 (eq (mm-body-7-or-8) '8bit))
2279 ;; The text code could have been decoded.
2280 (setq charset mail-parse-charset))
2281 (when (and (or (not ctl)
2282 (equal (car ctl) "text/plain"))
2283 (not format)) ;; article with format will decode later.
2284 (mm-decode-body
2285 charset (and cte (intern (downcase
2286 (gnus-strip-whitespace cte))))
2287 (car ctl)))))))
2288
2289 (defun article-decode-encoded-words ()
2290 "Remove encoded-word encoding from headers."
2291 (let ((inhibit-point-motion-hooks t)
2292 (mail-parse-charset gnus-newsgroup-charset)
2293 (mail-parse-ignored-charsets
2294 (save-excursion (condition-case nil
2295 (set-buffer gnus-summary-buffer)
2296 (error))
2297 gnus-newsgroup-ignored-charsets))
2298 (inhibit-read-only t))
2299 (save-restriction
2300 (article-narrow-to-head)
2301 (funcall gnus-decode-header-function (point-min) (point-max)))))
2302
2303 (defun article-decode-group-name ()
2304 "Decode group names in `Newsgroups:'."
2305 (let ((inhibit-point-motion-hooks t)
2306 (inhibit-read-only t)
2307 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2308 (when (and (or gnus-group-name-charset-method-alist
2309 gnus-group-name-charset-group-alist)
2310 (gnus-buffer-live-p gnus-original-article-buffer))
2311 (save-restriction
2312 (article-narrow-to-head)
2313 (with-current-buffer gnus-original-article-buffer
2314 (goto-char (point-min)))
2315 (while (re-search-forward
2316 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2317 (replace-match (save-match-data
2318 (gnus-decode-newsgroups
2319 ;; XXX how to use data in article buffer?
2320 (with-current-buffer gnus-original-article-buffer
2321 (re-search-forward
2322 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2323 nil t)
2324 (match-string 1))
2325 gnus-newsgroup-name method))
2326 t t nil 1))
2327 (goto-char (point-min))
2328 (with-current-buffer gnus-original-article-buffer
2329 (goto-char (point-min)))
2330 (while (re-search-forward
2331 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2332 (replace-match (save-match-data
2333 (gnus-decode-newsgroups
2334 ;; XXX how to use data in article buffer?
2335 (with-current-buffer gnus-original-article-buffer
2336 (re-search-forward
2337 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2338 nil t)
2339 (match-string 1))
2340 gnus-newsgroup-name method))
2341 t t nil 1))))))
2342
2343 (autoload 'idna-to-unicode "idna")
2344
2345 (defun article-decode-idna-rhs ()
2346 "Decode IDNA strings in RHS in various headers in current buffer.
2347 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2348 Mail-Reply-To: and Mail-Followup-To:."
2349 (when gnus-use-idna
2350 (save-restriction
2351 (let ((inhibit-point-motion-hooks t)
2352 (inhibit-read-only t))
2353 (article-narrow-to-head)
2354 (goto-char (point-min))
2355 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2356 (let (ace unicode)
2357 (when (save-match-data
2358 (and (setq ace (match-string 1))
2359 (save-excursion
2360 (and (re-search-backward "^[^ \t]" nil t)
2361 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2362 (setq unicode (idna-to-unicode ace))))
2363 (unless (string= ace unicode)
2364 (replace-match unicode nil nil nil 1)))))))))
2365
2366 (defun article-de-quoted-unreadable (&optional force read-charset)
2367 "Translate a quoted-printable-encoded article.
2368 If FORCE, decode the article whether it is marked as quoted-printable
2369 or not.
2370 If READ-CHARSET, ask for a coding system."
2371 (interactive (list 'force current-prefix-arg))
2372 (save-excursion
2373 (let ((inhibit-read-only t) type charset)
2374 (if (gnus-buffer-live-p gnus-original-article-buffer)
2375 (with-current-buffer gnus-original-article-buffer
2376 (setq type
2377 (gnus-fetch-field "content-transfer-encoding"))
2378 (let* ((ct (gnus-fetch-field "content-type"))
2379 (ctl (and ct
2380 (ignore-errors
2381 (mail-header-parse-content-type ct)))))
2382 (setq charset (and ctl
2383 (mail-content-type-get ctl 'charset)))
2384 (if (stringp charset)
2385 (setq charset (intern (downcase charset)))))))
2386 (if read-charset
2387 (setq charset (mm-read-coding-system "Charset: " charset)))
2388 (unless charset
2389 (setq charset gnus-newsgroup-charset))
2390 (when (or force
2391 (and type (let ((case-fold-search t))
2392 (string-match "quoted-printable" type))))
2393 (article-goto-body)
2394 (quoted-printable-decode-region
2395 (point) (point-max) (mm-charset-to-coding-system charset))))))
2396
2397 (defun article-de-base64-unreadable (&optional force read-charset)
2398 "Translate a base64 article.
2399 If FORCE, decode the article whether it is marked as base64 not.
2400 If READ-CHARSET, ask for a coding system."
2401 (interactive (list 'force current-prefix-arg))
2402 (save-excursion
2403 (let ((inhibit-read-only t) type charset)
2404 (if (gnus-buffer-live-p gnus-original-article-buffer)
2405 (with-current-buffer gnus-original-article-buffer
2406 (setq type
2407 (gnus-fetch-field "content-transfer-encoding"))
2408 (let* ((ct (gnus-fetch-field "content-type"))
2409 (ctl (and ct
2410 (ignore-errors
2411 (mail-header-parse-content-type ct)))))
2412 (setq charset (and ctl
2413 (mail-content-type-get ctl 'charset)))
2414 (if (stringp charset)
2415 (setq charset (intern (downcase charset)))))))
2416 (if read-charset
2417 (setq charset (mm-read-coding-system "Charset: " charset)))
2418 (unless charset
2419 (setq charset gnus-newsgroup-charset))
2420 (when (or force
2421 (and type (let ((case-fold-search t))
2422 (string-match "base64" type))))
2423 (article-goto-body)
2424 (save-restriction
2425 (narrow-to-region (point) (point-max))
2426 (base64-decode-region (point-min) (point-max))
2427 (mm-decode-coding-region
2428 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2429
2430 (eval-when-compile
2431 (require 'rfc1843))
2432
2433 (defun article-decode-HZ ()
2434 "Translate a HZ-encoded article."
2435 (interactive)
2436 (require 'rfc1843)
2437 (save-excursion
2438 (let ((inhibit-read-only t))
2439 (rfc1843-decode-region (point-min) (point-max)))))
2440
2441 (defun article-unsplit-urls ()
2442 "Remove the newlines that some other mailers insert into URLs."
2443 (interactive)
2444 (save-excursion
2445 (let ((inhibit-read-only t))
2446 (goto-char (point-min))
2447 (while (re-search-forward
2448 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2449 (replace-match "\\1\\3" t)))
2450 (when (interactive-p)
2451 (gnus-treat-article nil))))
2452
2453
2454 (defun article-wash-html (&optional read-charset)
2455 "Format an HTML article.
2456 If READ-CHARSET, ask for a coding system."
2457 (interactive "P")
2458 (save-excursion
2459 (let ((inhibit-read-only t)
2460 charset)
2461 (when (gnus-buffer-live-p gnus-original-article-buffer)
2462 (with-current-buffer gnus-original-article-buffer
2463 (let* ((ct (gnus-fetch-field "content-type"))
2464 (ctl (and ct
2465 (ignore-errors
2466 (mail-header-parse-content-type ct)))))
2467 (setq charset (and ctl
2468 (mail-content-type-get ctl 'charset)))
2469 (when (stringp charset)
2470 (setq charset (intern (downcase charset)))))))
2471 (when read-charset
2472 (setq charset (mm-read-coding-system "Charset: " charset)))
2473 (unless charset
2474 (setq charset gnus-newsgroup-charset))
2475 (article-goto-body)
2476 (save-window-excursion
2477 (save-restriction
2478 (narrow-to-region (point) (point-max))
2479 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2480 (entry (assq func mm-text-html-washer-alist)))
2481 (when entry
2482 (setq func (cdr entry)))
2483 (cond
2484 ((functionp func)
2485 (funcall func))
2486 (t
2487 (apply (car func) (cdr func))))))))))
2488
2489 (defun gnus-article-wash-html-with-w3 ()
2490 "Wash the current buffer with w3."
2491 (mm-setup-w3)
2492 (let ((w3-strict-width (window-width))
2493 (url-standalone-mode t)
2494 (url-gateway-unplugged t)
2495 (w3-honor-stylesheets nil))
2496 (condition-case ()
2497 (w3-region (point-min) (point-max))
2498 (error))))
2499
2500 (defun gnus-article-wash-html-with-w3m ()
2501 "Wash the current buffer with emacs-w3m."
2502 (mm-setup-w3m)
2503 (save-restriction
2504 (narrow-to-region (point) (point-max))
2505 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2506 w3m-force-redisplay)
2507 (w3m-region (point-min) (point-max)))
2508 (when (and mm-inline-text-html-with-w3m-keymap
2509 (boundp 'w3m-minor-mode-map)
2510 w3m-minor-mode-map)
2511 (add-text-properties
2512 (point-min) (point-max)
2513 (list 'keymap w3m-minor-mode-map
2514 ;; Put the mark meaning this part was rendered by emacs-w3m.
2515 'mm-inline-text-html-with-w3m t)))))
2516
2517 (defun article-hide-list-identifiers ()
2518 "Remove list identifies from the Subject header.
2519 The `gnus-list-identifiers' variable specifies what to do."
2520 (interactive)
2521 (let ((inhibit-point-motion-hooks t)
2522 (regexp (if (consp gnus-list-identifiers)
2523 (mapconcat 'identity gnus-list-identifiers " *\\|")
2524 gnus-list-identifiers))
2525 (inhibit-read-only t))
2526 (when regexp
2527 (save-excursion
2528 (save-restriction
2529 (article-narrow-to-head)
2530 (goto-char (point-min))
2531 (while (re-search-forward
2532 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2533 nil t)
2534 (delete-region (match-beginning 2) (match-end 0))
2535 (beginning-of-line))
2536 (when (re-search-forward
2537 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2538 (delete-region (match-beginning 1) (match-end 1))))))))
2539
2540 (defun article-hide-pem (&optional arg)
2541 "Toggle hiding of any PEM headers and signatures in the current article.
2542 If given a negative prefix, always show; if given a positive prefix,
2543 always hide."
2544 (interactive (gnus-article-hidden-arg))
2545 (unless (gnus-article-check-hidden-text 'pem arg)
2546 (save-excursion
2547 (let ((inhibit-read-only t) end)
2548 (goto-char (point-min))
2549 ;; Hide the horrendously ugly "header".
2550 (when (and (search-forward
2551 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2552 nil t)
2553 (setq end (1+ (match-beginning 0))))
2554 (gnus-add-wash-type 'pem)
2555 (gnus-article-hide-text-type
2556 end
2557 (if (search-forward "\n\n" nil t)
2558 (match-end 0)
2559 (point-max))
2560 'pem)
2561 ;; Hide the trailer as well
2562 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2563 nil t)
2564 (gnus-article-hide-text-type
2565 (match-beginning 0) (match-end 0) 'pem)))))))
2566
2567 (defun article-strip-banner ()
2568 "Strip the banners specified by the `banner' group parameter and by
2569 `gnus-article-address-banner-alist'."
2570 (interactive)
2571 (save-excursion
2572 (save-restriction
2573 (let ((inhibit-point-motion-hooks t))
2574 (when (gnus-parameter-banner gnus-newsgroup-name)
2575 (article-really-strip-banner
2576 (gnus-parameter-banner gnus-newsgroup-name)))
2577 (when gnus-article-address-banner-alist
2578 (article-really-strip-banner
2579 (let ((from (save-restriction
2580 (widen)
2581 (article-narrow-to-head)
2582 (mail-fetch-field "from"))))
2583 (when (and from
2584 (setq from
2585 (caar (mail-header-parse-addresses from))))
2586 (catch 'found
2587 (dolist (pair gnus-article-address-banner-alist)
2588 (when (string-match (car pair) from)
2589 (throw 'found (cdr pair)))))))))))))
2590
2591 (defun article-really-strip-banner (banner)
2592 "Strip the banner specified by the argument."
2593 (save-excursion
2594 (save-restriction
2595 (let ((inhibit-point-motion-hooks t)
2596 (gnus-signature-limit nil)
2597 (inhibit-read-only t))
2598 (article-goto-body)
2599 (cond
2600 ((eq banner 'signature)
2601 (when (gnus-article-narrow-to-signature)
2602 (widen)
2603 (forward-line -1)
2604 (delete-region (point) (point-max))))
2605 ((symbolp banner)
2606 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2607 (while (re-search-forward banner nil t)
2608 (delete-region (match-beginning 0) (match-end 0)))))
2609 ((stringp banner)
2610 (while (re-search-forward banner nil t)
2611 (delete-region (match-beginning 0) (match-end 0)))))))))
2612
2613 (defun article-babel ()
2614 "Translate article using an online translation service."
2615 (interactive)
2616 (require 'babel)
2617 (save-excursion
2618 (set-buffer gnus-article-buffer)
2619 (when (article-goto-body)
2620 (let* ((inhibit-read-only t)
2621 (start (point))
2622 (end (point-max))
2623 (orig (buffer-substring start end))
2624 (trans (babel-as-string orig)))
2625 (save-restriction
2626 (narrow-to-region start end)
2627 (delete-region start end)
2628 (insert trans))))))
2629
2630 (defun article-hide-signature (&optional arg)
2631 "Hide the signature in the current article.
2632 If given a negative prefix, always show; if given a positive prefix,
2633 always hide."
2634 (interactive (gnus-article-hidden-arg))
2635 (unless (gnus-article-check-hidden-text 'signature arg)
2636 (save-excursion
2637 (save-restriction
2638 (let ((inhibit-read-only t))
2639 (when (gnus-article-narrow-to-signature)
2640 (gnus-article-hide-text-type
2641 (point-min) (point-max) 'signature))))))
2642 (gnus-set-mode-line 'article))
2643
2644 (defun article-strip-headers-in-body ()
2645 "Strip offensive headers from bodies."
2646 (interactive)
2647 (save-excursion
2648 (article-goto-body)
2649 (let ((case-fold-search t))
2650 (when (looking-at "x-no-archive:")
2651 (gnus-delete-line)))))
2652
2653 (defun article-strip-leading-blank-lines ()
2654 "Remove all blank lines from the beginning of the article."
2655 (interactive)
2656 (save-excursion
2657 (let ((inhibit-point-motion-hooks t)
2658 (inhibit-read-only t))
2659 (when (article-goto-body)
2660 (while (and (not (eobp))
2661 (looking-at "[ \t]*$"))
2662 (gnus-delete-line))))))
2663
2664 (defun article-narrow-to-head ()
2665 "Narrow the buffer to the head of the message.
2666 Point is left at the beginning of the narrowed-to region."
2667 (narrow-to-region
2668 (goto-char (point-min))
2669 (if (search-forward "\n\n" nil 1)
2670 (1- (point))
2671 (point-max)))
2672 (goto-char (point-min)))
2673
2674 (defun article-goto-body ()
2675 "Place point at the start of the body."
2676 (goto-char (point-min))
2677 (cond
2678 ;; This variable is only bound when dealing with separate
2679 ;; MIME body parts.
2680 (article-goto-body-goes-to-point-min-p
2681 t)
2682 ((search-forward "\n\n" nil t)
2683 t)
2684 (t
2685 (goto-char (point-max))
2686 nil)))
2687
2688 (defun article-strip-multiple-blank-lines ()
2689 "Replace consecutive blank lines with one empty line."
2690 (interactive)
2691 (save-excursion
2692 (let ((inhibit-point-motion-hooks t)
2693 (inhibit-read-only t))
2694 ;; First make all blank lines empty.
2695 (article-goto-body)
2696 (while (re-search-forward "^[ \t]+$" nil t)
2697 (unless (gnus-annotation-in-region-p
2698 (match-beginning 0) (match-end 0))
2699 (replace-match "" nil t)))
2700 ;; Then replace multiple empty lines with a single empty line.
2701 (article-goto-body)
2702 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2703 (unless (gnus-annotation-in-region-p
2704 (match-beginning 0) (match-end 0))
2705 (delete-region (match-beginning 1) (match-end 1)))))))
2706
2707 (defun article-strip-leading-space ()
2708 "Remove all white space from the beginning of the lines in the article."
2709 (interactive)
2710 (save-excursion
2711 (let ((inhibit-point-motion-hooks t)
2712 (inhibit-read-only t))
2713 (article-goto-body)
2714 (while (re-search-forward "^[ \t]+" nil t)
2715 (replace-match "" t t)))))
2716
2717 (defun article-strip-trailing-space ()
2718 "Remove all white space from the end of the lines in the article."
2719 (interactive)
2720 (save-excursion
2721 (let ((inhibit-point-motion-hooks t)
2722 (inhibit-read-only t))
2723 (article-goto-body)
2724 (while (re-search-forward "[ \t]+$" nil t)
2725 (replace-match "" t t)))))
2726
2727 (defun article-strip-blank-lines ()
2728 "Strip leading, trailing and multiple blank lines."
2729 (interactive)
2730 (article-strip-leading-blank-lines)
2731 (article-remove-trailing-blank-lines)
2732 (article-strip-multiple-blank-lines))
2733
2734 (defun article-strip-all-blank-lines ()
2735 "Strip all blank lines."
2736 (interactive)
2737 (save-excursion
2738 (let ((inhibit-point-motion-hooks t)
2739 (inhibit-read-only t))
2740 (article-goto-body)
2741 (while (re-search-forward "^[ \t]*\n" nil t)
2742 (replace-match "" t t)))))
2743
2744 (defun gnus-article-narrow-to-signature ()
2745 "Narrow to the signature; return t if a signature is found, else nil."
2746 (let ((inhibit-point-motion-hooks t))
2747 (when (gnus-article-search-signature)
2748 (forward-line 1)
2749 ;; Check whether we have some limits to what we consider
2750 ;; to be a signature.
2751 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2752 (list gnus-signature-limit)))
2753 limit limited)
2754 (while (setq limit (pop limits))
2755 (if (or (and (integerp limit)
2756 (< (- (point-max) (point)) limit))
2757 (and (floatp limit)
2758 (< (count-lines (point) (point-max)) limit))
2759 (and (functionp limit)
2760 (funcall limit))
2761 (and (stringp limit)
2762 (not (re-search-forward limit nil t))))
2763 () ; This limit did not succeed.
2764 (setq limited t
2765 limits nil)))
2766 (unless limited
2767 (narrow-to-region (point) (point-max))
2768 t)))))
2769
2770 (defun gnus-article-search-signature ()
2771 "Search the current buffer for the signature separator.
2772 Put point at the beginning of the signature separator."
2773 (let ((cur (point)))
2774 (goto-char (point-max))
2775 (if (if (stringp gnus-signature-separator)
2776 (re-search-backward gnus-signature-separator nil t)
2777 (let ((seps gnus-signature-separator))
2778 (while (and seps
2779 (not (re-search-backward (car seps) nil t)))
2780 (pop seps))
2781 seps))
2782 t
2783 (goto-char cur)
2784 nil)))
2785
2786 (defun gnus-article-hidden-arg ()
2787 "Return the current prefix arg as a number, or 0 if no prefix."
2788 (list (if current-prefix-arg
2789 (prefix-numeric-value current-prefix-arg)
2790 0)))
2791
2792 (defun gnus-article-check-hidden-text (type arg)
2793 "Return nil if hiding is necessary.
2794 Arg can be nil or a number. nil and positive means hide, negative
2795 means show, 0 means toggle."
2796 (save-excursion
2797 (save-restriction
2798 (let ((hide (gnus-article-hidden-text-p type)))
2799 (cond
2800 ((or (null arg)
2801 (> arg 0))
2802 nil)
2803 ((< arg 0)
2804 (gnus-article-show-hidden-text type)
2805 t)
2806 (t
2807 (if (eq hide 'hidden)
2808 (progn
2809 (gnus-article-show-hidden-text type)
2810 t)
2811 nil)))))))
2812
2813 (defun gnus-article-hidden-text-p (type)
2814 "Say whether the current buffer contains hidden text of type TYPE."
2815 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2816 (while (and pos
2817 (not (get-text-property pos 'invisible))
2818 (not (get-text-property pos 'dummy-invisible)))
2819 (setq pos
2820 (text-property-any (1+ pos) (point-max) 'article-type type)))
2821 (if pos
2822 'hidden
2823 nil)))
2824
2825 (defun gnus-article-show-hidden-text (type &optional dummy)
2826 "Show all hidden text of type TYPE.
2827 Originally it is hide instead of DUMMY."
2828 (let ((inhibit-read-only t)
2829 (inhibit-point-motion-hooks t))
2830 (gnus-remove-text-properties-when
2831 'article-type type
2832 (point-min) (point-max)
2833 (cons 'article-type (cons type
2834 gnus-hidden-properties)))
2835 (gnus-delete-wash-type type)))
2836
2837 (defconst article-time-units
2838 `((year . ,(* 365.25 24 60 60))
2839 (week . ,(* 7 24 60 60))
2840 (day . ,(* 24 60 60))
2841 (hour . ,(* 60 60))
2842 (minute . 60)
2843 (second . 1))
2844 "Mapping from time units to seconds.")
2845
2846 (defun gnus-article-forward-header ()
2847 "Move point to the start of the next header.
2848 If the current header is a continuation header, this can be several
2849 lines forward."
2850 (let ((ended nil))
2851 (while (not ended)
2852 (forward-line 1)
2853 (if (looking-at "[ \t]+[^ \t]")
2854 (forward-line 1)
2855 (setq ended t)))))
2856
2857 (defun article-date-ut (&optional type highlight)
2858 "Convert DATE date to universal time in the current article.
2859 If TYPE is `local', convert to local time; if it is `lapsed', output
2860 how much time has lapsed since DATE. For `lapsed', the value of
2861 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2862 should replace the \"Date:\" one, or should be added below it."
2863 (interactive (list 'ut t))
2864 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2865 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2866 tdate-regexp)
2867 ((eq type 'lapsed)
2868 "^X-Sent:[ \t]")
2869 (article-lapsed-timer
2870 "^Date:[ \t]")
2871 (t
2872 tdate-regexp)))
2873 (case-fold-search t)
2874 (inhibit-read-only t)
2875 (inhibit-point-motion-hooks t)
2876 pos date bface eface)
2877 (save-excursion
2878 (save-restriction
2879 (widen)
2880 (goto-char (point-min))
2881 (while (or (setq date (get-text-property (setq pos (point))
2882 'original-date))
2883 (when (setq pos (next-single-property-change
2884 (point) 'original-date))
2885 (setq date (get-text-property pos 'original-date))
2886 t))
2887 (narrow-to-region pos (or (text-property-any pos (point-max)
2888 'original-date nil)
2889 (point-max)))
2890 (goto-char (point-min))
2891 (when (re-search-forward tdate-regexp nil t)
2892 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2893 eface (get-text-property (1- (gnus-point-at-eol)) 'face)))
2894 (goto-char (point-min))
2895 (setq pos nil)
2896 ;; Delete any old Date headers.
2897 (while (re-search-forward date-regexp nil t)
2898 (if pos
2899 (delete-region (gnus-point-at-bol)
2900 (progn
2901 (gnus-article-forward-header)
2902 (point)))
2903 (delete-region (gnus-point-at-bol)
2904 (progn
2905 (gnus-article-forward-header)
2906 (forward-char -1)
2907 (point)))
2908 (setq pos (point))))
2909 (when (and (not pos)
2910 (re-search-forward tdate-regexp nil t))
2911 (forward-line 1))
2912 (gnus-goto-char pos)
2913 (insert (article-make-date-line date (or type 'ut)))
2914 (unless pos
2915 (insert "\n")
2916 (forward-line -1))
2917 ;; Do highlighting.
2918 (beginning-of-line)
2919 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2920 (put-text-property (match-beginning 1) (1+ (match-end 1))
2921 'face bface)
2922 (put-text-property (match-beginning 2) (match-end 2)
2923 'face eface))
2924 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2925 (goto-char (point-max))
2926 (widen))))))
2927
2928 (defun article-make-date-line (date type)
2929 "Return a DATE line of TYPE."
2930 (unless (memq type '(local ut original user iso8601 lapsed english))
2931 (error "Unknown conversion type: %s" type))
2932 (condition-case ()
2933 (let ((time (date-to-time date)))
2934 (cond
2935 ;; Convert to the local timezone.
2936 ((eq type 'local)
2937 (let ((tz (car (current-time-zone time))))
2938 (format "Date: %s %s%02d%02d" (current-time-string time)
2939 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2940 (/ (% (abs tz) 3600) 60))))
2941 ;; Convert to Universal Time.
2942 ((eq type 'ut)
2943 (concat "Date: "
2944 (current-time-string
2945 (let* ((e (parse-time-string date))
2946 (tm (apply 'encode-time e))
2947 (ms (car tm))
2948 (ls (- (cadr tm) (car (current-time-zone time)))))
2949 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2950 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2951 (t (list ms ls)))))
2952 " UT"))
2953 ;; Get the original date from the article.
2954 ((eq type 'original)
2955 (concat "Date: " (if (string-match "\n+$" date)
2956 (substring date 0 (match-beginning 0))
2957 date)))
2958 ;; Let the user define the format.
2959 ((eq type 'user)
2960 (let ((format (or (condition-case nil
2961 (with-current-buffer gnus-summary-buffer
2962 gnus-article-time-format)
2963 (error nil))
2964 gnus-article-time-format)))
2965 (if (functionp format)
2966 (funcall format time)
2967 (concat "Date: " (format-time-string format time)))))
2968 ;; ISO 8601.
2969 ((eq type 'iso8601)
2970 (let ((tz (car (current-time-zone time))))
2971 (concat
2972 "Date: "
2973 (format-time-string "%Y%m%dT%H%M%S" time)
2974 (format "%s%02d%02d"
2975 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2976 (/ (% (abs tz) 3600) 60)))))
2977 ;; Do an X-Sent lapsed format.
2978 ((eq type 'lapsed)
2979 ;; If the date is seriously mangled, the timezone functions are
2980 ;; liable to bug out, so we ignore all errors.
2981 (let* ((now (current-time))
2982 (real-time (subtract-time now time))
2983 (real-sec (and real-time
2984 (+ (* (float (car real-time)) 65536)
2985 (cadr real-time))))
2986 (sec (and real-time (abs real-sec)))
2987 num prev)
2988 (cond
2989 ((null real-time)
2990 "X-Sent: Unknown")
2991 ((zerop sec)
2992 "X-Sent: Now")
2993 (t
2994 (concat
2995 "X-Sent: "
2996 ;; This is a bit convoluted, but basically we go
2997 ;; through the time units for years, weeks, etc,
2998 ;; and divide things to see whether that results
2999 ;; in positive answers.
3000 (mapconcat
3001 (lambda (unit)
3002 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3003 ;; The (remaining) seconds are too few to
3004 ;; be divided into this time unit.
3005 ""
3006 ;; It's big enough, so we output it.
3007 (setq sec (- sec (* num (cdr unit))))
3008 (prog1
3009 (concat (if prev ", " "") (int-to-string
3010 (floor num))
3011 " " (symbol-name (car unit))
3012 (if (> num 1) "s" ""))
3013 (setq prev t))))
3014 article-time-units "")
3015 ;; If dates are odd, then it might appear like the
3016 ;; article was sent in the future.
3017 (if (> real-sec 0)
3018 " ago"
3019 " in the future"))))))
3020 ;; Display the date in proper English
3021 ((eq type 'english)
3022 (let ((dtime (decode-time time)))
3023 (concat
3024 "Date: the "
3025 (number-to-string (nth 3 dtime))
3026 (let ((digit (% (nth 3 dtime) 10)))
3027 (cond
3028 ((memq (nth 3 dtime) '(11 12 13)) "th")
3029 ((= digit 1) "st")
3030 ((= digit 2) "nd")
3031 ((= digit 3) "rd")
3032 (t "th")))
3033 " of "
3034 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3035 " "
3036 (number-to-string (nth 5 dtime))
3037 " at "
3038 (format "%02d" (nth 2 dtime))
3039 ":"
3040 (format "%02d" (nth 1 dtime)))))))
3041 (error
3042 (format "Date: %s (from Gnus)" date))))
3043
3044 (defun article-date-local (&optional highlight)
3045 "Convert the current article date to the local timezone."
3046 (interactive (list t))
3047 (article-date-ut 'local highlight))
3048
3049 (defun article-date-english (&optional highlight)
3050 "Convert the current article date to something that is proper English."
3051 (interactive (list t))
3052 (article-date-ut 'english highlight))
3053
3054 (defun article-date-original (&optional highlight)
3055 "Convert the current article date to what it was originally.
3056 This is only useful if you have used some other date conversion
3057 function and want to see what the date was before converting."
3058 (interactive (list t))
3059 (article-date-ut 'original highlight))
3060
3061 (defun article-date-lapsed (&optional highlight)
3062 "Convert the current article date to time lapsed since it was sent."
3063 (interactive (list t))
3064 (article-date-ut 'lapsed highlight))
3065
3066 (defun article-update-date-lapsed ()
3067 "Function to be run from a timer to update the lapsed time line."
3068 (save-match-data
3069 (let (deactivate-mark)
3070 (save-excursion
3071 (ignore-errors
3072 (walk-windows
3073 (lambda (w)
3074 (set-buffer (window-buffer w))
3075 (when (eq major-mode 'gnus-article-mode)
3076 (let ((mark (point-marker)))
3077 (goto-char (point-min))
3078 (when (re-search-forward "^X-Sent:" nil t)
3079 (article-date-lapsed t))
3080 (goto-char (marker-position mark))
3081 (move-marker mark nil))))
3082 nil 'visible))))))
3083
3084 (defun gnus-start-date-timer (&optional n)
3085 "Start a timer to update the X-Sent header in the article buffers.
3086 The numerical prefix says how frequently (in seconds) the function
3087 is to run."
3088 (interactive "p")
3089 (unless n
3090 (setq n 1))
3091 (gnus-stop-date-timer)
3092 (setq article-lapsed-timer
3093 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3094
3095 (defun gnus-stop-date-timer ()
3096 "Stop the X-Sent timer."
3097 (interactive)
3098 (when article-lapsed-timer
3099 (nnheader-cancel-timer article-lapsed-timer)
3100 (setq article-lapsed-timer nil)))
3101
3102 (defun article-date-user (&optional highlight)
3103 "Convert the current article date to the user-defined format.
3104 This format is defined by the `gnus-article-time-format' variable."
3105 (interactive (list t))
3106 (article-date-ut 'user highlight))
3107
3108 (defun article-date-iso8601 (&optional highlight)
3109 "Convert the current article date to ISO8601."
3110 (interactive (list t))
3111 (article-date-ut 'iso8601 highlight))
3112
3113 (defmacro gnus-article-save-original-date (&rest forms)
3114 "Save the original date as a text property and evaluate FORMS."
3115 `(let* ((case-fold-search t)
3116 (start (progn
3117 (goto-char (point-min))
3118 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3119 (not (bolp)))
3120 (match-end 0))))
3121 (date (when (and start
3122 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3123 nil t))
3124 (buffer-substring-no-properties start
3125 (match-beginning 0)))))
3126 (goto-char (point-max))
3127 (skip-chars-backward "\n")
3128 (put-text-property (point-min) (point) 'original-date date)
3129 ,@forms
3130 (goto-char (point-max))
3131 (skip-chars-backward "\n")
3132 (put-text-property (point-min) (point) 'original-date date)))
3133
3134 ;; (defun article-show-all ()
3135 ;; "Show all hidden text in the article buffer."
3136 ;; (interactive)
3137 ;; (save-excursion
3138 ;; (let ((inhibit-read-only t))
3139 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3140
3141 (defun article-remove-leading-whitespace ()
3142 "Remove excessive whitespace from all headers."
3143 (interactive)
3144 (save-excursion
3145 (save-restriction
3146 (let ((inhibit-read-only t))
3147 (article-narrow-to-head)
3148 (goto-char (point-min))
3149 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3150 (delete-region (match-beginning 1) (match-end 1)))))))
3151
3152 (defun article-emphasize (&optional arg)
3153 "Emphasize text according to `gnus-emphasis-alist'."
3154 (interactive (gnus-article-hidden-arg))
3155 (unless (gnus-article-check-hidden-text 'emphasis arg)
3156 (save-excursion
3157 (let ((alist (or
3158 (condition-case nil
3159 (with-current-buffer gnus-summary-buffer
3160 gnus-article-emphasis-alist)
3161 (error))
3162 gnus-emphasis-alist))
3163 (inhibit-read-only t)
3164 (props (append '(article-type emphasis)
3165 gnus-hidden-properties))
3166 regexp elem beg invisible visible face)
3167 (article-goto-body)
3168 (setq beg (point))
3169 (while (setq elem (pop alist))
3170 (goto-char beg)
3171 (setq regexp (car elem)
3172 invisible (nth 1 elem)
3173 visible (nth 2 elem)
3174 face (nth 3 elem))
3175 (while (re-search-forward regexp nil t)
3176 (when (and (match-beginning visible) (match-beginning invisible))
3177 (gnus-article-hide-text
3178 (match-beginning invisible) (match-end invisible) props)
3179 (gnus-article-unhide-text-type
3180 (match-beginning visible) (match-end visible) 'emphasis)
3181 (gnus-put-overlay-excluding-newlines
3182 (match-beginning visible) (match-end visible) 'face face)
3183 (gnus-add-wash-type 'emphasis)
3184 (goto-char (match-end invisible)))))))))
3185
3186 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3187 "Setup newsgroup emphasis alist."
3188 (unless gnus-article-emphasis-alist
3189 (let ((name (and gnus-newsgroup-name
3190 (gnus-group-real-name gnus-newsgroup-name))))
3191 (make-local-variable 'gnus-article-emphasis-alist)
3192 (setq gnus-article-emphasis-alist
3193 (nconc
3194 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3195 (while (setq elem (pop alist))
3196 (when (and name (string-match (car elem) name))
3197 (setq alist nil
3198 highlight (copy-sequence (cdr elem)))))
3199 highlight)
3200 (copy-sequence highlight-words)
3201 (if gnus-newsgroup-name
3202 (copy-sequence (gnus-group-find-parameter
3203 gnus-newsgroup-name 'highlight-words t)))
3204 gnus-emphasis-alist)))))
3205
3206 (eval-when-compile
3207 (defvar gnus-summary-article-menu)
3208 (defvar gnus-summary-post-menu))
3209
3210 ;;; Saving functions.
3211
3212 (defun gnus-article-save (save-buffer file &optional num)
3213 "Save the currently selected article."
3214 (unless gnus-save-all-headers
3215 ;; Remove headers according to `gnus-saved-headers'.
3216 (let ((gnus-visible-headers
3217 (or gnus-saved-headers gnus-visible-headers))
3218 (gnus-article-buffer save-buffer))
3219 (save-excursion
3220 (set-buffer save-buffer)
3221 (article-hide-headers 1 t))))
3222 (save-window-excursion
3223 (if (not gnus-default-article-saver)
3224 (error "No default saver is defined")
3225 ;; !!! Magic! The saving functions all save
3226 ;; `gnus-save-article-buffer' (or so they think), but we
3227 ;; bind that variable to our save-buffer.
3228 (set-buffer gnus-article-buffer)
3229 (let* ((gnus-save-article-buffer save-buffer)
3230 (filename
3231 (cond
3232 ((not gnus-prompt-before-saving) 'default)
3233 ((eq gnus-prompt-before-saving 'always) nil)
3234 (t file)))
3235 (gnus-number-of-articles-to-be-saved
3236 (when (eq gnus-prompt-before-saving t)
3237 num))) ; Magic
3238 (set-buffer gnus-article-current-summary)
3239 (funcall gnus-default-article-saver filename)))))
3240
3241 (defun gnus-read-save-file-name (prompt &optional filename
3242 function group headers variable)
3243 (let ((default-name
3244 (funcall function group headers (symbol-value variable)))
3245 result)
3246 (setq result
3247 (expand-file-name
3248 (cond
3249 ((eq filename 'default)
3250 default-name)
3251 ((eq filename t)
3252 default-name)
3253 (filename filename)
3254 (t
3255 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3256 (prompt
3257 (format prompt
3258 (if (and gnus-number-of-articles-to-be-saved
3259 (> gnus-number-of-articles-to-be-saved 1))
3260 (format "these %d articles"
3261 gnus-number-of-articles-to-be-saved)
3262 "this article")))
3263 (file
3264 ;; Let the split methods have their say.
3265 (cond
3266 ;; No split name was found.
3267 ((null split-name)
3268 (read-file-name
3269 (concat prompt " (default "
3270 (file-name-nondirectory default-name) "): ")
3271 (file-name-directory default-name)
3272 default-name))
3273 ;; A single group name is returned.
3274 ((stringp split-name)
3275 (setq default-name
3276 (funcall function split-name headers
3277 (symbol-value variable)))
3278 (read-file-name
3279 (concat prompt " (default "
3280 (file-name-nondirectory default-name) "): ")
3281 (file-name-directory default-name)
3282 default-name))
3283 ;; A single split name was found
3284 ((= 1 (length split-name))
3285 (let* ((name (expand-file-name
3286 (car split-name)
3287 gnus-article-save-directory))
3288 (dir (cond ((file-directory-p name)
3289 (file-name-as-directory name))
3290 ((file-exists-p name) name)
3291 (t gnus-article-save-directory))))
3292 (read-file-name
3293 (concat prompt " (default " name "): ")
3294 dir name)))
3295 ;; A list of splits was found.
3296 (t
3297 (setq split-name (nreverse split-name))
3298 (let (result)
3299 (let ((file-name-history
3300 (nconc split-name file-name-history)))
3301 (setq result
3302 (expand-file-name
3303 (read-file-name
3304 (concat prompt " (`M-p' for defaults): ")
3305 gnus-article-save-directory
3306 (car split-name))
3307 gnus-article-save-directory)))
3308 (car (push result file-name-history)))))))
3309 ;; Create the directory.
3310 (gnus-make-directory (file-name-directory file))
3311 ;; If we have read a directory, we append the default file name.
3312 (when (file-directory-p file)
3313 (setq file (expand-file-name (file-name-nondirectory
3314 default-name)
3315 (file-name-as-directory file))))
3316 ;; Possibly translate some characters.
3317 (nnheader-translate-file-chars file))))))
3318 (gnus-make-directory (file-name-directory result))
3319 (set variable result)))
3320
3321 (defun gnus-article-archive-name (group)
3322 "Return the first instance of an \"Archive-name\" in the current buffer."
3323 (let ((case-fold-search t))
3324 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3325 (nnheader-concat gnus-article-save-directory
3326 (match-string 1)))))
3327
3328 (defun gnus-article-nndoc-name (group)
3329 "If GROUP is an nndoc group, return the name of the parent group."
3330 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3331 (gnus-group-get-parameter group 'save-article-group)))
3332
3333 (defun gnus-summary-save-in-rmail (&optional filename)
3334 "Append this article to Rmail file.
3335 Optional argument FILENAME specifies file name.
3336 Directory to save to is default to `gnus-article-save-directory'."
3337 (setq filename (gnus-read-save-file-name
3338 "Save %s in rmail file" filename
3339 gnus-rmail-save-name gnus-newsgroup-name
3340 gnus-current-headers 'gnus-newsgroup-last-rmail))
3341 (gnus-eval-in-buffer-window gnus-save-article-buffer
3342 (save-excursion
3343 (save-restriction
3344 (widen)
3345 (gnus-output-to-rmail filename))))
3346 filename)
3347
3348 (defun gnus-summary-save-in-mail (&optional filename)
3349 "Append this article to Unix mail file.
3350 Optional argument FILENAME specifies file name.
3351 Directory to save to is default to `gnus-article-save-directory'."
3352 (setq filename (gnus-read-save-file-name
3353 "Save %s in Unix mail file" filename
3354 gnus-mail-save-name gnus-newsgroup-name
3355 gnus-current-headers 'gnus-newsgroup-last-mail))
3356 (gnus-eval-in-buffer-window gnus-save-article-buffer
3357 (save-excursion
3358 (save-restriction
3359 (widen)
3360 (if (and (file-readable-p filename)
3361 (file-regular-p filename)
3362 (mail-file-babyl-p filename))
3363 (rmail-output-to-rmail-file filename t)
3364 (gnus-output-to-mail filename)))))
3365 filename)
3366
3367 (defun gnus-summary-save-in-file (&optional filename overwrite)
3368 "Append this article to file.
3369 Optional argument FILENAME specifies file name.
3370 Directory to save to is default to `gnus-article-save-directory'."
3371 (setq filename (gnus-read-save-file-name
3372 "Save %s in file" filename
3373 gnus-file-save-name gnus-newsgroup-name
3374 gnus-current-headers 'gnus-newsgroup-last-file))
3375 (gnus-eval-in-buffer-window gnus-save-article-buffer
3376 (save-excursion
3377 (save-restriction
3378 (widen)
3379 (when (and overwrite
3380 (file-exists-p filename))
3381 (delete-file filename))
3382 (gnus-output-to-file filename))))
3383 filename)
3384
3385 (defun gnus-summary-write-to-file (&optional filename)
3386 "Write this article to a file, overwriting it if the file exists.
3387 Optional argument FILENAME specifies file name.
3388 The directory to save in defaults to `gnus-article-save-directory'."
3389 (gnus-summary-save-in-file nil t))
3390
3391 (defun gnus-summary-save-body-in-file (&optional filename)
3392 "Append this article body to a file.
3393 Optional argument FILENAME specifies file name.
3394 The directory to save in defaults to `gnus-article-save-directory'."
3395 (setq filename (gnus-read-save-file-name
3396 "Save %s body in file" filename
3397 gnus-file-save-name gnus-newsgroup-name
3398 gnus-current-headers 'gnus-newsgroup-last-file))
3399 (gnus-eval-in-buffer-window gnus-save-article-buffer
3400 (save-excursion
3401 (save-restriction
3402 (widen)
3403 (when (article-goto-body)
3404 (narrow-to-region (point) (point-max)))
3405 (gnus-output-to-file filename))))
3406 filename)
3407
3408 (defun gnus-summary-save-in-pipe (&optional command)
3409 "Pipe this article to subprocess."
3410 (setq command
3411 (cond ((and (eq command 'default)
3412 gnus-last-shell-command)
3413 gnus-last-shell-command)
3414 ((stringp command)
3415 command)
3416 (t (read-string
3417 (format
3418 "Shell command on %s: "
3419 (if (and gnus-number-of-articles-to-be-saved
3420 (> gnus-number-of-articles-to-be-saved 1))
3421 (format "these %d articles"
3422 gnus-number-of-articles-to-be-saved)
3423 "this article"))
3424 gnus-last-shell-command))))
3425 (when (string-equal command "")
3426 (if gnus-last-shell-command
3427 (setq command gnus-last-shell-command)
3428 (error "A command is required")))
3429 (gnus-eval-in-buffer-window gnus-article-buffer
3430 (save-restriction
3431 (widen)
3432 (shell-command-on-region (point-min) (point-max) command nil)))
3433 (setq gnus-last-shell-command command))
3434
3435 (defmacro gnus-read-string (prompt &optional initial-contents history
3436 default-value)
3437 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3438 (if (and (featurep 'xemacs)
3439 (< emacs-minor-version 2))
3440 `(read-string ,prompt ,initial-contents ,history)
3441 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3442
3443 (defun gnus-summary-pipe-to-muttprint (&optional command)
3444 "Pipe this article to muttprint."
3445 (setq command (gnus-read-string
3446 "Print using command: " gnus-summary-muttprint-program
3447 nil gnus-summary-muttprint-program))
3448 (gnus-summary-save-in-pipe command))
3449
3450 ;;; Article file names when saving.
3451
3452 (defun gnus-capitalize-newsgroup (newsgroup)
3453 "Capitalize NEWSGROUP name."
3454 (when (not (zerop (length newsgroup)))
3455 (concat (char-to-string (upcase (aref newsgroup 0)))
3456 (substring newsgroup 1))))
3457
3458 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3459 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3460 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3461 Otherwise, it is like ~/News/news/group/num."
3462 (let ((default
3463 (expand-file-name
3464 (concat (if (gnus-use-long-file-name 'not-save)
3465 (gnus-capitalize-newsgroup newsgroup)
3466 (gnus-newsgroup-directory-form newsgroup))
3467 "/" (int-to-string (mail-header-number headers)))
3468 gnus-article-save-directory)))
3469 (if (and last-file
3470 (string-equal (file-name-directory default)
3471 (file-name-directory last-file))
3472 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3473 default
3474 (or last-file default))))
3475
3476 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3477 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3478 If variable `gnus-use-long-file-name' is non-nil, it is
3479 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3480 (let ((default
3481 (expand-file-name
3482 (concat (if (gnus-use-long-file-name 'not-save)
3483 newsgroup
3484 (gnus-newsgroup-directory-form newsgroup))
3485 "/" (int-to-string (mail-header-number headers)))
3486 gnus-article-save-directory)))
3487 (if (and last-file
3488 (string-equal (file-name-directory default)
3489 (file-name-directory last-file))
3490 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3491 default
3492 (or last-file default))))
3493
3494 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3495 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3496 If variable `gnus-use-long-file-name' is non-nil, it is
3497 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3498 (or last-file
3499 (expand-file-name
3500 (if (gnus-use-long-file-name 'not-save)
3501 newsgroup
3502 (file-relative-name
3503 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3504 default-directory))
3505 gnus-article-save-directory)))
3506
3507 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3508 "Generate file name from sender."
3509 (let ((from (mail-header-from headers)))
3510 (expand-file-name
3511 (if (and from (string-match "\\([^ <]+\\)@" from))
3512 (match-string 1 from)
3513 "nobody")
3514 gnus-article-save-directory)))
3515
3516 (defun article-verify-x-pgp-sig ()
3517 "Verify X-PGP-Sig."
3518 (interactive)
3519 (if (gnus-buffer-live-p gnus-original-article-buffer)
3520 (let ((sig (with-current-buffer gnus-original-article-buffer
3521 (gnus-fetch-field "X-PGP-Sig")))
3522 items info headers)
3523 (when (and sig
3524 mml2015-use
3525 (mml2015-clear-verify-function))
3526 (with-temp-buffer
3527 (insert-buffer-substring gnus-original-article-buffer)
3528 (setq items (split-string sig))
3529 (message-narrow-to-head)
3530 (let ((inhibit-point-motion-hooks t)
3531 (case-fold-search t))
3532 ;; Don't verify multiple headers.
3533 (setq headers (mapconcat (lambda (header)
3534 (concat header ": "
3535 (mail-fetch-field header)
3536 "\n"))
3537 (split-string (nth 1 items) ",") "")))
3538 (delete-region (point-min) (point-max))
3539 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3540 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3541 (insert headers)
3542 (widen)
3543 (forward-line)
3544 (while (not (eobp))
3545 (if (looking-at "^-")
3546 (insert "- "))
3547 (forward-line))
3548 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3549 (insert "Version: " (car items) "\n\n")
3550 (insert (mapconcat 'identity (cddr items) "\n"))
3551 (insert "\n-----END PGP SIGNATURE-----\n")
3552 (let ((mm-security-handle (list (format "multipart/signed"))))
3553 (mml2015-clean-buffer)
3554 (let ((coding-system-for-write (or gnus-newsgroup-charset
3555 'iso-8859-1)))
3556 (funcall (mml2015-clear-verify-function)))
3557 (setq info
3558 (or (mm-handle-multipart-ctl-parameter
3559 mm-security-handle 'gnus-details)
3560 (mm-handle-multipart-ctl-parameter
3561 mm-security-handle 'gnus-info)))))
3562 (when info
3563 (let ((inhibit-read-only t) bface eface)
3564 (save-restriction
3565 (message-narrow-to-head)
3566 (goto-char (point-max))
3567 (forward-line -1)
3568 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3569 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3570 (message-remove-header "X-Gnus-PGP-Verify")
3571 (if (re-search-forward "^X-PGP-Sig:" nil t)
3572 (forward-line)
3573 (goto-char (point-max)))
3574 (narrow-to-region (point) (point))
3575 (insert "X-Gnus-PGP-Verify: " info "\n")
3576 (goto-char (point-min))
3577 (forward-line)
3578 (while (not (eobp))
3579 (if (not (looking-at "^[ \t]"))
3580 (insert " "))
3581 (forward-line))
3582 ;; Do highlighting.
3583 (goto-char (point-min))
3584 (when (looking-at "\\([^:]+\\): *")
3585 (put-text-property (match-beginning 1) (1+ (match-end 1))
3586 'face bface)
3587 (put-text-property (match-end 0) (point-max)
3588 'face eface)))))))))
3589
3590 (defun article-verify-cancel-lock ()
3591 "Verify Cancel-Lock header."
3592 (interactive)
3593 (if (gnus-buffer-live-p gnus-original-article-buffer)
3594 (canlock-verify gnus-original-article-buffer)))
3595
3596 (eval-and-compile
3597 (mapcar
3598 (lambda (func)
3599 (let (afunc gfunc)
3600 (if (consp func)
3601 (setq afunc (car func)
3602 gfunc (cdr func))
3603 (setq afunc func
3604 gfunc (intern (format "gnus-%s" func))))
3605 (defalias gfunc
3606 (when (fboundp afunc)
3607 `(lambda (&optional interactive &rest args)
3608 ,(documentation afunc t)
3609 (interactive (list t))
3610 (save-excursion
3611 (set-buffer gnus-article-buffer)
3612 (if interactive
3613 (call-interactively ',afunc)
3614 (apply ',afunc args))))))))
3615 '(article-hide-headers
3616 article-verify-x-pgp-sig
3617 article-verify-cancel-lock
3618 article-hide-boring-headers
3619 article-treat-overstrike
3620 article-fill-long-lines
3621 article-capitalize-sentences
3622 article-remove-cr
3623 article-remove-leading-whitespace
3624 article-display-x-face
3625 article-display-face
3626 article-de-quoted-unreadable
3627 article-de-base64-unreadable
3628 article-decode-HZ
3629 article-wash-html
3630 article-unsplit-urls
3631 article-hide-list-identifiers
3632 article-strip-banner
3633 article-babel
3634 article-hide-pem
3635 article-hide-signature
3636 article-strip-headers-in-body
3637 article-remove-trailing-blank-lines
3638 article-strip-leading-blank-lines
3639 article-strip-multiple-blank-lines
3640 article-strip-leading-space
3641 article-strip-trailing-space
3642 article-strip-blank-lines
3643 article-strip-all-blank-lines
3644 article-date-local
3645 article-date-english
3646 article-date-iso8601
3647 article-date-original
3648 article-date-ut
3649 article-decode-mime-words
3650 article-decode-charset
3651 article-decode-encoded-words
3652 article-date-user
3653 article-date-lapsed
3654 article-emphasize
3655 article-treat-dumbquotes
3656 article-normalize-headers
3657 ;; (article-show-all . gnus-article-show-all-headers)
3658 )))
3659 \f
3660 ;;;
3661 ;;; Gnus article mode
3662 ;;;
3663
3664 (put 'gnus-article-mode 'mode-class 'special)
3665
3666 (set-keymap-parent gnus-article-mode-map widget-keymap)
3667
3668 (gnus-define-keys gnus-article-mode-map
3669 " " gnus-article-goto-next-page
3670 "\177" gnus-article-goto-prev-page
3671 [delete] gnus-article-goto-prev-page
3672 [backspace] gnus-article-goto-prev-page
3673 "\C-c^" gnus-article-refer-article
3674 "h" gnus-article-show-summary
3675 "s" gnus-article-show-summary
3676 "\C-c\C-m" gnus-article-mail
3677 "?" gnus-article-describe-briefly
3678 "e" gnus-summary-edit-article
3679 "<" beginning-of-buffer
3680 ">" end-of-buffer
3681 "\C-c\C-i" gnus-info-find-node
3682 "\C-c\C-b" gnus-bug
3683 "R" gnus-article-reply-with-original
3684 "F" gnus-article-followup-with-original
3685 "\C-hk" gnus-article-describe-key
3686 "\C-hc" gnus-article-describe-key-briefly
3687
3688 "\C-d" gnus-article-read-summary-keys
3689 "\M-*" gnus-article-read-summary-keys
3690 "\M-#" gnus-article-read-summary-keys
3691 "\M-^" gnus-article-read-summary-keys
3692 "\M-g" gnus-article-read-summary-keys)
3693
3694 (substitute-key-definition
3695 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3696
3697 (defun gnus-article-make-menu-bar ()
3698 (unless (boundp 'gnus-article-commands-menu)
3699 (gnus-summary-make-menu-bar))
3700 (gnus-turn-off-edit-menu 'article)
3701 (unless (boundp 'gnus-article-article-menu)
3702 (easy-menu-define
3703 gnus-article-article-menu gnus-article-mode-map ""
3704 '("Article"
3705 ["Scroll forwards" gnus-article-goto-next-page t]
3706 ["Scroll backwards" gnus-article-goto-prev-page t]
3707 ["Show summary" gnus-article-show-summary t]
3708 ["Fetch Message-ID at point" gnus-article-refer-article t]
3709 ["Mail to address at point" gnus-article-mail t]
3710 ["Send a bug report" gnus-bug t]))
3711
3712 (easy-menu-define
3713 gnus-article-treatment-menu gnus-article-mode-map ""
3714 ;; Fixme: this should use :active (and maybe :visible).
3715 '("Treatment"
3716 ["Hide headers" gnus-article-hide-headers t]
3717 ["Hide signature" gnus-article-hide-signature t]
3718 ["Hide citation" gnus-article-hide-citation t]
3719 ["Treat overstrike" gnus-article-treat-overstrike t]
3720 ["Remove carriage return" gnus-article-remove-cr t]
3721 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3722 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3723 ["Remove base64" gnus-article-de-base64-unreadable t]
3724 ["Treat html" gnus-article-wash-html t]
3725 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3726 ["Decode HZ" gnus-article-decode-HZ t]))
3727
3728 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3729
3730 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3731
3732 (gnus-run-hooks 'gnus-article-menu-hook)))
3733
3734 (defun gnus-article-mode ()
3735 "Major mode for displaying an article.
3736
3737 All normal editing commands are switched off.
3738
3739 The following commands are available in addition to all summary mode
3740 commands:
3741 \\<gnus-article-mode-map>
3742 \\[gnus-article-next-page]\t Scroll the article one page forwards
3743 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3744 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3745 \\[gnus-article-show-summary]\t Display the summary buffer
3746 \\[gnus-article-mail]\t Send a reply to the address near point
3747 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3748 \\[gnus-info-find-node]\t Go to the Gnus info node"
3749 (interactive)
3750 (kill-all-local-variables)
3751 (gnus-simplify-mode-line)
3752 (setq mode-name "Article")
3753 (setq major-mode 'gnus-article-mode)
3754 (make-local-variable 'minor-mode-alist)
3755 (use-local-map gnus-article-mode-map)
3756 (when (gnus-visual-p 'article-menu 'menu)
3757 (gnus-article-make-menu-bar)
3758 (when gnus-summary-tool-bar-map
3759 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3760 (gnus-update-format-specifications nil 'article-mode)
3761 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3762 (set (make-local-variable 'gnus-page-broken) nil)
3763 (make-local-variable 'gnus-button-marker-list)
3764 (make-local-variable 'gnus-article-current-summary)
3765 (make-local-variable 'gnus-article-mime-handles)
3766 (make-local-variable 'gnus-article-decoded-p)
3767 (make-local-variable 'gnus-article-mime-handle-alist)
3768 (make-local-variable 'gnus-article-wash-types)
3769 (make-local-variable 'gnus-article-image-alist)
3770 (make-local-variable 'gnus-article-charset)
3771 (make-local-variable 'gnus-article-ignored-charsets)
3772 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3773 (set (make-local-variable 'nobreak-char-display) nil)
3774 (gnus-set-default-directory)
3775 (buffer-disable-undo)
3776 (setq buffer-read-only t)
3777 (set-syntax-table gnus-article-mode-syntax-table)
3778 (mm-enable-multibyte)
3779 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3780
3781 (defun gnus-article-setup-buffer ()
3782 "Initialize the article buffer."
3783 (let* ((name (if gnus-single-article-buffer "*Article*"
3784 (concat "*Article " gnus-newsgroup-name "*")))
3785 (original
3786 (progn (string-match "\\*Article" name)
3787 (concat " *Original Article"
3788 (substring name (match-end 0))))))
3789 (setq gnus-article-buffer name)
3790 (setq gnus-original-article-buffer original)
3791 (setq gnus-article-mime-handle-alist nil)
3792 ;; This might be a variable local to the summary buffer.
3793 (unless gnus-single-article-buffer
3794 (save-excursion
3795 (set-buffer gnus-summary-buffer)
3796 (setq gnus-article-buffer name)
3797 (setq gnus-original-article-buffer original)
3798 (gnus-set-global-variables)))
3799 (gnus-article-setup-highlight-words)
3800 ;; Init original article buffer.
3801 (save-excursion
3802 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3803 (mm-enable-multibyte)
3804 (setq major-mode 'gnus-original-article-mode)
3805 (make-local-variable 'gnus-original-article))
3806 (if (and (get-buffer name)
3807 (with-current-buffer name
3808 (if gnus-article-edit-mode
3809 (if (y-or-n-p "Article mode edit in progress; discard? ")
3810 (progn
3811 (set-buffer-modified-p nil)
3812 (gnus-kill-buffer name)
3813 (message "")
3814 nil)
3815 (error "Action aborted"))
3816 t)))
3817 (save-excursion
3818 (set-buffer name)
3819 (set (make-local-variable 'gnus-article-edit-mode) nil)
3820 (when gnus-article-mime-handles
3821 (mm-destroy-parts gnus-article-mime-handles)
3822 (setq gnus-article-mime-handles nil))
3823 ;; Set it to nil in article-buffer!
3824 (setq gnus-article-mime-handle-alist nil)
3825 (buffer-disable-undo)
3826 (setq buffer-read-only t)
3827 ;; This list just keeps growing if we don't reset it.
3828 (setq gnus-button-marker-list nil)
3829 (unless (eq major-mode 'gnus-article-mode)
3830 (gnus-article-mode))
3831 (current-buffer))
3832 (save-excursion
3833 (set-buffer (gnus-get-buffer-create name))
3834 (gnus-article-mode)
3835 (make-local-variable 'gnus-summary-buffer)
3836 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3837 (current-buffer)))))
3838
3839 ;; Set article window start at LINE, where LINE is the number of lines
3840 ;; from the head of the article.
3841 (defun gnus-article-set-window-start (&optional line)
3842 (set-window-start
3843 (gnus-get-buffer-window gnus-article-buffer t)
3844 (save-excursion
3845 (set-buffer gnus-article-buffer)
3846 (goto-char (point-min))
3847 (if (not line)
3848 (point-min)
3849 (gnus-message 6 "Moved to bookmark")
3850 (search-forward "\n\n" nil t)
3851 (forward-line line)
3852 (point)))))
3853
3854 (defun gnus-article-prepare (article &optional all-headers header)
3855 "Prepare ARTICLE in article mode buffer.
3856 ARTICLE should either be an article number or a Message-ID.
3857 If ARTICLE is an id, HEADER should be the article headers.
3858 If ALL-HEADERS is non-nil, no headers are hidden."
3859 (save-excursion
3860 ;; Make sure we start in a summary buffer.
3861 (unless (eq major-mode 'gnus-summary-mode)
3862 (set-buffer gnus-summary-buffer))
3863 (setq gnus-summary-buffer (current-buffer))
3864 (let* ((gnus-article (if header (mail-header-number header) article))
3865 (summary-buffer (current-buffer))
3866 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3867 (group gnus-newsgroup-name)
3868 result)
3869 (save-excursion
3870 (gnus-article-setup-buffer)
3871 (set-buffer gnus-article-buffer)
3872 ;; Deactivate active regions.
3873 (when (and (boundp 'transient-mark-mode)
3874 transient-mark-mode)
3875 (setq mark-active nil))
3876 (if (not (setq result (let ((inhibit-read-only t))
3877 (gnus-request-article-this-buffer
3878 article group))))
3879 ;; There is no such article.
3880 (save-excursion
3881 (when (and (numberp article)
3882 (not (memq article gnus-newsgroup-sparse)))
3883 (setq gnus-article-current
3884 (cons gnus-newsgroup-name article))
3885 (set-buffer gnus-summary-buffer)
3886 (setq gnus-current-article article)
3887 (if (and (memq article gnus-newsgroup-undownloaded)
3888 (not (gnus-online (gnus-find-method-for-group
3889 gnus-newsgroup-name))))
3890 (progn
3891 (gnus-summary-set-agent-mark article)
3892 (message "Message marked for downloading"))
3893 (gnus-summary-mark-article article gnus-canceled-mark)
3894 (unless (memq article gnus-newsgroup-sparse)
3895 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3896 (if (or (eq result 'pseudo)
3897 (eq result 'nneething))
3898 (progn
3899 (save-excursion
3900 (set-buffer summary-buffer)
3901 (push article gnus-newsgroup-history)
3902 (setq gnus-last-article gnus-current-article
3903 gnus-current-article 0
3904 gnus-current-headers nil
3905 gnus-article-current nil)
3906 (if (eq result 'nneething)
3907 (gnus-configure-windows 'summary)
3908 (gnus-configure-windows 'article))
3909 (gnus-set-global-variables))
3910 (let ((gnus-article-mime-handle-alist-1
3911 gnus-article-mime-handle-alist))
3912 (gnus-set-mode-line 'article)))
3913 ;; The result from the `request' was an actual article -
3914 ;; or at least some text that is now displayed in the
3915 ;; article buffer.
3916 (when (and (numberp article)
3917 (not (eq article gnus-current-article)))
3918 ;; Seems like a new article has been selected.
3919 ;; `gnus-current-article' must be an article number.
3920 (save-excursion
3921 (set-buffer summary-buffer)
3922 (push article gnus-newsgroup-history)
3923 (setq gnus-last-article gnus-current-article
3924 gnus-current-article article
3925 gnus-current-headers
3926 (gnus-summary-article-header gnus-current-article)
3927 gnus-article-current
3928 (cons gnus-newsgroup-name gnus-current-article))
3929 (unless (vectorp gnus-current-headers)
3930 (setq gnus-current-headers nil))
3931 (gnus-summary-goto-subject gnus-current-article)
3932 (when (gnus-summary-show-thread)
3933 ;; If the summary buffer really was folded, the
3934 ;; previous goto may not actually have gone to
3935 ;; the right article, but the thread root instead.
3936 ;; So we go again.
3937 (gnus-summary-goto-subject gnus-current-article))
3938 (gnus-run-hooks 'gnus-mark-article-hook)
3939 (gnus-set-mode-line 'summary)
3940 (when (gnus-visual-p 'article-highlight 'highlight)
3941 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3942 ;; Set the global newsgroup variables here.
3943 (gnus-set-global-variables)
3944 (setq gnus-have-all-headers
3945 (or all-headers gnus-show-all-headers))))
3946 (save-excursion
3947 (gnus-configure-windows 'article))
3948 (when (or (numberp article)
3949 (stringp article))
3950 (gnus-article-prepare-display)
3951 ;; Do page break.
3952 (goto-char (point-min))
3953 (when gnus-break-pages
3954 (gnus-narrow-to-page)))
3955 (let ((gnus-article-mime-handle-alist-1
3956 gnus-article-mime-handle-alist))
3957 (gnus-set-mode-line 'article))
3958 (article-goto-body)
3959 (unless (bobp)
3960 (forward-line -1))
3961 (set-window-point (get-buffer-window (current-buffer)) (point))
3962 (gnus-configure-windows 'article)
3963 t))))))
3964
3965 ;;;###autoload
3966 (defun gnus-article-prepare-display ()
3967 "Make the current buffer look like a nice article."
3968 ;; Hooks for getting information from the article.
3969 ;; This hook must be called before being narrowed.
3970 (let ((gnus-article-buffer (current-buffer))
3971 buffer-read-only
3972 (inhibit-read-only t))
3973 (unless (eq major-mode 'gnus-article-mode)
3974 (gnus-article-mode))
3975 (setq buffer-read-only nil
3976 gnus-article-wash-types nil
3977 gnus-article-image-alist nil)
3978 (gnus-run-hooks 'gnus-tmp-internal-hook)
3979 (when gnus-display-mime-function
3980 (funcall gnus-display-mime-function))
3981 (gnus-run-hooks 'gnus-article-prepare-hook)))
3982
3983 ;;;
3984 ;;; Gnus MIME viewing functions
3985 ;;;
3986
3987 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3988 "Format of the MIME buttons.
3989
3990 Valid specifiers include:
3991 %t The MIME type
3992 %T MIME type, along with additional info
3993 %n The `name' parameter
3994 %d The description, if any
3995 %l The length of the encoded part
3996 %p The part identifier number
3997 %e Dots if the part isn't displayed
3998
3999 General format specifiers can also be used. See Info node
4000 `(gnus)Formatting Variables'.")
4001
4002 (defvar gnus-mime-button-line-format-alist
4003 '((?t gnus-tmp-type ?s)
4004 (?T gnus-tmp-type-long ?s)
4005 (?n gnus-tmp-name ?s)
4006 (?d gnus-tmp-description ?s)
4007 (?p gnus-tmp-id ?s)
4008 (?l gnus-tmp-length ?d)
4009 (?e gnus-tmp-dots ?s)))
4010
4011 (defvar gnus-mime-button-commands
4012 '((gnus-article-press-button "\r" "Toggle Display")
4013 (gnus-mime-view-part "v" "View Interactively...")
4014 (gnus-mime-view-part-as-type "t" "View As Type...")
4015 (gnus-mime-view-part-as-charset "C" "View As charset...")
4016 (gnus-mime-save-part "o" "Save...")
4017 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4018 (gnus-mime-delete-part "d" "Delete part")
4019 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4020 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4021 (gnus-mime-view-part-internally "E" "View Internally")
4022 (gnus-mime-view-part-externally "e" "View Externally")
4023 (gnus-mime-print-part "p" "Print")
4024 (gnus-mime-pipe-part "|" "Pipe To Command...")
4025 (gnus-mime-action-on-part "." "Take action on the part...")))
4026
4027 (defun gnus-article-mime-part-status ()
4028 (if gnus-article-mime-handle-alist-1
4029 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4030 " (1 part)"
4031 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4032 ""))
4033
4034 (defvar gnus-mime-button-map
4035 (let ((map (make-sparse-keymap)))
4036 (unless (>= (string-to-number emacs-version) 21)
4037 ;; XEmacs doesn't care.
4038 (set-keymap-parent map gnus-article-mode-map))
4039 (define-key map gnus-mouse-2 'gnus-article-push-button)
4040 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4041 (dolist (c gnus-mime-button-commands)
4042 (define-key map (cadr c) (car c)))
4043 map))
4044
4045 (easy-menu-define
4046 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4047 `("MIME Part"
4048 ,@(mapcar (lambda (c)
4049 (vector (caddr c) (car c) :enable t))
4050 gnus-mime-button-commands)))
4051
4052 (eval-when-compile
4053 (define-compiler-macro popup-menu (&whole form
4054 menu &optional position prefix)
4055 (if (and (fboundp 'popup-menu)
4056 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4057 form
4058 ;; Gnus is probably running under Emacs 20.
4059 `(let* ((menu (cdr ,menu))
4060 (response (x-popup-menu
4061 t (list (car menu)
4062 (cons "" (mapcar (lambda (c)
4063 (cons (caddr c) (car c)))
4064 (cdr menu)))))))
4065 (if response
4066 (call-interactively (nth 3 (assq response menu))))))))
4067
4068 (defun gnus-mime-button-menu (event prefix)
4069 "Construct a context-sensitive menu of MIME commands."
4070 (interactive "e\nP")
4071 (save-window-excursion
4072 (let ((pos (event-start event)))
4073 (select-window (posn-window pos))
4074 (goto-char (posn-point pos))
4075 (gnus-article-check-buffer)
4076 (popup-menu gnus-mime-button-menu nil prefix))))
4077
4078 (defun gnus-mime-view-all-parts (&optional handles)
4079 "View all the MIME parts."
4080 (interactive)
4081 (save-current-buffer
4082 (set-buffer gnus-article-buffer)
4083 (let ((handles (or handles gnus-article-mime-handles))
4084 (mail-parse-charset gnus-newsgroup-charset)
4085 (mail-parse-ignored-charsets
4086 (with-current-buffer gnus-summary-buffer
4087 gnus-newsgroup-ignored-charsets)))
4088 (when handles
4089 (mm-remove-parts handles)
4090 (goto-char (point-min))
4091 (or (search-forward "\n\n") (goto-char (point-max)))
4092 (let ((inhibit-read-only t))
4093 (delete-region (point) (point-max))
4094 (mm-display-parts handles))))))
4095
4096 (defun gnus-mime-save-part-and-strip ()
4097 "Save the MIME part under point then replace it with an external body."
4098 (interactive)
4099 (gnus-article-check-buffer)
4100 (when (gnus-group-read-only-p)
4101 (error "The current group does not support deleting of parts"))
4102 (when (mm-complicated-handles gnus-article-mime-handles)
4103 (error "\
4104 The current article has a complicated MIME structure, giving up..."))
4105 (when (gnus-yes-or-no-p "\
4106 Deleting parts may malfunction or destroy the article; continue? ")
4107 (let* ((data (get-text-property (point) 'gnus-data))
4108 file param
4109 (handles gnus-article-mime-handles))
4110 (setq file (and data (mm-save-part data)))
4111 (when file
4112 (with-current-buffer (mm-handle-buffer data)
4113 (erase-buffer)
4114 (insert "Content-Type: " (mm-handle-media-type data))
4115 (mml-insert-parameter-string (cdr (mm-handle-type data))
4116 '(charset))
4117 (insert "\n")
4118 (insert "Content-ID: " (message-make-message-id) "\n")
4119 (insert "Content-Transfer-Encoding: binary\n")
4120 (insert "\n"))
4121 (setcdr data
4122 (cdr (mm-make-handle nil
4123 `("message/external-body"
4124 (access-type . "LOCAL-FILE")
4125 (name . ,file)))))
4126 (set-buffer gnus-summary-buffer)
4127 (gnus-article-edit-article
4128 `(lambda ()
4129 (erase-buffer)
4130 (let ((mail-parse-charset (or gnus-article-charset
4131 ',gnus-newsgroup-charset))
4132 (mail-parse-ignored-charsets
4133 (or gnus-article-ignored-charsets
4134 ',gnus-newsgroup-ignored-charsets))
4135 (mbl mml-buffer-list))
4136 (setq mml-buffer-list nil)
4137 (insert-buffer-substring gnus-original-article-buffer)
4138 (mime-to-mml ',handles)
4139 (setq gnus-article-mime-handles nil)
4140 (let ((mbl1 mml-buffer-list))
4141 (setq mml-buffer-list mbl)
4142 (set (make-local-variable 'mml-buffer-list) mbl1))
4143 (gnus-make-local-hook 'kill-buffer-hook)
4144 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4145 `(lambda (no-highlight)
4146 (let ((mail-parse-charset (or gnus-article-charset
4147 ',gnus-newsgroup-charset))
4148 (message-options message-options)
4149 (message-options-set-recipient)
4150 (mail-parse-ignored-charsets
4151 (or gnus-article-ignored-charsets
4152 ',gnus-newsgroup-ignored-charsets)))
4153 (mml-to-mime)
4154 (mml-destroy-buffers)
4155 (remove-hook 'kill-buffer-hook
4156 'mml-destroy-buffers t)
4157 (kill-local-variable 'mml-buffer-list))
4158 (gnus-summary-edit-article-done
4159 ,(or (mail-header-references gnus-current-headers) "")
4160 ,(gnus-group-read-only-p)
4161 ,gnus-summary-buffer no-highlight)))))))
4162
4163 (defun gnus-mime-delete-part ()
4164 "Delete the MIME part under point.
4165 Replace it with some information about the removed part."
4166 (interactive)
4167 (gnus-article-check-buffer)
4168 (when (gnus-group-read-only-p)
4169 (error "The current group does not support deleting of parts"))
4170 (when (mm-complicated-handles gnus-article-mime-handles)
4171 (error "\
4172 The current article has a complicated MIME structure, giving up..."))
4173 (when (gnus-yes-or-no-p "\
4174 Deleting parts may malfunction or destroy the article; continue? ")
4175 (let* ((data (get-text-property (point) 'gnus-data))
4176 (handles gnus-article-mime-handles)
4177 (none "(none)")
4178 (description
4179 (or
4180 (mail-decode-encoded-word-string (or (mm-handle-description data)
4181 none))))
4182 (filename
4183 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4184 none))
4185 (type (mm-handle-media-type data)))
4186 (unless data
4187 (error "No MIME part under point"))
4188 (with-current-buffer (mm-handle-buffer data)
4189 (let ((bsize (format "%s" (buffer-size))))
4190 (erase-buffer)
4191 (insert
4192 (concat
4193 ",----\n"
4194 "| The following attachment has been deleted:\n"
4195 "|\n"
4196 "| Type: " type "\n"
4197 "| Filename: " filename "\n"
4198 "| Size (encoded): " bsize " Byte\n"
4199 "| Description: " description "\n"
4200 "`----\n"))
4201 (setcdr data
4202 (cdr (mm-make-handle
4203 nil `("text/plain") nil nil
4204 (list "attachment")
4205 (format "Deleted attachment (%s bytes)" bsize))))))
4206 (set-buffer gnus-summary-buffer)
4207 ;; FIXME: maybe some of the following code (borrowed from
4208 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4209 (gnus-article-edit-article
4210 `(lambda ()
4211 (erase-buffer)
4212 (let ((mail-parse-charset (or gnus-article-charset
4213 ',gnus-newsgroup-charset))
4214 (mail-parse-ignored-charsets
4215 (or gnus-article-ignored-charsets
4216 ',gnus-newsgroup-ignored-charsets))
4217 (mbl mml-buffer-list))
4218 (setq mml-buffer-list nil)
4219 (insert-buffer-substring gnus-original-article-buffer)
4220 (mime-to-mml ',handles)
4221 (setq gnus-article-mime-handles nil)
4222 (let ((mbl1 mml-buffer-list))
4223 (setq mml-buffer-list mbl)
4224 (set (make-local-variable 'mml-buffer-list) mbl1))
4225 (gnus-make-local-hook 'kill-buffer-hook)
4226 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4227 `(lambda (no-highlight)
4228 (let ((mail-parse-charset (or gnus-article-charset
4229 ',gnus-newsgroup-charset))
4230 (message-options message-options)
4231 (message-options-set-recipient)
4232 (mail-parse-ignored-charsets
4233 (or gnus-article-ignored-charsets
4234 ',gnus-newsgroup-ignored-charsets)))
4235 (mml-to-mime)
4236 (mml-destroy-buffers)
4237 (remove-hook 'kill-buffer-hook
4238 'mml-destroy-buffers t)
4239 (kill-local-variable 'mml-buffer-list))
4240 (gnus-summary-edit-article-done
4241 ,(or (mail-header-references gnus-current-headers) "")
4242 ,(gnus-group-read-only-p)
4243 ,gnus-summary-buffer no-highlight)))))
4244 ;; Not in `gnus-mime-save-part-and-strip':
4245 (gnus-article-edit-done)
4246 (gnus-summary-expand-window)
4247 (gnus-summary-show-article))
4248
4249 (defun gnus-mime-save-part ()
4250 "Save the MIME part under point."
4251 (interactive)
4252 (gnus-article-check-buffer)
4253 (let ((data (get-text-property (point) 'gnus-data)))
4254 (when data
4255 (mm-save-part data))))
4256
4257 (defun gnus-mime-pipe-part ()
4258 "Pipe the MIME part under point to a process."
4259 (interactive)
4260 (gnus-article-check-buffer)
4261 (let ((data (get-text-property (point) 'gnus-data)))
4262 (when data
4263 (mm-pipe-part data))))
4264
4265 (defun gnus-mime-view-part ()
4266 "Interactively choose a viewing method for the MIME part under point."
4267 (interactive)
4268 (gnus-article-check-buffer)
4269 (let ((data (get-text-property (point) 'gnus-data)))
4270 (when data
4271 (setq gnus-article-mime-handles
4272 (mm-merge-handles
4273 gnus-article-mime-handles (setq data (copy-sequence data))))
4274 (mm-interactively-view-part data))))
4275
4276 (defun gnus-mime-view-part-as-type-internal ()
4277 (gnus-article-check-buffer)
4278 (let* ((name (mail-content-type-get
4279 (mm-handle-type (get-text-property (point) 'gnus-data))
4280 'name))
4281 (def-type (and name (mm-default-file-encoding name))))
4282 (and def-type (cons def-type 0))))
4283
4284 (defun gnus-mime-view-part-as-type (&optional mime-type)
4285 "Choose a MIME media type, and view the part as such."
4286 (interactive)
4287 (unless mime-type
4288 (setq mime-type (completing-read
4289 "View as MIME type: "
4290 (mapcar #'list (mailcap-mime-types))
4291 nil nil
4292 (gnus-mime-view-part-as-type-internal))))
4293 (gnus-article-check-buffer)
4294 (let ((handle (get-text-property (point) 'gnus-data)))
4295 (when handle
4296 (setq handle
4297 (mm-make-handle (mm-handle-buffer handle)
4298 (cons mime-type (cdr (mm-handle-type handle)))
4299 (mm-handle-encoding handle)
4300 (mm-handle-undisplayer handle)
4301 (mm-handle-disposition handle)
4302 (mm-handle-description handle)
4303 nil
4304 (mm-handle-id handle)))
4305 (setq gnus-article-mime-handles
4306 (mm-merge-handles gnus-article-mime-handles handle))
4307 (gnus-mm-display-part handle))))
4308
4309 (eval-when-compile
4310 (require 'jka-compr))
4311
4312 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4313 ;; emacs can do that itself.
4314 ;;
4315 (defun gnus-mime-jka-compr-maybe-uncompress ()
4316 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4317 The uncompress method used is derived from `buffer-file-name'."
4318 (when (and (fboundp 'jka-compr-installed-p)
4319 (jka-compr-installed-p))
4320 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4321 (when info
4322 (let ((basename (file-name-nondirectory buffer-file-name))
4323 (args (jka-compr-info-uncompress-args info))
4324 (prog (jka-compr-info-uncompress-program info))
4325 (message (jka-compr-info-uncompress-message info))
4326 (err-file (jka-compr-make-temp-name)))
4327 (if message
4328 (message "%s %s..." message basename))
4329 (unwind-protect
4330 (unless (memq (apply 'call-process-region
4331 (point-min) (point-max)
4332 prog
4333 t (list t err-file) nil
4334 args)
4335 jka-compr-acceptable-retval-list)
4336 (jka-compr-error prog args basename message err-file))
4337 (jka-compr-delete-temp-file err-file)))))))
4338
4339 (defun gnus-mime-copy-part (&optional handle)
4340 "Put the MIME part under point into a new buffer.
4341 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4342 are decompressed."
4343 (interactive)
4344 (gnus-article-check-buffer)
4345 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4346 (contents (and handle (mm-get-part handle)))
4347 (base (and handle
4348 (file-name-nondirectory
4349 (or
4350 (mail-content-type-get (mm-handle-type handle) 'name)
4351 (mail-content-type-get (mm-handle-disposition handle)
4352 'filename)
4353 "*decoded*"))))
4354 (buffer (and base (generate-new-buffer base))))
4355 (when contents
4356 (switch-to-buffer buffer)
4357 (insert contents)
4358 ;; We do it this way to make `normal-mode' set the appropriate mode.
4359 (unwind-protect
4360 (progn
4361 (setq buffer-file-name (expand-file-name base))
4362 (gnus-mime-jka-compr-maybe-uncompress)
4363 (normal-mode))
4364 (setq buffer-file-name nil))
4365 (goto-char (point-min)))))
4366
4367 (defun gnus-mime-print-part (&optional handle filename)
4368 "Print the MIME part under point."
4369 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4370 (gnus-article-check-buffer)
4371 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4372 (contents (and handle (mm-get-part handle)))
4373 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4374 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4375 (when contents
4376 (if printer
4377 (unwind-protect
4378 (progn
4379 (mm-save-part-to-file handle file)
4380 (call-process shell-file-name nil
4381 (generate-new-buffer " *mm*")
4382 nil
4383 shell-command-switch
4384 (mm-mailcap-command
4385 printer file (mm-handle-type handle))))
4386 (delete-file file))
4387 (with-temp-buffer
4388 (insert contents)
4389 (gnus-print-buffer))
4390 (ps-despool filename)))))
4391
4392 (defun gnus-mime-inline-part (&optional handle arg)
4393 "Insert the MIME part under point into the current buffer."
4394 (interactive (list nil current-prefix-arg))
4395 (gnus-article-check-buffer)
4396 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4397 contents charset
4398 (b (point))
4399 (inhibit-read-only t))
4400 (when handle
4401 (if (and (not arg) (mm-handle-undisplayer handle))
4402 (mm-remove-part handle)
4403 (setq contents (mm-get-part handle))
4404 (cond
4405 ((not arg)
4406 (setq charset (or (mail-content-type-get
4407 (mm-handle-type handle) 'charset)
4408 gnus-newsgroup-charset)))
4409 ((numberp arg)
4410 (if (mm-handle-undisplayer handle)
4411 (mm-remove-part handle))
4412 (setq charset
4413 (or (cdr (assq arg
4414 gnus-summary-show-article-charset-alist))
4415 (mm-read-coding-system "Charset: "))))
4416 (t
4417 (if (mm-handle-undisplayer handle)
4418 (mm-remove-part handle))))
4419 (forward-line 2)
4420 (mm-insert-inline
4421 handle
4422 (if (and charset
4423 (setq charset (mm-charset-to-coding-system
4424 charset))
4425 (not (eq charset 'ascii)))
4426 (mm-decode-coding-string contents charset)
4427 (mm-string-to-multibyte contents)))
4428 (goto-char b)))))
4429
4430 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4431 "Insert the MIME part under point into the current buffer using the
4432 specified charset."
4433 (interactive (list nil current-prefix-arg))
4434 (gnus-article-check-buffer)
4435 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4436 contents charset
4437 (b (point))
4438 (inhibit-read-only t))
4439 (when handle
4440 (if (mm-handle-undisplayer handle)
4441 (mm-remove-part handle))
4442 (let ((gnus-newsgroup-charset
4443 (or (cdr (assq arg
4444 gnus-summary-show-article-charset-alist))
4445 (mm-read-coding-system "Charset: ")))
4446 (gnus-newsgroup-ignored-charsets 'gnus-all))
4447 (gnus-article-press-button)))))
4448
4449 (defun gnus-mime-view-part-externally (&optional handle)
4450 "View the MIME part under point with an external viewer."
4451 (interactive)
4452 (gnus-article-check-buffer)
4453 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4454 (mm-user-display-methods nil)
4455 (mm-inlined-types nil)
4456 (mail-parse-charset gnus-newsgroup-charset)
4457 (mail-parse-ignored-charsets
4458 (save-excursion (set-buffer gnus-summary-buffer)
4459 gnus-newsgroup-ignored-charsets)))
4460 (when handle
4461 (if (mm-handle-undisplayer handle)
4462 (mm-remove-part handle)
4463 (mm-display-part handle)))))
4464
4465 (defun gnus-mime-view-part-internally (&optional handle)
4466 "View the MIME part under point with an internal viewer.
4467 If no internal viewer is available, use an external viewer."
4468 (interactive)
4469 (gnus-article-check-buffer)
4470 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4471 (mm-inlined-types '(".*"))
4472 (mm-inline-large-images t)
4473 (mail-parse-charset gnus-newsgroup-charset)
4474 (mail-parse-ignored-charsets
4475 (save-excursion (set-buffer gnus-summary-buffer)
4476 gnus-newsgroup-ignored-charsets))
4477 (inhibit-read-only t))
4478 (when handle
4479 (if (mm-handle-undisplayer handle)
4480 (mm-remove-part handle)
4481 (mm-display-part handle)))))
4482
4483 (defun gnus-mime-action-on-part (&optional action)
4484 "Do something with the MIME attachment at \(point\)."
4485 (interactive
4486 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4487 (gnus-article-check-buffer)
4488 (let ((action-pair (assoc action gnus-mime-action-alist)))
4489 (if action-pair
4490 (funcall (cdr action-pair)))))
4491
4492 (defun gnus-article-part-wrapper (n function)
4493 (save-current-buffer
4494 (set-buffer gnus-article-buffer)
4495 (when (> n (length gnus-article-mime-handle-alist))
4496 (error "No such part"))
4497 (gnus-article-goto-part n)
4498 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4499 (funcall function handle))))
4500
4501 (defun gnus-article-pipe-part (n)
4502 "Pipe MIME part N, which is the numerical prefix."
4503 (interactive "p")
4504 (gnus-article-part-wrapper n 'mm-pipe-part))
4505
4506 (defun gnus-article-save-part (n)
4507 "Save MIME part N, which is the numerical prefix."
4508 (interactive "p")
4509 (gnus-article-part-wrapper n 'mm-save-part))
4510
4511 (defun gnus-article-interactively-view-part (n)
4512 "View MIME part N interactively, which is the numerical prefix."
4513 (interactive "p")
4514 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4515
4516 (defun gnus-article-copy-part (n)
4517 "Copy MIME part N, which is the numerical prefix."
4518 (interactive "p")
4519 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4520
4521 (defun gnus-article-view-part-as-charset (n)
4522 "View MIME part N using a specified charset.
4523 N is the numerical prefix."
4524 (interactive "p")
4525 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4526
4527 (defun gnus-article-view-part-externally (n)
4528 "View MIME part N externally, which is the numerical prefix."
4529 (interactive "p")
4530 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4531
4532 (defun gnus-article-inline-part (n)
4533 "Inline MIME part N, which is the numerical prefix."
4534 (interactive "p")
4535 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4536
4537 (defun gnus-article-mime-match-handle-first (condition)
4538 (if condition
4539 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4540 (while (setq ihandle (pop alist))
4541 (if (and (cond
4542 ((functionp condition)
4543 (funcall condition (cdr ihandle)))
4544 ((eq condition 'undisplayed)
4545 (not (or (mm-handle-undisplayer (cdr ihandle))
4546 (equal (mm-handle-media-type (cdr ihandle))
4547 "multipart/alternative"))))
4548 ((eq condition 'undisplayed-alternative)
4549 (not (mm-handle-undisplayer (cdr ihandle))))
4550 (t t))
4551 (gnus-article-goto-part (car ihandle))
4552 (or (not n) (< (car ihandle) n)))
4553 (setq n (car ihandle))))
4554 (or n 1))
4555 1))
4556
4557 (defun gnus-article-view-part (&optional n)
4558 "View MIME part N, which is the numerical prefix."
4559 (interactive "P")
4560 (save-current-buffer
4561 (set-buffer gnus-article-buffer)
4562 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4563 gnus-article-mime-match-handle-function)))
4564 (when (> n (length gnus-article-mime-handle-alist))
4565 (error "No such part"))
4566 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4567 (when (gnus-article-goto-part n)
4568 (if (equal (car handle) "multipart/alternative")
4569 (gnus-article-press-button)
4570 (when (eq (gnus-mm-display-part handle) 'internal)
4571 (gnus-set-window-start)))))))
4572
4573 (defsubst gnus-article-mime-total-parts ()
4574 (if (bufferp (car gnus-article-mime-handles))
4575 1 ;; single part
4576 (1- (length gnus-article-mime-handles))))
4577
4578 (defun gnus-mm-display-part (handle)
4579 "Display HANDLE and fix MIME button."
4580 (let ((id (get-text-property (point) 'gnus-part))
4581 (point (point))
4582 (inhibit-read-only t))
4583 (forward-line 1)
4584 (prog1
4585 (let ((window (selected-window))
4586 (mail-parse-charset gnus-newsgroup-charset)
4587 (mail-parse-ignored-charsets
4588 (if (gnus-buffer-live-p gnus-summary-buffer)
4589 (save-excursion
4590 (set-buffer gnus-summary-buffer)
4591 gnus-newsgroup-ignored-charsets)
4592 nil)))
4593 (save-excursion
4594 (unwind-protect
4595 (let ((win (gnus-get-buffer-window (current-buffer) t))
4596 (beg (point)))
4597 (when win
4598 (select-window win))
4599 (goto-char point)
4600 (forward-line)
4601 (if (mm-handle-displayed-p handle)
4602 ;; This will remove the part.
4603 (mm-display-part handle)
4604 (save-restriction
4605 (narrow-to-region (point)
4606 (if (eobp) (point) (1+ (point))))
4607 (mm-display-part handle)
4608 ;; We narrow to the part itself and
4609 ;; then call the treatment functions.
4610 (goto-char (point-min))
4611 (forward-line 1)
4612 (narrow-to-region (point) (point-max))
4613 (gnus-treat-article
4614 nil id
4615 (gnus-article-mime-total-parts)
4616 (mm-handle-media-type handle)))))
4617 (if (window-live-p window)
4618 (select-window window)))))
4619 (goto-char point)
4620 (gnus-delete-line)
4621 (gnus-insert-mime-button
4622 handle id (list (mm-handle-displayed-p handle)))
4623 (goto-char point))))
4624
4625 (defun gnus-article-goto-part (n)
4626 "Go to MIME part N."
4627 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4628
4629 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4630 (let ((gnus-tmp-name
4631 (or (mail-content-type-get (mm-handle-type handle) 'name)
4632 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4633 (mail-content-type-get (mm-handle-type handle) 'url)
4634 ""))
4635 (gnus-tmp-type (mm-handle-media-type handle))
4636 (gnus-tmp-description
4637 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4638 "")))
4639 (gnus-tmp-dots
4640 (if (if displayed (car displayed)
4641 (mm-handle-displayed-p handle))
4642 "" "..."))
4643 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4644 (buffer-size)))
4645 gnus-tmp-type-long b e)
4646 (when (string-match ".*/" gnus-tmp-name)
4647 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4648 (setq gnus-tmp-type-long (concat gnus-tmp-type
4649 (and (not (equal gnus-tmp-name ""))
4650 (concat "; " gnus-tmp-name))))
4651 (unless (equal gnus-tmp-description "")
4652 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4653 (unless (bolp)
4654 (insert "\n"))
4655 (setq b (point))
4656 (gnus-eval-format
4657 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4658 `(,@(gnus-local-map-property gnus-mime-button-map)
4659 gnus-callback gnus-mm-display-part
4660 gnus-part ,gnus-tmp-id
4661 article-type annotation
4662 gnus-data ,handle))
4663 (setq e (if (bolp)
4664 ;; Exclude a newline.
4665 (1- (point))
4666 (point)))
4667 (widget-convert-button
4668 'link b e
4669 :mime-handle handle
4670 :action 'gnus-widget-press-button
4671 :button-keymap gnus-mime-button-map
4672 :help-echo
4673 (lambda (widget/window &optional overlay pos)
4674 ;; Needed to properly clear the message due to a bug in
4675 ;; wid-edit (XEmacs only).
4676 (if (boundp 'help-echo-owns-message)
4677 (setq help-echo-owns-message t))
4678 (format
4679 "%S: %s the MIME part; %S: more options"
4680 (aref gnus-mouse-2 0)
4681 ;; XEmacs will get a single widget arg; Emacs 21 will get
4682 ;; window, overlay, position.
4683 (if (mm-handle-displayed-p
4684 (if overlay
4685 (with-current-buffer (gnus-overlay-buffer overlay)
4686 (widget-get (widget-at (gnus-overlay-start overlay))
4687 :mime-handle))
4688 (widget-get widget/window :mime-handle)))
4689 "hide" "show")
4690 (aref gnus-down-mouse-3 0))))))
4691
4692 (defun gnus-widget-press-button (elems el)
4693 (goto-char (widget-get elems :from))
4694 (gnus-article-press-button))
4695
4696 (defvar gnus-displaying-mime nil)
4697
4698 (defun gnus-display-mime (&optional ihandles)
4699 "Display the MIME parts."
4700 (save-excursion
4701 (save-selected-window
4702 (let ((window (get-buffer-window gnus-article-buffer))
4703 (point (point)))
4704 (when window
4705 (select-window window)
4706 ;; We have to do this since selecting the window
4707 ;; may change the point. So we set the window point.
4708 (set-window-point window point)))
4709 (let* ((handles (or ihandles
4710 (mm-dissect-buffer nil gnus-article-loose-mime)
4711 (and gnus-article-emulate-mime
4712 (mm-uu-dissect))))
4713 (inhibit-read-only t) handle name type b e display)
4714 (when (and (not ihandles)
4715 (not gnus-displaying-mime))
4716 ;; Top-level call; we clean up.
4717 (when gnus-article-mime-handles
4718 (mm-destroy-parts gnus-article-mime-handles)
4719 (setq gnus-article-mime-handle-alist nil));; A trick.
4720 (setq gnus-article-mime-handles handles)
4721 ;; We allow users to glean info from the handles.
4722 (when gnus-article-mime-part-function
4723 (gnus-mime-part-function handles)))
4724 (if (and handles
4725 (or (not (stringp (car handles)))
4726 (cdr handles)))
4727 (progn
4728 (when (and (not ihandles)
4729 (not gnus-displaying-mime))
4730 ;; Clean up for mime parts.
4731 (article-goto-body)
4732 (delete-region (point) (point-max)))
4733 (let ((gnus-displaying-mime t))
4734 (gnus-mime-display-part handles)))
4735 (save-restriction
4736 (article-goto-body)
4737 (narrow-to-region (point) (point-max))
4738 (gnus-treat-article nil 1 1)
4739 (widen)))
4740 (unless ihandles
4741 ;; Highlight the headers.
4742 (save-excursion
4743 (save-restriction
4744 (article-goto-body)
4745 (narrow-to-region (point-min) (point))
4746 (gnus-article-save-original-date
4747 (gnus-treat-article 'head)))))))))
4748
4749 (defcustom gnus-mime-display-multipart-as-mixed nil
4750 "Display \"multipart\" parts as \"multipart/mixed\".
4751
4752 If t, it overrides nil values of
4753 `gnus-mime-display-multipart-alternative-as-mixed' and
4754 `gnus-mime-display-multipart-related-as-mixed'."
4755 :group 'gnus-article-mime
4756 :type 'boolean)
4757
4758 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4759 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4760 :version "22.1"
4761 :group 'gnus-article-mime
4762 :type 'boolean)
4763
4764 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4765 "Display \"multipart/related\" parts as \"multipart/mixed\".
4766
4767 If displaying \"text/html\" is discouraged \(see
4768 `mm-discouraged-alternatives'\) images or other material inside a
4769 \"multipart/related\" part might be overlooked when this variable is nil."
4770 :version "22.1"
4771 :group 'gnus-article-mime
4772 :type 'boolean)
4773
4774 (defun gnus-mime-display-part (handle)
4775 (cond
4776 ;; Maybe a broken MIME message.
4777 ((null handle))
4778 ;; Single part.
4779 ((not (stringp (car handle)))
4780 (gnus-mime-display-single handle))
4781 ;; User-defined multipart
4782 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4783 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4784 handle))
4785 ;; multipart/alternative
4786 ((and (equal (car handle) "multipart/alternative")
4787 (not (or gnus-mime-display-multipart-as-mixed
4788 gnus-mime-display-multipart-alternative-as-mixed)))
4789 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4790 (push (cons id handle) gnus-article-mime-handle-alist)
4791 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4792 ;; multipart/related
4793 ((and (equal (car handle) "multipart/related")
4794 (not (or gnus-mime-display-multipart-as-mixed
4795 gnus-mime-display-multipart-related-as-mixed)))
4796 ;;;!!!We should find the start part, but we just default
4797 ;;;!!!to the first part.
4798 ;;(gnus-mime-display-part (cadr handle))
4799 ;;;!!! Most multipart/related is an HTML message plus images.
4800 ;;;!!! Unfortunately we are unable to let W3 display those
4801 ;;;!!! included images, so we just display it as a mixed multipart.
4802 ;;(gnus-mime-display-mixed (cdr handle))
4803 ;;;!!! No, w3 can display everything just fine.
4804 (gnus-mime-display-part (cadr handle)))
4805 ((equal (car handle) "multipart/signed")
4806 (gnus-add-wash-type 'signed)
4807 (gnus-mime-display-security handle))
4808 ((equal (car handle) "multipart/encrypted")
4809 (gnus-add-wash-type 'encrypted)
4810 (gnus-mime-display-security handle))
4811 ;; Other multiparts are handled like multipart/mixed.
4812 (t
4813 (gnus-mime-display-mixed (cdr handle)))))
4814
4815 (defun gnus-mime-part-function (handles)
4816 (if (stringp (car handles))
4817 (mapcar 'gnus-mime-part-function (cdr handles))
4818 (funcall gnus-article-mime-part-function handles)))
4819
4820 (defun gnus-mime-display-mixed (handles)
4821 (mapcar 'gnus-mime-display-part handles))
4822
4823 (defun gnus-mime-display-single (handle)
4824 (let ((type (mm-handle-media-type handle))
4825 (ignored gnus-ignored-mime-types)
4826 (not-attachment t)
4827 (move nil)
4828 display text)
4829 (catch 'ignored
4830 (progn
4831 (while ignored
4832 (when (string-match (pop ignored) type)
4833 (throw 'ignored nil)))
4834 (if (and (setq not-attachment
4835 (and (not (mm-inline-override-p handle))
4836 (or (not (mm-handle-disposition handle))
4837 (equal (car (mm-handle-disposition handle))
4838 "inline")
4839 (mm-attachment-override-p handle))))
4840 (mm-automatic-display-p handle)
4841 (or (and
4842 (mm-inlinable-p handle)
4843 (mm-inlined-p handle))
4844 (mm-automatic-external-display-p type)))
4845 (setq display t)
4846 (when (equal (mm-handle-media-supertype handle) "text")
4847 (setq text t)))
4848 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4849 beg)
4850 (push (cons id handle) gnus-article-mime-handle-alist)
4851 (when (or (not display)
4852 (not (gnus-unbuttonized-mime-type-p type)))
4853 ;(gnus-article-insert-newline)
4854 (gnus-insert-mime-button
4855 handle id (list (or display (and not-attachment text))))
4856 (gnus-article-insert-newline)
4857 ;(gnus-article-insert-newline)
4858 ;; Remember modify the number of forward lines.
4859 (setq move t))
4860 (setq beg (point))
4861 (cond
4862 (display
4863 (when move
4864 (forward-line -1)
4865 (setq beg (point)))
4866 (let ((mail-parse-charset gnus-newsgroup-charset)
4867 (mail-parse-ignored-charsets
4868 (save-excursion (condition-case ()
4869 (set-buffer gnus-summary-buffer)
4870 (error))
4871 gnus-newsgroup-ignored-charsets)))
4872 (mm-display-part handle t))
4873 (goto-char (point-max)))
4874 ((and text not-attachment)
4875 (when move
4876 (forward-line -1)
4877 (setq beg (point)))
4878 (gnus-article-insert-newline)
4879 (mm-insert-inline
4880 handle
4881 (let ((charset (mail-content-type-get (mm-handle-type handle)
4882 'charset)))
4883 (cond ((not charset)
4884 (mm-string-as-multibyte (mm-get-part handle)))
4885 ((eq charset 'gnus-decoded)
4886 (with-current-buffer (mm-handle-buffer handle)
4887 (buffer-string)))
4888 (t
4889 (mm-decode-string (mm-get-part handle) charset)))))
4890 (goto-char (point-max))))
4891 ;; Do highlighting.
4892 (save-excursion
4893 (save-restriction
4894 (narrow-to-region beg (point))
4895 (gnus-treat-article
4896 nil id
4897 (gnus-article-mime-total-parts)
4898 (mm-handle-media-type handle)))))))))
4899
4900 (defun gnus-unbuttonized-mime-type-p (type)
4901 "Say whether TYPE is to be unbuttonized."
4902 (unless gnus-inhibit-mime-unbuttonizing
4903 (when (catch 'found
4904 (let ((types gnus-unbuttonized-mime-types))
4905 (while types
4906 (when (string-match (pop types) type)
4907 (throw 'found t)))))
4908 (not (catch 'found
4909 (let ((types gnus-buttonized-mime-types))
4910 (while types
4911 (when (string-match (pop types) type)
4912 (throw 'found t)))))))))
4913
4914 (defun gnus-article-insert-newline ()
4915 "Insert a newline, but mark it as undeletable."
4916 (gnus-put-text-property
4917 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4918
4919 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4920 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4921 (ihandles handles)
4922 (point (point))
4923 handle (inhibit-read-only t) from props begend not-pref)
4924 (save-window-excursion
4925 (save-restriction
4926 (when ibegend
4927 (narrow-to-region (car ibegend)
4928 (or (cdr ibegend)
4929 (progn
4930 (goto-char (car ibegend))
4931 (forward-line 2)
4932 (point))))
4933 (delete-region (point-min) (point-max))
4934 (mm-remove-parts handles))
4935 (setq begend (list (point-marker)))
4936 ;; Do the toggle.
4937 (unless (setq not-pref (cadr (member preferred ihandles)))
4938 (setq not-pref (car ihandles)))
4939 (when (or ibegend
4940 (not preferred)
4941 (not (gnus-unbuttonized-mime-type-p
4942 "multipart/alternative")))
4943 (gnus-add-text-properties
4944 (setq from (point))
4945 (progn
4946 (insert (format "%d. " id))
4947 (point))
4948 `(gnus-callback
4949 (lambda (handles)
4950 (unless ,(not ibegend)
4951 (setq gnus-article-mime-handle-alist
4952 ',gnus-article-mime-handle-alist))
4953 (gnus-mime-display-alternative
4954 ',ihandles ',not-pref ',begend ,id))
4955 ,@(gnus-local-map-property gnus-mime-button-map)
4956 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4957 face ,gnus-article-button-face
4958 gnus-part ,id
4959 gnus-data ,handle))
4960 (widget-convert-button 'link from (point)
4961 :action 'gnus-widget-press-button
4962 :button-keymap gnus-widget-button-keymap)
4963 ;; Do the handles
4964 (while (setq handle (pop handles))
4965 (gnus-add-text-properties
4966 (setq from (point))
4967 (progn
4968 (insert (format "(%c) %-18s"
4969 (if (equal handle preferred) ?* ? )
4970 (mm-handle-media-type handle)))
4971 (point))
4972 `(gnus-callback
4973 (lambda (handles)
4974 (unless ,(not ibegend)
4975 (setq gnus-article-mime-handle-alist
4976 ',gnus-article-mime-handle-alist))
4977 (gnus-mime-display-alternative
4978 ',ihandles ',handle ',begend ,id))
4979 ,@(gnus-local-map-property gnus-mime-button-map)
4980 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4981 face ,gnus-article-button-face
4982 gnus-part ,id
4983 gnus-data ,handle))
4984 (widget-convert-button 'link from (point)
4985 :action 'gnus-widget-press-button
4986 :button-keymap gnus-widget-button-keymap)
4987 (insert " "))
4988 (insert "\n\n"))
4989 (when preferred
4990 (if (stringp (car preferred))
4991 (gnus-display-mime preferred)
4992 (let ((mail-parse-charset gnus-newsgroup-charset)
4993 (mail-parse-ignored-charsets
4994 (save-excursion (set-buffer gnus-summary-buffer)
4995 gnus-newsgroup-ignored-charsets)))
4996 (mm-display-part preferred)
4997 ;; Do highlighting.
4998 (save-excursion
4999 (save-restriction
5000 (narrow-to-region (car begend) (point-max))
5001 (gnus-treat-article
5002 nil (length gnus-article-mime-handle-alist)
5003 (gnus-article-mime-total-parts)
5004 (mm-handle-media-type handle))))))
5005 (goto-char (point-max))
5006 (setcdr begend (point-marker)))))
5007 (when ibegend
5008 (goto-char point))))
5009
5010 (defconst gnus-article-wash-status-strings
5011 (let ((alist '((cite "c" "Possible hidden citation text"
5012 " " "All citation text visible")
5013 (headers "h" "Hidden headers"
5014 " " "All headers visible.")
5015 (pgp "p" "Encrypted or signed message status hidden"
5016 " " "No hidden encryption nor digital signature status")
5017 (signature "s" "Signature has been hidden"
5018 " " "Signature is visible")
5019 (overstrike "o" "Overstrike (^H) characters applied"
5020 " " "No overstrike characters applied")
5021 (emphasis "e" "/*_Emphasis_*/ characters applied"
5022 " " "No /*_emphasis_*/ characters applied")))
5023 result)
5024 (dolist (entry alist result)
5025 (let ((key (nth 0 entry))
5026 (on (copy-sequence (nth 1 entry)))
5027 (on-help (nth 2 entry))
5028 (off (copy-sequence (nth 3 entry)))
5029 (off-help (nth 4 entry)))
5030 (put-text-property 0 1 'help-echo on-help on)
5031 (put-text-property 0 1 'help-echo off-help off)
5032 (push (list key on off) result))))
5033 "Alist of strings describing wash status in the mode line.
5034 Each entry has the form (KEY ON OF), where the KEY is a symbol
5035 representing the particular washing function, ON is the string to use
5036 in the article mode line when the washing function is active, and OFF
5037 is the string to use when it is inactive.")
5038
5039 (defun gnus-article-wash-status-entry (key value)
5040 (let ((entry (assoc key gnus-article-wash-status-strings)))
5041 (if value (nth 1 entry) (nth 2 entry))))
5042
5043 (defun gnus-article-wash-status ()
5044 "Return a string which display status of article washing."
5045 (save-excursion
5046 (set-buffer gnus-article-buffer)
5047 (let ((cite (memq 'cite gnus-article-wash-types))
5048 (headers (memq 'headers gnus-article-wash-types))
5049 (boring (memq 'boring-headers gnus-article-wash-types))
5050 (pgp (memq 'pgp gnus-article-wash-types))
5051 (pem (memq 'pem gnus-article-wash-types))
5052 (signed (memq 'signed gnus-article-wash-types))
5053 (encrypted (memq 'encrypted gnus-article-wash-types))
5054 (signature (memq 'signature gnus-article-wash-types))
5055 (overstrike (memq 'overstrike gnus-article-wash-types))
5056 (emphasis (memq 'emphasis gnus-article-wash-types)))
5057 (concat
5058 (gnus-article-wash-status-entry 'cite cite)
5059 (gnus-article-wash-status-entry 'headers (or headers boring))
5060 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5061 (gnus-article-wash-status-entry 'signature signature)
5062 (gnus-article-wash-status-entry 'overstrike overstrike)
5063 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5064
5065 (defun gnus-add-wash-type (type)
5066 "Add a washing of TYPE to the current status."
5067 (add-to-list 'gnus-article-wash-types type))
5068
5069 (defun gnus-delete-wash-type (type)
5070 "Add a washing of TYPE to the current status."
5071 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5072
5073 (defun gnus-add-image (category image)
5074 "Add IMAGE of CATEGORY to the list of displayed images."
5075 (let ((entry (assq category gnus-article-image-alist)))
5076 (unless entry
5077 (setq entry (list category))
5078 (push entry gnus-article-image-alist))
5079 (nconc entry (list image))))
5080
5081 (defun gnus-delete-images (category)
5082 "Delete all images in CATEGORY."
5083 (let ((entry (assq category gnus-article-image-alist)))
5084 (dolist (image (cdr entry))
5085 (gnus-remove-image image category))
5086 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5087 (gnus-delete-wash-type category)))
5088
5089 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5090
5091 (defun gnus-article-maybe-hide-headers ()
5092 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5093 Provided for backwards compatibility."
5094 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5095 (not (save-excursion (set-buffer gnus-summary-buffer)
5096 gnus-have-all-headers)))
5097 (not gnus-inhibit-hiding))
5098 (gnus-article-hide-headers)))
5099
5100 ;;; Article savers.
5101
5102 (defun gnus-output-to-file (file-name)
5103 "Append the current article to a file named FILE-NAME."
5104 (let ((artbuf (current-buffer)))
5105 (with-temp-buffer
5106 (insert-buffer-substring artbuf)
5107 ;; Append newline at end of the buffer as separator, and then
5108 ;; save it to file.
5109 (goto-char (point-max))
5110 (insert "\n")
5111 (let ((file-name-coding-system nnmail-pathname-coding-system))
5112 (mm-append-to-file (point-min) (point-max) file-name))
5113 t)))
5114
5115 (defun gnus-narrow-to-page (&optional arg)
5116 "Narrow the article buffer to a page.
5117 If given a numerical ARG, move forward ARG pages."
5118 (interactive "P")
5119 (setq arg (if arg (prefix-numeric-value arg) 0))
5120 (save-excursion
5121 (set-buffer gnus-article-buffer)
5122 (goto-char (point-min))
5123 (widen)
5124 ;; Remove any old next/prev buttons.
5125 (when (gnus-visual-p 'page-marker)
5126 (let ((inhibit-read-only t))
5127 (gnus-remove-text-with-property 'gnus-prev)
5128 (gnus-remove-text-with-property 'gnus-next)))
5129 (if
5130 (cond ((< arg 0)
5131 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5132 ((> arg 0)
5133 (re-search-forward page-delimiter nil 'move arg)))
5134 (goto-char (match-end 0))
5135 (save-excursion
5136 (goto-char (point-min))
5137 (setq gnus-page-broken
5138 (and (re-search-forward page-delimiter nil t) t))))
5139 (when gnus-page-broken
5140 (narrow-to-region
5141 (point)
5142 (if (re-search-forward page-delimiter nil 'move)
5143 (match-beginning 0)
5144 (point)))
5145 (when (and (gnus-visual-p 'page-marker)
5146 (> (point-min) (save-restriction (widen) (point-min))))
5147 (save-excursion
5148 (goto-char (point-min))
5149 (gnus-insert-prev-page-button)))
5150 (when (and (gnus-visual-p 'page-marker)
5151 (< (point-max) (save-restriction (widen) (point-max))))
5152 (save-excursion
5153 (goto-char (point-max))
5154 (gnus-insert-next-page-button))))))
5155
5156 ;; Article mode commands
5157
5158 (defun gnus-article-goto-next-page ()
5159 "Show the next page of the article."
5160 (interactive)
5161 (when (gnus-article-next-page)
5162 (goto-char (point-min))
5163 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5164
5165
5166 (defun gnus-article-goto-prev-page ()
5167 "Show the previous page of the article."
5168 (interactive)
5169 (if (bobp)
5170 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5171 (gnus-article-prev-page nil)))
5172
5173 ;; This is cleaner but currently breaks `gnus-pick-mode':
5174 ;;
5175 ;; (defun gnus-article-goto-next-page ()
5176 ;; "Show the next page of the article."
5177 ;; (interactive)
5178 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5179 ;; (gnus-summary-next-page)))
5180 ;;
5181 ;; (defun gnus-article-goto-prev-page ()
5182 ;; "Show the next page of the article."
5183 ;; (interactive)
5184 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5185 ;; (gnus-summary-prev-page)))
5186
5187 (defun gnus-article-next-page (&optional lines)
5188 "Show the next page of the current article.
5189 If end of article, return non-nil. Otherwise return nil.
5190 Argument LINES specifies lines to be scrolled up."
5191 (interactive "p")
5192 (move-to-window-line -1)
5193 (if (save-excursion
5194 (end-of-line)
5195 (and (pos-visible-in-window-p) ;Not continuation line.
5196 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5197 ;; Nothing in this page.
5198 (if (or (not gnus-page-broken)
5199 (save-excursion
5200 (save-restriction
5201 (widen)
5202 (forward-line)
5203 (eobp)))) ;Real end-of-buffer?
5204 (progn
5205 (when gnus-article-over-scroll
5206 (gnus-article-next-page-1 lines))
5207 t) ;Nothing more.
5208 (gnus-narrow-to-page 1) ;Go to next page.
5209 nil)
5210 ;; More in this page.
5211 (gnus-article-next-page-1 lines)
5212 nil))
5213
5214 (defmacro gnus-article-beginning-of-window ()
5215 "Move point to the beginning of the window.
5216 In Emacs, the point is placed at the line number which `scroll-margin'
5217 specifies."
5218 (if (featurep 'xemacs)
5219 '(move-to-window-line 0)
5220 '(move-to-window-line
5221 (min (max 0 scroll-margin)
5222 (max 1 (- (window-height)
5223 (if mode-line-format 1 0)
5224 (if (and (boundp 'header-line-format)
5225 (symbol-value 'header-line-format))
5226 1 0)))))))
5227
5228 (defun gnus-article-next-page-1 (lines)
5229 (when (and (not (featurep 'xemacs))
5230 (numberp lines)
5231 (> lines 0)
5232 (numberp (symbol-value 'scroll-margin))
5233 (> (symbol-value 'scroll-margin) 0))
5234 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5235 ;; too many number of lines if `scroll-margin' is set as two or greater.
5236 (setq lines (min lines
5237 (max 0 (- (count-lines (window-start) (point-max))
5238 (symbol-value 'scroll-margin))))))
5239 (condition-case ()
5240 (let ((scroll-in-place nil))
5241 (scroll-up lines))
5242 (end-of-buffer
5243 ;; Long lines may cause an end-of-buffer error.
5244 (goto-char (point-max))))
5245 (gnus-article-beginning-of-window))
5246
5247 (defun gnus-article-prev-page (&optional lines)
5248 "Show previous page of current article.
5249 Argument LINES specifies lines to be scrolled down."
5250 (interactive "p")
5251 (move-to-window-line 0)
5252 (if (and gnus-page-broken
5253 (bobp)
5254 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5255 (progn
5256 (gnus-narrow-to-page -1) ;Go to previous page.
5257 (goto-char (point-max))
5258 (recenter -1))
5259 (prog1
5260 (condition-case ()
5261 (let ((scroll-in-place nil))
5262 (scroll-down lines))
5263 (beginning-of-buffer
5264 (goto-char (point-min))))
5265 (gnus-article-beginning-of-window))))
5266
5267 (defun gnus-article-only-boring-p ()
5268 "Decide whether there is only boring text remaining in the article.
5269 Something \"interesting\" is a word of at least two letters that does
5270 not have a face in `gnus-article-boring-faces'."
5271 (when (and gnus-article-skip-boring
5272 (boundp 'gnus-article-boring-faces)
5273 (symbol-value 'gnus-article-boring-faces))
5274 (save-excursion
5275 (catch 'only-boring
5276 (while (re-search-forward "\\b\\w\\w" nil t)
5277 (forward-char -1)
5278 (when (not (gnus-intersection
5279 (gnus-faces-at (point))
5280 (symbol-value 'gnus-article-boring-faces)))
5281 (throw 'only-boring nil)))
5282 (throw 'only-boring t)))))
5283
5284 (defun gnus-article-refer-article ()
5285 "Read article specified by message-id around point."
5286 (interactive)
5287 (save-excursion
5288 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5289 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5290 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5291 (let ((msg-id (concat "<" (match-string 0) ">")))
5292 (set-buffer gnus-summary-buffer)
5293 (gnus-summary-refer-article msg-id))
5294 (error "No references around point"))))
5295
5296 (defun gnus-article-show-summary ()
5297 "Reconfigure windows to show summary buffer."
5298 (interactive)
5299 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5300 (error "There is no summary buffer for this article buffer")
5301 (gnus-article-set-globals)
5302 (gnus-configure-windows 'article)
5303 (gnus-summary-goto-subject gnus-current-article)
5304 (gnus-summary-position-point)))
5305
5306 (defun gnus-article-describe-briefly ()
5307 "Describe article mode commands briefly."
5308 (interactive)
5309 (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")))
5310
5311 (defun gnus-article-summary-command ()
5312 "Execute the last keystroke in the summary buffer."
5313 (interactive)
5314 (let ((obuf (current-buffer))
5315 (owin (current-window-configuration))
5316 func)
5317 (switch-to-buffer gnus-article-current-summary 'norecord)
5318 (setq func (lookup-key (current-local-map) (this-command-keys)))
5319 (call-interactively func)
5320 (set-buffer obuf)
5321 (set-window-configuration owin)
5322 (set-window-point (get-buffer-window (current-buffer)) (point))))
5323
5324 (defun gnus-article-summary-command-nosave ()
5325 "Execute the last keystroke in the summary buffer."
5326 (interactive)
5327 (let (func)
5328 (pop-to-buffer gnus-article-current-summary 'norecord)
5329 (setq func (lookup-key (current-local-map) (this-command-keys)))
5330 (call-interactively func)))
5331
5332 (defun gnus-article-check-buffer ()
5333 "Beep if not in an article buffer."
5334 (unless (equal major-mode 'gnus-article-mode)
5335 (error "Command invoked outside of a Gnus article buffer")))
5336
5337 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5338 "Read a summary buffer key sequence and execute it from the article buffer."
5339 (interactive "P")
5340 (gnus-article-check-buffer)
5341 (let ((nosaves
5342 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5343 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5344 "=" "^" "\M-^" "|"))
5345 (nosave-but-article
5346 '("A\r"))
5347 (nosave-in-article
5348 '("\C-d"))
5349 (up-to-top
5350 '("n" "Gn" "p" "Gp"))
5351 keys new-sum-point)
5352 (save-excursion
5353 (set-buffer gnus-article-current-summary)
5354 (let (gnus-pick-mode)
5355 (push (or key last-command-event) unread-command-events)
5356 (setq keys (if (featurep 'xemacs)
5357 (events-to-keys (read-key-sequence nil))
5358 (read-key-sequence nil)))))
5359
5360 (message "")
5361
5362 (if (or (member keys nosaves)
5363 (member keys nosave-but-article)
5364 (member keys nosave-in-article))
5365 (let (func)
5366 (save-window-excursion
5367 (pop-to-buffer gnus-article-current-summary 'norecord)
5368 ;; We disable the pick minor mode commands.
5369 (let (gnus-pick-mode)
5370 (setq func (lookup-key (current-local-map) keys))))
5371 (if (or (not func)
5372 (numberp func))
5373 (ding)
5374 (unless (member keys nosave-in-article)
5375 (set-buffer gnus-article-current-summary))
5376 (call-interactively func)
5377 (setq new-sum-point (point)))
5378 (when (member keys nosave-but-article)
5379 (pop-to-buffer gnus-article-buffer 'norecord)))
5380 ;; These commands should restore window configuration.
5381 (let ((obuf (current-buffer))
5382 (owin (current-window-configuration))
5383 (opoint (point))
5384 win func in-buffer selected new-sum-start new-sum-hscroll)
5385 (cond (not-restore-window
5386 (pop-to-buffer gnus-article-current-summary 'norecord))
5387 ((setq win (get-buffer-window gnus-article-current-summary))
5388 (select-window win))
5389 (t
5390 (switch-to-buffer gnus-article-current-summary 'norecord)))
5391 (setq in-buffer (current-buffer))
5392 ;; We disable the pick minor mode commands.
5393 (if (and (setq func (let (gnus-pick-mode)
5394 (lookup-key (current-local-map) keys)))
5395 (functionp func))
5396 (progn
5397 (call-interactively func)
5398 (when (eq win (selected-window))
5399 (setq new-sum-point (point)
5400 new-sum-start (window-start win)
5401 new-sum-hscroll (window-hscroll win)))
5402 (when (eq in-buffer (current-buffer))
5403 (setq selected (gnus-summary-select-article))
5404 (set-buffer obuf)
5405 (unless not-restore-window
5406 (set-window-configuration owin))
5407 (when (eq selected 'old)
5408 (article-goto-body)
5409 (set-window-start (get-buffer-window (current-buffer))
5410 1)
5411 (set-window-point (get-buffer-window (current-buffer))
5412 (point)))
5413 (when (and (not not-restore-window)
5414 new-sum-point)
5415 (set-window-point win new-sum-point)
5416 (set-window-start win new-sum-start)
5417 (set-window-hscroll win new-sum-hscroll))))
5418 (set-window-configuration owin)
5419 (ding))))))
5420
5421 (defun gnus-article-describe-key (key)
5422 "Display documentation of the function invoked by KEY. KEY is a string."
5423 (interactive "kDescribe key: ")
5424 (gnus-article-check-buffer)
5425 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5426 (save-excursion
5427 (set-buffer gnus-article-current-summary)
5428 (let (gnus-pick-mode)
5429 (if (featurep 'xemacs)
5430 (progn
5431 (push (elt key 0) unread-command-events)
5432 (setq key (events-to-keys
5433 (read-key-sequence "Describe key: "))))
5434 (setq unread-command-events
5435 (mapcar
5436 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5437 (string-to-list key)))
5438 (setq key (read-key-sequence "Describe key: "))))
5439 (describe-key key))
5440 (describe-key key)))
5441
5442 (defun gnus-article-describe-key-briefly (key &optional insert)
5443 "Display documentation of the function invoked by KEY. KEY is a string."
5444 (interactive "kDescribe key: \nP")
5445 (gnus-article-check-buffer)
5446 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5447 (save-excursion
5448 (set-buffer gnus-article-current-summary)
5449 (let (gnus-pick-mode)
5450 (if (featurep 'xemacs)
5451 (progn
5452 (push (elt key 0) unread-command-events)
5453 (setq key (events-to-keys
5454 (read-key-sequence "Describe key: "))))
5455 (setq unread-command-events
5456 (mapcar
5457 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5458 (string-to-list key)))
5459 (setq key (read-key-sequence "Describe key: "))))
5460 (describe-key-briefly key insert))
5461 (describe-key-briefly key insert)))
5462
5463 (defun gnus-article-reply-with-original (&optional wide)
5464 "Start composing a reply mail to the current message.
5465 The text in the region will be yanked. If the region isn't active,
5466 the entire article will be yanked."
5467 (interactive "P")
5468 (let ((article (cdr gnus-article-current))
5469 contents)
5470 (if (not (gnus-mark-active-p))
5471 (with-current-buffer gnus-summary-buffer
5472 (gnus-summary-reply (list (list article)) wide))
5473 (setq contents (buffer-substring (point) (mark t)))
5474 ;; Deactivate active regions.
5475 (when (and (boundp 'transient-mark-mode)
5476 transient-mark-mode)
5477 (setq mark-active nil))
5478 (with-current-buffer gnus-summary-buffer
5479 (gnus-summary-reply
5480 (list (list article contents)) wide)))))
5481
5482 (defun gnus-article-followup-with-original ()
5483 "Compose a followup to the current article.
5484 The text in the region will be yanked. If the region isn't active,
5485 the entire article will be yanked."
5486 (interactive)
5487 (let ((article (cdr gnus-article-current))
5488 contents)
5489 (if (not (gnus-mark-active-p))
5490 (with-current-buffer gnus-summary-buffer
5491 (gnus-summary-followup (list (list article))))
5492 (setq contents (buffer-substring (point) (mark t)))
5493 ;; Deactivate active regions.
5494 (when (and (boundp 'transient-mark-mode)
5495 transient-mark-mode)
5496 (setq mark-active nil))
5497 (with-current-buffer gnus-summary-buffer
5498 (gnus-summary-followup
5499 (list (list article contents)))))))
5500
5501 (defun gnus-article-hide (&optional arg force)
5502 "Hide all the gruft in the current article.
5503 This means that signatures, cited text and (some) headers will be
5504 hidden.
5505 If given a prefix, show the hidden text instead."
5506 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5507 (gnus-article-hide-headers arg)
5508 (gnus-article-hide-list-identifiers arg)
5509 (gnus-article-hide-citation-maybe arg force)
5510 (gnus-article-hide-signature arg))
5511
5512 (defun gnus-article-maybe-highlight ()
5513 "Do some article highlighting if article highlighting is requested."
5514 (when (gnus-visual-p 'article-highlight 'highlight)
5515 (gnus-article-highlight-some)))
5516
5517 (defun gnus-check-group-server ()
5518 ;; Make sure the connection to the server is alive.
5519 (unless (gnus-server-opened
5520 (gnus-find-method-for-group gnus-newsgroup-name))
5521 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5522 (gnus-request-group gnus-newsgroup-name t)))
5523
5524 (eval-when-compile
5525 (autoload 'nneething-get-file-name "nneething"))
5526
5527 (defun gnus-request-article-this-buffer (article group)
5528 "Get an article and insert it into this buffer."
5529 (let (do-update-line sparse-header)
5530 (prog1
5531 (save-excursion
5532 (erase-buffer)
5533 (gnus-kill-all-overlays)
5534 (setq group (or group gnus-newsgroup-name))
5535
5536 ;; Using `gnus-request-article' directly will insert the article into
5537 ;; `nntp-server-buffer' - so we'll save some time by not having to
5538 ;; copy it from the server buffer into the article buffer.
5539
5540 ;; We only request an article by message-id when we do not have the
5541 ;; headers for it, so we'll have to get those.
5542 (when (stringp article)
5543 (gnus-read-header article))
5544
5545 ;; If the article number is negative, that means that this article
5546 ;; doesn't belong in this newsgroup (possibly), so we find its
5547 ;; message-id and request it by id instead of number.
5548 (when (and (numberp article)
5549 gnus-summary-buffer
5550 (get-buffer gnus-summary-buffer)
5551 (gnus-buffer-exists-p gnus-summary-buffer))
5552 (save-excursion
5553 (set-buffer gnus-summary-buffer)
5554 (let ((header (gnus-summary-article-header article)))
5555 (when (< article 0)
5556 (cond
5557 ((memq article gnus-newsgroup-sparse)
5558 ;; This is a sparse gap article.
5559 (setq do-update-line article)
5560 (setq article (mail-header-id header))
5561 (setq sparse-header (gnus-read-header article))
5562 (setq gnus-newsgroup-sparse
5563 (delq article gnus-newsgroup-sparse)))
5564 ((vectorp header)
5565 ;; It's a real article.
5566 (setq article (mail-header-id header)))
5567 (t
5568 ;; It is an extracted pseudo-article.
5569 (setq article 'pseudo)
5570 (gnus-request-pseudo-article header))))
5571
5572 (let ((method (gnus-find-method-for-group
5573 gnus-newsgroup-name)))
5574 (when (and (eq (car method) 'nneething)
5575 (vectorp header))
5576 (let ((dir (nneething-get-file-name
5577 (mail-header-id header))))
5578 (when (and (stringp dir)
5579 (file-directory-p dir))
5580 (setq article 'nneething)
5581 (gnus-group-enter-directory dir))))))))
5582
5583 (cond
5584 ;; Refuse to select canceled articles.
5585 ((and (numberp article)
5586 gnus-summary-buffer
5587 (get-buffer gnus-summary-buffer)
5588 (gnus-buffer-exists-p gnus-summary-buffer)
5589 (eq (cdr (save-excursion
5590 (set-buffer gnus-summary-buffer)
5591 (assq article gnus-newsgroup-reads)))
5592 gnus-canceled-mark))
5593 nil)
5594 ;; We first check `gnus-original-article-buffer'.
5595 ((and (get-buffer gnus-original-article-buffer)
5596 (numberp article)
5597 (save-excursion
5598 (set-buffer gnus-original-article-buffer)
5599 (and (equal (car gnus-original-article) group)
5600 (eq (cdr gnus-original-article) article))))
5601 (insert-buffer-substring gnus-original-article-buffer)
5602 'article)
5603 ;; Check the backlog.
5604 ((and gnus-keep-backlog
5605 (gnus-backlog-request-article group article (current-buffer)))
5606 'article)
5607 ;; Check asynchronous pre-fetch.
5608 ((gnus-async-request-fetched-article group article (current-buffer))
5609 (gnus-async-prefetch-next group article gnus-summary-buffer)
5610 (when (and (numberp article) gnus-keep-backlog)
5611 (gnus-backlog-enter-article group article (current-buffer)))
5612 'article)
5613 ;; Check the cache.
5614 ((and gnus-use-cache
5615 (numberp article)
5616 (gnus-cache-request-article article group))
5617 'article)
5618 ;; Check the agent cache.
5619 ((gnus-agent-request-article article group)
5620 'article)
5621 ;; Get the article and put into the article buffer.
5622 ((or (stringp article)
5623 (numberp article))
5624 (let ((gnus-override-method gnus-override-method)
5625 (methods (and (stringp article)
5626 gnus-refer-article-method))
5627 (backend (car (gnus-find-method-for-group
5628 gnus-newsgroup-name)))
5629 result
5630 (inhibit-read-only t))
5631 (if (or (not (listp methods))
5632 (and (symbolp (car methods))
5633 (assq (car methods) nnoo-definition-alist)))
5634 (setq methods (list methods)))
5635 (when (and (null gnus-override-method)
5636 methods)
5637 (setq gnus-override-method (pop methods)))
5638 (while (not result)
5639 (when (eq gnus-override-method 'current)
5640 (setq gnus-override-method
5641 (with-current-buffer gnus-summary-buffer
5642 gnus-current-select-method)))
5643 (erase-buffer)
5644 (gnus-kill-all-overlays)
5645 (let ((gnus-newsgroup-name group))
5646 (gnus-check-group-server))
5647 (cond
5648 ((gnus-request-article article group (current-buffer))
5649 (when (numberp article)
5650 (gnus-async-prefetch-next group article
5651 gnus-summary-buffer)
5652 (when gnus-keep-backlog
5653 (gnus-backlog-enter-article
5654 group article (current-buffer))))
5655 (setq result 'article))
5656 (methods
5657 (setq gnus-override-method (pop methods)))
5658 ((not (string-match "^400 "
5659 (nnheader-get-report backend)))
5660 ;; If we get 400 server disconnect, reconnect and
5661 ;; retry; otherwise, assume the article has expired.
5662 (setq result 'done))))
5663 (and (eq result 'article) 'article)))
5664 ;; It was a pseudo.
5665 (t article)))
5666
5667 ;; Associate this article with the current summary buffer.
5668 (setq gnus-article-current-summary gnus-summary-buffer)
5669
5670 ;; Take the article from the original article buffer
5671 ;; and place it in the buffer it's supposed to be in.
5672 (when (and (get-buffer gnus-article-buffer)
5673 (equal (buffer-name (current-buffer))
5674 (buffer-name (get-buffer gnus-article-buffer))))
5675 (save-excursion
5676 (if (get-buffer gnus-original-article-buffer)
5677 (set-buffer gnus-original-article-buffer)
5678 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5679 (buffer-disable-undo)
5680 (setq major-mode 'gnus-original-article-mode)
5681 (setq buffer-read-only t))
5682 (let ((inhibit-read-only t))
5683 (erase-buffer)
5684 (insert-buffer-substring gnus-article-buffer))
5685 (setq gnus-original-article (cons group article)))
5686
5687 ;; Decode charsets.
5688 (run-hooks 'gnus-article-decode-hook)
5689 ;; Mark article as decoded or not.
5690 (setq gnus-article-decoded-p gnus-article-decode-hook))
5691
5692 ;; Update sparse articles.
5693 (when (and do-update-line
5694 (or (numberp article)
5695 (stringp article)))
5696 (let ((buf (current-buffer)))
5697 (set-buffer gnus-summary-buffer)
5698 (gnus-summary-update-article do-update-line sparse-header)
5699 (gnus-summary-goto-subject do-update-line nil t)
5700 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5701 (point))
5702 (set-buffer buf))))))
5703
5704 ;;;
5705 ;;; Article editing
5706 ;;;
5707
5708 (defcustom gnus-article-edit-mode-hook nil
5709 "Hook run in article edit mode buffers."
5710 :group 'gnus-article-various
5711 :type 'hook)
5712
5713 (defvar gnus-article-edit-done-function nil)
5714
5715 (defvar gnus-article-edit-mode-map nil)
5716 (defvar gnus-article-edit-mode nil)
5717
5718 ;; Should we be using derived.el for this?
5719 (unless gnus-article-edit-mode-map
5720 (setq gnus-article-edit-mode-map (make-keymap))
5721 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5722
5723 (gnus-define-keys gnus-article-edit-mode-map
5724 "\C-c?" describe-mode
5725 "\C-c\C-c" gnus-article-edit-done
5726 "\C-c\C-k" gnus-article-edit-exit
5727 "\C-c\C-f\C-t" message-goto-to
5728 "\C-c\C-f\C-o" message-goto-from
5729 "\C-c\C-f\C-b" message-goto-bcc
5730 ;;"\C-c\C-f\C-w" message-goto-fcc
5731 "\C-c\C-f\C-c" message-goto-cc
5732 "\C-c\C-f\C-s" message-goto-subject
5733 "\C-c\C-f\C-r" message-goto-reply-to
5734 "\C-c\C-f\C-n" message-goto-newsgroups
5735 "\C-c\C-f\C-d" message-goto-distribution
5736 "\C-c\C-f\C-f" message-goto-followup-to
5737 "\C-c\C-f\C-m" message-goto-mail-followup-to
5738 "\C-c\C-f\C-k" message-goto-keywords
5739 "\C-c\C-f\C-u" message-goto-summary
5740 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5741 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5742 "\C-c\C-b" message-goto-body
5743 "\C-c\C-i" message-goto-signature
5744
5745 "\C-c\C-t" message-insert-to
5746 "\C-c\C-n" message-insert-newsgroups
5747 "\C-c\C-o" message-sort-headers
5748 "\C-c\C-e" message-elide-region
5749 "\C-c\C-v" message-delete-not-region
5750 "\C-c\C-z" message-kill-to-signature
5751 "\M-\r" message-newline-and-reformat
5752 "\C-c\C-a" mml-attach-file
5753 "\C-a" message-beginning-of-line
5754 "\t" message-tab
5755 "\M-;" comment-region)
5756
5757 (gnus-define-keys (gnus-article-edit-wash-map
5758 "\C-c\C-w" gnus-article-edit-mode-map)
5759 "f" gnus-article-edit-full-stops))
5760
5761 (easy-menu-define
5762 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5763 '("Field"
5764 ["Fetch To" message-insert-to t]
5765 ["Fetch Newsgroups" message-insert-newsgroups t]
5766 "----"
5767 ["To" message-goto-to t]
5768 ["From" message-goto-from t]
5769 ["Subject" message-goto-subject t]
5770 ["Cc" message-goto-cc t]
5771 ["Reply-To" message-goto-reply-to t]
5772 ["Summary" message-goto-summary t]
5773 ["Keywords" message-goto-keywords t]
5774 ["Newsgroups" message-goto-newsgroups t]
5775 ["Followup-To" message-goto-followup-to t]
5776 ["Mail-Followup-To" message-goto-mail-followup-to t]
5777 ["Distribution" message-goto-distribution t]
5778 ["Body" message-goto-body t]
5779 ["Signature" message-goto-signature t]))
5780
5781 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5782 "Major mode for editing articles.
5783 This is an extended text-mode.
5784
5785 \\{gnus-article-edit-mode-map}"
5786 (make-local-variable 'gnus-article-edit-done-function)
5787 (make-local-variable 'gnus-prev-winconf)
5788 (set (make-local-variable 'font-lock-defaults)
5789 '(message-font-lock-keywords t))
5790 (set (make-local-variable 'mail-header-separator) "")
5791 (set (make-local-variable 'gnus-article-edit-mode) t)
5792 (easy-menu-add message-mode-field-menu message-mode-map)
5793 (mml-mode)
5794 (setq buffer-read-only nil)
5795 (buffer-enable-undo)
5796 (widen))
5797
5798 (defun gnus-article-edit (&optional force)
5799 "Edit the current article.
5800 This will have permanent effect only in mail groups.
5801 If FORCE is non-nil, allow editing of articles even in read-only
5802 groups."
5803 (interactive "P")
5804 (when (and (not force)
5805 (gnus-group-read-only-p))
5806 (error "The current newsgroup does not support article editing"))
5807 (gnus-article-date-original)
5808 (gnus-article-edit-article
5809 'ignore
5810 `(lambda (no-highlight)
5811 'ignore
5812 (gnus-summary-edit-article-done
5813 ,(or (mail-header-references gnus-current-headers) "")
5814 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5815
5816 (defun gnus-article-edit-article (start-func exit-func)
5817 "Start editing the contents of the current article buffer."
5818 (let ((winconf (current-window-configuration)))
5819 (set-buffer gnus-article-buffer)
5820 (let ((message-auto-save-directory
5821 ;; Don't associate the article buffer with a draft file.
5822 nil))
5823 (gnus-article-edit-mode))
5824 (funcall start-func)
5825 (set-buffer-modified-p nil)
5826 (gnus-configure-windows 'edit-article)
5827 (setq gnus-article-edit-done-function exit-func)
5828 (setq gnus-prev-winconf winconf)
5829 (gnus-message 6 "C-c C-c to end edits")))
5830
5831 (defun gnus-article-edit-done (&optional arg)
5832 "Update the article edits and exit."
5833 (interactive "P")
5834 (let ((func gnus-article-edit-done-function)
5835 (buf (current-buffer))
5836 (start (window-start))
5837 (p (point))
5838 (winconf gnus-prev-winconf))
5839 (widen) ;; Widen it in case that users narrowed the buffer.
5840 (funcall func arg)
5841 (set-buffer buf)
5842 ;; The cache and backlog have to be flushed somewhat.
5843 (when gnus-keep-backlog
5844 (gnus-backlog-remove-article
5845 (car gnus-article-current) (cdr gnus-article-current)))
5846 ;; Flush original article as well.
5847 (save-excursion
5848 (when (get-buffer gnus-original-article-buffer)
5849 (set-buffer gnus-original-article-buffer)
5850 (setq gnus-original-article nil)))
5851 (when gnus-use-cache
5852 (gnus-cache-update-article
5853 (car gnus-article-current) (cdr gnus-article-current)))
5854 ;; We remove all text props from the article buffer.
5855 (kill-all-local-variables)
5856 (gnus-set-text-properties (point-min) (point-max) nil)
5857 (gnus-article-mode)
5858 (set-window-configuration winconf)
5859 (set-buffer buf)
5860 (set-window-start (get-buffer-window buf) start)
5861 (set-window-point (get-buffer-window buf) (point)))
5862 (gnus-summary-show-article))
5863
5864 (defun gnus-article-edit-exit ()
5865 "Exit the article editing without updating."
5866 (interactive)
5867 (when (or (not (buffer-modified-p))
5868 (yes-or-no-p "Article modified; kill anyway? "))
5869 (let ((curbuf (current-buffer))
5870 (p (point))
5871 (window-start (window-start)))
5872 (erase-buffer)
5873 (if (gnus-buffer-live-p gnus-original-article-buffer)
5874 (insert-buffer-substring gnus-original-article-buffer))
5875 (let ((winconf gnus-prev-winconf))
5876 (kill-all-local-variables)
5877 (gnus-article-mode)
5878 (set-window-configuration winconf)
5879 ;; Tippy-toe some to make sure that point remains where it was.
5880 (save-current-buffer
5881 (set-buffer curbuf)
5882 (set-window-start (get-buffer-window (current-buffer)) window-start)
5883 (goto-char p))))
5884 (gnus-summary-show-article)))
5885
5886 (defun gnus-article-edit-full-stops ()
5887 "Interactively repair spacing at end of sentences."
5888 (interactive)
5889 (save-excursion
5890 (goto-char (point-min))
5891 (search-forward-regexp "^$" nil t)
5892 (let ((case-fold-search nil))
5893 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5894
5895 ;;;
5896 ;;; Article highlights
5897 ;;;
5898
5899 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5900
5901 ;;; Internal Variables:
5902
5903 (defcustom gnus-button-url-regexp
5904 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5905 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5906 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5907 "Regular expression that matches URLs."
5908 :group 'gnus-article-buttons
5909 :type 'regexp)
5910
5911 (defcustom gnus-button-valid-fqdn-regexp
5912 message-valid-fqdn-regexp
5913 "Regular expression that matches a valid FQDN."
5914 :version "22.1"
5915 :group 'gnus-article-buttons
5916 :type 'regexp)
5917
5918 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5919 (defcustom gnus-button-valid-localpart-regexp
5920 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
5921 "Regular expression that matches a localpart of mail addresses or MIDs."
5922 :version "22.1"
5923 :group 'gnus-article-buttons
5924 :type 'regexp)
5925
5926 (defcustom gnus-button-man-handler 'manual-entry
5927 "Function to use for displaying man pages.
5928 The function must take at least one argument with a string naming the
5929 man page."
5930 :version "22.1"
5931 :type '(choice (function-item :tag "Man" manual-entry)
5932 (function-item :tag "Woman" woman)
5933 (function :tag "Other"))
5934 :group 'gnus-article-buttons)
5935
5936 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5937 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5938 If the default site is too slow, try to find a CTAN mirror, see
5939 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5940 the variable `gnus-button-handle-ctan'."
5941 :version "22.1"
5942 :group 'gnus-article-buttons
5943 :link '(custom-manual "(gnus)Group Parameters")
5944 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5945 (const "http://tug.ctan.org/tex-archive/")
5946 (const "http://www.dante.de/CTAN/")
5947 (string :tag "Other")))
5948
5949 (defcustom gnus-button-ctan-handler 'browse-url
5950 "Function to use for displaying CTAN links.
5951 The function must take one argument, the string naming the URL."
5952 :version "22.1"
5953 :type '(choice (function-item :tag "Browse Url" browse-url)
5954 (function :tag "Other"))
5955 :group 'gnus-article-buttons)
5956
5957 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5958 "Bogus strings removed from CTAN URLs."
5959 :version "22.1"
5960 :group 'gnus-article-buttons
5961 :type '(choice (const "^/?tex-archive/\\|/")
5962 (regexp :tag "Other")))
5963
5964 (defcustom gnus-button-ctan-directory-regexp
5965 (regexp-opt
5966 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
5967 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
5968 "languages" "macros" "nonfree" "obsolete" "support" "systems"
5969 "tds" "tools" "usergrps" "web") t)
5970 "Regular expression for ctan directories.
5971 It should match all directories in the top level of `gnus-ctan-url'."
5972 :version "22.1"
5973 :group 'gnus-article-buttons
5974 :type 'regexp)
5975
5976 (defcustom gnus-button-mid-or-mail-regexp
5977 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
5978 gnus-button-valid-fqdn-regexp
5979 ">?\\)\\b")
5980 "Regular expression that matches a message ID or a mail address."
5981 :version "22.1"
5982 :group 'gnus-article-buttons
5983 :type 'regexp)
5984
5985 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5986 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5987 Strings like this can be either a message ID or a mail address. If it is one
5988 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5989 message ID or a mail address, respectively. If this variable is set to the
5990 symbol `ask', always query the user what do do. If it is a function, this
5991 function will be called with the string as it's only argument. The function
5992 must return `mid', `mail', `invalid' or `ask'."
5993 :version "22.1"
5994 :group 'gnus-article-buttons
5995 :type '(choice (function-item :tag "Heuristic function"
5996 gnus-button-mid-or-mail-heuristic)
5997 (const ask)
5998 (const mid)
5999 (const mail)))
6000
6001 (defcustom gnus-button-mid-or-mail-heuristic-alist
6002 '((-10.0 . ".+\\$.+@")
6003 (-10.0 . "#")
6004 (-10.0 . "\\*")
6005 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6006 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6007 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6008 (-1.0 . "^[^a-z]+@")
6009 ;;
6010 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6011 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6012 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6013 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6014 ;;
6015 (-2.0 . "^[0-9]")
6016 (-1.0 . "^[0-9][0-9]")
6017 ;;
6018 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6019 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6020 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6021 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6022 ;;
6023 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6024 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6025 ;; "[0-9]{8,}.*\@"
6026 (-3.0
6027 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6028 ;; "[0-9]{12,}.*\@"
6029 ;; compensation for TDMA dated mail addresses:
6030 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6031 ;;
6032 (-20.0 . "\\.fsf@") ;; Gnus
6033 (-20.0 . "^slrn")
6034 (-20.0 . "^Pine")
6035 (-20.0 . "_-_") ;; Subject change in thread
6036 ;;
6037 (-20.0 . "\\.ln@") ;; leafnode
6038 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6039 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6040 ;;
6041 ;; (5.0 . "") ;; $local_part_len <= 7
6042 (10.0 . "^[^0-9]+@")
6043 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6044 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6045 (3.0 . "\@stud")
6046 ;;
6047 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6048 ;;
6049 (0.5 . "^[A-Z][a-z]")
6050 (0.5 . "^[A-Z][a-z][a-z]")
6051 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6052 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6053 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6054
6055 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6056 address. The REGEXP is processed with `case-fold-search' set to nil."
6057 :version "22.1"
6058 :group 'gnus-article-buttons
6059 :type '(repeat (cons (number :tag "Rate")
6060 (regexp :tag "Regexp"))))
6061
6062 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6063 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6064 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6065 address, `ask' if unsure and `invalid' if the string is invalid."
6066 (let ((case-fold-search nil)
6067 (list gnus-button-mid-or-mail-heuristic-alist)
6068 (result 0) rate regexp lpartlen elem)
6069 (setq lpartlen
6070 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6071 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6072 ;; Certain special cases...
6073 (when (string-match
6074 (concat
6075 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6076 "^[0-9]+\\.[0-9]+@compuserve\\|"
6077 "@public\\.gmane\\.org")
6078 mid-or-mail)
6079 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6080 (setq result 'mail))
6081 (when (string-match "@.*@\\| " mid-or-mail)
6082 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6083 (setq result 'invalid))
6084 ;; Nothing more to do, if result is not a number here...
6085 (when (numberp result)
6086 (while list
6087 (setq elem (car list)
6088 rate (car elem)
6089 regexp (cdr elem)
6090 list (cdr list))
6091 (when (string-match regexp mid-or-mail)
6092 (setq result (+ result rate))
6093 (gnus-message
6094 9 "`%s' matched `%s', rate `%s', result `%s'."
6095 mid-or-mail regexp rate result)))
6096 (when (<= lpartlen 7)
6097 (setq result (+ result 5.0))
6098 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6099 mid-or-mail result))
6100 (when (>= lpartlen 12)
6101 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6102 (cond
6103 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6104 ;; Long local part should contain realname if e-mail address,
6105 ;; too many digits: message-id.
6106 ;; $score -= 5.0 + 0.1 * $local_part_len;
6107 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6108 (setq result (+ result rate))
6109 (gnus-message
6110 9 "Many digits in `%s', rate `%s', result `%s'."
6111 mid-or-mail rate result))
6112 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6113 mid-or-mail)
6114 ;; Too few vowels [^aeiouy]{4,}.*\@
6115 (setq result (+ result -5.0))
6116 (gnus-message
6117 9 "Few vowels in `%s', rate `%s', result `%s'."
6118 mid-or-mail -5.0 result))
6119 (t
6120 (setq result (+ result 5.0))
6121 (gnus-message
6122 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6123 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6124 ;; Maybe we should make this a customizable alist: (condition . 'result)
6125 (cond
6126 ((symbolp result) result)
6127 ;; Now convert number into proper results:
6128 ((< result -10.0) 'mid)
6129 ((> result 10.0) 'mail)
6130 (t 'ask))))
6131
6132 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6133 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6134 (url-mid (concat "news" ":" mid-or-mail))
6135 (url-mailto (concat "mailto" ":" mid-or-mail)))
6136 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6137 (when (fboundp pref)
6138 (setq guessed
6139 ;; get rid of surrounding angles...
6140 (funcall pref
6141 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6142 (if (or (eq 'mid guessed) (eq 'mail guessed))
6143 (setq pref guessed)
6144 (setq pref 'ask)))
6145 (if (eq pref 'ask)
6146 (save-window-excursion
6147 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6148 (setq pref 'mail)
6149 (setq pref 'mid))))
6150 (cond ((eq pref 'mid)
6151 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6152 (gnus-button-handle-news url-mid))
6153 ((eq pref 'mail)
6154 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6155 (gnus-url-mailto url-mailto))
6156 (t (gnus-message 3 "Invalid string.")))))
6157
6158 (defun gnus-button-handle-custom (url)
6159 "Follow a Custom URL."
6160 (customize-apropos (gnus-url-unhex-string url)))
6161
6162 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6163
6164 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6165 ;; stuff?
6166
6167 (defun gnus-button-handle-describe-function (url)
6168 "Call `describe-function' when pushing the corresponding URL button."
6169 (describe-function
6170 (intern
6171 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6172
6173 (defun gnus-button-handle-describe-variable (url)
6174 "Call `describe-variable' when pushing the corresponding URL button."
6175 (describe-variable
6176 (intern
6177 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6178
6179 (defun gnus-button-handle-symbol (url)
6180 "Display help on variable or function.
6181 Calls `describe-variable' or `describe-function'."
6182 (let ((sym (intern url)))
6183 (cond
6184 ((fboundp sym) (describe-function sym))
6185 ((boundp sym) (describe-variable sym))
6186 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6187
6188 (defun gnus-button-handle-describe-key (url)
6189 "Call `describe-key' when pushing the corresponding URL button."
6190 (let* ((key-string
6191 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6192 (keys (ignore-errors (eval `(kbd ,key-string)))))
6193 (if keys
6194 (describe-key keys)
6195 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6196
6197 (defun gnus-button-handle-apropos (url)
6198 "Call `apropos' when pushing the corresponding URL button."
6199 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6200
6201 (defun gnus-button-handle-apropos-command (url)
6202 "Call `apropos' when pushing the corresponding URL button."
6203 (apropos-command
6204 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6205
6206 (defun gnus-button-handle-apropos-variable (url)
6207 "Call `apropos' when pushing the corresponding URL button."
6208 (funcall
6209 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6210 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6211
6212 (defun gnus-button-handle-apropos-documentation (url)
6213 "Call `apropos' when pushing the corresponding URL button."
6214 (funcall
6215 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6216 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6217
6218 (defun gnus-button-handle-library (url)
6219 "Call `locate-library' when pushing the corresponding URL button."
6220 (gnus-message 9 "url=`%s'" url)
6221 (let* ((lib (locate-library url))
6222 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6223 (if (not lib)
6224 (gnus-message 1 "Cannot locale library `%s'." url)
6225 (find-file-read-only file))))
6226
6227 (defun gnus-button-handle-ctan (url)
6228 "Call `browse-url' when pushing a CTAN URL button."
6229 (funcall
6230 gnus-button-ctan-handler
6231 (concat
6232 gnus-ctan-url
6233 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6234
6235 (defcustom gnus-button-tex-level 5
6236 "*Integer that says how many TeX-related buttons Gnus will show.
6237 The higher the number, the more buttons will appear and the more false
6238 positives are possible. Note that you can set this variable local to
6239 specific groups. Setting it higher in TeX groups is probably a good idea.
6240 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6241 how to set variables in specific groups."
6242 :version "22.1"
6243 :group 'gnus-article-buttons
6244 :link '(custom-manual "(gnus)Group Parameters")
6245 :type 'integer)
6246
6247 (defcustom gnus-button-man-level 5
6248 "*Integer that says how many man-related buttons Gnus will show.
6249 The higher the number, the more buttons will appear and the more false
6250 positives are possible. Note that you can set this variable local to
6251 specific groups. Setting it higher in Unix groups is probably a good idea.
6252 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6253 how to set variables in specific groups."
6254 :version "22.1"
6255 :group 'gnus-article-buttons
6256 :link '(custom-manual "(gnus)Group Parameters")
6257 :type 'integer)
6258
6259 (defcustom gnus-button-emacs-level 5
6260 "*Integer that says how many emacs-related buttons Gnus will show.
6261 The higher the number, the more buttons will appear and the more false
6262 positives are possible. Note that you can set this variable local to
6263 specific groups. Setting it higher in Emacs or Gnus related groups is
6264 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6265 `gnus-parameters' on how to set variables in specific groups."
6266 :version "22.1"
6267 :group 'gnus-article-buttons
6268 :link '(custom-manual "(gnus)Group Parameters")
6269 :type 'integer)
6270
6271 (defcustom gnus-button-message-level 5
6272 "*Integer that says how many buttons for news or mail messages will appear.
6273 The higher the number, the more buttons will appear and the more false
6274 positives are possible."
6275 ;; mail addresses, MIDs, URLs for news, ...
6276 :version "22.1"
6277 :group 'gnus-article-buttons
6278 :type 'integer)
6279
6280 (defcustom gnus-button-browse-level 5
6281 "*Integer that says how many buttons for browsing will appear.
6282 The higher the number, the more buttons will appear and the more false
6283 positives are possible."
6284 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6285 :version "22.1"
6286 :group 'gnus-article-buttons
6287 :type 'integer)
6288
6289 (defcustom gnus-button-alist
6290 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6291 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6292 ((concat "\\b\\(nntp\\|news\\):\\("
6293 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6294 0 t gnus-button-handle-news 2)
6295 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6296 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6297 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6298 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6299 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6300 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6301 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6302 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6303 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6304 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6305 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6306 ;; RFC 2368 (The mailto URL scheme)
6307 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6308 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6309 ("\\bmailto:\\([^ \n\t]+\\)"
6310 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6311 ;; CTAN
6312 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6313 gnus-button-ctan-directory-regexp
6314 "[^][>)!;:,'\n\t ]+\\)")
6315 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6316 ((concat "\\btex-archive/\\("
6317 gnus-button-ctan-directory-regexp
6318 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6319 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6320 ((concat
6321 "\\b\\("
6322 gnus-button-ctan-directory-regexp
6323 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6324 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6325 ;; This is info (home-grown style) <info://foo/bar+baz>
6326 ("\\binfo://\\([^'\">\n\t ]+\\)"
6327 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6328 ;; Info GNOME style <info:foo#bar_baz>
6329 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6330 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6331 ;; Info KDE style <info:(foo)bar baz>
6332 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6333 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6334 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6335 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6336 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6337 ;; Info links like `C-h i d m CC Mode RET'
6338 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6339 ;; This is custom
6340 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6341 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6342 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6343 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6344 ;; Emacs help commands
6345 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6346 ;; regexp doesn't match arguments containing ` '.
6347 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6348 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6349 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6350 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6351 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6352 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6353 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6354 ;; The following entries may lead to many false positives so don't enable
6355 ;; them by default (use a high button level).
6356 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6357 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6358 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6359 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6360 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6361 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6362 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6363 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6364 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6365 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6366 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6367 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6368 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6369 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6370 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6371 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6372 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6373 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6374 ;; Unlike the other regexps we really have to require quoting
6375 ;; here to determine where it ends.
6376 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6377 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6378 ("<URL: *\\([^<>]*\\)>"
6379 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6380 ;; RFC 2396 (2.4.3., delims) ...
6381 ("\"URL: *\\([^\"]*\\)\""
6382 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6383 ;; RFC 2396 (2.4.3., delims) ...
6384 ("\"URL: *\\([^\"]*\\)\""
6385 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6386 ;; Raw URLs.
6387 (gnus-button-url-regexp
6388 0 (>= gnus-button-browse-level 0) browse-url 0)
6389 ;; man pages
6390 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6391 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6392 gnus-button-handle-man 1)
6393 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6394 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6395 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6396 gnus-button-handle-man 1)
6397 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6398 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6399 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6400 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6401 ;; MID or mail: To avoid too many false positives we don't try to catch
6402 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6403 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6404 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6405 ;; so that non-ambiguous entries (see above) match first.
6406 (gnus-button-mid-or-mail-regexp
6407 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6408 "*Alist of regexps matching buttons in article bodies.
6409
6410 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6411 REGEXP: is the string (case insensitive) matching text around the button (can
6412 also be Lisp expression evaluating to a string),
6413 BUTTON: is the number of the regexp grouping actually matching the button,
6414 FORM: is a Lisp expression which must eval to true for the button to
6415 be added,
6416 CALLBACK: is the function to call when the user push this button, and each
6417 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6418
6419 CALLBACK can also be a variable, in that case the value of that
6420 variable it the real callback function."
6421 :group 'gnus-article-buttons
6422 :type '(repeat (list (choice regexp variable sexp)
6423 (integer :tag "Button")
6424 (sexp :tag "Form")
6425 (function :tag "Callback")
6426 (repeat :tag "Par"
6427 :inline t
6428 (integer :tag "Regexp group")))))
6429
6430 (defcustom gnus-header-button-alist
6431 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6432 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6433 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6434 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6435 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6436 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6437 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6438 0 (>= gnus-button-browse-level 0) browse-url 0)
6439 ("^Subject:" gnus-button-url-regexp
6440 0 (>= gnus-button-browse-level 0) browse-url 0)
6441 ("^[^:]+:" gnus-button-url-regexp
6442 0 (>= gnus-button-browse-level 0) browse-url 0)
6443 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6444 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6445 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6446 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6447 "*Alist of headers and regexps to match buttons in article heads.
6448
6449 This alist is very similar to `gnus-button-alist', except that each
6450 alist has an additional HEADER element first in each entry:
6451
6452 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6453
6454 HEADER is a regexp to match a header. For a fuller explanation, see
6455 `gnus-button-alist'."
6456 :group 'gnus-article-buttons
6457 :group 'gnus-article-headers
6458 :type '(repeat (list (regexp :tag "Header")
6459 (choice regexp variable)
6460 (integer :tag "Button")
6461 (sexp :tag "Form")
6462 (function :tag "Callback")
6463 (repeat :tag "Par"
6464 :inline t
6465 (integer :tag "Regexp group")))))
6466
6467 (defvar gnus-button-regexp nil)
6468 (defvar gnus-button-marker-list nil)
6469 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6470
6471 (defvar gnus-button-last nil)
6472 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6473
6474 ;;; Commands:
6475
6476 (defun gnus-article-push-button (event)
6477 "Check text under the mouse pointer for a callback function.
6478 If the text under the mouse pointer has a `gnus-callback' property,
6479 call it with the value of the `gnus-data' text property."
6480 (interactive "e")
6481 (set-buffer (window-buffer (posn-window (event-start event))))
6482 (let* ((pos (posn-point (event-start event)))
6483 (data (get-text-property pos 'gnus-data))
6484 (fun (get-text-property pos 'gnus-callback)))
6485 (goto-char pos)
6486 (when fun
6487 (funcall fun data))))
6488
6489 (defun gnus-article-press-button ()
6490 "Check text at point for a callback function.
6491 If the text at point has a `gnus-callback' property,
6492 call it with the value of the `gnus-data' text property."
6493 (interactive)
6494 (let ((data (get-text-property (point) 'gnus-data))
6495 (fun (get-text-property (point) 'gnus-callback)))
6496 (when fun
6497 (funcall fun data))))
6498
6499 (defun gnus-article-highlight (&optional force)
6500 "Highlight current article.
6501 This function calls `gnus-article-highlight-headers',
6502 `gnus-article-highlight-citation',
6503 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6504 do the highlighting. See the documentation for those functions."
6505 (interactive (list 'force))
6506 (gnus-article-highlight-headers)
6507 (gnus-article-highlight-citation force)
6508 (gnus-article-highlight-signature)
6509 (gnus-article-add-buttons force)
6510 (gnus-article-add-buttons-to-head))
6511
6512 (defun gnus-article-highlight-some (&optional force)
6513 "Highlight current article.
6514 This function calls `gnus-article-highlight-headers',
6515 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6516 do the highlighting. See the documentation for those functions."
6517 (interactive (list 'force))
6518 (gnus-article-highlight-headers)
6519 (gnus-article-highlight-signature)
6520 (gnus-article-add-buttons))
6521
6522 (defun gnus-article-highlight-headers ()
6523 "Highlight article headers as specified by `gnus-header-face-alist'."
6524 (interactive)
6525 (save-excursion
6526 (set-buffer gnus-article-buffer)
6527 (save-restriction
6528 (let ((alist gnus-header-face-alist)
6529 (inhibit-read-only t)
6530 (case-fold-search t)
6531 (inhibit-point-motion-hooks t)
6532 entry regexp header-face field-face from hpoints fpoints)
6533 (article-narrow-to-head)
6534 (while (setq entry (pop alist))
6535 (goto-char (point-min))
6536 (setq regexp (concat "^\\("
6537 (if (string-equal "" (nth 0 entry))
6538 "[^\t ]"
6539 (nth 0 entry))
6540 "\\)")
6541 header-face (nth 1 entry)
6542 field-face (nth 2 entry))
6543 (while (and (re-search-forward regexp nil t)
6544 (not (eobp)))
6545 (beginning-of-line)
6546 (setq from (point))
6547 (unless (search-forward ":" nil t)
6548 (forward-char 1))
6549 (when (and header-face
6550 (not (memq (point) hpoints)))
6551 (push (point) hpoints)
6552 (gnus-put-text-property from (point) 'face header-face))
6553 (when (and field-face
6554 (not (memq (setq from (point)) fpoints)))
6555 (push from fpoints)
6556 (if (re-search-forward "^[^ \t]" nil t)
6557 (forward-char -2)
6558 (goto-char (point-max)))
6559 (gnus-put-text-property from (point) 'face field-face))))))))
6560
6561 (defun gnus-article-highlight-signature ()
6562 "Highlight the signature in an article.
6563 It does this by highlighting everything after
6564 `gnus-signature-separator' using the face `gnus-signature'."
6565 (interactive)
6566 (save-excursion
6567 (set-buffer gnus-article-buffer)
6568 (let ((inhibit-read-only t)
6569 (inhibit-point-motion-hooks t))
6570 (save-restriction
6571 (when (and gnus-signature-face
6572 (gnus-article-narrow-to-signature))
6573 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6574 'face gnus-signature-face)
6575 (widen)
6576 (gnus-article-search-signature)
6577 (let ((start (match-beginning 0))
6578 (end (set-marker (make-marker) (1+ (match-end 0)))))
6579 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6580 end)))))))
6581
6582 (defun gnus-button-in-region-p (b e prop)
6583 "Say whether PROP exists in the region."
6584 (text-property-not-all b e prop nil))
6585
6586 (defun gnus-article-add-buttons (&optional force)
6587 "Find external references in the article and make buttons of them.
6588 \"External references\" are things like Message-IDs and URLs, as
6589 specified by `gnus-button-alist'."
6590 (interactive (list 'force))
6591 (save-excursion
6592 (set-buffer gnus-article-buffer)
6593 (let ((inhibit-read-only t)
6594 (inhibit-point-motion-hooks t)
6595 (case-fold-search t)
6596 (alist gnus-button-alist)
6597 beg entry regexp)
6598 ;; Remove all old markers.
6599 (let (marker entry new-list)
6600 (while (setq marker (pop gnus-button-marker-list))
6601 (if (or (< marker (point-min)) (>= marker (point-max)))
6602 (push marker new-list)
6603 (goto-char marker)
6604 (when (setq entry (gnus-button-entry))
6605 (put-text-property (match-beginning (nth 1 entry))
6606 (match-end (nth 1 entry))
6607 'gnus-callback nil))
6608 (set-marker marker nil)))
6609 (setq gnus-button-marker-list new-list))
6610 ;; We skip the headers.
6611 (article-goto-body)
6612 (setq beg (point))
6613 (while (setq entry (pop alist))
6614 (setq regexp (eval (car entry)))
6615 (goto-char beg)
6616 (while (re-search-forward regexp nil t)
6617 (let* ((start (and entry (match-beginning (nth 1 entry))))
6618 (end (and entry (match-end (nth 1 entry))))
6619 (from (match-beginning 0)))
6620 (when (and (or (eq t (nth 2 entry))
6621 (eval (nth 2 entry)))
6622 (not (gnus-button-in-region-p
6623 start end 'gnus-callback)))
6624 ;; That optional form returned non-nil, so we add the
6625 ;; button.
6626 (gnus-article-add-button
6627 start end 'gnus-button-push
6628 (car (push (set-marker (make-marker) from)
6629 gnus-button-marker-list))))))))))
6630
6631 ;; Add buttons to the head of an article.
6632 (defun gnus-article-add-buttons-to-head ()
6633 "Add buttons to the head of the article."
6634 (interactive)
6635 (save-excursion
6636 (set-buffer gnus-article-buffer)
6637 (save-restriction
6638 (let ((inhibit-read-only t)
6639 (inhibit-point-motion-hooks t)
6640 (case-fold-search t)
6641 (alist gnus-header-button-alist)
6642 entry beg end)
6643 (article-narrow-to-head)
6644 (while alist
6645 ;; Each alist entry.
6646 (setq entry (car alist)
6647 alist (cdr alist))
6648 (goto-char (point-min))
6649 (while (re-search-forward (car entry) nil t)
6650 ;; Each header matching the entry.
6651 (setq beg (match-beginning 0))
6652 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6653 (match-beginning 0))
6654 (point-max)))
6655 (goto-char beg)
6656 (while (re-search-forward (eval (nth 1 entry)) end t)
6657 ;; Each match within a header.
6658 (let* ((entry (cdr entry))
6659 (start (match-beginning (nth 1 entry)))
6660 (end (match-end (nth 1 entry)))
6661 (form (nth 2 entry)))
6662 (goto-char (match-end 0))
6663 (when (eval form)
6664 (gnus-article-add-button
6665 start end (nth 3 entry)
6666 (buffer-substring (match-beginning (nth 4 entry))
6667 (match-end (nth 4 entry)))))))
6668 (goto-char end)))))))
6669
6670 ;;; External functions:
6671
6672 (defun gnus-article-add-button (from to fun &optional data)
6673 "Create a button between FROM and TO with callback FUN and data DATA."
6674 (when gnus-article-button-face
6675 (gnus-overlay-put (gnus-make-overlay from to)
6676 'face gnus-article-button-face))
6677 (gnus-add-text-properties
6678 from to
6679 (nconc (and gnus-article-mouse-face
6680 (list gnus-mouse-face-prop gnus-article-mouse-face))
6681 (list 'gnus-callback fun)
6682 (and data (list 'gnus-data data))))
6683 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6684 :button-keymap gnus-widget-button-keymap))
6685
6686 ;;; Internal functions:
6687
6688 (defun gnus-article-set-globals ()
6689 (save-excursion
6690 (set-buffer gnus-summary-buffer)
6691 (gnus-set-global-variables)))
6692
6693 (defun gnus-signature-toggle (end)
6694 (save-excursion
6695 (set-buffer gnus-article-buffer)
6696 (let ((inhibit-read-only t)
6697 (inhibit-point-motion-hooks t))
6698 (if (text-property-any end (point-max) 'article-type 'signature)
6699 (progn
6700 (gnus-delete-wash-type 'signature)
6701 (gnus-remove-text-properties-when
6702 'article-type 'signature end (point-max)
6703 (cons 'article-type (cons 'signature
6704 gnus-hidden-properties))))
6705 (gnus-add-wash-type 'signature)
6706 (gnus-add-text-properties-when
6707 'article-type nil end (point-max)
6708 (cons 'article-type (cons 'signature
6709 gnus-hidden-properties)))))
6710 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6711 (gnus-set-mode-line 'article))))
6712
6713 (defun gnus-button-entry ()
6714 ;; Return the first entry in `gnus-button-alist' matching this place.
6715 (let ((alist gnus-button-alist)
6716 (entry nil))
6717 (while alist
6718 (setq entry (pop alist))
6719 (if (looking-at (eval (car entry)))
6720 (setq alist nil)
6721 (setq entry nil)))
6722 entry))
6723
6724 (defun gnus-button-push (marker)
6725 ;; Push button starting at MARKER.
6726 (save-excursion
6727 (goto-char marker)
6728 (let* ((entry (gnus-button-entry))
6729 (inhibit-point-motion-hooks t)
6730 (fun (nth 3 entry))
6731 (args (mapcar (lambda (group)
6732 (let ((string (match-string group)))
6733 (gnus-set-text-properties
6734 0 (length string) nil string)
6735 string))
6736 (nthcdr 4 entry))))
6737 (cond
6738 ((fboundp fun)
6739 (apply fun args))
6740 ((and (boundp fun)
6741 (fboundp (symbol-value fun)))
6742 (apply (symbol-value fun) args))
6743 (t
6744 (gnus-message 1 "You must define `%S' to use this button"
6745 (cons fun args)))))))
6746
6747 (defun gnus-parse-news-url (url)
6748 (let (scheme server port group message-id articles)
6749 (with-temp-buffer
6750 (insert url)
6751 (goto-char (point-min))
6752 (when (looking-at "\\([A-Za-z]+\\):")
6753 (setq scheme (match-string 1))
6754 (goto-char (match-end 0)))
6755 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6756 (setq server (match-string 1))
6757 (setq port (if (stringp (match-string 3))
6758 (string-to-number (match-string 3))
6759 (match-string 3)))
6760 (goto-char (match-end 0)))
6761
6762 (cond
6763 ((looking-at "\\(.*@.*\\)")
6764 (setq message-id (match-string 1)))
6765 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6766 (setq group (match-string 1)
6767 articles (split-string (match-string 2) "-")))
6768 ((looking-at "\\([^/]+\\)/?")
6769 (setq group (match-string 1)))
6770 (t
6771 (error "Unknown news URL syntax"))))
6772 (list scheme server port group message-id articles)))
6773
6774 (defun gnus-button-handle-news (url)
6775 "Fetch a news URL."
6776 (destructuring-bind (scheme server port group message-id articles)
6777 (gnus-parse-news-url url)
6778 (cond
6779 (message-id
6780 (save-excursion
6781 (set-buffer gnus-summary-buffer)
6782 (if server
6783 (let ((gnus-refer-article-method
6784 (nconc (list (list 'nntp server))
6785 gnus-refer-article-method))
6786 (nntp-port-number (or port "nntp")))
6787 (gnus-message 7 "Fetching %s with %s"
6788 message-id gnus-refer-article-method)
6789 (gnus-summary-refer-article message-id))
6790 (gnus-summary-refer-article message-id))))
6791 (group
6792 (gnus-button-fetch-group url)))))
6793
6794 (defun gnus-button-handle-man (url)
6795 "Fetch a man page."
6796 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6797 (when (eq gnus-button-man-handler 'woman)
6798 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6799 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6800 (funcall gnus-button-man-handler url))
6801
6802 (defun gnus-button-handle-info-url (url)
6803 "Fetch an info URL."
6804 (setq url (mm-subst-char-in-string ?+ ?\ url))
6805 (cond
6806 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6807 (gnus-info-find-node
6808 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6809 "Gnus")
6810 ")" (gnus-url-unhex-string (match-string 2 url)))))
6811 ((string-match "([^)\"]+)[^\"]+" url)
6812 (setq url
6813 (gnus-replace-in-string
6814 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6815 (gnus-info-find-node url))
6816 (t (error "Can't parse %s" url))))
6817
6818 (defun gnus-button-handle-info-url-gnome (url)
6819 "Fetch GNOME style info URL."
6820 (setq url (mm-subst-char-in-string ?_ ?\ url))
6821 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6822 (gnus-info-find-node
6823 (concat "("
6824 (gnus-url-unhex-string
6825 (match-string 1 url))
6826 ")"
6827 (or (gnus-url-unhex-string
6828 (match-string 2 url))
6829 "Top")))
6830 (error "Can't parse %s" url)))
6831
6832 (defun gnus-button-handle-info-url-kde (url)
6833 "Fetch KDE style info URL."
6834 (gnus-info-find-node (gnus-url-unhex-string url)))
6835
6836 (defun gnus-button-handle-info-keystrokes (url)
6837 "Call `info' when pushing the corresponding URL button."
6838 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6839 (info)
6840 (Info-directory)
6841 (Info-menu url))
6842
6843 (defun gnus-button-message-id (message-id)
6844 "Fetch MESSAGE-ID."
6845 (save-excursion
6846 (set-buffer gnus-summary-buffer)
6847 (gnus-summary-refer-article message-id)))
6848
6849 (defun gnus-button-fetch-group (address)
6850 "Fetch GROUP specified by ADDRESS."
6851 (if (not (string-match "[:/]" address))
6852 ;; This is just a simple group url.
6853 (gnus-group-read-ephemeral-group address gnus-select-method)
6854 (if (not
6855 (string-match
6856 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6857 address))
6858 (error "Can't parse %s" address)
6859 (gnus-group-read-ephemeral-group
6860 (match-string 4 address)
6861 `(nntp ,(match-string 1 address)
6862 (nntp-address ,(match-string 1 address))
6863 (nntp-port-number ,(if (match-end 3)
6864 (match-string 3 address)
6865 "nntp")))
6866 nil nil nil
6867 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6868
6869 (defun gnus-url-parse-query-string (query &optional downcase)
6870 (let (retval pairs cur key val)
6871 (setq pairs (split-string query "&"))
6872 (while pairs
6873 (setq cur (car pairs)
6874 pairs (cdr pairs))
6875 (if (not (string-match "=" cur))
6876 nil ; Grace
6877 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6878 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6879 (if downcase
6880 (setq key (downcase key)))
6881 (setq cur (assoc key retval))
6882 (if cur
6883 (setcdr cur (cons val (cdr cur)))
6884 (setq retval (cons (list key val) retval)))))
6885 retval))
6886
6887 (defun gnus-url-mailto (url)
6888 ;; Send mail to someone
6889 (when (string-match "mailto:/*\\(.*\\)" url)
6890 (setq url (substring url (match-beginning 1) nil)))
6891 (let (to args subject func)
6892 (setq args (gnus-url-parse-query-string
6893 (if (string-match "^\\?" url)
6894 (substring url 1)
6895 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6896 (concat "to=" (match-string 1 url) "&"
6897 (match-string 2 url))
6898 (concat "to=" url)))
6899 t)
6900 subject (cdr-safe (assoc "subject" args)))
6901 (gnus-msg-mail)
6902 (while args
6903 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6904 (if (fboundp func)
6905 (funcall func)
6906 (message-position-on-field (caar args)))
6907 (insert (gnus-replace-in-string
6908 (mapconcat 'identity (reverse (cdar args)) ", ")
6909 "\r\n" "\n" t))
6910 (setq args (cdr args)))
6911 (if subject
6912 (message-goto-body)
6913 (message-goto-subject))))
6914
6915 (defun gnus-button-embedded-url (address)
6916 "Activate ADDRESS with `browse-url'."
6917 (browse-url (gnus-strip-whitespace address)))
6918
6919 ;;; Next/prev buttons in the article buffer.
6920
6921 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6922 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6923
6924 (defvar gnus-prev-page-map
6925 (let ((map (make-sparse-keymap)))
6926 (unless (>= emacs-major-version 21)
6927 ;; XEmacs doesn't care.
6928 (set-keymap-parent map gnus-article-mode-map))
6929 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6930 (define-key map "\r" 'gnus-button-prev-page)
6931 map))
6932
6933 (defvar gnus-next-page-map
6934 (let ((map (make-sparse-keymap)))
6935 (unless (>= emacs-major-version 21)
6936 ;; XEmacs doesn't care.
6937 (set-keymap-parent map gnus-article-mode-map))
6938 (define-key map gnus-mouse-2 'gnus-button-next-page)
6939 (define-key map "\r" 'gnus-button-next-page)
6940 map))
6941
6942 (defun gnus-insert-prev-page-button ()
6943 (let ((b (point))
6944 (inhibit-read-only t))
6945 (gnus-eval-format
6946 gnus-prev-page-line-format nil
6947 `(,@(gnus-local-map-property gnus-prev-page-map)
6948 gnus-prev t
6949 gnus-callback gnus-article-button-prev-page
6950 article-type annotation))
6951 (widget-convert-button
6952 'link b (if (bolp)
6953 ;; Exclude a newline.
6954 (1- (point))
6955 (point))
6956 :action 'gnus-button-prev-page
6957 :button-keymap gnus-prev-page-map)))
6958
6959 (defun gnus-button-next-page (&optional args more-args)
6960 "Go to the next page."
6961 (interactive)
6962 (let ((win (selected-window)))
6963 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6964 (gnus-article-next-page)
6965 (select-window win)))
6966
6967 (defun gnus-button-prev-page (&optional args more-args)
6968 "Go to the prev page."
6969 (interactive)
6970 (let ((win (selected-window)))
6971 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6972 (gnus-article-prev-page)
6973 (select-window win)))
6974
6975 (defun gnus-insert-next-page-button ()
6976 (let ((b (point))
6977 (inhibit-read-only t))
6978 (gnus-eval-format gnus-next-page-line-format nil
6979 `(,@(gnus-local-map-property gnus-next-page-map)
6980 gnus-next t
6981 gnus-callback gnus-article-button-next-page
6982 article-type annotation))
6983 (widget-convert-button
6984 'link b (if (bolp)
6985 ;; Exclude a newline.
6986 (1- (point))
6987 (point))
6988 :action 'gnus-button-next-page
6989 :button-keymap gnus-next-page-map)))
6990
6991 (defun gnus-article-button-next-page (arg)
6992 "Go to the next page."
6993 (interactive "P")
6994 (let ((win (selected-window)))
6995 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6996 (gnus-article-next-page)
6997 (select-window win)))
6998
6999 (defun gnus-article-button-prev-page (arg)
7000 "Go to the prev page."
7001 (interactive "P")
7002 (let ((win (selected-window)))
7003 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7004 (gnus-article-prev-page)
7005 (select-window win)))
7006
7007 (defvar gnus-decode-header-methods
7008 '(mail-decode-encoded-word-region)
7009 "List of methods used to decode headers.
7010
7011 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7012 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7013 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7014 whose names match REGEXP.
7015
7016 For example:
7017 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7018 mail-decode-encoded-word-region
7019 (\"chinese\" . rfc1843-decode-region))
7020 ")
7021
7022 (defvar gnus-decode-header-methods-cache nil)
7023
7024 (defun gnus-multi-decode-header (start end)
7025 "Apply the functions from `gnus-encoded-word-methods' that match."
7026 (unless (and gnus-decode-header-methods-cache
7027 (eq gnus-newsgroup-name
7028 (car gnus-decode-header-methods-cache)))
7029 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7030 (mapcar (lambda (x)
7031 (if (symbolp x)
7032 (nconc gnus-decode-header-methods-cache (list x))
7033 (if (and gnus-newsgroup-name
7034 (string-match (car x) gnus-newsgroup-name))
7035 (nconc gnus-decode-header-methods-cache
7036 (list (cdr x))))))
7037 gnus-decode-header-methods))
7038 (let ((xlist gnus-decode-header-methods-cache))
7039 (pop xlist)
7040 (save-restriction
7041 (narrow-to-region start end)
7042 (while xlist
7043 (funcall (pop xlist) (point-min) (point-max))))))
7044
7045 ;;;
7046 ;;; Treatment top-level handling.
7047 ;;;
7048
7049 (defun gnus-treat-article (condition &optional part-number total-parts type)
7050 (let ((length (- (point-max) (point-min)))
7051 (alist gnus-treatment-function-alist)
7052 (article-goto-body-goes-to-point-min-p t)
7053 (treated-type
7054 (or (not type)
7055 (catch 'found
7056 (let ((list gnus-article-treat-types))
7057 (while list
7058 (when (string-match (pop list) type)
7059 (throw 'found t)))))))
7060 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7061 val elem)
7062 (gnus-run-hooks 'gnus-part-display-hook)
7063 (dolist (elem alist)
7064 (setq val
7065 (save-excursion
7066 (when (gnus-buffer-live-p gnus-summary-buffer)
7067 (set-buffer gnus-summary-buffer))
7068 (symbol-value (car elem))))
7069 (when (and (or (consp val)
7070 treated-type)
7071 (gnus-treat-predicate val)
7072 (or (not (get (car elem) 'highlight))
7073 highlightp))
7074 (save-restriction
7075 (funcall (cadr elem)))))))
7076
7077 ;; Dynamic variables.
7078 (eval-when-compile
7079 (defvar part-number)
7080 (defvar total-parts)
7081 (defvar type)
7082 (defvar condition)
7083 (defvar length))
7084
7085 (defun gnus-treat-predicate (val)
7086 (cond
7087 ((null val)
7088 nil)
7089 (condition
7090 (eq condition val))
7091 ((and (listp val)
7092 (stringp (car val)))
7093 (apply 'gnus-or (mapcar `(lambda (s)
7094 (string-match s ,(or gnus-newsgroup-name "")))
7095 val)))
7096 ((listp val)
7097 (let ((pred (pop val)))
7098 (cond
7099 ((eq pred 'or)
7100 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7101 ((eq pred 'and)
7102 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7103 ((eq pred 'not)
7104 (not (gnus-treat-predicate (car val))))
7105 ((eq pred 'typep)
7106 (equal (car val) type))
7107 (t
7108 (error "%S is not a valid predicate" pred)))))
7109 ((eq val t)
7110 t)
7111 ((eq val 'head)
7112 nil)
7113 ((eq val 'last)
7114 (eq part-number total-parts))
7115 ((numberp val)
7116 (< length val))
7117 (t
7118 (error "%S is not a valid value" val))))
7119
7120 (defun gnus-article-encrypt-body (protocol &optional n)
7121 "Encrypt the article body."
7122 (interactive
7123 (list
7124 (or gnus-article-encrypt-protocol
7125 (completing-read "Encrypt protocol: "
7126 gnus-article-encrypt-protocol-alist
7127 nil t))
7128 current-prefix-arg))
7129 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7130 (unless func
7131 (error "Can't find the encrypt protocol %s" protocol))
7132 (if (member gnus-newsgroup-name '("nndraft:delayed"
7133 "nndraft:drafts"
7134 "nndraft:queue"))
7135 (error "Can't encrypt the article in group %s"
7136 gnus-newsgroup-name))
7137 (gnus-summary-iterate n
7138 (save-excursion
7139 (set-buffer gnus-summary-buffer)
7140 (let ((mail-parse-charset gnus-newsgroup-charset)
7141 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7142 (summary-buffer gnus-summary-buffer)
7143 references point)
7144 (gnus-set-global-variables)
7145 (when (gnus-group-read-only-p)
7146 (error "The current newsgroup does not support article encrypt"))
7147 (gnus-summary-show-article t)
7148 (setq references
7149 (or (mail-header-references gnus-current-headers) ""))
7150 (set-buffer gnus-article-buffer)
7151 (let* ((inhibit-read-only t)
7152 (headers
7153 (mapcar (lambda (field)
7154 (and (save-restriction
7155 (message-narrow-to-head)
7156 (goto-char (point-min))
7157 (search-forward field nil t))
7158 (prog2
7159 (message-narrow-to-field)
7160 (buffer-string)
7161 (delete-region (point-min) (point-max))
7162 (widen))))
7163 '("Content-Type:" "Content-Transfer-Encoding:"
7164 "Content-Disposition:"))))
7165 (message-narrow-to-head)
7166 (message-remove-header "MIME-Version")
7167 (goto-char (point-max))
7168 (setq point (point))
7169 (insert (apply 'concat headers))
7170 (widen)
7171 (narrow-to-region point (point-max))
7172 (let ((message-options message-options))
7173 (message-options-set 'message-sender user-mail-address)
7174 (message-options-set 'message-recipients user-mail-address)
7175 (message-options-set 'message-sign-encrypt 'not)
7176 (funcall func))
7177 (goto-char (point-min))
7178 (insert "MIME-Version: 1.0\n")
7179 (widen)
7180 (gnus-summary-edit-article-done
7181 references nil summary-buffer t))
7182 (when gnus-keep-backlog
7183 (gnus-backlog-remove-article
7184 (car gnus-article-current) (cdr gnus-article-current)))
7185 (save-excursion
7186 (when (get-buffer gnus-original-article-buffer)
7187 (set-buffer gnus-original-article-buffer)
7188 (setq gnus-original-article nil)))
7189 (when gnus-use-cache
7190 (gnus-cache-update-article
7191 (car gnus-article-current) (cdr gnus-article-current))))))))
7192
7193 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7194 "The following specs can be used:
7195 %t The security MIME type
7196 %i Additional info
7197 %d Details
7198 %D Details if button is pressed")
7199
7200 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7201 "The following specs can be used:
7202 %t The security MIME type
7203 %i Additional info
7204 %d Details
7205 %D Details if button is pressed")
7206
7207 (defvar gnus-mime-security-button-line-format-alist
7208 '((?t gnus-tmp-type ?s)
7209 (?i gnus-tmp-info ?s)
7210 (?d gnus-tmp-details ?s)
7211 (?D gnus-tmp-pressed-details ?s)))
7212
7213 (defvar gnus-mime-security-button-map
7214 (let ((map (make-sparse-keymap)))
7215 (unless (>= (string-to-number emacs-version) 21)
7216 (set-keymap-parent map gnus-article-mode-map))
7217 (define-key map gnus-mouse-2 'gnus-article-push-button)
7218 (define-key map "\r" 'gnus-article-press-button)
7219 map))
7220
7221 (defvar gnus-mime-security-details-buffer nil)
7222
7223 (defvar gnus-mime-security-button-pressed nil)
7224
7225 (defvar gnus-mime-security-show-details-inline t
7226 "If non-nil, show details in the article buffer.")
7227
7228 (defun gnus-mime-security-verify-or-decrypt (handle)
7229 (mm-remove-parts (cdr handle))
7230 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7231 point (inhibit-read-only t))
7232 (if region
7233 (goto-char (car region)))
7234 (save-restriction
7235 (narrow-to-region (point) (point))
7236 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7237 (let* ((mm-verify-option 'known)
7238 (mm-decrypt-option 'known)
7239 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7240 (unless (eq nparts (cdr handle))
7241 (mm-destroy-parts (cdr handle))
7242 (setcdr handle nparts))))
7243 (setq point (point))
7244 (gnus-mime-display-security handle)
7245 (goto-char (point-max)))
7246 (when region
7247 (delete-region (point) (cdr region))
7248 (set-marker (car region) nil)
7249 (set-marker (cdr region) nil))
7250 (goto-char point)))
7251
7252 (defun gnus-mime-security-show-details (handle)
7253 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7254 (if (not details)
7255 (gnus-message 5 "No details.")
7256 (if gnus-mime-security-show-details-inline
7257 (let ((gnus-mime-security-button-pressed
7258 (not (get-text-property (point) 'gnus-mime-details)))
7259 (gnus-mime-security-button-line-format
7260 (get-text-property (point) 'gnus-line-format))
7261 (inhibit-read-only t))
7262 (forward-char -1)
7263 (while (eq (get-text-property (point) 'gnus-line-format)
7264 gnus-mime-security-button-line-format)
7265 (forward-char -1))
7266 (forward-char)
7267 (save-restriction
7268 (narrow-to-region (point) (point))
7269 (gnus-insert-mime-security-button handle))
7270 (delete-region (point)
7271 (or (text-property-not-all
7272 (point) (point-max)
7273 'gnus-line-format
7274 gnus-mime-security-button-line-format)
7275 (point-max))))
7276 ;; Not inlined.
7277 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7278 (with-current-buffer gnus-mime-security-details-buffer
7279 (erase-buffer)
7280 t)
7281 (setq gnus-mime-security-details-buffer
7282 (gnus-get-buffer-create "*MIME Security Details*")))
7283 (with-current-buffer gnus-mime-security-details-buffer
7284 (insert details)
7285 (goto-char (point-min)))
7286 (pop-to-buffer gnus-mime-security-details-buffer)))))
7287
7288 (defun gnus-mime-security-press-button (handle)
7289 (save-excursion
7290 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7291 (gnus-mime-security-show-details handle)
7292 (gnus-mime-security-verify-or-decrypt handle))))
7293
7294 (defun gnus-insert-mime-security-button (handle &optional displayed)
7295 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7296 (gnus-tmp-type
7297 (concat
7298 (or (nth 2 (assoc protocol mm-verify-function-alist))
7299 (nth 2 (assoc protocol mm-decrypt-function-alist))
7300 "Unknown")
7301 (if (equal (car handle) "multipart/signed")
7302 " Signed" " Encrypted")
7303 " Part"))
7304 (gnus-tmp-info
7305 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7306 "Undecided"))
7307 (gnus-tmp-details
7308 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7309 gnus-tmp-pressed-details
7310 b e)
7311 (setq gnus-tmp-details
7312 (if gnus-tmp-details
7313 (concat "\n" gnus-tmp-details)
7314 ""))
7315 (setq gnus-tmp-pressed-details
7316 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7317 (unless (bolp)
7318 (insert "\n"))
7319 (setq b (point))
7320 (gnus-eval-format
7321 gnus-mime-security-button-line-format
7322 gnus-mime-security-button-line-format-alist
7323 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7324 gnus-callback gnus-mime-security-press-button
7325 gnus-line-format ,gnus-mime-security-button-line-format
7326 gnus-mime-details ,gnus-mime-security-button-pressed
7327 article-type annotation
7328 gnus-data ,handle))
7329 (setq e (if (bolp)
7330 ;; Exclude a newline.
7331 (1- (point))
7332 (point)))
7333 (widget-convert-button
7334 'link b e
7335 :mime-handle handle
7336 :action 'gnus-widget-press-button
7337 :button-keymap gnus-mime-security-button-map
7338 :help-echo
7339 (lambda (widget/window &optional overlay pos)
7340 ;; Needed to properly clear the message due to a bug in
7341 ;; wid-edit (XEmacs only).
7342 (when (boundp 'help-echo-owns-message)
7343 (setq help-echo-owns-message t))
7344 (format
7345 "%S: show detail"
7346 (aref gnus-mouse-2 0))))))
7347
7348 (defun gnus-mime-display-security (handle)
7349 (save-restriction
7350 (narrow-to-region (point) (point))
7351 (unless (gnus-unbuttonized-mime-type-p (car handle))
7352 (gnus-insert-mime-security-button handle))
7353 (gnus-mime-display-mixed (cdr handle))
7354 (unless (bolp)
7355 (insert "\n"))
7356 (unless (gnus-unbuttonized-mime-type-p (car handle))
7357 (let ((gnus-mime-security-button-line-format
7358 gnus-mime-security-button-end-line-format))
7359 (gnus-insert-mime-security-button handle)))
7360 (mm-set-handle-multipart-parameter
7361 handle 'gnus-region
7362 (cons (set-marker (make-marker) (point-min))
7363 (set-marker (make-marker) (point-max))))))
7364
7365 (gnus-ems-redefine)
7366
7367 (provide 'gnus-art)
7368
7369 (run-hooks 'gnus-art-load-hook)
7370
7371 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7372 ;;; gnus-art.el ends here