summaryrefslogtreecommitdiff
path: root/doc/fun.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/fun.texi')
-rw-r--r--doc/fun.texi140
1 files changed, 88 insertions, 52 deletions
diff --git a/doc/fun.texi b/doc/fun.texi
index 7fbd545..4bd7e33 100644
--- a/doc/fun.texi
+++ b/doc/fun.texi
@@ -1,7 +1,7 @@
-@node Fun between the parens
+@node Fun between the parens, Index, The REPL, Top
@chapter Fun between the parens
-A good REPL is a must, but just about half the story of a good Scheme
+A good @repl{} is a must, but just about half the story of a good Scheme
hacking environment. Well, perhaps a bit more than a half; but, at any
rate, one surely needs also a pleasant way of editing source code. Don't
pay attention to naysayers: Emacs comes with an excellent editor
@@ -11,7 +11,7 @@ Geiser's support for writing Scheme code adds to Emacs'
@code{scheme-mode}, rather than supplanting it; and it does so by means
of a minor mode (unimaginatively dubbed @code{geiser-mode}) that defines
a bunch of new commands to try and, with the help of the same Scheme
-process giving you the REPL, make those Scheme buffers come to life.
+process giving you the @repl{}, make those Scheme buffers come to life.
@menu
* Activating Geiser::
@@ -42,12 +42,12 @@ you how to fix that in a moment.
The menu provides a good synopsis of everthing Geiser brings to the
party, including those keyboard shortcuts we Emacsers love. If you're
seeing the name of your favourite Scheme implementation in the
-mode-line, have a running REPL and are comfortable with Emacs, you can
-stop reading now and, instead, discover Geiser's joys by yourself. I've
-tried to make Geiser as self-documenting as any self-respecting Emacs
-package should be. If you follow this route, make sure to take a look at
-Geiser's customization buffers (@kbd{M-x customize-group @key{RET}
-geiser}): there's lot of fine tunning available there.
+mode-line, have a running @repl{} and are comfortable with Emacs, you
+can stop reading now and, instead, discover Geiser's joys by yourself.
+I've tried to make Geiser as self-documenting as any self-respecting
+Emacs package should be. If you follow this route, make sure to take a
+look at Geiser's customization buffers (@kbd{M-x customize-group
+@key{RET} geiser}): there's lot of fine tunning available there.
Since @i{geiser-mode} is a minor mode, you can toggle it with
@kbd{M-x geiser-mode}, and control its activation in hooks with the
@@ -67,21 +67,21 @@ not recognised as such by Emacs, just tell her about it with:
Now, @i{geiser-mode} is just a useless wretch unless there's a running
Scheme process backing it up. Meaning that virtually all the commands it
-provides require a REPL up and running, preferably corresponding to the
-correct Scheme implementation. In the following section, we'll see how
-to make sure that that's actually the case.
+provides require a @repl{} up and running, preferably corresponding to
+the correct Scheme implementation. In the following section, we'll see
+how to make sure that that's actually the case.
@node The source and the REPL, Documentation helpers, Activating Geiser, Fun between the parens
@section The source and the REPL
As i've already mentioned a couple of times, @i{geiser-mode} needs a
-running REPL to be operative. Thus, a common usage pattern will be for
-you to first call @code{run-geiser} (or one of its variants, see
+running @repl{} to be operative. Thus, a common usage pattern will be
+for you to first call @code{run-geiser} (or one of its variants, see
them described @ref{choosing-impl,,here}), and then open Scheme files;
but there's nothing wrong in first opening a couple Scheme buffers and
-then starting the REPL (you can even find it more convenient, since
-pressing @kbd{C-c C-z} in a Scheme buffer will start the REPL for you).
-Since Geiser supports more than one Scheme implementation, though,
+then starting the @repl{} (you can even find it more convenient, since
+pressing @kbd{C-c C-z} in a Scheme buffer will start the @repl{} for
+you). Since Geiser supports more than one Scheme implementation, though,
there's the problem of knowing which of them is to be associated with
each Scheme source file. Serviceable as it is, @i{geiser-mode} will try
to guess the correct implementation for you, according to the algorithm
@@ -109,7 +109,7 @@ element is used as the chosen implementation.
The contents of the file is scanned for hints on its associated
implementation. For instance, files that contain a @code{#lang}
directive will be considered Racket source code, while those with a
-@code{define-module} form in them will be assigned to a Guile REPL.
+@code{define-module} form in them will be assigned to a Guile @repl{}.
@item
The current buffer's file name is checked against the rules given in
@code{geiser-implementations-alist}, and the first match is applied. You
@@ -136,14 +136,14 @@ default value for the latter variable:
((regexp "\\.rkt$") racket))
@end example
which describes the simple heuristic that files with @file{.scm} as
-extension are by default associated to a Guile REPL while those ending
-in @file{.ss} or @file{.rkt} correspond to Racket's implementation (with
-the caveat that these rules are applied only if the previous heuristics
-have failed to detect the correct implementation, and that they'll match
-only if the corresponding implementation is active). You can add rules
-to @code{geiser-implementations-alist} (or replace all of them) by
-customizing it. Besides regular expressions, you can also use a
-directory name; for instance, the following snippet:
+extension are by default associated to a Guile @repl{} while those
+ending in @file{.ss} or @file{.rkt} correspond to Racket's
+implementation (with the caveat that these rules are applied only if the
+previous heuristics have failed to detect the correct implementation,
+and that they'll match only if the corresponding implementation is
+active). You can add rules to @code{geiser-implementations-alist} (or
+replace all of them) by customizing it. Besides regular expressions, you
+can also use a directory name; for instance, the following snippet:
@example
(eval-after-load "geiser-impl"
'(add-to-list 'geiser-implementations-alist
@@ -156,18 +156,19 @@ first served, this new rule will take precedence over the default ones.
@subsubheading Switching between source files and the REPL
@anchor{switching-repl-buff} Once you have a working @i{geiser-mode},
-you can switch from Scheme source buffers to the REPL or @kbd{C-c C-z}.
-Those shortcuts map to the interactive command @code{switch-to-geiser}.
+you can switch from Scheme source buffers to the @repl{} or @kbd{C-c
+C-z}. Those shortcuts map to the interactive command
+@code{switch-to-geiser}.
If you use a numeric prefix, as in @kbd{C-u C-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 C-m} in the REPL, with
-the source file's module as argument; cf. @ref{Switching context}). This
-command is also bound to @kbd{C-c C-Z}, with a capital zed.
-
-Once you're in the REPL, the same @kbd{C-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
+teleported to the @repl{}, the latter will switch to the namespace of
+the Scheme source file (as if you had used @kbd{C-c C-m} in the @repl{},
+with the source file's module as argument; cf. @ref{Switching context}).
+This command is also bound to @kbd{C-c C-Z}, with a capital zed.
+
+Once you're in the @repl{}, the same @kbd{C-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.
@@ -185,8 +186,8 @@ a one to one correspondence between paths and modules, while Guile
relies on explicit @code{define-module} forms in the source file).
Now that we have @code{geiser-mode} happily alive in our Scheme buffers
-and communicating with the right REPL instance, let us see what it can
-do for us, besides jumping to and fro.
+and communicating with the right @repl{} instance, let us see what it
+can do for us, besides jumping to and fro.
@node Documentation helpers, Evaluating Scheme code, The source and the REPL, Fun between the parens
@section Documentation helpers
@@ -195,16 +196,17 @@ do for us, besides jumping to and fro.
The first thing you will notice by moving around Scheme source is that,
every now and then, the echo area lightens up with the same autodoc
-messages we know and love from our REPL forays. This happens every time
-the Scheme process is able to recognise an identifier in the buffer, and
-provide information either on its value (for variables) or on its arity
-and the name of its formal arguments (for procedures and macros). That
-information will only be available if the module the identifier belongs
-to has been loaded in the running Scheme image. So it can be the case
-that, at first, no autodoc is shown for identifiers defined in the file
-you're editing. But as soon as you evaluate them (either individually or
-collectively using any of the devices described in @ref{Evaluating
-Scheme code}) their signatures will start appearing in the echo area.
+messages we know and love from our @repl{} forays. This happens every
+time the Scheme process is able to recognise an identifier in the
+buffer, and provide information either on its value (for variables) or
+on its arity and the name of its formal arguments (for procedures and
+macros). That information will only be available if the module the
+identifier belongs to has been loaded in the running Scheme image. So it
+can be the case that, at first, no autodoc is shown for identifiers
+defined in the file you're editing. But as soon as you evaluate them
+(either individually or collectively using any of the devices described
+in @ref{Evaluating Scheme code}) their signatures will start appearing
+in the echo area.
Autodoc activation is controlled by a minor mode, @code{geiser-autodoc},
which you can toggle with @kbd{M-x geiser-autodoc}, or its associated
@@ -318,10 +320,44 @@ incremental evaluation. Some people disagree; if you happen to find
@uref{http://blog.racket-lang.org/2009/03/drscheme-repl-isnt-lisp.html,
their arguments} convincing, you don't have to throw away Geiser
together with the baby: @kbd{M-x geiser-restart-repl} will let you
-restart the REPL as many times as you see fit.
-
-For all of you bearded old lispers still with me, here are the commands
-performing incremental evaluation in Geiser:
+restart the @repl{} as many times as you see fit.
+
+For all of you bearded old lispers still with me, here are some of the
+commands performing incremental evaluation in Geiser.
+
+@code{geiser-eval-last-sexp}, bound to @kbd{C-x C-e}, will eval the
+s-expression just before point.
+
+@code{geiser-eval-definition}, bound to @kbd{C-M-x}, finds the topmost
+definition containing point and sends it for evaluation. The variant
+@code{geiser-eval-definition-and-go} (@kbd{C-c M-e}) works in the same
+way, but it also teleports you to @repl{} after the evaluation.
+
+@code{geiser-eval-region}, bound to @kbd{C-c C-r}, evals the current
+region. Again, there's an @i{and go} version available,
+@code{geiser-eval-region-and-go}, bound to @kbd{C-c M-r}.
+
+For all the commands above, the result of the evaluation is displayed in
+the minibuffer, unless it causes a (scheme-side) error, in which case
+Geiser will report the problem by opening a debug buffer with
+information on what went wrong.
+
+At the risk of repeating myself, i'll remember you that all these
+evaluations will take place in the namespace of the module corresponding
+to the Scheme file from which you're sending your code, which, in
+general, will be different from the @repl{}'s current module. And, if
+all goes according to plan, (re)defined variables and procedures should
+be immediately visible inside and, if exported, outside their module.
+
+Besides evaluating expressions, definitions and regions, you can also
+macro-expand them. The corresponding keybindings start with the prefix
+@kbd{C-c C-m} and end, respectively, with @kbd{C-e}, @kbd{C-x} and
+@kbd{C-r}. The result of the macro expansion always appears in a pop up
+buffer.
+
+When an error occurs during evaluation, you'll be presented with a
+backtrace, in a new buffer where file paths locating the origin of the
+error are clickable (you can navigate them using the @key{TAB} key).
@node Jumping around, Geiser writes for you, Evaluating Scheme code, Fun between the parens
@section Jumping around