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)
49 (autoload 'ansi-color-apply-on-region "ansi-color")
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)The Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
218 :group 'gnus-article-hiding)
220 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
221 "Regexp matching signature separator.
222 This can also be a list of regexps. In that case, it will be checked
223 from head to tail looking for a separator. Searches will be done from
224 the end of the buffer."
225 :type '(repeat string)
226 :group 'gnus-article-signature)
228 (defcustom gnus-signature-limit nil
229 "Provide a limit to what is considered a signature.
230 If it is a number, no signature may not be longer (in characters) than
231 that number. If it is a floating point number, no signature may be
232 longer (in lines) than that number. If it is a function, the function
233 will be called without any parameters, and if it returns nil, there is
234 no signature in the buffer. If it is a string, it will be used as a
235 regexp. If it matches, the text in question is not a signature."
236 :type '(choice (integer :value 200)
238 (function :value fun)
239 (regexp :value ".*"))
240 :group 'gnus-article-signature)
242 (defcustom gnus-hidden-properties '(invisible t intangible t)
243 "Property list to use for hiding text."
245 :group 'gnus-article-hiding)
247 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
248 ;; frames in a session.
249 (defcustom gnus-article-x-face-command
250 (if (featurep 'xemacs)
251 (if (or (gnus-image-type-available-p 'xface)
252 (gnus-image-type-available-p 'pbm))
253 'gnus-display-x-face-in-from
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
255 (if (gnus-image-type-available-p 'pbm)
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
259 "*String or function to be executed to display an X-Face header.
260 If it is a string, the command will be executed in a sub-shell
261 asynchronously. The compressed face will be piped to this command."
262 :type `(choice string
263 (function-item gnus-display-x-face-in-from)
267 :group 'gnus-article-washing)
269 (defcustom gnus-article-x-face-too-ugly nil
270 "Regexp matching posters whose face shouldn't be shown automatically."
271 :type '(choice regexp (const nil))
272 :group 'gnus-article-washing)
274 (defcustom gnus-article-banner-alist nil
275 "Banner alist for stripping.
277 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
279 :type '(repeat (cons symbol regexp))
280 :group 'gnus-article-washing)
282 (gnus-define-group-parameter
285 "Alist of regexps (to match group names) and banner."
286 :variable-group gnus-article-washing
288 '(choice :tag "Banner"
290 (const :tag "Remove signature" signature)
291 (symbol :tag "Item in `gnus-article-banner-alist'" none)
293 (const :tag "None" nil))
295 "If non-nil, specify how to remove `banners' from articles.
297 Symbol `signature' means to remove signatures delimited by
298 `gnus-signature-separator'. Any other symbol is used to look up a
299 regular expression to match the banner in `gnus-article-banner-alist'.
300 A string is used as a regular expression to match the banner
303 (defcustom gnus-article-address-banner-alist nil
304 "Alist of mail addresses and banners.
305 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
306 to match a mail address in the From: header, BANNER is one of a symbol
307 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
308 If ADDRESS matches author's mail address, it will remove things like
309 advertisements. For example:
311 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
315 (regexp :tag "Address")
316 (choice :tag "Banner" :value nil
317 (const :tag "Remove signature" signature)
318 (symbol :tag "Item in `gnus-article-banner-alist'" none)
320 (const :tag "None" nil))))
321 :group 'gnus-article-washing)
323 (defcustom gnus-emphasis-alist
325 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
330 ("_/" "/_" underline-italic)
331 ("_\\*" "\\*_" underline-bold)
332 ("\\*/" "/\\*" bold-italic)
333 ("_\\*/" "/\\*_" underline-bold-italic))))
337 (format format (car spec) (cadr spec))
338 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
340 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
341 2 3 gnus-emphasis-strikethru)
342 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
343 2 3 gnus-emphasis-underline)))
344 "*Alist that says how to fontify certain phrases.
345 Each item looks like this:
347 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
349 The first element is a regular expression to be matched. The second
350 is a number that says what regular expression grouping used to find
351 the entire emphasized word. The third is a number that says what
352 regexp grouping should be displayed and highlighted. The fourth
353 is the face used for highlighting."
354 :type '(repeat (list :value ("" 0 0 default)
356 (integer :tag "Match group")
357 (integer :tag "Emphasize group")
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
362 "A regexp to describe whitespace which should not be emphasized.
363 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
364 The former avoids underlining of leading and trailing whitespace,
365 and the latter avoids underlining any whitespace at all."
367 :group 'gnus-article-emphasis
370 (defface gnus-emphasis-bold '((t (:bold t)))
371 "Face used for displaying strong emphasized text (*word*)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-italic '((t (:italic t)))
375 "Face used for displaying italic emphasized text (/word/)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline '((t (:underline t)))
379 "Face used for displaying underlined emphasized text (_word_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
383 "Face used for displaying underlined bold emphasized text (_*word*_)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
387 "Face used for displaying underlined italic emphasized text (_/word/_)."
388 :group 'gnus-article-emphasis)
390 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
391 "Face used for displaying bold italic emphasized text (/*word*/)."
392 :group 'gnus-article-emphasis)
394 (defface gnus-emphasis-underline-bold-italic
395 '((t (:bold t :italic t :underline t)))
396 "Face used for displaying underlined bold italic emphasized text.
397 Example: (_/*word*/_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
401 '((t (:strikethru t)))
402 '((t (:strike-through t))))
403 "Face used for displaying strike-through text (-word-)."
404 :group 'gnus-article-emphasis)
406 (defface gnus-emphasis-highlight-words
407 '((t (:background "black" :foreground "yellow")))
408 "Face used for displaying highlighted words."
409 :group 'gnus-article-emphasis)
411 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
412 "Format for display of Date headers in article bodies.
413 See `format-time-string' for the possible values.
415 The variable can also be function, which should return a complete Date
416 header. The function is called with one argument, the time, which can
417 be fed to `format-time-string'."
418 :type '(choice string symbol)
419 :link '(custom-manual "(gnus)Article Date")
420 :group 'gnus-article-washing)
423 (autoload 'mail-extract-address-components "mail-extr"))
425 (defcustom gnus-save-all-headers t
426 "*If non-nil, don't remove any headers before saving."
427 :group 'gnus-article-saving
430 (defcustom gnus-prompt-before-saving 'always
431 "*This variable says how much prompting is to be done when saving articles.
432 If it is nil, no prompting will be done, and the articles will be
433 saved to the default files. If this variable is `always', each and
434 every article that is saved will be preceded by a prompt, even when
435 saving large batches of articles. If this variable is neither nil not
436 `always', there the user will be prompted once for a file name for
437 each invocation of the saving commands."
438 :group 'gnus-article-saving
439 :type '(choice (item always)
440 (item :tag "never" nil)
441 (sexp :tag "once" :format "%t\n" :value t)))
443 (defcustom gnus-saved-headers gnus-visible-headers
444 "Headers to keep if `gnus-save-all-headers' is nil.
445 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
446 If that variable is nil, however, all headers that match this regexp
447 will be kept while the rest will be deleted before saving."
448 :group 'gnus-article-saving
451 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
452 "A function to save articles in your favourite format.
453 The function must be interactively callable (in other words, it must
454 be an Emacs command).
456 Gnus provides the following functions:
458 * gnus-summary-save-in-rmail (Rmail format)
459 * gnus-summary-save-in-mail (Unix mail format)
460 * gnus-summary-save-in-folder (MH folder)
461 * gnus-summary-save-in-file (article format)
462 * gnus-summary-save-body-in-file (article body)
463 * gnus-summary-save-in-vm (use VM's folder format)
464 * gnus-summary-write-to-file (article format -- overwrite)."
465 :group 'gnus-article-saving
466 :type '(radio (function-item gnus-summary-save-in-rmail)
467 (function-item gnus-summary-save-in-mail)
468 (function-item gnus-summary-save-in-folder)
469 (function-item gnus-summary-save-in-file)
470 (function-item gnus-summary-save-body-in-file)
471 (function-item gnus-summary-save-in-vm)
472 (function-item gnus-summary-write-to-file)))
474 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
475 "A function generating a file name to save articles in Rmail format.
476 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
477 :group 'gnus-article-saving
480 (defcustom gnus-mail-save-name 'gnus-plain-save-name
481 "A function generating a file name to save articles in Unix mail format.
482 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
483 :group 'gnus-article-saving
486 (defcustom gnus-folder-save-name 'gnus-folder-save-name
487 "A function generating a file name to save articles in MH folder.
488 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
489 :group 'gnus-article-saving
492 (defcustom gnus-file-save-name 'gnus-numeric-save-name
493 "A function generating a file name to save articles in article format.
494 The function is called with NEWSGROUP, HEADERS, and optional
496 :group 'gnus-article-saving
499 (defcustom gnus-split-methods
500 '((gnus-article-archive-name)
501 (gnus-article-nndoc-name))
502 "*Variable used to suggest where articles are to be saved.
503 For instance, if you would like to save articles related to Gnus in
504 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
505 you could set this variable to something like:
507 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
508 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
510 This variable is an alist where the where the key is the match and the
511 value is a list of possible files to save in if the match is non-nil.
513 If the match is a string, it is used as a regexp match on the
514 article. If the match is a symbol, that symbol will be funcalled
515 from the buffer of the article to be saved with the newsgroup as the
516 parameter. If it is a list, it will be evaled in the same buffer.
518 If this form or function returns a string, this string will be used as
519 a possible file name; and if it returns a non-nil list, that list will
520 be used as possible file names."
521 :group 'gnus-article-saving
522 :type '(repeat (choice (list :value (fun) function)
523 (cons :value ("" "") regexp (repeat string))
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (make-obsolete-variable 'gnus-article-hide-pgp-hook
567 "This variable is obsolete in Gnus 5.10.")
569 (defcustom gnus-article-button-face 'bold
570 "Face used for highlighting buttons in the article buffer.
572 An article button is a piece of text that you can activate by pressing
573 `RET' or `mouse-2' above it."
575 :group 'gnus-article-buttons)
577 (defcustom gnus-article-mouse-face 'highlight
578 "Face used for mouse highlighting in the article buffer.
580 Article buttons will be displayed in this face when the cursor is
583 :group 'gnus-article-buttons)
585 (defcustom gnus-signature-face 'gnus-signature-face
586 "Face used for highlighting a signature in the article buffer.
587 Obsolete; use the face `gnus-signature-face' for customizations instead."
589 :group 'gnus-article-highlight
590 :group 'gnus-article-signature)
592 (defface gnus-signature-face
595 "Face used for highlighting a signature in the article buffer."
596 :group 'gnus-article-highlight
597 :group 'gnus-article-signature)
599 (defface gnus-header-from-face
602 (:foreground "spring green"))
605 (:foreground "red3"))
608 "Face used for displaying from headers."
609 :group 'gnus-article-headers
610 :group 'gnus-article-highlight)
612 (defface gnus-header-subject-face
615 (:foreground "SeaGreen3"))
618 (:foreground "red4"))
620 (:bold t :italic t)))
621 "Face used for displaying subject headers."
622 :group 'gnus-article-headers
623 :group 'gnus-article-highlight)
625 (defface gnus-header-newsgroups-face
628 (:foreground "yellow" :italic t))
631 (:foreground "MidnightBlue" :italic t))
634 "Face used for displaying newsgroups headers.
635 In the default setup this face is only used for crossposted
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
661 (:italic t))) "Face used for displaying header content."
662 :group 'gnus-article-headers
663 :group 'gnus-article-highlight)
665 (defcustom gnus-header-face-alist
666 '(("From" nil gnus-header-from-face)
667 ("Subject" nil gnus-header-subject-face)
668 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
669 ("" gnus-header-name-face gnus-header-content-face))
670 "*Controls highlighting of article headers.
672 An alist of the form (HEADER NAME CONTENT).
674 HEADER is a regular expression which should match the name of a
675 header and NAME and CONTENT are either face names or nil.
677 The name of each header field will be displayed using the face
678 specified by the first element in the list where HEADER matches
679 the header name and NAME is non-nil. Similarly, the content will
680 be displayed by the first non-nil matching CONTENT face."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight
683 :type '(repeat (list (regexp :tag "Header")
685 (item :tag "skip" nil)
686 (face :value default))
687 (choice :tag "Content"
688 (item :tag "skip" nil)
689 (face :value default)))))
691 (defcustom gnus-article-decode-hook
692 '(article-decode-charset article-decode-encoded-words
693 article-decode-group-name article-decode-idna-rhs)
694 "*Hook run to decode charsets in articles."
695 :group 'gnus-article-headers
698 (defcustom gnus-display-mime-function 'gnus-display-mime
699 "Function to display MIME articles."
700 :group 'gnus-article-mime
703 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
704 "Function used to decode headers.")
706 (defvar gnus-article-dumbquotes-map
726 "Table for MS-to-Latin1 translation.")
728 (defcustom gnus-ignored-mime-types nil
729 "List of MIME types that should be ignored by Gnus."
731 :group 'gnus-article-mime
732 :type '(repeat regexp))
734 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
735 "List of MIME types that should not be given buttons when rendered inline.
736 See also `gnus-buttonized-mime-types' which may override this variable.
737 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
739 :group 'gnus-article-mime
740 :type '(repeat regexp))
742 (defcustom gnus-buttonized-mime-types nil
743 "List of MIME types that should be given buttons when rendered inline.
744 If set, this variable overrides `gnus-unbuttonized-mime-types'.
745 To see e.g. security buttons you could set this to
746 `(\"multipart/signed\")'.
747 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
749 :group 'gnus-article-mime
750 :type '(repeat regexp))
752 (defcustom gnus-inhibit-mime-unbuttonizing nil
753 "If non-nil, all MIME parts get buttons.
754 When nil (the default value), then some MIME parts do not get buttons,
755 as described by the variables `gnus-buttonized-mime-types' and
756 `gnus-unbuttonized-mime-types'."
760 (defcustom gnus-body-boundary-delimiter "_"
761 "String used to delimit header and body.
762 This variable is used by `gnus-article-treat-body-boundary' which can
763 be controlled by `gnus-treat-body-boundary'."
764 :group 'gnus-article-various
765 :type '(choice (item :tag "None" :value nil)
768 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
769 "Defines the location of the faces database.
770 For information on obtaining this database of pretty pictures, please
771 see http://www.cs.indiana.edu/picons/ftp/index.html"
772 :type '(repeat directory)
773 :link '(url-link :tag "download"
774 "http://www.cs.indiana.edu/picons/ftp/index.html")
775 :link '(custom-manual "(gnus)Picons")
778 (defun gnus-picons-installed-p ()
779 "Say whether picons are installed on your machine."
780 (let ((installed nil))
781 (dolist (database gnus-picon-databases)
782 (when (file-exists-p database)
786 (defcustom gnus-article-mime-part-function nil
787 "Function called with a MIME handle as the argument.
788 This is meant for people who want to do something automatic based
789 on parts -- for instance, adding Vcard info to a database."
790 :group 'gnus-article-mime
793 (defcustom gnus-mime-multipart-functions nil
794 "An alist of MIME types to functions to display them."
796 :group 'gnus-article-mime
799 (defcustom gnus-article-date-lapsed-new-header nil
800 "Whether the X-Sent and Date headers can coexist.
801 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
802 either replace the old \"Date:\" header (if this variable is nil), or
803 be added below it (otherwise)."
805 :group 'gnus-article-headers
808 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
809 "Function called with a MIME handle as the argument.
810 This is meant for people who want to view first matched part.
811 For `undisplayed-alternative' (default), the first undisplayed
812 part or alternative part is used. For `undisplayed', the first
813 undisplayed part is used. For a function, the first part which
814 the function return t is used. For nil, the first part is
817 :group 'gnus-article-mime
819 (item :tag "first" :value nil)
820 (item :tag "undisplayed" :value undisplayed)
821 (item :tag "undisplayed or alternative"
822 :value undisplayed-alternative)
825 (defcustom gnus-mime-action-alist
826 '(("save to file" . gnus-mime-save-part)
827 ("save and strip" . gnus-mime-save-part-and-strip)
828 ("delete part" . gnus-mime-delete-part)
829 ("display as text" . gnus-mime-inline-part)
830 ("view the part" . gnus-mime-view-part)
831 ("pipe to command" . gnus-mime-pipe-part)
832 ("toggle display" . gnus-article-press-button)
833 ("toggle display" . gnus-article-view-part-as-charset)
834 ("view as type" . gnus-mime-view-part-as-type)
835 ("view internally" . gnus-mime-view-part-internally)
836 ("view externally" . gnus-mime-view-part-externally))
837 "An alist of actions that run on the MIME attachment."
838 :group 'gnus-article-mime
839 :type '(repeat (cons (string :tag "name")
843 ;;; The treatment variables
846 (defvar gnus-part-display-hook nil
847 "Hook called on parts that are to receive treatment.")
849 (defvar gnus-article-treat-custom
850 '(choice (const :tag "Off" nil)
852 (const :tag "Header" head)
853 (const :tag "Last" last)
854 (integer :tag "Less")
855 (repeat :tag "Groups" regexp)
856 (sexp :tag "Predicate")))
858 (defvar gnus-article-treat-head-custom
859 '(choice (const :tag "Off" nil)
860 (const :tag "Header" head)))
862 (defvar gnus-article-treat-types '("text/plain")
865 (defvar gnus-inhibit-treatment nil
866 "Whether to inhibit treatment.")
868 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
869 "Highlight the signature.
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles'."
872 :group 'gnus-article-treat
873 :link '(custom-manual "(gnus)Customizing Articles")
874 :type gnus-article-treat-custom)
875 (put 'gnus-treat-highlight-signature 'highlight t)
877 (defcustom gnus-treat-buttonize 100000
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles'."
881 :group 'gnus-article-treat
882 :link '(custom-manual "(gnus)Customizing Articles")
883 :type gnus-article-treat-custom)
884 (put 'gnus-treat-buttonize 'highlight t)
886 (defcustom gnus-treat-buttonize-head 'head
887 "Add buttons to the head.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See Info node `(gnus)Customizing Articles' for details."
890 :group 'gnus-article-treat
891 :link '(custom-manual "(gnus)Customizing Articles")
892 :type gnus-article-treat-head-custom)
893 (put 'gnus-treat-buttonize-head 'highlight t)
895 (defcustom gnus-treat-emphasize
896 (and (or window-system
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-emphasize 'highlight t)
907 (defcustom gnus-treat-strip-cr nil
908 "Remove carriage returns.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :link '(custom-manual "(gnus)Customizing Articles")
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-unsplit-urls nil
916 "Remove newlines from within URLs.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-leading-whitespace nil
924 "Remove leading whitespace in headers.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-hide-headers 'head
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-boring-headers nil
940 "Hide boring headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-signature nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-fill-article nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-hide-citation nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-hide-citation-maybe nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-list-identifiers 'head
980 "Strip list identifiers from `gnus-list-identifiers`.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (make-obsolete-variable 'gnus-treat-strip-pgp
989 "This option is obsolete in Gnus 5.10.")
991 (defcustom gnus-treat-strip-pem nil
992 "Strip PEM signatures.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-strip-banner t
1000 "Strip banners from articles.
1001 The banner to be stripped is specified in the `banner' group parameter.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-highlight-headers 'head
1009 "Highlight the headers.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-highlight-headers 'highlight t)
1017 (defcustom gnus-treat-highlight-citation t
1018 "Highlight cited text.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-highlight-citation 'highlight t)
1026 (defcustom gnus-treat-date-ut nil
1027 "Display the Date in UT (GMT).
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-local nil
1035 "Display the Date in the local timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-lapsed nil
1051 "Display the Date header in a way that says how much time has elapsed.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-original nil
1059 "Display the date in the original timezone.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-iso8601 nil
1067 "Display the date in the ISO8601 format.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-user-defined nil
1076 "Display the date in a user-defined format.
1077 The format is defined by the `gnus-article-time-format' variable.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-strip-headers-in-body t
1085 "Strip the X-No-Archive header line from the beginning of the body.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-trailing-blank-lines nil
1094 "Strip trailing blank lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-leading-blank-lines nil
1102 "Strip leading blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-multiple-blank-lines nil
1110 "Strip multiple blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-unfold-headers 'head
1118 "Unfold folded header lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fold-headers nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-newsgroups 'head
1134 "Fold the Newsgroups and Followup-To headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-overstrike t
1142 "Treat overstrike highlighting.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1148 (put 'gnus-treat-overstrike 'highlight t)
1150 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1151 "Treat ANSI SGR control sequences.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (make-obsolete-variable 'gnus-treat-display-xface
1159 'gnus-treat-display-x-face)
1161 (defcustom gnus-treat-display-x-face
1162 (and (not noninteractive)
1163 (or (and (fboundp 'image-type-available-p)
1164 (image-type-available-p 'xbm)
1165 (string-match "^0x" (shell-command-to-string "uncompface"))
1166 (executable-find "icontopbm"))
1167 (and (featurep 'xemacs)
1170 "Display X-Face headers.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' and Info node
1173 `(gnus)X-Face' for details."
1174 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :link '(custom-manual "(gnus)X-Face")
1178 :type gnus-article-treat-head-custom
1179 :set (lambda (symbol value)
1182 (cond ((or (boundp symbol) (get symbol 'saved-value))
1184 ((boundp 'gnus-treat-display-xface)
1186 ** gnus-treat-display-xface is an obsolete variable;\
1187 use gnus-treat-display-x-face instead")
1188 (default-value 'gnus-treat-display-xface))
1189 ((get 'gnus-treat-display-xface 'saved-value)
1191 ** gnus-treat-display-xface is an obsolete variable;\
1192 use gnus-treat-display-x-face instead")
1193 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1196 (put 'gnus-treat-display-x-face 'highlight t)
1198 (defcustom gnus-treat-display-face
1199 (and (not noninteractive)
1200 (or (and (fboundp 'image-type-available-p)
1201 (image-type-available-p 'png))
1202 (and (featurep 'xemacs)
1205 "Display Face headers.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' and Info node
1208 `(gnus)X-Face' for details."
1209 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :link '(custom-manual "(gnus)X-Face")
1213 :type gnus-article-treat-head-custom)
1214 (put 'gnus-treat-display-face 'highlight t)
1216 (defcustom gnus-treat-display-smileys
1217 (if (or (and (featurep 'xemacs)
1219 (and (fboundp 'image-type-available-p)
1220 (image-type-available-p 'pbm)))
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' and Info node
1225 `(gnus)Smileys' for details."
1226 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :link '(custom-manual "(gnus)Smileys")
1230 :type gnus-article-treat-custom)
1231 (put 'gnus-treat-display-smileys 'highlight t)
1233 (defcustom gnus-treat-from-picon
1234 (if (and (gnus-image-type-available-p 'xpm)
1235 (gnus-picons-installed-p))
1237 "Display picons in the From header.
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' and Info node
1240 `(gnus)Picons' for details."
1241 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :link '(custom-manual "(gnus)Picons")
1245 :type gnus-article-treat-head-custom)
1246 (put 'gnus-treat-from-picon 'highlight t)
1248 (defcustom gnus-treat-mail-picon
1249 (if (and (gnus-image-type-available-p 'xpm)
1250 (gnus-picons-installed-p))
1252 "Display picons in To and Cc headers.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' and Info node
1255 `(gnus)Picons' for details."
1256 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :link '(custom-manual "(gnus)Picons")
1260 :type gnus-article-treat-head-custom)
1261 (put 'gnus-treat-mail-picon 'highlight t)
1263 (defcustom gnus-treat-newsgroups-picon
1264 (if (and (gnus-image-type-available-p 'xpm)
1265 (gnus-picons-installed-p))
1267 "Display picons in the Newsgroups and Followup-To headers.
1268 Valid values are nil, t, `head', `last', an integer or a predicate.
1269 See Info node `(gnus)Customizing Articles' and Info node
1270 `(gnus)Picons' for details."
1271 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :link '(custom-manual "(gnus)Picons")
1275 :type gnus-article-treat-head-custom)
1276 (put 'gnus-treat-newsgroups-picon 'highlight t)
1278 (defcustom gnus-treat-body-boundary
1279 (if (or gnus-treat-newsgroups-picon
1280 gnus-treat-mail-picon
1281 gnus-treat-from-picon)
1283 "Draw a boundary at the end of the headers.
1284 Valid values are nil and `head'.
1285 See Info node `(gnus)Customizing Articles' for details."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-head-custom)
1291 (defcustom gnus-treat-capitalize-sentences nil
1292 "Capitalize sentence-starting words.
1293 Valid values are nil, t, `head', `last', an integer or a predicate.
1294 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-wash-html nil
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-fill-long-lines nil
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1312 :group 'gnus-article-treat
1313 :link '(custom-manual "(gnus)Customizing Articles")
1314 :type gnus-article-treat-custom)
1316 (defcustom gnus-treat-play-sounds nil
1318 Valid values are nil, t, `head', `last', an integer or a predicate.
1319 See Info node `(gnus)Customizing Articles' for details."
1321 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :type gnus-article-treat-custom)
1325 (defcustom gnus-treat-translate nil
1326 "Translate articles from one language to another.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' for details."
1330 :group 'gnus-article-treat
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (defcustom gnus-treat-x-pgp-sig nil
1336 To automatically treat X-PGP-Sig, set it to head.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' for details."
1339 :group 'gnus-article-treat
1340 :group 'mime-security
1341 :link '(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom)
1344 (defvar gnus-article-encrypt-protocol-alist
1345 '(("PGP" . mml2015-self-encrypt)))
1347 ;; Set to nil if more than one protocol added to
1348 ;; gnus-article-encrypt-protocol-alist.
1349 (defcustom gnus-article-encrypt-protocol "PGP"
1350 "The protocol used for encrypt articles.
1351 It is a string, such as \"PGP\". If nil, ask user."
1353 :group 'mime-security)
1355 (defvar gnus-article-wash-function nil
1356 "Function used for converting HTML into text.")
1358 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1359 (mm-coding-system-p 'utf-8)
1360 (executable-find idna-program))
1361 "Whether IDNA decoding of headers is used when viewing messages.
1362 This requires GNU Libidn, and by default only enabled if it is found."
1363 :group 'gnus-article-headers
1366 (defcustom gnus-article-over-scroll nil
1367 "If non-nil, allow scrolling the article buffer even when there no more text."
1368 :group 'gnus-article
1371 ;;; Internal variables
1373 (defvar gnus-english-month-names
1374 '("January" "February" "March" "April" "May" "June" "July" "August"
1375 "September" "October" "November" "December"))
1377 (defvar gnus-button-regexp nil)
1378 (defvar gnus-button-marker-list nil)
1379 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1381 (defvar gnus-button-last nil)
1382 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1384 (defvar article-goto-body-goes-to-point-min-p nil)
1385 (defvar gnus-article-wash-types nil)
1386 (defvar gnus-article-emphasis-alist nil)
1387 (defvar gnus-article-image-alist nil)
1389 (defvar gnus-article-mime-handle-alist-1 nil)
1390 (defvar gnus-treatment-function-alist
1391 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1392 (gnus-treat-strip-banner gnus-article-strip-banner)
1393 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1394 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1395 (gnus-treat-buttonize gnus-article-add-buttons)
1396 (gnus-treat-fill-article gnus-article-fill-cited-article)
1397 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1398 (gnus-treat-strip-cr gnus-article-remove-cr)
1399 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1400 (gnus-treat-date-ut gnus-article-date-ut)
1401 (gnus-treat-date-local gnus-article-date-local)
1402 (gnus-treat-date-english gnus-article-date-english)
1403 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1404 (gnus-treat-date-original gnus-article-date-original)
1405 (gnus-treat-date-user-defined gnus-article-date-user)
1406 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1407 (gnus-treat-display-x-face gnus-article-display-x-face)
1408 (gnus-treat-display-face gnus-article-display-face)
1409 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1410 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1411 (gnus-treat-hide-signature gnus-article-hide-signature)
1412 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1413 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1414 (gnus-treat-strip-pem gnus-article-hide-pem)
1415 (gnus-treat-from-picon gnus-treat-from-picon)
1416 (gnus-treat-mail-picon gnus-treat-mail-picon)
1417 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1418 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1419 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1420 (gnus-treat-strip-trailing-blank-lines
1421 gnus-article-remove-trailing-blank-lines)
1422 (gnus-treat-strip-leading-blank-lines
1423 gnus-article-strip-leading-blank-lines)
1424 (gnus-treat-strip-multiple-blank-lines
1425 gnus-article-strip-multiple-blank-lines)
1426 (gnus-treat-overstrike gnus-article-treat-overstrike)
1427 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1428 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1429 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1430 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1431 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1432 (gnus-treat-display-smileys gnus-treat-smiley)
1433 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1434 (gnus-treat-wash-html gnus-article-wash-html)
1435 (gnus-treat-emphasize gnus-article-emphasize)
1436 (gnus-treat-hide-citation gnus-article-hide-citation)
1437 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1438 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1439 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1440 (gnus-treat-play-sounds gnus-earcon-display)))
1442 (defvar gnus-article-mime-handle-alist nil)
1443 (defvar article-lapsed-timer nil)
1444 (defvar gnus-article-current-summary nil)
1446 (defvar gnus-article-mode-syntax-table
1447 (let ((table (copy-syntax-table text-mode-syntax-table)))
1448 ;; This causes the citation match run O(2^n).
1449 ;; (modify-syntax-entry ?- "w" table)
1450 (modify-syntax-entry ?> ")<" table)
1451 (modify-syntax-entry ?< "(>" table)
1452 ;; make M-. in article buffers work for `foo' strings
1453 (modify-syntax-entry ?' " " table)
1454 (modify-syntax-entry ?` " " table)
1456 "Syntax table used in article mode buffers.
1457 Initialized from `text-mode-syntax-table.")
1459 (defvar gnus-save-article-buffer nil)
1461 (defvar gnus-article-mode-line-format-alist
1462 (nconc '((?w (gnus-article-wash-status) ?s)
1463 (?m (gnus-article-mime-part-status) ?s))
1464 gnus-summary-mode-line-format-alist))
1466 (defvar gnus-number-of-articles-to-be-saved nil)
1468 (defvar gnus-inhibit-hiding nil)
1470 (defvar gnus-article-edit-mode nil)
1472 ;;; Macros for dealing with the article buffer.
1474 (defmacro gnus-with-article-headers (&rest forms)
1476 (set-buffer gnus-article-buffer)
1478 (let ((buffer-read-only nil)
1479 (inhibit-point-motion-hooks t)
1480 (case-fold-search t))
1481 (article-narrow-to-head)
1484 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1485 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1487 (defmacro gnus-with-article-buffer (&rest forms)
1489 (set-buffer gnus-article-buffer)
1490 (let ((buffer-read-only nil))
1493 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1494 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1496 (defun gnus-article-goto-header (header)
1497 "Go to HEADER, which is a regular expression."
1498 (re-search-forward (concat "^\\(" header "\\):") nil t))
1500 (defsubst gnus-article-hide-text (b e props)
1501 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1502 (gnus-add-text-properties-when 'article-type nil b e props)
1503 (when (memq 'intangible props)
1505 (max (1- b) (point-min))
1506 b 'intangible (cddr (memq 'intangible props)))))
1508 (defsubst gnus-article-unhide-text (b e)
1509 "Remove hidden text properties from region between B and E."
1510 (remove-text-properties b e gnus-hidden-properties)
1511 (when (memq 'intangible gnus-hidden-properties)
1512 (put-text-property (max (1- b) (point-min))
1513 b 'intangible nil)))
1515 (defun gnus-article-hide-text-type (b e type)
1516 "Hide text of TYPE between B and E."
1517 (gnus-add-wash-type type)
1518 (gnus-article-hide-text
1519 b e (cons 'article-type (cons type gnus-hidden-properties))))
1521 (defun gnus-article-unhide-text-type (b e type)
1522 "Unhide text of TYPE between B and E."
1523 (gnus-delete-wash-type type)
1524 (remove-text-properties
1525 b e (cons 'article-type (cons type gnus-hidden-properties)))
1526 (when (memq 'intangible gnus-hidden-properties)
1527 (put-text-property (max (1- b) (point-min))
1528 b 'intangible nil)))
1530 (defun gnus-article-hide-text-of-type (type)
1531 "Hide text of TYPE in the current buffer."
1533 (let ((b (point-min))
1535 (while (setq b (text-property-any b e 'article-type type))
1536 (add-text-properties b (incf b) gnus-hidden-properties)))))
1538 (defun gnus-article-delete-text-of-type (type)
1539 "Delete text of TYPE in the current buffer."
1541 (let ((b (point-min)))
1542 (while (setq b (text-property-any b (point-max) 'article-type type))
1544 b (or (text-property-not-all b (point-max) 'article-type type)
1547 (defun gnus-article-delete-invisible-text ()
1548 "Delete all invisible text in the current buffer."
1550 (let ((b (point-min)))
1551 (while (setq b (text-property-any b (point-max) 'invisible t))
1553 b (or (text-property-not-all b (point-max) 'invisible t)
1556 (defun gnus-article-text-type-exists-p (type)
1557 "Say whether any text of type TYPE exists in the buffer."
1558 (text-property-any (point-min) (point-max) 'article-type type))
1560 (defsubst gnus-article-header-rank ()
1561 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1562 (let ((list gnus-sorted-header-list)
1565 (if (looking-at (car list))
1567 (setq list (cdr list))
1571 (defun article-hide-headers (&optional arg delete)
1572 "Hide unwanted headers and possibly sort them as well."
1574 ;; This function might be inhibited.
1575 (unless gnus-inhibit-hiding
1578 (let ((buffer-read-only nil)
1579 (case-fold-search t)
1580 (max (1+ (length gnus-sorted-header-list)))
1581 (ignored (when (not gnus-visible-headers)
1582 (cond ((stringp gnus-ignored-headers)
1583 gnus-ignored-headers)
1584 ((listp gnus-ignored-headers)
1585 (mapconcat 'identity gnus-ignored-headers
1588 (cond ((stringp gnus-visible-headers)
1589 gnus-visible-headers)
1590 ((and gnus-visible-headers
1591 (listp gnus-visible-headers))
1592 (mapconcat 'identity gnus-visible-headers "\\|"))))
1593 (inhibit-point-motion-hooks t)
1595 ;; First we narrow to just the headers.
1596 (article-narrow-to-head)
1597 ;; Hide any "From " lines at the beginning of (mail) articles.
1598 (while (looking-at "From ")
1601 (delete-region (point-min) (point)))
1602 ;; Then treat the rest of the header lines.
1603 ;; Then we use the two regular expressions
1604 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1605 ;; select which header lines is to remain visible in the
1607 (while (re-search-forward "^[^ \t:]*:" nil t)
1609 ;; Mark the rank of the header.
1611 (point) (1+ (point)) 'message-rank
1612 (if (or (and visible (looking-at visible))
1614 (not (looking-at ignored))))
1615 (gnus-article-header-rank)
1618 (message-sort-headers-1)
1619 (when (setq beg (text-property-any
1620 (point-min) (point-max) 'message-rank (+ 2 max)))
1621 ;; We delete the unwanted headers.
1622 (gnus-add-wash-type 'headers)
1623 (add-text-properties (point-min) (+ 5 (point-min))
1624 '(article-type headers dummy-invisible t))
1625 (delete-region beg (point-max))))))))
1627 (defun article-hide-boring-headers (&optional arg)
1628 "Toggle hiding of headers that aren't very interesting.
1629 If given a negative prefix, always show; if given a positive prefix,
1631 (interactive (gnus-article-hidden-arg))
1632 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1633 (not gnus-show-all-headers))
1636 (let ((buffer-read-only nil)
1637 (list gnus-boring-article-headers)
1638 (inhibit-point-motion-hooks t)
1640 (article-narrow-to-head)
1642 (setq elem (pop list))
1643 (goto-char (point-min))
1645 ;; Hide empty headers.
1647 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1649 (gnus-article-hide-text-type
1653 (if (re-search-forward "^[^ \t]" nil t)
1657 ;; Hide boring Newsgroups header.
1658 ((eq elem 'newsgroups)
1659 (when (gnus-string-equal
1660 (gnus-fetch-field "newsgroups")
1661 (gnus-group-real-name
1662 (if (boundp 'gnus-newsgroup-name)
1665 (gnus-article-hide-header "newsgroups")))
1666 ((eq elem 'to-address)
1667 (let ((to (message-fetch-field "to"))
1669 (gnus-parameter-to-address
1670 (if (boundp 'gnus-newsgroup-name)
1671 gnus-newsgroup-name ""))))
1672 (when (and to to-address
1675 ;; only one address in To
1676 (nth 1 (mail-extract-address-components to))
1678 (gnus-article-hide-header "to"))))
1680 (let ((to (message-fetch-field "to"))
1682 (gnus-parameter-to-list
1683 (if (boundp 'gnus-newsgroup-name)
1684 gnus-newsgroup-name ""))))
1685 (when (and to to-list
1688 ;; only one address in To
1689 (nth 1 (mail-extract-address-components to))
1691 (gnus-article-hide-header "to"))))
1693 (let ((cc (message-fetch-field "cc"))
1695 (gnus-parameter-to-list
1696 (if (boundp 'gnus-newsgroup-name)
1697 gnus-newsgroup-name ""))))
1698 (when (and cc to-list
1701 ;; only one address in CC
1702 (nth 1 (mail-extract-address-components cc))
1704 (gnus-article-hide-header "cc"))))
1705 ((eq elem 'followup-to)
1706 (when (gnus-string-equal
1707 (message-fetch-field "followup-to")
1708 (message-fetch-field "newsgroups"))
1709 (gnus-article-hide-header "followup-to")))
1710 ((eq elem 'reply-to)
1711 (if (gnus-group-find-parameter
1712 gnus-newsgroup-name 'broken-reply-to)
1713 (gnus-article-hide-header "reply-to")
1714 (let ((from (message-fetch-field "from"))
1715 (reply-to (message-fetch-field "reply-to")))
1722 (lambda (x) (downcase (cadr x)))
1723 (mail-extract-address-components from t))
1726 (lambda (x) (downcase (cadr x)))
1727 (mail-extract-address-components reply-to t))
1729 (gnus-article-hide-header "reply-to")))))
1731 (let ((date (message-fetch-field "date")))
1733 (< (days-between (current-time-string) date)
1735 (gnus-article-hide-header "date"))))
1737 (let ((to (message-fetch-field "to"))
1738 (cc (message-fetch-field "cc")))
1739 (when (> (length to) 1024)
1740 (gnus-article-hide-header "to"))
1741 (when (> (length cc) 1024)
1742 (gnus-article-hide-header "cc"))))
1746 (goto-char (point-min))
1747 (while (re-search-forward "^to:" nil t)
1748 (setq to-count (1+ to-count)))
1749 (when (> to-count 1)
1750 (while (> to-count 0)
1751 (goto-char (point-min))
1753 (re-search-forward "^to:" nil nil to-count)
1755 (narrow-to-region (point) (point-max))
1756 (gnus-article-hide-header "to"))
1757 (setq to-count (1- to-count))))
1758 (goto-char (point-min))
1759 (while (re-search-forward "^cc:" nil t)
1760 (setq cc-count (1+ cc-count)))
1761 (when (> cc-count 1)
1762 (while (> cc-count 0)
1763 (goto-char (point-min))
1765 (re-search-forward "^cc:" nil nil cc-count)
1767 (narrow-to-region (point) (point-max))
1768 (gnus-article-hide-header "cc"))
1769 (setq cc-count (1- cc-count)))))))))))))
1771 (defun gnus-article-hide-header (header)
1773 (goto-char (point-min))
1774 (when (re-search-forward (concat "^" header ":") nil t)
1775 (gnus-article-hide-text-type
1779 (if (re-search-forward "^[^ \t]" nil t)
1784 (defvar gnus-article-normalized-header-length 40
1785 "Length of normalized headers.")
1787 (defun article-normalize-headers ()
1788 "Make all header lines 40 characters long."
1790 (let ((buffer-read-only nil)
1794 (article-narrow-to-head)
1797 ((< (setq column (- (point-at-eol) (point)))
1798 gnus-article-normalized-header-length)
1800 (insert (make-string
1801 (- gnus-article-normalized-header-length column)
1803 ((> column gnus-article-normalized-header-length)
1804 (gnus-put-text-property
1806 (forward-char gnus-article-normalized-header-length)
1813 (forward-line 1))))))
1815 (defun article-treat-dumbquotes ()
1816 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1817 Note that this function guesses whether a character is a sm*rtq**t* or
1818 not, so it should only be used interactively.
1820 Sm*rtq**t*s are M****s***'s unilateral extension to the
1821 iso-8859-1 character map in an attempt to provide more quoting
1822 characters. If you see something like \\222 or \\264 where
1823 you're expecting some kind of apostrophe or quotation mark, then
1826 (article-translate-strings gnus-article-dumbquotes-map))
1828 (defun article-translate-characters (from to)
1829 "Translate all characters in the body of the article according to FROM and TO.
1830 FROM is a string of characters to translate from; to is a string of
1831 characters to translate to."
1833 (when (article-goto-body)
1834 (let ((buffer-read-only nil)
1835 (x (make-string 225 ?x))
1837 (while (< (incf i) (length x))
1840 (while (< i (length from))
1841 (aset x (aref from i) (aref to i))
1843 (translate-region (point) (point-max) x)))))
1845 (defun article-translate-strings (map)
1846 "Translate all string in the body of the article according to MAP.
1847 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1849 (when (article-goto-body)
1850 (let ((buffer-read-only nil)
1852 (while (setq elem (pop map))
1854 (while (search-forward (car elem) nil t)
1855 (replace-match (cadr elem)))))))))
1857 (defun article-treat-overstrike ()
1858 "Translate overstrikes into bold text."
1861 (when (article-goto-body)
1862 (let ((buffer-read-only nil))
1863 (while (search-forward "\b" nil t)
1864 (let ((next (char-after))
1865 (previous (char-after (- (point) 2))))
1866 ;; We do the boldification/underlining by hiding the
1867 ;; overstrikes and putting the proper text property
1871 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1872 (put-text-property (point) (1+ (point)) 'face 'bold))
1874 (gnus-article-hide-text-type
1875 (1- (point)) (1+ (point)) 'overstrike)
1877 (- (point) 2) (1- (point)) 'face 'underline))
1879 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1881 (point) (1+ (point)) 'face 'underline)))))))))
1883 (defun article-treat-ansi-sequences ()
1884 "Translate ANSI SGR control sequences into overlays or extents."
1887 (when (article-goto-body)
1888 (let ((buffer-read-only nil))
1889 (ansi-color-apply-on-region (point) (point-max))))))
1891 (defun gnus-article-treat-unfold-headers ()
1892 "Unfold folded message headers.
1893 Only the headers that fit into the current window width will be
1896 (gnus-with-article-headers
1900 (mail-header-narrow-to-field)
1901 (let ((header (buffer-string)))
1904 (goto-char (point-min))
1905 (while (re-search-forward "\n[\t ]" nil t)
1906 (replace-match " " t t)))
1907 (setq length (- (point-max) (point-min) 1)))
1908 (when (< length (window-width))
1909 (while (re-search-forward "\n[\t ]" nil t)
1910 (replace-match " " t t)))
1911 (goto-char (point-max)))))))
1913 (defun gnus-article-treat-fold-headers ()
1914 "Fold message headers."
1916 (gnus-with-article-headers
1919 (mail-header-narrow-to-field)
1920 (mail-header-fold-field)
1921 (goto-char (point-max))))))
1923 (defun gnus-treat-smiley ()
1924 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1926 (gnus-with-article-buffer
1927 (if (memq 'smiley gnus-article-wash-types)
1928 (gnus-delete-images 'smiley)
1930 (let ((images (smiley-region (point) (point-max))))
1932 (gnus-add-wash-type 'smiley)
1933 (dolist (image images)
1934 (gnus-add-image 'smiley image)))))))
1936 (defun gnus-article-remove-images ()
1937 "Remove all images from the article buffer."
1939 (gnus-with-article-buffer
1940 (dolist (elem gnus-article-image-alist)
1941 (gnus-delete-images (car elem)))))
1943 (defun gnus-article-treat-fold-newsgroups ()
1944 "Unfold folded message headers.
1945 Only the headers that fit into the current window width will be
1948 (gnus-with-article-headers
1949 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1951 (mail-header-narrow-to-field)
1952 (while (re-search-forward ", *" nil t)
1953 (replace-match ", " t t))
1954 (mail-header-fold-field)
1955 (goto-char (point-max))))))
1957 (defun gnus-article-treat-body-boundary ()
1958 "Place a boundary line at the end of the headers."
1960 (when (and gnus-body-boundary-delimiter
1961 (> (length gnus-body-boundary-delimiter) 0))
1962 (gnus-with-article-headers
1963 (goto-char (point-max))
1964 (let ((start (point)))
1965 (insert "X-Boundary: ")
1966 (gnus-add-text-properties start (point) '(invisible t intangible t))
1968 (while (>= (1- (window-width)) (length str))
1969 (setq str (concat str gnus-body-boundary-delimiter)))
1970 (substring str 0 (1- (window-width))))
1972 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1974 (defun article-fill-long-lines ()
1975 "Fill lines that are wider than the window width."
1978 (let ((buffer-read-only nil)
1979 (width (window-width (get-buffer-window (current-buffer)))))
1982 (let ((adaptive-fill-mode nil)) ;Why? -sm
1985 (when (>= (current-column) (min fill-column width))
1986 (narrow-to-region (min (1+ (point)) (point-max))
1988 (let ((goback (point-marker)))
1989 (fill-paragraph nil)
1990 (goto-char (marker-position goback)))
1992 (forward-line 1)))))))
1994 (defun article-capitalize-sentences ()
1995 "Capitalize the first word in each sentence."
1998 (let ((buffer-read-only nil)
1999 (paragraph-start "^[\n\^L]"))
2003 (forward-sentence)))))
2005 (defun article-remove-cr ()
2006 "Remove trailing CRs and then translate remaining CRs into LFs."
2009 (let ((buffer-read-only nil))
2010 (goto-char (point-min))
2011 (while (re-search-forward "\r+$" nil t)
2012 (replace-match "" t t))
2013 (goto-char (point-min))
2014 (while (search-forward "\r" nil t)
2015 (replace-match "\n" t t)))))
2017 (defun article-remove-trailing-blank-lines ()
2018 "Remove all trailing blank lines from the article."
2021 (let ((buffer-read-only nil))
2022 (goto-char (point-max))
2026 (while (and (not (bobp))
2027 (looking-at "^[ \t]*$")
2028 (not (gnus-annotation-in-region-p
2029 (point) (point-at-eol))))
2035 (defvar gnus-face-properties-alist))
2037 (defun article-display-face ()
2038 "Display any Face headers in the header."
2040 (let ((wash-face-p buffer-read-only))
2041 (gnus-with-article-headers
2042 ;; When displaying parts, this function can be called several times on
2043 ;; the same article, without any intended toggle semantic (as typing `W
2044 ;; D d' would have). So face deletion must occur only when we come from
2045 ;; an interactive command, that is when the *Article* buffer is
2047 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2048 (gnus-delete-images 'face)
2051 (when (and wash-face-p
2053 (goto-char (point-min))
2054 (not (re-search-forward "^Face:[\t ]*" nil t)))
2055 (gnus-buffer-live-p gnus-original-article-buffer))
2056 (set-buffer gnus-original-article-buffer))
2058 (mail-narrow-to-head)
2059 (while (gnus-article-goto-header "Face")
2060 (push (mail-header-field-value) faces))))
2061 (while (setq face (pop faces))
2062 (let ((png (gnus-convert-face-to-png face))
2066 (apply 'gnus-create-image png 'png t
2067 (cdr (assq 'png gnus-face-properties-alist))))
2068 (gnus-article-goto-header "from")
2070 (insert "From: [no `from' set]\n")
2072 (gnus-add-wash-type 'face)
2073 (gnus-add-image 'face image)
2074 (gnus-put-image image nil 'face))))))
2077 (defun article-display-x-face (&optional force)
2078 "Look for an X-Face header and display it if present."
2079 (interactive (list 'force))
2080 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2081 (gnus-with-article-headers
2082 ;; Delete the old process, if any.
2083 (when (process-status "article-x-face")
2084 (delete-process "article-x-face"))
2085 ;; See the comment in `article-display-face'.
2086 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2087 ;; We have already displayed X-Faces, so we remove them
2089 (gnus-delete-images 'xface)
2091 (let (x-faces from face)
2093 (when (and wash-face-p
2095 (goto-char (point-min))
2096 (not (re-search-forward
2097 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2098 (gnus-buffer-live-p gnus-original-article-buffer))
2099 ;; If type `W f', use gnus-original-article-buffer,
2100 ;; otherwise use the current buffer because displaying
2101 ;; RFC822 parts calls this function too.
2102 (set-buffer gnus-original-article-buffer))
2104 (mail-narrow-to-head)
2105 (while (gnus-article-goto-header "X-Face")
2106 (push (mail-header-field-value) x-faces))
2107 (setq from (message-fetch-field "from"))))
2108 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2109 ;; single external face.
2110 (when (stringp gnus-article-x-face-command)
2111 (setq x-faces (list (car x-faces))))
2112 (while (and (setq face (pop x-faces))
2113 gnus-article-x-face-command
2115 ;; Check whether this face is censored.
2116 (not gnus-article-x-face-too-ugly)
2117 (and gnus-article-x-face-too-ugly from
2118 (not (string-match gnus-article-x-face-too-ugly
2120 ;; We display the face.
2121 (cond ((stringp gnus-article-x-face-command)
2122 ;; The command is a string, so we interpret the command
2123 ;; as a, well, command, and fork it off.
2124 (let ((process-connection-type nil))
2125 (process-kill-without-query
2127 "article-x-face" nil shell-file-name
2128 shell-command-switch gnus-article-x-face-command))
2131 (process-send-region "article-x-face"
2132 (point-min) (point-max)))
2133 (process-send-eof "article-x-face")))
2134 ((functionp gnus-article-x-face-command)
2135 ;; The command is a lisp function, so we call it.
2136 (funcall gnus-article-x-face-command face))
2138 (error "%s is not a function"
2139 gnus-article-x-face-command)))))))))
2141 (defun article-decode-mime-words ()
2142 "Decode all MIME-encoded words in the article."
2144 (gnus-with-article-buffer
2145 (let ((inhibit-point-motion-hooks t)
2146 (mail-parse-charset gnus-newsgroup-charset)
2147 (mail-parse-ignored-charsets
2148 (with-current-buffer gnus-summary-buffer
2149 gnus-newsgroup-ignored-charsets)))
2150 (mail-decode-encoded-word-region (point-min) (point-max)))))
2152 (defun article-decode-charset (&optional prompt)
2153 "Decode charset-encoded text in the article.
2154 If PROMPT (the prefix), prompt for a coding system to use."
2156 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2158 (mail-parse-charset gnus-newsgroup-charset)
2159 (mail-parse-ignored-charsets
2160 (save-excursion (condition-case nil
2161 (set-buffer gnus-summary-buffer)
2163 gnus-newsgroup-ignored-charsets))
2164 ct cte ctl charset format)
2167 (article-narrow-to-head)
2168 (setq ct (message-fetch-field "Content-Type" t)
2169 cte (message-fetch-field "Content-Transfer-Encoding" t)
2170 ctl (and ct (ignore-errors
2171 (mail-header-parse-content-type ct)))
2174 (mm-read-coding-system "Charset to decode: "))
2176 (mail-content-type-get ctl 'charset)))
2177 format (and ctl (mail-content-type-get ctl 'format)))
2179 (setq cte (mail-header-strip cte)))
2180 (if (and ctl (not (string-match "/" (car ctl))))
2182 (goto-char (point-max)))
2185 (narrow-to-region (point) (point-max))
2186 (when (and (eq mail-parse-charset 'gnus-decoded)
2187 (eq (mm-body-7-or-8) '8bit))
2188 ;; The text code could have been decoded.
2189 (setq charset mail-parse-charset))
2190 (when (and (or (not ctl)
2191 (equal (car ctl) "text/plain"))
2192 (not format)) ;; article with format will decode later.
2194 charset (and cte (intern (downcase
2195 (gnus-strip-whitespace cte))))
2198 (defun article-decode-encoded-words ()
2199 "Remove encoded-word encoding from headers."
2200 (let ((inhibit-point-motion-hooks t)
2201 (mail-parse-charset gnus-newsgroup-charset)
2202 (mail-parse-ignored-charsets
2203 (save-excursion (condition-case nil
2204 (set-buffer gnus-summary-buffer)
2206 gnus-newsgroup-ignored-charsets))
2209 (article-narrow-to-head)
2210 (funcall gnus-decode-header-function (point-min) (point-max)))))
2212 (defun article-decode-group-name ()
2213 "Decode group names in `Newsgroups:'."
2214 (let ((inhibit-point-motion-hooks t)
2216 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2217 (when (and (or gnus-group-name-charset-method-alist
2218 gnus-group-name-charset-group-alist)
2219 (gnus-buffer-live-p gnus-original-article-buffer))
2221 (article-narrow-to-head)
2222 (with-current-buffer gnus-original-article-buffer
2223 (goto-char (point-min)))
2224 (while (re-search-forward
2225 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2226 (replace-match (save-match-data
2227 (gnus-decode-newsgroups
2228 ;; XXX how to use data in article buffer?
2229 (with-current-buffer gnus-original-article-buffer
2231 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2234 gnus-newsgroup-name method))
2236 (goto-char (point-min))
2237 (with-current-buffer gnus-original-article-buffer
2238 (goto-char (point-min)))
2239 (while (re-search-forward
2240 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2241 (replace-match (save-match-data
2242 (gnus-decode-newsgroups
2243 ;; XXX how to use data in article buffer?
2244 (with-current-buffer gnus-original-article-buffer
2246 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2249 gnus-newsgroup-name method))
2252 (autoload 'idna-to-unicode "idna")
2254 (defun article-decode-idna-rhs ()
2255 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2258 (let ((inhibit-point-motion-hooks t)
2260 (article-narrow-to-head)
2261 (goto-char (point-min))
2262 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2264 (when (save-match-data
2265 (and (setq ace (match-string 1))
2267 (and (re-search-backward "^[^ \t]" nil t)
2268 (looking-at "From\\|To\\|Cc")))
2269 (save-excursion (backward-char)
2270 (message-idna-inside-rhs-p))
2271 (setq unicode (idna-to-unicode ace))))
2272 (unless (string= ace unicode)
2273 (replace-match unicode nil nil nil 1)))))))))
2275 (defun article-de-quoted-unreadable (&optional force read-charset)
2276 "Translate a quoted-printable-encoded article.
2277 If FORCE, decode the article whether it is marked as quoted-printable
2279 If READ-CHARSET, ask for a coding system."
2280 (interactive (list 'force current-prefix-arg))
2282 (let ((buffer-read-only nil) type charset)
2283 (if (gnus-buffer-live-p gnus-original-article-buffer)
2284 (with-current-buffer gnus-original-article-buffer
2286 (gnus-fetch-field "content-transfer-encoding"))
2287 (let* ((ct (gnus-fetch-field "content-type"))
2290 (mail-header-parse-content-type ct)))))
2291 (setq charset (and ctl
2292 (mail-content-type-get ctl 'charset)))
2293 (if (stringp charset)
2294 (setq charset (intern (downcase charset)))))))
2296 (setq charset (mm-read-coding-system "Charset: " charset)))
2298 (setq charset gnus-newsgroup-charset))
2300 (and type (let ((case-fold-search t))
2301 (string-match "quoted-printable" type))))
2303 (quoted-printable-decode-region
2304 (point) (point-max) (mm-charset-to-coding-system charset))))))
2306 (defun article-de-base64-unreadable (&optional force read-charset)
2307 "Translate a base64 article.
2308 If FORCE, decode the article whether it is marked as base64 not.
2309 If READ-CHARSET, ask for a coding system."
2310 (interactive (list 'force current-prefix-arg))
2312 (let ((buffer-read-only nil) type charset)
2313 (if (gnus-buffer-live-p gnus-original-article-buffer)
2314 (with-current-buffer gnus-original-article-buffer
2316 (gnus-fetch-field "content-transfer-encoding"))
2317 (let* ((ct (gnus-fetch-field "content-type"))
2320 (mail-header-parse-content-type ct)))))
2321 (setq charset (and ctl
2322 (mail-content-type-get ctl 'charset)))
2323 (if (stringp charset)
2324 (setq charset (intern (downcase charset)))))))
2326 (setq charset (mm-read-coding-system "Charset: " charset)))
2328 (setq charset gnus-newsgroup-charset))
2330 (and type (let ((case-fold-search t))
2331 (string-match "base64" type))))
2334 (narrow-to-region (point) (point-max))
2335 (base64-decode-region (point-min) (point-max))
2336 (mm-decode-coding-region
2337 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2342 (defun article-decode-HZ ()
2343 "Translate a HZ-encoded article."
2347 (let ((buffer-read-only nil))
2348 (rfc1843-decode-region (point-min) (point-max)))))
2350 (defun article-unsplit-urls ()
2351 "Remove the newlines that some other mailers insert into URLs."
2354 (let ((buffer-read-only nil))
2355 (goto-char (point-min))
2356 (while (re-search-forward
2357 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2358 (replace-match "\\1\\3" t)))
2359 (when (interactive-p)
2360 (gnus-treat-article nil))))
2363 (defun article-wash-html (&optional read-charset)
2364 "Format an HTML article.
2365 If READ-CHARSET, ask for a coding system."
2368 (let ((buffer-read-only nil)
2370 (when (gnus-buffer-live-p gnus-original-article-buffer)
2371 (with-current-buffer gnus-original-article-buffer
2372 (let* ((ct (gnus-fetch-field "content-type"))
2375 (mail-header-parse-content-type ct)))))
2376 (setq charset (and ctl
2377 (mail-content-type-get ctl 'charset)))
2378 (when (stringp charset)
2379 (setq charset (intern (downcase charset)))))))
2381 (setq charset (mm-read-coding-system "Charset: " charset)))
2383 (setq charset gnus-newsgroup-charset))
2385 (save-window-excursion
2387 (narrow-to-region (point) (point-max))
2388 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2389 (entry (assq func mm-text-html-washer-alist)))
2391 (setq func (cdr entry)))
2396 (apply (car func) (cdr func))))))))))
2398 (defun gnus-article-wash-html-with-w3 ()
2399 "Wash the current buffer with w3."
2401 (let ((w3-strict-width (window-width))
2402 (url-standalone-mode t)
2403 (url-gateway-unplugged t)
2404 (w3-honor-stylesheets nil))
2406 (w3-region (point-min) (point-max))
2409 (defun gnus-article-wash-html-with-w3m ()
2410 "Wash the current buffer with emacs-w3m."
2413 (narrow-to-region (point) (point-max))
2414 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2417 w3m-force-redisplay)
2418 (w3m-region (point-min) (point-max)))
2419 (when (and mm-inline-text-html-with-w3m-keymap
2420 (boundp 'w3m-minor-mode-map)
2422 (add-text-properties
2423 (point-min) (point-max)
2424 (list 'keymap w3m-minor-mode-map
2425 ;; Put the mark meaning this part was rendered by emacs-w3m.
2426 'mm-inline-text-html-with-w3m t)))))
2428 (defun article-hide-list-identifiers ()
2429 "Remove list identifies from the Subject header.
2430 The `gnus-list-identifiers' variable specifies what to do."
2432 (let ((inhibit-point-motion-hooks t)
2433 (regexp (if (consp gnus-list-identifiers)
2434 (mapconcat 'identity gnus-list-identifiers " *\\|")
2435 gnus-list-identifiers))
2440 (article-narrow-to-head)
2441 (goto-char (point-min))
2442 (while (re-search-forward
2443 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2445 (delete-region (match-beginning 2) (match-end 0))
2446 (beginning-of-line))
2447 (when (re-search-forward
2448 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2449 (delete-region (match-beginning 1) (match-end 1))))))))
2451 (defun article-hide-pem (&optional arg)
2452 "Toggle hiding of any PEM headers and signatures in the current article.
2453 If given a negative prefix, always show; if given a positive prefix,
2455 (interactive (gnus-article-hidden-arg))
2456 (unless (gnus-article-check-hidden-text 'pem arg)
2458 (let (buffer-read-only end)
2459 (goto-char (point-min))
2460 ;; Hide the horrendously ugly "header".
2461 (when (and (search-forward
2462 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2464 (setq end (1+ (match-beginning 0))))
2465 (gnus-add-wash-type 'pem)
2466 (gnus-article-hide-text-type
2468 (if (search-forward "\n\n" nil t)
2472 ;; Hide the trailer as well
2473 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2475 (gnus-article-hide-text-type
2476 (match-beginning 0) (match-end 0) 'pem)))))))
2478 (defun article-strip-banner ()
2479 "Strip the banners specified by the `banner' group parameter and by
2480 `gnus-article-address-banner-alist'."
2484 (let ((inhibit-point-motion-hooks t))
2485 (when (gnus-parameter-banner gnus-newsgroup-name)
2486 (article-really-strip-banner
2487 (gnus-parameter-banner gnus-newsgroup-name)))
2488 (when gnus-article-address-banner-alist
2489 (article-really-strip-banner
2490 (let ((from (save-restriction
2492 (article-narrow-to-head)
2493 (mail-fetch-field "from"))))
2496 (caar (mail-header-parse-addresses from))))
2498 (dolist (pair gnus-article-address-banner-alist)
2499 (when (string-match (car pair) from)
2500 (throw 'found (cdr pair)))))))))))))
2502 (defun article-really-strip-banner (banner)
2503 "Strip the banner specified by the argument."
2506 (let ((inhibit-point-motion-hooks t)
2507 (gnus-signature-limit nil)
2511 ((eq banner 'signature)
2512 (when (gnus-article-narrow-to-signature)
2515 (delete-region (point) (point-max))))
2517 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2518 (while (re-search-forward banner nil t)
2519 (delete-region (match-beginning 0) (match-end 0)))))
2521 (while (re-search-forward banner nil t)
2522 (delete-region (match-beginning 0) (match-end 0)))))))))
2524 (defun article-babel ()
2525 "Translate article using an online translation service."
2528 (gnus-with-article-buffer
2529 (when (article-goto-body)
2530 (let* ((start (point))
2532 (orig (buffer-substring start end))
2533 (trans (babel-as-string orig)))
2535 (narrow-to-region start end)
2536 (delete-region start end)
2539 (defun article-hide-signature (&optional arg)
2540 "Hide the signature in the current article.
2541 If given a negative prefix, always show; if given a positive prefix,
2543 (interactive (gnus-article-hidden-arg))
2544 (unless (gnus-article-check-hidden-text 'signature arg)
2547 (let ((buffer-read-only nil))
2548 (when (gnus-article-narrow-to-signature)
2549 (gnus-article-hide-text-type
2550 (point-min) (point-max) 'signature))))))
2551 (gnus-set-mode-line 'article))
2553 (defun article-strip-headers-in-body ()
2554 "Strip offensive headers from bodies."
2558 (let ((case-fold-search t))
2559 (when (looking-at "x-no-archive:")
2560 (gnus-delete-line)))))
2562 (defun article-strip-leading-blank-lines ()
2563 "Remove all blank lines from the beginning of the article."
2566 (let ((inhibit-point-motion-hooks t)
2568 (when (article-goto-body)
2569 (while (and (not (eobp))
2570 (looking-at "[ \t]*$"))
2571 (gnus-delete-line))))))
2573 (defun article-narrow-to-head ()
2574 "Narrow the buffer to the head of the message.
2575 Point is left at the beginning of the narrowed-to region."
2577 (goto-char (point-min))
2578 (if (search-forward "\n\n" nil 1)
2581 (goto-char (point-min)))
2583 (defun article-goto-body ()
2584 "Place point at the start of the body."
2585 (goto-char (point-min))
2587 ;; This variable is only bound when dealing with separate
2589 (article-goto-body-goes-to-point-min-p
2591 ((search-forward "\n\n" nil t)
2594 (goto-char (point-max))
2597 (defun article-strip-multiple-blank-lines ()
2598 "Replace consecutive blank lines with one empty line."
2601 (let ((inhibit-point-motion-hooks t)
2603 ;; First make all blank lines empty.
2605 (while (re-search-forward "^[ \t]+$" nil t)
2606 (unless (gnus-annotation-in-region-p
2607 (match-beginning 0) (match-end 0))
2608 (replace-match "" nil t)))
2609 ;; Then replace multiple empty lines with a single empty line.
2611 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2612 (unless (gnus-annotation-in-region-p
2613 (match-beginning 0) (match-end 0))
2614 (delete-region (match-beginning 1) (match-end 1)))))))
2616 (defun article-strip-leading-space ()
2617 "Remove all white space from the beginning of the lines in the article."
2620 (let ((inhibit-point-motion-hooks t)
2623 (while (re-search-forward "^[ \t]+" nil t)
2624 (replace-match "" t t)))))
2626 (defun article-strip-trailing-space ()
2627 "Remove all white space from the end of the lines in the article."
2630 (let ((inhibit-point-motion-hooks t)
2633 (while (re-search-forward "[ \t]+$" nil t)
2634 (replace-match "" t t)))))
2636 (defun article-strip-blank-lines ()
2637 "Strip leading, trailing and multiple blank lines."
2639 (article-strip-leading-blank-lines)
2640 (article-remove-trailing-blank-lines)
2641 (article-strip-multiple-blank-lines))
2643 (defun article-strip-all-blank-lines ()
2644 "Strip all blank lines."
2647 (let ((inhibit-point-motion-hooks t)
2650 (while (re-search-forward "^[ \t]*\n" nil t)
2651 (replace-match "" t t)))))
2653 (defun gnus-article-narrow-to-signature ()
2654 "Narrow to the signature; return t if a signature is found, else nil."
2655 (let ((inhibit-point-motion-hooks t))
2656 (when (gnus-article-search-signature)
2658 ;; Check whether we have some limits to what we consider
2659 ;; to be a signature.
2660 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2661 (list gnus-signature-limit)))
2663 (while (setq limit (pop limits))
2664 (if (or (and (integerp limit)
2665 (< (- (point-max) (point)) limit))
2667 (< (count-lines (point) (point-max)) limit))
2668 (and (functionp limit)
2670 (and (stringp limit)
2671 (not (re-search-forward limit nil t))))
2672 () ; This limit did not succeed.
2676 (narrow-to-region (point) (point-max))
2679 (defun gnus-article-search-signature ()
2680 "Search the current buffer for the signature separator.
2681 Put point at the beginning of the signature separator."
2682 (let ((cur (point)))
2683 (goto-char (point-max))
2684 (if (if (stringp gnus-signature-separator)
2685 (re-search-backward gnus-signature-separator nil t)
2686 (let ((seps gnus-signature-separator))
2688 (not (re-search-backward (car seps) nil t)))
2695 (defun gnus-article-hidden-arg ()
2696 "Return the current prefix arg as a number, or 0 if no prefix."
2697 (list (if current-prefix-arg
2698 (prefix-numeric-value current-prefix-arg)
2701 (defun gnus-article-check-hidden-text (type arg)
2702 "Return nil if hiding is necessary.
2703 Arg can be nil or a number. nil and positive means hide, negative
2704 means show, 0 means toggle."
2707 (let ((hide (gnus-article-hidden-text-p type)))
2713 (gnus-article-show-hidden-text type)
2716 (if (eq hide 'hidden)
2718 (gnus-article-show-hidden-text type)
2722 (defun gnus-article-hidden-text-p (type)
2723 "Say whether the current buffer contains hidden text of type TYPE."
2724 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2726 (not (get-text-property pos 'invisible))
2727 (not (get-text-property pos 'dummy-invisible)))
2729 (text-property-any (1+ pos) (point-max) 'article-type type)))
2734 (defun gnus-article-show-hidden-text (type &optional dummy)
2735 "Show all hidden text of type TYPE.
2736 Originally it is hide instead of DUMMY."
2737 (let ((buffer-read-only nil)
2738 (inhibit-point-motion-hooks t))
2739 (gnus-remove-text-properties-when
2741 (point-min) (point-max)
2742 (cons 'article-type (cons type
2743 gnus-hidden-properties)))
2744 (gnus-delete-wash-type type)))
2746 (defconst article-time-units
2747 `((year . ,(* 365.25 24 60 60))
2748 (week . ,(* 7 24 60 60))
2749 (day . ,(* 24 60 60))
2753 "Mapping from time units to seconds.")
2755 (defun gnus-article-forward-header ()
2756 "Move point to the start of the next header.
2757 If the current header is a continuation header, this can be several
2762 (if (looking-at "[ \t]+[^ \t]")
2766 (defun article-date-ut (&optional type highlight header)
2767 "Convert DATE date to universal time in the current article.
2768 If TYPE is `local', convert to local time; if it is `lapsed', output
2769 how much time has lapsed since DATE. For `lapsed', the value of
2770 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2771 should replace the \"Date:\" one, or should be added below it."
2772 (interactive (list 'ut t))
2773 (let* ((header (or header
2774 (message-fetch-field "date")
2776 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2779 ((not gnus-article-date-lapsed-new-header)
2785 (date (if (vectorp header) (mail-header-date header)
2787 (inhibit-point-motion-hooks t)
2792 (article-narrow-to-head)
2793 (when (re-search-forward tdate-regexp nil t)
2794 (setq bface (get-text-property (point-at-bol) 'face)
2795 date (or (get-text-property (point-at-bol)
2798 eface (get-text-property (1- (point-at-eol)) 'face))
2800 (when (and date (not (string= date "")))
2801 (goto-char (point-min))
2802 (let ((buffer-read-only nil))
2803 ;; Delete any old Date headers.
2804 (while (re-search-forward date-regexp nil t)
2806 (delete-region (point-at-bol)
2807 (progn (gnus-article-forward-header)
2809 (delete-region (point-at-bol)
2810 (progn (gnus-article-forward-header)
2813 (setq pos (point))))
2814 (when (and (not pos)
2815 (re-search-forward tdate-regexp nil t))
2817 (gnus-goto-char pos)
2818 (insert (article-make-date-line date (or type 'ut)))
2824 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2825 (put-text-property (match-beginning 1) (1+ (match-end 1))
2826 'original-date date)
2827 (put-text-property (match-beginning 1) (1+ (match-end 1))
2829 (put-text-property (match-beginning 2) (match-end 2)
2832 (defun article-make-date-line (date type)
2833 "Return a DATE line of TYPE."
2834 (unless (memq type '(local ut original user iso8601 lapsed english))
2835 (error "Unknown conversion type: %s" type))
2837 (let ((time (date-to-time date)))
2839 ;; Convert to the local timezone.
2841 (let ((tz (car (current-time-zone time))))
2842 (format "Date: %s %s%02d%02d" (current-time-string time)
2843 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2844 (/ (% (abs tz) 3600) 60))))
2845 ;; Convert to Universal Time.
2848 (current-time-string
2849 (let* ((e (parse-time-string date))
2850 (tm (apply 'encode-time e))
2852 (ls (- (cadr tm) (car (current-time-zone time)))))
2853 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2854 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2857 ;; Get the original date from the article.
2858 ((eq type 'original)
2859 (concat "Date: " (if (string-match "\n+$" date)
2860 (substring date 0 (match-beginning 0))
2862 ;; Let the user define the format.
2864 (let ((format (or (condition-case nil
2865 (with-current-buffer gnus-summary-buffer
2866 gnus-article-time-format)
2868 gnus-article-time-format)))
2869 (if (functionp format)
2870 (funcall format time)
2871 (concat "Date: " (format-time-string format time)))))
2874 (let ((tz (car (current-time-zone time))))
2877 (format-time-string "%Y%m%dT%H%M%S" time)
2878 (format "%s%02d%02d"
2879 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2880 (/ (% (abs tz) 3600) 60)))))
2881 ;; Do an X-Sent lapsed format.
2883 ;; If the date is seriously mangled, the timezone functions are
2884 ;; liable to bug out, so we ignore all errors.
2885 (let* ((now (current-time))
2886 (real-time (subtract-time now time))
2887 (real-sec (and real-time
2888 (+ (* (float (car real-time)) 65536)
2890 (sec (and real-time (abs real-sec)))
2900 ;; This is a bit convoluted, but basically we go
2901 ;; through the time units for years, weeks, etc,
2902 ;; and divide things to see whether that results
2903 ;; in positive answers.
2906 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2907 ;; The (remaining) seconds are too few to
2908 ;; be divided into this time unit.
2910 ;; It's big enough, so we output it.
2911 (setq sec (- sec (* num (cdr unit))))
2913 (concat (if prev ", " "") (int-to-string
2915 " " (symbol-name (car unit))
2916 (if (> num 1) "s" ""))
2918 article-time-units "")
2919 ;; If dates are odd, then it might appear like the
2920 ;; article was sent in the future.
2923 " in the future"))))))
2924 ;; Display the date in proper English
2926 (let ((dtime (decode-time time)))
2929 (number-to-string (nth 3 dtime))
2930 (let ((digit (% (nth 3 dtime) 10)))
2932 ((memq (nth 3 dtime) '(11 12 13)) "th")
2938 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2940 (number-to-string (nth 5 dtime))
2942 (format "%02d" (nth 2 dtime))
2944 (format "%02d" (nth 1 dtime)))))))
2946 (format "Date: %s (from Gnus)" date))))
2948 (defun article-date-local (&optional highlight)
2949 "Convert the current article date to the local timezone."
2950 (interactive (list t))
2951 (article-date-ut 'local highlight))
2953 (defun article-date-english (&optional highlight)
2954 "Convert the current article date to something that is proper English."
2955 (interactive (list t))
2956 (article-date-ut 'english highlight))
2958 (defun article-date-original (&optional highlight)
2959 "Convert the current article date to what it was originally.
2960 This is only useful if you have used some other date conversion
2961 function and want to see what the date was before converting."
2962 (interactive (list t))
2963 (article-date-ut 'original highlight))
2965 (defun article-date-lapsed (&optional highlight)
2966 "Convert the current article date to time lapsed since it was sent."
2967 (interactive (list t))
2968 (article-date-ut 'lapsed highlight))
2970 (defun article-update-date-lapsed ()
2971 "Function to be run from a timer to update the lapsed time line."
2972 (let (deactivate-mark)
2977 (set-buffer (window-buffer w))
2978 (when (eq major-mode 'gnus-article-mode)
2979 (let ((mark (point-marker)))
2980 (goto-char (point-min))
2981 (when (re-search-forward "^X-Sent:" nil t)
2982 (article-date-lapsed t))
2983 (goto-char (marker-position mark))
2984 (move-marker mark nil))))
2987 (defun gnus-start-date-timer (&optional n)
2988 "Start a timer to update the X-Sent header in the article buffers.
2989 The numerical prefix says how frequently (in seconds) the function
2994 (gnus-stop-date-timer)
2995 (setq article-lapsed-timer
2996 (run-at-time 1 n 'article-update-date-lapsed)))
2998 (defun gnus-stop-date-timer ()
2999 "Stop the X-Sent timer."
3001 (when article-lapsed-timer
3002 (nnheader-cancel-timer article-lapsed-timer)
3003 (setq article-lapsed-timer nil)))
3005 (defun article-date-user (&optional highlight)
3006 "Convert the current article date to the user-defined format.
3007 This format is defined by the `gnus-article-time-format' variable."
3008 (interactive (list t))
3009 (article-date-ut 'user highlight))
3011 (defun article-date-iso8601 (&optional highlight)
3012 "Convert the current article date to ISO8601."
3013 (interactive (list t))
3014 (article-date-ut 'iso8601 highlight))
3016 ;; (defun article-show-all ()
3017 ;; "Show all hidden text in the article buffer."
3020 ;; (let ((buffer-read-only nil))
3021 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3023 (defun article-remove-leading-whitespace ()
3024 "Remove excessive whitespace from all headers."
3028 (let ((buffer-read-only nil))
3029 (article-narrow-to-head)
3030 (goto-char (point-min))
3031 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3032 (delete-region (match-beginning 1) (match-end 1)))))))
3034 (defun article-emphasize (&optional arg)
3035 "Emphasize text according to `gnus-emphasis-alist'."
3036 (interactive (gnus-article-hidden-arg))
3037 (unless (gnus-article-check-hidden-text 'emphasis arg)
3041 (with-current-buffer gnus-summary-buffer
3042 gnus-article-emphasis-alist)
3044 gnus-emphasis-alist))
3045 (buffer-read-only nil)
3046 (props (append '(article-type emphasis)
3047 gnus-hidden-properties))
3048 regexp elem beg invisible visible face)
3051 (while (setq elem (pop alist))
3053 (setq regexp (car elem)
3054 invisible (nth 1 elem)
3055 visible (nth 2 elem)
3057 (while (re-search-forward regexp nil t)
3058 (when (and (match-beginning visible) (match-beginning invisible))
3059 (gnus-article-hide-text
3060 (match-beginning invisible) (match-end invisible) props)
3061 (gnus-article-unhide-text-type
3062 (match-beginning visible) (match-end visible) 'emphasis)
3063 (gnus-put-overlay-excluding-newlines
3064 (match-beginning visible) (match-end visible) 'face face)
3065 (gnus-add-wash-type 'emphasis)
3066 (goto-char (match-end invisible)))))))))
3068 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3069 "Setup newsgroup emphasis alist."
3070 (unless gnus-article-emphasis-alist
3071 (let ((name (and gnus-newsgroup-name
3072 (gnus-group-real-name gnus-newsgroup-name))))
3073 (make-local-variable 'gnus-article-emphasis-alist)
3074 (setq gnus-article-emphasis-alist
3076 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3077 (while (setq elem (pop alist))
3078 (when (and name (string-match (car elem) name))
3080 highlight (copy-sequence (cdr elem)))))
3082 (copy-sequence highlight-words)
3083 (if gnus-newsgroup-name
3084 (copy-sequence (gnus-group-find-parameter
3085 gnus-newsgroup-name 'highlight-words t)))
3086 gnus-emphasis-alist)))))
3089 (defvar gnus-summary-article-menu)
3090 (defvar gnus-summary-post-menu))
3092 ;;; Saving functions.
3094 (defun gnus-article-save (save-buffer file &optional num)
3095 "Save the currently selected article."
3096 (unless gnus-save-all-headers
3097 ;; Remove headers according to `gnus-saved-headers'.
3098 (let ((gnus-visible-headers
3099 (or gnus-saved-headers gnus-visible-headers))
3100 (gnus-article-buffer save-buffer))
3102 (set-buffer save-buffer)
3103 (article-hide-headers 1 t))))
3104 (save-window-excursion
3105 (if (not gnus-default-article-saver)
3106 (error "No default saver is defined")
3107 ;; !!! Magic! The saving functions all save
3108 ;; `gnus-save-article-buffer' (or so they think), but we
3109 ;; bind that variable to our save-buffer.
3110 (set-buffer gnus-article-buffer)
3111 (let* ((gnus-save-article-buffer save-buffer)
3114 ((not gnus-prompt-before-saving) 'default)
3115 ((eq gnus-prompt-before-saving 'always) nil)
3117 (gnus-number-of-articles-to-be-saved
3118 (when (eq gnus-prompt-before-saving t)
3120 (set-buffer gnus-article-current-summary)
3121 (funcall gnus-default-article-saver filename)))))
3123 (defun gnus-read-save-file-name (prompt &optional filename
3124 function group headers variable)
3126 (funcall function group headers (symbol-value variable)))
3131 ((eq filename 'default)
3137 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3140 (if (and gnus-number-of-articles-to-be-saved
3141 (> gnus-number-of-articles-to-be-saved 1))
3142 (format "these %d articles"
3143 gnus-number-of-articles-to-be-saved)
3146 ;; Let the split methods have their say.
3148 ;; No split name was found.
3151 (concat prompt " (default "
3152 (file-name-nondirectory default-name) ") ")
3153 (file-name-directory default-name)
3155 ;; A single group name is returned.
3156 ((stringp split-name)
3158 (funcall function split-name headers
3159 (symbol-value variable)))
3161 (concat prompt " (default "
3162 (file-name-nondirectory default-name) ") ")
3163 (file-name-directory default-name)
3165 ;; A single split name was found
3166 ((= 1 (length split-name))
3167 (let* ((name (expand-file-name
3169 gnus-article-save-directory))
3170 (dir (cond ((file-directory-p name)
3171 (file-name-as-directory name))
3172 ((file-exists-p name) name)
3173 (t gnus-article-save-directory))))
3175 (concat prompt " (default " name ") ")
3177 ;; A list of splits was found.
3179 (setq split-name (nreverse split-name))
3181 (let ((file-name-history
3182 (nconc split-name file-name-history)))
3186 (concat prompt " (`M-p' for defaults) ")
3187 gnus-article-save-directory
3189 gnus-article-save-directory)))
3190 (car (push result file-name-history)))))))
3191 ;; Create the directory.
3192 (gnus-make-directory (file-name-directory file))
3193 ;; If we have read a directory, we append the default file name.
3194 (when (file-directory-p file)
3195 (setq file (expand-file-name (file-name-nondirectory
3197 (file-name-as-directory file))))
3198 ;; Possibly translate some characters.
3199 (nnheader-translate-file-chars file))))))
3200 (gnus-make-directory (file-name-directory result))
3201 (set variable result)))
3203 (defun gnus-article-archive-name (group)
3204 "Return the first instance of an \"Archive-name\" in the current buffer."
3205 (let ((case-fold-search t))
3206 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3207 (nnheader-concat gnus-article-save-directory
3208 (match-string 1)))))
3210 (defun gnus-article-nndoc-name (group)
3211 "If GROUP is an nndoc group, return the name of the parent group."
3212 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3213 (gnus-group-get-parameter group 'save-article-group)))
3215 (defun gnus-summary-save-in-rmail (&optional filename)
3216 "Append this article to Rmail file.
3217 Optional argument FILENAME specifies file name.
3218 Directory to save to is default to `gnus-article-save-directory'."
3219 (setq filename (gnus-read-save-file-name
3220 "Save %s in rmail file:" filename
3221 gnus-rmail-save-name gnus-newsgroup-name
3222 gnus-current-headers 'gnus-newsgroup-last-rmail))
3223 (gnus-eval-in-buffer-window gnus-save-article-buffer
3227 (gnus-output-to-rmail filename))))
3230 (defun gnus-summary-save-in-mail (&optional filename)
3231 "Append this article to Unix mail file.
3232 Optional argument FILENAME specifies file name.
3233 Directory to save to is default to `gnus-article-save-directory'."
3234 (setq filename (gnus-read-save-file-name
3235 "Save %s in Unix mail file:" filename
3236 gnus-mail-save-name gnus-newsgroup-name
3237 gnus-current-headers 'gnus-newsgroup-last-mail))
3238 (gnus-eval-in-buffer-window gnus-save-article-buffer
3242 (if (and (file-readable-p filename)
3243 (file-regular-p filename)
3244 (mail-file-babyl-p filename))
3245 (rmail-output-to-rmail-file filename t)
3246 (gnus-output-to-mail filename)))))
3249 (defun gnus-summary-save-in-file (&optional filename overwrite)
3250 "Append this article to file.
3251 Optional argument FILENAME specifies file name.
3252 Directory to save to is default to `gnus-article-save-directory'."
3253 (setq filename (gnus-read-save-file-name
3254 "Save %s in file:" filename
3255 gnus-file-save-name gnus-newsgroup-name
3256 gnus-current-headers 'gnus-newsgroup-last-file))
3257 (gnus-eval-in-buffer-window gnus-save-article-buffer
3261 (when (and overwrite
3262 (file-exists-p filename))
3263 (delete-file filename))
3264 (gnus-output-to-file filename))))
3267 (defun gnus-summary-write-to-file (&optional filename)
3268 "Write this article to a file, overwriting it if the file exists.
3269 Optional argument FILENAME specifies file name.
3270 The directory to save in defaults to `gnus-article-save-directory'."
3271 (gnus-summary-save-in-file nil t))
3273 (defun gnus-summary-save-body-in-file (&optional filename)
3274 "Append this article body to a file.
3275 Optional argument FILENAME specifies file name.
3276 The directory to save in defaults to `gnus-article-save-directory'."
3277 (setq filename (gnus-read-save-file-name
3278 "Save %s body in file:" filename
3279 gnus-file-save-name gnus-newsgroup-name
3280 gnus-current-headers 'gnus-newsgroup-last-file))
3281 (gnus-eval-in-buffer-window gnus-save-article-buffer
3285 (when (article-goto-body)
3286 (narrow-to-region (point) (point-max)))
3287 (gnus-output-to-file filename))))
3290 (defun gnus-summary-save-in-pipe (&optional command)
3291 "Pipe this article to subprocess."
3293 (cond ((and (eq command 'default)
3294 gnus-last-shell-command)
3295 gnus-last-shell-command)
3300 "Shell command on %s: "
3301 (if (and gnus-number-of-articles-to-be-saved
3302 (> gnus-number-of-articles-to-be-saved 1))
3303 (format "these %d articles"
3304 gnus-number-of-articles-to-be-saved)
3306 gnus-last-shell-command))))
3307 (when (string-equal command "")
3308 (if gnus-last-shell-command
3309 (setq command gnus-last-shell-command)
3310 (error "A command is required")))
3311 (gnus-eval-in-buffer-window gnus-article-buffer
3314 (shell-command-on-region (point-min) (point-max) command nil)))
3315 (setq gnus-last-shell-command command))
3317 (defun gnus-summary-pipe-to-muttprint (&optional command)
3318 "Pipe this article to muttprint."
3319 (setq command (read-string
3320 "Print using command: " gnus-summary-muttprint-program
3321 nil gnus-summary-muttprint-program))
3322 (gnus-summary-save-in-pipe command))
3324 ;;; Article file names when saving.
3326 (defun gnus-capitalize-newsgroup (newsgroup)
3327 "Capitalize NEWSGROUP name."
3328 (when (not (zerop (length newsgroup)))
3329 (concat (char-to-string (upcase (aref newsgroup 0)))
3330 (substring newsgroup 1))))
3332 (defun gnus-Numeric-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 ~/News/News.group/num.
3335 Otherwise, it is like ~/News/news/group/num."
3338 (concat (if (gnus-use-long-file-name 'not-save)
3339 (gnus-capitalize-newsgroup newsgroup)
3340 (gnus-newsgroup-directory-form newsgroup))
3341 "/" (int-to-string (mail-header-number headers)))
3342 gnus-article-save-directory)))
3344 (string-equal (file-name-directory default)
3345 (file-name-directory last-file))
3346 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3348 (or last-file default))))
3350 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3351 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3352 If variable `gnus-use-long-file-name' is non-nil, it is
3353 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3356 (concat (if (gnus-use-long-file-name 'not-save)
3358 (gnus-newsgroup-directory-form newsgroup))
3359 "/" (int-to-string (mail-header-number headers)))
3360 gnus-article-save-directory)))
3362 (string-equal (file-name-directory default)
3363 (file-name-directory last-file))
3364 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3366 (or last-file default))))
3368 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3369 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3370 If variable `gnus-use-long-file-name' is non-nil, it is
3371 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3374 (if (gnus-use-long-file-name 'not-save)
3377 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3379 gnus-article-save-directory)))
3381 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3382 "Generate file name from sender."
3383 (let ((from (mail-header-from headers)))
3385 (if (and from (string-match "\\([^ <]+\\)@" from))
3386 (match-string 1 from)
3388 gnus-article-save-directory)))
3390 (defun article-verify-x-pgp-sig ()
3393 (if (gnus-buffer-live-p gnus-original-article-buffer)
3394 (let ((sig (with-current-buffer gnus-original-article-buffer
3395 (gnus-fetch-field "X-PGP-Sig")))
3399 (mml2015-clear-verify-function))
3401 (insert-buffer-substring gnus-original-article-buffer)
3402 (setq items (split-string sig))
3403 (message-narrow-to-head)
3404 (let ((inhibit-point-motion-hooks t)
3405 (case-fold-search t))
3406 ;; Don't verify multiple headers.
3407 (setq headers (mapconcat (lambda (header)
3409 (mail-fetch-field header)
3411 (split-string (nth 1 items) ",") "")))
3412 (delete-region (point-min) (point-max))
3413 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3414 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3419 (if (looking-at "^-")
3422 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3423 (insert "Version: " (car items) "\n\n")
3424 (insert (mapconcat 'identity (cddr items) "\n"))
3425 (insert "\n-----END PGP SIGNATURE-----\n")
3426 (let ((mm-security-handle (list (format "multipart/signed"))))
3427 (mml2015-clean-buffer)
3428 (let ((coding-system-for-write (or gnus-newsgroup-charset
3430 (funcall (mml2015-clear-verify-function)))
3432 (or (mm-handle-multipart-ctl-parameter
3433 mm-security-handle 'gnus-details)
3434 (mm-handle-multipart-ctl-parameter
3435 mm-security-handle 'gnus-info)))))
3437 (let (buffer-read-only bface eface)
3439 (message-narrow-to-head)
3440 (goto-char (point-max))
3442 (setq bface (get-text-property (point-at-bol) 'face)
3443 eface (get-text-property (1- (point-at-eol)) 'face))
3444 (message-remove-header "X-Gnus-PGP-Verify")
3445 (if (re-search-forward "^X-PGP-Sig:" nil t)
3447 (goto-char (point-max)))
3448 (narrow-to-region (point) (point))
3449 (insert "X-Gnus-PGP-Verify: " info "\n")
3450 (goto-char (point-min))
3453 (if (not (looking-at "^[ \t]"))
3457 (goto-char (point-min))
3458 (when (looking-at "\\([^:]+\\): *")
3459 (put-text-property (match-beginning 1) (1+ (match-end 1))
3461 (put-text-property (match-end 0) (point-max)
3462 'face eface)))))))))
3464 (defun article-verify-cancel-lock ()
3465 "Verify Cancel-Lock header."
3467 (if (gnus-buffer-live-p gnus-original-article-buffer)
3468 (canlock-verify gnus-original-article-buffer)))
3475 (setq afunc (car func)
3478 gfunc (intern (format "gnus-%s" func))))
3480 (when (fboundp afunc)
3481 `(lambda (&optional interactive &rest args)
3482 ,(documentation afunc t)
3483 (interactive (list t))
3485 (set-buffer gnus-article-buffer)
3487 (call-interactively ',afunc)
3488 (apply ',afunc args))))))))
3489 '(article-hide-headers
3490 article-verify-x-pgp-sig
3491 article-verify-cancel-lock
3492 article-hide-boring-headers
3493 article-treat-overstrike
3494 article-treat-ansi-sequences
3495 article-fill-long-lines
3496 article-capitalize-sentences
3498 article-remove-leading-whitespace
3499 article-display-x-face
3500 article-display-face
3501 article-de-quoted-unreadable
3502 article-de-base64-unreadable
3505 article-unsplit-urls
3506 article-hide-list-identifiers
3507 article-strip-banner
3510 article-hide-signature
3511 article-strip-headers-in-body
3512 article-remove-trailing-blank-lines
3513 article-strip-leading-blank-lines
3514 article-strip-multiple-blank-lines
3515 article-strip-leading-space
3516 article-strip-trailing-space
3517 article-strip-blank-lines
3518 article-strip-all-blank-lines
3520 article-date-english
3521 article-date-iso8601
3522 article-date-original
3524 article-decode-mime-words
3525 article-decode-charset
3526 article-decode-encoded-words
3530 article-treat-dumbquotes
3531 article-normalize-headers
3532 ;; (article-show-all . gnus-article-show-all-headers)
3536 ;;; Gnus article mode
3539 (put 'gnus-article-mode 'mode-class 'special)
3541 (set-keymap-parent gnus-article-mode-map widget-keymap)
3543 (gnus-define-keys gnus-article-mode-map
3544 " " gnus-article-goto-next-page
3545 "\177" gnus-article-goto-prev-page
3546 [delete] gnus-article-goto-prev-page
3547 [backspace] gnus-article-goto-prev-page
3548 "\C-c^" gnus-article-refer-article
3549 "h" gnus-article-show-summary
3550 "s" gnus-article-show-summary
3551 "\C-c\C-m" gnus-article-mail
3552 "?" gnus-article-describe-briefly
3553 "e" gnus-summary-edit-article
3554 "<" beginning-of-buffer
3556 "\C-c\C-i" gnus-info-find-node
3558 "R" gnus-article-reply-with-original
3559 "F" gnus-article-followup-with-original
3560 "\C-hk" gnus-article-describe-key
3561 "\C-hc" gnus-article-describe-key-briefly
3563 "\C-d" gnus-article-read-summary-keys
3564 "\M-*" gnus-article-read-summary-keys
3565 "\M-#" gnus-article-read-summary-keys
3566 "\M-^" gnus-article-read-summary-keys
3567 "\M-g" gnus-article-read-summary-keys)
3569 (substitute-key-definition
3570 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3572 (defun gnus-article-make-menu-bar ()
3573 (unless (boundp 'gnus-article-commands-menu)
3574 (gnus-summary-make-menu-bar))
3575 (gnus-turn-off-edit-menu 'article)
3576 (unless (boundp 'gnus-article-article-menu)
3578 gnus-article-article-menu gnus-article-mode-map ""
3580 ["Scroll forwards" gnus-article-goto-next-page t]
3581 ["Scroll backwards" gnus-article-goto-prev-page t]
3582 ["Show summary" gnus-article-show-summary t]
3583 ["Fetch Message-ID at point" gnus-article-refer-article t]
3584 ["Mail to address at point" gnus-article-mail t]
3585 ["Send a bug report" gnus-bug t]))
3588 gnus-article-treatment-menu gnus-article-mode-map ""
3589 ;; Fixme: this should use :active (and maybe :visible).
3591 ["Hide headers" gnus-article-hide-headers t]
3592 ["Hide signature" gnus-article-hide-signature t]
3593 ["Hide citation" gnus-article-hide-citation t]
3594 ["Treat overstrike" gnus-article-treat-overstrike t]
3595 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3596 ["Remove carriage return" gnus-article-remove-cr t]
3597 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3598 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3599 ["Remove base64" gnus-article-de-base64-unreadable t]
3600 ["Treat html" gnus-article-wash-html t]
3601 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3602 ["Decode HZ" gnus-article-decode-HZ t]))
3604 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3606 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3608 (gnus-run-hooks 'gnus-article-menu-hook)))
3610 (defun gnus-article-mode ()
3611 "Major mode for displaying an article.
3613 All normal editing commands are switched off.
3615 The following commands are available in addition to all summary mode
3617 \\<gnus-article-mode-map>
3618 \\[gnus-article-next-page]\t Scroll the article one page forwards
3619 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3620 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3621 \\[gnus-article-show-summary]\t Display the summary buffer
3622 \\[gnus-article-mail]\t Send a reply to the address near point
3623 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3624 \\[gnus-info-find-node]\t Go to the Gnus info node"
3626 (gnus-simplify-mode-line)
3627 (setq mode-name "Article")
3628 (setq major-mode 'gnus-article-mode)
3629 (make-local-variable 'minor-mode-alist)
3630 (use-local-map gnus-article-mode-map)
3631 (when (gnus-visual-p 'article-menu 'menu)
3632 (gnus-article-make-menu-bar)
3633 (when gnus-summary-tool-bar-map
3634 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3635 (gnus-update-format-specifications nil 'article-mode)
3636 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3637 (set (make-local-variable 'gnus-page-broken) nil)
3638 (make-local-variable 'gnus-button-marker-list)
3639 (make-local-variable 'gnus-article-current-summary)
3640 (make-local-variable 'gnus-article-mime-handles)
3641 (make-local-variable 'gnus-article-decoded-p)
3642 (make-local-variable 'gnus-article-mime-handle-alist)
3643 (make-local-variable 'gnus-article-wash-types)
3644 (make-local-variable 'gnus-article-image-alist)
3645 (make-local-variable 'gnus-article-charset)
3646 (make-local-variable 'gnus-article-ignored-charsets)
3647 (gnus-set-default-directory)
3648 (buffer-disable-undo)
3649 (setq buffer-read-only t)
3650 (set-syntax-table gnus-article-mode-syntax-table)
3651 (mm-enable-multibyte)
3652 (gnus-run-hooks 'gnus-article-mode-hook))
3654 (defun gnus-article-setup-buffer ()
3655 "Initialize the article buffer."
3656 (let* ((name (if gnus-single-article-buffer "*Article*"
3657 (concat "*Article " gnus-newsgroup-name "*")))
3659 (progn (string-match "\\*Article" name)
3660 (concat " *Original Article"
3661 (substring name (match-end 0))))))
3662 (setq gnus-article-buffer name)
3663 (setq gnus-original-article-buffer original)
3664 (setq gnus-article-mime-handle-alist nil)
3665 ;; This might be a variable local to the summary buffer.
3666 (unless gnus-single-article-buffer
3668 (set-buffer gnus-summary-buffer)
3669 (setq gnus-article-buffer name)
3670 (setq gnus-original-article-buffer original)
3671 (gnus-set-global-variables)))
3672 (gnus-article-setup-highlight-words)
3673 ;; Init original article buffer.
3675 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3676 (mm-enable-multibyte)
3677 (setq major-mode 'gnus-original-article-mode)
3678 (make-local-variable 'gnus-original-article))
3679 (if (get-buffer name)
3682 (when (and gnus-article-edit-mode
3685 (y-or-n-p "Article mode edit in progress; discard? ")))
3686 (error "Action aborted"))
3687 (set (make-local-variable 'gnus-article-edit-mode) nil)
3688 (when gnus-article-mime-handles
3689 (mm-destroy-parts gnus-article-mime-handles)
3690 (setq gnus-article-mime-handles nil))
3691 ;; Set it to nil in article-buffer!
3692 (setq gnus-article-mime-handle-alist nil)
3693 (buffer-disable-undo)
3694 (setq buffer-read-only t)
3695 ;; This list just keeps growing if we don't reset it.
3696 (setq gnus-button-marker-list nil)
3697 (unless (eq major-mode 'gnus-article-mode)
3698 (gnus-article-mode))
3701 (set-buffer (gnus-get-buffer-create name))
3703 (make-local-variable 'gnus-summary-buffer)
3704 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3705 (current-buffer)))))
3707 ;; Set article window start at LINE, where LINE is the number of lines
3708 ;; from the head of the article.
3709 (defun gnus-article-set-window-start (&optional line)
3711 (gnus-get-buffer-window gnus-article-buffer t)
3713 (set-buffer gnus-article-buffer)
3714 (goto-char (point-min))
3717 (gnus-message 6 "Moved to bookmark")
3718 (search-forward "\n\n" nil t)
3722 (defun gnus-article-prepare (article &optional all-headers header)
3723 "Prepare ARTICLE in article mode buffer.
3724 ARTICLE should either be an article number or a Message-ID.
3725 If ARTICLE is an id, HEADER should be the article headers.
3726 If ALL-HEADERS is non-nil, no headers are hidden."
3728 ;; Make sure we start in a summary buffer.
3729 (unless (eq major-mode 'gnus-summary-mode)
3730 (set-buffer gnus-summary-buffer))
3731 (setq gnus-summary-buffer (current-buffer))
3732 (let* ((gnus-article (if header (mail-header-number header) article))
3733 (summary-buffer (current-buffer))
3734 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3735 (group gnus-newsgroup-name)
3738 (gnus-article-setup-buffer)
3739 (set-buffer gnus-article-buffer)
3740 ;; Deactivate active regions.
3741 (when (and (boundp 'transient-mark-mode)
3742 transient-mark-mode)
3743 (setq mark-active nil))
3744 (if (not (setq result (let ((buffer-read-only nil))
3745 (gnus-request-article-this-buffer
3747 ;; There is no such article.
3749 (when (and (numberp article)
3750 (not (memq article gnus-newsgroup-sparse)))
3751 (setq gnus-article-current
3752 (cons gnus-newsgroup-name article))
3753 (set-buffer gnus-summary-buffer)
3754 (setq gnus-current-article article)
3755 (if (and (memq article gnus-newsgroup-undownloaded)
3756 (not (gnus-online (gnus-find-method-for-group
3757 gnus-newsgroup-name))))
3759 (gnus-summary-set-agent-mark article)
3760 (message "Message marked for downloading"))
3761 (gnus-summary-mark-article article gnus-canceled-mark)
3762 (unless (memq article gnus-newsgroup-sparse)
3763 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3764 (if (or (eq result 'pseudo)
3765 (eq result 'nneething))
3768 (set-buffer summary-buffer)
3769 (push article gnus-newsgroup-history)
3770 (setq gnus-last-article gnus-current-article
3771 gnus-current-article 0
3772 gnus-current-headers nil
3773 gnus-article-current nil)
3774 (if (eq result 'nneething)
3775 (gnus-configure-windows 'summary)
3776 (gnus-configure-windows 'article))
3777 (gnus-set-global-variables))
3778 (let ((gnus-article-mime-handle-alist-1
3779 gnus-article-mime-handle-alist))
3780 (gnus-set-mode-line 'article)))
3781 ;; The result from the `request' was an actual article -
3782 ;; or at least some text that is now displayed in the
3784 (when (and (numberp article)
3785 (not (eq article gnus-current-article)))
3786 ;; Seems like a new article has been selected.
3787 ;; `gnus-current-article' must be an article number.
3789 (set-buffer summary-buffer)
3790 (push article gnus-newsgroup-history)
3791 (setq gnus-last-article gnus-current-article
3792 gnus-current-article article
3793 gnus-current-headers
3794 (gnus-summary-article-header gnus-current-article)
3795 gnus-article-current
3796 (cons gnus-newsgroup-name gnus-current-article))
3797 (unless (vectorp gnus-current-headers)
3798 (setq gnus-current-headers nil))
3799 (gnus-summary-goto-subject gnus-current-article)
3800 (when (gnus-summary-show-thread)
3801 ;; If the summary buffer really was folded, the
3802 ;; previous goto may not actually have gone to
3803 ;; the right article, but the thread root instead.
3805 (gnus-summary-goto-subject gnus-current-article))
3806 (gnus-run-hooks 'gnus-mark-article-hook)
3807 (gnus-set-mode-line 'summary)
3808 (when (gnus-visual-p 'article-highlight 'highlight)
3809 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3810 ;; Set the global newsgroup variables here.
3811 (gnus-set-global-variables)
3812 (setq gnus-have-all-headers
3813 (or all-headers gnus-show-all-headers))))
3815 (gnus-configure-windows 'article))
3816 (when (or (numberp article)
3818 (gnus-article-prepare-display)
3820 (goto-char (point-min))
3821 (when gnus-break-pages
3822 (gnus-narrow-to-page)))
3823 (let ((gnus-article-mime-handle-alist-1
3824 gnus-article-mime-handle-alist))
3825 (gnus-set-mode-line 'article))
3829 (set-window-point (get-buffer-window (current-buffer)) (point))
3830 (gnus-configure-windows 'article)
3834 (defun gnus-article-prepare-display ()
3835 "Make the current buffer look like a nice article."
3836 ;; Hooks for getting information from the article.
3837 ;; This hook must be called before being narrowed.
3838 (let ((gnus-article-buffer (current-buffer))
3840 (unless (eq major-mode 'gnus-article-mode)
3841 (gnus-article-mode))
3842 (setq buffer-read-only nil
3843 gnus-article-wash-types nil
3844 gnus-article-image-alist nil)
3845 (gnus-run-hooks 'gnus-tmp-internal-hook)
3846 (when gnus-display-mime-function
3847 (funcall gnus-display-mime-function))
3848 (gnus-run-hooks 'gnus-article-prepare-hook)))
3851 ;;; Gnus MIME viewing functions
3854 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3855 "Format of the MIME buttons.
3857 Valid specifiers include:
3859 %T MIME type, along with additional info
3860 %n The `name' parameter
3861 %d The description, if any
3862 %l The length of the encoded part
3863 %p The part identifier number
3864 %e Dots if the part isn't displayed
3866 General format specifiers can also be used. See Info node
3867 `(gnus)Formatting Variables'.")
3869 (defvar gnus-mime-button-line-format-alist
3870 '((?t gnus-tmp-type ?s)
3871 (?T gnus-tmp-type-long ?s)
3872 (?n gnus-tmp-name ?s)
3873 (?d gnus-tmp-description ?s)
3875 (?l gnus-tmp-length ?d)
3876 (?e gnus-tmp-dots ?s)))
3878 (defvar gnus-mime-button-commands
3879 '((gnus-article-press-button "\r" "Toggle Display")
3880 (gnus-mime-view-part "v" "View Interactively...")
3881 (gnus-mime-view-part-as-type "t" "View As Type...")
3882 (gnus-mime-view-part-as-charset "C" "View As charset...")
3883 (gnus-mime-save-part "o" "Save...")
3884 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3885 (gnus-mime-delete-part "d" "Delete part")
3886 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3887 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3888 (gnus-mime-view-part-internally "E" "View Internally")
3889 (gnus-mime-view-part-externally "e" "View Externally")
3890 (gnus-mime-print-part "p" "Print")
3891 (gnus-mime-pipe-part "|" "Pipe To Command...")
3892 (gnus-mime-action-on-part "." "Take action on the part...")))
3894 (defun gnus-article-mime-part-status ()
3895 (if gnus-article-mime-handle-alist-1
3896 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3898 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3901 (defvar gnus-mime-button-map
3902 (let ((map (make-sparse-keymap)))
3903 (define-key map gnus-mouse-2 'gnus-article-push-button)
3904 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3905 (dolist (c gnus-mime-button-commands)
3906 (define-key map (cadr c) (car c)))
3910 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3912 ,@(mapcar (lambda (c)
3913 (vector (caddr c) (car c) :enable t))
3914 gnus-mime-button-commands)))
3916 (defun gnus-mime-button-menu (event prefix)
3917 "Construct a context-sensitive menu of MIME commands."
3918 (interactive "e\nP")
3919 (save-window-excursion
3920 (let ((pos (event-start event)))
3921 (select-window (posn-window pos))
3922 (goto-char (posn-point pos))
3923 (gnus-article-check-buffer)
3924 (popup-menu gnus-mime-button-menu nil prefix))))
3926 (defun gnus-mime-view-all-parts (&optional handles)
3927 "View all the MIME parts."
3929 (with-current-buffer gnus-article-buffer
3930 (let ((handles (or handles gnus-article-mime-handles))
3931 (mail-parse-charset gnus-newsgroup-charset)
3932 (mail-parse-ignored-charsets
3933 (with-current-buffer gnus-summary-buffer
3934 gnus-newsgroup-ignored-charsets)))
3936 (mm-remove-parts handles)
3937 (goto-char (point-min))
3938 (or (search-forward "\n\n") (goto-char (point-max)))
3939 (let (buffer-read-only)
3940 (delete-region (point) (point-max))
3941 (mm-display-parts handles))))))
3943 (defun gnus-mime-save-part-and-strip ()
3944 "Save the MIME part under point then replace it with an external body."
3946 (gnus-article-check-buffer)
3947 (let* ((data (get-text-property (point) 'gnus-data))
3949 (handles gnus-article-mime-handles))
3950 (if (mm-multiple-handles gnus-article-mime-handles)
3951 (error "This function is not implemented"))
3952 (setq file (and data (mm-save-part data)))
3954 (with-current-buffer (mm-handle-buffer data)
3956 (insert "Content-Type: " (mm-handle-media-type data))
3957 (mml-insert-parameter-string (cdr (mm-handle-type data))
3960 (insert "Content-ID: " (message-make-message-id) "\n")
3961 (insert "Content-Transfer-Encoding: binary\n")
3964 (cdr (mm-make-handle nil
3965 `("message/external-body"
3966 (access-type . "LOCAL-FILE")
3968 (set-buffer gnus-summary-buffer)
3969 (gnus-article-edit-article
3972 (let ((mail-parse-charset (or gnus-article-charset
3973 ',gnus-newsgroup-charset))
3974 (mail-parse-ignored-charsets
3975 (or gnus-article-ignored-charsets
3976 ',gnus-newsgroup-ignored-charsets))
3977 (mbl mml-buffer-list))
3978 (setq mml-buffer-list nil)
3979 (insert-buffer gnus-original-article-buffer)
3980 (mime-to-mml ',handles)
3981 (setq gnus-article-mime-handles nil)
3982 (let ((mbl1 mml-buffer-list))
3983 (setq mml-buffer-list mbl)
3984 (set (make-local-variable 'mml-buffer-list) mbl1))
3985 (gnus-make-local-hook 'kill-buffer-hook)
3986 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3987 `(lambda (no-highlight)
3988 (let ((mail-parse-charset (or gnus-article-charset
3989 ',gnus-newsgroup-charset))
3990 (message-options message-options)
3991 (message-options-set-recipient)
3992 (mail-parse-ignored-charsets
3993 (or gnus-article-ignored-charsets
3994 ',gnus-newsgroup-ignored-charsets)))
3996 (mml-destroy-buffers)
3997 (remove-hook 'kill-buffer-hook
3998 'mml-destroy-buffers t)
3999 (kill-local-variable 'mml-buffer-list))
4000 (gnus-summary-edit-article-done
4001 ,(or (mail-header-references gnus-current-headers) "")
4002 ,(gnus-group-read-only-p)
4003 ,gnus-summary-buffer no-highlight))))))
4005 (defun gnus-mime-delete-part ()
4006 "Delete the MIME part under point.
4007 Replace it with some information about the removed part."
4009 (gnus-article-check-buffer)
4010 (unless (and gnus-novice-user
4011 (not (gnus-yes-or-no-p
4012 "Really delete attachment forever? ")))
4013 (let* ((data (get-text-property (point) 'gnus-data))
4014 (handles gnus-article-mime-handles)
4018 (mail-decode-encoded-word-string (or (mm-handle-description data)
4021 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4023 (type (mm-handle-media-type data)))
4024 (if (mm-multiple-handles gnus-article-mime-handles)
4025 (error "This function is not implemented"))
4026 (with-current-buffer (mm-handle-buffer data)
4027 (let ((bsize (format "%s" (buffer-size))))
4032 "| The following attachment has been deleted:\n"
4034 "| Type: " type "\n"
4035 "| Filename: " filename "\n"
4036 "| Size (encoded): " bsize " Byte\n"
4037 "| Description: " description "\n"
4040 (cdr (mm-make-handle
4041 nil `("text/plain") nil nil
4043 (format "Deleted attachment (%s bytes)" bsize))))))
4044 (set-buffer gnus-summary-buffer)
4045 ;; FIXME: maybe some of the following code (borrowed from
4046 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4047 (gnus-article-edit-article
4050 (let ((mail-parse-charset (or gnus-article-charset
4051 ',gnus-newsgroup-charset))
4052 (mail-parse-ignored-charsets
4053 (or gnus-article-ignored-charsets
4054 ',gnus-newsgroup-ignored-charsets))
4055 (mbl mml-buffer-list))
4056 (setq mml-buffer-list nil)
4057 (insert-buffer gnus-original-article-buffer)
4058 (mime-to-mml ',handles)
4059 (setq gnus-article-mime-handles nil)
4060 (let ((mbl1 mml-buffer-list))
4061 (setq mml-buffer-list mbl)
4062 (set (make-local-variable 'mml-buffer-list) mbl1))
4063 (gnus-make-local-hook 'kill-buffer-hook)
4064 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4065 `(lambda (no-highlight)
4066 (let ((mail-parse-charset (or gnus-article-charset
4067 ',gnus-newsgroup-charset))
4068 (message-options message-options)
4069 (message-options-set-recipient)
4070 (mail-parse-ignored-charsets
4071 (or gnus-article-ignored-charsets
4072 ',gnus-newsgroup-ignored-charsets)))
4074 (mml-destroy-buffers)
4075 (remove-hook 'kill-buffer-hook
4076 'mml-destroy-buffers t)
4077 (kill-local-variable 'mml-buffer-list))
4078 (gnus-summary-edit-article-done
4079 ,(or (mail-header-references gnus-current-headers) "")
4080 ,(gnus-group-read-only-p)
4081 ,gnus-summary-buffer no-highlight)))))
4082 ;; Not in `gnus-mime-save-part-and-strip':
4083 (gnus-article-edit-done)
4084 (gnus-summary-expand-window)
4085 (gnus-summary-show-article))
4087 (defun gnus-mime-save-part ()
4088 "Save the MIME part under point."
4090 (gnus-article-check-buffer)
4091 (let ((data (get-text-property (point) 'gnus-data)))
4093 (mm-save-part data))))
4095 (defun gnus-mime-pipe-part ()
4096 "Pipe the MIME part under point to a process."
4098 (gnus-article-check-buffer)
4099 (let ((data (get-text-property (point) 'gnus-data)))
4101 (mm-pipe-part data))))
4103 (defun gnus-mime-view-part ()
4104 "Interactively choose a viewing method for the MIME part under point."
4106 (gnus-article-check-buffer)
4107 (let ((data (get-text-property (point) 'gnus-data)))
4109 (setq gnus-article-mime-handles
4111 gnus-article-mime-handles (setq data (copy-sequence data))))
4112 (mm-interactively-view-part data))))
4114 (defun gnus-mime-view-part-as-type-internal ()
4115 (gnus-article-check-buffer)
4116 (let* ((name (mail-content-type-get
4117 (mm-handle-type (get-text-property (point) 'gnus-data))
4119 (def-type (and name (mm-default-file-encoding name))))
4120 (and def-type (cons def-type 0))))
4122 (defun gnus-mime-view-part-as-type (&optional mime-type)
4123 "Choose a MIME media type, and view the part as such."
4126 (setq mime-type (completing-read
4127 "View as MIME type: "
4128 (mapcar #'list (mailcap-mime-types))
4130 (gnus-mime-view-part-as-type-internal))))
4131 (gnus-article-check-buffer)
4132 (let ((handle (get-text-property (point) 'gnus-data)))
4135 (mm-make-handle (mm-handle-buffer handle)
4136 (cons mime-type (cdr (mm-handle-type handle)))
4137 (mm-handle-encoding handle)
4138 (mm-handle-undisplayer handle)
4139 (mm-handle-disposition handle)
4140 (mm-handle-description handle)
4142 (mm-handle-id handle)))
4143 (setq gnus-article-mime-handles
4144 (mm-merge-handles gnus-article-mime-handles handle))
4145 (gnus-mm-display-part handle))))
4148 (require 'jka-compr))
4150 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4151 ;; emacs can do that itself.
4153 (defun gnus-mime-jka-compr-maybe-uncompress ()
4154 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4155 The uncompress method used is derived from `buffer-file-name'."
4156 (when (and (fboundp 'jka-compr-installed-p)
4157 (jka-compr-installed-p))
4158 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4160 (let ((basename (file-name-nondirectory buffer-file-name))
4161 (args (jka-compr-info-uncompress-args info))
4162 (prog (jka-compr-info-uncompress-program info))
4163 (message (jka-compr-info-uncompress-message info))
4164 (err-file (jka-compr-make-temp-name)))
4166 (message "%s %s..." message basename))
4168 (unless (memq (apply 'call-process-region
4169 (point-min) (point-max)
4171 t (list t err-file) nil
4173 jka-compr-acceptable-retval-list)
4174 (jka-compr-error prog args basename message err-file))
4175 (jka-compr-delete-temp-file err-file)))))))
4177 (defun gnus-mime-copy-part (&optional handle)
4178 "Put the MIME part under point into a new buffer.
4179 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4182 (gnus-article-check-buffer)
4183 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4184 (contents (and handle (mm-get-part handle)))
4186 (file-name-nondirectory
4188 (mail-content-type-get (mm-handle-type handle) 'name)
4189 (mail-content-type-get (mm-handle-disposition handle)
4192 (buffer (and base (generate-new-buffer base))))
4194 (switch-to-buffer buffer)
4196 ;; We do it this way to make `normal-mode' set the appropriate mode.
4199 (setq buffer-file-name (expand-file-name base))
4200 (gnus-mime-jka-compr-maybe-uncompress)
4202 (setq buffer-file-name nil))
4203 (goto-char (point-min)))))
4205 (defun gnus-mime-print-part (&optional handle filename)
4206 "Print the MIME part under point."
4207 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4208 (gnus-article-check-buffer)
4209 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4210 (contents (and handle (mm-get-part handle)))
4211 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4212 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4217 (mm-save-part-to-file handle file)
4218 (call-process shell-file-name nil
4219 (generate-new-buffer " *mm*")
4221 shell-command-switch
4223 printer file (mm-handle-type handle))))
4227 (gnus-print-buffer))
4228 (ps-despool filename)))))
4230 (defun gnus-mime-inline-part (&optional handle arg)
4231 "Insert the MIME part under point into the current buffer."
4232 (interactive (list nil current-prefix-arg))
4233 (gnus-article-check-buffer)
4234 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4239 (if (and (not arg) (mm-handle-undisplayer handle))
4240 (mm-remove-part handle)
4241 (setq contents (mm-get-part handle))
4244 (setq charset (or (mail-content-type-get
4245 (mm-handle-type handle) 'charset)
4246 gnus-newsgroup-charset)))
4248 (if (mm-handle-undisplayer handle)
4249 (mm-remove-part handle))
4252 gnus-summary-show-article-charset-alist))
4253 (mm-read-coding-system "Charset: ")))))
4255 (mm-insert-inline handle
4257 (setq charset (mm-charset-to-coding-system
4259 (not (eq charset 'ascii)))
4260 (mm-decode-coding-string contents charset)
4264 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4265 "Insert the MIME part under point into the current buffer using the
4267 (interactive (list nil current-prefix-arg))
4268 (gnus-article-check-buffer)
4269 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4274 (if (mm-handle-undisplayer handle)
4275 (mm-remove-part handle))
4276 (let ((gnus-newsgroup-charset
4278 gnus-summary-show-article-charset-alist))
4279 (mm-read-coding-system "Charset: ")))
4280 (gnus-newsgroup-ignored-charsets 'gnus-all))
4281 (gnus-article-press-button)))))
4283 (defun gnus-mime-view-part-externally (&optional handle)
4284 "View the MIME part under point with an external viewer."
4286 (gnus-article-check-buffer)
4287 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4288 (mm-user-display-methods nil)
4289 (mm-inlined-types nil)
4290 (mail-parse-charset gnus-newsgroup-charset)
4291 (mail-parse-ignored-charsets
4292 (with-current-buffer gnus-summary-buffer
4293 gnus-newsgroup-ignored-charsets)))
4295 (if (mm-handle-undisplayer handle)
4296 (mm-remove-part handle)
4297 (mm-display-part handle)))))
4299 (defun gnus-mime-view-part-internally (&optional handle)
4300 "View the MIME part under point with an internal viewer.
4301 If no internal viewer is available, use an external viewer."
4303 (gnus-article-check-buffer)
4304 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4305 (mm-inlined-types '(".*"))
4306 (mm-inline-large-images t)
4307 (mail-parse-charset gnus-newsgroup-charset)
4308 (mail-parse-ignored-charsets
4309 (with-current-buffer gnus-summary-buffer
4310 gnus-newsgroup-ignored-charsets))
4313 (if (mm-handle-undisplayer handle)
4314 (mm-remove-part handle)
4315 (mm-display-part handle)))))
4317 (defun gnus-mime-action-on-part (&optional action)
4318 "Do something with the MIME attachment at \(point\)."
4320 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4321 (gnus-article-check-buffer)
4322 (let ((action-pair (assoc action gnus-mime-action-alist)))
4324 (funcall (cdr action-pair)))))
4326 (defun gnus-article-part-wrapper (n function)
4327 (with-current-buffer gnus-article-buffer
4328 (when (> n (length gnus-article-mime-handle-alist))
4329 (error "No such part"))
4330 (gnus-article-goto-part n)
4331 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4332 (funcall function handle))))
4334 (defun gnus-article-pipe-part (n)
4335 "Pipe MIME part N, which is the numerical prefix."
4337 (gnus-article-part-wrapper n 'mm-pipe-part))
4339 (defun gnus-article-save-part (n)
4340 "Save MIME part N, which is the numerical prefix."
4342 (gnus-article-part-wrapper n 'mm-save-part))
4344 (defun gnus-article-interactively-view-part (n)
4345 "View MIME part N interactively, which is the numerical prefix."
4347 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4349 (defun gnus-article-copy-part (n)
4350 "Copy MIME part N, which is the numerical prefix."
4352 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4354 (defun gnus-article-view-part-as-charset (n)
4355 "View MIME part N using a specified charset.
4356 N is the numerical prefix."
4358 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4360 (defun gnus-article-view-part-externally (n)
4361 "View MIME part N externally, which is the numerical prefix."
4363 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4365 (defun gnus-article-inline-part (n)
4366 "Inline MIME part N, which is the numerical prefix."
4368 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4370 (defun gnus-article-mime-match-handle-first (condition)
4372 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4373 (while (setq ihandle (pop alist))
4375 ((functionp condition)
4376 (funcall condition (cdr ihandle)))
4377 ((eq condition 'undisplayed)
4378 (not (or (mm-handle-undisplayer (cdr ihandle))
4379 (equal (mm-handle-media-type (cdr ihandle))
4380 "multipart/alternative"))))
4381 ((eq condition 'undisplayed-alternative)
4382 (not (mm-handle-undisplayer (cdr ihandle))))
4384 (gnus-article-goto-part (car ihandle))
4385 (or (not n) (< (car ihandle) n)))
4386 (setq n (car ihandle))))
4390 (defun gnus-article-view-part (&optional n)
4391 "View MIME part N, which is the numerical prefix."
4393 (with-current-buffer gnus-article-buffer
4394 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4395 gnus-article-mime-match-handle-function)))
4396 (when (> n (length gnus-article-mime-handle-alist))
4397 (error "No such part"))
4398 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4399 (when (gnus-article-goto-part n)
4400 (if (equal (car handle) "multipart/alternative")
4401 (gnus-article-press-button)
4402 (when (eq (gnus-mm-display-part handle) 'internal)
4403 (gnus-set-window-start)))))))
4405 (defsubst gnus-article-mime-total-parts ()
4406 (if (bufferp (car gnus-article-mime-handles))
4408 (1- (length gnus-article-mime-handles))))
4410 (defun gnus-mm-display-part (handle)
4411 "Display HANDLE and fix MIME button."
4412 (let ((id (get-text-property (point) 'gnus-part))
4417 (let ((window (selected-window))
4418 (mail-parse-charset gnus-newsgroup-charset)
4419 (mail-parse-ignored-charsets
4420 (if (gnus-buffer-live-p gnus-summary-buffer)
4421 (with-current-buffer gnus-summary-buffer
4422 gnus-newsgroup-ignored-charsets)
4426 (let ((win (gnus-get-buffer-window (current-buffer) t))
4429 (select-window win))
4432 (if (mm-handle-displayed-p handle)
4433 ;; This will remove the part.
4434 (mm-display-part handle)
4436 (narrow-to-region (point)
4437 (if (eobp) (point) (1+ (point))))
4438 (mm-display-part handle)
4439 ;; We narrow to the part itself and
4440 ;; then call the treatment functions.
4441 (goto-char (point-min))
4443 (narrow-to-region (point) (point-max))
4446 (gnus-article-mime-total-parts)
4447 (mm-handle-media-type handle)))))
4448 (if (window-live-p window)
4449 (select-window window)))))
4452 (gnus-insert-mime-button
4453 handle id (list (mm-handle-displayed-p handle)))
4454 (goto-char point))))
4456 (defun gnus-article-goto-part (n)
4457 "Go to MIME part N."
4458 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4460 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4461 (let ((gnus-tmp-name
4462 (or (mail-content-type-get (mm-handle-type handle) 'name)
4463 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4464 (mail-content-type-get (mm-handle-type handle) 'url)
4466 (gnus-tmp-type (mm-handle-media-type handle))
4467 (gnus-tmp-description
4468 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4471 (if (if displayed (car displayed)
4472 (mm-handle-displayed-p handle))
4474 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4476 gnus-tmp-type-long b e)
4477 (when (string-match ".*/" gnus-tmp-name)
4478 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4479 (setq gnus-tmp-type-long (concat gnus-tmp-type
4480 (and (not (equal gnus-tmp-name ""))
4481 (concat "; " gnus-tmp-name))))
4482 (unless (equal gnus-tmp-description "")
4483 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4488 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4489 `(keymap ,gnus-mime-button-map
4490 gnus-callback gnus-mm-display-part
4491 gnus-part ,gnus-tmp-id
4492 article-type annotation
4495 ;; Exclude a newline.
4498 (widget-convert-button
4501 :action 'gnus-widget-press-button
4502 :button-keymap gnus-mime-button-map
4504 (lambda (widget/window &optional overlay pos)
4505 ;; Needed to properly clear the message due to a bug in
4506 ;; wid-edit (XEmacs only).
4507 (if (boundp 'help-echo-owns-message)
4508 (setq help-echo-owns-message t))
4510 "%S: %s the MIME part; %S: more options"
4511 (aref gnus-mouse-2 0)
4512 ;; XEmacs will get a single widget arg; Emacs 21 will get
4513 ;; window, overlay, position.
4514 (if (mm-handle-displayed-p
4516 (with-current-buffer (gnus-overlay-buffer overlay)
4517 (widget-get (widget-at (gnus-overlay-start overlay))
4519 (widget-get widget/window :mime-handle)))
4521 (aref gnus-down-mouse-3 0))))))
4523 (defun gnus-widget-press-button (elems el)
4524 (goto-char (widget-get elems :from))
4525 (gnus-article-press-button))
4527 (defvar gnus-displaying-mime nil)
4529 (defun gnus-display-mime (&optional ihandles)
4530 "Display the MIME parts."
4532 (save-selected-window
4533 (let ((window (get-buffer-window gnus-article-buffer))
4536 (select-window window)
4537 ;; We have to do this since selecting the window
4538 ;; may change the point. So we set the window point.
4539 (set-window-point window point)))
4540 (let* ((handles (or ihandles
4541 (mm-dissect-buffer nil gnus-article-loose-mime)
4542 (and gnus-article-emulate-mime
4544 buffer-read-only handle name type b e display)
4545 (when (and (not ihandles)
4546 (not gnus-displaying-mime))
4547 ;; Top-level call; we clean up.
4548 (when gnus-article-mime-handles
4549 (mm-destroy-parts gnus-article-mime-handles)
4550 (setq gnus-article-mime-handle-alist nil));; A trick.
4551 (setq gnus-article-mime-handles handles)
4552 ;; We allow users to glean info from the handles.
4553 (when gnus-article-mime-part-function
4554 (gnus-mime-part-function handles)))
4556 (or (not (stringp (car handles)))
4559 (when (and (not ihandles)
4560 (not gnus-displaying-mime))
4561 ;; Clean up for mime parts.
4563 (delete-region (point) (point-max)))
4564 (let ((gnus-displaying-mime t))
4565 (gnus-mime-display-part handles)))
4568 (narrow-to-region (point) (point-max))
4569 (gnus-treat-article nil 1 1)
4572 ;; Highlight the headers.
4576 (narrow-to-region (point-min) (point))
4577 (gnus-treat-article 'head))))))))
4579 (defcustom gnus-mime-display-multipart-as-mixed nil
4580 "Display \"multipart\" parts as \"multipart/mixed\".
4582 If t, it overrides nil values of
4583 `gnus-mime-display-multipart-alternative-as-mixed' and
4584 `gnus-mime-display-multipart-related-as-mixed'."
4585 :group 'gnus-article-mime
4588 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4589 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4590 :group 'gnus-article-mime
4593 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4594 "Display \"multipart/related\" parts as \"multipart/mixed\".
4596 If displaying \"text/html\" is discouraged \(see
4597 `mm-discouraged-alternatives'\) images or other material inside a
4598 \"multipart/related\" part might be overlooked when this variable is nil."
4599 :group 'gnus-article-mime
4602 (defun gnus-mime-display-part (handle)
4605 ((not (stringp (car handle)))
4606 (gnus-mime-display-single handle))
4607 ;; User-defined multipart
4608 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4609 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4611 ;; multipart/alternative
4612 ((and (equal (car handle) "multipart/alternative")
4613 (not (or gnus-mime-display-multipart-as-mixed
4614 gnus-mime-display-multipart-alternative-as-mixed)))
4615 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4616 (push (cons id handle) gnus-article-mime-handle-alist)
4617 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4618 ;; multipart/related
4619 ((and (equal (car handle) "multipart/related")
4620 (not (or gnus-mime-display-multipart-as-mixed
4621 gnus-mime-display-multipart-related-as-mixed)))
4622 ;;;!!!We should find the start part, but we just default
4623 ;;;!!!to the first part.
4624 ;;(gnus-mime-display-part (cadr handle))
4625 ;;;!!! Most multipart/related is an HTML message plus images.
4626 ;;;!!! Unfortunately we are unable to let W3 display those
4627 ;;;!!! included images, so we just display it as a mixed multipart.
4628 ;;(gnus-mime-display-mixed (cdr handle))
4629 ;;;!!! No, w3 can display everything just fine.
4630 (gnus-mime-display-part (cadr handle)))
4631 ((equal (car handle) "multipart/signed")
4632 (gnus-add-wash-type 'signed)
4633 (gnus-mime-display-security handle))
4634 ((equal (car handle) "multipart/encrypted")
4635 (gnus-add-wash-type 'encrypted)
4636 (gnus-mime-display-security handle))
4637 ;; Other multiparts are handled like multipart/mixed.
4639 (gnus-mime-display-mixed (cdr handle)))))
4641 (defun gnus-mime-part-function (handles)
4642 (if (stringp (car handles))
4643 (mapcar 'gnus-mime-part-function (cdr handles))
4644 (funcall gnus-article-mime-part-function handles)))
4646 (defun gnus-mime-display-mixed (handles)
4647 (mapcar 'gnus-mime-display-part handles))
4649 (defun gnus-mime-display-single (handle)
4650 (let ((type (mm-handle-media-type handle))
4651 (ignored gnus-ignored-mime-types)
4658 (when (string-match (pop ignored) type)
4659 (throw 'ignored nil)))
4660 (if (and (setq not-attachment
4661 (and (not (mm-inline-override-p handle))
4662 (or (not (mm-handle-disposition handle))
4663 (equal (car (mm-handle-disposition handle))
4665 (mm-attachment-override-p handle))))
4666 (mm-automatic-display-p handle)
4668 (mm-inlinable-p handle)
4669 (mm-inlined-p handle))
4670 (mm-automatic-external-display-p type)))
4672 (when (equal (mm-handle-media-supertype handle) "text")
4674 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4676 (push (cons id handle) gnus-article-mime-handle-alist)
4677 (when (or (not display)
4678 (not (gnus-unbuttonized-mime-type-p type)))
4679 ;(gnus-article-insert-newline)
4680 (gnus-insert-mime-button
4681 handle id (list (or display (and not-attachment text))))
4682 (gnus-article-insert-newline)
4683 ;(gnus-article-insert-newline)
4684 ;; Remember modify the number of forward lines.
4692 (let ((mail-parse-charset gnus-newsgroup-charset)
4693 (mail-parse-ignored-charsets
4694 (save-excursion (condition-case ()
4695 (set-buffer gnus-summary-buffer)
4697 gnus-newsgroup-ignored-charsets)))
4698 (mm-display-part handle t))
4699 (goto-char (point-max)))
4700 ((and text not-attachment)
4704 (gnus-article-insert-newline)
4705 (mm-insert-inline handle (mm-get-part handle))
4706 (goto-char (point-max))))
4710 (narrow-to-region beg (point))
4713 (gnus-article-mime-total-parts)
4714 (mm-handle-media-type handle)))))))))
4716 (defun gnus-unbuttonized-mime-type-p (type)
4717 "Say whether TYPE is to be unbuttonized."
4718 (unless gnus-inhibit-mime-unbuttonizing
4720 (let ((types gnus-unbuttonized-mime-types))
4722 (when (string-match (pop types) type)
4723 (throw 'found t)))))
4725 (let ((types gnus-buttonized-mime-types))
4727 (when (string-match (pop types) type)
4728 (throw 'found t)))))))))
4730 (defun gnus-article-insert-newline ()
4731 "Insert a newline, but mark it as undeletable."
4732 (gnus-put-text-property
4733 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4735 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4736 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4739 handle buffer-read-only from props begend not-pref)
4740 (save-window-excursion
4743 (narrow-to-region (car ibegend)
4746 (goto-char (car ibegend))
4749 (delete-region (point-min) (point-max))
4750 (mm-remove-parts handles))
4751 (setq begend (list (point-marker)))
4753 (unless (setq not-pref (cadr (member preferred ihandles)))
4754 (setq not-pref (car ihandles)))
4757 (not (gnus-unbuttonized-mime-type-p
4758 "multipart/alternative")))
4759 (gnus-add-text-properties
4762 (insert (format "%d. " id))
4766 (unless ,(not ibegend)
4767 (setq gnus-article-mime-handle-alist
4768 ',gnus-article-mime-handle-alist))
4769 (gnus-mime-display-alternative
4770 ',ihandles ',not-pref ',begend ,id))
4771 keymap ,gnus-mime-button-map
4772 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4773 face ,gnus-article-button-face
4776 (widget-convert-button 'link from (point)
4777 :action 'gnus-widget-press-button
4778 :button-keymap gnus-widget-button-keymap)
4780 (while (setq handle (pop handles))
4781 (gnus-add-text-properties
4784 (insert (format "(%c) %-18s"
4785 (if (equal handle preferred) ?* ? )
4786 (mm-handle-media-type handle)))
4790 (unless ,(not ibegend)
4791 (setq gnus-article-mime-handle-alist
4792 ',gnus-article-mime-handle-alist))
4793 (gnus-mime-display-alternative
4794 ',ihandles ',handle ',begend ,id))
4795 keymap ,gnus-mime-button-map
4796 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4797 face ,gnus-article-button-face
4800 (widget-convert-button 'link from (point)
4801 :action 'gnus-widget-press-button
4802 :button-keymap gnus-widget-button-keymap)
4806 (if (stringp (car preferred))
4807 (gnus-display-mime preferred)
4808 (let ((mail-parse-charset gnus-newsgroup-charset)
4809 (mail-parse-ignored-charsets
4810 (with-current-buffer gnus-summary-buffer
4811 gnus-newsgroup-ignored-charsets)))
4812 (mm-display-part preferred)
4816 (narrow-to-region (car begend) (point-max))
4818 nil (length gnus-article-mime-handle-alist)
4819 (gnus-article-mime-total-parts)
4820 (mm-handle-media-type handle))))))
4821 (goto-char (point-max))
4822 (setcdr begend (point-marker)))))
4824 (goto-char point))))
4826 (defconst gnus-article-wash-status-strings
4827 (let ((alist '((cite "c" "Possible hidden citation text"
4828 " " "All citation text visible")
4829 (headers "h" "Hidden headers"
4830 " " "All headers visible.")
4831 (pgp "p" "Encrypted or signed message status hidden"
4832 " " "No hidden encryption nor digital signature status")
4833 (signature "s" "Signature has been hidden"
4834 " " "Signature is visible")
4835 (overstrike "o" "Overstrike (^H) characters applied"
4836 " " "No overstrike characters applied")
4837 (emphasis "e" "/*_Emphasis_*/ characters applied"
4838 " " "No /*_emphasis_*/ characters applied")))
4840 (dolist (entry alist result)
4841 (let ((key (nth 0 entry))
4842 (on (copy-sequence (nth 1 entry)))
4843 (on-help (nth 2 entry))
4844 (off (copy-sequence (nth 3 entry)))
4845 (off-help (nth 4 entry)))
4846 (put-text-property 0 1 'help-echo on-help on)
4847 (put-text-property 0 1 'help-echo off-help off)
4848 (push (list key on off) result))))
4849 "Alist of strings describing wash status in the mode line.
4850 Each entry has the form (KEY ON OF), where the KEY is a symbol
4851 representing the particular washing function, ON is the string to use
4852 in the article mode line when the washing function is active, and OFF
4853 is the string to use when it is inactive.")
4855 (defun gnus-article-wash-status-entry (key value)
4856 (let ((entry (assoc key gnus-article-wash-status-strings)))
4857 (if value (nth 1 entry) (nth 2 entry))))
4859 (defun gnus-article-wash-status ()
4860 "Return a string which display status of article washing."
4861 (with-current-buffer gnus-article-buffer
4862 (let ((cite (memq 'cite gnus-article-wash-types))
4863 (headers (memq 'headers gnus-article-wash-types))
4864 (boring (memq 'boring-headers gnus-article-wash-types))
4865 (pgp (memq 'pgp gnus-article-wash-types))
4866 (pem (memq 'pem gnus-article-wash-types))
4867 (signed (memq 'signed gnus-article-wash-types))
4868 (encrypted (memq 'encrypted gnus-article-wash-types))
4869 (signature (memq 'signature gnus-article-wash-types))
4870 (overstrike (memq 'overstrike gnus-article-wash-types))
4871 (emphasis (memq 'emphasis gnus-article-wash-types)))
4873 (gnus-article-wash-status-entry 'cite cite)
4874 (gnus-article-wash-status-entry 'headers (or headers boring))
4875 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4876 (gnus-article-wash-status-entry 'signature signature)
4877 (gnus-article-wash-status-entry 'overstrike overstrike)
4878 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4880 (defun gnus-add-wash-type (type)
4881 "Add a washing of TYPE to the current status."
4882 (add-to-list 'gnus-article-wash-types type))
4884 (defun gnus-delete-wash-type (type)
4885 "Add a washing of TYPE to the current status."
4886 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4888 (defun gnus-add-image (category image)
4889 "Add IMAGE of CATEGORY to the list of displayed images."
4890 (let ((entry (assq category gnus-article-image-alist)))
4892 (setq entry (list category))
4893 (push entry gnus-article-image-alist))
4894 (nconc entry (list image))))
4896 (defun gnus-delete-images (category)
4897 "Delete all images in CATEGORY."
4898 (let ((entry (assq category gnus-article-image-alist)))
4899 (dolist (image (cdr entry))
4900 (gnus-remove-image image category))
4901 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4902 (gnus-delete-wash-type category)))
4904 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4906 (defun gnus-article-maybe-hide-headers ()
4907 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4908 Provided for backwards compatibility."
4909 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4910 (not (with-current-buffer gnus-summary-buffer
4911 gnus-have-all-headers)))
4912 (not gnus-inhibit-hiding))
4913 (gnus-article-hide-headers)))
4917 (defun gnus-output-to-file (file-name)
4918 "Append the current article to a file named FILE-NAME."
4919 (let ((artbuf (current-buffer)))
4921 (insert-buffer-substring artbuf)
4922 ;; Append newline at end of the buffer as separator, and then
4924 (goto-char (point-max))
4926 (let ((file-name-coding-system nnmail-pathname-coding-system))
4927 (mm-append-to-file (point-min) (point-max) file-name))
4930 (defun gnus-narrow-to-page (&optional arg)
4931 "Narrow the article buffer to a page.
4932 If given a numerical ARG, move forward ARG pages."
4934 (setq arg (if arg (prefix-numeric-value arg) 0))
4936 (set-buffer gnus-article-buffer)
4937 (goto-char (point-min))
4939 ;; Remove any old next/prev buttons.
4940 (when (gnus-visual-p 'page-marker)
4941 (let ((buffer-read-only nil))
4942 (gnus-remove-text-with-property 'gnus-prev)
4943 (gnus-remove-text-with-property 'gnus-next)))
4946 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4948 (re-search-forward page-delimiter nil 'move arg)))
4949 (goto-char (match-end 0))
4951 (goto-char (point-min))
4952 (setq gnus-page-broken
4953 (and (re-search-forward page-delimiter nil t) t))))
4954 (when gnus-page-broken
4957 (if (re-search-forward page-delimiter nil 'move)
4960 (when (and (gnus-visual-p 'page-marker)
4961 (not (= (point-min) 1)))
4963 (goto-char (point-min))
4964 (gnus-insert-prev-page-button)))
4965 (when (and (gnus-visual-p 'page-marker)
4966 (< (+ (point-max) 2) (buffer-size)))
4968 (goto-char (point-max))
4969 (gnus-insert-next-page-button))))))
4971 ;; Article mode commands
4973 (defun gnus-article-goto-next-page ()
4974 "Show the next page of the article."
4976 (when (gnus-article-next-page)
4977 (goto-char (point-min))
4978 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4981 (defun gnus-article-goto-prev-page ()
4982 "Show the previous page of the article."
4985 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4986 (gnus-article-prev-page nil)))
4988 ;; This is cleaner but currently breaks `gnus-pick-mode':
4990 ;; (defun gnus-article-goto-next-page ()
4991 ;; "Show the next page of the article."
4993 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4994 ;; (gnus-summary-next-page)))
4996 ;; (defun gnus-article-goto-prev-page ()
4997 ;; "Show the next page of the article."
4999 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5000 ;; (gnus-summary-prev-page)))
5002 (defun gnus-article-next-page (&optional lines)
5003 "Show the next page of the current article.
5004 If end of article, return non-nil. Otherwise return nil.
5005 Argument LINES specifies lines to be scrolled up."
5007 (move-to-window-line -1)
5010 (and (pos-visible-in-window-p) ;Not continuation line.
5011 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5012 ;; Nothing in this page.
5013 (if (or (not gnus-page-broken)
5017 (eobp)))) ;Real end-of-buffer?
5019 (when gnus-article-over-scroll
5020 (gnus-article-next-page-1 lines))
5022 (gnus-narrow-to-page 1) ;Go to next page.
5024 ;; More in this page.
5025 (gnus-article-next-page-1 lines)
5028 (defun gnus-article-next-page-1 (lines)
5029 (let ((scroll-in-place nil))
5033 ;; Long lines may cause an end-of-buffer error.
5034 (goto-char (point-max)))))
5035 (move-to-window-line 0))
5037 (defun gnus-article-prev-page (&optional lines)
5038 "Show previous page of current article.
5039 Argument LINES specifies lines to be scrolled down."
5041 (move-to-window-line 0)
5042 (if (and gnus-page-broken
5044 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5046 (gnus-narrow-to-page -1) ;Go to previous page.
5047 (goto-char (point-max))
5049 (let ((scroll-in-place nil))
5053 (beginning-of-buffer
5054 (goto-char (point-min))))
5055 (move-to-window-line 0)))))
5057 (defun gnus-article-only-boring-p ()
5058 "Decide whether there is only boring text remaining in the article.
5059 Something \"interesting\" is a word of at least two letters that does
5060 not have a face in `gnus-article-boring-faces'."
5061 (when (and gnus-article-skip-boring
5062 (boundp 'gnus-article-boring-faces)
5063 (symbol-value 'gnus-article-boring-faces))
5066 (while (re-search-forward "\\b\\w\\w" nil t)
5068 (when (not (gnus-intersection
5069 (gnus-faces-at (point))
5070 (symbol-value 'gnus-article-boring-faces)))
5071 (throw 'only-boring nil)))
5072 (throw 'only-boring t)))))
5074 (defun gnus-article-refer-article ()
5075 "Read article specified by message-id around point."
5078 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5079 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5080 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5081 (let ((msg-id (concat "<" (match-string 0) ">")))
5082 (set-buffer gnus-summary-buffer)
5083 (gnus-summary-refer-article msg-id))
5084 (error "No references around point"))))
5086 (defun gnus-article-show-summary ()
5087 "Reconfigure windows to show summary buffer."
5089 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5090 (error "There is no summary buffer for this article buffer")
5091 (gnus-article-set-globals)
5092 (gnus-configure-windows 'article)
5093 (gnus-summary-goto-subject gnus-current-article)
5094 (gnus-summary-position-point)))
5096 (defun gnus-article-describe-briefly ()
5097 "Describe article mode commands briefly."
5099 (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")))
5101 (defun gnus-article-summary-command ()
5102 "Execute the last keystroke in the summary buffer."
5104 (let ((obuf (current-buffer))
5105 (owin (current-window-configuration))
5107 (switch-to-buffer gnus-article-current-summary 'norecord)
5108 (setq func (lookup-key (current-local-map) (this-command-keys)))
5109 (call-interactively func)
5111 (set-window-configuration owin)
5112 (set-window-point (get-buffer-window (current-buffer)) (point))))
5114 (defun gnus-article-summary-command-nosave ()
5115 "Execute the last keystroke in the summary buffer."
5118 (pop-to-buffer gnus-article-current-summary 'norecord)
5119 (setq func (lookup-key (current-local-map) (this-command-keys)))
5120 (call-interactively func)))
5122 (defun gnus-article-check-buffer ()
5123 "Beep if not in an article buffer."
5124 (unless (equal major-mode 'gnus-article-mode)
5125 (error "Command invoked outside of a Gnus article buffer")))
5127 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5128 "Read a summary buffer key sequence and execute it from the article buffer."
5130 (gnus-article-check-buffer)
5132 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5133 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5134 "=" "^" "\M-^" "|"))
5140 '("n" "Gn" "p" "Gp"))
5143 (set-buffer gnus-article-current-summary)
5144 (let (gnus-pick-mode)
5145 (push (or key last-command-event) unread-command-events)
5146 (setq keys (if (featurep 'xemacs)
5147 (events-to-keys (read-key-sequence nil))
5148 (read-key-sequence nil)))))
5152 (if (or (member keys nosaves)
5153 (member keys nosave-but-article)
5154 (member keys nosave-in-article))
5156 (save-window-excursion
5157 (pop-to-buffer gnus-article-current-summary 'norecord)
5158 ;; We disable the pick minor mode commands.
5159 (let (gnus-pick-mode)
5160 (setq func (lookup-key (current-local-map) keys))))
5164 (unless (member keys nosave-in-article)
5165 (set-buffer gnus-article-current-summary))
5166 (call-interactively func)
5167 (setq new-sum-point (point)))
5168 (when (member keys nosave-but-article)
5169 (pop-to-buffer gnus-article-buffer 'norecord)))
5170 ;; These commands should restore window configuration.
5171 (let ((obuf (current-buffer))
5172 (owin (current-window-configuration))
5174 (summary gnus-article-current-summary)
5175 func in-buffer selected)
5176 (if not-restore-window
5177 (pop-to-buffer summary 'norecord)
5178 (switch-to-buffer summary 'norecord))
5179 (setq in-buffer (current-buffer))
5180 ;; We disable the pick minor mode commands.
5181 (if (and (setq func (let (gnus-pick-mode)
5182 (lookup-key (current-local-map) keys)))
5185 (call-interactively func)
5186 (setq new-sum-point (point))
5187 (when (eq in-buffer (current-buffer))
5188 (setq selected (gnus-summary-select-article))
5190 (unless not-restore-window
5191 (set-window-configuration owin))
5192 (when (eq selected 'old)
5194 (set-window-start (get-buffer-window (current-buffer))
5196 (set-window-point (get-buffer-window (current-buffer))
5198 (let ((win (get-buffer-window gnus-article-current-summary)))
5200 (set-window-point win new-sum-point)))) )
5201 (switch-to-buffer gnus-article-buffer)
5204 (defun gnus-article-describe-key (key)
5205 "Display documentation of the function invoked by KEY. KEY is a string."
5206 (interactive "kDescribe key: ")
5207 (gnus-article-check-buffer)
5208 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5210 (set-buffer gnus-article-current-summary)
5211 (let (gnus-pick-mode)
5212 (if (featurep 'xemacs)
5214 (push (elt key 0) unread-command-events)
5215 (setq key (events-to-keys
5216 (read-key-sequence "Describe key: "))))
5217 (setq unread-command-events
5219 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5220 (string-to-list key)))
5221 (setq key (read-key-sequence "Describe key: "))))
5223 (describe-key key)))
5225 (defun gnus-article-describe-key-briefly (key &optional insert)
5226 "Display documentation of the function invoked by KEY. KEY is a string."
5227 (interactive "kDescribe key: \nP")
5228 (gnus-article-check-buffer)
5229 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5231 (set-buffer gnus-article-current-summary)
5232 (let (gnus-pick-mode)
5233 (if (featurep 'xemacs)
5235 (push (elt key 0) unread-command-events)
5236 (setq key (events-to-keys
5237 (read-key-sequence "Describe key: "))))
5238 (setq unread-command-events
5240 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5241 (string-to-list key)))
5242 (setq key (read-key-sequence "Describe key: "))))
5243 (describe-key-briefly key insert))
5244 (describe-key-briefly key insert)))
5246 (defun gnus-article-reply-with-original (&optional wide)
5247 "Start composing a reply mail to the current message.
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-reply (list (list article)) wide))
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
5263 (list (list article contents)) wide)))))
5265 (defun gnus-article-followup-with-original ()
5266 "Compose a followup to the current article.
5267 The text in the region will be yanked. If the region isn't active,
5268 the entire article will be yanked."
5270 (let ((article (cdr gnus-article-current))
5272 (if (not (gnus-mark-active-p))
5273 (with-current-buffer gnus-summary-buffer
5274 (gnus-summary-followup (list (list article))))
5275 (setq contents (buffer-substring (point) (mark t)))
5276 ;; Deactivate active regions.
5277 (when (and (boundp 'transient-mark-mode)
5278 transient-mark-mode)
5279 (setq mark-active nil))
5280 (with-current-buffer gnus-summary-buffer
5281 (gnus-summary-followup
5282 (list (list article contents)))))))
5284 (defun gnus-article-hide (&optional arg force)
5285 "Hide all the gruft in the current article.
5286 This means that signatures, cited text and (some) headers will be
5288 If given a prefix, show the hidden text instead."
5289 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5290 (gnus-article-hide-headers arg)
5291 (gnus-article-hide-list-identifiers arg)
5292 (gnus-article-hide-citation-maybe arg force)
5293 (gnus-article-hide-signature arg))
5295 (defun gnus-article-maybe-highlight ()
5296 "Do some article highlighting if article highlighting is requested."
5297 (when (gnus-visual-p 'article-highlight 'highlight)
5298 (gnus-article-highlight-some)))
5300 (defun gnus-check-group-server ()
5301 ;; Make sure the connection to the server is alive.
5302 (unless (gnus-server-opened
5303 (gnus-find-method-for-group gnus-newsgroup-name))
5304 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5305 (gnus-request-group gnus-newsgroup-name t)))
5308 (autoload 'nneething-get-file-name "nneething"))
5310 (defun gnus-request-article-this-buffer (article group)
5311 "Get an article and insert it into this buffer."
5312 (let (do-update-line sparse-header)
5316 (gnus-kill-all-overlays)
5317 (setq group (or group gnus-newsgroup-name))
5319 ;; Using `gnus-request-article' directly will insert the article into
5320 ;; `nntp-server-buffer' - so we'll save some time by not having to
5321 ;; copy it from the server buffer into the article buffer.
5323 ;; We only request an article by message-id when we do not have the
5324 ;; headers for it, so we'll have to get those.
5325 (when (stringp article)
5326 (gnus-read-header article))
5328 ;; If the article number is negative, that means that this article
5329 ;; doesn't belong in this newsgroup (possibly), so we find its
5330 ;; message-id and request it by id instead of number.
5331 (when (and (numberp article)
5333 (get-buffer gnus-summary-buffer)
5334 (gnus-buffer-exists-p gnus-summary-buffer))
5336 (set-buffer gnus-summary-buffer)
5337 (let ((header (gnus-summary-article-header article)))
5340 ((memq article gnus-newsgroup-sparse)
5341 ;; This is a sparse gap article.
5342 (setq do-update-line article)
5343 (setq article (mail-header-id header))
5344 (setq sparse-header (gnus-read-header article))
5345 (setq gnus-newsgroup-sparse
5346 (delq article gnus-newsgroup-sparse)))
5348 ;; It's a real article.
5349 (setq article (mail-header-id header)))
5351 ;; It is an extracted pseudo-article.
5352 (setq article 'pseudo)
5353 (gnus-request-pseudo-article header))))
5355 (let ((method (gnus-find-method-for-group
5356 gnus-newsgroup-name)))
5357 (when (and (eq (car method) 'nneething)
5359 (let ((dir (nneething-get-file-name
5360 (mail-header-id header))))
5361 (when (and (stringp dir)
5362 (file-directory-p dir))
5363 (setq article 'nneething)
5364 (gnus-group-enter-directory dir))))))))
5367 ;; Refuse to select canceled articles.
5368 ((and (numberp article)
5370 (get-buffer gnus-summary-buffer)
5371 (gnus-buffer-exists-p gnus-summary-buffer)
5372 (eq (cdr (with-current-buffer gnus-summary-buffer
5373 (assq article gnus-newsgroup-reads)))
5374 gnus-canceled-mark))
5376 ;; We first check `gnus-original-article-buffer'.
5377 ((and (get-buffer gnus-original-article-buffer)
5379 (with-current-buffer gnus-original-article-buffer
5380 (and (equal (car gnus-original-article) group)
5381 (eq (cdr gnus-original-article) article))))
5382 (insert-buffer-substring gnus-original-article-buffer)
5384 ;; Check the backlog.
5385 ((and gnus-keep-backlog
5386 (gnus-backlog-request-article group article (current-buffer)))
5388 ;; Check asynchronous pre-fetch.
5389 ((gnus-async-request-fetched-article group article (current-buffer))
5390 (gnus-async-prefetch-next group article gnus-summary-buffer)
5391 (when (and (numberp article) gnus-keep-backlog)
5392 (gnus-backlog-enter-article group article (current-buffer)))
5395 ((and gnus-use-cache
5397 (gnus-cache-request-article article group))
5399 ;; Check the agent cache.
5400 ((gnus-agent-request-article article group)
5402 ;; Get the article and put into the article buffer.
5403 ((or (stringp article)
5405 (let ((gnus-override-method gnus-override-method)
5406 (methods (and (stringp article)
5407 gnus-refer-article-method))
5408 (backend (car (gnus-find-method-for-group
5409 gnus-newsgroup-name)))
5411 (buffer-read-only nil))
5412 (if (or (not (listp methods))
5413 (and (symbolp (car methods))
5414 (assq (car methods) nnoo-definition-alist)))
5415 (setq methods (list methods)))
5416 (when (and (null gnus-override-method)
5418 (setq gnus-override-method (pop methods)))
5420 (when (eq gnus-override-method 'current)
5421 (setq gnus-override-method
5422 (with-current-buffer gnus-summary-buffer
5423 gnus-current-select-method)))
5425 (gnus-kill-all-overlays)
5426 (let ((gnus-newsgroup-name group))
5427 (gnus-check-group-server))
5429 ((gnus-request-article article group (current-buffer))
5430 (when (numberp article)
5431 (gnus-async-prefetch-next group article
5432 gnus-summary-buffer)
5433 (when gnus-keep-backlog
5434 (gnus-backlog-enter-article
5435 group article (current-buffer))))
5436 (setq result 'article))
5438 (setq gnus-override-method (pop methods)))
5439 ((not (string-match "^400 "
5440 (nnheader-get-report backend)))
5441 ;; If we get 400 server disconnect, reconnect and
5442 ;; retry; otherwise, assume the article has expired.
5443 (setq result 'done))))
5444 (and (eq result 'article) 'article)))
5448 ;; Associate this article with the current summary buffer.
5449 (setq gnus-article-current-summary gnus-summary-buffer)
5451 ;; Take the article from the original article buffer
5452 ;; and place it in the buffer it's supposed to be in.
5453 (when (and (get-buffer gnus-article-buffer)
5454 (equal (buffer-name (current-buffer))
5455 (buffer-name (get-buffer gnus-article-buffer))))
5457 (if (get-buffer gnus-original-article-buffer)
5458 (set-buffer gnus-original-article-buffer)
5459 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5460 (buffer-disable-undo)
5461 (setq major-mode 'gnus-original-article-mode)
5462 (setq buffer-read-only t))
5463 (let (buffer-read-only)
5465 (insert-buffer-substring gnus-article-buffer))
5466 (setq gnus-original-article (cons group article)))
5469 (run-hooks 'gnus-article-decode-hook)
5470 ;; Mark article as decoded or not.
5471 (setq gnus-article-decoded-p gnus-article-decode-hook))
5473 ;; Update sparse articles.
5474 (when (and do-update-line
5475 (or (numberp article)
5477 (let ((buf (current-buffer)))
5478 (set-buffer gnus-summary-buffer)
5479 (gnus-summary-update-article do-update-line sparse-header)
5480 (gnus-summary-goto-subject do-update-line nil t)
5481 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5483 (set-buffer buf))))))
5489 (defcustom gnus-article-edit-mode-hook nil
5490 "Hook run in article edit mode buffers."
5491 :group 'gnus-article-various
5494 (defvar gnus-article-edit-done-function nil)
5496 (defvar gnus-article-edit-mode-map nil)
5498 ;; Should we be using derived.el for this?
5499 (unless gnus-article-edit-mode-map
5500 (setq gnus-article-edit-mode-map (make-keymap))
5501 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5503 (gnus-define-keys gnus-article-edit-mode-map
5504 "\C-c?" describe-mode
5505 "\C-c\C-c" gnus-article-edit-done
5506 "\C-c\C-k" gnus-article-edit-exit
5507 "\C-c\C-f\C-t" message-goto-to
5508 "\C-c\C-f\C-o" message-goto-from
5509 "\C-c\C-f\C-b" message-goto-bcc
5510 ;;"\C-c\C-f\C-w" message-goto-fcc
5511 "\C-c\C-f\C-c" message-goto-cc
5512 "\C-c\C-f\C-s" message-goto-subject
5513 "\C-c\C-f\C-r" message-goto-reply-to
5514 "\C-c\C-f\C-n" message-goto-newsgroups
5515 "\C-c\C-f\C-d" message-goto-distribution
5516 "\C-c\C-f\C-f" message-goto-followup-to
5517 "\C-c\C-f\C-m" message-goto-mail-followup-to
5518 "\C-c\C-f\C-k" message-goto-keywords
5519 "\C-c\C-f\C-u" message-goto-summary
5520 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5521 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5522 "\C-c\C-b" message-goto-body
5523 "\C-c\C-i" message-goto-signature
5525 "\C-c\C-t" message-insert-to
5526 "\C-c\C-n" message-insert-newsgroups
5527 "\C-c\C-o" message-sort-headers
5528 "\C-c\C-e" message-elide-region
5529 "\C-c\C-v" message-delete-not-region
5530 "\C-c\C-z" message-kill-to-signature
5531 "\M-\r" message-newline-and-reformat
5532 "\C-c\C-a" mml-attach-file
5533 "\C-a" message-beginning-of-line
5535 "\M-;" comment-region)
5537 (gnus-define-keys (gnus-article-edit-wash-map
5538 "\C-c\C-w" gnus-article-edit-mode-map)
5539 "f" gnus-article-edit-full-stops))
5542 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5544 ["Fetch To" message-insert-to t]
5545 ["Fetch Newsgroups" message-insert-newsgroups t]
5547 ["To" message-goto-to t]
5548 ["From" message-goto-from t]
5549 ["Subject" message-goto-subject t]
5550 ["Cc" message-goto-cc t]
5551 ["Reply-To" message-goto-reply-to t]
5552 ["Summary" message-goto-summary t]
5553 ["Keywords" message-goto-keywords t]
5554 ["Newsgroups" message-goto-newsgroups t]
5555 ["Followup-To" message-goto-followup-to t]
5556 ["Mail-Followup-To" message-goto-mail-followup-to t]
5557 ["Distribution" message-goto-distribution t]
5558 ["Body" message-goto-body t]
5559 ["Signature" message-goto-signature t]))
5561 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5562 "Major mode for editing articles.
5563 This is an extended text-mode.
5565 \\{gnus-article-edit-mode-map}"
5566 (make-local-variable 'gnus-article-edit-done-function)
5567 (make-local-variable 'gnus-prev-winconf)
5568 (set (make-local-variable 'font-lock-defaults)
5569 '(message-font-lock-keywords t))
5570 (set (make-local-variable 'mail-header-separator) "")
5571 (set (make-local-variable 'gnus-article-edit-mode) t)
5572 (easy-menu-add message-mode-field-menu message-mode-map)
5574 (setq buffer-read-only nil)
5575 (buffer-enable-undo)
5578 (defun gnus-article-edit (&optional force)
5579 "Edit the current article.
5580 This will have permanent effect only in mail groups.
5581 If FORCE is non-nil, allow editing of articles even in read-only
5584 (when (and (not force)
5585 (gnus-group-read-only-p))
5586 (error "The current newsgroup does not support article editing"))
5587 (gnus-article-date-original)
5588 (gnus-article-edit-article
5590 `(lambda (no-highlight)
5592 (gnus-summary-edit-article-done
5593 ,(or (mail-header-references gnus-current-headers) "")
5594 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5596 (defun gnus-article-edit-article (start-func exit-func)
5597 "Start editing the contents of the current article buffer."
5598 (let ((winconf (current-window-configuration)))
5599 (set-buffer gnus-article-buffer)
5600 (gnus-article-edit-mode)
5601 (funcall start-func)
5602 (set-buffer-modified-p nil)
5603 (gnus-configure-windows 'edit-article)
5604 (setq gnus-article-edit-done-function exit-func)
5605 (setq gnus-prev-winconf winconf)
5606 (gnus-message 6 "C-c C-c to end edits")))
5608 (defun gnus-article-edit-done (&optional arg)
5609 "Update the article edits and exit."
5611 (let ((func gnus-article-edit-done-function)
5612 (buf (current-buffer))
5613 (start (window-start))
5615 (winconf gnus-prev-winconf))
5616 (widen) ;; Widen it in case that users narrowed the buffer.
5619 ;; The cache and backlog have to be flushed somewhat.
5620 (when gnus-keep-backlog
5621 (gnus-backlog-remove-article
5622 (car gnus-article-current) (cdr gnus-article-current)))
5623 ;; Flush original article as well.
5625 (when (get-buffer gnus-original-article-buffer)
5626 (set-buffer gnus-original-article-buffer)
5627 (setq gnus-original-article nil)))
5628 (when gnus-use-cache
5629 (gnus-cache-update-article
5630 (car gnus-article-current) (cdr gnus-article-current)))
5631 ;; We remove all text props from the article buffer.
5632 (kill-all-local-variables)
5633 (set-text-properties (point-min) (point-max) nil)
5635 (set-window-configuration winconf)
5637 (set-window-start (get-buffer-window buf) start)
5638 (set-window-point (get-buffer-window buf) (point)))
5639 (gnus-summary-show-article))
5641 (defun gnus-article-edit-exit ()
5642 "Exit the article editing without updating."
5644 (when (or (not (buffer-modified-p))
5645 (yes-or-no-p "Article modified; kill anyway? "))
5646 (let ((curbuf (current-buffer))
5648 (window-start (window-start)))
5650 (if (gnus-buffer-live-p gnus-original-article-buffer)
5651 (insert-buffer gnus-original-article-buffer))
5652 (let ((winconf gnus-prev-winconf))
5653 (kill-all-local-variables)
5655 (set-window-configuration winconf)
5656 ;; Tippy-toe some to make sure that point remains where it was.
5657 (save-current-buffer
5659 (set-window-start (get-buffer-window (current-buffer)) window-start)
5661 (gnus-summary-show-article)))
5663 (defun gnus-article-edit-full-stops ()
5664 "Interactively repair spacing at end of sentences."
5667 (goto-char (point-min))
5668 (search-forward-regexp "^$" nil t)
5669 (let ((case-fold-search nil))
5670 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5673 ;;; Article highlights
5676 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5678 ;;; Internal Variables:
5680 (defcustom gnus-button-url-regexp
5681 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5682 "\\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:]]\\)"
5683 "\\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\\)\\)")
5684 "Regular expression that matches URLs."
5685 :group 'gnus-article-buttons
5688 (defcustom gnus-button-valid-fqdn-regexp
5689 message-valid-fqdn-regexp
5690 "Regular expression that matches a valid FQDN."
5691 :group 'gnus-article-buttons
5694 (defcustom gnus-button-man-handler 'manual-entry
5695 "Function to use for displaying man pages.
5696 The function must take at least one argument with a string naming the
5698 :type '(choice (function-item :tag "Man" manual-entry)
5699 (function-item :tag "Woman" woman)
5700 (function :tag "Other"))
5701 :group 'gnus-article-buttons)
5703 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5704 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5705 If the default site is too slow, try to find a CTAN mirror, see
5706 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5707 the variable `gnus-button-handle-ctan'."
5708 :group 'gnus-article-buttons
5709 :link '(custom-manual "(gnus)Group Parameters")
5710 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5711 (const "http://tug.ctan.org/tex-archive/")
5712 (const "http://www.dante.de/CTAN/")
5713 (string :tag "Other")))
5715 (defcustom gnus-button-ctan-handler 'browse-url
5716 "Function to use for displaying CTAN links.
5717 The function must take one argument, the string naming the URL."
5718 :type '(choice (function-item :tag "Browse Url" browse-url)
5719 (function :tag "Other"))
5720 :group 'gnus-article-buttons)
5722 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5723 "Bogus strings removed from CTAN URLs."
5724 :group 'gnus-article-buttons
5725 :type '(choice (const "^/?tex-archive/\\|/")
5726 (regexp :tag "Other")))
5728 (defcustom gnus-button-ctan-directory-regexp
5731 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5732 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5733 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5735 "Regular expression for ctan directories.
5736 It should match all directories in the top level of `gnus-ctan-url'."
5737 :group 'gnus-article-buttons
5740 (defcustom gnus-button-mid-or-mail-regexp
5741 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5742 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5743 gnus-button-valid-fqdn-regexp
5745 "Regular expression that matches a message ID or a mail address."
5746 :group 'gnus-article-buttons
5749 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5750 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5751 Strings like this can be either a message ID or a mail address. If it is one
5752 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5753 message ID or a mail address, respectively. If this variable is set to the
5754 symbol `ask', always query the user what do do. If it is a function, this
5755 function will be called with the string as it's only argument. The function
5756 must return `mid', `mail', `invalid' or `ask'."
5757 :group 'gnus-article-buttons
5758 :type '(choice (function-item :tag "Heuristic function"
5759 gnus-button-mid-or-mail-heuristic)
5764 (defcustom gnus-button-mid-or-mail-heuristic-alist
5765 '((-10.0 . ".+\\$.+@")
5768 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5769 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5770 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5771 (-1.0 . "^[^a-z]+@")
5773 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5774 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5775 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5776 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5779 (-1.0 . "^[0-9][0-9]")
5781 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5782 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5783 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5784 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5786 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5787 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5790 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5792 ;; compensation for TDMA dated mail addresses:
5793 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5795 (-20.0 . "\\.fsf@") ;; Gnus
5798 (-20.0 . "_-_") ;; Subject change in thread
5800 (-20.0 . "\\.ln@") ;; leafnode
5801 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5802 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5804 ;; (5.0 . "") ;; $local_part_len <= 7
5805 (10.0 . "^[^0-9]+@")
5806 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5807 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5810 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5812 (0.5 . "^[A-Z][a-z]")
5813 (0.5 . "^[A-Z][a-z][a-z]")
5814 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5815 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5816 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5818 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5819 address. The REGEXP is processed with `case-fold-search' set to nil."
5820 :group 'gnus-article-buttons
5821 :type '(repeat (cons (number :tag "Rate")
5822 (regexp :tag "Regexp"))))
5824 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5825 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5826 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5827 address, `ask' if unsure and `invalid' if the string is invalid."
5828 (let ((case-fold-search nil)
5829 (list gnus-button-mid-or-mail-heuristic-alist)
5830 (result 0) rate regexp lpartlen elem)
5832 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5833 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5834 ;; Certain special cases...
5837 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5838 "^[0-9]+\\.[0-9]+@compuserve\\|"
5839 "@public\\.gmane\\.org")
5841 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5842 (setq result 'mail))
5843 (when (string-match "@.*@\\| " mid-or-mail)
5844 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5845 (setq result 'invalid))
5846 ;; Nothing more to do, if result is not a number here...
5847 (when (numberp result)
5849 (setq elem (car list)
5853 (when (string-match regexp mid-or-mail)
5854 (setq result (+ result rate))
5856 9 "`%s' matched `%s', rate `%s', result `%s'."
5857 mid-or-mail regexp rate result)))
5858 (when (<= lpartlen 7)
5859 (setq result (+ result 5.0))
5860 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5861 mid-or-mail result))
5862 (when (>= lpartlen 12)
5863 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5865 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5866 ;; Long local part should contain realname if e-mail address,
5867 ;; too many digits: message-id.
5868 ;; $score -= 5.0 + 0.1 * $local_part_len;
5869 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5870 (setq result (+ result rate))
5872 9 "Many digits in `%s', rate `%s', result `%s'."
5873 mid-or-mail rate result))
5874 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5876 ;; Too few vowels [^aeiouy]{4,}.*\@
5877 (setq result (+ result -5.0))
5879 9 "Few vowels in `%s', rate `%s', result `%s'."
5880 mid-or-mail -5.0 result))
5882 (setq result (+ result 5.0))
5884 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5885 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5886 ;; Maybe we should make this a customizable alist: (condition . 'result)
5888 ((symbolp result) result)
5889 ;; Now convert number into proper results:
5890 ((< result -10.0) 'mid)
5891 ((> result 10.0) 'mail)
5894 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5895 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5896 (url-mid (concat "news" ":" mid-or-mail))
5897 (url-mailto (concat "mailto" ":" mid-or-mail)))
5898 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5899 (when (fboundp pref)
5901 ;; get rid of surrounding angles...
5903 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5904 (if (or (eq 'mid guessed) (eq 'mail guessed))
5908 (save-window-excursion
5909 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5912 (cond ((eq pref 'mid)
5913 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5914 (gnus-button-handle-news url-mid))
5916 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5917 (gnus-url-mailto url-mailto))
5918 (t (gnus-message 3 "Invalid string.")))))
5920 (defun gnus-button-handle-custom (url)
5921 "Follow a Custom URL."
5922 (customize-apropos (gnus-url-unhex-string url)))
5924 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5926 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5929 (defun gnus-button-handle-describe-function (url)
5930 "Call `describe-function' when pushing the corresponding URL button."
5933 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5935 (defun gnus-button-handle-describe-variable (url)
5936 "Call `describe-variable' when pushing the corresponding URL button."
5939 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5941 (defun gnus-button-handle-symbol (url)
5942 "Display help on variable or function.
5943 Calls `describe-variable' or `describe-function'."
5944 (let ((sym (intern url)))
5946 ((fboundp sym) (describe-function sym))
5947 ((boundp sym) (describe-variable sym))
5948 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5950 (defun gnus-button-handle-describe-key (url)
5951 "Call `describe-key' when pushing the corresponding URL button."
5953 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5954 (keys (ignore-errors (eval `(kbd ,key-string)))))
5957 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5959 (defun gnus-button-handle-apropos (url)
5960 "Call `apropos' when pushing the corresponding URL button."
5961 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5963 (defun gnus-button-handle-apropos-command (url)
5964 "Call `apropos' when pushing the corresponding URL button."
5966 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5968 (defun gnus-button-handle-apropos-variable (url)
5969 "Call `apropos' when pushing the corresponding URL button."
5971 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5972 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5974 (defun gnus-button-handle-apropos-documentation (url)
5975 "Call `apropos' when pushing the corresponding URL button."
5977 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5978 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5980 (defun gnus-button-handle-library (url)
5981 "Call `locate-library' when pushing the corresponding URL button."
5982 (gnus-message 9 "url=`%s'" url)
5983 (let* ((lib (locate-library url))
5984 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5986 (gnus-message 1 "Cannot locale library `%s'." url)
5987 (find-file-read-only file))))
5989 (defun gnus-button-handle-ctan (url)
5990 "Call `browse-url' when pushing a CTAN URL button."
5992 gnus-button-ctan-handler
5995 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5997 (defcustom gnus-button-tex-level 5
5998 "*Integer that says how many TeX-related buttons Gnus will show.
5999 The higher the number, the more buttons will appear and the more false
6000 positives are possible. Note that you can set this variable local to
6001 specific groups. Setting it higher in TeX groups is probably a good idea.
6002 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6003 how to set variables in specific groups."
6004 :group 'gnus-article-buttons
6005 :link '(custom-manual "(gnus)Group Parameters")
6008 (defcustom gnus-button-man-level 5
6009 "*Integer that says how many man-related buttons Gnus will show.
6010 The higher the number, the more buttons will appear and the more false
6011 positives are possible. Note that you can set this variable local to
6012 specific groups. Setting it higher in Unix groups is probably a good idea.
6013 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6014 how to set variables in specific groups."
6015 :group 'gnus-article-buttons
6016 :link '(custom-manual "(gnus)Group Parameters")
6019 (defcustom gnus-button-emacs-level 5
6020 "*Integer that says how many emacs-related buttons Gnus will show.
6021 The higher the number, the more buttons will appear and the more false
6022 positives are possible. Note that you can set this variable local to
6023 specific groups. Setting it higher in Emacs or Gnus related groups is
6024 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6025 `gnus-parameters' on how to set variables in specific groups."
6026 :group 'gnus-article-buttons
6027 :link '(custom-manual "(gnus)Group Parameters")
6030 (defcustom gnus-button-message-level 5
6031 "*Integer that says how many buttons for news or mail messages will appear.
6032 The higher the number, the more buttons will appear and the more false
6033 positives are possible."
6034 ;; mail addresses, MIDs, URLs for news, ...
6035 :group 'gnus-article-buttons
6038 (defcustom gnus-button-browse-level 5
6039 "*Integer that says how many buttons for browsing will appear.
6040 The higher the number, the more buttons will appear and the more false
6041 positives are possible."
6042 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6043 :group 'gnus-article-buttons
6046 (defcustom gnus-button-alist
6047 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6048 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6049 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6050 gnus-button-handle-news 2)
6051 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6052 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6053 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6054 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6055 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6056 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6057 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6058 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6059 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6060 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6061 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6062 ;; RFC 2368 (The mailto URL scheme)
6063 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6064 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6065 ("\\bmailto:\\([^ \n\t]+\\)"
6066 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6068 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6069 gnus-button-ctan-directory-regexp
6070 "[^][>)!;:,'\n\t ]+\\)")
6071 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6072 ((concat "\\btex-archive/\\("
6073 gnus-button-ctan-directory-regexp
6074 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6075 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6078 gnus-button-ctan-directory-regexp
6079 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6080 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6081 ;; This is info (home-grown style) <info://foo/bar+baz>
6082 ("\\binfo://\\([^'\">\n\t ]+\\)"
6083 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6084 ;; Info GNOME style <info:foo#bar_baz>
6085 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6086 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6087 ;; Info KDE style <info:(foo)bar baz>
6088 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6089 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6090 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6091 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6092 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6093 ;; Info links like `C-h i d m CC Mode RET'
6094 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6096 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6097 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6098 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6099 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6100 ;; Emacs help commands
6101 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6102 ;; regexp doesn't match arguments containing ` '.
6103 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6104 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6105 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6106 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6107 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6108 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6109 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6110 ;; The following entries may lead to many false positives so don't enable
6111 ;; them by default (use a high button level):
6112 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6113 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6114 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6115 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6116 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6117 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6118 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6119 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6120 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6121 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6122 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6123 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6124 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6125 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6126 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6127 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6128 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6129 ;; Unlike the other regexps we really have to require quoting
6130 ;; here to determine where it ends.
6131 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6132 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6133 ("<URL: *\\([^<>]*\\)>"
6134 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6135 ;; RFC 2396 (2.4.3., delims) ...
6136 ("\"URL: *\\([^\"]*\\)\""
6137 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6138 ;; RFC 2396 (2.4.3., delims) ...
6139 ("\"URL: *\\([^\"]*\\)\""
6140 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6142 (gnus-button-url-regexp
6143 0 (>= gnus-button-browse-level 0) browse-url 0)
6145 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6146 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6147 gnus-button-handle-man 1)
6148 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6149 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6150 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6151 gnus-button-handle-man 1)
6152 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6153 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6154 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6155 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6156 ;; MID or mail: To avoid too many false positives we don't try to catch
6157 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6158 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6159 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6160 ;; so that non-ambiguous entries (see above) match first.
6161 (gnus-button-mid-or-mail-regexp
6162 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6163 "*Alist of regexps matching buttons in article bodies.
6165 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6166 REGEXP: is the string (case insensitive) matching text around the button (can
6167 also be Lisp expression evaluating to a string),
6168 BUTTON: is the number of the regexp grouping actually matching the button,
6169 FORM: is a Lisp expression which must eval to true for the button to
6171 CALLBACK: is the function to call when the user push this button, and each
6172 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6174 CALLBACK can also be a variable, in that case the value of that
6175 variable it the real callback function."
6176 :group 'gnus-article-buttons
6177 :type '(repeat (list (choice regexp variable sexp)
6178 (integer :tag "Button")
6180 (function :tag "Callback")
6183 (integer :tag "Regexp group")))))
6185 (defcustom gnus-header-button-alist
6186 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6187 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6188 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6189 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6190 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6191 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6192 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6193 0 (>= gnus-button-browse-level 0) browse-url 0)
6194 ("^Subject:" gnus-button-url-regexp
6195 0 (>= gnus-button-browse-level 0) browse-url 0)
6196 ("^[^:]+:" gnus-button-url-regexp
6197 0 (>= gnus-button-browse-level 0) browse-url 0)
6198 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6199 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6200 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6201 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6202 "*Alist of headers and regexps to match buttons in article heads.
6204 This alist is very similar to `gnus-button-alist', except that each
6205 alist has an additional HEADER element first in each entry:
6207 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6209 HEADER is a regexp to match a header. For a fuller explanation, see
6210 `gnus-button-alist'."
6211 :group 'gnus-article-buttons
6212 :group 'gnus-article-headers
6213 :type '(repeat (list (regexp :tag "Header")
6214 (choice regexp variable)
6215 (integer :tag "Button")
6217 (function :tag "Callback")
6220 (integer :tag "Regexp group")))))
6224 (defun gnus-article-push-button (event)
6225 "Check text under the mouse pointer for a callback function.
6226 If the text under the mouse pointer has a `gnus-callback' property,
6227 call it with the value of the `gnus-data' text property."
6229 (set-buffer (window-buffer (posn-window (event-start event))))
6230 (let* ((pos (posn-point (event-start event)))
6231 (data (get-text-property pos 'gnus-data))
6232 (fun (get-text-property pos 'gnus-callback)))
6235 (funcall fun data))))
6237 (defun gnus-article-press-button ()
6238 "Check text at point for a callback function.
6239 If the text at point has a `gnus-callback' property,
6240 call it with the value of the `gnus-data' text property."
6242 (let ((data (get-text-property (point) 'gnus-data))
6243 (fun (get-text-property (point) 'gnus-callback)))
6245 (funcall fun data))))
6247 (defun gnus-article-highlight (&optional force)
6248 "Highlight current article.
6249 This function calls `gnus-article-highlight-headers',
6250 `gnus-article-highlight-citation',
6251 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6252 do the highlighting. See the documentation for those functions."
6253 (interactive (list 'force))
6254 (gnus-article-highlight-headers)
6255 (gnus-article-highlight-citation force)
6256 (gnus-article-highlight-signature)
6257 (gnus-article-add-buttons force)
6258 (gnus-article-add-buttons-to-head))
6260 (defun gnus-article-highlight-some (&optional force)
6261 "Highlight current article.
6262 This function calls `gnus-article-highlight-headers',
6263 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6264 do the highlighting. See the documentation for those functions."
6265 (interactive (list 'force))
6266 (gnus-article-highlight-headers)
6267 (gnus-article-highlight-signature)
6268 (gnus-article-add-buttons))
6270 (defun gnus-article-highlight-headers ()
6271 "Highlight article headers as specified by `gnus-header-face-alist'."
6273 (gnus-with-article-headers
6274 (let ((alist gnus-header-face-alist)
6275 entry regexp header-face field-face from hpoints fpoints)
6276 (while (setq entry (pop alist))
6277 (goto-char (point-min))
6278 (setq regexp (concat "^\\("
6279 (if (string-equal "" (nth 0 entry))
6283 header-face (nth 1 entry)
6284 field-face (nth 2 entry))
6285 (while (and (re-search-forward regexp nil t)
6289 (unless (search-forward ":" nil t)
6291 (when (and header-face
6292 (not (memq (point) hpoints)))
6293 (push (point) hpoints)
6294 (gnus-put-text-property from (point) 'face header-face))
6295 (when (and field-face
6296 (not (memq (setq from (point)) fpoints)))
6298 (if (re-search-forward "^[^ \t]" nil t)
6300 (goto-char (point-max)))
6301 (gnus-put-text-property from (point) 'face field-face)))))))
6303 (defun gnus-article-highlight-signature ()
6304 "Highlight the signature in an article.
6305 It does this by highlighting everything after
6306 `gnus-signature-separator' using `gnus-signature-face'."
6308 (gnus-with-article-buffer
6309 (let ((inhibit-point-motion-hooks t))
6311 (when (and gnus-signature-face
6312 (gnus-article-narrow-to-signature))
6313 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6314 'face gnus-signature-face)
6316 (gnus-article-search-signature)
6317 (let ((start (match-beginning 0))
6318 (end (set-marker (make-marker) (1+ (match-end 0)))))
6319 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6322 (defun gnus-button-in-region-p (b e prop)
6323 "Say whether PROP exists in the region."
6324 (text-property-not-all b e prop nil))
6326 (defun gnus-article-add-buttons (&optional force)
6327 "Find external references in the article and make buttons of them.
6328 \"External references\" are things like Message-IDs and URLs, as
6329 specified by `gnus-button-alist'."
6330 (interactive (list 'force))
6331 (gnus-with-article-buffer
6332 (let ((inhibit-point-motion-hooks t)
6333 (case-fold-search t)
6334 (alist gnus-button-alist)
6336 ;; Remove all old markers.
6337 (let (marker entry new-list)
6338 (while (setq marker (pop gnus-button-marker-list))
6339 (if (or (< marker (point-min)) (>= marker (point-max)))
6340 (push marker new-list)
6342 (when (setq entry (gnus-button-entry))
6343 (put-text-property (match-beginning (nth 1 entry))
6344 (match-end (nth 1 entry))
6345 'gnus-callback nil))
6346 (set-marker marker nil)))
6347 (setq gnus-button-marker-list new-list))
6348 ;; We skip the headers.
6351 (while (setq entry (pop alist))
6352 (setq regexp (eval (car entry)))
6354 (while (re-search-forward regexp nil t)
6355 (let* ((start (and entry (match-beginning (nth 1 entry))))
6356 (end (and entry (match-end (nth 1 entry))))
6357 (from (match-beginning 0)))
6358 (when (and (or (eq t (nth 2 entry))
6359 (eval (nth 2 entry)))
6360 (not (gnus-button-in-region-p
6361 start end 'gnus-callback)))
6362 ;; That optional form returned non-nil, so we add the
6364 (gnus-article-add-button
6365 start end 'gnus-button-push
6366 (car (push (set-marker (make-marker) from)
6367 gnus-button-marker-list))))))))))
6369 ;; Add buttons to the head of an article.
6370 (defun gnus-article-add-buttons-to-head ()
6371 "Add buttons to the head of the article."
6373 (gnus-with-article-headers
6374 (let ((alist gnus-header-button-alist)
6377 ;; Each alist entry.
6378 (setq entry (pop alist))
6379 (goto-char (point-min))
6380 (while (re-search-forward (car entry) nil t)
6381 ;; Each header matching the entry.
6382 (setq beg (match-beginning 0))
6383 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6384 (match-beginning 0))
6387 (while (re-search-forward (eval (nth 1 entry)) end t)
6388 ;; Each match within a header.
6389 (let* ((entry (cdr entry))
6390 (start (match-beginning (nth 1 entry)))
6391 (end (match-end (nth 1 entry)))
6392 (form (nth 2 entry)))
6393 (goto-char (match-end 0))
6395 (gnus-article-add-button
6396 start end (nth 3 entry)
6397 (buffer-substring (match-beginning (nth 4 entry))
6398 (match-end (nth 4 entry)))))))
6399 (goto-char end))))))
6401 ;;; External functions:
6403 (defun gnus-article-add-button (from to fun &optional data)
6404 "Create a button between FROM and TO with callback FUN and data DATA."
6405 (when gnus-article-button-face
6406 (gnus-overlay-put (gnus-make-overlay from to)
6407 'face gnus-article-button-face))
6408 (gnus-add-text-properties
6410 (nconc (and gnus-article-mouse-face
6411 (list gnus-mouse-face-prop gnus-article-mouse-face))
6412 (list 'gnus-callback fun)
6413 (and data (list 'gnus-data data))))
6414 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6415 :button-keymap gnus-widget-button-keymap))
6417 ;;; Internal functions:
6419 (defun gnus-article-set-globals ()
6420 (with-current-buffer gnus-summary-buffer
6421 (gnus-set-global-variables)))
6423 (defun gnus-signature-toggle (end)
6424 (gnus-with-article-buffer
6425 (let ((inhibit-point-motion-hooks t))
6426 (if (text-property-any end (point-max) 'article-type 'signature)
6428 (gnus-delete-wash-type 'signature)
6429 (gnus-remove-text-properties-when
6430 'article-type 'signature end (point-max)
6431 (cons 'article-type (cons 'signature
6432 gnus-hidden-properties))))
6433 (gnus-add-wash-type 'signature)
6434 (gnus-add-text-properties-when
6435 'article-type nil end (point-max)
6436 (cons 'article-type (cons 'signature
6437 gnus-hidden-properties)))))
6438 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6439 (gnus-set-mode-line 'article))))
6441 (defun gnus-button-entry ()
6442 ;; Return the first entry in `gnus-button-alist' matching this place.
6443 (let ((alist gnus-button-alist)
6446 (setq entry (pop alist))
6447 (if (looking-at (eval (car entry)))
6452 (defun gnus-button-push (marker)
6453 ;; Push button starting at MARKER.
6456 (let* ((entry (gnus-button-entry))
6457 (inhibit-point-motion-hooks t)
6459 (args (mapcar (lambda (group)
6460 (let ((string (match-string group)))
6461 (set-text-properties
6462 0 (length string) nil string)
6469 (fboundp (symbol-value fun)))
6470 (apply (symbol-value fun) args))
6472 (gnus-message 1 "You must define `%S' to use this button"
6473 (cons fun args)))))))
6475 (defun gnus-parse-news-url (url)
6476 (let (scheme server group message-id articles)
6479 (goto-char (point-min))
6480 (when (looking-at "\\([A-Za-z]+\\):")
6481 (setq scheme (match-string 1))
6482 (goto-char (match-end 0)))
6483 (when (looking-at "//\\([^/]+\\)/")
6484 (setq server (match-string 1))
6485 (goto-char (match-end 0)))
6488 ((looking-at "\\(.*@.*\\)")
6489 (setq message-id (match-string 1)))
6490 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6491 (setq group (match-string 1)
6492 articles (split-string (match-string 2) "-")))
6493 ((looking-at "\\([^/]+\\)/?")
6494 (setq group (match-string 1)))
6496 (error "Unknown news URL syntax"))))
6497 (list scheme server group message-id articles)))
6499 (defun gnus-button-handle-news (url)
6501 (destructuring-bind (scheme server group message-id articles)
6502 (gnus-parse-news-url url)
6506 (set-buffer gnus-summary-buffer)
6508 (let ((gnus-refer-article-method (list (list 'nntp server))))
6509 (gnus-summary-refer-article message-id))
6510 (gnus-summary-refer-article message-id))))
6512 (gnus-button-fetch-group url)))))
6514 (defun gnus-button-handle-man (url)
6516 (funcall gnus-button-man-handler url))
6518 (defun gnus-button-handle-info-url (url)
6519 "Fetch an info URL."
6520 (setq url (mm-subst-char-in-string ?+ ?\ url))
6522 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6523 (gnus-info-find-node
6524 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6526 ")" (gnus-url-unhex-string (match-string 2 url)))))
6527 ((string-match "([^)\"]+)[^\"]+" url)
6529 (gnus-replace-in-string
6530 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6531 (gnus-info-find-node url))
6532 (t (error "Can't parse %s" url))))
6534 (defun gnus-button-handle-info-url-gnome (url)
6535 "Fetch GNOME style info URL."
6536 (setq url (mm-subst-char-in-string ?_ ?\ url))
6537 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6538 (gnus-info-find-node
6540 (gnus-url-unhex-string
6541 (match-string 1 url))
6543 (or (gnus-url-unhex-string
6544 (match-string 2 url))
6546 (error "Can't parse %s" url)))
6548 (defun gnus-button-handle-info-url-kde (url)
6549 "Fetch KDE style info URL."
6550 (gnus-info-find-node (gnus-url-unhex-string url)))
6552 (defun gnus-button-handle-info-keystrokes (url)
6553 "Call `info' when pushing the corresponding URL button."
6554 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6559 (defun gnus-button-message-id (message-id)
6561 (with-current-buffer gnus-summary-buffer
6562 (gnus-summary-refer-article message-id)))
6564 (defun gnus-button-fetch-group (address)
6565 "Fetch GROUP specified by ADDRESS."
6566 (if (not (string-match "[:/]" address))
6567 ;; This is just a simple group url.
6568 (gnus-group-read-ephemeral-group address gnus-select-method)
6571 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6573 (error "Can't parse %s" address)
6574 (gnus-group-read-ephemeral-group
6575 (match-string 4 address)
6576 `(nntp ,(match-string 1 address)
6577 (nntp-address ,(match-string 1 address))
6578 (nntp-port-number ,(if (match-end 3)
6579 (match-string 3 address)
6582 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6584 (defun gnus-url-parse-query-string (query &optional downcase)
6585 (let (retval pairs cur key val)
6586 (setq pairs (split-string query "&"))
6588 (setq cur (car pairs)
6590 (if (not (string-match "=" cur))
6592 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6593 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6595 (setq key (downcase key)))
6596 (setq cur (assoc key retval))
6598 (setcdr cur (cons val (cdr cur)))
6599 (setq retval (cons (list key val) retval)))))
6602 (defun gnus-url-mailto (url)
6603 ;; Send mail to someone
6604 (when (string-match "mailto:/*\\(.*\\)" url)
6605 (setq url (substring url (match-beginning 1) nil)))
6606 (let (to args subject func)
6607 (setq args (gnus-url-parse-query-string
6608 (if (string-match "^\\?" url)
6610 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6611 (concat "to=" (match-string 1 url) "&"
6612 (match-string 2 url))
6613 (concat "to=" url)))
6615 subject (cdr-safe (assoc "subject" args)))
6618 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6621 (message-position-on-field (caar args)))
6622 (insert (gnus-replace-in-string
6623 (mapconcat 'identity (reverse (cdar args)) ", ")
6625 (setq args (cdr args)))
6628 (message-goto-subject))))
6630 (defun gnus-button-embedded-url (address)
6631 "Activate ADDRESS with `browse-url'."
6632 (browse-url (gnus-strip-whitespace address)))
6634 ;;; Next/prev buttons in the article buffer.
6636 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6637 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6639 (defvar gnus-prev-page-map
6640 (let ((map (make-sparse-keymap)))
6641 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6642 (define-key map "\r" 'gnus-button-prev-page)
6645 (defvar gnus-next-page-map
6646 (let ((map (make-sparse-keymap)))
6647 (define-key map gnus-mouse-2 'gnus-button-next-page)
6648 (define-key map "\r" 'gnus-button-next-page)
6651 (defun gnus-insert-prev-page-button ()
6653 (buffer-read-only nil))
6655 gnus-prev-page-line-format nil
6656 `(keymap ,gnus-prev-page-map
6658 gnus-callback gnus-article-button-prev-page
6659 article-type annotation))
6660 (widget-convert-button
6662 ;; Exclude a newline.
6665 :action 'gnus-button-prev-page
6666 :button-keymap gnus-prev-page-map)))
6668 (defun gnus-button-next-page (&optional args more-args)
6669 "Go to the next page."
6671 (let ((win (selected-window)))
6672 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6673 (gnus-article-next-page)
6674 (select-window win)))
6676 (defun gnus-button-prev-page (&optional args more-args)
6677 "Go to the prev page."
6679 (let ((win (selected-window)))
6680 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6681 (gnus-article-prev-page)
6682 (select-window win)))
6684 (defun gnus-insert-next-page-button ()
6686 (buffer-read-only nil))
6687 (gnus-eval-format gnus-next-page-line-format nil
6688 `(keymap ,gnus-next-page-map
6690 gnus-callback gnus-article-button-next-page
6691 article-type annotation))
6692 (widget-convert-button
6694 ;; Exclude a newline.
6697 :action 'gnus-button-next-page
6698 :button-keymap gnus-next-page-map)))
6700 (defun gnus-article-button-next-page (arg)
6701 "Go to the next page."
6703 (let ((win (selected-window)))
6704 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6705 (gnus-article-next-page)
6706 (select-window win)))
6708 (defun gnus-article-button-prev-page (arg)
6709 "Go to the prev page."
6711 (let ((win (selected-window)))
6712 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6713 (gnus-article-prev-page)
6714 (select-window win)))
6716 (defvar gnus-decode-header-methods
6717 '(mail-decode-encoded-word-region)
6718 "List of methods used to decode headers.
6720 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6721 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6722 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6723 whose names match REGEXP.
6726 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6727 mail-decode-encoded-word-region
6728 (\"chinese\" . rfc1843-decode-region))
6731 (defvar gnus-decode-header-methods-cache nil)
6733 (defun gnus-multi-decode-header (start end)
6734 "Apply the functions from `gnus-encoded-word-methods' that match."
6735 (unless (and gnus-decode-header-methods-cache
6736 (eq gnus-newsgroup-name
6737 (car gnus-decode-header-methods-cache)))
6738 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6741 (nconc gnus-decode-header-methods-cache (list x))
6742 (if (and gnus-newsgroup-name
6743 (string-match (car x) gnus-newsgroup-name))
6744 (nconc gnus-decode-header-methods-cache
6746 gnus-decode-header-methods))
6747 (let ((xlist gnus-decode-header-methods-cache))
6750 (narrow-to-region start end)
6752 (funcall (pop xlist) (point-min) (point-max))))))
6755 ;;; Treatment top-level handling.
6758 (defun gnus-treat-article (condition &optional part-number total-parts type)
6759 (let ((length (- (point-max) (point-min)))
6760 (alist gnus-treatment-function-alist)
6761 (article-goto-body-goes-to-point-min-p t)
6765 (let ((list gnus-article-treat-types))
6767 (when (string-match (pop list) type)
6768 (throw 'found t)))))))
6769 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6771 (gnus-run-hooks 'gnus-part-display-hook)
6772 (dolist (elem alist)
6775 (when (gnus-buffer-live-p gnus-summary-buffer)
6776 (set-buffer gnus-summary-buffer))
6777 (symbol-value (car elem))))
6778 (when (and (or (consp val)
6780 (gnus-treat-predicate val)
6781 (or (not (get (car elem) 'highlight))
6784 (funcall (cadr elem)))))))
6786 ;; Dynamic variables.
6788 (defvar part-number)
6789 (defvar total-parts)
6794 (defun gnus-treat-predicate (val)
6801 (stringp (car val)))
6802 (apply 'gnus-or (mapcar `(lambda (s)
6803 (string-match s ,(or gnus-newsgroup-name "")))
6806 (let ((pred (pop val)))
6809 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6811 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6813 (not (gnus-treat-predicate (car val))))
6815 (equal (car val) type))
6817 (error "%S is not a valid predicate" pred)))))
6823 (eq part-number total-parts))
6827 (error "%S is not a valid value" val))))
6829 (defun gnus-article-encrypt-body (protocol &optional n)
6830 "Encrypt the article body."
6833 (or gnus-article-encrypt-protocol
6834 (completing-read "Encrypt protocol: "
6835 gnus-article-encrypt-protocol-alist
6837 current-prefix-arg))
6838 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6840 (error (format "Can't find the encrypt protocol %s" protocol)))
6841 (if (member gnus-newsgroup-name '("nndraft:delayed"
6844 (error "Can't encrypt the article in group %s"
6845 gnus-newsgroup-name))
6846 (gnus-summary-iterate n
6848 (set-buffer gnus-summary-buffer)
6849 (let ((mail-parse-charset gnus-newsgroup-charset)
6850 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6851 (summary-buffer gnus-summary-buffer)
6853 (gnus-set-global-variables)
6854 (when (gnus-group-read-only-p)
6855 (error "The current newsgroup does not support article encrypt"))
6856 (gnus-summary-show-article t)
6858 (or (mail-header-references gnus-current-headers) ""))
6859 (set-buffer gnus-article-buffer)
6860 (let* ((buffer-read-only nil)
6862 (mapcar (lambda (field)
6863 (and (save-restriction
6864 (message-narrow-to-head)
6865 (goto-char (point-min))
6866 (search-forward field nil t))
6868 (message-narrow-to-field)
6870 (delete-region (point-min) (point-max))
6872 '("Content-Type:" "Content-Transfer-Encoding:"
6873 "Content-Disposition:"))))
6874 (message-narrow-to-head)
6875 (message-remove-header "MIME-Version")
6876 (goto-char (point-max))
6877 (setq point (point))
6878 (insert (apply 'concat headers))
6880 (narrow-to-region point (point-max))
6881 (let ((message-options message-options))
6882 (message-options-set 'message-sender user-mail-address)
6883 (message-options-set 'message-recipients user-mail-address)
6884 (message-options-set 'message-sign-encrypt 'not)
6886 (goto-char (point-min))
6887 (insert "MIME-Version: 1.0\n")
6889 (gnus-summary-edit-article-done
6890 references nil summary-buffer t))
6891 (when gnus-keep-backlog
6892 (gnus-backlog-remove-article
6893 (car gnus-article-current) (cdr gnus-article-current)))
6895 (when (get-buffer gnus-original-article-buffer)
6896 (set-buffer gnus-original-article-buffer)
6897 (setq gnus-original-article nil)))
6898 (when gnus-use-cache
6899 (gnus-cache-update-article
6900 (car gnus-article-current) (cdr gnus-article-current))))))))
6902 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6903 "The following specs can be used:
6904 %t The security MIME type
6907 %D Details if button is pressed")
6909 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6910 "The following specs can be used:
6911 %t The security MIME type
6914 %D Details if button is pressed")
6916 (defvar gnus-mime-security-button-line-format-alist
6917 '((?t gnus-tmp-type ?s)
6918 (?i gnus-tmp-info ?s)
6919 (?d gnus-tmp-details ?s)
6920 (?D gnus-tmp-pressed-details ?s)))
6922 (defvar gnus-mime-security-button-map
6923 (let ((map (make-sparse-keymap)))
6924 (define-key map gnus-mouse-2 'gnus-article-push-button)
6925 (define-key map "\r" 'gnus-article-press-button)
6928 (defvar gnus-mime-security-details-buffer nil)
6930 (defvar gnus-mime-security-button-pressed nil)
6932 (defvar gnus-mime-security-show-details-inline t
6933 "If non-nil, show details in the article buffer.")
6935 (defun gnus-mime-security-verify-or-decrypt (handle)
6936 (mm-remove-parts (cdr handle))
6937 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6938 point buffer-read-only)
6940 (goto-char (car region)))
6942 (narrow-to-region (point) (point))
6943 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6944 (let* ((mm-verify-option 'known)
6945 (mm-decrypt-option 'known)
6946 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6947 (unless (eq nparts (cdr handle))
6948 (mm-destroy-parts (cdr handle))
6949 (setcdr handle nparts))))
6950 (setq point (point))
6951 (gnus-mime-display-security handle)
6952 (goto-char (point-max)))
6954 (delete-region (point) (cdr region))
6955 (set-marker (car region) nil)
6956 (set-marker (cdr region) nil))
6959 (defun gnus-mime-security-show-details (handle)
6960 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6962 (gnus-message 5 "No details.")
6963 (if gnus-mime-security-show-details-inline
6964 (let ((gnus-mime-security-button-pressed
6965 (not (get-text-property (point) 'gnus-mime-details)))
6966 (gnus-mime-security-button-line-format
6967 (get-text-property (point) 'gnus-line-format))
6970 (while (eq (get-text-property (point) 'gnus-line-format)
6971 gnus-mime-security-button-line-format)
6975 (narrow-to-region (point) (point))
6976 (gnus-insert-mime-security-button handle))
6977 (delete-region (point)
6978 (or (text-property-not-all
6981 gnus-mime-security-button-line-format)
6984 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6985 (with-current-buffer gnus-mime-security-details-buffer
6988 (setq gnus-mime-security-details-buffer
6989 (gnus-get-buffer-create "*MIME Security Details*")))
6990 (with-current-buffer gnus-mime-security-details-buffer
6992 (goto-char (point-min)))
6993 (pop-to-buffer gnus-mime-security-details-buffer)))))
6995 (defun gnus-mime-security-press-button (handle)
6997 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6998 (gnus-mime-security-show-details handle)
6999 (gnus-mime-security-verify-or-decrypt handle))))
7001 (defun gnus-insert-mime-security-button (handle &optional displayed)
7002 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7005 (or (nth 2 (assoc protocol mm-verify-function-alist))
7006 (nth 2 (assoc protocol mm-decrypt-function-alist))
7008 (if (equal (car handle) "multipart/signed")
7009 " Signed" " Encrypted")
7012 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7015 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7016 gnus-tmp-pressed-details
7018 (setq gnus-tmp-details
7019 (if gnus-tmp-details
7020 (concat "\n" gnus-tmp-details)
7022 (setq gnus-tmp-pressed-details
7023 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7028 gnus-mime-security-button-line-format
7029 gnus-mime-security-button-line-format-alist
7030 `(keymap ,gnus-mime-security-button-map
7031 gnus-callback gnus-mime-security-press-button
7032 gnus-line-format ,gnus-mime-security-button-line-format
7033 gnus-mime-details ,gnus-mime-security-button-pressed
7034 article-type annotation
7037 ;; Exclude a newline.
7040 (widget-convert-button
7043 :action 'gnus-widget-press-button
7044 :button-keymap gnus-mime-security-button-map
7046 (lambda (widget/window &optional overlay pos)
7047 ;; Needed to properly clear the message due to a bug in
7048 ;; wid-edit (XEmacs only).
7049 (when (boundp 'help-echo-owns-message)
7050 (setq help-echo-owns-message t))
7053 (aref gnus-mouse-2 0))))))
7055 (defun gnus-mime-display-security (handle)
7057 (narrow-to-region (point) (point))
7058 (unless (gnus-unbuttonized-mime-type-p (car handle))
7059 (gnus-insert-mime-security-button handle))
7060 (gnus-mime-display-mixed (cdr handle))
7063 (unless (gnus-unbuttonized-mime-type-p (car handle))
7064 (let ((gnus-mime-security-button-line-format
7065 gnus-mime-security-button-end-line-format))
7066 (gnus-insert-mime-security-button handle)))
7067 (mm-set-handle-multipart-parameter
7069 (cons (set-marker (make-marker) (point-min))
7070 (set-marker (make-marker) (point-max))))))
7076 (run-hooks 'gnus-art-load-hook)
7078 ;;; gnus-art.el ends here