summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-07-25 23:43:50 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-07-25 23:43:50 +0200
commit235543503d09a52a513054ed75ac2506b7ce87bf (patch)
treee75df482f8154e55a1a418fc38b5ccd4c2c09364
parent941d65165b3bce917d3bff9952e582800ccf2981 (diff)
downloadgeiser-guile-235543503d09a52a513054ed75ac2506b7ce87bf.tar.gz
geiser-guile-235543503d09a52a513054ed75ac2506b7ce87bf.tar.bz2
C-c z as a to and fro jump, plus documentation.
-rw-r--r--README2
-rw-r--r--doc/fun.texi25
-rw-r--r--doc/repl.texi4
-rw-r--r--elisp/geiser-debug.el2
-rw-r--r--elisp/geiser-doc.el6
-rw-r--r--elisp/geiser-mode.el7
-rw-r--r--elisp/geiser-repl.el26
7 files changed, 52 insertions, 20 deletions
diff --git a/README b/README
index fcf5f4f..09b52c7 100644
--- a/README
+++ b/README
@@ -130,7 +130,7 @@
*** In the REPL
|----------------+----------------------------------------------------|
- | C-c C-z, C-c z | Start Scheme REPL (if it's not running) |
+ | C-c C-z, C-c z | Start Scheme REPL, or jump to previous buffer |
| C-c C-q | Kill Scheme process |
|----------------+----------------------------------------------------|
| M-. | Edit identifier at point |
diff --git a/doc/fun.texi b/doc/fun.texi
index 44ca833..aae3c40 100644
--- a/doc/fun.texi
+++ b/doc/fun.texi
@@ -160,16 +160,33 @@ first served, this new rule will take precedence over the default ones.
you can switch from Scheme source buffers to the REPL using @kbd{C-c z}
or @kbd{C-c C-z} (as you might have noticed, in Geiser, whenever a key
chord ends with a single letter, there's an equivalent one with that
-letter modified by @key{Ctrl}). If you use a prefix, as in @kbd{C-u C-c
-z}, besides being teleported to the REPL, the latter will switch to the
-namespace of the Scheme source file (as if you had used @kbd{C-c m} in
-the REPL, cf. @ref{Switching context}).
+letter modified by @key{Ctrl}). Those shortcuts map to the interactive
+command @code{switch-to-geiser}.
+
+If you use a numeric prefix, as in @kbd{C-u C-c z}, besides being
+teleported to the REPL, the latter will switch to the namespace of the
+Scheme source file (as if you had used @kbd{C-c m} in the REPL, with the
+source file's module as argument; cf. @ref{Switching context}).
+
+Once you're in the REPL, the same @kbd{C-c z} shortcut will bring you
+back to the buffer you jumped from, provided you don't kill the Scheme
+process in between. This is why the command is called
+@i{switch-to-geiser} instead of @i{switch-to-repl}, and what makes it
+really handy, if you ask me.
If for some reason you're not happy with the Scheme implementation that
Geiser has assigned to your file, you can change it with @kbd{C-c s},
and probably take a look at @ref{switching-repl-buff,,the previous
subsection} to make sure that Geiser doesn't get confused again.
+@subsubheading A note about context
+As explained before (@pxref{Modus operandi}), all Geiser activities take
+place in the context of the @i{current namespace}, which, for Scheme
+buffers, corresponds to the module that the Scheme implementation
+associates to the source file at hand (for instance, in Racket, there's
+a one to one correspondence between paths and modules, while Guile
+relies on @code{define-module}).
+
@node Autodoc redux, Evaluating Scheme code, The source and the REPL, Fun between the parens
@section Autodoc redux
diff --git a/doc/repl.texi b/doc/repl.texi
index aa15367..272a052 100644
--- a/doc/repl.texi
+++ b/doc/repl.texi
@@ -79,7 +79,9 @@ the input received from then underlying Scheme (specially if you have
multiple threads writing to the standard ports), and become
irresponsive; you can try this command to try to revive it without
killing the process. Finally, if worse comes to worst and the process is
-dead, @kbd{C-c z} will restart it.
+dead, @kbd{C-c z} will restart it (but the same shortcut, issued when
+the REPL is alive, will bring you back to the buffer you came from, as
+explained @ref{switching-repl-buff,,here}).
The remaining commands are meatier, and deserve sections of their own.
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)