try to install .el and .info files
[sepia.git] / sepia.texi
blob28c829e12f39c55cf59a35768ccb3cad03166a40
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 * Other commands::              
191 @end menu
193 @node Completion, Navigation, Editing, Editing
194 @section Completion
196 Sepia implements partial-word completion that communicates with the
197 inferior Perl process.  For example, @samp{%S:X:v_u} completes to
198 @samp{%Sepia::Xref::var_use} when Sepia is loaded.  This completion only
199 operates on functions and global variables known to the Perl
200 interpreter, so it works best when code and interpreter are in sync.
202 More precisely, completion examines the text before point and tries each
203 of the following in turn, using the first successful approach:
205 @enumerate
206 @item
207 If the text looks like a method call (e.g. @samp{$object->f} or
208 @samp{Class->f}), complete on methods.
210 @item
211 If it looks like a variable (e.g. @samp{%hash} or @samp{$scalar}),
212 complete first on lexical, then global variables.
214 @item
215 Complete on modules and functions.
217 @item
218 Otherwise, complete on Perl built-in operators.
219 @end enumerate
221 For each of the first three cases, completions candidates are first
222 generated by splitting the text on characters @code{[:_]} and matching
223 the resulting word parts.  For example, @samp{X:a_b} will complete to
224 all symbols matching @samp{^X[^:]*:+a[^:_]*_b} such as
225 @samp{Xref::a_bug} and @samp{X::always_bites_me}.  If the module parts
226 of the input match a module exactly and completions exist, they are not
227 expanded.  For example, @samp{X:a} will expand only to @samp{X::aa} when
228 @samp{X::aa} and @samp{Xx::aa} exist.  If no matches result, the text is
229 treated as an acronym.  For example, @samp{dry} will complete to
230 @samp{dont_repeat_yourself}.  @emph{Note: partial-word completion is not
231 currently supported for lexicals.}
233 Completion is performed by the following commands:
234 @table @kbd
235 @item M-x sepia-complete-symbol
236 @findex sepia-complete-symbol
237 Complete the symbol before point as described above.  This is always
238 case-sensitive, independent of @code{completion-ignore-case}.
240 @item TAB
241 @itemx M-x sepia-indent-or-complete
242 @findex sepia-indent-or-complete
243 First try to reindent the current line.  If its indentation does not
244 change, then try to expand an abbrev at point (unless
245 @code{sepia-indent-expand-abbrev} is @code{nil}).  If no abbrev is
246 expanded, then call @code{sepia-complete-symbol}.
248 @end table
250 @node Navigation, Documentation, Completion, Editing
251 @section Navigation
253 Sepia provides several commands for navigating program source.  All of
254 them rely on information from the inferior Perl process, so it is
255 important both that it be running, and that its internal representation
256 of the program match the program source.  The commands marked (Xref)
257 below also rely on a cross-reference database, which must be explicitly
258 rebuilt by calling @code{xref-rebuild} when the program changes.
260 There are two basic kinds of navigation commands.  The first kind jumps
261 directly to the first matching location when possible, prompting only if
262 no such location is found.  These commands find only a single location.
264 @c direct-jump commands
265 @table @kbd
267 @item M-. M-.
268 @itemx M-x sepia-dwim
269 @findex sepia-dwim
270 Guess what kind of identifier is at point, and try to do the right
271 thing: for a function, find its definition(s); for a variable, find its
272 uses; for a module, view its documentation; otherwise, prompt for the
273 name of a function to visit.  @code{sepia-dwim} automatically goes to
274 the first function definition or variable use found.
276 @item M-. l
277 @itemx M-x sepia-location
278 @findex sepia-location
279 Jump directly to the definition of the function at point, prompting if
280 point is not on a known function.  If multiple definitions are found,
281 choose one arbitrarily.  This function is similar to @code{sepia-defs},
282 and the two should probably be merged.
284 @item M-. j
285 @itemx M-x sepia-jump-to-symbol
286 @findex sepia-jump-to-symbol
287 Navigate to a function using ``ido'' interactive completion.  Within
288 interactive completion, press @key{:} to descend into a package,
289 @key{DEL} to ascend to a parent package, and @key{RET} to go to the
290 currently-selected function.
292 @end table
294 The second kind of navigation commands always prompts the user -- though
295 usually with a sensible default value -- and finds multiple locations.
296 When called with a prefix argument, these commands present their results
297 in a @code{grep-mode} buffer.  When called @emph{without} a prefix
298 argument, they place all results on the found-location ring and jump
299 directly to the first.  The remaining locations can be cycled through by
300 calls to @code{sepia-next}.
302 @c prompt-and-go commands
303 @table @kbd
304 @item M-. f @var{name} @key{RET}
305 @itemx M-x sepia-defs
306 @findex sepia-defs
307 Find definition(s) of function @var{name}.
309 @item M-. m @var{name} @key{RET}
310 @itemx M-x sepia-module-find @var{name} @key{RET}
311 @findex sepia-module-find
312 Find the source of module @var{name}.
314 @item M-. a @var{regexp} @key{RET}
315 @itemx M-x sepia-apropos @var{regexp} @key{RET}
316 @findex sepia-apropos
317 Find definitions of all functions whose names match @var{regexp}.
319 @item M-x sepia-apropos-module @var{regexp} @key{RET}
320 @findex sepia-apropos-module
321 Find all installed modules matching @var{regexp}.  This function may be
322 slow the first time it is called, because it has to build a list of
323 installed modules.
325 @item M-. c @var{name} @key{RET}
326 @itemx M-x sepia-callers @var{name} @key{RET}
327 @findex sepia-callers
328 (Xref) Find calls to function @var{name}.
330 @item M-. C @var{name} @key{RET}
331 @itemx M-x sepia-callees @var{name} @key{RET}
332 @findex sepia-callees
333 (Xref) Find the definitions of functions called by @var{name}.
335 @item M-. v @var{name} @key{RET}
336 @itemx M-x sepia-var-uses @var{name} @key{RET}
337 @findex sepia-var-uses
338 (Xref) Find uses of the global variable @var{name}.
340 @item M-. V @var{name} @key{RET}
341 @itemx M-x sepia-var-defs @var{name} @key{RET}
342 @findex sepia-var-defs
343 (Xref) Find definitions of global variable @var{name}.  Since Perl's
344 global variables are not declared, this is rarely useful
346 @c XXX: broken, so don't mention it.
347 @c @item M-. A @var{regexp} @key{RET}
348 @c @itemx M-x sepia-var-apropos
349 @c @findex sepia-var-apropos
350 @c Find definitions of all variables whose names match @var{regexp}.  Since
351 @c this function does not handle lexical variables, and since Perl's global
352 @c variables are not declared, this is rarely useful.
354 @end table
356 Finally, there are several other navigation-related commands that do not
357 fit into either of the above categories.
359 @c other commands
360 @table @kbd
361 @item M-,
362 @itemx M-x sepia-next
363 @findex sepia-next
364 Cycle through the definitions found by the previous @key{M-.} search.
366 @item M-. r
367 @itemx M-x sepia-rebuild
368 @findex sepia-rebuild
369 Rebuild the cross-reference database by walking the op-tree and
370 stashes.
372 @item M-. t
373 @itemx M-x find-tag
374 Execute the @code{find-tag} command typically bound to @key{M-.}.
376 @end table
378 @node Documentation, Other commands, Navigation, Editing
379 @section Documentation
381 Sepia can be used to browse installed modules' documentation, to format
382 and display the current buffer's POD, and to browse the list of modules
383 installed on the system.
385 @table @kbd
386 @item M-. d @var{name} @key{RET}
387 @itemx M-x sepia-perldoc-this
388 @findex sepia-perldoc-this
389 View documentation for module @var{name} or Perl manual page @var{name}.
391 @item C-c C-d
392 @itemx M-x sepia-view-pod
393 @findex sepia-view-pod
394 Format and view the current buffer's documentation.
396 @item sepia-package-list
397 @findex sepia-package-list
398 Browse a tree of installed packages.  This lists only the top-level
399 packages from installed distributions, so if package @code{My::Stuff}
400 also provides @code{My::Stuff::Details}, it will not be displayed.  When
401 Emacs-w3m is available, each module is linked to its documentation.
403 @item sepia-module-list
404 @findex sepia-module-list
405 Browse a tree of both top-level and internal packages, like
406 @code{sepia-package-list}.
408 @end table
410 @findex sepia-install-eldoc
411 Sepia also integrates with eldoc (at least in GNU Emacs >= 22).
412 Documentation for Perl operators and control structures is taken from
413 CPerl mode.  Sepia will also display documentation for user-defined
414 functions if their POD is formatted in the standard way, with functions
415 described in a ``=head2'' or ``=item'' entry.  To load user
416 documentation, visit the relevant file and type @kbd{M-x
417 sepia-doc-update}.
419 If @code{Module::CoreList} is available, Sepia's eldoc function will
420 also display the first version of Perl with which a module was shipped.
421 This is intended to give the programmer a sense of when he is creating
422 external dependencies.
424 @node Other commands,  , Documentation, Editing
425 @section Other commands
427 @table @kbd
428 @item M-x sepia-rename-lexical
429 @findex sepia-rename-lexical
430 Rename a variable in the function at point, querying for each
431 replacement when called with a prefix argument.  Currently, this is only
432 a thin wrapper around @code{query-replace}.
433 @end table
436 @c ============================================================
437 @node Interactive Perl, CPAN browsing, Editing, Top
438 @chapter Interactive Perl
440 @findex sepia-repl
441 Sepia's second main contribution is an interactive interface (REPL) to
442 an inferior Perl process.  The interface is based on GUD mode, and
443 inherits many of its bindings; this chapter discusses only the Sepia
444 extensions.  To start or switch to the repl, type @kbd{M-x sepia-repl}.
445 As in Sepia mode, @key{TAB} in the REPL performs partial-word completion
446 with @code{sepia-complete-symbol}.
448 Sepia also provides a number of other ways to evaluate pieces of code in
449 Perl, and commands to process buffer text using the inferior process.
451 @menu
452 * Shortcuts::                   
453 * Debugger::                    
454 * Evaluation::                  
455 * Mutilation::                  
456 * Scratchpad::                  
457 @end menu
459 @node Shortcuts, Debugger, Interactive Perl, Interactive Perl
460 @section Shortcuts
462 ``Shortcuts'' are commands handled specially by the REPL rather than
463 being evaluated as Perl code.  They either communicate with the REPL
464 function, or provide a convenient interface to Sepia variables and
465 functions.  Shortcuts are prefixed by a comma (@key{,}), and may be
466 abbreviated to the shortest unique prefix.  The debugger defines
467 additional shortcuts (@xref{Debugger}.).
469 @table @kbd
470 @item break @var{file}:@var{line} [@var{expr}]
471 Set a breakpoint in @var{file} at @var{line}.  If @var{expr} is
472 supplied, stop only if it evaluates to true.
474 @item cd @var{dir}
475 Change Perl's current directory to @var{dir}.
477 @item debug [@var{val}]
478 Turn Sepia debugger hook on or off, or toggle if @var{val} is missing.
480 @item define @var{name} ['@var{doc}'] @var{body...}
481 Define @var{name} as a shortcut for Perl code @var{body}, with optional
482 documentation @var{doc}, surrounded by single quotes.  @var{body} is
483 passed the raw command-line text as its first argument.
485 @item format @var{type}
486 Set the output format to @var{type}, either ``dumper'' (using
487 @code{Data::Dumper}), ``dump'' (@code{Data::Dump}), ``yaml''
488 (@code{YAML}), or ``plain'' (stringification).  Default: ``dumper''.
490 @item help
491 Display a list of shortcuts.
493 @item load [@var{file}]
494 Reload saved variables from @var{file} (or @file{~/.sepia-save}),
495 created by @kbd{save}.
497 @item lsbreak
498 List breakpoints.
500 @item methods @var{name} [@var{regexp}]
501 Display a list of functions defined in package @var{name} and its
502 @code{ISA}-ancestors matching optional pattern @var{regexp}.
504 @item package @var{name}
505 Set the default evaluation package to @var{name}.
507 @item pwd
508 Show the process's current working directory.
510 @item quit
511 Exit the inferior Perl process.
513 @item reload [@var{module} | @var{/pattern/}]
514 Reload @var{module} (but not its dependencies), or all modules matching
515 @var{pattern}.
517 @item freload @var{module}
518 Reload @var{module} and all of its dependencies.
520 @item restart
521 Reload @file{Sepia.pm} and recursively invoke the REPL.  This command is
522 mostly of interest when working on Sepia itself, and will fail
523 catastrophically if @file{Sepia.pm} fails to compile.
525 @item save [@var{pattern} [@var{file}]]
526 Save variables matching @var{pattern} (or all variables) to @var{file}
527 (or @file{~/.sepia-save}) in @code{Storable} format.  Note that because
528 saving magic variables can have unpredictable results, using @kbd{save}
529 without a pattern argument is risky.  Sepia excludes common magic
530 variables and dangerous packages, but its list is not foolproof.
532 @item shell [@var{command}]
533 Execute shell command @var{command}, displaying its standard output and
534 standard error.
536 @item size [@var{package} [@var{regexp}]]
537 List the variables in @var{package} (or the current package) along with
538 their total sizes.  This requires the @code{Devel::Size} module.
540 @item strict [@var{val}]
541 Set evaluation strictness to @var{val}, or toggle it if @var{val} is not
542 given.  Note that turning strictness off and on clears the REPL's
543 lexical environment.
545 @item test [@var{file}]
546 Run tests in the current directory.  If @var{file} is given, only run
547 test @var{file} or @file{t/@var{file}}
549 @item time [@var{val}]
550 Set time display to @var{val}, or toggle it if @var{val} is not given.
551 With time display enabled, Sepia will use @code{BSD::Resource} and/or
552 @code{Time::HiRes} to display wall clock time and CPU usage for the
553 previous command as part of the prompt.
555 @item undef @var{name}
556 Undefine shortcut @var{name}.  @strong{Warning}: this can equally be
557 used to remove built-in shortcuts.
559 @item wantarray [@var{val}]
560 Set the evaluation context to @var{val}, or toggle between scalar and
561 array context.
563 @item who @var{package} [@var{regexp}]
564 @itemx who [@var{regexp}]
565 List identifiers in @var{package} (main by default) matching
566 optional @var{regexp}.
568 @end table
570 @node Debugger, Evaluation, Shortcuts, Interactive Perl
571 @section Debugger
573 Sepia uses Perl's debugger hooks and GUD mode to support conditional
574 breakpoints and single-stepping, and overrides Perl's @code{die()} to
575 invoke the debugger rather than unwind the stack.  This makes it
576 possible to produce a backtrace, inspect and modify global variables,
577 and even continue execution when a program tries to kill itself.  If the
578 PadWalker module is available, Sepia also provides functions to inspect
579 and modify lexical variables.
581 The debugger has its own set of shortcuts, also prefixed by a comma.
583 @table @kbd
584 @item backtrace
585 Show a backtrace.
587 @item delete
588 Delete the current breakpoint.
590 @item down @var{n}
591 @itemx up @var{n}
592 Move the current stack frame up or down by @var{n} (or one) frames.
594 @item inspect [@var{n}]
595 Inspect lexicals in the current frame or frame @var{n}, counting upward
596 from 1.
598 @item next [@var{n}]
599 Advance @var{n} (or one) lines, skipping subroutine calls.
601 @item quit
602 @itemx die
603 @itemx warn
604 Continue as the program would have executed without debugger
605 intervention, dying if the debugger was called from @code{die()}.
607 @item return @var{expr}
608 Continue execution as if @code{die()} had returned the value of
609 @var{expr}, which is evaluated in the global environment.
611 @item step [@var{n}]
612 Step forward @var{n} (or one) lines, descending into subroutines.
614 @item xreturn @var{sub} @var{expr}
615 Return @var{expr} from the innermost call to @var{sub}.  This is a
616 somewhat dangerous and experimental feature, but is probably more useful
617 than returning a value from @code{die()}.
619 @end table
621 @node Evaluation, Mutilation, Debugger, Interactive Perl
622 @section Evaluation
624 When interactive Perl is running, Sepia can evaluate regions of code in
625 the inferior Perl process.  The following commands assume that this
626 process has already been started by calling @code{sepia-repl}.
628 @table @kbd
629 @item C-M-x
630 @itemx M-x sepia-eval-defun
631 @findex sepia-eval-defun
632 Evaluate the function around point in the inferior Perl process.  If it
633 contains errors, jump to the location of the first.
635 @item C-c C-l
636 @itemx M-x sepia-load-file
637 @findex sepia-load-file
638 Save the current buffer, then reload its file and if warnings or errors
639 occur, display an error buffer.  With a prefix argument, also rebuild
640 the cross-reference index.
642 @item C-c e
643 @itemx M-x sepia-eval-expression @key{RET} @var{expr} @key{RET}
644 @findex sepia-eval-expression
645 Evaluate @var{expr} in scalar context and echo the result.  With a
646 prefix argument, evaluate in list context.
648 @item C-c!
649 @itemx sepia-set-cwd
650 @findex sepia-set-cwd
651 Set the REPL's working directory to the current buffer's directory.
653 @end table
655 @node Mutilation, Scratchpad, Evaluation, Interactive Perl
656 @section Mutilation
658 Sepia contains several functions to operate on regions of text using the
659 interactive Perl process.  These functions can be used like standard
660 one-liners (e.g. @samp{perl -pe ...}), with the advantage that all of
661 the functions and variables in the interactive session are available.
663 @table @kbd
664 @item M-x sepia-perl-pe-region @key{RET} @var{code} @key{RET}
665 @findex sepia-perl-pe-region
666 Evaluate @var{code} on each line in the region with @code{$_} bound to
667 the line text, collecting the resulting values of @code{$_}.  With a
668 prefix argument, replace the region with the result.
670 @item M-x sepia-perl-ne-region @key{RET} @var{code} @key{RET}
671 @findex sepia-perl-ne-region
672 Evaluate @var{code} as above, but collect the results instead.
674 @item M-x sepia-perlize-region @key{RET} @var{code} @key{RET}
675 @findex sepia-perlize-region
676 Evaluate @var{code} once with @code{$_} bound to the entire region,
677 collecting the final value of @code{$_}.  With a prefix argument,
678 replace the region.
680 @end table
682 @node Scratchpad,  , Mutilation, Interactive Perl
683 @section Scratchpad
685 @findex sepia-scratch
686 Sepia also supports a scratchpad, another form of interaction inspired
687 by Emacs' @code{*scratch*} buffer.  To create or switch to the
688 scratchpad, type @kbd{M-x sepia-scratch}.  Scratchpad mode is exactly
689 like Sepia mode, except @key{C-j} evaluates the current line and prints
690 the result on the next line.
692 @c ============================================================
693 @node  CPAN browsing, Customization, Interactive Perl, Top
694 @chapter CPAN browsing
696 Sepia has rudimentary support for browsing documentation and installing
697 modules from CPAN.  Modules whose names, descriptions, or authors match
698 a query are displayed in a @code{*sepia-cpan*} buffer, in which the
699 following commands are available:
701 @table @kbd
702 @item s
703 @itemx M-x sepia-cpan-search @key{RET} @var{pattern} @key{RET}
704 @findex sepia-cpan-search
705 List modules whose names match @var{pattern}.
707 @item /
708 @itemx M-x sepia-cpan-desc @key{RET} @var{pattern} @key{RET}
709 @findex sepia-cpan-desc
710 List modules whose names or descriptions match @var{pattern}.
712 @item l
713 @itemx M-x sepia-cpan-list @key{RET} @var{name} @key{RET}
714 @findex sepia-cpan-list
715 List modules authored by @var{name}.
717 @item r
718 @itemx M-x sepia-cpan-readme @key{RET} @var{module} @key{RET}
719 @findex sepia-cpan-readme
720 Fetch and display @var{module}'s README file.
722 @item d
723 @itemx M-x sepia-cpan-doc @key{RET} @var{module} @key{RET}
724 @findex sepia-cpan-doc
725 Browse @var{module}'s documentation on @url{http://search.cpan.org}.
727 @item i
728 @itemx M-x sepia-cpan-install @key{RET} @var{module} @key{RET}
729 @findex sepia-cpan-install
730 Install @var{module} and its prerequisites.  This feature is not yet
731 well tested.
733 @end table
735 @c ============================================================
736 @node Customization, Internals, CPAN browsing, Top
737 @chapter Customization
739 While Sepia can be customized in both the Perl and Emacs Lisp, most of
740 the user-accessible configuration is in the latter.
742 @menu
743 * Emacs Variables::             
744 * Perl Variables::              
745 @end menu
747 @node Emacs Variables, Perl Variables, Customization, Customization
748 @section Emacs Variables
750 Since Sepia tries where possible to reuse existing Emacs functionality,
751 its behavior should already be covered by existing customizations.  The
752 two variables most likely to need customization are
753 @kbd{sepia-program-name} and @kbd{sepia-perl5lib}.  General Sepia mode
754 configuration can be done with @kbd{sepia-mode-hook}, while
755 REPL-specific configuration can be done with @kbd{sepia-repl-mode-hook}.
757 @vtable @kbd
759 @item sepia-complete-methods
760 If non-@code{nil}, @code{sepia-complete-symbol} will complete
761 simple method calls of the form @code{$x->} or @code{Module->}.  Since
762 the former requires evaluation of @code{$x}, this can be disabled.
763 Default: @code{T}.
765 @item sepia-eval-defun-include-decls
766 If non-@code{nil}, attempt to generate a declaration list for
767 @code{sepia-eval-defun}.  This is necessary when evaluating some code,
768 such as that calling functions without parentheses, because the presence
769 of declarations affects the parsing of barewords.  Default: @code{T}.
771 @item sepia-indent-expand-abbrev
772 If non-@code{nil}, @code{sepia-indent-or-complete} will, if
773 reindentation does not change the current line, expand an abbreviation
774 before point rather than performing completion.  Only if no abbreviation
775 is found will it perform completion.  Default: @code{T}.
777 @item sepia-module-list-function
778 The function to view a tree of installed modules.  Default:
779 @code{w3m-find-file} if Emacs-w3m is installed, or
780 @code{browse-url-of-buffer} otherwise.
782 @item sepia-perldoc-function
783 The function called to view installed modules' documentation.  Default:
784 @code{w3m-perldoc} if Emacs-w3m is installed, or @code{cperl-perldoc}
785 otherwise.
787 @item sepia-perl5lib
788 A list of directories to include in @code{PERL5LIB} when starting
789 interactive Perl.  Default: @code{nil}.
791 @item sepia-prefix-key
792 The prefix to use for for functions in @code{sepia-keymap}.  Default:
793 @key{M-.}.
795 @item sepia-program-name
796 The Perl program name for interactive Perl.  Default: ``perl''.
798 @item sepia-use-completion
799 If non-@code{nil}, various Sepia functions will generate completion
800 candidates from interactive Perl when called interactively.  This may be
801 slow or undesirable in some situations.  Default: @code{T}.
803 @item sepia-view-pod-function
804 The function called to view the current buffer's documentation.
805 Default: @code{sepia-w3m-view-pod} if Emacs-w3m is available, or
806 @code{sepia-perldoc-buffer} otherwise.
808 @end vtable
810 @node Perl Variables,  , Emacs Variables, Customization
811 @section Perl Variables
813 When Sepia starts up, it evaluates the Perl script in @file{~/.sepiarc}.
814 The following variables in the Sepia package control various aspects of
815 interactive evaluation.
817 @table @code
819 @item $PACKAGE
820 The package in which user input is evaluated, determined automatically
821 when code is evaluated from a buffer.  Default: @code{main}.
823 @item $PRINTER
824 The function called to format interactive output, normally set with the
825 @code{printer} shortcut.
827 @item $PRINT_PRETTY
828 If true, format some values nicely independent of the value of
829 @code{$PRINTER}.  Currently, this means columnating lists of simple
830 scalars.  Default: true.
832 @item $PS1
833 The trailing end of the prompt string, which should end with ``> ''.
834 Default: @code{"> "}.
836 @item $STOPDIE
837 If true, calls to @code{die} from interactive code will invoke the Sepia
838 debugger.  Default: true.
840 @item $STOPWARN
841 If true, calls to @code{warn} from interactive code will invoke the
842 Sepia debugger.  Default: false.
844 @item $WANTARRAY
845 If true, evaluate interactive expressions in list context.  Default: true.
847 @end table
849 Additional REPL shortcuts can be defined with
850 @kbd{Sepia::define_shortcut}.  For example
852 @example
853 Sepia::define_shortcut time => sub @{ print scalar localtime, "\n" @},
854     'time', 'Display the current time.';
855 @end example
857 defines a shortcut ``time'' that displays the current time.  For
858 details, see the code in @file{Sepia.pm}.
860 @c ============================================================
861 @node Internals, Credits, Customization, Top
862 @chapter Internals
864 Many things remain unexplained except by the code itself, and some
865 details mentioned above should probably be given less prominence.  For
866 developer documentation, please see the POD for @code{Sepia} and
867 @code{Sepia::Xref}, and the doc-strings in @file{sepia.el}.
869 @node Credits, Function Index, Internals, Top
870 @unnumbered Credits
872 @table @asis
873 @item Hilko Bengen
874 Found and motivated me to fix a bunch of bugs, created Debian packages.
876 @item Ævar Arnfjörð Bjarmason
877 Miscellaneous fixes.  Tested unicode support.
879 @item Ye Wenbin
880 Found and fixed numerous bugs.
882 @item Free Software
883 Portions of the code were lifted from Emacs-w3m, SLIME, ido, and
884 B::Xref, all of which are Free software.
886 @end table
888 @c ============================================================
889 @node Function Index, Variable Index, Credits, Top
890 @unnumbered Function Index
891 @printindex fn
893 @node Variable Index,  , Function Index, Top
894 @unnumbered Variable Index
895 @printindex vr
897 @bye