diff options
-rw-r--r-- | geiser-chez.el | 43 | ||||
-rw-r--r-- | src/geiser/geiser.ss | 9 |
2 files changed, 24 insertions, 28 deletions
diff --git a/geiser-chez.el b/geiser-chez.el index af3f11d..d9ad5eb 100644 --- a/geiser-chez.el +++ b/geiser-chez.el @@ -31,7 +31,7 @@ (eval-when-compile (require 'cl-lib)) -;;; Customization: +;;; Customization (defgroup geiser-chez nil "Customization for Geiser's Chez Scheme flavour." @@ -40,8 +40,7 @@ (geiser-custom--defcustom geiser-chez-binary "scheme" "Name to use to call the Chez Scheme executable when starting a REPL." - :type '(choice string (repeat string)) - :group 'geiser-chez) + :type '(choice string (repeat string))) (geiser-custom--defcustom geiser-chez-init-file "~/.chez-geiser" "Initialization file with user code for the Chez REPL. @@ -49,30 +48,30 @@ Do mind that this file is local to running process, so remote process will use an init file at this location in the remote host." - :type 'string - :group 'geiser-chez) + :type 'string) (geiser-custom--defcustom geiser-chez-extra-command-line-parameters '() "Additional parameters to supply to the Chez binary." - :type '(repeat string) - :group 'geiser-chez) + :type '(repeat string)) (geiser-custom--defcustom geiser-chez-extra-keywords '() "Extra keywords highlighted in Chez Scheme buffers." - :type '(repeat string) - :group 'geiser-chez) + :type '(repeat string)) (geiser-custom--defcustom geiser-chez-debug-on-exception nil - "Whether to automatically enter the debugger when catching an exception" - :type 'boolean - :group 'geiser-chez) + "Whether to automatically enter the debugger when an evaluation throws." + :type 'boolean) (define-obsolete-variable-alias 'geiser-chez-debug-on-exception-p 'geiser-chez-debug-on-exception "0.18") +(geiser-custom--defcustom geiser-chez-show-error-on-debug t + "Whether to issue a `show condition' command upon entering the debugger." + :type 'boolean) + (defconst geiser-chez-minimum-version "9.4") -;;; REPL support: +;;; REPL support (defun geiser-chez--binary () "Return path to Chez scheme binary." @@ -132,7 +131,7 @@ Return its local name." (geiser-eval--send/wait "(begin (import (geiser)) (write `((result ) (output . \"\"))) (newline))"))) -;;; Evaluation support: +;;; Evaluation support (defun geiser-chez--geiser-procedure (proc &rest args) "Transform PROC in string for a scheme procedure using ARGS." @@ -180,19 +179,15 @@ Return its local name." "(exit 0)") -;;; Error display: +;;; Error display and debugger (defun geiser-chez--enter-debugger () "Tell Geiser to interact with the debugger." (when geiser-chez-debug-on-exception - (geiser-switch nil 'chez) - (let ((bt-cmd "\n(debug)\n") - (repl-buffer (geiser-repl--repl/impl 'chez))) - (compilation-forget-errors) - (goto-char (point-max)) - (geiser-repl--prepare-send) - (comint-send-string repl-buffer bt-cmd) - (ignore-errors (next-error))) + (geiser-repl-switch nil 'chez) + (compilation-forget-errors) + (geiser-repl--send "(debug)") + (when geiser-chez-show-error-on-debug (geiser-repl--send "s")) t)) (defun geiser-chez--display-error (_module key msg) @@ -202,7 +197,7 @@ Return its local name." (geiser-edit--buttonize-files) (not (zerop (length msg))))) -;;; Keywords and syntax: +;;; Keywords and syntax (defconst geiser-chez--builtin-keywords '("call-with-input-file" diff --git a/src/geiser/geiser.ss b/src/geiser/geiser.ss index 62cd6ad..ba5d616 100644 --- a/src/geiser/geiser.ss +++ b/src/geiser/geiser.ss @@ -41,9 +41,10 @@ (lambda (k) (with-exception-handler (lambda (e) - (debug-condition e) ; save the condition for the debugger + (debug-condition e) ; save the condition for the debugger (k `((result "") (output . ,(get-output-string output-string)) + (debug #t) (error (key . condition) (msg . ,(as-string (display-condition e))))))) (lambda () @@ -106,13 +107,13 @@ (define not-found (gensym)) - (define current-environment (make-parameter environment?)) - (define (module-env env) (cond ((environment? env) env) ((list? env) (environment env)) (else #f))) + (define current-environment (make-parameter #f module-env)) + (define (try-eval sym . env) (call/cc (lambda (k) @@ -123,7 +124,7 @@ (define (geiser:eval module form) (call-with-result (lambda () - (parameterize ((current-environment (module-env module))) + (parameterize ((current-environment module)) (if (environment? (current-environment)) (eval form (current-environment)) (eval form)))))) |