mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
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.
This commit is contained in:
parent
8fba85750d
commit
ff87b2bd7c
5 changed files with 86 additions and 53 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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)))
|
||||
|
|
72
module/ice-9/top-repl.scm
Normal file
72
module/ice-9/top-repl.scm
Normal file
|
@ -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)))))
|
Loading…
Add table
Add a link
Reference in a new issue