diff options
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-debug.el | 2 | ||||
-rw-r--r-- | elisp/geiser-doc.el | 6 | ||||
-rw-r--r-- | elisp/geiser-mode.el | 7 | ||||
-rw-r--r-- | elisp/geiser-repl.el | 26 |
4 files changed, 27 insertions, 14 deletions
diff --git a/elisp/geiser-debug.el b/elisp/geiser-debug.el index 46d4509..4c1f93e 100644 --- a/elisp/geiser-debug.el +++ b/elisp/geiser-debug.el @@ -72,7 +72,7 @@ non-null value.") (module (geiser-eval--get-module))) (if (eq key 'geiser-debugger) (progn - (switch-to-geiser) + (switch-to-geiser nil nil (current-buffer)) (geiser-debug--display-error impl module key output)) (geiser-debug--with-buffer (erase-buffer) diff --git a/elisp/geiser-doc.el b/elisp/geiser-doc.el index bd84d7e..e8e3f58 100644 --- a/elisp/geiser-doc.el +++ b/elisp/geiser-doc.el @@ -352,6 +352,10 @@ With prefix, the current page is deleted from history." (set-keymap-parent map button-buffer-map) map)) +(defun geiser-doc-switch-to-repl () + (interactive) + (switch-to-geiser nil nil (current-buffer))) + (geiser-menu--defmenu doc geiser-doc-mode-map ("Next page" ("n" "f") geiser-doc-next "Next item" :enable (geiser-doc--history-next-p)) @@ -359,7 +363,7 @@ With prefix, the current page is deleted from history." :enable (geiser-doc--history-previous-p)) ("Next link" nil forward-button) ("Previous link" nil backward-button) - ("Go to REPL" ("z" "\C-cz" "\C-c\C-z") switch-to-geiser) + ("Go to REPL" ("z" "\C-cz" "\C-c\C-z") geiser-doc-switch-to-repl) ("Refresh" ("g" "r") geiser-doc-refresh "Refresh current page") -- ("Edit symbol" ("." "\M-.") geiser-doc-edit-symbol-at-point diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el index 72d3536..ff50a10 100644 --- a/elisp/geiser-mode.el +++ b/elisp/geiser-mode.el @@ -55,7 +55,7 @@ ;;; Evaluation commands: (defun geiser--go-to-repl () - (switch-to-geiser) + (switch-to-geiser nil nil (current-buffer)) (push-mark) (goto-char (point-max))) @@ -155,8 +155,9 @@ With prefix, recursively macro-expand the resulting expression." "Switches to Geiser REPL. With prefix, try to enter the current's buffer module." (interactive "P") - (if arg (switch-to-geiser-module (geiser-eval--get-module)) - (switch-to-geiser))) + (if arg + (switch-to-geiser-module (geiser-eval--get-module) (current-buffer)) + (switch-to-geiser nil nil (current-buffer)))) (defun geiser-mode-switch-to-repl-and-enter () "Switches to Geiser REPL and enters current's buffer module." diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 694f21b..d969164 100644 --- a/elisp/geiser-repl.el +++ b/elisp/geiser-repl.el @@ -222,7 +222,10 @@ you at that point.") "Start Geiser for scheme implementation: ")))) (geiser-repl--start-repl impl)) -(defun switch-to-geiser (&optional ask impl) +(make-variable-buffer-local + (defvar geiser-repl--last-scm-buffer nil)) + +(defun switch-to-geiser (&optional ask impl buffer) "Switch to running Geiser REPL. With prefix argument, ask for which one if more than one is running. If no REPL is running, execute `run-geiser' to start a fresh one." @@ -233,12 +236,17 @@ If no REPL is running, execute `run-geiser' to start a fresh one." (car geiser-repl--repls)))) ((and (not ask) impl (geiser-repl--repl/impl impl))))) (pop-up-windows geiser-repl-window-allow-split)) - (if repl - (pop-to-buffer repl) - (run-geiser (or impl - (and (not ask) - (geiser-repl--only-impl-p)) - (geiser-repl--read-impl "Switch to scheme REPL: ")))))) + (cond ((and (eq (current-buffer) repl) + (buffer-live-p geiser-repl--last-scm-buffer)) + (pop-to-buffer geiser-repl--last-scm-buffer)) + (repl (pop-to-buffer repl)) + (t (run-geiser (or impl + (and (not ask) + (geiser-repl--only-impl-p)) + (geiser-repl--read-impl + "Switch to scheme REPL: "))))) + (when (and buffer (eq major-mode 'geiser-repl-mode)) + (setq geiser-repl--last-scm-buffer buffer)))) (defalias 'geiser 'switch-to-geiser) @@ -254,7 +262,7 @@ If no REPL is running, execute `run-geiser' to start a fresh one." "Function taking a module designator and returning a REPL enter module command as a string") -(defun switch-to-geiser-module (&optional module) +(defun switch-to-geiser-module (&optional module buffer) "Switch to running Geiser REPL and try to enter a given module." (interactive) (let* ((module (or module @@ -262,7 +270,7 @@ module command as a string") (cmd (and module (geiser-repl--enter-cmd geiser-impl--implementation module)))) - (switch-to-geiser) + (switch-to-geiser nil nil buffer) (geiser-repl--send cmd))) (geiser-impl--define-caller geiser-repl--import-cmd import-command (module) |