Rename lexical, a basic wrapper around query-replace.
[sepia.git] / sepia.texi
bloba585b97a6aee6f178201a60cf5d10fbdd501564d
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename sepia.info
4 @settitle SEPIA: Simple Emacs Perl Integration
5 @dircategory Emacs
6 @direntry
7 * Sepia: (sepia).    Simple Emacs Perl Integration.
8 @end direntry
9 @c %**end of header
11 @titlepage
12 @title Sepia: Simple Emacs Perl Integration
13 @author Sean O'Rourke
14 @end titlepage
16 @macro kbinding{key,cmd}
17 @item \key\ `\cmd\'
18 @kindex \key\
19 @end macro
21 @macro fitem{name}
22 @item \name\
23 @findex \name\
24 @end macro
26 @macro xxx{stuff}
27 @b{XXX: \stuff\}
28 @end macro
30 @node Top, Introduction, (dir), (dir)
32 @ifinfo
33 @top SEPIA
34 @end ifinfo
36 @ifhtml
37 @image{Sepia,,,,jpg}
38 @end ifhtml
40 Sepia is a set of Perl development tools for Emacs supporting code
41 navigation and interactive evaluation.
43 @menu
44 * Introduction::                
45 * Editing::                     
46 * Interactive Perl::            
47 * CPAN browsing::               
48 * Customization::               
49 * Internals::                   
50 * Credits::                     
51 * Function Index::              
52 * Variable Index::              
53 @end menu
55 @c ============================================================
56 @node Introduction, Editing, Top, Top
57 @chapter Introduction
59 Sepia is a set of tools for Perl development in Emacs.  Its goal is to
60 extend CPerl mode to support fast code navigation and interactive
61 development.  It is inspired by Emacs' current support for a number of
62 other languages, including Lisp, Python, and Emacs Lisp.
64 @menu
65 * Getting Started::             
66 * Philosophy::                  
67 * Related Work::                
68 @end menu
70 @node Getting Started, Philosophy, Introduction, Introduction
71 @section Getting Started
73 To install Sepia, its Emacs Lisp files must be in Emacs'
74 @code{load-path}, and the @file{lib} directory must be in Perl's
75 @code{@@INC}.  Assuming that Sepia has been unpacked in
76 @file{~/sepia}, it can be installed by adding the following lines to
77 @file{~/.emacs}:
79 @example
80 (add-to-list 'load-path "~/sepia")
81 (setq sepia-perl5lib (list (expand-file-name "~/sepia/lib")))
82 (defalias 'perl-mode 'sepia-mode)
83 (require 'sepia)
84 @end example
86 Then to bring up the interactive Perl prompt, type @kbd{M-x sepia-repl}.
88 @node Philosophy, Related Work, Getting Started, Introduction
89 @section Philosophy
91 A development environment should support three activities: code
92 spelunking, interaction, and customization.  Emacs as an environment for
93 developing Emacs Lisp thoroughly supports all of them: It has commands
94 to visit individual functions' code and documentation, commands to
95 evaluate or step through expressions, and an architecture that
96 encourages customization in Emacs Lisp.  As an environment for Perl,
97 however, it is lacking: there is limited interactivity with the Perl
98 debugger, and reasonable documentation browsing, but no support for
99 navigating, editing, and re-evaluating code.  Sepia attempts to remedy
100 the situation.
102 Modern IDEs also support these three activities, but do so awkwardly.
103 Rather than having functions to visit definitions (@kbd{find-function})
104 and search for functions (@kbd{apropos}), they clutter the screen with
105 class and file trees.  Rather than supporting interactive evaluation of
106 small pieces of code, they perform background semantic checking on whole
107 projects and highlight errors.  Rather than allowing minor
108 customizations to grow organically into features, they support limited
109 configuration files and baroque plug-in APIs.  Sepia tries to adhere to
110 the apparent Emacs philosophy that rich semantic information should be
111 unobtrusive, and that the best way to build working code is to start
112 by experimenting with small pieces.
114 Language support packages for Emacs vary widely in the degree to which
115 they make use of or replace existing Emacs features.  Minimal modes
116 provide keyword-based syntax highlighting and an unadorned comint buffer
117 as an interpreter.  Others provide their own specialized equivalents of
118 comint, eldoc, completion, and other Emacs features.  Sepia takes a
119 third approach by trying to do as much as possible with existing Emacs
120 features, even when they are not optimal for Perl.  For example, it uses
121 comint to communicate with the subprocess, eldoc to display
122 documentation, and grep to list source locations.
124 This approach has three advantages: First, it maximizes the number of
125 features that can be supported with limited development time.  Second,
126 it respects users' settings.  A seasoned Emacs user may have changed
127 hundreds of settings, so a mode that reimplements features will have to
128 support equivalent settings, and will force the user to re-specify them.
129 Finally, this approach respects decades of development spent, as Neal
130 Stephenson put it, ``focused with maniacal intensity on the deceptively
131 simple-seeming problem of editing text.''  Many non-obvious choices go
132 into making a polished interface, and while a reimplementation gets rid
133 of accumulated cruft, it must rediscover these hidden trade-offs.
135 Anyways, I hope you enjoy using Sepia.  Its development style is strange
136 for someone used Perl's typical mix of one-liners and edit-save-run, but
137 once you are accustomed to it, you may find it very effective.
139 @node Related Work,  , Philosophy, Introduction
140 @comment  node-name,  next,  previous,  up
141 @section Related Work
143 A number of more-or-less related Emacs extensions are currently under
144 development.  Here is a list of the ones I have heard about, along with
145 my brief impression of how they differ from Sepia.  Since I use none of
146 them regularly, these impressions should be taken with a grain of salt.
148 @table @cite
150 @item PDE
152 PDE is similar to Sepia in offering an interactive Lisp-like development
153 environment interfacing with a long-running Perl process.  It seems more
154 ambitious, and therefore a bit more invasive.
156 @url{http://search.cpan.org/search?query=pde&mode=module}
158 @item Devel::PerlySense
160 Devel::PerlySense offers a more Eclipse-like development environment,
161 with offline code analysis via @acronym{PPI}.
163 @url{http://search.cpan.org/search?query=devel::perlysense&mode=module}
165 @item Emacs::EPL
167 Emacs::EPL is a low-level IPC interface between Emacs and Perl.  Sepia
168 was originally based on Emacs::EPL, but the current
169 @command{comint}-based implementation proved more maintainable.
171 @url{http://search.cpan.org/search?query=emacs::epl&mode=module}
173 @end table
175 @c ============================================================
176 @node Editing, Interactive Perl, Introduction, Top
177 @chapter Editing
178 @findex sepia-mode
180 Sepia's first contribution is a set of commands to explore a Perl
181 codebase.  These include commands to browse and display documentation,
182 to find function definitions, and to query a cross-reference database of
183 function and variable uses.  Sepia also provides intelligent symbol
184 completion.
186 @menu
187 * Completion::                  
188 * Navigation::                  
189 * Documentation::               
190 @end menu
192 @node Completion, Navigation, Editing, Editing
193 @section Completion
195 Sepia implements partial-word completion that communicates with the
196 inferior Perl process.  For example, @samp{%S:X:v_u} completes to
197 @samp{%Sepia::Xref::var_use} when Sepia is loaded.  This completion only
198 operates on functions and global variables known to the Perl
199 interpreter, so it works best when code and interpreter are in sync.
201 More precisely, completion examines the text before point and tries each
202 of the following in turn, using the first successful approach:
204 @enumerate
205 @item
206 If the text looks like a method call (e.g. @samp{$object->f} or
207 @samp{Class->f}), complete on methods.
209 @item
210 If it looks like a variable (e.g. @samp{%hash} or @samp{$scalar}),
211 complete first on lexical, then global variables.
213 @item
214 Complete on modules and functions.
216 @item
217 Otherwise, complete on Perl built-in operators.
218 @end enumerate
220 For each of the first three cases, completions candidates are first
221 generated by splitting the text on characters @code{[:_]} and matching
222 the resulting word parts.  For example, @samp{X:a_b} will complete to
223 all symbols matching @samp{^X[^:]*:+a[^:_]*_b} such as @samp{Xref::a_bug}
224 and @samp{X::always_bites_me}.  If no matches result, the text is
225 treated as an acronym.  For example, @samp{dry} will complete to
226 @samp{dont_repeat_yourself}.  @emph{Note: partial-word completion is not
227 currently supported for lexicals.}
229 Completion is performed by the following commands:
230 @table @kbd
231 @item M-x sepia-complete-symbol
232 @findex sepia-complete-symbol
233 Complete the symbol before point as described above.  This is always
234 case-sensitive, independent of @code{completion-ignore-case}.
236 @item TAB
237 @itemx M-x sepia-indent-or-complete
238 @findex sepia-indent-or-complete
239 First try to reindent the current line.  If its indentation does not
240 change, then try to expand an abbrev at point (unless
241 @code{sepia-indent-expand-abbrev} is @code{nil}).  If no abbrev is
242 expanded, then call @code{sepia-complete-symbol}.
244 @end table
246 @node Navigation, Documentation, Completion, Editing
247 @section Navigation
249 Sepia provides several commands for navigating program source.  All of
250 them rely on information from the inferior Perl process, so it is
251 important both that it be running, and that its internal representation
252 of the program match the program source.  The commands marked (Xref)
253 below also rely on a cross-reference database, which must be explicitly
254 rebuilt by calling @code{xref-rebuild} when the program changes.
256 There are two basic kinds of navigation commands.  The first kind jumps
257 directly to the first matching location when possible, prompting only if
258 no such location is found.  These commands find only a single location.
260 @c direct-jump commands
261 @table @kbd
263 @item M-. M-.
264 @itemx M-x sepia-dwim
265 @findex sepia-dwim
266 Guess what kind of identifier is at point, and try to do the right
267 thing: for a function, find its definition(s); for a variable, find its
268 uses; for a module, view its documentation; otherwise, prompt for the
269 name of a function to visit.  @code{sepia-dwim} automatically goes to
270 the first function definition or variable use found.
272 @item M-. l
273 @itemx M-x sepia-location
274 @findex sepia-location
275 Jump directly to the definition of the function at point, prompting if
276 point is not on a known function.  If multiple definitions are found,
277 choose one arbitrarily.  This function is similar to @code{sepia-defs},
278 and the two should probably be merged.
280 @item M-. j
281 @itemx M-x sepia-jump-to-symbol
282 @findex sepia-jump-to-symbol
283 Navigate to a function using ``ido'' interactive completion.  Within
284 interactive completion, press @key{:} to descend into a package,
285 @key{DEL} to ascend to a parent package, and @key{RET} to go to the
286 currently-selected function.
288 @end table
290 The second kind of navigation commands always prompts the user -- though
291 usually with a sensible default value -- and finds multiple locations.
292 When called with a prefix argument, these commands present their results
293 in a @code{grep-mode} buffer.  When called @emph{without} a prefix
294 argument, they place all results on the found-location ring and jump
295 directly to the first.  The remaining locations can be cycled through by
296 calls to @code{sepia-next}.
298 @c prompt-and-go commands
299 @table @kbd
300 @item M-. f @var{name} @key{RET}
301 @itemx M-x sepia-defs
302 @findex sepia-defs
303 Find definition(s) of function @var{name}.
305 @item M-. m @var{name} @key{RET}
306 @itemx M-x sepia-module-find @var{name} @key{RET}
307 @findex sepia-module-find
308 Find the source of module @var{name}.
310 @item M-. a @var{regexp} @key{RET}
311 @itemx M-x sepia-apropos @var{regexp} @key{RET}
312 @findex sepia-apropos
313 Find definitions of all functions whose names match @var{regexp}.
315 @item M-. c @var{name} @key{RET}
316 @itemx M-x sepia-callers @var{name} @key{RET}
317 @findex sepia-callers
318 (Xref) Find calls to function @var{name}.
320 @item M-. C @var{name} @key{RET}
321 @itemx M-x sepia-callees @var{name} @key{RET}
322 @findex sepia-callees
323 (Xref) Find the definitions of functions called by @var{name}.
325 @item M-. v @var{name} @key{RET}
326 @itemx M-x sepia-var-uses @var{name} @key{RET}
327 @findex sepia-var-uses
328 (Xref) Find uses of the global variable @var{name}.
330 @item M-. V @var{name} @key{RET}
331 @itemx M-x sepia-var-defs @var{name} @key{RET}
332 @findex sepia-var-defs
333 (Xref) Find definitions of global variable @var{name}.  Since Perl's
334 global variables are not declared, this is rarely useful
336 @c XXX: broken, so don't mention it.
337 @c @item M-. A @var{regexp} @key{RET}
338 @c @itemx M-x sepia-var-apropos
339 @c @findex sepia-var-apropos
340 @c Find definitions of all variables whose names match @var{regexp}.  Since
341 @c this function does not handle lexical variables, and since Perl's global
342 @c variables are not declared, this is rarely useful.
344 @end table
346 Finally, there are several other navigation-related commands that do not
347 fit into either of the above categories.
349 @c other commands
350 @table @kbd
351 @item M-,
352 @itemx M-x sepia-next
353 @findex sepia-next
354 Cycle through the definitions found by the previous @key{M-.} search.
356 @item M-. r
357 @itemx M-x sepia-rebuild
358 @findex sepia-rebuild
359 Rebuild the cross-reference database by walking the op-tree and
360 stashes.
362 @item M-. t
363 @itemx M-x find-tag
364 Execute the @code{find-tag} command typically bound to @key{M-.}.
366 @end table
368 @node Documentation,  , Navigation, Editing
369 @section Documentation
371 Sepia can be used to browse installed modules' documentation, to format
372 and display the current buffer's POD, and to browse the list of modules
373 installed on the system.
375 @table @kbd
376 @item M-. d @var{name} @key{RET}
377 @itemx M-x sepia-perldoc-this
378 @findex sepia-perldoc-this
379 View documentation for module @var{name} or Perl manual page @var{name}.
381 @item C-c C-d
382 @itemx M-x sepia-view-pod
383 @findex sepia-view-pod
384 Format and view the current buffer's documentation.
386 @item sepia-package-list
387 @findex sepia-package-list
388 Browse a tree of installed packages.  This lists only the top-level
389 packages from installed distributions, so if package @code{My::Stuff}
390 also provides @code{My::Stuff::Details}, it will not be displayed.  When
391 Emacs-w3m is available, each module is linked to its documentation.
393 @item sepia-module-list
394 @findex sepia-module-list
395 Browse a tree of both top-level and internal packages, like
396 @code{sepia-package-list}.
398 @end table
400 @findex sepia-install-eldoc
401 Sepia also integrates with eldoc (at least in GNU Emacs >= 22).
402 Documentation for Perl operators and control structures is taken from
403 CPerl mode.  Sepia will also display documentation for user-defined
404 functions if their POD is formatted in the standard way, with functions
405 described in a ``=head2'' or ``=item'' entry.  To load user
406 documentation, visit the relevant file and type @kbd{M-x
407 sepia-doc-update}.
409 If @code{Module::CoreList} is available, Sepia's eldoc function will
410 also display the first version of Perl with which a module was shipped.
411 This is intended to give the programmer a sense of when he is creating
412 external dependencies.
414 @c ============================================================
415 @node Interactive Perl, CPAN browsing, Editing, Top
416 @chapter Interactive Perl
418 @findex sepia-repl
419 Sepia's second main contribution is an interactive interface (REPL) to
420 an inferior Perl process.  The interface is based on GUD mode, and
421 inherits many of its bindings; this chapter discusses only the Sepia
422 extensions.  To start or switch to the repl, type @kbd{M-x sepia-repl}.
423 As in Sepia mode, @key{TAB} in the REPL performs partial-word completion
424 with @code{sepia-complete-symbol}.
426 Sepia also provides a number of other ways to evaluate pieces of code in
427 Perl, and commands to process buffer text using the inferior process.
429 @menu
430 * Shortcuts::                   
431 * Debugger::                    
432 * Evaluation::                  
433 * Mutilation::                  
434 * Scratchpad::                  
435 @end menu
437 @node Shortcuts, Debugger, Interactive Perl, Interactive Perl
438 @section Shortcuts
440 ``Shortcuts'' are commands handled specially by the REPL rather than
441 being evaluated as Perl code.  They either communicate with the REPL
442 function, or provide a convenient interface to variables in the Sepia
443 package.  Shortcuts are prefixed by a comma (@key{,}), and may be
444 abbreviated to the shortest unique prefix.
446 @table @kbd
447 @item cd @var{dir}
448 Change Perl's current directory to @var{dir}.
450 @item debug [@var{val}]
451 Turn Sepia debugger hook on or off, or toggle if @var{val} is missing.
453 @item define @var{name} ['@var{doc}'] @var{body...}
454 Define @var{name} as a shortcut for Perl code @var{body}, with optional
455 documentation @var{doc}, surrounded by single quotes.  @var{body} is
456 passed the raw command-line text as its first argument.
458 @item delete
459 Delete the current breakpoint.
461 @item format @var{type}
462 Set the output format to @var{type}, either ``dumper'' (using
463 @code{Data::Dumper}), ``dump'' (@code{Data::Dump}), ``yaml''
464 (@code{YAML}), or ``plain'' (stringification).  Default: ``dumper''.
466 @item help
467 Display a list of shortcuts.
469 @item lsbreak
470 List breakpoints.
472 @item methods @var{name} [@var{regexp}]
473 Display a list of functions defined in package @var{name} and its
474 @code{ISA}-ancestors matching optional pattern @var{regexp}.
476 @item package @var{name}
477 Set the default evaluation package to @var{name}.
479 @item pwd
480 Show the process's current working directory.
482 @item quit
483 Exit the inferior Perl process.
485 @item reload
486 Reload @file{Sepia.pm} and recursively invoke the REPL.  This command is
487 mostly of interest when working on Sepia itself.
489 @item shell [@var{command}]
490 Execute shell command @var{command}, displaying its standard output and
491 standard error.
493 @item strict [@var{val}]
494 Set evaluation strictness to @var{val}, or toggle it if @var{val} is not
495 given.  Note that turning strictness off and on clears the REPL's
496 lexical environment.
498 @item undef @var{name}
499 Undefine shortcut @var{name}.  @strong{Warning}: this can equally be
500 used to remove built-in shortcuts.
502 @item wantarray [@var{val}]
503 Set the evaluation context to @var{val}, or toggle between scalar and
504 array context.
506 @item who @var{package} [@var{regexp}]
507 @itemx who [@var{regexp}]
508 List identifiers in @var{package} (main by default) matching
509 optional @var{regexp}.
511 @end table
513 @node Debugger, Evaluation, Shortcuts, Interactive Perl
514 @section Debugger
516 Sepia uses Perl's debugger hooks and GUD mode to support conditional
517 breakpoints and single-stepping, and overrides Perl's @code{die()} to
518 invoke the debugger rather than unwind the stack.  This makes it
519 possible to produce a backtrace, inspect and modify global variables,
520 and even continue execution when a program tries to kill itself.  If the
521 PadWalker module is available, Sepia also provides functions to inspect
522 and modify lexical variables.
524 The debugger has its own set of shortcuts, also prefixed by a comma.
526 @table @kbd
527 @item backtrace
528 Show a backtrace.
530 @item break @var{file}:@var{line} [@var{expr}]
531 Set a breakpoint in @var{file} at @var{line}.  If @var{expr} is
532 supplied, stop only if it evaluates to true.
534 @item down @var{n}
535 @itemx up @var{n}
536 Move the current stack frame up or down by @var{n} (or one) frames.
538 @item inspect [@var{n}]
539 Inspect lexicals in the current frame or frame @var{n}, counting upward
540 from 1.
542 @item lsbreak
543 List breakpoints.
545 @item next [@var{n}]
546 Advance @var{n} (or one) lines, skipping subroutine calls.
548 @item quit
549 @itemx die
550 @itemx warn
551 Continue as the program would have executed without debugger
552 intervention, dying if the debugger was called from @code{die()}.
554 @item return @var{expr}
555 Continue execution as if @code{die()} had returned the value of
556 @var{expr}, which is evaluated in the global environment.
558 @item step [@var{n}]
559 Step forward @var{n} (or one) lines, descending into subroutines.
561 @item xreturn @var{sub} @var{expr}
562 Return @var{expr} from the innermost call to @var{sub}.  This is a
563 somewhat dangerous and experimental feature, but is probably more useful
564 than returning a value from @code{die()}.
566 @end table
568 @node Evaluation, Mutilation, Debugger, Interactive Perl
569 @section Evaluation
571 When interactive Perl is running, Sepia can evaluate regions of code in
572 the inferior Perl process.  The following commands assume that this
573 process has already been started by calling @code{sepia-repl}.
575 @table @kbd
576 @item C-M-x
577 @itemx M-x sepia-eval-defun
578 @findex sepia-eval-defun
579 Evaluate the function around point in the inferior Perl process.  If it
580 contains errors, jump to the location of the first.
582 @item C-c C-l
583 @itemx M-x sepia-load-file
584 @findex sepia-load-file
585 Save the current buffer, then reload its file and if warnings or errors
586 occur, display an error buffer.  With a prefix argument, also rebuild
587 the cross-reference index.
589 @item C-c e
590 @itemx M-x sepia-eval-expression @key{RET} @var{expr} @key{RET}
591 @findex sepia-eval-expression
592 Evaluate @var{expr} in scalar context and echo the result.  With a
593 prefix argument, evaluate in list context.
595 @item C-c!
596 @itemx sepia-set-cwd
597 @findex sepia-set-cwd
598 Set the REPL's working directory to the current buffer's directory.
600 @end table
602 @node Mutilation, Scratchpad, Evaluation, Interactive Perl
603 @section Mutilation
605 Sepia contains several functions to operate on regions of text using the
606 interactive Perl process.  These functions can be used like standard
607 one-liners (e.g. @samp{perl -pe ...}), with the advantage that all of
608 the functions and variables in the interactive session are available.
610 @table @kbd
611 @item M-x sepia-perl-pe-region @key{RET} @var{code} @key{RET}
612 @findex sepia-perl-pe-region
613 Evaluate @var{code} on each line in the region with @code{$_} bound to
614 the line text, collecting the resulting values of @code{$_}.  With a
615 prefix argument, replace the region with the result.
617 @item M-x sepia-perl-ne-region @key{RET} @var{code} @key{RET}
618 @findex sepia-perl-ne-region
619 Evaluate @var{code} as above, but collect the results instead.
621 @item M-x sepia-perlize-region @key{RET} @var{code} @key{RET}
622 @findex sepia-perlize-region
623 Evaluate @var{code} once with @code{$_} bound to the entire region,
624 collecting the final value of @code{$_}.  With a prefix argument,
625 replace the region.
627 @end table
629 @node Scratchpad,  , Mutilation, Interactive Perl
630 @section Scratchpad
632 @findex sepia-scratch
633 Sepia also supports a scratchpad, another form of interaction inspired
634 by Emacs' @code{*scratch*} buffer.  To create or switch to the
635 scratchpad, type @kbd{M-x sepia-scratch}.  Scratchpad mode is exactly
636 like Sepia mode, except @key{C-j} evaluates the current line and prints
637 the result on the next line.
639 @c ============================================================
640 @node  CPAN browsing, Customization, Interactive Perl, Top
641 @chapter CPAN browsing
643 Sepia has rudimentary support for browsing documentation and installing
644 modules from CPAN.  Modules whose names, descriptions, or authors match
645 a query are displayed in a @code{*sepia-cpan*} buffer, in which the
646 following commands are available:
648 @table @kbd
649 @item s
650 @itemx M-x sepia-cpan-search @key{RET} @var{pattern} @key{RET}
651 @findex sepia-cpan-search
652 List modules whose names match @var{pattern}.
654 @item /
655 @itemx M-x sepia-cpan-desc @key{RET} @var{pattern} @key{RET}
656 @findex sepia-cpan-desc
657 List modules whose names or descriptions match @var{pattern}.
659 @item l
660 @itemx M-x sepia-cpan-list @key{RET} @var{name} @key{RET}
661 @findex sepia-cpan-list
662 List modules authored by @var{name}.
664 @item r
665 @itemx M-x sepia-cpan-readme @key{RET} @var{module} @key{RET}
666 @findex sepia-cpan-readme
667 Fetch and display @var{module}'s README file.
669 @item d
670 @itemx M-x sepia-cpan-doc @key{RET} @var{module} @key{RET}
671 @findex sepia-cpan-doc
672 Browse @var{module}'s documentation on @url{http://search.cpan.org}.
674 @item i
675 @itemx M-x sepia-cpan-install @key{RET} @var{module} @key{RET}
676 @findex sepia-cpan-install
677 Install @var{module} and its prerequisites.  This feature is not yet
678 well tested.
680 @end table
682 @c ============================================================
683 @node Customization, Internals, CPAN browsing, Top
684 @chapter Customization
686 While Sepia can be customized in both the Perl and Emacs Lisp, most of
687 the user-accessible configuration is in the latter.
689 @menu
690 * Emacs Variables::             
691 * Perl Variables::              
692 @end menu
694 @node Emacs Variables, Perl Variables, Customization, Customization
695 @section Emacs Variables
697 Since Sepia tries where possible to reuse existing Emacs functionality,
698 its behavior should already be covered by existing customizations.  The
699 two variables most likely to need customization are
700 @kbd{sepia-program-name} and @kbd{sepia-perl5lib}.  General Sepia mode
701 configuration can be done with @kbd{sepia-mode-hook}, while
702 REPL-specific configuration can be done with @kbd{sepia-repl-mode-hook}.
704 @vtable @kbd
706 @item sepia-complete-methods
707 If non-@code{nil}, @code{sepia-complete-symbol} will complete
708 simple method calls of the form @code{$x->} or @code{Module->}.  Since
709 the former requires evaluation of @code{$x}, this can be disabled.
710 Default: @code{T}.
712 @item sepia-eval-defun-include-decls
713 If non-@code{nil}, attempt to generate a declaration list for
714 @code{sepia-eval-defun}.  This is necessary when evaluating some code,
715 such as that calling functions without parentheses, because the presence
716 of declarations affects the parsing of barewords.  Default: @code{T}.
718 @item sepia-indent-expand-abbrev
719 If non-@code{nil}, @code{sepia-indent-or-complete} will, if
720 reindentation does not change the current line, expand an abbreviation
721 before point rather than performing completion.  Only if no abbreviation
722 is found will it perform completion.  Default: @code{T}.
724 @item sepia-module-list-function
725 The function to view a tree of installed modules.  Default:
726 @code{w3m-find-file} if Emacs-w3m is installed, or
727 @code{browse-url-of-buffer} otherwise.
729 @item sepia-perldoc-function
730 The function called to view installed modules' documentation.  Default:
731 @code{w3m-perldoc} if Emacs-w3m is installed, or @code{cperl-perldoc}
732 otherwise.
734 @item sepia-perl5lib
735 A list of directories to include in @code{PERL5LIB} when starting
736 interactive Perl.  Default: @code{nil}.
738 @item sepia-prefix-key
739 The prefix to use for for functions in @code{sepia-keymap}.  Default:
740 @key{M-.}.
742 @item sepia-program-name
743 The Perl program name for interactive Perl.  Default: ``perl''.
745 @item sepia-use-completion
746 If non-@code{nil}, various Sepia functions will generate completion
747 candidates from interactive Perl when called interactively.  This may be
748 slow or undesirable in some situations.  Default: @code{T}.
750 @item sepia-view-pod-function
751 The function called to view the current buffer's documentation.
752 Default: @code{sepia-w3m-view-pod} if Emacs-w3m is available, or
753 @code{sepia-perldoc-buffer} otherwise.
755 @end vtable
757 @node Perl Variables,  , Emacs Variables, Customization
758 @section Perl Variables
760 When Sepia starts up, it evaluates the Perl script in @file{~/.sepiarc}.
761 The following variables in the Sepia package control various aspects of
762 interactive evaluation.
764 @table @code
766 @item $PACKAGE
767 The package in which user input is evaluated, determined automatically
768 when code is evaluated from a buffer.  Default: @code{main}.
770 @item $PRINTER
771 The function called to format interactive output, normally set with the
772 @code{printer} shortcut.
774 @item $PRINT_PRETTY
775 If true, format some values nicely independent of the value of
776 @code{$PRINTER}.  Currently, this means columnating lists of simple
777 scalars.  Default: true.
779 @item $PS1
780 The trailing end of the prompt string, which should end with ``> ''.
781 Default: @code{"> "}.
783 @item $STOPDIE
784 If true, calls to @code{die} from interactive code will invoke the Sepia
785 debugger.  Default: true.
787 @item $STOPWARN
788 If true, calls to @code{warn} from interactive code will invoke the
789 Sepia debugger.  Default: false.
791 @item $WANTARRAY
792 If true, evaluate interactive expressions in list context.  Default: true.
794 @end table
796 Additional REPL shortcuts can be defined with
797 @kbd{Sepia::define_shortcut}.  For example
799 @example
800 Sepia::define_shortcut time => sub @{ print scalar localtime, "\n"; 0 @},
801     'Display the current time.';
802 @end example
804 defines a shortcut ``time'' that displays the current time.  For
805 details, see the code in @file{Sepia.pm}.
807 @c ============================================================
808 @node Internals, Credits, Customization, Top
809 @chapter Internals
811 Many things remain unexplained except by the code itself, and some
812 details mentioned above should probably be given less prominence.  For
813 developer documentation, please see the POD for @code{Sepia} and
814 @code{Sepia::Xref}, and the doc-strings in @file{sepia.el}.
816 @node Credits, Function Index, Internals, Top
817 @unnumbered Credits
819 @table @asis
820 @item Hilko Bengen
821 Found and motivated me to fix a bunch of bugs, created Debian packages.
823 @item Ævar Arnfjörð Bjarmason
824 Miscellaneous fixes.  Tested unicode support.
826 @item Ye Wenbin
827 Found and fixed numerous bugs.
829 @item Free Software
830 Portions of the code were lifted from Emacs-w3m, SLIME, ido, and
831 B::Xref, all of which are Free software.
833 @end table
835 @c ============================================================
836 @node Function Index, Variable Index, Credits, Top
837 @unnumbered Function Index
838 @printindex fn
840 @node Variable Index,  , Function Index, Top
841 @unnumbered Variable Index
842 @printindex vr
844 @bye