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