document and test new completion behavior.
[sepia.git] / sepia.texi
bloba89b05b34da5922e1a8c40348b01b3aa7f1d73c4
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-. c @var{name} @key{RET}
320 @itemx M-x sepia-callers @var{name} @key{RET}
321 @findex sepia-callers
322 (Xref) Find calls to function @var{name}.
324 @item M-. C @var{name} @key{RET}
325 @itemx M-x sepia-callees @var{name} @key{RET}
326 @findex sepia-callees
327 (Xref) Find the definitions of functions called by @var{name}.
329 @item M-. v @var{name} @key{RET}
330 @itemx M-x sepia-var-uses @var{name} @key{RET}
331 @findex sepia-var-uses
332 (Xref) Find uses of the global variable @var{name}.
334 @item M-. V @var{name} @key{RET}
335 @itemx M-x sepia-var-defs @var{name} @key{RET}
336 @findex sepia-var-defs
337 (Xref) Find definitions of global variable @var{name}.  Since Perl's
338 global variables are not declared, this is rarely useful
340 @c XXX: broken, so don't mention it.
341 @c @item M-. A @var{regexp} @key{RET}
342 @c @itemx M-x sepia-var-apropos
343 @c @findex sepia-var-apropos
344 @c Find definitions of all variables whose names match @var{regexp}.  Since
345 @c this function does not handle lexical variables, and since Perl's global
346 @c variables are not declared, this is rarely useful.
348 @end table
350 Finally, there are several other navigation-related commands that do not
351 fit into either of the above categories.
353 @c other commands
354 @table @kbd
355 @item M-,
356 @itemx M-x sepia-next
357 @findex sepia-next
358 Cycle through the definitions found by the previous @key{M-.} search.
360 @item M-. r
361 @itemx M-x sepia-rebuild
362 @findex sepia-rebuild
363 Rebuild the cross-reference database by walking the op-tree and
364 stashes.
366 @item M-. t
367 @itemx M-x find-tag
368 Execute the @code{find-tag} command typically bound to @key{M-.}.
370 @end table
372 @node Documentation, Other commands, Navigation, Editing
373 @section Documentation
375 Sepia can be used to browse installed modules' documentation, to format
376 and display the current buffer's POD, and to browse the list of modules
377 installed on the system.
379 @table @kbd
380 @item M-. d @var{name} @key{RET}
381 @itemx M-x sepia-perldoc-this
382 @findex sepia-perldoc-this
383 View documentation for module @var{name} or Perl manual page @var{name}.
385 @item C-c C-d
386 @itemx M-x sepia-view-pod
387 @findex sepia-view-pod
388 Format and view the current buffer's documentation.
390 @item sepia-package-list
391 @findex sepia-package-list
392 Browse a tree of installed packages.  This lists only the top-level
393 packages from installed distributions, so if package @code{My::Stuff}
394 also provides @code{My::Stuff::Details}, it will not be displayed.  When
395 Emacs-w3m is available, each module is linked to its documentation.
397 @item sepia-module-list
398 @findex sepia-module-list
399 Browse a tree of both top-level and internal packages, like
400 @code{sepia-package-list}.
402 @end table
404 @findex sepia-install-eldoc
405 Sepia also integrates with eldoc (at least in GNU Emacs >= 22).
406 Documentation for Perl operators and control structures is taken from
407 CPerl mode.  Sepia will also display documentation for user-defined
408 functions if their POD is formatted in the standard way, with functions
409 described in a ``=head2'' or ``=item'' entry.  To load user
410 documentation, visit the relevant file and type @kbd{M-x
411 sepia-doc-update}.
413 If @code{Module::CoreList} is available, Sepia's eldoc function will
414 also display the first version of Perl with which a module was shipped.
415 This is intended to give the programmer a sense of when he is creating
416 external dependencies.
418 @node Other commands,  , Documentation, Editing
419 @section Other commands
421 @table @kbd
422 @item M-x sepia-rename-lexical
423 @findex sepia-rename-lexical
424 Rename a variable in the function at point, querying for each
425 replacement when called with a prefix argument.  Currently, this is only
426 a thin wrapper around @code{query-replace}.
427 @end table
430 @c ============================================================
431 @node Interactive Perl, CPAN browsing, Editing, Top
432 @chapter Interactive Perl
434 @findex sepia-repl
435 Sepia's second main contribution is an interactive interface (REPL) to
436 an inferior Perl process.  The interface is based on GUD mode, and
437 inherits many of its bindings; this chapter discusses only the Sepia
438 extensions.  To start or switch to the repl, type @kbd{M-x sepia-repl}.
439 As in Sepia mode, @key{TAB} in the REPL performs partial-word completion
440 with @code{sepia-complete-symbol}.
442 Sepia also provides a number of other ways to evaluate pieces of code in
443 Perl, and commands to process buffer text using the inferior process.
445 @menu
446 * Shortcuts::                   
447 * Debugger::                    
448 * Evaluation::                  
449 * Mutilation::                  
450 * Scratchpad::                  
451 @end menu
453 @node Shortcuts, Debugger, Interactive Perl, Interactive Perl
454 @section Shortcuts
456 ``Shortcuts'' are commands handled specially by the REPL rather than
457 being evaluated as Perl code.  They either communicate with the REPL
458 function, or provide a convenient interface to Sepia variables and
459 functions.  Shortcuts are prefixed by a comma (@key{,}), and may be
460 abbreviated to the shortest unique prefix.  The debugger defines
461 additional shortcuts (@xref{Debugger}.).
463 @table @kbd
464 @item break @var{file}:@var{line} [@var{expr}]
465 Set a breakpoint in @var{file} at @var{line}.  If @var{expr} is
466 supplied, stop only if it evaluates to true.
468 @item cd @var{dir}
469 Change Perl's current directory to @var{dir}.
471 @item debug [@var{val}]
472 Turn Sepia debugger hook on or off, or toggle if @var{val} is missing.
474 @item define @var{name} ['@var{doc}'] @var{body...}
475 Define @var{name} as a shortcut for Perl code @var{body}, with optional
476 documentation @var{doc}, surrounded by single quotes.  @var{body} is
477 passed the raw command-line text as its first argument.
479 @item format @var{type}
480 Set the output format to @var{type}, either ``dumper'' (using
481 @code{Data::Dumper}), ``dump'' (@code{Data::Dump}), ``yaml''
482 (@code{YAML}), or ``plain'' (stringification).  Default: ``dumper''.
484 @item help
485 Display a list of shortcuts.
487 @item load [@var{file}]
488 Reload saved variables from @var{file} (or @file{~/.sepia-save}),
489 created by @kbd{save}.
491 @item lsbreak
492 List breakpoints.
494 @item methods @var{name} [@var{regexp}]
495 Display a list of functions defined in package @var{name} and its
496 @code{ISA}-ancestors matching optional pattern @var{regexp}.
498 @item package @var{name}
499 Set the default evaluation package to @var{name}.
501 @item pwd
502 Show the process's current working directory.
504 @item quit
505 Exit the inferior Perl process.
507 @item reload
508 Reload @file{Sepia.pm} and recursively invoke the REPL.  This command is
509 mostly of interest when working on Sepia itself, and will fail
510 catastrophically if @file{Sepia.pm} fails to compile.
512 @item save [@var{pattern} [@var{file}]]
513 Save variables matching @var{pattern} (or all variables) to @var{file}
514 (or @file{~/.sepia-save}) in @code{Storable} format.  Note that because
515 saving magic variables can have unpredictable results, using @kbd{save}
516 without a pattern argument is risky.  Sepia excludes common magic
517 variables and dangerous packages, but its list is not foolproof.
519 @item shell [@var{command}]
520 Execute shell command @var{command}, displaying its standard output and
521 standard error.
523 @item size [@var{package} [@var{regexp}]]
524 List the variables in @var{package} (or the current package) along with
525 their total sizes.  This requires the @code{Devel::Size} module.
527 @item strict [@var{val}]
528 Set evaluation strictness to @var{val}, or toggle it if @var{val} is not
529 given.  Note that turning strictness off and on clears the REPL's
530 lexical environment.
532 @item undef @var{name}
533 Undefine shortcut @var{name}.  @strong{Warning}: this can equally be
534 used to remove built-in shortcuts.
536 @item wantarray [@var{val}]
537 Set the evaluation context to @var{val}, or toggle between scalar and
538 array context.
540 @item who @var{package} [@var{regexp}]
541 @itemx who [@var{regexp}]
542 List identifiers in @var{package} (main by default) matching
543 optional @var{regexp}.
545 @end table
547 @node Debugger, Evaluation, Shortcuts, Interactive Perl
548 @section Debugger
550 Sepia uses Perl's debugger hooks and GUD mode to support conditional
551 breakpoints and single-stepping, and overrides Perl's @code{die()} to
552 invoke the debugger rather than unwind the stack.  This makes it
553 possible to produce a backtrace, inspect and modify global variables,
554 and even continue execution when a program tries to kill itself.  If the
555 PadWalker module is available, Sepia also provides functions to inspect
556 and modify lexical variables.
558 The debugger has its own set of shortcuts, also prefixed by a comma.
560 @table @kbd
561 @item backtrace
562 Show a backtrace.
564 @item delete
565 Delete the current breakpoint.
567 @item down @var{n}
568 @itemx up @var{n}
569 Move the current stack frame up or down by @var{n} (or one) frames.
571 @item inspect [@var{n}]
572 Inspect lexicals in the current frame or frame @var{n}, counting upward
573 from 1.
575 @item next [@var{n}]
576 Advance @var{n} (or one) lines, skipping subroutine calls.
578 @item quit
579 @itemx die
580 @itemx warn
581 Continue as the program would have executed without debugger
582 intervention, dying if the debugger was called from @code{die()}.
584 @item return @var{expr}
585 Continue execution as if @code{die()} had returned the value of
586 @var{expr}, which is evaluated in the global environment.
588 @item step [@var{n}]
589 Step forward @var{n} (or one) lines, descending into subroutines.
591 @item xreturn @var{sub} @var{expr}
592 Return @var{expr} from the innermost call to @var{sub}.  This is a
593 somewhat dangerous and experimental feature, but is probably more useful
594 than returning a value from @code{die()}.
596 @end table
598 @node Evaluation, Mutilation, Debugger, Interactive Perl
599 @section Evaluation
601 When interactive Perl is running, Sepia can evaluate regions of code in
602 the inferior Perl process.  The following commands assume that this
603 process has already been started by calling @code{sepia-repl}.
605 @table @kbd
606 @item C-M-x
607 @itemx M-x sepia-eval-defun
608 @findex sepia-eval-defun
609 Evaluate the function around point in the inferior Perl process.  If it
610 contains errors, jump to the location of the first.
612 @item C-c C-l
613 @itemx M-x sepia-load-file
614 @findex sepia-load-file
615 Save the current buffer, then reload its file and if warnings or errors
616 occur, display an error buffer.  With a prefix argument, also rebuild
617 the cross-reference index.
619 @item C-c e
620 @itemx M-x sepia-eval-expression @key{RET} @var{expr} @key{RET}
621 @findex sepia-eval-expression
622 Evaluate @var{expr} in scalar context and echo the result.  With a
623 prefix argument, evaluate in list context.
625 @item C-c!
626 @itemx sepia-set-cwd
627 @findex sepia-set-cwd
628 Set the REPL's working directory to the current buffer's directory.
630 @end table
632 @node Mutilation, Scratchpad, Evaluation, Interactive Perl
633 @section Mutilation
635 Sepia contains several functions to operate on regions of text using the
636 interactive Perl process.  These functions can be used like standard
637 one-liners (e.g. @samp{perl -pe ...}), with the advantage that all of
638 the functions and variables in the interactive session are available.
640 @table @kbd
641 @item M-x sepia-perl-pe-region @key{RET} @var{code} @key{RET}
642 @findex sepia-perl-pe-region
643 Evaluate @var{code} on each line in the region with @code{$_} bound to
644 the line text, collecting the resulting values of @code{$_}.  With a
645 prefix argument, replace the region with the result.
647 @item M-x sepia-perl-ne-region @key{RET} @var{code} @key{RET}
648 @findex sepia-perl-ne-region
649 Evaluate @var{code} as above, but collect the results instead.
651 @item M-x sepia-perlize-region @key{RET} @var{code} @key{RET}
652 @findex sepia-perlize-region
653 Evaluate @var{code} once with @code{$_} bound to the entire region,
654 collecting the final value of @code{$_}.  With a prefix argument,
655 replace the region.
657 @end table
659 @node Scratchpad,  , Mutilation, Interactive Perl
660 @section Scratchpad
662 @findex sepia-scratch
663 Sepia also supports a scratchpad, another form of interaction inspired
664 by Emacs' @code{*scratch*} buffer.  To create or switch to the
665 scratchpad, type @kbd{M-x sepia-scratch}.  Scratchpad mode is exactly
666 like Sepia mode, except @key{C-j} evaluates the current line and prints
667 the result on the next line.
669 @c ============================================================
670 @node  CPAN browsing, Customization, Interactive Perl, Top
671 @chapter CPAN browsing
673 Sepia has rudimentary support for browsing documentation and installing
674 modules from CPAN.  Modules whose names, descriptions, or authors match
675 a query are displayed in a @code{*sepia-cpan*} buffer, in which the
676 following commands are available:
678 @table @kbd
679 @item s
680 @itemx M-x sepia-cpan-search @key{RET} @var{pattern} @key{RET}
681 @findex sepia-cpan-search
682 List modules whose names match @var{pattern}.
684 @item /
685 @itemx M-x sepia-cpan-desc @key{RET} @var{pattern} @key{RET}
686 @findex sepia-cpan-desc
687 List modules whose names or descriptions match @var{pattern}.
689 @item l
690 @itemx M-x sepia-cpan-list @key{RET} @var{name} @key{RET}
691 @findex sepia-cpan-list
692 List modules authored by @var{name}.
694 @item r
695 @itemx M-x sepia-cpan-readme @key{RET} @var{module} @key{RET}
696 @findex sepia-cpan-readme
697 Fetch and display @var{module}'s README file.
699 @item d
700 @itemx M-x sepia-cpan-doc @key{RET} @var{module} @key{RET}
701 @findex sepia-cpan-doc
702 Browse @var{module}'s documentation on @url{http://search.cpan.org}.
704 @item i
705 @itemx M-x sepia-cpan-install @key{RET} @var{module} @key{RET}
706 @findex sepia-cpan-install
707 Install @var{module} and its prerequisites.  This feature is not yet
708 well tested.
710 @end table
712 @c ============================================================
713 @node Customization, Internals, CPAN browsing, Top
714 @chapter Customization
716 While Sepia can be customized in both the Perl and Emacs Lisp, most of
717 the user-accessible configuration is in the latter.
719 @menu
720 * Emacs Variables::             
721 * Perl Variables::              
722 @end menu
724 @node Emacs Variables, Perl Variables, Customization, Customization
725 @section Emacs Variables
727 Since Sepia tries where possible to reuse existing Emacs functionality,
728 its behavior should already be covered by existing customizations.  The
729 two variables most likely to need customization are
730 @kbd{sepia-program-name} and @kbd{sepia-perl5lib}.  General Sepia mode
731 configuration can be done with @kbd{sepia-mode-hook}, while
732 REPL-specific configuration can be done with @kbd{sepia-repl-mode-hook}.
734 @vtable @kbd
736 @item sepia-complete-methods
737 If non-@code{nil}, @code{sepia-complete-symbol} will complete
738 simple method calls of the form @code{$x->} or @code{Module->}.  Since
739 the former requires evaluation of @code{$x}, this can be disabled.
740 Default: @code{T}.
742 @item sepia-eval-defun-include-decls
743 If non-@code{nil}, attempt to generate a declaration list for
744 @code{sepia-eval-defun}.  This is necessary when evaluating some code,
745 such as that calling functions without parentheses, because the presence
746 of declarations affects the parsing of barewords.  Default: @code{T}.
748 @item sepia-indent-expand-abbrev
749 If non-@code{nil}, @code{sepia-indent-or-complete} will, if
750 reindentation does not change the current line, expand an abbreviation
751 before point rather than performing completion.  Only if no abbreviation
752 is found will it perform completion.  Default: @code{T}.
754 @item sepia-module-list-function
755 The function to view a tree of installed modules.  Default:
756 @code{w3m-find-file} if Emacs-w3m is installed, or
757 @code{browse-url-of-buffer} otherwise.
759 @item sepia-perldoc-function
760 The function called to view installed modules' documentation.  Default:
761 @code{w3m-perldoc} if Emacs-w3m is installed, or @code{cperl-perldoc}
762 otherwise.
764 @item sepia-perl5lib
765 A list of directories to include in @code{PERL5LIB} when starting
766 interactive Perl.  Default: @code{nil}.
768 @item sepia-prefix-key
769 The prefix to use for for functions in @code{sepia-keymap}.  Default:
770 @key{M-.}.
772 @item sepia-program-name
773 The Perl program name for interactive Perl.  Default: ``perl''.
775 @item sepia-use-completion
776 If non-@code{nil}, various Sepia functions will generate completion
777 candidates from interactive Perl when called interactively.  This may be
778 slow or undesirable in some situations.  Default: @code{T}.
780 @item sepia-view-pod-function
781 The function called to view the current buffer's documentation.
782 Default: @code{sepia-w3m-view-pod} if Emacs-w3m is available, or
783 @code{sepia-perldoc-buffer} otherwise.
785 @end vtable
787 @node Perl Variables,  , Emacs Variables, Customization
788 @section Perl Variables
790 When Sepia starts up, it evaluates the Perl script in @file{~/.sepiarc}.
791 The following variables in the Sepia package control various aspects of
792 interactive evaluation.
794 @table @code
796 @item $PACKAGE
797 The package in which user input is evaluated, determined automatically
798 when code is evaluated from a buffer.  Default: @code{main}.
800 @item $PRINTER
801 The function called to format interactive output, normally set with the
802 @code{printer} shortcut.
804 @item $PRINT_PRETTY
805 If true, format some values nicely independent of the value of
806 @code{$PRINTER}.  Currently, this means columnating lists of simple
807 scalars.  Default: true.
809 @item $PS1
810 The trailing end of the prompt string, which should end with ``> ''.
811 Default: @code{"> "}.
813 @item $STOPDIE
814 If true, calls to @code{die} from interactive code will invoke the Sepia
815 debugger.  Default: true.
817 @item $STOPWARN
818 If true, calls to @code{warn} from interactive code will invoke the
819 Sepia debugger.  Default: false.
821 @item $WANTARRAY
822 If true, evaluate interactive expressions in list context.  Default: true.
824 @end table
826 Additional REPL shortcuts can be defined with
827 @kbd{Sepia::define_shortcut}.  For example
829 @example
830 Sepia::define_shortcut time => sub @{ print scalar localtime, "\n"; 0 @},
831     'Display the current time.';
832 @end example
834 defines a shortcut ``time'' that displays the current time.  For
835 details, see the code in @file{Sepia.pm}.
837 @c ============================================================
838 @node Internals, Credits, Customization, Top
839 @chapter Internals
841 Many things remain unexplained except by the code itself, and some
842 details mentioned above should probably be given less prominence.  For
843 developer documentation, please see the POD for @code{Sepia} and
844 @code{Sepia::Xref}, and the doc-strings in @file{sepia.el}.
846 @node Credits, Function Index, Internals, Top
847 @unnumbered Credits
849 @table @asis
850 @item Hilko Bengen
851 Found and motivated me to fix a bunch of bugs, created Debian packages.
853 @item Ævar Arnfjörð Bjarmason
854 Miscellaneous fixes.  Tested unicode support.
856 @item Ye Wenbin
857 Found and fixed numerous bugs.
859 @item Free Software
860 Portions of the code were lifted from Emacs-w3m, SLIME, ido, and
861 B::Xref, all of which are Free software.
863 @end table
865 @c ============================================================
866 @node Function Index, Variable Index, Credits, Top
867 @unnumbered Function Index
868 @printindex fn
870 @node Variable Index,  , Function Index, Top
871 @unnumbered Variable Index
872 @printindex vr
874 @bye