Links to olde blog posts
[geiser.git] / doc / parens.texi
blob118c0201f39f853a9ae464eb43f79dc93eeeaeaf
1 @node Between the parens, Cheat sheet, The REPL, Top
2 @chapter Between the parens
4 A good REPL is a must, but just about half the story of a good Scheme
5 hacking environment.  Well, perhaps a bit more than a half; but, at any
6 rate, one surely needs also a pleasant way of editing source code.  Don't
7 pay attention to naysayers: Emacs comes with an excellent editor
8 included for about any language on Earth, and just the best one when
9 that language is sexpy (especially if you use
10 @ifhtml
11 @ref{paredit,,Paredit}).
12 @end ifhtml
13 @ifnothtml
14 Paredit).
15 @end ifnothtml
16 Geiser's support for writing Scheme code adds to Emacs'
17 @code{scheme-mode}, rather than supplanting it; and it does so by means
18 of a minor mode (unimaginatively dubbed @code{geiser-mode}) that defines
19 a bunch of new commands to try and, with the help of the same Scheme
20 process giving you the REPL, make those Scheme buffers come to life.
22 @menu
23 * Activating Geiser::
24 * The source and the REPL::
25 * Documentation helpers::
26 * To eval or not to eval::
27 * To err perchance to debug::
28 * Jumping around::
29 * Geiser writes for you::
30 @end menu
32 @node Activating Geiser, The source and the REPL, Between the parens, Between the parens
33 @section Activating Geiser
35 @cindex geiser-mode
36 @img{geiser-mode, right}
37 With Geiser installed following any of the
38 procedures described in @ref{The easy and quick way} or @ref{From the
39 source's mouth}, Emacs will automatically activate @i{geiser-mode} when
40 opening a Scheme buffer.  Geiser also instructs Emacs to consider files
41 with the extension @file{rkt} part of the family, so that, in principle,
42 there's nothing you need to do to ensure that Geiser's extensions will
43 be available, out of the box, when you start editing Scheme code.
45 Indications that everything is working according to plan include the
46 'Geiser' minor mode indicator in your mode-line and the appearance of a
47 new entry for Geiser in the menu bar.  If, moreover, the mode-line
48 indicator is the name of a Scheme implementation, you're indeed in a
49 perfect world; otherwise, don't despair and keep on reading: i'll tell
50 you how to fix that in a moment.
52 @cindex geiser-mode commands
53 The menu provides a good synopsis of everything Geiser brings to the
54 party, including those keyboard shortcuts we Emacsers love.  If you're
55 seeing the name of your favourite Scheme implementation in the
56 mode-line, have a running REPL and are comfortable with Emacs, you can
57 stop reading now and, instead, discover Geiser's joys by yourself.  I've
58 tried to make Geiser as self-documenting as any self-respecting Emacs
59 package should be.  If you follow this route, make sure to take a look at
60 Geiser's customization buffers (@kbd{M-x customize-group @key{RET}
61 geiser}): there's lot of fine-tuning available there.  You might also
62 want to take a glance at
63 @ifhtml
64 our @ref{Cheat sheet,,cheat sheet}.
65 @end ifhtml
66 @ifnothtml
67 the tables in @pxref{Cheat sheet, our cheat sheet}.
68 @end ifnothtml
70 Since @i{geiser-mode} is a minor mode, you can toggle it with
71 @kbd{M-x geiser-mode}, and control its activation in hooks with the
72 functions @code{turn-on-geiser-mode} and @code{turn-off-geiser-mode}.
73 If, for some reason i cannot fathom, you prefer @i{geiser-mode} not
74 to be active by default, customizing @code{geiser-mode-auto-p} to
75 @code{nil} will do the trick.
77 @cindex scheme file extensions
78 And if you happen to use a funky extension for your Scheme files that is
79 not recognised as such by Emacs, just tell her about it with:
81 @example
82 (add-to-list 'auto-mode-alist '("\\.funky-extension\\'" . scheme-mode))
83 @end example
85 @cindex useless wretch
86 Now, @i{geiser-mode} is just a useless wretch unless there's a running
87 Scheme process backing it up.  Meaning that virtually all the commands it
88 provides require a REPL up and running, preferably corresponding to
89 the correct Scheme implementation.  In the following section, we'll see
90 how to make sure that that's actually the case.
92 @node The source and the REPL, Documentation helpers, Activating Geiser, Between the parens
93 @section The source and the REPL
95 As i've already mentioned a couple of times, @i{geiser-mode} needs a
96 running REPL to be operative.  Thus, a common usage pattern will be
97 for you to first call @code{run-geiser}
98 @ifhtml
99 (or @ref{choosing-impl,,one of its variants}),
100 @end ifhtml
101 @ifnothtml
102 (or one of its variants, e.g. @code{run-guile}),
103 @end ifnothtml
104 and then open some Scheme files;
105 but there's nothing wrong in first opening a couple Scheme buffers and
106 then starting the REPL (you can even find it more convenient, since
107 pressing @kbd{C-c C-z} in a Scheme buffer will start the REPL for
108 you).  Since Geiser supports more than one Scheme implementation, though,
109 there's the problem of knowing which of them is to be associated with
110 each Scheme source file.  Serviceable as it is, @i{geiser-mode} will try
111 to guess the correct implementation for you, according to the algorithm
112 described below.
113 @ifhtml
114 If you find that Geiser is already guessing right the Scheme
115 implementation, feel free to skip to the @ref{switching-repl-buff,,next
116 subsection}.
117 @end ifhtml
119 @subsubheading How Geiser associates a REPL to your Scheme buffer
120 @cindex scheme implementation, choosing
121 @anchor{repl-association} To determine what Scheme implementation
122 corresponds to a given source file, Geiser uses the following algorithm:
124 @enumerate
125 @item
126 If the file-local variable @code{geiser-scheme-implementation} is
127 defined, its value is used.  A common way of setting buffer-local
128 variables is to put them in a comment near the beginning of the file,
129 surrounded by @code{-*-} marks, as in:
131 @example
132 ;; -*- geiser-scheme-implementation: guile -*-
133 @end example
135 @item
136 If you've customized @code{geiser-active-implementations} so that it's a
137 single-element
138 @ifhtml
139 list (as explained in @ref{choosing-impl,,here}),
140 @end ifhtml
141 @ifnothtml
142 list,
143 @end ifnothtml
144 that element is used as the chosen implementation.
145 @item
146 The contents of the file is scanned for hints on its associated
147 implementation.  For instance, files that contain a @code{#lang}
148 directive will be considered Racket source code, while those with a
149 @code{define-module} form in them will be assigned to a Guile REPL.
150 @item
151 The current buffer's file name is checked against the rules given in
152 @code{geiser-implementations-alist}, and the first match is applied.  You
153 can provide your own rules by customizing this variable, as explained
154 below.
155 @item
156 If we haven't been lucky this far and you have customized
157 @code{geiser-default-implementation} to the name of a supported
158 implementation, we'll follow your lead.
159 @item
160 See?  That's the problem of being a smart aleck: one's always outsmarted
161 by people around.  At this point, @i{geiser-mode} will humbly give up and
162 ask you to explicitly choose the Scheme implementation.
163 @end enumerate
165 As you can see in the list above, there are several ways to influence
166 Geiser's guessing by means of customizable variables.  The most direct (and
167 most impoverishing) is probably limiting the active implementations to a
168 single one, while customizing @code{geiser-implementations-alist} is the
169 most flexible (and, unsurprisingly, also the most complex).  Here's the
170 default value for the latter variable:
172 @example
173 (((regexp "\\.scm$") guile)
174  ((regexp "\\.ss$") racket)
175  ((regexp "\\.rkt$") racket))
176 @end example
178 @noindent
179 which describes the simple heuristic that files with @file{.scm} as
180 extension are by default associated to a Guile REPL while those ending
181 in @file{.ss} or @file{.rkt} correspond to Racket's implementation (with
182 the caveat that these rules are applied only if the previous heuristics
183 have failed to detect the correct implementation, and that they'll match
184 only if the corresponding implementation is active).  You can add rules
185 to @code{geiser-implementations-alist} (or replace all of them) by
186 customizing it.  Besides regular expressions, you can also use a
187 directory name; for instance, the following snippet:
189 @example
190 (eval-after-load "geiser-impl"
191   '(add-to-list 'geiser-implementations-alist
192                 '((dir "/home/jao/prj/frob") guile)))
193 @end example
195 @noindent
196 will add a new rule that says that any file inside my
197 @file{/home/jao/prj/frob} directory (or, recursively, any of its
198 children) is to be assigned to Guile.  Since rules are first matched,
199 first served, this new rule will take precedence over the default ones.
201 @cindex autostart REPL
202 @cindex start REPL, automatically
203 A final tip: if you want Geiser to start automatically a REPL for you if
204 it notices that there's no one active when it enters @i{geiser-mode},
205 you can customize @code{geiser-mode-start-repl-p} to @code{t}.
207 @subsubheading Switching between source files and the REPL
208 @cindex switching to REPL
209 @cindex switching to source
210 @anchor{switching-repl-buff} Once you have a working @i{geiser-mode},
211 you can switch from Scheme source buffers to the REPL or @kbd{C-c
212 C-z}.  Those shortcuts map to the interactive command
213 @code{switch-to-geiser}.
215 @cindex switching to module
216 If you use a numeric prefix, as in @kbd{C-u C-c C-z}, besides being
217 teleported to the REPL, the latter will switch to the namespace of the
218 Scheme source file, as if you had used @kbd{C-c C-m} in the REPL, with
219 the source file's module as argument;
220 cf. discussion in
221 @altr{Switching context,,Switching context,. This}
222 command is also bound to @kbd{C-c C-a}.
224 Once you're in the REPL, the same @kbd{C-c C-z} shortcut will bring
225 you back to the buffer you jumped from, provided you don't kill the
226 Scheme process in between.  This is why the command is called
227 @i{switch-to-geiser} instead of @i{switch-to-repl}, and what makes it
228 really handy, if you ask me.
230 @cindex switching schemes
231 If for some reason you're not happy with the Scheme implementation that
232 Geiser has assigned to your file, you can change it with @kbd{C-c C-s},
233 and you probably should take a look at
234 @ifhtml
235 @ref{repl-association,,the previous subsection}
236 @end ifhtml
237 @ifnothtml
238 the previous subsection
239 @end ifnothtml
240 to make sure that Geiser
241 doesn't get confused again.
243 @subsubheading A note about context
244 As explained before (@pxref{Modus operandi}), all Geiser activities take
245 place in the context of the @i{current namespace}, which, for Scheme
246 buffers, corresponds to the module that the Scheme implementation
247 associates to the source file at hand (for instance, in Racket, there's
248 a one-to-one correspondence between paths and modules, while Guile
249 relies on explicit @code{define-module} forms in the source file).
251 Now that we have @code{geiser-mode} happily alive in our Scheme buffers
252 and communicating with the right REPL instance, let us see what it
253 can do for us, besides jumping to and fro.
255 @node Documentation helpers, To eval or not to eval, The source and the REPL, Between the parens
256 @section Documentation helpers
258 @subsubheading Autodoc redux
260 @cindex autodoc, in scheme buffers
261 The first thing you will notice by moving around Scheme source is that,
262 every now and then, the echo area lights up with the same autodoc
263 messages we know and love from our REPL forays.  This happens every
264 time the Scheme process is able to recognise an identifier in the
265 buffer, and provide information either on its value (for variables) or
266 on its arity and the name of its formal arguments (for procedures and
267 macros).  That information will only be available if the module the
268 identifier belongs to has been loaded in the running Scheme image.  So it
269 can be the case that, at first, no autodoc is shown for identifiers
270 defined in the file you're editing.  But as soon as you evaluate them
271 (either individually or collectively using any of the devices described
272 in @ref{To eval or not to eval}) their signatures will start appearing
273 in the echo area.
275 @cindex disabling autodoc
276 @cindex manual autodoc
277 Autodoc activation is controlled by a minor mode, @code{geiser-autodoc},
278 which you can toggle with @kbd{M-x geiser-autodoc-mode}, or its associated
279 keyboard shortcut, @kbd{C-c C-d a}.  That @t{/A} indicator in the
280 mode-line is telling you that autodoc is active.  If you prefer that it
281 be inactive by default (e.g., because you're connecting to a really
282 remote scheme and want to minimize network exchanges), just set
283 @code{geiser-mode-autodoc-p} to @code{nil} in your customization files.
284 Even when autodoc mode is off, you can use @code{geiser-autodoc-show},
285 bound by default to @kbd{C-c C-d s}, to show the autodoc string for the
286 symbol at point.
288 @cindex autodoc explained
289 @img{autodoc-scm, right}
290 The way autodoc displays information deserves
291 some explanation.  It will first show the name of the module where the
292 identifier at hand is defined, followed by a colon and the identifier
293 itself.  If the latter corresponds to a procedure or macro, it will be
294 followed by a list of argument names, starting with the ones that are
295 required.  Then there comes a list of optional arguments, if any,
296 enclosed in parentheses.  When an optional argument has a default value
297 (or a form defining its default value), autodoc will display it after
298 the argument name.  When the optional arguments are keywords, their names
299 are prefixed with ``#:'' (i.e., their names @i{are} keywords).  An
300 ellipsis (@dots{}) serves as a marker of an indeterminate number of
301 parameters, as is the case with @i{rest} arguments or when autodoc
302 cannot fathom the exact number of arguments (this is often the case with
303 macros defined using @code{syntax-case}).  Another way in which autodoc
304 displays its ignorance is by using an underscore to display parameters
305 whose name is beyond its powers.
307 @img{autodoc-multi, right}
308 It can also be the case that a function or
309 macro has more than one signature (e.g., functions defined using
310 @code{case-lambda}, or some @code{syntax-rules} macros, for which Geiser
311 has often the black magic necessary to retrieve their actual arities).
312 In those cases, autodoc shows all known signatures (using the above
313 rules for each one) separated by a vertical bar (|).
315 As you have already noticed, the whole autodoc message is enclosed in
316 parentheses.  After all, we're talking about Scheme here.
318 @cindex autodoc for variables
319 @img{autodoc-var, right}
320 Finally, life is much easier when your cursor
321 is on a symbol corresponding to a plain variable: you'll see in the echo
322 area its name, preceded by the module where it's defined, and followed
323 by its value, with an intervening arrow for greater effect.  This time,
324 there are no enclosing parentheses (i hope you see the logic in my
325 madness).
327 @cindex autodoc customized
328 You can change the way Geiser displays the module/identifier combo by
329 customizing @code{geiser-autodoc-identifier-format}.  For example, if you
330 wanted a tilde surrounded by spaces instead of a colon as a separator,
331 you would write something like:
333 @example
334 (setq geiser-autodoc-identifier-format "%s ~ %s")
335 @end example
337 @noindent
338 in your Emacs initialisation files.  There's also a face
339 (@code{geiser-font-lock-autodoc-identifier}) that you can customize (for
340 instance, with @kbd{M-x customize-face}) to change the appearance of the
341 text.  And another one (@code{geiser-font-lock-autodoc-current-arg}) that
342 controls how the current argument position is highlighted.
344 @subsubheading Other documentation commands
346 @anchor{doc-browser}Sometimes, autodoc won't provide enough information
347 for you to understand what a function does.  In those cases, you can ask
348 Geiser to ask the running Scheme for further information on a given
349 identifier or module.
351 @cindex documentation for symbol
352 @cindex docstrings, maybe
353 For symbols, the incantation is @kbd{M-x geiser-doc-symbol-at-point}, or
354 @kbd{C-c C-d C-d} for short.  If the associated Scheme supports
355 docstrings (as, for instance, Guile does), you'll be teleported to a new
356 Emacs buffer displaying Geiser's documentation browser, filled with
357 information about the identifier, including its docstring (if any;
358 unfortunately, that an implementation supports docstrings doesn't mean
359 that they're used everywhere).
361 @imgc{docstring}
363 Pressing @kbd{q} in the documentation buffer will bring you back,
364 enlightened, to where you were.  There's also a handful of other
365 navigation commands available in that buffer, which you can discover by
366 means of its menu or via the good old @kbd{C-h m} command.  And feel free
367 to use the navigation buttons and hyperlinks that justify my calling
368 this buffer a documentation browser.
370 For Racket, which does not support docstrings out of the box, this
371 command will provide less information, but the documentation browser
372 will display the corresponding contract when it's available, as well as
373 some other tidbits for re-exported identifiers.
375 @imgc{docstring-racket}
377 You can also ask Geiser to display information about a module, in the
378 form of a list of its exported identifiers, using @kbd{C-c C-d C-m},
379 exactly as you would do in
380 @altr{repl-mod,the REPL,The REPL,.}
382 In both cases, the documentation browser will show a couple of buttons
383 giving you access to further documentation.  First, you'll see a button
384 named @i{source}: pressing it you'll jump to the symbol's definition.
385 The second button, dubbed @i{manual}, will open the Scheme
386 implementation's manual page for the symbol at hand.  For Racket, that
387 will open your web browser displaying the corresponding reference's page
388 (using the HTML browser in Racket's configuration, which you can edit in
389 DrRacket's preferences dialog, or by setting
390 @code{plt:framework-pref:external-browser} directly in
391 @file{~/.racket/racket-prefs.rktd}), while in Guile a lookup will be
392 performed in the texinfo manual.
394 @cindex Guile info nodes
395 For Guile, the manual lookup uses the info indexes in the standard
396 Guile info nodes, which are usually named ``guile'' or ``guile-2.0''.
397 If yours are named differently, just add your name to the customizable
398 variable @code{geiser-guile-manual-lookup-nodes}.
400 A list of all navigation commands in the documentation browser is
401 available in
402 @altr{Documentation browser,our cheat-sheet,Documentation browser,.}
404 @cindex opening manual pages
405 You can also skip the documentation browser and jump directly to the
406 manual page for the symbol at point with the command
407 @code{geiser-doc-look-up-manual}, bound to @kbd{C-c C-d i}.
409 @node To eval or not to eval, To err perchance to debug, Documentation helpers, Between the parens
410 @section To eval or not to eval
412 @cindex philosophy
413 @cindex incremental development
414 One of Geiser's main goals is to facilitate incremental development.  You
415 might have noticed that i've made a big fuss of Geiser's ability to
416 recognize context, by being aware of the namespace where its operations
417 happen.
419 That awareness is especially important when evaluating code in your
420 scheme buffers, using the commands described below.  They allow you to
421 send code to the running Scheme with a granularity ranging from whole
422 files to single s-expressions.  That code will be evaluated in the module
423 associated with the file you're editing, allowing you to redefine values
424 and procedures to your heart's (and other modules') content.
426 @cindex incremental development, evil
427 Macros are, of course, another kettle of fish: one needs to re-evaluate
428 uses of a macro after redefining it.  That's not a limitation imposed by
429 Geiser, but a consequence of how macros work in Scheme (and other
430 Lisps).  There's also the risk that you lose track of what's actually
431 defined and what's not during a given session.  But,
432 @uref{https://jaortega.wordpress.com/2009/03/29/from-my-cold-prying-hands,
433 in my opinion}, those are limitations we lispers are aware of, and they
434 don't force us to throw the baby with the bathwater and ditch
435 incremental evaluation.  Some people disagree; if you happen to find
436 @uref{https://blog.racket-lang.org/2009/03/the-drscheme-repl-isnt-the-one-in-emacs.html,
437 their arguments} convincing, you don't have to throw away Geiser
438 together with the baby: @kbd{M-x geiser-restart-repl} will let you
439 restart the REPL as many times as you see fit.  Moreover, you can invoke
440 @kbd{geiser-compile-current-buffer} and @kbd{geiser-load-current-buffer}
441 with a prefix argument (that'd be something like @kbd{C-u C-c C-k} for
442 compilation, for instance), to tell Geiser to restart the REPL
443 associated with a buffer before compiling or loading its current
444 contents.
446 @cindex evaluation
447 @cindex incremental development, not evil
448 For all of you bearded old lispers still with me, here are some of the
449 commands performing incremental evaluation in Geiser.
451 @code{geiser-eval-last-sexp}, bound to @kbd{C-x C-e}, will eval the
452 s-expression just before point.  If you use a prefix, as in @kbd{C-u C-x
453 C-e}, besides evaluating it the expression is inserted in the the
454 buffer.
456 @code{geiser-eval-definition}, bound to @kbd{C-M-x}, finds the topmost
457 definition containing point and sends it for evaluation.  The variant
458 @code{geiser-eval-definition-and-go} (@kbd{C-c M-e}) works in the same
459 way, but it also teleports you to REPL after the evaluation.
461 @code{geiser-eval-region}, bound to @kbd{C-c C-r}, evals the current
462 region.  Again, there's an @i{and-go} version available,
463 @code{geiser-eval-region-and-go}, bound to @kbd{C-c M-r}.  And, if you
464 want to extend the evaluated region to the whole buffer, there is
465 @code{geiser-eval-buffer}, bound to @kbd{C-c C-b} and its companion
466 @code{geiser-eval-buffer-and-go}, bound to @kbd{C-c M-b}.
468 @cindex evaluating images
469 @cindex image display
470 For all the commands above, the result of the evaluation is displayed in
471 the minibuffer, unless it causes a (Scheme-side) error (@pxref{To err
472 perchance to debug}), or, for schemes supporting them (such as Racket),
473 the evaluation yields an image, in which case you'll see it in popping
474 up in the Geiser debug buffer (if your Emacs runs under the auspices of
475 a graphical toolkit), or via an external viewer if you set
476 @c{geiser-image-viewer} to the path of an appropriate visualization
477 program (see also @ref{Seeing is believing} for more on image support).
479 At the risk of repeating myself, i'll remind you that all these
480 evaluations will take place in the namespace of the module corresponding
481 to the Scheme file from which you're sending your code, which, in
482 general, will be different from the REPL's current module.  And, if all
483 goes according to plan, (re)defined variables and procedures should be
484 immediately visible inside and, if exported, outside their module.
486 Besides evaluating expressions, definitions and regions, you can also
487 macro-expand them.  The corresponding key bindings start with the prefix
488 @kbd{C-c C-m} and end, respectively, with @kbd{C-e}, @kbd{C-x} and
489 @kbd{C-r}.  The result of the macro expansion always appears in a pop up
490 buffer.
492 @node To err perchance to debug, Jumping around, To eval or not to eval, Between the parens
493 @section To err: perchance to debug
495 @cindex to err is schemey
496 @cindex backtraces
497 When an error occurs during evaluation, it will be reported according to
498 the capabilities of the underlying Scheme REPL.
500 @cindex error buffer
501 In Racket, you'll be presented with a backtrace, in a new buffer where
502 file paths locating the origin of the error are click-able (you can
503 navigate them using the @key{TAB} key, and use @key{RET} or the mouse to
504 jump to the offending spot; or invoke Emacs' stock commands
505 @code{next-error} and @code{previous-error}, bound to @kbd{M-g n} and
506 @kbd{M-g p} by default).
508 @imgc{eval-error}
510 The Racket backtrace also highlights the exception type, making it
511 click-able.  Following the link will open the documentation corresponding
512 to said exception type.  Both the error and exception link faces are
513 customizable (@code{geiser-font-lock-error-link} and
514 @code{geiser-font-lock-doc-link}).
516 By default, Geiser will tele-transport your pointer to the debug buffer:
517 if you prefer to stay in the source buffer, set
518 @code{geiser-debug-jump-to-debug-p} to nil.  And if, in addition, you
519 don't even want to see the error trace, customize
520 @code{geiser-debug-show-debug-p}, again, to nil.
522 On the other hand, Guile's reaction to evaluation errors is different:
523 it enters the debugger in its REPL.  Accordingly, the REPL buffer will
524 pop up if your evaluation fails in a Guile file, and the error message
525 and backtrace will be displayed in there, again click-able and all.  But
526 there you have the debugger at your disposal, with the REPL's current
527 module set to that of the offender, and a host of special debugging
528 commands that are described in Guile's fine documentation.
530 @imgc{guile-eval-error}
532 In addition, Guile will sometimes report warnings for otherwise
533 successful evaluations.  In those cases, it won't enter the debugger, and
534 Geiser will report the warnings in a debug buffer, as it does for
535 Racket.  You can control how picky Guile is reporting warnings by
536 customizing the variable @code{geiser-guile-warning-level}, whose
537 detailed docstring (which see, using, e.g. @kbd{C-h v}) allows me to
538 offer no further explanation here.  The customization group
539 @i{geiser-guile} is also worth a glance, for a couple of options to
540 fine-tune how Geiser interacts with Guile's debugger (and more).  Same
541 thing for racketeers and @i{geiser-racket}.
543 @node Jumping around, Geiser writes for you, To err perchance to debug, Between the parens
544 @section Jumping around
546 @cindex jumping in scheme buffers
547 This one feature is as sweet as it is easy to explain: @kbd{M-.}
548 (@code{geiser-edit-symbol-at-point}) will open the file where the
549 identifier around point is defined and land your point on its
550 definition.  To return to where you were, press @kbd{M-,}
551 (@code{geiser-pop-symbol-stack}).  This command works also for module
552 names: Geiser first tries to locate a definition for the identifier at
553 point and, if that fails, a module with that name; if the latter
554 succeeds, the file where the module is defined will pop up.
556 Sometimes, the underlying Scheme will tell Geiser only the file where
557 the symbol is defined, but Geiser will use some heuristics (read,
558 regular expressions) to locate the exact line and bring you there.  Thus,
559 if you find Geiser systematically missing your definitions, send a
560 message to the @email{geiser-users@@nongnu.org, mailing list}, and we'll
561 try to make the algorithm smarter.
563 @cindex jumping customized
564 You can control how the destination buffer pops up by setting
565 @code{geiser-edit-symbol-method} to either @code{nil} (to open the file
566 in the current window), @code{'window} (other window in the same frame)
567 or @code{'frame} (in a new frame).
569 @node Geiser writes for you,  , Jumping around, Between the parens
570 @section Geiser writes for you
572 @cindex completion in scheme buffers
573 No self-respecting programming mode would be complete without
574 completion.  In geiser-mode, identifier completion is bound to
575 @kbd{M-@key{TAB}}, and will offer all visible identifiers starting with
576 the prefix before point.  Visible here means all symbols imported or
577 defined in the current namespace plus locally bound ones.  E.g., if
578 you're at the end of the following partial expression:
580 @example
581 (let ((default 42))
582   (frob def
583 @end example
585 @noindent
586 and press @kbd{M-@key{TAB}}, one of the possible completions will be
587 @code{default}.
589 @cindex partial completion
590 After obtaining the list of completions from the running Scheme, Geiser
591 uses the standard Emacs completion machinery to display them.  That
592 means, among other things, that partial completion is available: just
593 try to complete @code{d-s} or @code{w-o-t-s} to see why this is a good
594 thing.  Partial completion won't work if you have disabled it globally in
595 your Emacs configuration: if you don't know what i'm talking about,
596 never mind: Geiser's partial completion will work for you out of the
597 box.
599 @cindex smart tabs
600 If you find the @kbd{M} modifier annoying, you always have the option to
601 activate @code{geiser-smart-tab-mode}, which will make the @key{TAB} key
602 double duty as the regular Emacs indentation command (when the cursor is
603 not near a symbol) and Geiser's completion function.  If you want this
604 smarty pants mode always on in Scheme buffers, customize
605 @code{geiser-mode-smart-tab-p} to @code{t}.
607 @cindex completion for module names
608 Geiser also knows how to complete module names: if no completion for the
609 prefix at point is found among the currently visible bindings, it will
610 try to find a module name that matches it.  You can also request
611 explicitly completion only over module names using @kbd{M-`} (that's a
612 backtick).
614 Besides completion, there's also this little command,
615 @code{geiser-squarify}, which will toggle the delimiters of the
616 innermost list around point between round and square brackets.  It is
617 bound to @kbd{C-c C-e [}.  With a numeric prefix (as in, say, @kbd{M-2
618 C-c C-e [}), it will perform that many toggles, forward for positive
619 values and backward for negative ones.
621 @subheading Caveat about completion
623 It is possible for Geiser to hang your Emacs process when trying to
624 complete symbols. This can happen in the REPL itself or even in a
625 Scheme buffer that is attached to the REPL process. For more details
626 on how to fix this problem, @ref{completion-caveat,,Caveat about
627 completion & the REPL}
629 @c Local Variables:
630 @c mode: texinfo
631 @c TeX-master: "geiser"
632 @c End: