1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^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:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
247 ;; frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
400 "Face used for displaying strike-through text (-word-)."
401 :group 'gnus-article-emphasis)
403 (defface gnus-emphasis-highlight-words
404 '((t (:background "black" :foreground "yellow")))
405 "Face used for displaying highlighted words."
406 :group 'gnus-article-emphasis)
408 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
409 "Format for display of Date headers in article bodies.
410 See `format-time-string' for the possible values.
412 The variable can also be function, which should return a complete Date
413 header. The function is called with one argument, the time, which can
414 be fed to `format-time-string'."
415 :type '(choice string symbol)
416 :link '(custom-manual "(gnus)Article Date")
417 :group 'gnus-article-washing)
420 (autoload 'mail-extract-address-components "mail-extr"))
422 (defcustom gnus-save-all-headers t
423 "*If non-nil, don't remove any headers before saving."
424 :group 'gnus-article-saving
427 (defcustom gnus-prompt-before-saving 'always
428 "*This variable says how much prompting is to be done when saving articles.
429 If it is nil, no prompting will be done, and the articles will be
430 saved to the default files. If this variable is `always', each and
431 every article that is saved will be preceded by a prompt, even when
432 saving large batches of articles. If this variable is neither nil not
433 `always', there the user will be prompted once for a file name for
434 each invocation of the saving commands."
435 :group 'gnus-article-saving
436 :type '(choice (item always)
437 (item :tag "never" nil)
438 (sexp :tag "once" :format "%t\n" :value t)))
440 (defcustom gnus-saved-headers gnus-visible-headers
441 "Headers to keep if `gnus-save-all-headers' is nil.
442 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
443 If that variable is nil, however, all headers that match this regexp
444 will be kept while the rest will be deleted before saving."
445 :group 'gnus-article-saving
448 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
449 "A function to save articles in your favourite format.
450 The function must be interactively callable (in other words, it must
451 be an Emacs command).
453 Gnus provides the following functions:
455 * gnus-summary-save-in-rmail (Rmail format)
456 * gnus-summary-save-in-mail (Unix mail format)
457 * gnus-summary-save-in-folder (MH folder)
458 * gnus-summary-save-in-file (article format)
459 * gnus-summary-save-body-in-file (article body)
460 * gnus-summary-save-in-vm (use VM's folder format)
461 * gnus-summary-write-to-file (article format -- overwrite)."
462 :group 'gnus-article-saving
463 :type '(radio (function-item gnus-summary-save-in-rmail)
464 (function-item gnus-summary-save-in-mail)
465 (function-item gnus-summary-save-in-folder)
466 (function-item gnus-summary-save-in-file)
467 (function-item gnus-summary-save-body-in-file)
468 (function-item gnus-summary-save-in-vm)
469 (function-item gnus-summary-write-to-file)))
471 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
472 "A function generating a file name to save articles in Rmail format.
473 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
474 :group 'gnus-article-saving
477 (defcustom gnus-mail-save-name 'gnus-plain-save-name
478 "A function generating a file name to save articles in Unix mail format.
479 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
480 :group 'gnus-article-saving
483 (defcustom gnus-folder-save-name 'gnus-folder-save-name
484 "A function generating a file name to save articles in MH folder.
485 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
486 :group 'gnus-article-saving
489 (defcustom gnus-file-save-name 'gnus-numeric-save-name
490 "A function generating a file name to save articles in article format.
491 The function is called with NEWSGROUP, HEADERS, and optional
493 :group 'gnus-article-saving
496 (defcustom gnus-split-methods
497 '((gnus-article-archive-name)
498 (gnus-article-nndoc-name))
499 "*Variable used to suggest where articles are to be saved.
500 For instance, if you would like to save articles related to Gnus in
501 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
502 you could set this variable to something like:
504 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
505 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
507 This variable is an alist where the where the key is the match and the
508 value is a list of possible files to save in if the match is non-nil.
510 If the match is a string, it is used as a regexp match on the
511 article. If the match is a symbol, that symbol will be funcalled
512 from the buffer of the article to be saved with the newsgroup as the
513 parameter. If it is a list, it will be evaled in the same buffer.
515 If this form or function returns a string, this string will be used as
516 a possible file name; and if it returns a non-nil list, that list will
517 be used as possible file names."
518 :group 'gnus-article-saving
519 :type '(repeat (choice (list :value (fun) function)
520 (cons :value ("" "") regexp (repeat string))
523 (defcustom gnus-page-delimiter "^\^L"
524 "*Regexp describing what to use as article page delimiters.
525 The default value is \"^\^L\", which is a form linefeed at the
526 beginning of a line."
528 :group 'gnus-article-various)
530 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
531 "*The format specification for the article mode line.
532 See `gnus-summary-mode-line-format' for a closer description.
534 The following additional specs are available:
536 %w The article washing status.
537 %m The number of MIME parts in the article."
539 :group 'gnus-article-various)
541 (defcustom gnus-article-mode-hook nil
542 "*A hook for Gnus article mode."
544 :group 'gnus-article-various)
546 (when (featurep 'xemacs)
547 ;; Extracted from gnus-xmas-define in order to preserve user settings
548 (when (fboundp 'turn-off-scroll-in-place)
549 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
550 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
551 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
553 (defcustom gnus-article-menu-hook nil
554 "*Hook run after the creation of the article mode menu."
556 :group 'gnus-article-various)
558 (defcustom gnus-article-prepare-hook nil
559 "*A hook called after an article has been prepared in the article buffer."
561 :group 'gnus-article-various)
563 (make-obsolete-variable 'gnus-article-hide-pgp-hook
564 "This variable is obsolete in Gnus 5.10.")
566 (defcustom gnus-article-button-face 'bold
567 "Face used for highlighting buttons in the article buffer.
569 An article button is a piece of text that you can activate by pressing
570 `RET' or `mouse-2' above it."
572 :group 'gnus-article-buttons)
574 (defcustom gnus-article-mouse-face 'highlight
575 "Face used for mouse highlighting in the article buffer.
577 Article buttons will be displayed in this face when the cursor is
580 :group 'gnus-article-buttons)
582 (defcustom gnus-signature-face 'gnus-signature-face
583 "Face used for highlighting a signature in the article buffer.
584 Obsolete; use the face `gnus-signature-face' for customizations instead."
586 :group 'gnus-article-highlight
587 :group 'gnus-article-signature)
589 (defface gnus-signature-face
592 "Face used for highlighting a signature in the article buffer."
593 :group 'gnus-article-highlight
594 :group 'gnus-article-signature)
596 (defface gnus-header-from-face
599 (:foreground "spring green"))
602 (:foreground "red3"))
605 "Face used for displaying from headers."
606 :group 'gnus-article-headers
607 :group 'gnus-article-highlight)
609 (defface gnus-header-subject-face
612 (:foreground "SeaGreen3"))
615 (:foreground "red4"))
617 (:bold t :italic t)))
618 "Face used for displaying subject headers."
619 :group 'gnus-article-headers
620 :group 'gnus-article-highlight)
622 (defface gnus-header-newsgroups-face
625 (:foreground "yellow" :italic t))
628 (:foreground "MidnightBlue" :italic t))
631 "Face used for displaying newsgroups headers.
632 In the default setup this face is only used for crossposted
634 :group 'gnus-article-headers
635 :group 'gnus-article-highlight)
637 (defface gnus-header-name-face
640 (:foreground "SeaGreen"))
643 (:foreground "maroon"))
646 "Face used for displaying header names."
647 :group 'gnus-article-headers
648 :group 'gnus-article-highlight)
650 (defface gnus-header-content-face
653 (:foreground "forest green" :italic t))
656 (:foreground "indianred4" :italic t))
658 (:italic t))) "Face used for displaying header content."
659 :group 'gnus-article-headers
660 :group 'gnus-article-highlight)
662 (defcustom gnus-header-face-alist
663 '(("From" nil gnus-header-from-face)
664 ("Subject" nil gnus-header-subject-face)
665 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
666 ("" gnus-header-name-face gnus-header-content-face))
667 "*Controls highlighting of article headers.
669 An alist of the form (HEADER NAME CONTENT).
671 HEADER is a regular expression which should match the name of a
672 header and NAME and CONTENT are either face names or nil.
674 The name of each header field will be displayed using the face
675 specified by the first element in the list where HEADER matches
676 the header name and NAME is non-nil. Similarly, the content will
677 be displayed by the first non-nil matching CONTENT face."
678 :group 'gnus-article-headers
679 :group 'gnus-article-highlight
680 :type '(repeat (list (regexp :tag "Header")
682 (item :tag "skip" nil)
683 (face :value default))
684 (choice :tag "Content"
685 (item :tag "skip" nil)
686 (face :value default)))))
688 (defcustom gnus-article-decode-hook
689 '(article-decode-charset article-decode-encoded-words
690 article-decode-group-name article-decode-idna-rhs)
691 "*Hook run to decode charsets in articles."
692 :group 'gnus-article-headers
695 (defcustom gnus-display-mime-function 'gnus-display-mime
696 "Function to display MIME articles."
697 :group 'gnus-article-mime
700 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
701 "Function used to decode headers.")
703 (defvar gnus-article-dumbquotes-map
723 "Table for MS-to-Latin1 translation.")
725 (defcustom gnus-ignored-mime-types nil
726 "List of MIME types that should be ignored by Gnus."
728 :group 'gnus-article-mime
729 :type '(repeat regexp))
731 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
732 "List of MIME types that should not be given buttons when rendered inline.
733 See also `gnus-buttonized-mime-types' which may override this variable.
734 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
736 :group 'gnus-article-mime
737 :type '(repeat regexp))
739 (defcustom gnus-buttonized-mime-types nil
740 "List of MIME types that should be given buttons when rendered inline.
741 If set, this variable overrides `gnus-unbuttonized-mime-types'.
742 To see e.g. security buttons you could set this to
743 `(\"multipart/signed\")'.
744 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
746 :group 'gnus-article-mime
747 :type '(repeat regexp))
749 (defcustom gnus-inhibit-mime-unbuttonizing nil
750 "If non-nil, all MIME parts get buttons.
751 When nil (the default value), then some MIME parts do not get buttons,
752 as described by the variables `gnus-buttonized-mime-types' and
753 `gnus-unbuttonized-mime-types'."
757 (defcustom gnus-body-boundary-delimiter "_"
758 "String used to delimit header and body.
759 This variable is used by `gnus-article-treat-body-boundary' which can
760 be controlled by `gnus-treat-body-boundary'."
761 :group 'gnus-article-various
762 :type '(choice (item :tag "None" :value nil)
765 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
766 "Defines the location of the faces database.
767 For information on obtaining this database of pretty pictures, please
768 see http://www.cs.indiana.edu/picons/ftp/index.html"
769 :type '(repeat directory)
770 :link '(url-link :tag "download"
771 "http://www.cs.indiana.edu/picons/ftp/index.html")
772 :link '(custom-manual "(gnus)Picons")
775 (defun gnus-picons-installed-p ()
776 "Say whether picons are installed on your machine."
777 (let ((installed nil))
778 (dolist (database gnus-picon-databases)
779 (when (file-exists-p database)
783 (defcustom gnus-article-mime-part-function nil
784 "Function called with a MIME handle as the argument.
785 This is meant for people who want to do something automatic based
786 on parts -- for instance, adding Vcard info to a database."
787 :group 'gnus-article-mime
790 (defcustom gnus-mime-multipart-functions nil
791 "An alist of MIME types to functions to display them."
793 :group 'gnus-article-mime
796 (defcustom gnus-article-date-lapsed-new-header nil
797 "Whether the X-Sent and Date headers can coexist.
798 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
799 either replace the old \"Date:\" header (if this variable is nil), or
800 be added below it (otherwise)."
802 :group 'gnus-article-headers
805 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
806 "Function called with a MIME handle as the argument.
807 This is meant for people who want to view first matched part.
808 For `undisplayed-alternative' (default), the first undisplayed
809 part or alternative part is used. For `undisplayed', the first
810 undisplayed part is used. For a function, the first part which
811 the function return t is used. For nil, the first part is
814 :group 'gnus-article-mime
816 (item :tag "first" :value nil)
817 (item :tag "undisplayed" :value undisplayed)
818 (item :tag "undisplayed or alternative"
819 :value undisplayed-alternative)
822 (defcustom gnus-mime-action-alist
823 '(("save to file" . gnus-mime-save-part)
824 ("save and strip" . gnus-mime-save-part-and-strip)
825 ("delete part" . gnus-mime-delete-part)
826 ("display as text" . gnus-mime-inline-part)
827 ("view the part" . gnus-mime-view-part)
828 ("pipe to command" . gnus-mime-pipe-part)
829 ("toggle display" . gnus-article-press-button)
830 ("toggle display" . gnus-article-view-part-as-charset)
831 ("view as type" . gnus-mime-view-part-as-type)
832 ("view internally" . gnus-mime-view-part-internally)
833 ("view externally" . gnus-mime-view-part-externally))
834 "An alist of actions that run on the MIME attachment."
835 :group 'gnus-article-mime
836 :type '(repeat (cons (string :tag "name")
840 ;;; The treatment variables
843 (defvar gnus-part-display-hook nil
844 "Hook called on parts that are to receive treatment.")
846 (defvar gnus-article-treat-custom
847 '(choice (const :tag "Off" nil)
849 (const :tag "Header" head)
850 (const :tag "Last" last)
851 (integer :tag "Less")
852 (repeat :tag "Groups" regexp)
853 (sexp :tag "Predicate")))
855 (defvar gnus-article-treat-head-custom
856 '(choice (const :tag "Off" nil)
857 (const :tag "Header" head)))
859 (defvar gnus-article-treat-types '("text/plain")
862 (defvar gnus-inhibit-treatment nil
863 "Whether to inhibit treatment.")
865 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
866 "Highlight the signature.
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See Info node `(gnus)Customizing Articles'."
869 :group 'gnus-article-treat
870 :link '(custom-manual "(gnus)Customizing Articles")
871 :type gnus-article-treat-custom)
872 (put 'gnus-treat-highlight-signature 'highlight t)
874 (defcustom gnus-treat-buttonize 100000
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles'."
878 :group 'gnus-article-treat
879 :link '(custom-manual "(gnus)Customizing Articles")
880 :type gnus-article-treat-custom)
881 (put 'gnus-treat-buttonize 'highlight t)
883 (defcustom gnus-treat-buttonize-head 'head
884 "Add buttons to the head.
885 Valid values are nil, t, `head', `last', an integer or a predicate.
886 See Info node `(gnus)Customizing Articles' for details."
887 :group 'gnus-article-treat
888 :link '(custom-manual "(gnus)Customizing Articles")
889 :type gnus-article-treat-head-custom)
890 (put 'gnus-treat-buttonize-head 'highlight t)
892 (defcustom gnus-treat-emphasize
893 (and (or window-system
895 (>= (string-to-number emacs-version) 21))
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :link '(custom-manual "(gnus)Customizing Articles")
902 :type gnus-article-treat-custom)
903 (put 'gnus-treat-emphasize 'highlight t)
905 (defcustom gnus-treat-strip-cr nil
906 "Remove carriage returns.
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles' for details."
909 :group 'gnus-article-treat
910 :link '(custom-manual "(gnus)Customizing Articles")
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-unsplit-urls nil
914 "Remove newlines from within URLs.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See Info node `(gnus)Customizing Articles' for details."
917 :group 'gnus-article-treat
918 :link '(custom-manual "(gnus)Customizing Articles")
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-leading-whitespace nil
922 "Remove leading whitespace in headers.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :link '(custom-manual "(gnus)Customizing Articles")
927 :type gnus-article-treat-custom)
929 (defcustom gnus-treat-hide-headers 'head
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles' for details."
933 :group 'gnus-article-treat
934 :link '(custom-manual "(gnus)Customizing Articles")
935 :type gnus-article-treat-head-custom)
937 (defcustom gnus-treat-hide-boring-headers nil
938 "Hide boring headers.
939 Valid values are nil, t, `head', `last', an integer or a predicate.
940 See Info node `(gnus)Customizing Articles' for details."
941 :group 'gnus-article-treat
942 :link '(custom-manual "(gnus)Customizing Articles")
943 :type gnus-article-treat-head-custom)
945 (defcustom gnus-treat-hide-signature nil
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-fill-article nil
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-hide-citation nil
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-hide-citation-maybe nil
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-strip-list-identifiers 'head
978 "Strip list identifiers from `gnus-list-identifiers`.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
982 :group 'gnus-article-treat
983 :link '(custom-manual "(gnus)Customizing Articles")
984 :type gnus-article-treat-custom)
986 (make-obsolete-variable 'gnus-treat-strip-pgp
987 "This option is obsolete in Gnus 5.10.")
989 (defcustom gnus-treat-strip-pem nil
990 "Strip PEM signatures.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-strip-banner t
998 "Strip banners from articles.
999 The banner to be stripped is specified in the `banner' group parameter.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-custom)
1006 (defcustom gnus-treat-highlight-headers 'head
1007 "Highlight the headers.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1013 (put 'gnus-treat-highlight-headers 'highlight t)
1015 (defcustom gnus-treat-highlight-citation t
1016 "Highlight cited text.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-custom)
1022 (put 'gnus-treat-highlight-citation 'highlight t)
1024 (defcustom gnus-treat-date-ut nil
1025 "Display the Date in UT (GMT).
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-head-custom)
1032 (defcustom gnus-treat-date-local nil
1033 "Display the Date in the local timezone.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-head-custom)
1040 (defcustom gnus-treat-date-english nil
1041 "Display the Date in a format that can be read aloud in English.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-head-custom)
1048 (defcustom gnus-treat-date-lapsed nil
1049 "Display the Date header in a way that says how much time has elapsed.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-date-original nil
1057 "Display the date in the original timezone.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-date-iso8601 nil
1065 "Display the date in the ISO8601 format.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1073 (defcustom gnus-treat-date-user-defined nil
1074 "Display the date in a user-defined format.
1075 The format is defined by the `gnus-article-time-format' variable.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-head-custom)
1082 (defcustom gnus-treat-strip-headers-in-body t
1083 "Strip the X-No-Archive header line from the beginning of the body.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 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)
1091 (defcustom gnus-treat-strip-trailing-blank-lines nil
1092 "Strip trailing blank lines.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-strip-leading-blank-lines nil
1100 "Strip leading blank lines.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-strip-multiple-blank-lines nil
1108 "Strip multiple blank lines.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-unfold-headers 'head
1116 "Unfold folded header lines.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-custom)
1123 (defcustom gnus-treat-fold-headers nil
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1131 (defcustom gnus-treat-fold-newsgroups 'head
1132 "Fold the Newsgroups and Followup-To headers.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1139 (defcustom gnus-treat-overstrike t
1140 "Treat overstrike highlighting.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 See Info node `(gnus)Customizing Articles' for details."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1146 (put 'gnus-treat-overstrike 'highlight t)
1148 (make-obsolete-variable 'gnus-treat-display-xface
1149 'gnus-treat-display-x-face)
1151 (defcustom gnus-treat-display-x-face
1152 (and (not noninteractive)
1153 (or (and (fboundp 'image-type-available-p)
1154 (image-type-available-p 'xbm)
1155 (string-match "^0x" (shell-command-to-string "uncompface"))
1156 (executable-find "icontopbm"))
1157 (and (featurep 'xemacs)
1160 "Display X-Face headers.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' and Info node
1163 `(gnus)X-Face' for details."
1164 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :link '(custom-manual "(gnus)X-Face")
1168 :type gnus-article-treat-head-custom
1169 :set (lambda (symbol value)
1172 (cond ((or (boundp symbol) (get symbol 'saved-value))
1174 ((boundp 'gnus-treat-display-xface)
1176 ** gnus-treat-display-xface is an obsolete variable;\
1177 use gnus-treat-display-x-face instead")
1178 (default-value 'gnus-treat-display-xface))
1179 ((get 'gnus-treat-display-xface 'saved-value)
1181 ** gnus-treat-display-xface is an obsolete variable;\
1182 use gnus-treat-display-x-face instead")
1183 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1186 (put 'gnus-treat-display-x-face 'highlight t)
1188 (defcustom gnus-treat-display-face
1189 (and (not noninteractive)
1190 (or (and (fboundp 'image-type-available-p)
1191 (image-type-available-p 'png))
1192 (and (featurep 'xemacs)
1195 "Display Face headers.
1196 Valid values are nil, t, `head', `last', an integer or a predicate.
1197 See Info node `(gnus)Customizing Articles' and Info node
1198 `(gnus)X-Face' for details."
1199 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :link '(custom-manual "(gnus)X-Face")
1203 :type gnus-article-treat-head-custom)
1204 (put 'gnus-treat-display-face 'highlight t)
1206 (defcustom gnus-treat-display-smileys
1207 (if (or (and (featurep 'xemacs)
1209 (and (fboundp 'image-type-available-p)
1210 (image-type-available-p 'pbm)))
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' and Info node
1215 `(gnus)Smileys' for details."
1216 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :link '(custom-manual "(gnus)Smileys")
1220 :type gnus-article-treat-custom)
1221 (put 'gnus-treat-display-smileys 'highlight t)
1223 (defcustom gnus-treat-from-picon
1224 (if (and (gnus-image-type-available-p 'xpm)
1225 (gnus-picons-installed-p))
1227 "Display picons in the From header.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' and Info node
1230 `(gnus)Picons' for details."
1231 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :link '(custom-manual "(gnus)Picons")
1235 :type gnus-article-treat-head-custom)
1236 (put 'gnus-treat-from-picon 'highlight t)
1238 (defcustom gnus-treat-mail-picon
1239 (if (and (gnus-image-type-available-p 'xpm)
1240 (gnus-picons-installed-p))
1242 "Display picons in To and Cc headers.
1243 Valid values are nil, t, `head', `last', an integer or a predicate.
1244 See Info node `(gnus)Customizing Articles' and Info node
1245 `(gnus)Picons' for details."
1246 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :link '(custom-manual "(gnus)Picons")
1250 :type gnus-article-treat-head-custom)
1251 (put 'gnus-treat-mail-picon 'highlight t)
1253 (defcustom gnus-treat-newsgroups-picon
1254 (if (and (gnus-image-type-available-p 'xpm)
1255 (gnus-picons-installed-p))
1257 "Display picons in the Newsgroups and Followup-To headers.
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' and Info node
1260 `(gnus)Picons' for details."
1261 :group 'gnus-article-treat
1263 :link '(custom-manual "(gnus)Customizing Articles")
1264 :link '(custom-manual "(gnus)Picons")
1265 :type gnus-article-treat-head-custom)
1266 (put 'gnus-treat-newsgroups-picon 'highlight t)
1268 (defcustom gnus-treat-body-boundary
1269 (if (or gnus-treat-newsgroups-picon
1270 gnus-treat-mail-picon
1271 gnus-treat-from-picon)
1273 "Draw a boundary at the end of the headers.
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' for details."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1281 (defcustom gnus-treat-capitalize-sentences nil
1282 "Capitalize sentence-starting words.
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (defcustom gnus-treat-wash-html nil
1292 Valid values are nil, t, `head', `last', an integer or a predicate.
1293 See Info node `(gnus)Customizing Articles' for details."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (defcustom gnus-treat-fill-long-lines nil
1300 Valid values are nil, t, `head', `last', an integer or a predicate.
1301 See Info node `(gnus)Customizing Articles' for details."
1302 :group 'gnus-article-treat
1303 :link '(custom-manual "(gnus)Customizing Articles")
1304 :type gnus-article-treat-custom)
1306 (defcustom gnus-treat-play-sounds nil
1308 Valid values are nil, t, `head', `last', an integer or a predicate.
1309 See Info node `(gnus)Customizing Articles' for details."
1311 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :type gnus-article-treat-custom)
1315 (defcustom gnus-treat-translate nil
1316 "Translate articles from one language to another.
1317 Valid values are nil, t, `head', `last', an integer or a predicate.
1318 See Info node `(gnus)Customizing Articles' for details."
1320 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :type gnus-article-treat-custom)
1324 (defcustom gnus-treat-x-pgp-sig nil
1326 To automatically treat X-PGP-Sig, set it to head.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' for details."
1329 :group 'gnus-article-treat
1330 :group 'mime-security
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (defvar gnus-article-encrypt-protocol-alist
1335 '(("PGP" . mml2015-self-encrypt)))
1337 ;; Set to nil if more than one protocol added to
1338 ;; gnus-article-encrypt-protocol-alist.
1339 (defcustom gnus-article-encrypt-protocol "PGP"
1340 "The protocol used for encrypt articles.
1341 It is a string, such as \"PGP\". If nil, ask user."
1343 :group 'mime-security)
1345 (defvar gnus-article-wash-function nil
1346 "Function used for converting HTML into text.")
1348 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1349 (mm-coding-system-p 'utf-8)
1350 (executable-find idna-program))
1351 "Whether IDNA decoding of headers is used when viewing messages.
1352 This requires GNU Libidn, and by default only enabled if it is found."
1353 :group 'gnus-article-headers
1356 (defcustom gnus-article-over-scroll nil
1357 "If non-nil, allow scrolling the article buffer even when there no more text."
1358 :group 'gnus-article
1361 ;;; Internal variables
1363 (defvar gnus-english-month-names
1364 '("January" "February" "March" "April" "May" "June" "July" "August"
1365 "September" "October" "November" "December"))
1367 (defvar article-goto-body-goes-to-point-min-p nil)
1368 (defvar gnus-article-wash-types nil)
1369 (defvar gnus-article-emphasis-alist nil)
1370 (defvar gnus-article-image-alist nil)
1372 (defvar gnus-article-mime-handle-alist-1 nil)
1373 (defvar gnus-treatment-function-alist
1374 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1375 (gnus-treat-strip-banner gnus-article-strip-banner)
1376 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1377 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1378 (gnus-treat-buttonize gnus-article-add-buttons)
1379 (gnus-treat-fill-article gnus-article-fill-cited-article)
1380 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1381 (gnus-treat-strip-cr gnus-article-remove-cr)
1382 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1383 (gnus-treat-date-ut gnus-article-date-ut)
1384 (gnus-treat-date-local gnus-article-date-local)
1385 (gnus-treat-date-english gnus-article-date-english)
1386 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1387 (gnus-treat-date-original gnus-article-date-original)
1388 (gnus-treat-date-user-defined gnus-article-date-user)
1389 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1390 (gnus-treat-display-x-face gnus-article-display-x-face)
1391 (gnus-treat-display-face gnus-article-display-face)
1392 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1393 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1394 (gnus-treat-hide-signature gnus-article-hide-signature)
1395 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1396 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1397 (gnus-treat-strip-pem gnus-article-hide-pem)
1398 (gnus-treat-from-picon gnus-treat-from-picon)
1399 (gnus-treat-mail-picon gnus-treat-mail-picon)
1400 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1401 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1402 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1403 (gnus-treat-strip-trailing-blank-lines
1404 gnus-article-remove-trailing-blank-lines)
1405 (gnus-treat-strip-leading-blank-lines
1406 gnus-article-strip-leading-blank-lines)
1407 (gnus-treat-strip-multiple-blank-lines
1408 gnus-article-strip-multiple-blank-lines)
1409 (gnus-treat-overstrike gnus-article-treat-overstrike)
1410 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1411 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1412 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1413 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1414 (gnus-treat-display-smileys gnus-treat-smiley)
1415 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1416 (gnus-treat-wash-html gnus-article-wash-html)
1417 (gnus-treat-emphasize gnus-article-emphasize)
1418 (gnus-treat-hide-citation gnus-article-hide-citation)
1419 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1420 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1421 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1422 (gnus-treat-play-sounds gnus-earcon-display)))
1424 (defvar gnus-article-mime-handle-alist nil)
1425 (defvar article-lapsed-timer nil)
1426 (defvar gnus-article-current-summary nil)
1428 (defvar gnus-article-mode-syntax-table
1429 (let ((table (copy-syntax-table text-mode-syntax-table)))
1430 ;; This causes the citation match run O(2^n).
1431 ;; (modify-syntax-entry ?- "w" table)
1432 (modify-syntax-entry ?> ")<" table)
1433 (modify-syntax-entry ?< "(>" table)
1434 ;; make M-. in article buffers work for `foo' strings
1435 (modify-syntax-entry ?' " " table)
1436 (modify-syntax-entry ?` " " table)
1438 "Syntax table used in article mode buffers.
1439 Initialized from `text-mode-syntax-table.")
1441 (defvar gnus-save-article-buffer nil)
1443 (defvar gnus-article-mode-line-format-alist
1444 (nconc '((?w (gnus-article-wash-status) ?s)
1445 (?m (gnus-article-mime-part-status) ?s))
1446 gnus-summary-mode-line-format-alist))
1448 (defvar gnus-number-of-articles-to-be-saved nil)
1450 (defvar gnus-inhibit-hiding nil)
1452 ;;; Macros for dealing with the article buffer.
1454 (defmacro gnus-with-article-headers (&rest forms)
1456 (set-buffer gnus-article-buffer)
1458 (let ((buffer-read-only nil)
1459 (inhibit-point-motion-hooks t)
1460 (case-fold-search t))
1461 (article-narrow-to-head)
1464 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1465 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1467 (defmacro gnus-with-article-buffer (&rest forms)
1469 (set-buffer gnus-article-buffer)
1470 (let ((buffer-read-only nil))
1473 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1474 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1476 (defun gnus-article-goto-header (header)
1477 "Go to HEADER, which is a regular expression."
1478 (re-search-forward (concat "^\\(" header "\\):") nil t))
1480 (defsubst gnus-article-hide-text (b e props)
1481 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1482 (gnus-add-text-properties-when 'article-type nil b e props)
1483 (when (memq 'intangible props)
1485 (max (1- b) (point-min))
1486 b 'intangible (cddr (memq 'intangible props)))))
1488 (defsubst gnus-article-unhide-text (b e)
1489 "Remove hidden text properties from region between B and E."
1490 (remove-text-properties b e gnus-hidden-properties)
1491 (when (memq 'intangible gnus-hidden-properties)
1492 (put-text-property (max (1- b) (point-min))
1493 b 'intangible nil)))
1495 (defun gnus-article-hide-text-type (b e type)
1496 "Hide text of TYPE between B and E."
1497 (gnus-add-wash-type type)
1498 (gnus-article-hide-text
1499 b e (cons 'article-type (cons type gnus-hidden-properties))))
1501 (defun gnus-article-unhide-text-type (b e type)
1502 "Unhide text of TYPE between B and E."
1503 (gnus-delete-wash-type type)
1504 (remove-text-properties
1505 b e (cons 'article-type (cons type gnus-hidden-properties)))
1506 (when (memq 'intangible gnus-hidden-properties)
1507 (put-text-property (max (1- b) (point-min))
1508 b 'intangible nil)))
1510 (defun gnus-article-hide-text-of-type (type)
1511 "Hide text of TYPE in the current buffer."
1513 (let ((b (point-min))
1515 (while (setq b (text-property-any b e 'article-type type))
1516 (add-text-properties b (incf b) gnus-hidden-properties)))))
1518 (defun gnus-article-delete-text-of-type (type)
1519 "Delete text of TYPE in the current buffer."
1521 (let ((b (point-min)))
1522 (while (setq b (text-property-any b (point-max) 'article-type type))
1524 b (or (text-property-not-all b (point-max) 'article-type type)
1527 (defun gnus-article-delete-invisible-text ()
1528 "Delete all invisible text in the current buffer."
1530 (let ((b (point-min)))
1531 (while (setq b (text-property-any b (point-max) 'invisible t))
1533 b (or (text-property-not-all b (point-max) 'invisible t)
1536 (defun gnus-article-text-type-exists-p (type)
1537 "Say whether any text of type TYPE exists in the buffer."
1538 (text-property-any (point-min) (point-max) 'article-type type))
1540 (defsubst gnus-article-header-rank ()
1541 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1542 (let ((list gnus-sorted-header-list)
1545 (if (looking-at (car list))
1547 (setq list (cdr list))
1551 (defun article-hide-headers (&optional arg delete)
1552 "Hide unwanted headers and possibly sort them as well."
1554 ;; This function might be inhibited.
1555 (unless gnus-inhibit-hiding
1558 (let ((buffer-read-only nil)
1559 (case-fold-search t)
1560 (max (1+ (length gnus-sorted-header-list)))
1561 (ignored (when (not gnus-visible-headers)
1562 (cond ((stringp gnus-ignored-headers)
1563 gnus-ignored-headers)
1564 ((listp gnus-ignored-headers)
1565 (mapconcat 'identity gnus-ignored-headers
1568 (cond ((stringp gnus-visible-headers)
1569 gnus-visible-headers)
1570 ((and gnus-visible-headers
1571 (listp gnus-visible-headers))
1572 (mapconcat 'identity gnus-visible-headers "\\|"))))
1573 (inhibit-point-motion-hooks t)
1575 ;; First we narrow to just the headers.
1576 (article-narrow-to-head)
1577 ;; Hide any "From " lines at the beginning of (mail) articles.
1578 (while (looking-at "From ")
1581 (delete-region (point-min) (point)))
1582 ;; Then treat the rest of the header lines.
1583 ;; Then we use the two regular expressions
1584 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1585 ;; select which header lines is to remain visible in the
1587 (while (re-search-forward "^[^ \t:]*:" nil t)
1589 ;; Mark the rank of the header.
1591 (point) (1+ (point)) 'message-rank
1592 (if (or (and visible (looking-at visible))
1594 (not (looking-at ignored))))
1595 (gnus-article-header-rank)
1598 (message-sort-headers-1)
1599 (when (setq beg (text-property-any
1600 (point-min) (point-max) 'message-rank (+ 2 max)))
1601 ;; We delete the unwanted headers.
1602 (gnus-add-wash-type 'headers)
1603 (add-text-properties (point-min) (+ 5 (point-min))
1604 '(article-type headers dummy-invisible t))
1605 (delete-region beg (point-max))))))))
1607 (defun article-hide-boring-headers (&optional arg)
1608 "Toggle hiding of headers that aren't very interesting.
1609 If given a negative prefix, always show; if given a positive prefix,
1611 (interactive (gnus-article-hidden-arg))
1612 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1613 (not gnus-show-all-headers))
1616 (let ((buffer-read-only nil)
1617 (list gnus-boring-article-headers)
1618 (inhibit-point-motion-hooks t)
1620 (article-narrow-to-head)
1622 (setq elem (pop list))
1623 (goto-char (point-min))
1625 ;; Hide empty headers.
1627 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1629 (gnus-article-hide-text-type
1633 (if (re-search-forward "^[^ \t]" nil t)
1637 ;; Hide boring Newsgroups header.
1638 ((eq elem 'newsgroups)
1639 (when (gnus-string-equal
1640 (gnus-fetch-field "newsgroups")
1641 (gnus-group-real-name
1642 (if (boundp 'gnus-newsgroup-name)
1645 (gnus-article-hide-header "newsgroups")))
1646 ((eq elem 'to-address)
1647 (let ((to (message-fetch-field "to"))
1649 (gnus-parameter-to-address
1650 (if (boundp 'gnus-newsgroup-name)
1651 gnus-newsgroup-name ""))))
1652 (when (and to to-address
1655 ;; only one address in To
1656 (nth 1 (mail-extract-address-components to))
1658 (gnus-article-hide-header "to"))))
1660 (let ((to (message-fetch-field "to"))
1662 (gnus-parameter-to-list
1663 (if (boundp 'gnus-newsgroup-name)
1664 gnus-newsgroup-name ""))))
1665 (when (and to to-list
1668 ;; only one address in To
1669 (nth 1 (mail-extract-address-components to))
1671 (gnus-article-hide-header "to"))))
1673 (let ((cc (message-fetch-field "cc"))
1675 (gnus-parameter-to-list
1676 (if (boundp 'gnus-newsgroup-name)
1677 gnus-newsgroup-name ""))))
1678 (when (and cc to-list
1681 ;; only one address in CC
1682 (nth 1 (mail-extract-address-components cc))
1684 (gnus-article-hide-header "cc"))))
1685 ((eq elem 'followup-to)
1686 (when (gnus-string-equal
1687 (message-fetch-field "followup-to")
1688 (message-fetch-field "newsgroups"))
1689 (gnus-article-hide-header "followup-to")))
1690 ((eq elem 'reply-to)
1691 (if (gnus-group-find-parameter
1692 gnus-newsgroup-name 'broken-reply-to)
1693 (gnus-article-hide-header "reply-to")
1694 (let ((from (message-fetch-field "from"))
1695 (reply-to (message-fetch-field "reply-to")))
1700 (nth 1 (mail-extract-address-components from))
1701 (nth 1 (mail-extract-address-components reply-to)))))
1702 (gnus-article-hide-header "reply-to")))))
1704 (let ((date (message-fetch-field "date")))
1706 (< (days-between (current-time-string) date)
1708 (gnus-article-hide-header "date"))))
1710 (let ((to (message-fetch-field "to"))
1711 (cc (message-fetch-field "cc")))
1712 (when (> (length to) 1024)
1713 (gnus-article-hide-header "to"))
1714 (when (> (length cc) 1024)
1715 (gnus-article-hide-header "cc"))))
1719 (goto-char (point-min))
1720 (while (re-search-forward "^to:" nil t)
1721 (setq to-count (1+ to-count)))
1722 (when (> to-count 1)
1723 (while (> to-count 0)
1724 (goto-char (point-min))
1726 (re-search-forward "^to:" nil nil to-count)
1728 (narrow-to-region (point) (point-max))
1729 (gnus-article-hide-header "to"))
1730 (setq to-count (1- to-count))))
1731 (goto-char (point-min))
1732 (while (re-search-forward "^cc:" nil t)
1733 (setq cc-count (1+ cc-count)))
1734 (when (> cc-count 1)
1735 (while (> cc-count 0)
1736 (goto-char (point-min))
1738 (re-search-forward "^cc:" nil nil cc-count)
1740 (narrow-to-region (point) (point-max))
1741 (gnus-article-hide-header "cc"))
1742 (setq cc-count (1- cc-count)))))))))))))
1744 (defun gnus-article-hide-header (header)
1746 (goto-char (point-min))
1747 (when (re-search-forward (concat "^" header ":") nil t)
1748 (gnus-article-hide-text-type
1752 (if (re-search-forward "^[^ \t]" nil t)
1757 (defvar gnus-article-normalized-header-length 40
1758 "Length of normalized headers.")
1760 (defun article-normalize-headers ()
1761 "Make all header lines 40 characters long."
1763 (let ((buffer-read-only nil)
1767 (article-narrow-to-head)
1770 ((< (setq column (- (gnus-point-at-eol) (point)))
1771 gnus-article-normalized-header-length)
1773 (insert (make-string
1774 (- gnus-article-normalized-header-length column)
1776 ((> column gnus-article-normalized-header-length)
1777 (gnus-put-text-property
1779 (forward-char gnus-article-normalized-header-length)
1786 (forward-line 1))))))
1788 (defun article-treat-dumbquotes ()
1789 "Translate M****s*** sm*rtq**t*s into proper text.
1790 Note that this function guesses whether a character is a sm*rtq**t* or
1791 not, so it should only be used interactively.
1793 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1794 in an attempt to provide more quoting characters. If you see
1795 something like \\222 or \\264 where you're expecting some kind of
1796 apostrophe or quotation mark, then try this wash."
1798 (article-translate-strings gnus-article-dumbquotes-map))
1800 (defun article-translate-characters (from to)
1801 "Translate all characters in the body of the article according to FROM and TO.
1802 FROM is a string of characters to translate from; to is a string of
1803 characters to translate to."
1805 (when (article-goto-body)
1806 (let ((buffer-read-only nil)
1807 (x (make-string 225 ?x))
1809 (while (< (incf i) (length x))
1812 (while (< i (length from))
1813 (aset x (aref from i) (aref to i))
1815 (translate-region (point) (point-max) x)))))
1817 (defun article-translate-strings (map)
1818 "Translate all string in the body of the article according to MAP.
1819 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1821 (when (article-goto-body)
1822 (let ((buffer-read-only nil)
1824 (while (setq elem (pop map))
1826 (while (search-forward (car elem) nil t)
1827 (replace-match (cadr elem)))))))))
1829 (defun article-treat-overstrike ()
1830 "Translate overstrikes into bold text."
1833 (when (article-goto-body)
1834 (let ((buffer-read-only nil))
1835 (while (search-forward "\b" nil t)
1836 (let ((next (char-after))
1837 (previous (char-after (- (point) 2))))
1838 ;; We do the boldification/underlining by hiding the
1839 ;; overstrikes and putting the proper text property
1843 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1844 (put-text-property (point) (1+ (point)) 'face 'bold))
1846 (gnus-article-hide-text-type
1847 (1- (point)) (1+ (point)) 'overstrike)
1849 (- (point) 2) (1- (point)) 'face 'underline))
1851 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1853 (point) (1+ (point)) 'face 'underline)))))))))
1855 (defun gnus-article-treat-unfold-headers ()
1856 "Unfold folded message headers.
1857 Only the headers that fit into the current window width will be
1860 (gnus-with-article-headers
1864 (mail-header-narrow-to-field)
1865 (let ((header (buffer-string)))
1868 (goto-char (point-min))
1869 (while (re-search-forward "\n[\t ]" nil t)
1870 (replace-match " " t t)))
1871 (setq length (- (point-max) (point-min) 1)))
1872 (when (< length (window-width))
1873 (while (re-search-forward "\n[\t ]" nil t)
1874 (replace-match " " t t)))
1875 (goto-char (point-max)))))))
1877 (defun gnus-article-treat-fold-headers ()
1878 "Fold message headers."
1880 (gnus-with-article-headers
1883 (mail-header-narrow-to-field)
1884 (mail-header-fold-field)
1885 (goto-char (point-max))))))
1887 (defun gnus-treat-smiley ()
1888 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1890 (gnus-with-article-buffer
1891 (if (memq 'smiley gnus-article-wash-types)
1892 (gnus-delete-images 'smiley)
1894 (let ((images (smiley-region (point) (point-max))))
1896 (gnus-add-wash-type 'smiley)
1897 (dolist (image images)
1898 (gnus-add-image 'smiley image)))))))
1900 (defun gnus-article-remove-images ()
1901 "Remove all images from the article buffer."
1903 (gnus-with-article-buffer
1904 (dolist (elem gnus-article-image-alist)
1905 (gnus-delete-images (car elem)))))
1907 (defun gnus-article-treat-fold-newsgroups ()
1908 "Unfold folded message headers.
1909 Only the headers that fit into the current window width will be
1912 (gnus-with-article-headers
1913 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1915 (mail-header-narrow-to-field)
1916 (while (re-search-forward ", *" nil t)
1917 (replace-match ", " t t))
1918 (mail-header-fold-field)
1919 (goto-char (point-max))))))
1921 (defun gnus-article-treat-body-boundary ()
1922 "Place a boundary line at the end of the headers."
1924 (when (and gnus-body-boundary-delimiter
1925 (> (length gnus-body-boundary-delimiter) 0))
1926 (gnus-with-article-headers
1927 (goto-char (point-max))
1928 (let ((start (point)))
1929 (insert "X-Boundary: ")
1930 (gnus-add-text-properties start (point) '(invisible t intangible t))
1932 (while (>= (1- (window-width)) (length str))
1933 (setq str (concat str gnus-body-boundary-delimiter)))
1934 (substring str 0 (1- (window-width))))
1936 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1938 (defun article-fill-long-lines ()
1939 "Fill lines that are wider than the window width."
1942 (let ((buffer-read-only nil)
1943 (width (window-width (get-buffer-window (current-buffer)))))
1946 (let ((adaptive-fill-mode nil)) ;Why? -sm
1949 (when (>= (current-column) (min fill-column width))
1950 (narrow-to-region (min (1+ (point)) (point-max))
1951 (gnus-point-at-bol))
1952 (let ((goback (point-marker)))
1953 (fill-paragraph nil)
1954 (goto-char (marker-position goback)))
1956 (forward-line 1)))))))
1958 (defun article-capitalize-sentences ()
1959 "Capitalize the first word in each sentence."
1962 (let ((buffer-read-only nil)
1963 (paragraph-start "^[\n\^L]"))
1967 (forward-sentence)))))
1969 (defun article-remove-cr ()
1970 "Remove trailing CRs and then translate remaining CRs into LFs."
1973 (let ((buffer-read-only nil))
1974 (goto-char (point-min))
1975 (while (re-search-forward "\r+$" nil t)
1976 (replace-match "" t t))
1977 (goto-char (point-min))
1978 (while (search-forward "\r" nil t)
1979 (replace-match "\n" t t)))))
1981 (defun article-remove-trailing-blank-lines ()
1982 "Remove all trailing blank lines from the article."
1985 (let ((buffer-read-only nil))
1986 (goto-char (point-max))
1990 (while (and (not (bobp))
1991 (looking-at "^[ \t]*$")
1992 (not (gnus-annotation-in-region-p
1993 (point) (gnus-point-at-eol))))
1998 (defun article-display-face ()
1999 "Display any Face headers in the header."
2001 (let ((wash-face-p buffer-read-only))
2002 (gnus-with-article-headers
2003 ;; When displaying parts, this function can be called several times on
2004 ;; the same article, without any intended toggle semantic (as typing `W
2005 ;; D d' would have). So face deletion must occur only when we come from
2006 ;; an interactive command, that is when the *Article* buffer is
2008 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2009 (gnus-delete-images 'face)
2012 (when (and wash-face-p
2014 (goto-char (point-min))
2015 (not (re-search-forward "^Face:[\t ]*" nil t)))
2016 (gnus-buffer-live-p gnus-original-article-buffer))
2017 (set-buffer gnus-original-article-buffer))
2019 (mail-narrow-to-head)
2020 (while (gnus-article-goto-header "Face")
2021 (push (mail-header-field-value) faces))))
2022 (while (setq face (pop faces))
2023 (let ((png (gnus-convert-face-to-png face))
2026 (setq image (gnus-create-image png 'png t))
2027 (gnus-article-goto-header "from")
2029 (insert "From: [no `from' set]\n")
2031 (gnus-add-wash-type 'face)
2032 (gnus-add-image 'face image)
2033 (gnus-put-image image nil 'face))))))
2036 (defun article-display-x-face (&optional force)
2037 "Look for an X-Face header and display it if present."
2038 (interactive (list 'force))
2039 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2040 (gnus-with-article-headers
2041 ;; Delete the old process, if any.
2042 (when (process-status "article-x-face")
2043 (delete-process "article-x-face"))
2044 ;; See the comment in `article-display-face'.
2045 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2046 ;; We have already displayed X-Faces, so we remove them
2048 (gnus-delete-images 'xface)
2050 (let (x-faces from face)
2052 (when (and wash-face-p
2054 (goto-char (point-min))
2055 (not (re-search-forward
2056 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2057 (gnus-buffer-live-p gnus-original-article-buffer))
2058 ;; If type `W f', use gnus-original-article-buffer,
2059 ;; otherwise use the current buffer because displaying
2060 ;; RFC822 parts calls this function too.
2061 (set-buffer gnus-original-article-buffer))
2063 (mail-narrow-to-head)
2064 (while (gnus-article-goto-header "X-Face")
2065 (push (mail-header-field-value) x-faces))
2066 (setq from (message-fetch-field "from"))))
2067 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2068 ;; single external face.
2069 (when (stringp gnus-article-x-face-command)
2070 (setq x-faces (list (car x-faces))))
2071 (while (and (setq face (pop x-faces))
2072 gnus-article-x-face-command
2074 ;; Check whether this face is censored.
2075 (not gnus-article-x-face-too-ugly)
2076 (and gnus-article-x-face-too-ugly from
2077 (not (string-match gnus-article-x-face-too-ugly
2079 ;; We display the face.
2080 (if (symbolp gnus-article-x-face-command)
2081 ;; The command is a lisp function, so we call it.
2082 (if (functionp gnus-article-x-face-command)
2083 (funcall gnus-article-x-face-command face)
2084 (error "%s is not a function" gnus-article-x-face-command))
2085 ;; The command is a string, so we interpret the command
2086 ;; as a, well, command, and fork it off.
2087 (let ((process-connection-type nil))
2088 (process-kill-without-query
2090 "article-x-face" nil shell-file-name shell-command-switch
2091 gnus-article-x-face-command))
2094 (process-send-region "article-x-face"
2095 (point-min) (point-max)))
2096 (process-send-eof "article-x-face")))))))))
2098 (defun article-decode-mime-words ()
2099 "Decode all MIME-encoded words in the article."
2102 (set-buffer gnus-article-buffer)
2103 (let ((inhibit-point-motion-hooks t)
2105 (mail-parse-charset gnus-newsgroup-charset)
2106 (mail-parse-ignored-charsets
2107 (save-excursion (set-buffer gnus-summary-buffer)
2108 gnus-newsgroup-ignored-charsets)))
2109 (mail-decode-encoded-word-region (point-min) (point-max)))))
2111 (defun article-decode-charset (&optional prompt)
2112 "Decode charset-encoded text in the article.
2113 If PROMPT (the prefix), prompt for a coding system to use."
2115 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2117 (mail-parse-charset gnus-newsgroup-charset)
2118 (mail-parse-ignored-charsets
2119 (save-excursion (condition-case nil
2120 (set-buffer gnus-summary-buffer)
2122 gnus-newsgroup-ignored-charsets))
2123 ct cte ctl charset format)
2126 (article-narrow-to-head)
2127 (setq ct (message-fetch-field "Content-Type" t)
2128 cte (message-fetch-field "Content-Transfer-Encoding" t)
2129 ctl (and ct (ignore-errors
2130 (mail-header-parse-content-type ct)))
2133 (mm-read-coding-system "Charset to decode: "))
2135 (mail-content-type-get ctl 'charset)))
2136 format (and ctl (mail-content-type-get ctl 'format)))
2138 (setq cte (mail-header-strip cte)))
2139 (if (and ctl (not (string-match "/" (car ctl))))
2141 (goto-char (point-max)))
2144 (narrow-to-region (point) (point-max))
2145 (when (and (eq mail-parse-charset 'gnus-decoded)
2146 (eq (mm-body-7-or-8) '8bit))
2147 ;; The text code could have been decoded.
2148 (setq charset mail-parse-charset))
2149 (when (and (or (not ctl)
2150 (equal (car ctl) "text/plain"))
2151 (not format)) ;; article with format will decode later.
2153 charset (and cte (intern (downcase
2154 (gnus-strip-whitespace cte))))
2157 (defun article-decode-encoded-words ()
2158 "Remove encoded-word encoding from headers."
2159 (let ((inhibit-point-motion-hooks t)
2160 (mail-parse-charset gnus-newsgroup-charset)
2161 (mail-parse-ignored-charsets
2162 (save-excursion (condition-case nil
2163 (set-buffer gnus-summary-buffer)
2165 gnus-newsgroup-ignored-charsets))
2168 (article-narrow-to-head)
2169 (funcall gnus-decode-header-function (point-min) (point-max)))))
2171 (defun article-decode-group-name ()
2172 "Decode group names in `Newsgroups:'."
2173 (let ((inhibit-point-motion-hooks t)
2175 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2176 (when (and (or gnus-group-name-charset-method-alist
2177 gnus-group-name-charset-group-alist)
2178 (gnus-buffer-live-p gnus-original-article-buffer))
2180 (article-narrow-to-head)
2181 (with-current-buffer gnus-original-article-buffer
2182 (goto-char (point-min)))
2183 (while (re-search-forward
2184 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2185 (replace-match (save-match-data
2186 (gnus-decode-newsgroups
2187 ;; XXX how to use data in article buffer?
2188 (with-current-buffer gnus-original-article-buffer
2190 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2193 gnus-newsgroup-name method))
2195 (goto-char (point-min))
2196 (with-current-buffer gnus-original-article-buffer
2197 (goto-char (point-min)))
2198 (while (re-search-forward
2199 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2200 (replace-match (save-match-data
2201 (gnus-decode-newsgroups
2202 ;; XXX how to use data in article buffer?
2203 (with-current-buffer gnus-original-article-buffer
2205 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2208 gnus-newsgroup-name method))
2211 (autoload 'idna-to-unicode "idna")
2213 (defun article-decode-idna-rhs ()
2214 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2217 (let ((inhibit-point-motion-hooks t)
2219 (article-narrow-to-head)
2220 (goto-char (point-min))
2221 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2223 (when (save-match-data
2224 (and (setq ace (match-string 1))
2226 (and (re-search-backward "^[^ \t]" nil t)
2227 (looking-at "From\\|To\\|Cc")))
2228 (save-excursion (backward-char)
2229 (message-idna-inside-rhs-p))
2230 (setq unicode (idna-to-unicode ace))))
2231 (unless (string= ace unicode)
2232 (replace-match unicode nil nil nil 1)))))))))
2234 (defun article-de-quoted-unreadable (&optional force read-charset)
2235 "Translate a quoted-printable-encoded article.
2236 If FORCE, decode the article whether it is marked as quoted-printable
2238 If READ-CHARSET, ask for a coding system."
2239 (interactive (list 'force current-prefix-arg))
2241 (let ((buffer-read-only nil) type charset)
2242 (if (gnus-buffer-live-p gnus-original-article-buffer)
2243 (with-current-buffer gnus-original-article-buffer
2245 (gnus-fetch-field "content-transfer-encoding"))
2246 (let* ((ct (gnus-fetch-field "content-type"))
2249 (mail-header-parse-content-type ct)))))
2250 (setq charset (and ctl
2251 (mail-content-type-get ctl 'charset)))
2252 (if (stringp charset)
2253 (setq charset (intern (downcase charset)))))))
2255 (setq charset (mm-read-coding-system "Charset: " charset)))
2257 (setq charset gnus-newsgroup-charset))
2259 (and type (let ((case-fold-search t))
2260 (string-match "quoted-printable" type))))
2262 (quoted-printable-decode-region
2263 (point) (point-max) (mm-charset-to-coding-system charset))))))
2265 (defun article-de-base64-unreadable (&optional force read-charset)
2266 "Translate a base64 article.
2267 If FORCE, decode the article whether it is marked as base64 not.
2268 If READ-CHARSET, ask for a coding system."
2269 (interactive (list 'force current-prefix-arg))
2271 (let ((buffer-read-only nil) type charset)
2272 (if (gnus-buffer-live-p gnus-original-article-buffer)
2273 (with-current-buffer gnus-original-article-buffer
2275 (gnus-fetch-field "content-transfer-encoding"))
2276 (let* ((ct (gnus-fetch-field "content-type"))
2279 (mail-header-parse-content-type ct)))))
2280 (setq charset (and ctl
2281 (mail-content-type-get ctl 'charset)))
2282 (if (stringp charset)
2283 (setq charset (intern (downcase charset)))))))
2285 (setq charset (mm-read-coding-system "Charset: " charset)))
2287 (setq charset gnus-newsgroup-charset))
2289 (and type (let ((case-fold-search t))
2290 (string-match "base64" type))))
2293 (narrow-to-region (point) (point-max))
2294 (base64-decode-region (point-min) (point-max))
2295 (mm-decode-coding-region
2296 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2301 (defun article-decode-HZ ()
2302 "Translate a HZ-encoded article."
2306 (let ((buffer-read-only nil))
2307 (rfc1843-decode-region (point-min) (point-max)))))
2309 (defun article-unsplit-urls ()
2310 "Remove the newlines that some other mailers insert into URLs."
2313 (let ((buffer-read-only nil))
2314 (goto-char (point-min))
2315 (while (re-search-forward
2316 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2317 (replace-match "\\1\\3" t)))
2318 (when (interactive-p)
2319 (gnus-treat-article nil))))
2322 (defun article-wash-html (&optional read-charset)
2323 "Format an HTML article.
2324 If READ-CHARSET, ask for a coding system."
2327 (let ((buffer-read-only nil)
2329 (when (gnus-buffer-live-p gnus-original-article-buffer)
2330 (with-current-buffer gnus-original-article-buffer
2331 (let* ((ct (gnus-fetch-field "content-type"))
2334 (mail-header-parse-content-type ct)))))
2335 (setq charset (and ctl
2336 (mail-content-type-get ctl 'charset)))
2337 (when (stringp charset)
2338 (setq charset (intern (downcase charset)))))))
2340 (setq charset (mm-read-coding-system "Charset: " charset)))
2342 (setq charset gnus-newsgroup-charset))
2344 (save-window-excursion
2346 (narrow-to-region (point) (point-max))
2347 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2348 (entry (assq func mm-text-html-washer-alist)))
2350 (setq func (cdr entry)))
2355 (apply (car func) (cdr func))))))))))
2357 (defun gnus-article-wash-html-with-w3 ()
2358 "Wash the current buffer with w3."
2360 (let ((w3-strict-width (window-width))
2361 (url-standalone-mode t)
2362 (url-gateway-unplugged t)
2363 (w3-honor-stylesheets nil))
2365 (w3-region (point-min) (point-max))
2368 (defun gnus-article-wash-html-with-w3m ()
2369 "Wash the current buffer with emacs-w3m."
2372 (narrow-to-region (point) (point-max))
2373 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2376 w3m-force-redisplay)
2377 (w3m-region (point-min) (point-max)))
2378 (when mm-inline-text-html-with-w3m-keymap
2379 (add-text-properties
2380 (point-min) (point-max)
2381 (nconc (mm-w3m-local-map-property)
2382 '(mm-inline-text-html-with-w3m t))))))
2384 (defun article-hide-list-identifiers ()
2385 "Remove list identifies from the Subject header.
2386 The `gnus-list-identifiers' variable specifies what to do."
2388 (let ((inhibit-point-motion-hooks t)
2389 (regexp (if (consp gnus-list-identifiers)
2390 (mapconcat 'identity gnus-list-identifiers " *\\|")
2391 gnus-list-identifiers))
2396 (article-narrow-to-head)
2397 (goto-char (point-min))
2398 (while (re-search-forward
2399 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2401 (delete-region (match-beginning 2) (match-end 0))
2402 (beginning-of-line))
2403 (when (re-search-forward
2404 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2405 (delete-region (match-beginning 1) (match-end 1))))))))
2407 (defun article-hide-pem (&optional arg)
2408 "Toggle hiding of any PEM headers and signatures in the current article.
2409 If given a negative prefix, always show; if given a positive prefix,
2411 (interactive (gnus-article-hidden-arg))
2412 (unless (gnus-article-check-hidden-text 'pem arg)
2414 (let (buffer-read-only end)
2415 (goto-char (point-min))
2416 ;; Hide the horrendously ugly "header".
2417 (when (and (search-forward
2418 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2420 (setq end (1+ (match-beginning 0))))
2421 (gnus-add-wash-type 'pem)
2422 (gnus-article-hide-text-type
2424 (if (search-forward "\n\n" nil t)
2428 ;; Hide the trailer as well
2429 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2431 (gnus-article-hide-text-type
2432 (match-beginning 0) (match-end 0) 'pem)))))))
2434 (defun article-strip-banner ()
2435 "Strip the banners specified by the `banner' group parameter and by
2436 `gnus-article-address-banner-alist'."
2440 (let ((inhibit-point-motion-hooks t))
2441 (when (gnus-parameter-banner gnus-newsgroup-name)
2442 (article-really-strip-banner
2443 (gnus-parameter-banner gnus-newsgroup-name)))
2444 (when gnus-article-address-banner-alist
2445 (article-really-strip-banner
2446 (let ((from (save-restriction
2448 (article-narrow-to-head)
2449 (mail-fetch-field "from"))))
2452 (caar (mail-header-parse-addresses from))))
2454 (dolist (pair gnus-article-address-banner-alist)
2455 (when (string-match (car pair) from)
2456 (throw 'found (cdr pair)))))))))))))
2458 (defun article-really-strip-banner (banner)
2459 "Strip the banner specified by the argument."
2462 (let ((inhibit-point-motion-hooks t)
2463 (gnus-signature-limit nil)
2467 ((eq banner 'signature)
2468 (when (gnus-article-narrow-to-signature)
2471 (delete-region (point) (point-max))))
2473 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2474 (while (re-search-forward banner nil t)
2475 (delete-region (match-beginning 0) (match-end 0)))))
2477 (while (re-search-forward banner nil t)
2478 (delete-region (match-beginning 0) (match-end 0)))))))))
2480 (defun article-babel ()
2481 "Translate article using an online translation service."
2485 (set-buffer gnus-article-buffer)
2486 (when (article-goto-body)
2487 (let* ((buffer-read-only nil)
2490 (orig (buffer-substring start end))
2491 (trans (babel-as-string orig)))
2493 (narrow-to-region start end)
2494 (delete-region start end)
2497 (defun article-hide-signature (&optional arg)
2498 "Hide the signature in the current article.
2499 If given a negative prefix, always show; if given a positive prefix,
2501 (interactive (gnus-article-hidden-arg))
2502 (unless (gnus-article-check-hidden-text 'signature arg)
2505 (let ((buffer-read-only nil))
2506 (when (gnus-article-narrow-to-signature)
2507 (gnus-article-hide-text-type
2508 (point-min) (point-max) 'signature))))))
2509 (gnus-set-mode-line 'article))
2511 (defun article-strip-headers-in-body ()
2512 "Strip offensive headers from bodies."
2516 (let ((case-fold-search t))
2517 (when (looking-at "x-no-archive:")
2518 (gnus-delete-line)))))
2520 (defun article-strip-leading-blank-lines ()
2521 "Remove all blank lines from the beginning of the article."
2524 (let ((inhibit-point-motion-hooks t)
2526 (when (article-goto-body)
2527 (while (and (not (eobp))
2528 (looking-at "[ \t]*$"))
2529 (gnus-delete-line))))))
2531 (defun article-narrow-to-head ()
2532 "Narrow the buffer to the head of the message.
2533 Point is left at the beginning of the narrowed-to region."
2535 (goto-char (point-min))
2536 (if (search-forward "\n\n" nil 1)
2539 (goto-char (point-min)))
2541 (defun article-goto-body ()
2542 "Place point at the start of the body."
2543 (goto-char (point-min))
2545 ;; This variable is only bound when dealing with separate
2547 (article-goto-body-goes-to-point-min-p
2549 ((search-forward "\n\n" nil t)
2552 (goto-char (point-max))
2555 (defun article-strip-multiple-blank-lines ()
2556 "Replace consecutive blank lines with one empty line."
2559 (let ((inhibit-point-motion-hooks t)
2561 ;; First make all blank lines empty.
2563 (while (re-search-forward "^[ \t]+$" nil t)
2564 (unless (gnus-annotation-in-region-p
2565 (match-beginning 0) (match-end 0))
2566 (replace-match "" nil t)))
2567 ;; Then replace multiple empty lines with a single empty line.
2569 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2570 (unless (gnus-annotation-in-region-p
2571 (match-beginning 0) (match-end 0))
2572 (delete-region (match-beginning 1) (match-end 1)))))))
2574 (defun article-strip-leading-space ()
2575 "Remove all white space from the beginning of the lines in the article."
2578 (let ((inhibit-point-motion-hooks t)
2581 (while (re-search-forward "^[ \t]+" nil t)
2582 (replace-match "" t t)))))
2584 (defun article-strip-trailing-space ()
2585 "Remove all white space from the end of the lines in the article."
2588 (let ((inhibit-point-motion-hooks t)
2591 (while (re-search-forward "[ \t]+$" nil t)
2592 (replace-match "" t t)))))
2594 (defun article-strip-blank-lines ()
2595 "Strip leading, trailing and multiple blank lines."
2597 (article-strip-leading-blank-lines)
2598 (article-remove-trailing-blank-lines)
2599 (article-strip-multiple-blank-lines))
2601 (defun article-strip-all-blank-lines ()
2602 "Strip all blank lines."
2605 (let ((inhibit-point-motion-hooks t)
2608 (while (re-search-forward "^[ \t]*\n" nil t)
2609 (replace-match "" t t)))))
2611 (defun gnus-article-narrow-to-signature ()
2612 "Narrow to the signature; return t if a signature is found, else nil."
2613 (let ((inhibit-point-motion-hooks t))
2614 (when (gnus-article-search-signature)
2616 ;; Check whether we have some limits to what we consider
2617 ;; to be a signature.
2618 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2619 (list gnus-signature-limit)))
2621 (while (setq limit (pop limits))
2622 (if (or (and (integerp limit)
2623 (< (- (point-max) (point)) limit))
2625 (< (count-lines (point) (point-max)) limit))
2626 (and (functionp limit)
2628 (and (stringp limit)
2629 (not (re-search-forward limit nil t))))
2630 () ; This limit did not succeed.
2634 (narrow-to-region (point) (point-max))
2637 (defun gnus-article-search-signature ()
2638 "Search the current buffer for the signature separator.
2639 Put point at the beginning of the signature separator."
2640 (let ((cur (point)))
2641 (goto-char (point-max))
2642 (if (if (stringp gnus-signature-separator)
2643 (re-search-backward gnus-signature-separator nil t)
2644 (let ((seps gnus-signature-separator))
2646 (not (re-search-backward (car seps) nil t)))
2653 (defun gnus-article-hidden-arg ()
2654 "Return the current prefix arg as a number, or 0 if no prefix."
2655 (list (if current-prefix-arg
2656 (prefix-numeric-value current-prefix-arg)
2659 (defun gnus-article-check-hidden-text (type arg)
2660 "Return nil if hiding is necessary.
2661 Arg can be nil or a number. nil and positive means hide, negative
2662 means show, 0 means toggle."
2665 (let ((hide (gnus-article-hidden-text-p type)))
2671 (gnus-article-show-hidden-text type)
2674 (if (eq hide 'hidden)
2676 (gnus-article-show-hidden-text type)
2680 (defun gnus-article-hidden-text-p (type)
2681 "Say whether the current buffer contains hidden text of type TYPE."
2682 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2684 (not (get-text-property pos 'invisible))
2685 (not (get-text-property pos 'dummy-invisible)))
2687 (text-property-any (1+ pos) (point-max) 'article-type type)))
2692 (defun gnus-article-show-hidden-text (type &optional dummy)
2693 "Show all hidden text of type TYPE.
2694 Originally it is hide instead of DUMMY."
2695 (let ((buffer-read-only nil)
2696 (inhibit-point-motion-hooks t))
2697 (gnus-remove-text-properties-when
2699 (point-min) (point-max)
2700 (cons 'article-type (cons type
2701 gnus-hidden-properties)))
2702 (gnus-delete-wash-type type)))
2704 (defconst article-time-units
2705 `((year . ,(* 365.25 24 60 60))
2706 (week . ,(* 7 24 60 60))
2707 (day . ,(* 24 60 60))
2711 "Mapping from time units to seconds.")
2713 (defun gnus-article-forward-header ()
2714 "Move point to the start of the next header.
2715 If the current header is a continuation header, this can be several
2720 (if (looking-at "[ \t]+[^ \t]")
2724 (defun article-date-ut (&optional type highlight header)
2725 "Convert DATE date to universal time in the current article.
2726 If TYPE is `local', convert to local time; if it is `lapsed', output
2727 how much time has lapsed since DATE. For `lapsed', the value of
2728 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2729 should replace the \"Date:\" one, or should be added below it."
2730 (interactive (list 'ut t))
2731 (let* ((header (or header
2732 (message-fetch-field "date")
2734 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2737 ((not gnus-article-date-lapsed-new-header)
2743 (date (if (vectorp header) (mail-header-date header)
2745 (inhibit-point-motion-hooks t)
2750 (article-narrow-to-head)
2751 (when (re-search-forward tdate-regexp nil t)
2752 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2753 date (or (get-text-property (gnus-point-at-bol)
2756 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2758 (when (and date (not (string= date "")))
2759 (goto-char (point-min))
2760 (let ((buffer-read-only nil))
2761 ;; Delete any old Date headers.
2762 (while (re-search-forward date-regexp nil t)
2764 (delete-region (progn (beginning-of-line) (point))
2765 (progn (gnus-article-forward-header)
2767 (delete-region (progn (beginning-of-line) (point))
2768 (progn (gnus-article-forward-header)
2771 (setq pos (point))))
2772 (when (and (not pos)
2773 (re-search-forward tdate-regexp nil t))
2777 (insert (article-make-date-line date (or type 'ut)))
2783 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2784 (put-text-property (match-beginning 1) (1+ (match-end 1))
2785 'original-date date)
2786 (put-text-property (match-beginning 1) (1+ (match-end 1))
2788 (put-text-property (match-beginning 2) (match-end 2)
2791 (defun article-make-date-line (date type)
2792 "Return a DATE line of TYPE."
2793 (unless (memq type '(local ut original user iso8601 lapsed english))
2794 (error "Unknown conversion type: %s" type))
2796 (let ((time (date-to-time date)))
2798 ;; Convert to the local timezone.
2800 (let ((tz (car (current-time-zone time))))
2801 (format "Date: %s %s%02d%02d" (current-time-string time)
2802 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2803 (/ (% (abs tz) 3600) 60))))
2804 ;; Convert to Universal Time.
2807 (current-time-string
2808 (let* ((e (parse-time-string date))
2809 (tm (apply 'encode-time e))
2811 (ls (- (cadr tm) (car (current-time-zone time)))))
2812 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2813 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2816 ;; Get the original date from the article.
2817 ((eq type 'original)
2818 (concat "Date: " (if (string-match "\n+$" date)
2819 (substring date 0 (match-beginning 0))
2821 ;; Let the user define the format.
2823 (let ((format (or (condition-case nil
2824 (with-current-buffer gnus-summary-buffer
2825 gnus-article-time-format)
2827 gnus-article-time-format)))
2828 (if (functionp format)
2829 (funcall format time)
2830 (concat "Date: " (format-time-string format time)))))
2833 (let ((tz (car (current-time-zone time))))
2836 (format-time-string "%Y%m%dT%H%M%S" time)
2837 (format "%s%02d%02d"
2838 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2839 (/ (% (abs tz) 3600) 60)))))
2840 ;; Do an X-Sent lapsed format.
2842 ;; If the date is seriously mangled, the timezone functions are
2843 ;; liable to bug out, so we ignore all errors.
2844 (let* ((now (current-time))
2845 (real-time (subtract-time now time))
2846 (real-sec (and real-time
2847 (+ (* (float (car real-time)) 65536)
2849 (sec (and real-time (abs real-sec)))
2859 ;; This is a bit convoluted, but basically we go
2860 ;; through the time units for years, weeks, etc,
2861 ;; and divide things to see whether that results
2862 ;; in positive answers.
2865 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2866 ;; The (remaining) seconds are too few to
2867 ;; be divided into this time unit.
2869 ;; It's big enough, so we output it.
2870 (setq sec (- sec (* num (cdr unit))))
2872 (concat (if prev ", " "") (int-to-string
2874 " " (symbol-name (car unit))
2875 (if (> num 1) "s" ""))
2877 article-time-units "")
2878 ;; If dates are odd, then it might appear like the
2879 ;; article was sent in the future.
2882 " in the future"))))))
2883 ;; Display the date in proper English
2885 (let ((dtime (decode-time time)))
2888 (number-to-string (nth 3 dtime))
2889 (let ((digit (% (nth 3 dtime) 10)))
2891 ((memq (nth 3 dtime) '(11 12 13)) "th")
2897 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2899 (number-to-string (nth 5 dtime))
2901 (format "%02d" (nth 2 dtime))
2903 (format "%02d" (nth 1 dtime)))))))
2905 (format "Date: %s (from Gnus)" date))))
2907 (defun article-date-local (&optional highlight)
2908 "Convert the current article date to the local timezone."
2909 (interactive (list t))
2910 (article-date-ut 'local highlight))
2912 (defun article-date-english (&optional highlight)
2913 "Convert the current article date to something that is proper English."
2914 (interactive (list t))
2915 (article-date-ut 'english highlight))
2917 (defun article-date-original (&optional highlight)
2918 "Convert the current article date to what it was originally.
2919 This is only useful if you have used some other date conversion
2920 function and want to see what the date was before converting."
2921 (interactive (list t))
2922 (article-date-ut 'original highlight))
2924 (defun article-date-lapsed (&optional highlight)
2925 "Convert the current article date to time lapsed since it was sent."
2926 (interactive (list t))
2927 (article-date-ut 'lapsed highlight))
2929 (defun article-update-date-lapsed ()
2930 "Function to be run from a timer to update the lapsed time line."
2931 (let (deactivate-mark)
2936 (set-buffer (window-buffer w))
2937 (when (eq major-mode 'gnus-article-mode)
2938 (goto-char (point-min))
2939 (when (re-search-forward "^X-Sent:" nil t)
2940 (article-date-lapsed t))))
2943 (defun gnus-start-date-timer (&optional n)
2944 "Start a timer to update the X-Sent header in the article buffers.
2945 The numerical prefix says how frequently (in seconds) the function
2950 (gnus-stop-date-timer)
2951 (setq article-lapsed-timer
2952 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2954 (defun gnus-stop-date-timer ()
2955 "Stop the X-Sent timer."
2957 (when article-lapsed-timer
2958 (nnheader-cancel-timer article-lapsed-timer)
2959 (setq article-lapsed-timer nil)))
2961 (defun article-date-user (&optional highlight)
2962 "Convert the current article date to the user-defined format.
2963 This format is defined by the `gnus-article-time-format' variable."
2964 (interactive (list t))
2965 (article-date-ut 'user highlight))
2967 (defun article-date-iso8601 (&optional highlight)
2968 "Convert the current article date to ISO8601."
2969 (interactive (list t))
2970 (article-date-ut 'iso8601 highlight))
2972 ;; (defun article-show-all ()
2973 ;; "Show all hidden text in the article buffer."
2976 ;; (let ((buffer-read-only nil))
2977 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2979 (defun article-remove-leading-whitespace ()
2980 "Remove excessive whitespace from all headers."
2984 (let ((buffer-read-only nil))
2985 (article-narrow-to-head)
2986 (goto-char (point-min))
2987 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2988 (delete-region (match-beginning 1) (match-end 1)))))))
2990 (defun article-emphasize (&optional arg)
2991 "Emphasize text according to `gnus-emphasis-alist'."
2992 (interactive (gnus-article-hidden-arg))
2993 (unless (gnus-article-check-hidden-text 'emphasis arg)
2997 (with-current-buffer gnus-summary-buffer
2998 gnus-article-emphasis-alist)
3000 gnus-emphasis-alist))
3001 (buffer-read-only nil)
3002 (props (append '(article-type emphasis)
3003 gnus-hidden-properties))
3004 regexp elem beg invisible visible face)
3007 (while (setq elem (pop alist))
3009 (setq regexp (car elem)
3010 invisible (nth 1 elem)
3011 visible (nth 2 elem)
3013 (while (re-search-forward regexp nil t)
3014 (when (and (match-beginning visible) (match-beginning invisible))
3015 (gnus-article-hide-text
3016 (match-beginning invisible) (match-end invisible) props)
3017 (gnus-article-unhide-text-type
3018 (match-beginning visible) (match-end visible) 'emphasis)
3019 (gnus-put-overlay-excluding-newlines
3020 (match-beginning visible) (match-end visible) 'face face)
3021 (gnus-add-wash-type 'emphasis)
3022 (goto-char (match-end invisible)))))))))
3024 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3025 "Setup newsgroup emphasis alist."
3026 (unless gnus-article-emphasis-alist
3027 (let ((name (and gnus-newsgroup-name
3028 (gnus-group-real-name gnus-newsgroup-name))))
3029 (make-local-variable 'gnus-article-emphasis-alist)
3030 (setq gnus-article-emphasis-alist
3032 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3033 (while (setq elem (pop alist))
3034 (when (and name (string-match (car elem) name))
3036 highlight (copy-sequence (cdr elem)))))
3038 (copy-sequence highlight-words)
3039 (if gnus-newsgroup-name
3040 (copy-sequence (gnus-group-find-parameter
3041 gnus-newsgroup-name 'highlight-words t)))
3042 gnus-emphasis-alist)))))
3045 (defvar gnus-summary-article-menu)
3046 (defvar gnus-summary-post-menu))
3048 ;;; Saving functions.
3050 (defun gnus-article-save (save-buffer file &optional num)
3051 "Save the currently selected article."
3052 (unless gnus-save-all-headers
3053 ;; Remove headers according to `gnus-saved-headers'.
3054 (let ((gnus-visible-headers
3055 (or gnus-saved-headers gnus-visible-headers))
3056 (gnus-article-buffer save-buffer))
3058 (set-buffer save-buffer)
3059 (article-hide-headers 1 t))))
3060 (save-window-excursion
3061 (if (not gnus-default-article-saver)
3062 (error "No default saver is defined")
3063 ;; !!! Magic! The saving functions all save
3064 ;; `gnus-save-article-buffer' (or so they think), but we
3065 ;; bind that variable to our save-buffer.
3066 (set-buffer gnus-article-buffer)
3067 (let* ((gnus-save-article-buffer save-buffer)
3070 ((not gnus-prompt-before-saving) 'default)
3071 ((eq gnus-prompt-before-saving 'always) nil)
3073 (gnus-number-of-articles-to-be-saved
3074 (when (eq gnus-prompt-before-saving t)
3076 (set-buffer gnus-article-current-summary)
3077 (funcall gnus-default-article-saver filename)))))
3079 (defun gnus-read-save-file-name (prompt &optional filename
3080 function group headers variable)
3082 (funcall function group headers (symbol-value variable)))
3087 ((eq filename 'default)
3093 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3096 (if (and gnus-number-of-articles-to-be-saved
3097 (> gnus-number-of-articles-to-be-saved 1))
3098 (format "these %d articles"
3099 gnus-number-of-articles-to-be-saved)
3102 ;; Let the split methods have their say.
3104 ;; No split name was found.
3107 (concat prompt " (default "
3108 (file-name-nondirectory default-name) ") ")
3109 (file-name-directory default-name)
3111 ;; A single group name is returned.
3112 ((stringp split-name)
3114 (funcall function split-name headers
3115 (symbol-value variable)))
3117 (concat prompt " (default "
3118 (file-name-nondirectory default-name) ") ")
3119 (file-name-directory default-name)
3121 ;; A single split name was found
3122 ((= 1 (length split-name))
3123 (let* ((name (expand-file-name
3125 gnus-article-save-directory))
3126 (dir (cond ((file-directory-p name)
3127 (file-name-as-directory name))
3128 ((file-exists-p name) name)
3129 (t gnus-article-save-directory))))
3131 (concat prompt " (default " name ") ")
3133 ;; A list of splits was found.
3135 (setq split-name (nreverse split-name))
3137 (let ((file-name-history
3138 (nconc split-name file-name-history)))
3142 (concat prompt " (`M-p' for defaults) ")
3143 gnus-article-save-directory
3145 gnus-article-save-directory)))
3146 (car (push result file-name-history)))))))
3147 ;; Create the directory.
3148 (gnus-make-directory (file-name-directory file))
3149 ;; If we have read a directory, we append the default file name.
3150 (when (file-directory-p file)
3151 (setq file (expand-file-name (file-name-nondirectory
3153 (file-name-as-directory file))))
3154 ;; Possibly translate some characters.
3155 (nnheader-translate-file-chars file))))))
3156 (gnus-make-directory (file-name-directory result))
3157 (set variable result)))
3159 (defun gnus-article-archive-name (group)
3160 "Return the first instance of an \"Archive-name\" in the current buffer."
3161 (let ((case-fold-search t))
3162 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3163 (nnheader-concat gnus-article-save-directory
3164 (match-string 1)))))
3166 (defun gnus-article-nndoc-name (group)
3167 "If GROUP is an nndoc group, return the name of the parent group."
3168 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3169 (gnus-group-get-parameter group 'save-article-group)))
3171 (defun gnus-summary-save-in-rmail (&optional filename)
3172 "Append this article to Rmail file.
3173 Optional argument FILENAME specifies file name.
3174 Directory to save to is default to `gnus-article-save-directory'."
3175 (setq filename (gnus-read-save-file-name
3176 "Save %s in rmail file:" filename
3177 gnus-rmail-save-name gnus-newsgroup-name
3178 gnus-current-headers 'gnus-newsgroup-last-rmail))
3179 (gnus-eval-in-buffer-window gnus-save-article-buffer
3183 (gnus-output-to-rmail filename))))
3186 (defun gnus-summary-save-in-mail (&optional filename)
3187 "Append this article to Unix mail file.
3188 Optional argument FILENAME specifies file name.
3189 Directory to save to is default to `gnus-article-save-directory'."
3190 (setq filename (gnus-read-save-file-name
3191 "Save %s in Unix mail file:" filename
3192 gnus-mail-save-name gnus-newsgroup-name
3193 gnus-current-headers 'gnus-newsgroup-last-mail))
3194 (gnus-eval-in-buffer-window gnus-save-article-buffer
3198 (if (and (file-readable-p filename)
3199 (file-regular-p filename)
3200 (mail-file-babyl-p filename))
3201 (rmail-output-to-rmail-file filename t)
3202 (gnus-output-to-mail filename)))))
3205 (defun gnus-summary-save-in-file (&optional filename overwrite)
3206 "Append this article to file.
3207 Optional argument FILENAME specifies file name.
3208 Directory to save to is default to `gnus-article-save-directory'."
3209 (setq filename (gnus-read-save-file-name
3210 "Save %s in file:" filename
3211 gnus-file-save-name gnus-newsgroup-name
3212 gnus-current-headers 'gnus-newsgroup-last-file))
3213 (gnus-eval-in-buffer-window gnus-save-article-buffer
3217 (when (and overwrite
3218 (file-exists-p filename))
3219 (delete-file filename))
3220 (gnus-output-to-file filename))))
3223 (defun gnus-summary-write-to-file (&optional filename)
3224 "Write this article to a file, overwriting it if the file exists.
3225 Optional argument FILENAME specifies file name.
3226 The directory to save in defaults to `gnus-article-save-directory'."
3227 (gnus-summary-save-in-file nil t))
3229 (defun gnus-summary-save-body-in-file (&optional filename)
3230 "Append this article body to a file.
3231 Optional argument FILENAME specifies file name.
3232 The directory to save in defaults to `gnus-article-save-directory'."
3233 (setq filename (gnus-read-save-file-name
3234 "Save %s body in file:" filename
3235 gnus-file-save-name gnus-newsgroup-name
3236 gnus-current-headers 'gnus-newsgroup-last-file))
3237 (gnus-eval-in-buffer-window gnus-save-article-buffer
3241 (when (article-goto-body)
3242 (narrow-to-region (point) (point-max)))
3243 (gnus-output-to-file filename))))
3246 (defun gnus-summary-save-in-pipe (&optional command)
3247 "Pipe this article to subprocess."
3249 (cond ((and (eq command 'default)
3250 gnus-last-shell-command)
3251 gnus-last-shell-command)
3256 "Shell command on %s: "
3257 (if (and gnus-number-of-articles-to-be-saved
3258 (> gnus-number-of-articles-to-be-saved 1))
3259 (format "these %d articles"
3260 gnus-number-of-articles-to-be-saved)
3262 gnus-last-shell-command))))
3263 (when (string-equal command "")
3264 (if gnus-last-shell-command
3265 (setq command gnus-last-shell-command)
3266 (error "A command is required")))
3267 (gnus-eval-in-buffer-window gnus-article-buffer
3270 (shell-command-on-region (point-min) (point-max) command nil)))
3271 (setq gnus-last-shell-command command))
3273 (defmacro gnus-read-string (prompt &optional initial-contents history
3275 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3276 (if (and (featurep 'xemacs)
3277 (< emacs-minor-version 2))
3278 `(read-string ,prompt ,initial-contents ,history)
3279 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3281 (defun gnus-summary-pipe-to-muttprint (&optional command)
3282 "Pipe this article to muttprint."
3283 (setq command (gnus-read-string
3284 "Print using command: " gnus-summary-muttprint-program
3285 nil gnus-summary-muttprint-program))
3286 (gnus-summary-save-in-pipe command))
3288 ;;; Article file names when saving.
3290 (defun gnus-capitalize-newsgroup (newsgroup)
3291 "Capitalize NEWSGROUP name."
3292 (when (not (zerop (length newsgroup)))
3293 (concat (char-to-string (upcase (aref newsgroup 0)))
3294 (substring newsgroup 1))))
3296 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3297 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3298 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3299 Otherwise, it is like ~/News/news/group/num."
3302 (concat (if (gnus-use-long-file-name 'not-save)
3303 (gnus-capitalize-newsgroup newsgroup)
3304 (gnus-newsgroup-directory-form newsgroup))
3305 "/" (int-to-string (mail-header-number headers)))
3306 gnus-article-save-directory)))
3308 (string-equal (file-name-directory default)
3309 (file-name-directory last-file))
3310 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3312 (or last-file default))))
3314 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3315 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3316 If variable `gnus-use-long-file-name' is non-nil, it is
3317 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3320 (concat (if (gnus-use-long-file-name 'not-save)
3322 (gnus-newsgroup-directory-form newsgroup))
3323 "/" (int-to-string (mail-header-number headers)))
3324 gnus-article-save-directory)))
3326 (string-equal (file-name-directory default)
3327 (file-name-directory last-file))
3328 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3330 (or last-file default))))
3332 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3333 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3334 If variable `gnus-use-long-file-name' is non-nil, it is
3335 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3338 (if (gnus-use-long-file-name 'not-save)
3341 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3343 gnus-article-save-directory)))
3345 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3346 "Generate file name from sender."
3347 (let ((from (mail-header-from headers)))
3349 (if (and from (string-match "\\([^ <]+\\)@" from))
3350 (match-string 1 from)
3352 gnus-article-save-directory)))
3354 (defun article-verify-x-pgp-sig ()
3357 (if (gnus-buffer-live-p gnus-original-article-buffer)
3358 (let ((sig (with-current-buffer gnus-original-article-buffer
3359 (gnus-fetch-field "X-PGP-Sig")))
3363 (mml2015-clear-verify-function))
3365 (insert-buffer-substring gnus-original-article-buffer)
3366 (setq items (split-string sig))
3367 (message-narrow-to-head)
3368 (let ((inhibit-point-motion-hooks t)
3369 (case-fold-search t))
3370 ;; Don't verify multiple headers.
3371 (setq headers (mapconcat (lambda (header)
3373 (mail-fetch-field header)
3375 (split-string (nth 1 items) ",") "")))
3376 (delete-region (point-min) (point-max))
3377 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3378 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3383 (if (looking-at "^-")
3386 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3387 (insert "Version: " (car items) "\n\n")
3388 (insert (mapconcat 'identity (cddr items) "\n"))
3389 (insert "\n-----END PGP SIGNATURE-----\n")
3390 (let ((mm-security-handle (list (format "multipart/signed"))))
3391 (mml2015-clean-buffer)
3392 (let ((coding-system-for-write (or gnus-newsgroup-charset
3394 (funcall (mml2015-clear-verify-function)))
3396 (or (mm-handle-multipart-ctl-parameter
3397 mm-security-handle 'gnus-details)
3398 (mm-handle-multipart-ctl-parameter
3399 mm-security-handle 'gnus-info)))))
3401 (let (buffer-read-only bface eface)
3403 (message-narrow-to-head)
3404 (goto-char (point-max))
3406 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3407 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3408 (message-remove-header "X-Gnus-PGP-Verify")
3409 (if (re-search-forward "^X-PGP-Sig:" nil t)
3411 (goto-char (point-max)))
3412 (narrow-to-region (point) (point))
3413 (insert "X-Gnus-PGP-Verify: " info "\n")
3414 (goto-char (point-min))
3417 (if (not (looking-at "^[ \t]"))
3421 (goto-char (point-min))
3422 (when (looking-at "\\([^:]+\\): *")
3423 (put-text-property (match-beginning 1) (1+ (match-end 1))
3425 (put-text-property (match-end 0) (point-max)
3426 'face eface)))))))))
3428 (defun article-verify-cancel-lock ()
3429 "Verify Cancel-Lock header."
3431 (if (gnus-buffer-live-p gnus-original-article-buffer)
3432 (canlock-verify gnus-original-article-buffer)))
3439 (setq afunc (car func)
3442 gfunc (intern (format "gnus-%s" func))))
3444 (when (fboundp afunc)
3445 `(lambda (&optional interactive &rest args)
3446 ,(documentation afunc t)
3447 (interactive (list t))
3449 (set-buffer gnus-article-buffer)
3451 (call-interactively ',afunc)
3452 (apply ',afunc args))))))))
3453 '(article-hide-headers
3454 article-verify-x-pgp-sig
3455 article-verify-cancel-lock
3456 article-hide-boring-headers
3457 article-treat-overstrike
3458 article-fill-long-lines
3459 article-capitalize-sentences
3461 article-remove-leading-whitespace
3462 article-display-x-face
3463 article-display-face
3464 article-de-quoted-unreadable
3465 article-de-base64-unreadable
3468 article-unsplit-urls
3469 article-hide-list-identifiers
3470 article-strip-banner
3473 article-hide-signature
3474 article-strip-headers-in-body
3475 article-remove-trailing-blank-lines
3476 article-strip-leading-blank-lines
3477 article-strip-multiple-blank-lines
3478 article-strip-leading-space
3479 article-strip-trailing-space
3480 article-strip-blank-lines
3481 article-strip-all-blank-lines
3483 article-date-english
3484 article-date-iso8601
3485 article-date-original
3487 article-decode-mime-words
3488 article-decode-charset
3489 article-decode-encoded-words
3493 article-treat-dumbquotes
3494 article-normalize-headers
3495 ;; (article-show-all . gnus-article-show-all-headers)
3499 ;;; Gnus article mode
3502 (put 'gnus-article-mode 'mode-class 'special)
3504 (set-keymap-parent gnus-article-mode-map widget-keymap)
3506 (gnus-define-keys gnus-article-mode-map
3507 " " gnus-article-goto-next-page
3508 "\177" gnus-article-goto-prev-page
3509 [delete] gnus-article-goto-prev-page
3510 [backspace] gnus-article-goto-prev-page
3511 "\C-c^" gnus-article-refer-article
3512 "h" gnus-article-show-summary
3513 "s" gnus-article-show-summary
3514 "\C-c\C-m" gnus-article-mail
3515 "?" gnus-article-describe-briefly
3516 "e" gnus-summary-edit-article
3517 "<" beginning-of-buffer
3519 "\C-c\C-i" gnus-info-find-node
3521 "R" gnus-article-reply-with-original
3522 "F" gnus-article-followup-with-original
3523 "\C-hk" gnus-article-describe-key
3524 "\C-hc" gnus-article-describe-key-briefly
3526 "\C-d" gnus-article-read-summary-keys
3527 "\M-*" gnus-article-read-summary-keys
3528 "\M-#" gnus-article-read-summary-keys
3529 "\M-^" gnus-article-read-summary-keys
3530 "\M-g" gnus-article-read-summary-keys)
3532 (substitute-key-definition
3533 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3535 (defun gnus-article-make-menu-bar ()
3536 (unless (boundp 'gnus-article-commands-menu)
3537 (gnus-summary-make-menu-bar))
3538 (gnus-turn-off-edit-menu 'article)
3539 (unless (boundp 'gnus-article-article-menu)
3541 gnus-article-article-menu gnus-article-mode-map ""
3543 ["Scroll forwards" gnus-article-goto-next-page t]
3544 ["Scroll backwards" gnus-article-goto-prev-page t]
3545 ["Show summary" gnus-article-show-summary t]
3546 ["Fetch Message-ID at point" gnus-article-refer-article t]
3547 ["Mail to address at point" gnus-article-mail t]
3548 ["Send a bug report" gnus-bug t]))
3551 gnus-article-treatment-menu gnus-article-mode-map ""
3552 ;; Fixme: this should use :active (and maybe :visible).
3554 ["Hide headers" gnus-article-hide-headers t]
3555 ["Hide signature" gnus-article-hide-signature t]
3556 ["Hide citation" gnus-article-hide-citation t]
3557 ["Treat overstrike" gnus-article-treat-overstrike t]
3558 ["Remove carriage return" gnus-article-remove-cr t]
3559 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3560 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3561 ["Remove base64" gnus-article-de-base64-unreadable t]
3562 ["Treat html" gnus-article-wash-html t]
3563 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3564 ["Decode HZ" gnus-article-decode-HZ t]))
3566 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3568 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3570 (gnus-run-hooks 'gnus-article-menu-hook)))
3572 (defun gnus-article-mode ()
3573 "Major mode for displaying an article.
3575 All normal editing commands are switched off.
3577 The following commands are available in addition to all summary mode
3579 \\<gnus-article-mode-map>
3580 \\[gnus-article-next-page]\t Scroll the article one page forwards
3581 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3582 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3583 \\[gnus-article-show-summary]\t Display the summary buffer
3584 \\[gnus-article-mail]\t Send a reply to the address near point
3585 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3586 \\[gnus-info-find-node]\t Go to the Gnus info node"
3588 (gnus-simplify-mode-line)
3589 (setq mode-name "Article")
3590 (setq major-mode 'gnus-article-mode)
3591 (make-local-variable 'minor-mode-alist)
3592 (use-local-map gnus-article-mode-map)
3593 (when (gnus-visual-p 'article-menu 'menu)
3594 (gnus-article-make-menu-bar)
3595 (when gnus-summary-tool-bar-map
3596 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3597 (gnus-update-format-specifications nil 'article-mode)
3598 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3599 (make-local-variable 'gnus-page-broken)
3600 (make-local-variable 'gnus-button-marker-list)
3601 (make-local-variable 'gnus-article-current-summary)
3602 (make-local-variable 'gnus-article-mime-handles)
3603 (make-local-variable 'gnus-article-decoded-p)
3604 (make-local-variable 'gnus-article-mime-handle-alist)
3605 (make-local-variable 'gnus-article-wash-types)
3606 (make-local-variable 'gnus-article-image-alist)
3607 (make-local-variable 'gnus-article-charset)
3608 (make-local-variable 'gnus-article-ignored-charsets)
3609 (gnus-set-default-directory)
3610 (buffer-disable-undo)
3611 (setq buffer-read-only t)
3612 (set-syntax-table gnus-article-mode-syntax-table)
3613 (mm-enable-multibyte)
3614 (gnus-run-hooks 'gnus-article-mode-hook))
3616 (defun gnus-article-setup-buffer ()
3617 "Initialize the article buffer."
3618 (let* ((name (if gnus-single-article-buffer "*Article*"
3619 (concat "*Article " gnus-newsgroup-name "*")))
3621 (progn (string-match "\\*Article" name)
3622 (concat " *Original Article"
3623 (substring name (match-end 0))))))
3624 (setq gnus-article-buffer name)
3625 (setq gnus-original-article-buffer original)
3626 (setq gnus-article-mime-handle-alist nil)
3627 ;; This might be a variable local to the summary buffer.
3628 (unless gnus-single-article-buffer
3630 (set-buffer gnus-summary-buffer)
3631 (setq gnus-article-buffer name)
3632 (setq gnus-original-article-buffer original)
3633 (gnus-set-global-variables)))
3634 (gnus-article-setup-highlight-words)
3635 ;; Init original article buffer.
3637 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3638 (mm-enable-multibyte)
3639 (setq major-mode 'gnus-original-article-mode)
3640 (make-local-variable 'gnus-original-article))
3641 (if (get-buffer name)
3644 (when (and gnus-article-edit-mode
3647 (y-or-n-p "Article mode edit in progress; discard? ")))
3648 (error "Action aborted"))
3649 (set (make-local-variable 'gnus-article-edit-mode) nil)
3650 (when gnus-article-mime-handles
3651 (mm-destroy-parts gnus-article-mime-handles)
3652 (setq gnus-article-mime-handles nil))
3653 ;; Set it to nil in article-buffer!
3654 (setq gnus-article-mime-handle-alist nil)
3655 (buffer-disable-undo)
3656 (setq buffer-read-only t)
3657 ;; This list just keeps growing if we don't reset it.
3658 (setq gnus-button-marker-list nil)
3659 (unless (eq major-mode 'gnus-article-mode)
3660 (gnus-article-mode))
3663 (set-buffer (gnus-get-buffer-create name))
3665 (make-local-variable 'gnus-summary-buffer)
3666 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3667 (current-buffer)))))
3669 ;; Set article window start at LINE, where LINE is the number of lines
3670 ;; from the head of the article.
3671 (defun gnus-article-set-window-start (&optional line)
3673 (gnus-get-buffer-window gnus-article-buffer t)
3675 (set-buffer gnus-article-buffer)
3676 (goto-char (point-min))
3679 (gnus-message 6 "Moved to bookmark")
3680 (search-forward "\n\n" nil t)
3684 (defun gnus-article-prepare (article &optional all-headers header)
3685 "Prepare ARTICLE in article mode buffer.
3686 ARTICLE should either be an article number or a Message-ID.
3687 If ARTICLE is an id, HEADER should be the article headers.
3688 If ALL-HEADERS is non-nil, no headers are hidden."
3690 ;; Make sure we start in a summary buffer.
3691 (unless (eq major-mode 'gnus-summary-mode)
3692 (set-buffer gnus-summary-buffer))
3693 (setq gnus-summary-buffer (current-buffer))
3694 (let* ((gnus-article (if header (mail-header-number header) article))
3695 (summary-buffer (current-buffer))
3696 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3697 (group gnus-newsgroup-name)
3700 (gnus-article-setup-buffer)
3701 (set-buffer gnus-article-buffer)
3702 ;; Deactivate active regions.
3703 (when (and (boundp 'transient-mark-mode)
3704 transient-mark-mode)
3705 (setq mark-active nil))
3706 (if (not (setq result (let ((buffer-read-only nil))
3707 (gnus-request-article-this-buffer
3709 ;; There is no such article.
3711 (when (and (numberp article)
3712 (not (memq article gnus-newsgroup-sparse)))
3713 (setq gnus-article-current
3714 (cons gnus-newsgroup-name article))
3715 (set-buffer gnus-summary-buffer)
3716 (setq gnus-current-article article)
3717 (if (and (memq article gnus-newsgroup-undownloaded)
3718 (not (gnus-online (gnus-find-method-for-group
3719 gnus-newsgroup-name))))
3721 (gnus-summary-set-agent-mark article)
3722 (message "Message marked for downloading"))
3723 (gnus-summary-mark-article article gnus-canceled-mark)
3724 (unless (memq article gnus-newsgroup-sparse)
3725 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3726 (if (or (eq result 'pseudo)
3727 (eq result 'nneething))
3730 (set-buffer summary-buffer)
3731 (push article gnus-newsgroup-history)
3732 (setq gnus-last-article gnus-current-article
3733 gnus-current-article 0
3734 gnus-current-headers nil
3735 gnus-article-current nil)
3736 (if (eq result 'nneething)
3737 (gnus-configure-windows 'summary)
3738 (gnus-configure-windows 'article))
3739 (gnus-set-global-variables))
3740 (let ((gnus-article-mime-handle-alist-1
3741 gnus-article-mime-handle-alist))
3742 (gnus-set-mode-line 'article)))
3743 ;; The result from the `request' was an actual article -
3744 ;; or at least some text that is now displayed in the
3746 (when (and (numberp article)
3747 (not (eq article gnus-current-article)))
3748 ;; Seems like a new article has been selected.
3749 ;; `gnus-current-article' must be an article number.
3751 (set-buffer summary-buffer)
3752 (push article gnus-newsgroup-history)
3753 (setq gnus-last-article gnus-current-article
3754 gnus-current-article article
3755 gnus-current-headers
3756 (gnus-summary-article-header gnus-current-article)
3757 gnus-article-current
3758 (cons gnus-newsgroup-name gnus-current-article))
3759 (unless (vectorp gnus-current-headers)
3760 (setq gnus-current-headers nil))
3761 (gnus-summary-goto-subject gnus-current-article)
3762 (when (gnus-summary-show-thread)
3763 ;; If the summary buffer really was folded, the
3764 ;; previous goto may not actually have gone to
3765 ;; the right article, but the thread root instead.
3767 (gnus-summary-goto-subject gnus-current-article))
3768 (gnus-run-hooks 'gnus-mark-article-hook)
3769 (gnus-set-mode-line 'summary)
3770 (when (gnus-visual-p 'article-highlight 'highlight)
3771 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3772 ;; Set the global newsgroup variables here.
3773 (gnus-set-global-variables)
3774 (setq gnus-have-all-headers
3775 (or all-headers gnus-show-all-headers))))
3777 (gnus-configure-windows 'article))
3778 (when (or (numberp article)
3780 (gnus-article-prepare-display)
3782 (goto-char (point-min))
3783 (setq gnus-page-broken
3784 (when gnus-break-pages
3785 (gnus-narrow-to-page)
3787 (let ((gnus-article-mime-handle-alist-1
3788 gnus-article-mime-handle-alist))
3789 (gnus-set-mode-line 'article))
3793 (set-window-point (get-buffer-window (current-buffer)) (point))
3794 (gnus-configure-windows 'article)
3798 (defun gnus-article-prepare-display ()
3799 "Make the current buffer look like a nice article."
3800 ;; Hooks for getting information from the article.
3801 ;; This hook must be called before being narrowed.
3802 (let ((gnus-article-buffer (current-buffer))
3804 (unless (eq major-mode 'gnus-article-mode)
3805 (gnus-article-mode))
3806 (setq buffer-read-only nil
3807 gnus-article-wash-types nil
3808 gnus-article-image-alist nil)
3809 (gnus-run-hooks 'gnus-tmp-internal-hook)
3810 (when gnus-display-mime-function
3811 (funcall gnus-display-mime-function))
3812 (gnus-run-hooks 'gnus-article-prepare-hook)))
3815 ;;; Gnus MIME viewing functions
3818 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3819 "Format of the MIME buttons.
3821 Valid specifiers include:
3823 %T MIME type, along with additional info
3824 %n The `name' parameter
3825 %d The description, if any
3826 %l The length of the encoded part
3827 %p The part identifier number
3828 %e Dots if the part isn't displayed
3830 General format specifiers can also be used. See Info node
3831 `(gnus)Formatting Variables'.")
3833 (defvar gnus-mime-button-line-format-alist
3834 '((?t gnus-tmp-type ?s)
3835 (?T gnus-tmp-type-long ?s)
3836 (?n gnus-tmp-name ?s)
3837 (?d gnus-tmp-description ?s)
3839 (?l gnus-tmp-length ?d)
3840 (?e gnus-tmp-dots ?s)))
3842 (defvar gnus-mime-button-commands
3843 '((gnus-article-press-button "\r" "Toggle Display")
3844 (gnus-mime-view-part "v" "View Interactively...")
3845 (gnus-mime-view-part-as-type "t" "View As Type...")
3846 (gnus-mime-view-part-as-charset "C" "View As charset...")
3847 (gnus-mime-save-part "o" "Save...")
3848 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3849 (gnus-mime-delete-part "d" "Delete part")
3850 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3851 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3852 (gnus-mime-view-part-internally "E" "View Internally")
3853 (gnus-mime-view-part-externally "e" "View Externally")
3854 (gnus-mime-print-part "p" "Print")
3855 (gnus-mime-pipe-part "|" "Pipe To Command...")
3856 (gnus-mime-action-on-part "." "Take action on the part...")))
3858 (defun gnus-article-mime-part-status ()
3859 (if gnus-article-mime-handle-alist-1
3860 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3862 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3865 (defvar gnus-mime-button-map
3866 (let ((map (make-sparse-keymap)))
3867 (unless (>= (string-to-number emacs-version) 21)
3868 ;; XEmacs doesn't care.
3869 (set-keymap-parent map gnus-article-mode-map))
3870 (define-key map gnus-mouse-2 'gnus-article-push-button)
3871 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3872 (dolist (c gnus-mime-button-commands)
3873 (define-key map (cadr c) (car c)))
3877 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3879 ,@(mapcar (lambda (c)
3880 (vector (caddr c) (car c) :enable t))
3881 gnus-mime-button-commands)))
3884 (define-compiler-macro popup-menu (&whole form
3885 menu &optional position prefix)
3886 (if (and (fboundp 'popup-menu)
3887 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3889 ;; Gnus is probably running under Emacs 20.
3890 `(let* ((menu (cdr ,menu))
3891 (response (x-popup-menu
3893 (cons "" (mapcar (lambda (c)
3894 (cons (caddr c) (car c)))
3897 (call-interactively (nth 3 (assq response menu))))))))
3899 (defun gnus-mime-button-menu (event prefix)
3900 "Construct a context-sensitive menu of MIME commands."
3901 (interactive "e\nP")
3902 (save-window-excursion
3903 (let ((pos (event-start event)))
3904 (select-window (posn-window pos))
3905 (goto-char (posn-point pos))
3906 (gnus-article-check-buffer)
3907 (popup-menu gnus-mime-button-menu nil prefix))))
3909 (defun gnus-mime-view-all-parts (&optional handles)
3910 "View all the MIME parts."
3912 (save-current-buffer
3913 (set-buffer gnus-article-buffer)
3914 (let ((handles (or handles gnus-article-mime-handles))
3915 (mail-parse-charset gnus-newsgroup-charset)
3916 (mail-parse-ignored-charsets
3917 (with-current-buffer gnus-summary-buffer
3918 gnus-newsgroup-ignored-charsets)))
3920 (mm-remove-parts handles)
3921 (goto-char (point-min))
3922 (or (search-forward "\n\n") (goto-char (point-max)))
3923 (let (buffer-read-only)
3924 (delete-region (point) (point-max))
3925 (mm-display-parts handles))))))
3927 (defun gnus-mime-save-part-and-strip ()
3928 "Save the MIME part under point then replace it with an external body."
3930 (gnus-article-check-buffer)
3931 (let* ((data (get-text-property (point) 'gnus-data))
3933 (handles gnus-article-mime-handles))
3934 (if (mm-multiple-handles gnus-article-mime-handles)
3935 (error "This function is not implemented"))
3936 (setq file (and data (mm-save-part data)))
3938 (with-current-buffer (mm-handle-buffer data)
3940 (insert "Content-Type: " (mm-handle-media-type data))
3941 (mml-insert-parameter-string (cdr (mm-handle-type data))
3944 (insert "Content-ID: " (message-make-message-id) "\n")
3945 (insert "Content-Transfer-Encoding: binary\n")
3948 (cdr (mm-make-handle nil
3949 `("message/external-body"
3950 (access-type . "LOCAL-FILE")
3952 (set-buffer gnus-summary-buffer)
3953 (gnus-article-edit-article
3956 (let ((mail-parse-charset (or gnus-article-charset
3957 ',gnus-newsgroup-charset))
3958 (mail-parse-ignored-charsets
3959 (or gnus-article-ignored-charsets
3960 ',gnus-newsgroup-ignored-charsets))
3961 (mbl mml-buffer-list))
3962 (setq mml-buffer-list nil)
3963 (insert-buffer gnus-original-article-buffer)
3964 (mime-to-mml ',handles)
3965 (setq gnus-article-mime-handles nil)
3966 (let ((mbl1 mml-buffer-list))
3967 (setq mml-buffer-list mbl)
3968 (set (make-local-variable 'mml-buffer-list) mbl1))
3969 (gnus-make-local-hook 'kill-buffer-hook)
3970 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3971 `(lambda (no-highlight)
3972 (let ((mail-parse-charset (or gnus-article-charset
3973 ',gnus-newsgroup-charset))
3974 (message-options message-options)
3975 (message-options-set-recipient)
3976 (mail-parse-ignored-charsets
3977 (or gnus-article-ignored-charsets
3978 ',gnus-newsgroup-ignored-charsets)))
3980 (mml-destroy-buffers)
3981 (remove-hook 'kill-buffer-hook
3982 'mml-destroy-buffers t)
3983 (kill-local-variable 'mml-buffer-list))
3984 (gnus-summary-edit-article-done
3985 ,(or (mail-header-references gnus-current-headers) "")
3986 ,(gnus-group-read-only-p)
3987 ,gnus-summary-buffer no-highlight))))))
3989 (defun gnus-mime-delete-part ()
3990 "Delete the MIME part under point.
3991 Replace it with some information about the removed part."
3993 (gnus-article-check-buffer)
3994 (unless (and gnus-novice-user
3995 (not (gnus-yes-or-no-p
3996 "Really delete attachment forever? ")))
3997 (let* ((data (get-text-property (point) 'gnus-data))
3998 (handles gnus-article-mime-handles)
4002 (mail-decode-encoded-word-string (or (mm-handle-description data)
4005 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4007 (type (mm-handle-media-type data)))
4008 (if (mm-multiple-handles gnus-article-mime-handles)
4009 (error "This function is not implemented"))
4010 (with-current-buffer (mm-handle-buffer data)
4011 (let ((bsize (format "%s" (buffer-size))))
4015 "<#part type=text/plain nofile=yes disposition=attachment"
4016 " description=\"Deleted attachment (" bsize " Byte)\">"
4018 "| The following attachment has been deleted:\n"
4020 "| Type: " type "\n"
4021 "| Filename: " filename "\n"
4022 "| Size (encoded): " bsize " Byte\n"
4023 "| Description: " description "\n"
4027 (cdr (mm-make-handle nil `("text/plain"))))))
4028 (set-buffer gnus-summary-buffer)
4029 ;; FIXME: maybe some of the following code (borrowed from
4030 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4031 (gnus-article-edit-article
4034 (let ((mail-parse-charset (or gnus-article-charset
4035 ',gnus-newsgroup-charset))
4036 (mail-parse-ignored-charsets
4037 (or gnus-article-ignored-charsets
4038 ',gnus-newsgroup-ignored-charsets))
4039 (mbl mml-buffer-list))
4040 (setq mml-buffer-list nil)
4041 (insert-buffer gnus-original-article-buffer)
4042 (mime-to-mml ',handles)
4043 (setq gnus-article-mime-handles nil)
4044 (let ((mbl1 mml-buffer-list))
4045 (setq mml-buffer-list mbl)
4046 (set (make-local-variable 'mml-buffer-list) mbl1))
4047 (gnus-make-local-hook 'kill-buffer-hook)
4048 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4049 `(lambda (no-highlight)
4050 (let ((mail-parse-charset (or gnus-article-charset
4051 ',gnus-newsgroup-charset))
4052 (message-options message-options)
4053 (message-options-set-recipient)
4054 (mail-parse-ignored-charsets
4055 (or gnus-article-ignored-charsets
4056 ',gnus-newsgroup-ignored-charsets)))
4058 (mml-destroy-buffers)
4059 (remove-hook 'kill-buffer-hook
4060 'mml-destroy-buffers t)
4061 (kill-local-variable 'mml-buffer-list))
4062 (gnus-summary-edit-article-done
4063 ,(or (mail-header-references gnus-current-headers) "")
4064 ,(gnus-group-read-only-p)
4065 ,gnus-summary-buffer no-highlight)))))
4066 ;; Not in `gnus-mime-save-part-and-strip':
4067 (gnus-article-edit-done)
4068 (gnus-summary-expand-window)
4069 (gnus-summary-show-article))
4071 (defun gnus-mime-save-part ()
4072 "Save the MIME part under point."
4074 (gnus-article-check-buffer)
4075 (let ((data (get-text-property (point) 'gnus-data)))
4077 (mm-save-part data))))
4079 (defun gnus-mime-pipe-part ()
4080 "Pipe the MIME part under point to a process."
4082 (gnus-article-check-buffer)
4083 (let ((data (get-text-property (point) 'gnus-data)))
4085 (mm-pipe-part data))))
4087 (defun gnus-mime-view-part ()
4088 "Interactively choose a viewing method for the MIME part under point."
4090 (gnus-article-check-buffer)
4091 (let ((data (get-text-property (point) 'gnus-data)))
4093 (setq gnus-article-mime-handles
4095 gnus-article-mime-handles (setq data (copy-sequence data))))
4096 (mm-interactively-view-part data))))
4098 (defun gnus-mime-view-part-as-type-internal ()
4099 (gnus-article-check-buffer)
4100 (let* ((name (mail-content-type-get
4101 (mm-handle-type (get-text-property (point) 'gnus-data))
4103 (def-type (and name (mm-default-file-encoding name))))
4104 (and def-type (cons def-type 0))))
4106 (defun gnus-mime-view-part-as-type (&optional mime-type)
4107 "Choose a MIME media type, and view the part as such."
4110 (setq mime-type (completing-read
4111 "View as MIME type: "
4112 (mapcar #'list (mailcap-mime-types))
4114 (gnus-mime-view-part-as-type-internal))))
4115 (gnus-article-check-buffer)
4116 (let ((handle (get-text-property (point) 'gnus-data)))
4119 (mm-make-handle (mm-handle-buffer handle)
4120 (cons mime-type (cdr (mm-handle-type handle)))
4121 (mm-handle-encoding handle)
4122 (mm-handle-undisplayer handle)
4123 (mm-handle-disposition handle)
4124 (mm-handle-description handle)
4126 (mm-handle-id handle)))
4127 (setq gnus-article-mime-handles
4128 (mm-merge-handles gnus-article-mime-handles handle))
4129 (gnus-mm-display-part handle))))
4132 (require 'jka-compr))
4134 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4135 ;; emacs can do that itself.
4137 (defun gnus-mime-jka-compr-maybe-uncompress ()
4138 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4139 The uncompress method used is derived from `buffer-file-name'."
4140 (when (and (fboundp 'jka-compr-installed-p)
4141 (jka-compr-installed-p))
4142 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4144 (let ((basename (file-name-nondirectory buffer-file-name))
4145 (args (jka-compr-info-uncompress-args info))
4146 (prog (jka-compr-info-uncompress-program info))
4147 (message (jka-compr-info-uncompress-message info))
4148 (err-file (jka-compr-make-temp-name)))
4150 (message "%s %s..." message basename))
4152 (unless (memq (apply 'call-process-region
4153 (point-min) (point-max)
4155 t (list t err-file) nil
4157 jka-compr-acceptable-retval-list)
4158 (jka-compr-error prog args basename message err-file))
4159 (jka-compr-delete-temp-file err-file)))))))
4161 (defun gnus-mime-copy-part (&optional handle)
4162 "Put the MIME part under point into a new buffer.
4163 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4166 (gnus-article-check-buffer)
4167 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4168 (contents (and handle (mm-get-part handle)))
4170 (file-name-nondirectory
4172 (mail-content-type-get (mm-handle-type handle) 'name)
4173 (mail-content-type-get (mm-handle-disposition handle)
4176 (buffer (and base (generate-new-buffer base))))
4178 (switch-to-buffer buffer)
4180 ;; We do it this way to make `normal-mode' set the appropriate mode.
4183 (setq buffer-file-name (expand-file-name base))
4184 (gnus-mime-jka-compr-maybe-uncompress)
4186 (setq buffer-file-name nil))
4187 (goto-char (point-min)))))
4189 (defun gnus-mime-print-part (&optional handle filename)
4190 "Print the MIME part under point."
4191 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4192 (gnus-article-check-buffer)
4193 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4194 (contents (and handle (mm-get-part handle)))
4195 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4196 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4201 (mm-save-part-to-file handle file)
4202 (call-process shell-file-name nil
4203 (generate-new-buffer " *mm*")
4205 shell-command-switch
4207 printer file (mm-handle-type handle))))
4211 (gnus-print-buffer))
4212 (ps-despool filename)))))
4214 (defun gnus-mime-inline-part (&optional handle arg)
4215 "Insert the MIME part under point into the current buffer."
4216 (interactive (list nil current-prefix-arg))
4217 (gnus-article-check-buffer)
4218 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4223 (if (and (not arg) (mm-handle-undisplayer handle))
4224 (mm-remove-part handle)
4225 (setq contents (mm-get-part handle))
4228 (setq charset (or (mail-content-type-get
4229 (mm-handle-type handle) 'charset)
4230 gnus-newsgroup-charset)))
4232 (if (mm-handle-undisplayer handle)
4233 (mm-remove-part handle))
4236 gnus-summary-show-article-charset-alist))
4237 (mm-read-coding-system "Charset: ")))))
4239 (mm-insert-inline handle
4241 (setq charset (mm-charset-to-coding-system
4243 (not (eq charset 'ascii)))
4244 (mm-decode-coding-string contents charset)
4248 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4249 "Insert the MIME part under point into the current buffer using the
4251 (interactive (list nil current-prefix-arg))
4252 (gnus-article-check-buffer)
4253 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4258 (if (mm-handle-undisplayer handle)
4259 (mm-remove-part handle))
4260 (let ((gnus-newsgroup-charset
4262 gnus-summary-show-article-charset-alist))
4263 (mm-read-coding-system "Charset: ")))
4264 (gnus-newsgroup-ignored-charsets 'gnus-all))
4265 (gnus-article-press-button)))))
4267 (defun gnus-mime-view-part-externally (&optional handle)
4268 "View the MIME part under point with an external viewer."
4270 (gnus-article-check-buffer)
4271 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4272 (mm-user-display-methods nil)
4273 (mm-inlined-types nil)
4274 (mail-parse-charset gnus-newsgroup-charset)
4275 (mail-parse-ignored-charsets
4276 (save-excursion (set-buffer gnus-summary-buffer)
4277 gnus-newsgroup-ignored-charsets)))
4279 (if (mm-handle-undisplayer handle)
4280 (mm-remove-part handle)
4281 (mm-display-part handle)))))
4283 (defun gnus-mime-view-part-internally (&optional handle)
4284 "View the MIME part under point with an internal viewer.
4285 If no internal viewer is available, use an external viewer."
4287 (gnus-article-check-buffer)
4288 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4289 (mm-inlined-types '(".*"))
4290 (mm-inline-large-images t)
4291 (mail-parse-charset gnus-newsgroup-charset)
4292 (mail-parse-ignored-charsets
4293 (save-excursion (set-buffer gnus-summary-buffer)
4294 gnus-newsgroup-ignored-charsets))
4297 (if (mm-handle-undisplayer handle)
4298 (mm-remove-part handle)
4299 (mm-display-part handle)))))
4301 (defun gnus-mime-action-on-part (&optional action)
4302 "Do something with the MIME attachment at \(point\)."
4304 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4305 (gnus-article-check-buffer)
4306 (let ((action-pair (assoc action gnus-mime-action-alist)))
4308 (funcall (cdr action-pair)))))
4310 (defun gnus-article-part-wrapper (n function)
4311 (save-current-buffer
4312 (set-buffer gnus-article-buffer)
4313 (when (> n (length gnus-article-mime-handle-alist))
4314 (error "No such part"))
4315 (gnus-article-goto-part n)
4316 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4317 (funcall function handle))))
4319 (defun gnus-article-pipe-part (n)
4320 "Pipe MIME part N, which is the numerical prefix."
4322 (gnus-article-part-wrapper n 'mm-pipe-part))
4324 (defun gnus-article-save-part (n)
4325 "Save MIME part N, which is the numerical prefix."
4327 (gnus-article-part-wrapper n 'mm-save-part))
4329 (defun gnus-article-interactively-view-part (n)
4330 "View MIME part N interactively, which is the numerical prefix."
4332 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4334 (defun gnus-article-copy-part (n)
4335 "Copy MIME part N, which is the numerical prefix."
4337 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4339 (defun gnus-article-view-part-as-charset (n)
4340 "Copy MIME part N, which is the numerical prefix."
4342 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4344 (defun gnus-article-view-part-externally (n)
4345 "View MIME part N externally, which is the numerical prefix."
4347 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4349 (defun gnus-article-inline-part (n)
4350 "Inline MIME part N, which is the numerical prefix."
4352 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4354 (defun gnus-article-mime-match-handle-first (condition)
4356 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4357 (while (setq ihandle (pop alist))
4359 ((functionp condition)
4360 (funcall condition (cdr ihandle)))
4361 ((eq condition 'undisplayed)
4362 (not (or (mm-handle-undisplayer (cdr ihandle))
4363 (equal (mm-handle-media-type (cdr ihandle))
4364 "multipart/alternative"))))
4365 ((eq condition 'undisplayed-alternative)
4366 (not (mm-handle-undisplayer (cdr ihandle))))
4368 (gnus-article-goto-part (car ihandle))
4369 (or (not n) (< (car ihandle) n)))
4370 (setq n (car ihandle))))
4374 (defun gnus-article-view-part (&optional n)
4375 "View MIME part N, which is the numerical prefix."
4377 (save-current-buffer
4378 (set-buffer gnus-article-buffer)
4379 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4380 gnus-article-mime-match-handle-function)))
4381 (when (> n (length gnus-article-mime-handle-alist))
4382 (error "No such part"))
4383 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4384 (when (gnus-article-goto-part n)
4385 (if (equal (car handle) "multipart/alternative")
4386 (gnus-article-press-button)
4387 (when (eq (gnus-mm-display-part handle) 'internal)
4388 (gnus-set-window-start)))))))
4390 (defsubst gnus-article-mime-total-parts ()
4391 (if (bufferp (car gnus-article-mime-handles))
4393 (1- (length gnus-article-mime-handles))))
4395 (defun gnus-mm-display-part (handle)
4396 "Display HANDLE and fix MIME button."
4397 (let ((id (get-text-property (point) 'gnus-part))
4402 (let ((window (selected-window))
4403 (mail-parse-charset gnus-newsgroup-charset)
4404 (mail-parse-ignored-charsets
4405 (if (gnus-buffer-live-p gnus-summary-buffer)
4407 (set-buffer gnus-summary-buffer)
4408 gnus-newsgroup-ignored-charsets)
4412 (let ((win (gnus-get-buffer-window (current-buffer) t))
4415 (select-window win))
4418 (if (mm-handle-displayed-p handle)
4419 ;; This will remove the part.
4420 (mm-display-part handle)
4422 (narrow-to-region (point)
4423 (if (eobp) (point) (1+ (point))))
4424 (mm-display-part handle)
4425 ;; We narrow to the part itself and
4426 ;; then call the treatment functions.
4427 (goto-char (point-min))
4429 (narrow-to-region (point) (point-max))
4432 (gnus-article-mime-total-parts)
4433 (mm-handle-media-type handle)))))
4434 (if (window-live-p window)
4435 (select-window window)))))
4438 (gnus-insert-mime-button
4439 handle id (list (mm-handle-displayed-p handle)))
4440 (goto-char point))))
4442 (defun gnus-article-goto-part (n)
4443 "Go to MIME part N."
4444 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4446 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4447 (let ((gnus-tmp-name
4448 (or (mail-content-type-get (mm-handle-type handle) 'name)
4449 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4450 (mail-content-type-get (mm-handle-type handle) 'url)
4452 (gnus-tmp-type (mm-handle-media-type handle))
4453 (gnus-tmp-description
4454 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4457 (if (if displayed (car displayed)
4458 (mm-handle-displayed-p handle))
4460 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4462 gnus-tmp-type-long b e)
4463 (when (string-match ".*/" gnus-tmp-name)
4464 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4465 (setq gnus-tmp-type-long (concat gnus-tmp-type
4466 (and (not (equal gnus-tmp-name ""))
4467 (concat "; " gnus-tmp-name))))
4468 (unless (equal gnus-tmp-description "")
4469 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4474 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4475 `(,@(gnus-local-map-property gnus-mime-button-map)
4476 gnus-callback gnus-mm-display-part
4477 gnus-part ,gnus-tmp-id
4478 article-type annotation
4481 ;; Exclude a newline.
4484 (widget-convert-button
4487 :action 'gnus-widget-press-button
4488 :button-keymap gnus-mime-button-map
4490 (lambda (widget/window &optional overlay pos)
4491 ;; Needed to properly clear the message due to a bug in
4492 ;; wid-edit (XEmacs only).
4493 (if (boundp 'help-echo-owns-message)
4494 (setq help-echo-owns-message t))
4496 "%S: %s the MIME part; %S: more options"
4497 (aref gnus-mouse-2 0)
4498 ;; XEmacs will get a single widget arg; Emacs 21 will get
4499 ;; window, overlay, position.
4500 (if (mm-handle-displayed-p
4502 (with-current-buffer (gnus-overlay-buffer overlay)
4503 (widget-get (widget-at (gnus-overlay-start overlay))
4505 (widget-get widget/window :mime-handle)))
4507 (aref gnus-down-mouse-3 0))))))
4509 (defun gnus-widget-press-button (elems el)
4510 (goto-char (widget-get elems :from))
4511 (gnus-article-press-button))
4513 (defvar gnus-displaying-mime nil)
4515 (defun gnus-display-mime (&optional ihandles)
4516 "Display the MIME parts."
4518 (save-selected-window
4519 (let ((window (get-buffer-window gnus-article-buffer))
4522 (select-window window)
4523 ;; We have to do this since selecting the window
4524 ;; may change the point. So we set the window point.
4525 (set-window-point window point)))
4526 (let* ((handles (or ihandles
4527 (mm-dissect-buffer nil gnus-article-loose-mime)
4528 (and gnus-article-emulate-mime
4530 buffer-read-only handle name type b e display)
4531 (when (and (not ihandles)
4532 (not gnus-displaying-mime))
4533 ;; Top-level call; we clean up.
4534 (when gnus-article-mime-handles
4535 (mm-destroy-parts gnus-article-mime-handles)
4536 (setq gnus-article-mime-handle-alist nil));; A trick.
4537 (setq gnus-article-mime-handles handles)
4538 ;; We allow users to glean info from the handles.
4539 (when gnus-article-mime-part-function
4540 (gnus-mime-part-function handles)))
4542 (or (not (stringp (car handles)))
4545 (when (and (not ihandles)
4546 (not gnus-displaying-mime))
4547 ;; Clean up for mime parts.
4549 (delete-region (point) (point-max)))
4550 (let ((gnus-displaying-mime t))
4551 (gnus-mime-display-part handles)))
4554 (narrow-to-region (point) (point-max))
4555 (gnus-treat-article nil 1 1)
4558 ;; Highlight the headers.
4562 (narrow-to-region (point-min) (point))
4563 (gnus-treat-article 'head))))))))
4565 (defcustom gnus-mime-display-multipart-as-mixed nil
4566 "Display \"multipart\" parts as \"multipart/mixed\".
4568 If t, it overrides nil values of
4569 `gnus-mime-display-multipart-alternative-as-mixed' and
4570 `gnus-mime-display-multipart-related-as-mixed'."
4571 :group 'gnus-article-mime
4574 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4575 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4576 :group 'gnus-article-mime
4579 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4580 "Display \"multipart/related\" parts as \"multipart/mixed\".
4582 If displaying \"text/html\" is discouraged \(see
4583 `mm-discouraged-alternatives'\) images or other material inside a
4584 \"multipart/related\" part might be overlooked when this variable is nil."
4585 :group 'gnus-article-mime
4588 (defun gnus-mime-display-part (handle)
4591 ((not (stringp (car handle)))
4592 (gnus-mime-display-single handle))
4593 ;; User-defined multipart
4594 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4595 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4597 ;; multipart/alternative
4598 ((and (equal (car handle) "multipart/alternative")
4599 (not (or gnus-mime-display-multipart-as-mixed
4600 gnus-mime-display-multipart-alternative-as-mixed)))
4601 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4602 (push (cons id handle) gnus-article-mime-handle-alist)
4603 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4604 ;; multipart/related
4605 ((and (equal (car handle) "multipart/related")
4606 (not (or gnus-mime-display-multipart-as-mixed
4607 gnus-mime-display-multipart-related-as-mixed)))
4608 ;;;!!!We should find the start part, but we just default
4609 ;;;!!!to the first part.
4610 ;;(gnus-mime-display-part (cadr handle))
4611 ;;;!!! Most multipart/related is an HTML message plus images.
4612 ;;;!!! Unfortunately we are unable to let W3 display those
4613 ;;;!!! included images, so we just display it as a mixed multipart.
4614 ;;(gnus-mime-display-mixed (cdr handle))
4615 ;;;!!! No, w3 can display everything just fine.
4616 (gnus-mime-display-part (cadr handle)))
4617 ((equal (car handle) "multipart/signed")
4618 (gnus-add-wash-type 'signed)
4619 (gnus-mime-display-security handle))
4620 ((equal (car handle) "multipart/encrypted")
4621 (gnus-add-wash-type 'encrypted)
4622 (gnus-mime-display-security handle))
4623 ;; Other multiparts are handled like multipart/mixed.
4625 (gnus-mime-display-mixed (cdr handle)))))
4627 (defun gnus-mime-part-function (handles)
4628 (if (stringp (car handles))
4629 (mapcar 'gnus-mime-part-function (cdr handles))
4630 (funcall gnus-article-mime-part-function handles)))
4632 (defun gnus-mime-display-mixed (handles)
4633 (mapcar 'gnus-mime-display-part handles))
4635 (defun gnus-mime-display-single (handle)
4636 (let ((type (mm-handle-media-type handle))
4637 (ignored gnus-ignored-mime-types)
4644 (when (string-match (pop ignored) type)
4645 (throw 'ignored nil)))
4646 (if (and (setq not-attachment
4647 (and (not (mm-inline-override-p handle))
4648 (or (not (mm-handle-disposition handle))
4649 (equal (car (mm-handle-disposition handle))
4651 (mm-attachment-override-p handle))))
4652 (mm-automatic-display-p handle)
4654 (mm-inlinable-p handle)
4655 (mm-inlined-p handle))
4656 (mm-automatic-external-display-p type)))
4658 (when (equal (mm-handle-media-supertype handle) "text")
4660 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4662 (push (cons id handle) gnus-article-mime-handle-alist)
4663 (when (or (not display)
4664 (not (gnus-unbuttonized-mime-type-p type)))
4665 ;(gnus-article-insert-newline)
4666 (gnus-insert-mime-button
4667 handle id (list (or display (and not-attachment text))))
4668 (gnus-article-insert-newline)
4669 ;(gnus-article-insert-newline)
4670 ;; Remember modify the number of forward lines.
4678 (let ((mail-parse-charset gnus-newsgroup-charset)
4679 (mail-parse-ignored-charsets
4680 (save-excursion (condition-case ()
4681 (set-buffer gnus-summary-buffer)
4683 gnus-newsgroup-ignored-charsets)))
4684 (mm-display-part handle t))
4685 (goto-char (point-max)))
4686 ((and text not-attachment)
4690 (gnus-article-insert-newline)
4691 (mm-insert-inline handle (mm-get-part handle))
4692 (goto-char (point-max))))
4696 (narrow-to-region beg (point))
4699 (gnus-article-mime-total-parts)
4700 (mm-handle-media-type handle)))))))))
4702 (defun gnus-unbuttonized-mime-type-p (type)
4703 "Say whether TYPE is to be unbuttonized."
4704 (unless gnus-inhibit-mime-unbuttonizing
4706 (let ((types gnus-unbuttonized-mime-types))
4708 (when (string-match (pop types) type)
4709 (throw 'found t)))))
4711 (let ((types gnus-buttonized-mime-types))
4713 (when (string-match (pop types) type)
4714 (throw 'found t)))))))))
4716 (defun gnus-article-insert-newline ()
4717 "Insert a newline, but mark it as undeletable."
4718 (gnus-put-text-property
4719 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4721 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4722 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4725 handle buffer-read-only from props begend not-pref)
4726 (save-window-excursion
4729 (narrow-to-region (car ibegend)
4732 (goto-char (car ibegend))
4735 (delete-region (point-min) (point-max))
4736 (mm-remove-parts handles))
4737 (setq begend (list (point-marker)))
4739 (unless (setq not-pref (cadr (member preferred ihandles)))
4740 (setq not-pref (car ihandles)))
4743 (not (gnus-unbuttonized-mime-type-p
4744 "multipart/alternative")))
4745 (gnus-add-text-properties
4748 (insert (format "%d. " id))
4752 (unless ,(not ibegend)
4753 (setq gnus-article-mime-handle-alist
4754 ',gnus-article-mime-handle-alist))
4755 (gnus-mime-display-alternative
4756 ',ihandles ',not-pref ',begend ,id))
4757 ,@(gnus-local-map-property gnus-mime-button-map)
4758 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4759 face ,gnus-article-button-face
4762 (widget-convert-button 'link from (point)
4763 :action 'gnus-widget-press-button
4764 :button-keymap gnus-widget-button-keymap)
4766 (while (setq handle (pop handles))
4767 (gnus-add-text-properties
4770 (insert (format "(%c) %-18s"
4771 (if (equal handle preferred) ?* ? )
4772 (mm-handle-media-type handle)))
4776 (unless ,(not ibegend)
4777 (setq gnus-article-mime-handle-alist
4778 ',gnus-article-mime-handle-alist))
4779 (gnus-mime-display-alternative
4780 ',ihandles ',handle ',begend ,id))
4781 ,@(gnus-local-map-property gnus-mime-button-map)
4782 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4783 face ,gnus-article-button-face
4786 (widget-convert-button 'link from (point)
4787 :action 'gnus-widget-press-button
4788 :button-keymap gnus-widget-button-keymap)
4792 (if (stringp (car preferred))
4793 (gnus-display-mime preferred)
4794 (let ((mail-parse-charset gnus-newsgroup-charset)
4795 (mail-parse-ignored-charsets
4796 (save-excursion (set-buffer gnus-summary-buffer)
4797 gnus-newsgroup-ignored-charsets)))
4798 (mm-display-part preferred)
4802 (narrow-to-region (car begend) (point-max))
4804 nil (length gnus-article-mime-handle-alist)
4805 (gnus-article-mime-total-parts)
4806 (mm-handle-media-type handle))))))
4807 (goto-char (point-max))
4808 (setcdr begend (point-marker)))))
4810 (goto-char point))))
4812 (defconst gnus-article-wash-status-strings
4813 (let ((alist '((cite "c" "Possible hidden citation text"
4814 " " "All citation text visible")
4815 (headers "h" "Hidden headers"
4816 " " "All headers visible.")
4817 (pgp "p" "Encrypted or signed message status hidden"
4818 " " "No hidden encryption nor digital signature status")
4819 (signature "s" "Signature has been hidden"
4820 " " "Signature is visible")
4821 (overstrike "o" "Overstrike (^H) characters applied"
4822 " " "No overstrike characters applied")
4823 (emphasis "e" "/*_Emphasis_*/ characters applied"
4824 " " "No /*_emphasis_*/ characters applied")))
4826 (dolist (entry alist result)
4827 (let ((key (nth 0 entry))
4828 (on (copy-sequence (nth 1 entry)))
4829 (on-help (nth 2 entry))
4830 (off (copy-sequence (nth 3 entry)))
4831 (off-help (nth 4 entry)))
4832 (put-text-property 0 1 'help-echo on-help on)
4833 (put-text-property 0 1 'help-echo off-help off)
4834 (push (list key on off) result))))
4835 "Alist of strings describing wash status in the mode line.
4836 Each entry has the form (KEY ON OF), where the KEY is a symbol
4837 representing the particular washing function, ON is the string to use
4838 in the article mode line when the washing function is active, and OFF
4839 is the string to use when it is inactive.")
4841 (defun gnus-article-wash-status-entry (key value)
4842 (let ((entry (assoc key gnus-article-wash-status-strings)))
4843 (if value (nth 1 entry) (nth 2 entry))))
4845 (defun gnus-article-wash-status ()
4846 "Return a string which display status of article washing."
4848 (set-buffer gnus-article-buffer)
4849 (let ((cite (memq 'cite gnus-article-wash-types))
4850 (headers (memq 'headers gnus-article-wash-types))
4851 (boring (memq 'boring-headers gnus-article-wash-types))
4852 (pgp (memq 'pgp gnus-article-wash-types))
4853 (pem (memq 'pem gnus-article-wash-types))
4854 (signed (memq 'signed gnus-article-wash-types))
4855 (encrypted (memq 'encrypted gnus-article-wash-types))
4856 (signature (memq 'signature gnus-article-wash-types))
4857 (overstrike (memq 'overstrike gnus-article-wash-types))
4858 (emphasis (memq 'emphasis gnus-article-wash-types)))
4860 (gnus-article-wash-status-entry 'cite cite)
4861 (gnus-article-wash-status-entry 'headers (or headers boring))
4862 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4863 (gnus-article-wash-status-entry 'signature signature)
4864 (gnus-article-wash-status-entry 'overstrike overstrike)
4865 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4867 (defun gnus-add-wash-type (type)
4868 "Add a washing of TYPE to the current status."
4869 (add-to-list 'gnus-article-wash-types type))
4871 (defun gnus-delete-wash-type (type)
4872 "Add a washing of TYPE to the current status."
4873 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4875 (defun gnus-add-image (category image)
4876 "Add IMAGE of CATEGORY to the list of displayed images."
4877 (let ((entry (assq category gnus-article-image-alist)))
4879 (setq entry (list category))
4880 (push entry gnus-article-image-alist))
4881 (nconc entry (list image))))
4883 (defun gnus-delete-images (category)
4884 "Delete all images in CATEGORY."
4885 (let ((entry (assq category gnus-article-image-alist)))
4886 (dolist (image (cdr entry))
4887 (gnus-remove-image image category))
4888 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4889 (gnus-delete-wash-type category)))
4891 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4893 (defun gnus-article-maybe-hide-headers ()
4894 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4895 Provided for backwards compatibility."
4896 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4897 (not (save-excursion (set-buffer gnus-summary-buffer)
4898 gnus-have-all-headers)))
4899 (not gnus-inhibit-hiding))
4900 (gnus-article-hide-headers)))
4904 (defun gnus-output-to-file (file-name)
4905 "Append the current article to a file named FILE-NAME."
4906 (let ((artbuf (current-buffer)))
4908 (insert-buffer-substring artbuf)
4909 ;; Append newline at end of the buffer as separator, and then
4911 (goto-char (point-max))
4913 (let ((file-name-coding-system nnmail-pathname-coding-system))
4914 (mm-append-to-file (point-min) (point-max) file-name))
4917 (defun gnus-narrow-to-page (&optional arg)
4918 "Narrow the article buffer to a page.
4919 If given a numerical ARG, move forward ARG pages."
4921 (setq arg (if arg (prefix-numeric-value arg) 0))
4923 (set-buffer gnus-article-buffer)
4924 (goto-char (point-min))
4926 ;; Remove any old next/prev buttons.
4927 (when (gnus-visual-p 'page-marker)
4928 (let ((buffer-read-only nil))
4929 (gnus-remove-text-with-property 'gnus-prev)
4930 (gnus-remove-text-with-property 'gnus-next)))
4933 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4935 (re-search-forward page-delimiter nil 'move arg)))
4936 (goto-char (match-end 0)))
4939 (if (re-search-forward page-delimiter nil 'move)
4942 (when (and (gnus-visual-p 'page-marker)
4943 (not (= (point-min) 1)))
4945 (goto-char (point-min))
4946 (gnus-insert-prev-page-button)))
4947 (when (and (gnus-visual-p 'page-marker)
4948 (< (+ (point-max) 2) (buffer-size)))
4950 (goto-char (point-max))
4951 (gnus-insert-next-page-button)))))
4953 ;; Article mode commands
4955 (defun gnus-article-goto-next-page ()
4956 "Show the next page of the article."
4958 (when (gnus-article-next-page)
4959 (goto-char (point-min))
4960 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4963 (defun gnus-article-goto-prev-page ()
4964 "Show the next page of the article."
4967 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4968 (gnus-article-prev-page nil)))
4970 ;; This is cleaner but currently breaks `gnus-pick-mode':
4972 ;; (defun gnus-article-goto-next-page ()
4973 ;; "Show the next page of the article."
4975 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4976 ;; (gnus-summary-next-page)))
4978 ;; (defun gnus-article-goto-prev-page ()
4979 ;; "Show the next page of the article."
4981 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4982 ;; (gnus-summary-prev-page)))
4984 (defun gnus-article-next-page (&optional lines)
4985 "Show the next page of the current article.
4986 If end of article, return non-nil. Otherwise return nil.
4987 Argument LINES specifies lines to be scrolled up."
4989 (move-to-window-line -1)
4992 (and (pos-visible-in-window-p) ;Not continuation line.
4993 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4994 ;; Nothing in this page.
4995 (if (or (not gnus-page-broken)
4998 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
5000 (when gnus-article-over-scroll
5001 (gnus-article-next-page-1 lines))
5003 (gnus-narrow-to-page 1) ;Go to next page.
5005 ;; More in this page.
5006 (gnus-article-next-page-1 lines)
5009 (defun gnus-article-next-page-1 (lines)
5010 (let ((scroll-in-place nil))
5014 ;; Long lines may cause an end-of-buffer error.
5015 (goto-char (point-max)))))
5016 (move-to-window-line 0))
5018 (defun gnus-article-prev-page (&optional lines)
5019 "Show previous page of current article.
5020 Argument LINES specifies lines to be scrolled down."
5022 (move-to-window-line 0)
5023 (if (and gnus-page-broken
5025 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5027 (gnus-narrow-to-page -1) ;Go to previous page.
5028 (goto-char (point-max))
5030 (let ((scroll-in-place nil))
5034 (beginning-of-buffer
5035 (goto-char (point-min))))
5036 (move-to-window-line 0)))))
5038 (defun gnus-article-only-boring-p ()
5039 "Decide whether there is only boring text remaining in the article.
5040 Something \"interesting\" is a word of at least two letters that does
5041 not have a face in `gnus-article-boring-faces'."
5042 (when (and gnus-article-skip-boring
5043 (boundp 'gnus-article-boring-faces)
5044 (symbol-value 'gnus-article-boring-faces))
5047 (while (re-search-forward "\\b\\w\\w" nil t)
5049 (when (not (gnus-intersection
5050 (gnus-faces-at (point))
5051 (symbol-value 'gnus-article-boring-faces)))
5052 (throw 'only-boring nil)))
5053 (throw 'only-boring t)))))
5055 (defun gnus-article-refer-article ()
5056 "Read article specified by message-id around point."
5059 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5060 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5061 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5062 (let ((msg-id (concat "<" (match-string 0) ">")))
5063 (set-buffer gnus-summary-buffer)
5064 (gnus-summary-refer-article msg-id))
5065 (error "No references around point"))))
5067 (defun gnus-article-show-summary ()
5068 "Reconfigure windows to show summary buffer."
5070 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5071 (error "There is no summary buffer for this article buffer")
5072 (gnus-article-set-globals)
5073 (gnus-configure-windows 'article)
5074 (gnus-summary-goto-subject gnus-current-article)
5075 (gnus-summary-position-point)))
5077 (defun gnus-article-describe-briefly ()
5078 "Describe article mode commands briefly."
5080 (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")))
5082 (defun gnus-article-summary-command ()
5083 "Execute the last keystroke in the summary buffer."
5085 (let ((obuf (current-buffer))
5086 (owin (current-window-configuration))
5088 (switch-to-buffer gnus-article-current-summary 'norecord)
5089 (setq func (lookup-key (current-local-map) (this-command-keys)))
5090 (call-interactively func)
5092 (set-window-configuration owin)
5093 (set-window-point (get-buffer-window (current-buffer)) (point))))
5095 (defun gnus-article-summary-command-nosave ()
5096 "Execute the last keystroke in the summary buffer."
5099 (pop-to-buffer gnus-article-current-summary 'norecord)
5100 (setq func (lookup-key (current-local-map) (this-command-keys)))
5101 (call-interactively func)))
5103 (defun gnus-article-check-buffer ()
5104 "Beep if not in an article buffer."
5105 (unless (equal major-mode 'gnus-article-mode)
5106 (error "Command invoked outside of a Gnus article buffer")))
5108 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5109 "Read a summary buffer key sequence and execute it from the article buffer."
5111 (gnus-article-check-buffer)
5113 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5114 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5115 "=" "^" "\M-^" "|"))
5121 '("n" "Gn" "p" "Gp"))
5124 (set-buffer gnus-article-current-summary)
5125 (let (gnus-pick-mode)
5126 (push (or key last-command-event) unread-command-events)
5127 (setq keys (if (featurep 'xemacs)
5128 (events-to-keys (read-key-sequence nil))
5129 (read-key-sequence nil)))))
5133 (if (or (member keys nosaves)
5134 (member keys nosave-but-article)
5135 (member keys nosave-in-article))
5137 (save-window-excursion
5138 (pop-to-buffer gnus-article-current-summary 'norecord)
5139 ;; We disable the pick minor mode commands.
5140 (let (gnus-pick-mode)
5141 (setq func (lookup-key (current-local-map) keys))))
5145 (unless (member keys nosave-in-article)
5146 (set-buffer gnus-article-current-summary))
5147 (call-interactively func)
5148 (setq new-sum-point (point)))
5149 (when (member keys nosave-but-article)
5150 (pop-to-buffer gnus-article-buffer 'norecord)))
5151 ;; These commands should restore window configuration.
5152 (let ((obuf (current-buffer))
5153 (owin (current-window-configuration))
5155 (summary gnus-article-current-summary)
5156 func in-buffer selected)
5157 (if not-restore-window
5158 (pop-to-buffer summary 'norecord)
5159 (switch-to-buffer summary 'norecord))
5160 (setq in-buffer (current-buffer))
5161 ;; We disable the pick minor mode commands.
5162 (if (and (setq func (let (gnus-pick-mode)
5163 (lookup-key (current-local-map) keys)))
5166 (call-interactively func)
5167 (setq new-sum-point (point))
5168 (when (eq in-buffer (current-buffer))
5169 (setq selected (gnus-summary-select-article))
5171 (unless not-restore-window
5172 (set-window-configuration owin))
5173 (when (eq selected 'old)
5175 (set-window-start (get-buffer-window (current-buffer))
5177 (set-window-point (get-buffer-window (current-buffer))
5179 (let ((win (get-buffer-window gnus-article-current-summary)))
5181 (set-window-point win new-sum-point)))) )
5182 (switch-to-buffer gnus-article-buffer)
5185 (defun gnus-article-describe-key (key)
5186 "Display documentation of the function invoked by KEY. KEY is a string."
5187 (interactive "kDescribe key: ")
5188 (gnus-article-check-buffer)
5189 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5191 (set-buffer gnus-article-current-summary)
5192 (let (gnus-pick-mode)
5193 (if (featurep 'xemacs)
5195 (push (elt key 0) unread-command-events)
5196 (setq key (events-to-keys
5197 (read-key-sequence "Describe key: "))))
5198 (setq unread-command-events
5200 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5201 (string-to-list key)))
5202 (setq key (read-key-sequence "Describe key: "))))
5204 (describe-key key)))
5206 (defun gnus-article-describe-key-briefly (key &optional insert)
5207 "Display documentation of the function invoked by KEY. KEY is a string."
5208 (interactive "kDescribe key: \nP")
5209 (gnus-article-check-buffer)
5210 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5212 (set-buffer gnus-article-current-summary)
5213 (let (gnus-pick-mode)
5214 (if (featurep 'xemacs)
5216 (push (elt key 0) unread-command-events)
5217 (setq key (events-to-keys
5218 (read-key-sequence "Describe key: "))))
5219 (setq unread-command-events
5221 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5222 (string-to-list key)))
5223 (setq key (read-key-sequence "Describe key: "))))
5224 (describe-key-briefly key insert))
5225 (describe-key-briefly key insert)))
5227 (defun gnus-article-reply-with-original (&optional wide)
5228 "Start composing a reply mail to the current message.
5229 The text in the region will be yanked. If the region isn't active,
5230 the entire article will be yanked."
5232 (let ((article (cdr gnus-article-current))
5234 (if (not (gnus-mark-active-p))
5235 (with-current-buffer gnus-summary-buffer
5236 (gnus-summary-reply (list (list article)) wide))
5237 (setq contents (buffer-substring (point) (mark t)))
5238 ;; Deactivate active regions.
5239 (when (and (boundp 'transient-mark-mode)
5240 transient-mark-mode)
5241 (setq mark-active nil))
5242 (with-current-buffer gnus-summary-buffer
5244 (list (list article contents)) wide)))))
5246 (defun gnus-article-followup-with-original ()
5247 "Compose a followup to the current article.
5248 The text in the region will be yanked. If the region isn't active,
5249 the entire article will be yanked."
5251 (let ((article (cdr gnus-article-current))
5253 (if (not (gnus-mark-active-p))
5254 (with-current-buffer gnus-summary-buffer
5255 (gnus-summary-followup (list (list article))))
5256 (setq contents (buffer-substring (point) (mark t)))
5257 ;; Deactivate active regions.
5258 (when (and (boundp 'transient-mark-mode)
5259 transient-mark-mode)
5260 (setq mark-active nil))
5261 (with-current-buffer gnus-summary-buffer
5262 (gnus-summary-followup
5263 (list (list article contents)))))))
5265 (defun gnus-article-hide (&optional arg force)
5266 "Hide all the gruft in the current article.
5267 This means that signatures, cited text and (some) headers will be
5269 If given a prefix, show the hidden text instead."
5270 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5271 (gnus-article-hide-headers arg)
5272 (gnus-article-hide-list-identifiers arg)
5273 (gnus-article-hide-citation-maybe arg force)
5274 (gnus-article-hide-signature arg))
5276 (defun gnus-article-maybe-highlight ()
5277 "Do some article highlighting if article highlighting is requested."
5278 (when (gnus-visual-p 'article-highlight 'highlight)
5279 (gnus-article-highlight-some)))
5281 (defun gnus-check-group-server ()
5282 ;; Make sure the connection to the server is alive.
5283 (unless (gnus-server-opened
5284 (gnus-find-method-for-group gnus-newsgroup-name))
5285 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5286 (gnus-request-group gnus-newsgroup-name t)))
5289 (autoload 'nneething-get-file-name "nneething"))
5291 (defun gnus-request-article-this-buffer (article group)
5292 "Get an article and insert it into this buffer."
5293 (let (do-update-line sparse-header)
5297 (gnus-kill-all-overlays)
5298 (setq group (or group gnus-newsgroup-name))
5300 ;; Using `gnus-request-article' directly will insert the article into
5301 ;; `nntp-server-buffer' - so we'll save some time by not having to
5302 ;; copy it from the server buffer into the article buffer.
5304 ;; We only request an article by message-id when we do not have the
5305 ;; headers for it, so we'll have to get those.
5306 (when (stringp article)
5307 (gnus-read-header article))
5309 ;; If the article number is negative, that means that this article
5310 ;; doesn't belong in this newsgroup (possibly), so we find its
5311 ;; message-id and request it by id instead of number.
5312 (when (and (numberp article)
5314 (get-buffer gnus-summary-buffer)
5315 (gnus-buffer-exists-p gnus-summary-buffer))
5317 (set-buffer gnus-summary-buffer)
5318 (let ((header (gnus-summary-article-header article)))
5321 ((memq article gnus-newsgroup-sparse)
5322 ;; This is a sparse gap article.
5323 (setq do-update-line article)
5324 (setq article (mail-header-id header))
5325 (setq sparse-header (gnus-read-header article))
5326 (setq gnus-newsgroup-sparse
5327 (delq article gnus-newsgroup-sparse)))
5329 ;; It's a real article.
5330 (setq article (mail-header-id header)))
5332 ;; It is an extracted pseudo-article.
5333 (setq article 'pseudo)
5334 (gnus-request-pseudo-article header))))
5336 (let ((method (gnus-find-method-for-group
5337 gnus-newsgroup-name)))
5338 (when (and (eq (car method) 'nneething)
5340 (let ((dir (nneething-get-file-name
5341 (mail-header-id header))))
5342 (when (and (stringp dir)
5343 (file-directory-p dir))
5344 (setq article 'nneething)
5345 (gnus-group-enter-directory dir))))))))
5348 ;; Refuse to select canceled articles.
5349 ((and (numberp article)
5351 (get-buffer gnus-summary-buffer)
5352 (gnus-buffer-exists-p gnus-summary-buffer)
5353 (eq (cdr (save-excursion
5354 (set-buffer gnus-summary-buffer)
5355 (assq article gnus-newsgroup-reads)))
5356 gnus-canceled-mark))
5358 ;; We first check `gnus-original-article-buffer'.
5359 ((and (get-buffer gnus-original-article-buffer)
5362 (set-buffer gnus-original-article-buffer)
5363 (and (equal (car gnus-original-article) group)
5364 (eq (cdr gnus-original-article) article))))
5365 (insert-buffer-substring gnus-original-article-buffer)
5367 ;; Check the backlog.
5368 ((and gnus-keep-backlog
5369 (gnus-backlog-request-article group article (current-buffer)))
5371 ;; Check asynchronous pre-fetch.
5372 ((gnus-async-request-fetched-article group article (current-buffer))
5373 (gnus-async-prefetch-next group article gnus-summary-buffer)
5374 (when (and (numberp article) gnus-keep-backlog)
5375 (gnus-backlog-enter-article group article (current-buffer)))
5378 ((and gnus-use-cache
5380 (gnus-cache-request-article article group))
5382 ;; Check the agent cache.
5383 ((gnus-agent-request-article article group)
5385 ;; Get the article and put into the article buffer.
5386 ((or (stringp article)
5388 (let ((gnus-override-method gnus-override-method)
5389 (methods (and (stringp article)
5390 gnus-refer-article-method))
5391 (backend (car (gnus-find-method-for-group
5392 gnus-newsgroup-name)))
5394 (buffer-read-only nil))
5395 (if (or (not (listp methods))
5396 (and (symbolp (car methods))
5397 (assq (car methods) nnoo-definition-alist)))
5398 (setq methods (list methods)))
5399 (when (and (null gnus-override-method)
5401 (setq gnus-override-method (pop methods)))
5403 (when (eq gnus-override-method 'current)
5404 (setq gnus-override-method
5405 (with-current-buffer gnus-summary-buffer
5406 gnus-current-select-method)))
5408 (gnus-kill-all-overlays)
5409 (let ((gnus-newsgroup-name group))
5410 (gnus-check-group-server))
5412 ((gnus-request-article article group (current-buffer))
5413 (when (numberp article)
5414 (gnus-async-prefetch-next group article
5415 gnus-summary-buffer)
5416 (when gnus-keep-backlog
5417 (gnus-backlog-enter-article
5418 group article (current-buffer))))
5419 (setq result 'article))
5421 (setq gnus-override-method (pop methods)))
5422 ((not (string-match "^400 "
5423 (nnheader-get-report backend)))
5424 ;; If we get 400 server disconnect, reconnect and
5425 ;; retry; otherwise, assume the article has expired.
5426 (setq result 'done))))
5427 (and (eq result 'article) 'article)))
5431 ;; Associate this article with the current summary buffer.
5432 (setq gnus-article-current-summary gnus-summary-buffer)
5434 ;; Take the article from the original article buffer
5435 ;; and place it in the buffer it's supposed to be in.
5436 (when (and (get-buffer gnus-article-buffer)
5437 (equal (buffer-name (current-buffer))
5438 (buffer-name (get-buffer gnus-article-buffer))))
5440 (if (get-buffer gnus-original-article-buffer)
5441 (set-buffer gnus-original-article-buffer)
5442 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5443 (buffer-disable-undo)
5444 (setq major-mode 'gnus-original-article-mode)
5445 (setq buffer-read-only t))
5446 (let (buffer-read-only)
5448 (insert-buffer-substring gnus-article-buffer))
5449 (setq gnus-original-article (cons group article)))
5452 (run-hooks 'gnus-article-decode-hook)
5453 ;; Mark article as decoded or not.
5454 (setq gnus-article-decoded-p gnus-article-decode-hook))
5456 ;; Update sparse articles.
5457 (when (and do-update-line
5458 (or (numberp article)
5460 (let ((buf (current-buffer)))
5461 (set-buffer gnus-summary-buffer)
5462 (gnus-summary-update-article do-update-line sparse-header)
5463 (gnus-summary-goto-subject do-update-line nil t)
5464 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5466 (set-buffer buf))))))
5472 (defcustom gnus-article-edit-mode-hook nil
5473 "Hook run in article edit mode buffers."
5474 :group 'gnus-article-various
5477 (defvar gnus-article-edit-done-function nil)
5479 (defvar gnus-article-edit-mode-map nil)
5480 (defvar gnus-article-edit-mode nil)
5482 ;; Should we be using derived.el for this?
5483 (unless gnus-article-edit-mode-map
5484 (setq gnus-article-edit-mode-map (make-keymap))
5485 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5487 (gnus-define-keys gnus-article-edit-mode-map
5488 "\C-c?" describe-mode
5489 "\C-c\C-c" gnus-article-edit-done
5490 "\C-c\C-k" gnus-article-edit-exit
5491 "\C-c\C-f\C-t" message-goto-to
5492 "\C-c\C-f\C-o" message-goto-from
5493 "\C-c\C-f\C-b" message-goto-bcc
5494 ;;"\C-c\C-f\C-w" message-goto-fcc
5495 "\C-c\C-f\C-c" message-goto-cc
5496 "\C-c\C-f\C-s" message-goto-subject
5497 "\C-c\C-f\C-r" message-goto-reply-to
5498 "\C-c\C-f\C-n" message-goto-newsgroups
5499 "\C-c\C-f\C-d" message-goto-distribution
5500 "\C-c\C-f\C-f" message-goto-followup-to
5501 "\C-c\C-f\C-m" message-goto-mail-followup-to
5502 "\C-c\C-f\C-k" message-goto-keywords
5503 "\C-c\C-f\C-u" message-goto-summary
5504 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5505 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5506 "\C-c\C-b" message-goto-body
5507 "\C-c\C-i" message-goto-signature
5509 "\C-c\C-t" message-insert-to
5510 "\C-c\C-n" message-insert-newsgroups
5511 "\C-c\C-o" message-sort-headers
5512 "\C-c\C-e" message-elide-region
5513 "\C-c\C-v" message-delete-not-region
5514 "\C-c\C-z" message-kill-to-signature
5515 "\M-\r" message-newline-and-reformat
5516 "\C-c\C-a" mml-attach-file
5517 "\C-a" message-beginning-of-line
5519 "\M-;" comment-region)
5521 (gnus-define-keys (gnus-article-edit-wash-map
5522 "\C-c\C-w" gnus-article-edit-mode-map)
5523 "f" gnus-article-edit-full-stops))
5526 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5528 ["Fetch To" message-insert-to t]
5529 ["Fetch Newsgroups" message-insert-newsgroups t]
5531 ["To" message-goto-to t]
5532 ["From" message-goto-from t]
5533 ["Subject" message-goto-subject t]
5534 ["Cc" message-goto-cc t]
5535 ["Reply-To" message-goto-reply-to t]
5536 ["Summary" message-goto-summary t]
5537 ["Keywords" message-goto-keywords t]
5538 ["Newsgroups" message-goto-newsgroups t]
5539 ["Followup-To" message-goto-followup-to t]
5540 ["Mail-Followup-To" message-goto-mail-followup-to t]
5541 ["Distribution" message-goto-distribution t]
5542 ["Body" message-goto-body t]
5543 ["Signature" message-goto-signature t]))
5545 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5546 "Major mode for editing articles.
5547 This is an extended text-mode.
5549 \\{gnus-article-edit-mode-map}"
5550 (make-local-variable 'gnus-article-edit-done-function)
5551 (make-local-variable 'gnus-prev-winconf)
5552 (set (make-local-variable 'font-lock-defaults)
5553 '(message-font-lock-keywords t))
5554 (set (make-local-variable 'mail-header-separator) "")
5555 (set (make-local-variable 'gnus-article-edit-mode) t)
5556 (easy-menu-add message-mode-field-menu message-mode-map)
5558 (setq buffer-read-only nil)
5559 (buffer-enable-undo)
5562 (defun gnus-article-edit (&optional force)
5563 "Edit the current article.
5564 This will have permanent effect only in mail groups.
5565 If FORCE is non-nil, allow editing of articles even in read-only
5568 (when (and (not force)
5569 (gnus-group-read-only-p))
5570 (error "The current newsgroup does not support article editing"))
5571 (gnus-article-date-original)
5572 (gnus-article-edit-article
5574 `(lambda (no-highlight)
5576 (gnus-summary-edit-article-done
5577 ,(or (mail-header-references gnus-current-headers) "")
5578 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5580 (defun gnus-article-edit-article (start-func exit-func)
5581 "Start editing the contents of the current article buffer."
5582 (let ((winconf (current-window-configuration)))
5583 (set-buffer gnus-article-buffer)
5584 (gnus-article-edit-mode)
5585 (funcall start-func)
5586 (set-buffer-modified-p nil)
5587 (gnus-configure-windows 'edit-article)
5588 (setq gnus-article-edit-done-function exit-func)
5589 (setq gnus-prev-winconf winconf)
5590 (gnus-message 6 "C-c C-c to end edits")))
5592 (defun gnus-article-edit-done (&optional arg)
5593 "Update the article edits and exit."
5595 (let ((func gnus-article-edit-done-function)
5596 (buf (current-buffer))
5597 (start (window-start))
5599 (winconf gnus-prev-winconf))
5600 (widen) ;; Widen it in case that users narrowed the buffer.
5603 ;; The cache and backlog have to be flushed somewhat.
5604 (when gnus-keep-backlog
5605 (gnus-backlog-remove-article
5606 (car gnus-article-current) (cdr gnus-article-current)))
5607 ;; Flush original article as well.
5609 (when (get-buffer gnus-original-article-buffer)
5610 (set-buffer gnus-original-article-buffer)
5611 (setq gnus-original-article nil)))
5612 (when gnus-use-cache
5613 (gnus-cache-update-article
5614 (car gnus-article-current) (cdr gnus-article-current)))
5615 ;; We remove all text props from the article buffer.
5616 (kill-all-local-variables)
5617 (gnus-set-text-properties (point-min) (point-max) nil)
5619 (set-window-configuration winconf)
5621 (set-window-start (get-buffer-window buf) start)
5622 (set-window-point (get-buffer-window buf) (point)))
5623 (gnus-summary-show-article))
5625 (defun gnus-article-edit-exit ()
5626 "Exit the article editing without updating."
5628 (when (or (not (buffer-modified-p))
5629 (yes-or-no-p "Article modified; kill anyway? "))
5630 (let ((curbuf (current-buffer))
5632 (window-start (window-start)))
5634 (if (gnus-buffer-live-p gnus-original-article-buffer)
5635 (insert-buffer gnus-original-article-buffer))
5636 (let ((winconf gnus-prev-winconf))
5637 (kill-all-local-variables)
5639 (set-window-configuration winconf)
5640 ;; Tippy-toe some to make sure that point remains where it was.
5641 (save-current-buffer
5643 (set-window-start (get-buffer-window (current-buffer)) window-start)
5645 (gnus-summary-show-article)))
5647 (defun gnus-article-edit-full-stops ()
5648 "Interactively repair spacing at end of sentences."
5651 (goto-char (point-min))
5652 (search-forward-regexp "^$" nil t)
5653 (let ((case-fold-search nil))
5654 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5657 ;;; Article highlights
5660 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5662 ;;; Internal Variables:
5664 (defcustom gnus-button-url-regexp
5665 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5666 "\\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:]]\\)"
5667 "\\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\\)\\)")
5668 "Regular expression that matches URLs."
5669 :group 'gnus-article-buttons
5672 (defcustom gnus-button-valid-fqdn-regexp
5673 message-valid-fqdn-regexp
5674 "Regular expression that matches a valid FQDN."
5675 :group 'gnus-article-buttons
5678 (defcustom gnus-button-man-handler 'manual-entry
5679 "Function to use for displaying man pages.
5680 The function must take at least one argument with a string naming the
5682 :type '(choice (function-item :tag "Man" manual-entry)
5683 (function-item :tag "Woman" woman)
5684 (function :tag "Other"))
5685 :group 'gnus-article-buttons)
5687 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5688 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5689 If the default site is too slow, try to find a CTAN mirror, see
5690 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5691 the variable `gnus-button-handle-ctan'."
5692 :group 'gnus-article-buttons
5693 :link '(custom-manual "(gnus)Group Parameters")
5694 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5695 (const "http://tug.ctan.org/tex-archive/")
5696 (const "http://www.dante.de/CTAN/")
5697 (string :tag "Other")))
5699 (defcustom gnus-button-ctan-handler 'browse-url
5700 "Function to use for displaying CTAN links.
5701 The function must take one argument, the string naming the URL."
5702 :type '(choice (function-item :tag "Browse Url" browse-url)
5703 (function :tag "Other"))
5704 :group 'gnus-article-buttons)
5706 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5707 "Bogus strings removed from CTAN URLs."
5708 :group 'gnus-article-buttons
5709 :type '(choice (const "^/?tex-archive/\\|/")
5710 (regexp :tag "Other")))
5712 (defcustom gnus-button-ctan-directory-regexp
5714 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5715 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5716 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5717 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5719 "Regular expression for ctan directories.
5720 It should match all directories in the top level of `gnus-ctan-url'."
5721 :group 'gnus-article-buttons
5724 (defcustom gnus-button-mid-or-mail-regexp
5725 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5726 gnus-button-valid-fqdn-regexp
5728 "Regular expression that matches a message ID or a mail address."
5729 :group 'gnus-article-buttons
5732 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5733 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5734 Strings like this can be either a message ID or a mail address. If it is one
5735 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5736 message ID or a mail address, respectively. If this variable is set to the
5737 symbol `ask', always query the user what do do. If it is a function, this
5738 function will be called with the string as it's only argument. The function
5739 must return `mid', `mail', `invalid' or `ask'."
5740 :group 'gnus-article-buttons
5741 :type '(choice (function-item :tag "Heuristic function"
5742 gnus-button-mid-or-mail-heuristic)
5747 (defcustom gnus-button-mid-or-mail-heuristic-alist
5748 '((-10.0 . ".+\\$.+@")
5751 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5752 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5753 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5754 (-1.0 . "^[^a-z]+@")
5756 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5757 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5758 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5759 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5762 (-1.0 . "^[0-9][0-9]")
5764 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5765 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5766 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5767 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5769 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5770 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5773 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5775 ;; compensation for TDMA dated mail addresses:
5776 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5778 (-20.0 . "\\.fsf@") ;; Gnus
5781 (-20.0 . "_-_") ;; Subject change in thread
5783 (-20.0 . "\\.ln@") ;; leafnode
5784 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5785 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5787 ;; (5.0 . "") ;; $local_part_len <= 7
5788 (10.0 . "^[^0-9]+@")
5789 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5790 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5793 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5795 (0.5 . "^[A-Z][a-z]")
5796 (0.5 . "^[A-Z][a-z][a-z]")
5797 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5798 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5799 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5801 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5802 address. The REGEXP is processed with `case-fold-search' set to nil."
5803 :group 'gnus-article-buttons
5804 :type '(repeat (cons (number :tag "Rate")
5805 (regexp :tag "Regexp"))))
5807 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5808 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5809 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5810 address, `ask' if unsure and `invalid' if the string is invalid."
5811 (let ((case-fold-search nil)
5812 (list gnus-button-mid-or-mail-heuristic-alist)
5813 (result 0) rate regexp lpartlen elem)
5815 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5816 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5817 ;; Certain special cases...
5820 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5821 "^[0-9]+\.[0-9]+\@compuserve")
5823 (gnus-message 8 "`%s' is a known mail address.")
5824 (setq result 'mail))
5825 (when (string-match "@.*@\\| " mid-or-mail)
5826 (gnus-message 8 "`%s' is invalid.")
5827 (setq result 'invalid))
5828 ;; Nothing more to do, if result is not a number here...
5829 (when (numberp result)
5831 (setq elem (car list)
5835 (when (string-match regexp mid-or-mail)
5836 (setq result (+ result rate))
5838 9 "`%s' matched `%s', rate `%s', result `%s'."
5839 mid-or-mail regexp rate result)))
5840 (when (<= lpartlen 7)
5841 (setq result (+ result 5.0))
5842 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5843 mid-or-mail result))
5844 (when (>= lpartlen 12)
5845 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5847 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5848 ;; Long local part should contain realname if e-mail address,
5849 ;; too many digits: message-id.
5850 ;; $score -= 5.0 + 0.1 * $local_part_len;
5851 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5852 (setq result (+ result rate))
5854 9 "Many digits in `%s', rate `%s', result `%s'."
5855 mid-or-mail rate result))
5856 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5858 ;; Too few vowels [^aeiouy]{4,}.*\@
5859 (setq result (+ result -5.0))
5861 9 "Few vowels in `%s', rate `%s', result `%s'."
5862 mid-or-mail -5.0 result))
5864 (setq result (+ result 5.0))
5866 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5867 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5869 ;; Maybe we should make this a customizable alist: (condition . 'result)
5870 ((< result -10.0) 'mid)
5871 ((> result 10.0) 'mail)
5874 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5875 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5876 (url-mid (concat "news" ":" mid-or-mail))
5877 (url-mailto (concat "mailto" ":" mid-or-mail)))
5878 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5879 (when (fboundp pref)
5881 ;; get rid of surrounding angles...
5883 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5884 (if (or (eq 'mid guessed) (eq 'mail guessed))
5888 (save-window-excursion
5889 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5892 (cond ((eq pref 'mid)
5893 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5894 (gnus-button-handle-news url-mid))
5896 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5897 (gnus-url-mailto url-mailto))
5898 (t (gnus-message 3 "Invalid string.")))))
5900 (defun gnus-button-handle-custom (url)
5901 "Follow a Custom URL."
5902 (customize-apropos (gnus-url-unhex-string url)))
5904 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5906 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5909 (defun gnus-button-handle-describe-function (url)
5910 "Call `describe-function' when pushing the corresponding URL button."
5913 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5915 (defun gnus-button-handle-describe-variable (url)
5916 "Call `describe-variable' when pushing the corresponding URL button."
5919 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5921 (defun gnus-button-handle-symbol (url)
5922 "Display help on variable or function.
5923 Calls `describe-variable' or `describe-function'."
5924 (let ((sym (intern url)))
5926 ((fboundp sym) (describe-function sym))
5927 ((boundp sym) (describe-variable sym))
5928 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5930 (defun gnus-button-handle-describe-key (url)
5931 "Call `describe-key' when pushing the corresponding URL button."
5933 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5934 (keys (ignore-errors (eval `(kbd ,key-string)))))
5937 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5939 (defun gnus-button-handle-apropos (url)
5940 "Call `apropos' when pushing the corresponding URL button."
5941 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5943 (defun gnus-button-handle-apropos-command (url)
5944 "Call `apropos' when pushing the corresponding URL button."
5946 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5948 (defun gnus-button-handle-apropos-variable (url)
5949 "Call `apropos' when pushing the corresponding URL button."
5951 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5952 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5954 (defun gnus-button-handle-apropos-documentation (url)
5955 "Call `apropos' when pushing the corresponding URL button."
5957 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5958 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5960 (defun gnus-button-handle-library (url)
5961 "Call `locate-library' when pushing the corresponding URL button."
5962 (gnus-message 9 "url=`%s'" url)
5963 (let* ((lib (locate-library url))
5964 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5966 (gnus-message 1 "Cannot locale library `%s'." url)
5967 (find-file-read-only file))))
5969 (defun gnus-button-handle-ctan (url)
5970 "Call `browse-url' when pushing a CTAN URL button."
5972 gnus-button-ctan-handler
5975 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5977 (defcustom gnus-button-tex-level 5
5978 "*Integer that says how many TeX-related buttons Gnus will show.
5979 The higher the number, the more buttons will appear and the more false
5980 positives are possible. Note that you can set this variable local to
5981 specific groups. Setting it higher in TeX groups is probably a good idea.
5982 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5983 how to set variables in specific groups."
5984 :group 'gnus-article-buttons
5985 :link '(custom-manual "(gnus)Group Parameters")
5988 (defcustom gnus-button-man-level 5
5989 "*Integer that says how many man-related buttons Gnus will show.
5990 The higher the number, the more buttons will appear and the more false
5991 positives are possible. Note that you can set this variable local to
5992 specific groups. Setting it higher in Unix groups is probably a good idea.
5993 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5994 how to set variables in specific groups."
5995 :group 'gnus-article-buttons
5996 :link '(custom-manual "(gnus)Group Parameters")
5999 (defcustom gnus-button-emacs-level 5
6000 "*Integer that says how many emacs-related buttons Gnus will show.
6001 The higher the number, the more buttons will appear and the more false
6002 positives are possible. Note that you can set this variable local to
6003 specific groups. Setting it higher in Emacs or Gnus related groups is
6004 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6005 `gnus-parameters' on how to set variables in specific groups."
6006 :group 'gnus-article-buttons
6007 :link '(custom-manual "(gnus)Group Parameters")
6010 (defcustom gnus-button-message-level 5
6011 "*Integer that says how many buttons for news or mail messages will appear.
6012 The higher the number, the more buttons will appear and the more false
6013 positives are possible."
6014 ;; mail addresses, MIDs, URLs for news, ...
6015 :group 'gnus-article-buttons
6018 (defcustom gnus-button-browse-level 5
6019 "*Integer that says how many buttons for browsing will appear.
6020 The higher the number, the more buttons will appear and the more false
6021 positives are possible."
6022 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6023 :group 'gnus-article-buttons
6026 (defcustom gnus-button-alist
6027 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6028 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6029 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6030 gnus-button-handle-news 2)
6031 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6032 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6033 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6034 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6035 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6036 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6037 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6038 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6039 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6040 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6041 ("\\bmailto:\\([^ \n\t]+\\)"
6042 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6044 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6045 gnus-button-ctan-directory-regexp
6046 "[^][>)!;:,'\n\t ]+\\)")
6047 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6048 ((concat "\\btex-archive/\\("
6049 gnus-button-ctan-directory-regexp
6050 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6051 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6054 gnus-button-ctan-directory-regexp
6055 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6056 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6058 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6059 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6060 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6061 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6062 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6063 ;; Info links like `C-h i d m CC Mode RET'
6064 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6066 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6067 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6068 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6069 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6070 ;; Emacs help commands
6071 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6072 ;; regexp doesn't match arguments containing ` '.
6073 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6074 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6075 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6076 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6077 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6078 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6079 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6080 ;; The following entries may lead to many false positives so don't enable
6081 ;; them by default (use a high button level):
6082 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6083 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6084 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6085 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6086 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6087 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6088 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6089 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6090 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6091 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6092 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6093 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6094 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6095 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6096 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6097 ;; Unlike the other regexps we really have to require quoting
6098 ;; here to determine where it ends.
6099 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6100 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6101 ("<URL: *\\([^<>]*\\)>"
6102 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6104 (gnus-button-url-regexp
6105 0 (>= gnus-button-browse-level 0) browse-url 0)
6107 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6108 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6109 gnus-button-handle-man 1)
6110 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6111 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6112 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6113 gnus-button-handle-man 1)
6114 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6115 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6116 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6117 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6118 ;; MID or mail: To avoid too many false positives we don't try to catch
6119 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6120 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6121 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6122 ;; so that non-ambiguous entries (see above) match first.
6123 (gnus-button-mid-or-mail-regexp
6124 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6125 "*Alist of regexps matching buttons in article bodies.
6127 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6128 REGEXP: is the string (case insensitive) matching text around the button (can
6129 also be Lisp expression evaluating to a string),
6130 BUTTON: is the number of the regexp grouping actually matching the button,
6131 FORM: is a Lisp expression which must eval to true for the button to
6133 CALLBACK: is the function to call when the user push this button, and each
6134 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6136 CALLBACK can also be a variable, in that case the value of that
6137 variable it the real callback function."
6138 :group 'gnus-article-buttons
6139 :type '(repeat (list (choice regexp variable sexp)
6140 (integer :tag "Button")
6142 (function :tag "Callback")
6145 (integer :tag "Regexp group")))))
6147 (defcustom gnus-header-button-alist
6148 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6149 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6150 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6151 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6152 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6153 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6154 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6155 0 (>= gnus-button-browse-level 0) browse-url 0)
6156 ("^Subject:" gnus-button-url-regexp
6157 0 (>= gnus-button-browse-level 0) browse-url 0)
6158 ("^[^:]+:" gnus-button-url-regexp
6159 0 (>= gnus-button-browse-level 0) browse-url 0)
6160 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6161 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6162 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6163 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6164 "*Alist of headers and regexps to match buttons in article heads.
6166 This alist is very similar to `gnus-button-alist', except that each
6167 alist has an additional HEADER element first in each entry:
6169 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6171 HEADER is a regexp to match a header. For a fuller explanation, see
6172 `gnus-button-alist'."
6173 :group 'gnus-article-buttons
6174 :group 'gnus-article-headers
6175 :type '(repeat (list (regexp :tag "Header")
6176 (choice regexp variable)
6177 (integer :tag "Button")
6179 (function :tag "Callback")
6182 (integer :tag "Regexp group")))))
6184 (defvar gnus-button-regexp nil)
6185 (defvar gnus-button-marker-list nil)
6186 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6188 (defvar gnus-button-last nil)
6189 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6193 (defun gnus-article-push-button (event)
6194 "Check text under the mouse pointer for a callback function.
6195 If the text under the mouse pointer has a `gnus-callback' property,
6196 call it with the value of the `gnus-data' text property."
6198 (set-buffer (window-buffer (posn-window (event-start event))))
6199 (let* ((pos (posn-point (event-start event)))
6200 (data (get-text-property pos 'gnus-data))
6201 (fun (get-text-property pos 'gnus-callback)))
6204 (funcall fun data))))
6206 (defun gnus-article-press-button ()
6207 "Check text at point for a callback function.
6208 If the text at point has a `gnus-callback' property,
6209 call it with the value of the `gnus-data' text property."
6211 (let ((data (get-text-property (point) 'gnus-data))
6212 (fun (get-text-property (point) 'gnus-callback)))
6214 (funcall fun data))))
6216 (defun gnus-article-highlight (&optional force)
6217 "Highlight current article.
6218 This function calls `gnus-article-highlight-headers',
6219 `gnus-article-highlight-citation',
6220 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6221 do the highlighting. See the documentation for those functions."
6222 (interactive (list 'force))
6223 (gnus-article-highlight-headers)
6224 (gnus-article-highlight-citation force)
6225 (gnus-article-highlight-signature)
6226 (gnus-article-add-buttons force)
6227 (gnus-article-add-buttons-to-head))
6229 (defun gnus-article-highlight-some (&optional force)
6230 "Highlight current article.
6231 This function calls `gnus-article-highlight-headers',
6232 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6233 do the highlighting. See the documentation for those functions."
6234 (interactive (list 'force))
6235 (gnus-article-highlight-headers)
6236 (gnus-article-highlight-signature)
6237 (gnus-article-add-buttons))
6239 (defun gnus-article-highlight-headers ()
6240 "Highlight article headers as specified by `gnus-header-face-alist'."
6243 (set-buffer gnus-article-buffer)
6245 (let ((alist gnus-header-face-alist)
6246 (buffer-read-only nil)
6247 (case-fold-search t)
6248 (inhibit-point-motion-hooks t)
6249 entry regexp header-face field-face from hpoints fpoints)
6250 (article-narrow-to-head)
6251 (while (setq entry (pop alist))
6252 (goto-char (point-min))
6253 (setq regexp (concat "^\\("
6254 (if (string-equal "" (nth 0 entry))
6258 header-face (nth 1 entry)
6259 field-face (nth 2 entry))
6260 (while (and (re-search-forward regexp nil t)
6264 (unless (search-forward ":" nil t)
6266 (when (and header-face
6267 (not (memq (point) hpoints)))
6268 (push (point) hpoints)
6269 (gnus-put-text-property from (point) 'face header-face))
6270 (when (and field-face
6271 (not (memq (setq from (point)) fpoints)))
6273 (if (re-search-forward "^[^ \t]" nil t)
6275 (goto-char (point-max)))
6276 (gnus-put-text-property from (point) 'face field-face))))))))
6278 (defun gnus-article-highlight-signature ()
6279 "Highlight the signature in an article.
6280 It does this by highlighting everything after
6281 `gnus-signature-separator' using `gnus-signature-face'."
6284 (set-buffer gnus-article-buffer)
6285 (let ((buffer-read-only nil)
6286 (inhibit-point-motion-hooks t))
6288 (when (and gnus-signature-face
6289 (gnus-article-narrow-to-signature))
6290 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6291 'face gnus-signature-face)
6293 (gnus-article-search-signature)
6294 (let ((start (match-beginning 0))
6295 (end (set-marker (make-marker) (1+ (match-end 0)))))
6296 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6299 (defun gnus-button-in-region-p (b e prop)
6300 "Say whether PROP exists in the region."
6301 (text-property-not-all b e prop nil))
6303 (defun gnus-article-add-buttons (&optional force)
6304 "Find external references in the article and make buttons of them.
6305 \"External references\" are things like Message-IDs and URLs, as
6306 specified by `gnus-button-alist'."
6307 (interactive (list 'force))
6309 (set-buffer gnus-article-buffer)
6310 (let ((buffer-read-only nil)
6311 (inhibit-point-motion-hooks t)
6312 (case-fold-search t)
6313 (alist gnus-button-alist)
6315 ;; Remove all old markers.
6316 (let (marker entry new-list)
6317 (while (setq marker (pop gnus-button-marker-list))
6318 (if (or (< marker (point-min)) (>= marker (point-max)))
6319 (push marker new-list)
6321 (when (setq entry (gnus-button-entry))
6322 (put-text-property (match-beginning (nth 1 entry))
6323 (match-end (nth 1 entry))
6324 'gnus-callback nil))
6325 (set-marker marker nil)))
6326 (setq gnus-button-marker-list new-list))
6327 ;; We skip the headers.
6330 (while (setq entry (pop alist))
6331 (setq regexp (eval (car entry)))
6333 (while (re-search-forward regexp nil t)
6334 (let* ((start (and entry (match-beginning (nth 1 entry))))
6335 (end (and entry (match-end (nth 1 entry))))
6336 (from (match-beginning 0)))
6337 (when (and (or (eq t (nth 2 entry))
6338 (eval (nth 2 entry)))
6339 (not (gnus-button-in-region-p
6340 start end 'gnus-callback)))
6341 ;; That optional form returned non-nil, so we add the
6343 (gnus-article-add-button
6344 start end 'gnus-button-push
6345 (car (push (set-marker (make-marker) from)
6346 gnus-button-marker-list))))))))))
6348 ;; Add buttons to the head of an article.
6349 (defun gnus-article-add-buttons-to-head ()
6350 "Add buttons to the head of the article."
6353 (set-buffer gnus-article-buffer)
6355 (let ((buffer-read-only nil)
6356 (inhibit-point-motion-hooks t)
6357 (case-fold-search t)
6358 (alist gnus-header-button-alist)
6360 (article-narrow-to-head)
6362 ;; Each alist entry.
6363 (setq entry (car alist)
6365 (goto-char (point-min))
6366 (while (re-search-forward (car entry) nil t)
6367 ;; Each header matching the entry.
6368 (setq beg (match-beginning 0))
6369 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6370 (match-beginning 0))
6373 (while (re-search-forward (eval (nth 1 entry)) end t)
6374 ;; Each match within a header.
6375 (let* ((entry (cdr entry))
6376 (start (match-beginning (nth 1 entry)))
6377 (end (match-end (nth 1 entry)))
6378 (form (nth 2 entry)))
6379 (goto-char (match-end 0))
6381 (gnus-article-add-button
6382 start end (nth 3 entry)
6383 (buffer-substring (match-beginning (nth 4 entry))
6384 (match-end (nth 4 entry)))))))
6385 (goto-char end)))))))
6387 ;;; External functions:
6389 (defun gnus-article-add-button (from to fun &optional data)
6390 "Create a button between FROM and TO with callback FUN and data DATA."
6391 (when gnus-article-button-face
6392 (gnus-overlay-put (gnus-make-overlay from to)
6393 'face gnus-article-button-face))
6394 (gnus-add-text-properties
6396 (nconc (and gnus-article-mouse-face
6397 (list gnus-mouse-face-prop gnus-article-mouse-face))
6398 (list 'gnus-callback fun)
6399 (and data (list 'gnus-data data))))
6400 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6401 :button-keymap gnus-widget-button-keymap))
6403 ;;; Internal functions:
6405 (defun gnus-article-set-globals ()
6407 (set-buffer gnus-summary-buffer)
6408 (gnus-set-global-variables)))
6410 (defun gnus-signature-toggle (end)
6412 (set-buffer gnus-article-buffer)
6413 (let ((buffer-read-only nil)
6414 (inhibit-point-motion-hooks t))
6415 (if (text-property-any end (point-max) 'article-type 'signature)
6417 (gnus-delete-wash-type 'signature)
6418 (gnus-remove-text-properties-when
6419 'article-type 'signature end (point-max)
6420 (cons 'article-type (cons 'signature
6421 gnus-hidden-properties))))
6422 (gnus-add-wash-type 'signature)
6423 (gnus-add-text-properties-when
6424 'article-type nil end (point-max)
6425 (cons 'article-type (cons 'signature
6426 gnus-hidden-properties)))))
6427 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6428 (gnus-set-mode-line 'article))))
6430 (defun gnus-button-entry ()
6431 ;; Return the first entry in `gnus-button-alist' matching this place.
6432 (let ((alist gnus-button-alist)
6435 (setq entry (pop alist))
6436 (if (looking-at (eval (car entry)))
6441 (defun gnus-button-push (marker)
6442 ;; Push button starting at MARKER.
6445 (let* ((entry (gnus-button-entry))
6446 (inhibit-point-motion-hooks t)
6448 (args (mapcar (lambda (group)
6449 (let ((string (match-string group)))
6450 (gnus-set-text-properties
6451 0 (length string) nil string)
6458 (fboundp (symbol-value fun)))
6459 (apply (symbol-value fun) args))
6461 (gnus-message 1 "You must define `%S' to use this button"
6462 (cons fun args)))))))
6464 (defun gnus-parse-news-url (url)
6465 (let (scheme server group message-id articles)
6468 (goto-char (point-min))
6469 (when (looking-at "\\([A-Za-z]+\\):")
6470 (setq scheme (match-string 1))
6471 (goto-char (match-end 0)))
6472 (when (looking-at "//\\([^/]+\\)/")
6473 (setq server (match-string 1))
6474 (goto-char (match-end 0)))
6477 ((looking-at "\\(.*@.*\\)")
6478 (setq message-id (match-string 1)))
6479 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6480 (setq group (match-string 1)
6481 articles (split-string (match-string 2) "-")))
6482 ((looking-at "\\([^/]+\\)/?")
6483 (setq group (match-string 1)))
6485 (error "Unknown news URL syntax"))))
6486 (list scheme server group message-id articles)))
6488 (defun gnus-button-handle-news (url)
6490 (destructuring-bind (scheme server group message-id articles)
6491 (gnus-parse-news-url url)
6495 (set-buffer gnus-summary-buffer)
6497 (let ((gnus-refer-article-method (list (list 'nntp server))))
6498 (gnus-summary-refer-article message-id))
6499 (gnus-summary-refer-article message-id))))
6501 (gnus-button-fetch-group url)))))
6503 (defun gnus-button-handle-man (url)
6505 (funcall gnus-button-man-handler url))
6507 (defun gnus-button-handle-info-url (url)
6508 "Fetch an info URL."
6510 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6511 (gnus-info-find-node
6512 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6514 ")" (gnus-url-unhex-string (match-string 2 url)))))
6515 ((string-match "([^)\"]+)[^\"]+" url)
6517 (gnus-replace-in-string
6518 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6519 (gnus-info-find-node url))
6520 (t (error "Can't parse %s" url))))
6522 (defun gnus-button-handle-info-keystrokes (url)
6523 "Call `info' when pushing the corresponding URL button."
6524 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6529 (defun gnus-button-message-id (message-id)
6532 (set-buffer gnus-summary-buffer)
6533 (gnus-summary-refer-article message-id)))
6535 (defun gnus-button-fetch-group (address)
6536 "Fetch GROUP specified by ADDRESS."
6537 (if (not (string-match "[:/]" address))
6538 ;; This is just a simple group url.
6539 (gnus-group-read-ephemeral-group address gnus-select-method)
6542 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6544 (error "Can't parse %s" address)
6545 (gnus-group-read-ephemeral-group
6546 (match-string 4 address)
6547 `(nntp ,(match-string 1 address)
6548 (nntp-address ,(match-string 1 address))
6549 (nntp-port-number ,(if (match-end 3)
6550 (match-string 3 address)
6553 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6555 (defun gnus-url-parse-query-string (query &optional downcase)
6556 (let (retval pairs cur key val)
6557 (setq pairs (split-string query "&"))
6559 (setq cur (car pairs)
6561 (if (not (string-match "=" cur))
6563 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6564 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6566 (setq key (downcase key)))
6567 (setq cur (assoc key retval))
6569 (setcdr cur (cons val (cdr cur)))
6570 (setq retval (cons (list key val) retval)))))
6573 (defun gnus-url-mailto (url)
6574 ;; Send mail to someone
6575 (when (string-match "mailto:/*\\(.*\\)" url)
6576 (setq url (substring url (match-beginning 1) nil)))
6577 (let (to args subject func)
6578 (if (string-match (regexp-quote "?") url)
6579 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6580 args (gnus-url-parse-query-string
6581 (substring url (match-end 0) nil) t))
6582 (setq to (gnus-url-unhex-string url)))
6583 (setq args (cons (list "to" to) args)
6584 subject (cdr-safe (assoc "subject" args)))
6587 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6590 (message-position-on-field (caar args)))
6591 (insert (mapconcat 'identity (cdar args) ", "))
6592 (setq args (cdr args)))
6595 (message-goto-subject))))
6597 (defun gnus-button-embedded-url (address)
6598 "Activate ADDRESS with `browse-url'."
6599 (browse-url (gnus-strip-whitespace address)))
6601 ;;; Next/prev buttons in the article buffer.
6603 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6604 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6606 (defvar gnus-prev-page-map
6607 (let ((map (make-sparse-keymap)))
6608 (unless (>= emacs-major-version 21)
6609 ;; XEmacs doesn't care.
6610 (set-keymap-parent map gnus-article-mode-map))
6611 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6612 (define-key map "\r" 'gnus-button-prev-page)
6615 (defun gnus-insert-prev-page-button ()
6617 (buffer-read-only nil))
6619 gnus-prev-page-line-format nil
6620 `(,@(gnus-local-map-property gnus-prev-page-map)
6622 gnus-callback gnus-article-button-prev-page
6623 article-type annotation))
6624 (widget-convert-button
6626 ;; Exclude a newline.
6629 :action 'gnus-button-prev-page
6630 :button-keymap gnus-prev-page-map)))
6632 (defvar gnus-prev-page-map
6633 (let ((map (make-sparse-keymap)))
6634 (unless (>= emacs-major-version 21)
6635 ;; XEmacs doesn't care.
6636 (set-keymap-parent map gnus-article-mode-map))
6637 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6638 (define-key map "\r" 'gnus-button-prev-page)
6641 (defvar gnus-next-page-map
6642 (let ((map (make-sparse-keymap)))
6643 (unless (>= emacs-major-version 21)
6644 ;; XEmacs doesn't care.
6645 (set-keymap-parent map gnus-article-mode-map))
6646 (define-key map gnus-mouse-2 'gnus-button-next-page)
6647 (define-key map "\r" 'gnus-button-next-page)
6650 (defun gnus-button-next-page (&optional args more-args)
6651 "Go to the next page."
6653 (let ((win (selected-window)))
6654 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6655 (gnus-article-next-page)
6656 (select-window win)))
6658 (defun gnus-button-prev-page (&optional args more-args)
6659 "Go to the prev page."
6661 (let ((win (selected-window)))
6662 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6663 (gnus-article-prev-page)
6664 (select-window win)))
6666 (defun gnus-insert-next-page-button ()
6668 (buffer-read-only nil))
6669 (gnus-eval-format gnus-next-page-line-format nil
6670 `(,@(gnus-local-map-property gnus-next-page-map)
6672 gnus-callback gnus-article-button-next-page
6673 article-type annotation))
6674 (widget-convert-button
6676 ;; Exclude a newline.
6679 :action 'gnus-button-next-page
6680 :button-keymap gnus-next-page-map)))
6682 (defun gnus-article-button-next-page (arg)
6683 "Go to the next page."
6685 (let ((win (selected-window)))
6686 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6687 (gnus-article-next-page)
6688 (select-window win)))
6690 (defun gnus-article-button-prev-page (arg)
6691 "Go to the prev page."
6693 (let ((win (selected-window)))
6694 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6695 (gnus-article-prev-page)
6696 (select-window win)))
6698 (defvar gnus-decode-header-methods
6699 '(mail-decode-encoded-word-region)
6700 "List of methods used to decode headers.
6702 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6703 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6704 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6705 whose names match REGEXP.
6708 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6709 mail-decode-encoded-word-region
6710 (\"chinese\" . rfc1843-decode-region))
6713 (defvar gnus-decode-header-methods-cache nil)
6715 (defun gnus-multi-decode-header (start end)
6716 "Apply the functions from `gnus-encoded-word-methods' that match."
6717 (unless (and gnus-decode-header-methods-cache
6718 (eq gnus-newsgroup-name
6719 (car gnus-decode-header-methods-cache)))
6720 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6723 (nconc gnus-decode-header-methods-cache (list x))
6724 (if (and gnus-newsgroup-name
6725 (string-match (car x) gnus-newsgroup-name))
6726 (nconc gnus-decode-header-methods-cache
6728 gnus-decode-header-methods))
6729 (let ((xlist gnus-decode-header-methods-cache))
6732 (narrow-to-region start end)
6734 (funcall (pop xlist) (point-min) (point-max))))))
6737 ;;; Treatment top-level handling.
6740 (defun gnus-treat-article (condition &optional part-number total-parts type)
6741 (let ((length (- (point-max) (point-min)))
6742 (alist gnus-treatment-function-alist)
6743 (article-goto-body-goes-to-point-min-p t)
6747 (let ((list gnus-article-treat-types))
6749 (when (string-match (pop list) type)
6750 (throw 'found t)))))))
6751 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6753 (gnus-run-hooks 'gnus-part-display-hook)
6754 (dolist (elem alist)
6757 (when (gnus-buffer-live-p gnus-summary-buffer)
6758 (set-buffer gnus-summary-buffer))
6759 (symbol-value (car elem))))
6760 (when (and (or (consp val)
6762 (gnus-treat-predicate val)
6763 (or (not (get (car elem) 'highlight))
6766 (funcall (cadr elem)))))))
6768 ;; Dynamic variables.
6770 (defvar part-number)
6771 (defvar total-parts)
6776 (defun gnus-treat-predicate (val)
6783 (stringp (car val)))
6784 (apply 'gnus-or (mapcar `(lambda (s)
6785 (string-match s ,(or gnus-newsgroup-name "")))
6788 (let ((pred (pop val)))
6791 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6793 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6795 (not (gnus-treat-predicate (car val))))
6797 (equal (car val) type))
6799 (error "%S is not a valid predicate" pred)))))
6805 (eq part-number total-parts))
6809 (error "%S is not a valid value" val))))
6811 (defun gnus-article-encrypt-body (protocol &optional n)
6812 "Encrypt the article body."
6815 (or gnus-article-encrypt-protocol
6816 (completing-read "Encrypt protocol: "
6817 gnus-article-encrypt-protocol-alist
6819 current-prefix-arg))
6820 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6822 (error (format "Can't find the encrypt protocol %s" protocol)))
6823 (if (member gnus-newsgroup-name '("nndraft:delayed"
6826 (error "Can't encrypt the article in group %s"
6827 gnus-newsgroup-name))
6828 (gnus-summary-iterate n
6830 (set-buffer gnus-summary-buffer)
6831 (let ((mail-parse-charset gnus-newsgroup-charset)
6832 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6833 (summary-buffer gnus-summary-buffer)
6835 (gnus-set-global-variables)
6836 (when (gnus-group-read-only-p)
6837 (error "The current newsgroup does not support article encrypt"))
6838 (gnus-summary-show-article t)
6840 (or (mail-header-references gnus-current-headers) ""))
6841 (set-buffer gnus-article-buffer)
6842 (let* ((buffer-read-only nil)
6844 (mapcar (lambda (field)
6845 (and (save-restriction
6846 (message-narrow-to-head)
6847 (goto-char (point-min))
6848 (search-forward field nil t))
6850 (message-narrow-to-field)
6852 (delete-region (point-min) (point-max))
6854 '("Content-Type:" "Content-Transfer-Encoding:"
6855 "Content-Disposition:"))))
6856 (message-narrow-to-head)
6857 (message-remove-header "MIME-Version")
6858 (goto-char (point-max))
6859 (setq point (point))
6860 (insert (apply 'concat headers))
6862 (narrow-to-region point (point-max))
6863 (let ((message-options message-options))
6864 (message-options-set 'message-sender user-mail-address)
6865 (message-options-set 'message-recipients user-mail-address)
6866 (message-options-set 'message-sign-encrypt 'not)
6868 (goto-char (point-min))
6869 (insert "MIME-Version: 1.0\n")
6871 (gnus-summary-edit-article-done
6872 references nil summary-buffer t))
6873 (when gnus-keep-backlog
6874 (gnus-backlog-remove-article
6875 (car gnus-article-current) (cdr gnus-article-current)))
6877 (when (get-buffer gnus-original-article-buffer)
6878 (set-buffer gnus-original-article-buffer)
6879 (setq gnus-original-article nil)))
6880 (when gnus-use-cache
6881 (gnus-cache-update-article
6882 (car gnus-article-current) (cdr gnus-article-current))))))))
6884 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6885 "The following specs can be used:
6886 %t The security MIME type
6889 %D Details if button is pressed")
6891 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6892 "The following specs can be used:
6893 %t The security MIME type
6896 %D Details if button is pressed")
6898 (defvar gnus-mime-security-button-line-format-alist
6899 '((?t gnus-tmp-type ?s)
6900 (?i gnus-tmp-info ?s)
6901 (?d gnus-tmp-details ?s)
6902 (?D gnus-tmp-pressed-details ?s)))
6904 (defvar gnus-mime-security-button-map
6905 (let ((map (make-sparse-keymap)))
6906 (unless (>= (string-to-number emacs-version) 21)
6907 (set-keymap-parent map gnus-article-mode-map))
6908 (define-key map gnus-mouse-2 'gnus-article-push-button)
6909 (define-key map "\r" 'gnus-article-press-button)
6912 (defvar gnus-mime-security-details-buffer nil)
6914 (defvar gnus-mime-security-button-pressed nil)
6916 (defvar gnus-mime-security-show-details-inline t
6917 "If non-nil, show details in the article buffer.")
6919 (defun gnus-mime-security-verify-or-decrypt (handle)
6920 (mm-remove-parts (cdr handle))
6921 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6922 point buffer-read-only)
6924 (goto-char (car region)))
6926 (narrow-to-region (point) (point))
6927 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6928 (let* ((mm-verify-option 'known)
6929 (mm-decrypt-option 'known)
6930 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6931 (unless (eq nparts (cdr handle))
6932 (mm-destroy-parts (cdr handle))
6933 (setcdr handle nparts))))
6934 (setq point (point))
6935 (gnus-mime-display-security handle)
6936 (goto-char (point-max)))
6938 (delete-region (point) (cdr region))
6939 (set-marker (car region) nil)
6940 (set-marker (cdr region) nil))
6943 (defun gnus-mime-security-show-details (handle)
6944 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6946 (gnus-message 5 "No details.")
6947 (if gnus-mime-security-show-details-inline
6948 (let ((gnus-mime-security-button-pressed
6949 (not (get-text-property (point) 'gnus-mime-details)))
6950 (gnus-mime-security-button-line-format
6951 (get-text-property (point) 'gnus-line-format))
6954 (while (eq (get-text-property (point) 'gnus-line-format)
6955 gnus-mime-security-button-line-format)
6959 (narrow-to-region (point) (point))
6960 (gnus-insert-mime-security-button handle))
6961 (delete-region (point)
6962 (or (text-property-not-all
6965 gnus-mime-security-button-line-format)
6968 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6969 (with-current-buffer gnus-mime-security-details-buffer
6972 (setq gnus-mime-security-details-buffer
6973 (gnus-get-buffer-create "*MIME Security Details*")))
6974 (with-current-buffer gnus-mime-security-details-buffer
6976 (goto-char (point-min)))
6977 (pop-to-buffer gnus-mime-security-details-buffer)))))
6979 (defun gnus-mime-security-press-button (handle)
6981 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6982 (gnus-mime-security-show-details handle)
6983 (gnus-mime-security-verify-or-decrypt handle))))
6985 (defun gnus-insert-mime-security-button (handle &optional displayed)
6986 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6989 (or (nth 2 (assoc protocol mm-verify-function-alist))
6990 (nth 2 (assoc protocol mm-decrypt-function-alist))
6992 (if (equal (car handle) "multipart/signed")
6993 " Signed" " Encrypted")
6996 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6999 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7000 gnus-tmp-pressed-details
7002 (setq gnus-tmp-details
7003 (if gnus-tmp-details
7004 (concat "\n" gnus-tmp-details)
7006 (setq gnus-tmp-pressed-details
7007 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7012 gnus-mime-security-button-line-format
7013 gnus-mime-security-button-line-format-alist
7014 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7015 gnus-callback gnus-mime-security-press-button
7016 gnus-line-format ,gnus-mime-security-button-line-format
7017 gnus-mime-details ,gnus-mime-security-button-pressed
7018 article-type annotation
7021 ;; Exclude a newline.
7024 (widget-convert-button
7027 :action 'gnus-widget-press-button
7028 :button-keymap gnus-mime-security-button-map
7030 (lambda (widget/window &optional overlay pos)
7031 ;; Needed to properly clear the message due to a bug in
7032 ;; wid-edit (XEmacs only).
7033 (when (boundp 'help-echo-owns-message)
7034 (setq help-echo-owns-message t))
7037 (aref gnus-mouse-2 0))))))
7039 (defun gnus-mime-display-security (handle)
7041 (narrow-to-region (point) (point))
7042 (unless (gnus-unbuttonized-mime-type-p (car handle))
7043 (gnus-insert-mime-security-button handle))
7044 (gnus-mime-display-mixed (cdr handle))
7047 (unless (gnus-unbuttonized-mime-type-p (car handle))
7048 (let ((gnus-mime-security-button-line-format
7049 gnus-mime-security-button-end-line-format))
7050 (gnus-insert-mime-security-button handle)))
7051 (mm-set-handle-multipart-parameter
7053 (cons (set-marker (make-marker) (point-min))
7054 (set-marker (make-marker) (point-max))))))
7060 (run-hooks 'gnus-art-load-hook)
7062 ;;; gnus-art.el ends here