summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-06-22 23:50:27 +0200
committerAndy Wingo <wingo@pobox.com>2010-06-22 23:50:27 +0200
commitff87b2bd7c8a421333fa2182837388e6421df88e (patch)
tree0e9d14af04ee7b28fab3e0d5df11804c922ff725
parent8fba85750d512bf628520310574e658c147b6cc7 (diff)
downloadguile-ff87b2bd7c8a421333fa2182837388e6421df88e.tar.gz
top-repl out to its own module
* module/ice-9/boot-9.scm: * module/ice-9/top-repl.scm: Move top-repl out here. * module/Makefile.am: Add new file. * module/ice-9/deprecated.scm (top-repl): Deprecated shim. * libguile/script.c (scm_compile_shell_switches): Invoke top-repl from its new location.
-rw-r--r--libguile/script.c7
-rw-r--r--module/Makefile.am1
-rw-r--r--module/ice-9/boot-9.scm51
-rw-r--r--module/ice-9/deprecated.scm8
-rw-r--r--module/ice-9/top-repl.scm72
5 files changed, 86 insertions, 53 deletions
diff --git a/libguile/script.c b/libguile/script.c
index 3c0992165..3ea425cd6 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -406,6 +406,7 @@ SCM_SYMBOL (sym_command_line, "command-line");
SCM_SYMBOL (sym_begin, "begin");
SCM_SYMBOL (sym_turn_on_debugging, "turn-on-debugging");
SCM_SYMBOL (sym_load_user_init, "load-user-init");
+SCM_SYMBOL (sym_ice_9, "ice-9");
SCM_SYMBOL (sym_top_repl, "top-repl");
SCM_SYMBOL (sym_quit, "quit");
SCM_SYMBOL (sym_use_srfis, "use-srfis");
@@ -681,7 +682,11 @@ scm_compile_shell_switches (int argc, char **argv)
/* If we didn't end with a -c or a -s, start the repl. */
if (interactive)
{
- tail = scm_cons (scm_cons (sym_top_repl, SCM_EOL), tail);
+ tail = scm_cons (scm_list_1 (scm_list_3
+ (sym_at,
+ scm_list_2 (sym_ice_9, sym_top_repl),
+ sym_top_repl)),
+ tail);
}
else
{
diff --git a/module/Makefile.am b/module/Makefile.am
index 08367c4ff..6e3e064c7 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -219,6 +219,7 @@ ICE_9_SOURCES = \
ice-9/string-fun.scm \
ice-9/syncase.scm \
ice-9/threads.scm \
+ ice-9/top-repl.scm \
ice-9/buffered-input.scm \
ice-9/time.scm \
ice-9/history.scm \
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 32c4dd5cf..bd5625d91 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3341,57 +3341,6 @@ module '(ice-9 q) '(make-q q-length))}."
(lambda () (fluid-ref using-readline?))
(lambda (v) (fluid-set! using-readline? v)))))
-(define (top-repl)
- (define (call-with-sigint thunk)
- (if (not (provided? 'posix))
- (thunk)
- (let ((handler #f))
- (dynamic-wind
- (lambda ()
- (set! handler
- (sigaction SIGINT
- (lambda (sig)
- (scm-error 'signal #f "User interrupt" #f
- (list sig))))))
- thunk
- (lambda ()
- (if handler
- ;; restore Scheme handler, SIG_IGN or SIG_DFL.
- (sigaction SIGINT (car handler) (cdr handler))
- ;; restore original C handler.
- (sigaction SIGINT #f)))))))
-
- (let ((guile-user-module (resolve-module '(guile-user))))
-
- ;; Use some convenient modules (in reverse order)
-
- (set-current-module guile-user-module)
- (process-use-modules
- (append
- '(((ice-9 r5rs))
- ((ice-9 session))
- ((ice-9 debug)))
- (if (provided? 'regex)
- '(((ice-9 regex)))
- '())
- (if (provided? 'threads)
- '(((ice-9 threads)))
- '())))
- ;; load debugger on demand
- (module-autoload! guile-user-module '(system vm debug) '(debug))
-
- (let (;; We can't use @ here, as modules have been booted, but in Guile's
- ;; build the srfi-1 helper lib hasn't been built yet, which will
- ;; result in an error when (system repl repl) is loaded at compile
- ;; time (to see if it is a macro or not).
- (start-repl (module-ref (resolve-module '(system repl repl))
- 'start-repl)))
- (call-with-sigint
- (lambda ()
- (let ((status (start-repl 'scheme)))
- (run-hook exit-hook)
- status))))))
-
;;; {Deprecated stuff}
diff --git a/module/ice-9/deprecated.scm b/module/ice-9/deprecated.scm
index 4e80a8d22..1ce98f244 100644
--- a/module/ice-9/deprecated.scm
+++ b/module/ice-9/deprecated.scm
@@ -64,7 +64,8 @@
the-last-stack
save-stack
named-module-use!
- load-emacs-interface)
+ load-emacs-interface
+ top-repl)
#:replace (module-ref-submodule module-define-submodule!))
@@ -685,3 +686,8 @@ Use Geiser.")
(and (provided? 'debug-extensions)
(debug-enable 'backtrace))
(named-module-use! '(guile-user) '(ice-9 emacs)))
+
+(define (top-repl)
+ (issue-deprecation-warning
+ "`top-repl' has moved to the `(ice-9 top-repl)' module.")
+ ((module-ref (resolve-module '(ice-9 top-repl)) 'top-repl)))
diff --git a/module/ice-9/top-repl.scm b/module/ice-9/top-repl.scm
new file mode 100644
index 000000000..e41da4e7c
--- /dev/null
+++ b/module/ice-9/top-repl.scm
@@ -0,0 +1,72 @@
+;;; -*- mode: scheme; coding: utf-8; -*-
+
+;;;; Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010
+;;;; Free Software Foundation, Inc.
+;;;;
+;;;; This library is free software; you can redistribute it and/or
+;;;; modify it under the terms of the GNU Lesser General Public
+;;;; License as published by the Free Software Foundation; either
+;;;; version 3 of the License, or (at your option) any later version.
+;;;;
+;;;; This library is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;;; Lesser General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free Software
+;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+;;;;
+
+(define-module (ice-9 top-repl)
+ #:use-module (ice-9 top-repl)
+ #:use-module ((system repl repl) #:select (start-repl))
+
+ ;; #:replace, as with deprecated code enabled these will be in the root env
+ #:replace (top-repl))
+
+(define call-with-sigint
+ (if (not (provided? 'posix))
+ (lambda (thunk) (thunk))
+ (lambda (thunk)
+ (let ((handler #f))
+ (dynamic-wind
+ (lambda ()
+ (set! handler
+ (sigaction SIGINT
+ (lambda (sig)
+ (scm-error 'signal #f "User interrupt" #f
+ (list sig))))))
+ thunk
+ (lambda ()
+ (if handler
+ ;; restore Scheme handler, SIG_IGN or SIG_DFL.
+ (sigaction SIGINT (car handler) (cdr handler))
+ ;; restore original C handler.
+ (sigaction SIGINT #f))))))))
+
+(define (top-repl)
+ (let ((guile-user-module (resolve-module '(guile-user))))
+
+ ;; Use some convenient modules (in reverse order)
+
+ (set-current-module guile-user-module)
+ (process-use-modules
+ (append
+ '(((ice-9 r5rs))
+ ((ice-9 session))
+ ((ice-9 debug)))
+ (if (provided? 'regex)
+ '(((ice-9 regex)))
+ '())
+ (if (provided? 'threads)
+ '(((ice-9 threads)))
+ '())))
+ ;; load debugger on demand
+ (module-autoload! guile-user-module '(system vm debug) '(debug))
+
+ (call-with-sigint
+ (lambda ()
+ (let ((status (start-repl 'scheme)))
+ (run-hook exit-hook)
+ status)))))