Simple value history support.
[bpt/guile.git] / ice-9 / history.scm
CommitLineData
870777d7
KN
1;;;; Copyright (C) 2000 Free Software Foundation, Inc.
2;;;;
3;;;; This program is free software; you can redistribute it and/or modify
4;;;; it under the terms of the GNU General Public License as published by
5;;;; the Free Software Foundation; either version 2, or (at your option)
6;;;; any later version.
7;;;;
8;;;; This program is distributed in the hope that it will be useful,
9;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11;;;; GNU General Public License for more details.
12;;;;
13;;;; You should have received a copy of the GNU General Public License
14;;;; along with this software; see the file COPYING. If not, write to
15;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16;;;; Boston, MA 02111-1307 USA
17;;;;
18\f
19;;;; A simple value history support
20
21(define-module (ice-9 history))
22
23(define (use-value-history x)
24 (module-use! (current-module)
25 (resolve-module '(value-history))))
26
27(define save-value-history
28 (let ((count 0)
29 (history (resolve-module '(value-history))))
30 (lambda (v)
31 (if (not (unspecified? v))
32 (let* ((c (1+ count))
33 (s (string->symbol (simple-format #f "$~A" c))))
34 (simple-format #t "~A = " s)
35 (module-define! history s v)
36 (set! count c))))))
37
38(add-hook! before-eval-hook use-value-history)
39(add-hook! before-print-hook save-value-history)