diff options
-rw-r--r-- | elisp/geiser-guile.el | 31 | ||||
-rw-r--r-- | elisp/geiser-racket.el | 4 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 38 |
3 files changed, 50 insertions, 23 deletions
diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index 55116d3..7f73efe 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -148,6 +148,9 @@ This function uses `geiser-guile-init-file' if it exists." (defun geiser-guile--enter-command (module) (geiser-guile--module-cmd module ",m %s" "(guile-user)")) + +(defun geiser-guile--exit-command () ",q") + (defun geiser-guile--symbol-begin (module) (if module (max (save-excursion (beginning-of-line) (point)) @@ -158,20 +161,19 @@ This function uses `geiser-guile-init-file' if it exists." ;;; Error display (defun geiser-guile--enter-debugger () - (when (eq key 'geiser-debugger) - (let ((bt-cmd (format ",%s\n" - (if geiser-guile-debug-show-bt-p "bt" "fr")))) - (compilation-forget-errors) - (goto-char (point-max)) - (comint-send-string nil "((@ (geiser emacs) ge:newline))\n") - (comint-send-string nil ",error-message\n") - (comint-send-string nil bt-cmd) - (when geiser-guile-show-debug-help-p - (message "Debug REPL. Enter ,q to quit, ,h for help.")) - (when geiser-guile-jump-on-debug-p - (accept-process-output (get-buffer-process (current-buffer)) - 0.2 nil t) - (ignore-errors (next-error)))))) + (let ((bt-cmd (format ",%s\n" + (if geiser-guile-debug-show-bt-p "bt" "fr")))) + (compilation-forget-errors) + (goto-char (point-max)) + (comint-send-string nil "((@ (geiser emacs) ge:newline))\n") + (comint-send-string nil ",error-message\n") + (comint-send-string nil bt-cmd) + (when geiser-guile-show-debug-help-p + (message "Debug REPL. Enter ,q to quit, ,h for help.")) + (when geiser-guile-jump-on-debug-p + (accept-process-output (get-buffer-process (current-buffer)) + 0.2 nil t) + (ignore-errors (next-error))))) (defun geiser-guile--display-error (module key msg) (newline) @@ -245,6 +247,7 @@ The new level is set using the value of `geiser-guile-warning-level'." (marshall-procedure geiser-guile--geiser-procedure) (find-module geiser-guile--get-module) (enter-command geiser-guile--enter-command) + (exit-command geiser-guile--exit-command) (import-command geiser-guile--import-command) (find-symbol-begin geiser-guile--symbol-begin) (display-error geiser-guile--display-error) diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el index 6d04858..fc3fe23 100644 --- a/elisp/geiser-racket.el +++ b/elisp/geiser-racket.el @@ -123,6 +123,9 @@ This function uses `geiser-racket-init-file' if it exists." (not (zerop (length module))) (format "(require %s)" module))) +(defun geiser-racket--exit-command () + (not (geiser-eval--send/result '(:eval (exit) geiser/emacs)))) + (defconst geiser-racket--binding-forms '(for for/list for/hash for/hasheq for/and for/or for/lists for/first for/last for/fold @@ -205,6 +208,7 @@ This function uses `geiser-racket-init-file' if it exists." (find-module geiser-racket--get-module) (enter-command geiser-racket--enter-command) (import-command geiser-racket--import-command) + (exit-command geiser-racket--exit-command) (find-symbol-begin geiser-racket--symbol-begin) (display-error geiser-racket--display-error) (display-help geiser-racket--external-help) diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 1c2a95a..e0db2c3 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -89,6 +89,11 @@ expression, if any." :type 'boolean :group 'geiser-repl) +(geiser-custom--defcustom geiser-repl-query-on-exit-p nil + "Whether to prompt for confirmation on \\[geiser-repl-exit]." + :type 'boolean + :group 'geiser-repl) + ;;; Geiser REPL buffers and processes: @@ -170,6 +175,17 @@ the REPL has entered debugging mode.") has been initialised. All Geiser functionality is available to you at that point.") +(geiser-impl--define-caller geiser-repl--enter-cmd enter-command (module) + "Function taking a module designator and returning a REPL enter +module command as a string") + +(geiser-impl--define-caller geiser-repl--import-cmd import-command (module) + "Function taking a module designator and returning a REPL import +module command as a string") + +(geiser-impl--define-caller geiser-repl--exit-cmd exit-command () + "Function returning the REPL exit command as a string") + (defun geiser-repl--start-repl (impl) (message "Starting Geiser REPL for %s ..." impl) (geiser-repl--to-repl-buffer impl) @@ -269,10 +285,6 @@ If no REPL is running, execute `run-geiser' to start a fresh one." (let ((comint-input-filter (lambda (x) nil))) (comint-send-input nil t)))) -(geiser-impl--define-caller geiser-repl--enter-cmd enter-command (module) - "Function taking a module designator and returning a REPL enter -module command as a string") - (defun switch-to-geiser-module (&optional module buffer) "Switch to running Geiser REPL and try to enter a given module." (interactive) @@ -285,10 +297,6 @@ module command as a string") (switch-to-geiser nil nil (or buffer (current-buffer)))) (geiser-repl--send cmd))) -(geiser-impl--define-caller geiser-repl--import-cmd import-command (module) - "Function taking a module designator and returning a REPL import -module command as a string") - (defun geiser-repl-import-module (&optional module) "Import a given module in the current namespace of the REPL." (interactive) @@ -300,6 +308,18 @@ module command as a string") (switch-to-geiser nil nil (current-buffer)) (geiser-repl--send cmd))) +(defun geiser-repl-exit (&optional arg) + "Exit the current REPL. +With a prefix argument, force exit by killing the scheme process." + (interactive "P") + (when (or (not geiser-repl-query-on-exit-p) + (y-or-n-p "Really quit this REPL? ")) + (let ((cmd (and (not arg) + (geiser-repl--exit-cmd geiser-impl--implementation)))) + (if cmd + (when (stringp cmd) (geiser-repl--send cmd)) + (comint-kill-subjob))))) + (defun geiser-repl-nuke () "Try this command if the REPL becomes unresponsive." (interactive) @@ -485,7 +505,7 @@ module command as a string") ("Module documentation" ("\C-c\C-dm" "\C-c\C-d\C-m") geiser-repl--doc-module "Documentation for module at point" :enable (symbol-at-point)) -- - ("Kill Scheme interpreter" "\C-c\C-q" comint-kill-subjob + ("Kill Scheme interpreter" "\C-c\C-q" geiser-repl-exit :enable (geiser-repl--live-p)) ("Restart" "\C-c\C-z" switch-to-geiser :enable (not (geiser-repl--live-p))) ("Revive REPL" "\C-c\C-k" geiser-repl-nuke |