Add geiser-mode-eval-to-buffer-transformer
[geiser.git] / doc / parens.texi
blob26f0fd4c136e85f9c8261eecb9638cfe647cc01a
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{http://jaortega.wordpress.com/2009/03/29/from-my-cold-prying-hands/index.html,
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{http://blog.racket-lang.org/2009/03/drscheme-repl-isnt-lisp-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.
441 @cindex evaluation
442 @cindex incremental development, not evil
443 For all of you bearded old lispers still with me, here are some of the
444 commands performing incremental evaluation in Geiser.
446 @code{geiser-eval-last-sexp}, bound to @kbd{C-x C-e}, will eval the
447 s-expression just before point.  If you use a prefix, as in @kbd{C-u C-x
448 C-e}, besides evaluating it the expression is inserted in the the
449 buffer.
451 @code{geiser-eval-definition}, bound to @kbd{C-M-x}, finds the topmost
452 definition containing point and sends it for evaluation.  The variant
453 @code{geiser-eval-definition-and-go} (@kbd{C-c M-e}) works in the same
454 way, but it also teleports you to REPL after the evaluation.
456 @code{geiser-eval-region}, bound to @kbd{C-c C-r}, evals the current
457 region.  Again, there's an @i{and-go} version available,
458 @code{geiser-eval-region-and-go}, bound to @kbd{C-c M-r}.  And, if you
459 want to extend the evaluated region to the whole buffer, there is
460 @code{geiser-eval-buffer}, bound to @kbd{C-c C-b} and its companion
461 @code{geiser-eval-buffer-and-go}, bound to @kbd{C-c M-b}.
463 @cindex evaluating images
464 @cindex image display
465 For all the commands above, the result of the evaluation is displayed in
466 the minibuffer, unless it causes a (Scheme-side) error (@pxref{To err
467 perchance to debug}), or, for schemes supporting them (such as Racket),
468 the evaluation yields an image, in which case you'll see it in popping
469 up in the Geiser debug buffer (if your Emacs runs under the auspices of
470 a graphical toolkit), or via an external viewer if you set
471 @c{geiser-image-viewer} to the path of an appropriate visualization
472 program (see also @ref{Seeing is believing} for more on image support).
474 At the risk of repeating myself, i'll remind you that all these
475 evaluations will take place in the namespace of the module corresponding
476 to the Scheme file from which you're sending your code, which, in
477 general, will be different from the REPL's current module.  And, if all
478 goes according to plan, (re)defined variables and procedures should be
479 immediately visible inside and, if exported, outside their module.
481 Besides evaluating expressions, definitions and regions, you can also
482 macro-expand them.  The corresponding key bindings start with the prefix
483 @kbd{C-c C-m} and end, respectively, with @kbd{C-e}, @kbd{C-x} and
484 @kbd{C-r}.  The result of the macro expansion always appears in a pop up
485 buffer.
487 @node To err perchance to debug, Jumping around, To eval or not to eval, Between the parens
488 @section To err: perchance to debug
490 @cindex to err is schemey
491 @cindex backtraces
492 When an error occurs during evaluation, it will be reported according to
493 the capabilities of the underlying Scheme REPL.
495 @cindex error buffer
496 In Racket, you'll be presented with a backtrace, in a new buffer where
497 file paths locating the origin of the error are click-able (you can
498 navigate them using the @key{TAB} key, and use @key{RET} or the mouse to
499 jump to the offending spot; or invoke Emacs' stock commands
500 @code{next-error} and @code{previous-error}, bound to @kbd{M-g n} and
501 @kbd{M-g p} by default).
503 @imgc{eval-error}
505 The Racket backtrace also highlights the exception type, making it
506 click-able.  Following the link will open the documentation corresponding
507 to said exception type.  Both the error and exception link faces are
508 customizable (@code{geiser-font-lock-error-link} and
509 @code{geiser-font-lock-doc-link}).
511 By default, Geiser will tele-transport your pointer to the debug buffer:
512 if you prefer to stay in the source buffer, set
513 @code{geiser-debug-jump-to-debug-p} to nil.  And if, in addition, you
514 don't even want to see the error trace, customize
515 @code{geiser-debug-show-debug-p}, again, to nil.
517 On the other hand, Guile's reaction to evaluation errors is different:
518 it enters the debugger in its REPL.  Accordingly, the REPL buffer will
519 pop up if your evaluation fails in a Guile file, and the error message
520 and backtrace will be displayed in there, again click-able and all.  But
521 there you have the debugger at your disposal, with the REPL's current
522 module set to that of the offender, and a host of special debugging
523 commands that are described in Guile's fine documentation.
525 @imgc{guile-eval-error}
527 In addition, Guile will sometimes report warnings for otherwise
528 successful evaluations.  In those cases, it won't enter the debugger, and
529 Geiser will report the warnings in a debug buffer, as it does for
530 Racket.  You can control how picky Guile is reporting warnings by
531 customizing the variable @code{geiser-guile-warning-level}, whose
532 detailed docstring (which see, using, e.g. @kbd{C-h v}) allows me to
533 offer no further explanation here.  The customization group
534 @i{geiser-guile} is also worth a glance, for a couple of options to
535 fine-tune how Geiser interacts with Guile's debugger (and more).  Same
536 thing for racketeers and @i{geiser-racket}.
538 @node Jumping around, Geiser writes for you, To err perchance to debug, Between the parens
539 @section Jumping around
541 @cindex jumping in scheme buffers
542 This one feature is as sweet as it is easy to explain: @kbd{M-.}
543 (@code{geiser-edit-symbol-at-point}) will open the file where the
544 identifier around point is defined and land your point on its
545 definition.  To return to where you were, press @kbd{M-,}
546 (@code{geiser-pop-symbol-stack}).  This command works also for module
547 names: Geiser first tries to locate a definition for the identifier at
548 point and, if that fails, a module with that name; if the latter
549 succeeds, the file where the module is defined will pop up.
551 Sometimes, the underlying Scheme will tell Geiser only the file where
552 the symbol is defined, but Geiser will use some heuristics (read,
553 regular expressions) to locate the exact line and bring you there.  Thus,
554 if you find Geiser systematically missing your definitions, send a
555 message to the @email{geiser-users@@nongnu.org, mailing list}, and we'll
556 try to make the algorithm smarter.
558 @cindex jumping customized
559 You can control how the destination buffer pops up by setting
560 @code{geiser-edit-symbol-method} to either @code{nil} (to open the file
561 in the current window), @code{'window} (other window in the same frame)
562 or @code{'frame} (in a new frame).
564 @node Geiser writes for you,  , Jumping around, Between the parens
565 @section Geiser writes for you
567 @cindex completion in scheme buffers
568 No self-respecting programming mode would be complete without
569 completion.  In geiser-mode, identifier completion is bound to
570 @kbd{M-@key{TAB}}, and will offer all visible identifiers starting with
571 the prefix before point.  Visible here means all symbols imported or
572 defined in the current namespace plus locally bound ones.  E.g., if
573 you're at the end of the following partial expression:
575 @example
576 (let ((default 42))
577   (frob def
578 @end example
580 @noindent
581 and press @kbd{M-@key{TAB}}, one of the possible completions will be
582 @code{default}.
584 @cindex partial completion
585 After obtaining the list of completions from the running Scheme, Geiser
586 uses the standard Emacs completion machinery to display them.  That
587 means, among other things, that partial completion is available: just
588 try to complete @code{d-s} or @code{w-o-t-s} to see why this is a good
589 thing.  Partial completion won't work if you have disabled it globally in
590 your Emacs configuration: if you don't know what i'm talking about,
591 never mind: Geiser's partial completion will work for you out of the
592 box.
594 @cindex smart tabs
595 If you find the @kbd{M} modifier annoying, you always have the option to
596 activate @code{geiser-smart-tab-mode}, which will make the @key{TAB} key
597 double duty as the regular Emacs indentation command (when the cursor is
598 not near a symbol) and Geiser's completion function.  If you want this
599 smarty pants mode always on in Scheme buffers, customize
600 @code{geiser-mode-smart-tab-p} to @code{t}.
602 @cindex completion for module names
603 Geiser also knows how to complete module names: if no completion for the
604 prefix at point is found among the currently visible bindings, it will
605 try to find a module name that matches it.  You can also request
606 explicitly completion only over module names using @kbd{M-`} (that's a
607 backtick).
609 Besides completion, there's also this little command,
610 @code{geiser-squarify}, which will toggle the delimiters of the
611 innermost list around point between round and square brackets.  It is
612 bound to @kbd{C-c C-e [}.  With a numeric prefix (as in, say, @kbd{M-2
613 C-c C-e [}), it will perform that many toggles, forward for positive
614 values and backward for negative ones.
616 @c Local Variables:
617 @c mode: texinfo
618 @c TeX-master: "geiser"
619 @c End: