The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<html lang="en">
<head>
<title>SEPIA: Simple Emacs Perl Integration</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="SEPIA: Simple Emacs Perl Integration">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="top" href="#Top">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<h1 class="settitle">SEPIA: Simple Emacs Perl Integration</h1>
<div class="node">
<p><hr>
<a name="Top"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Introduction">Introduction</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>

</div>

   <div class="block-image"><img src="Sepia.jpg" alt="Sepia.jpg"></div>

   <p>Sepia is a set of Perl development tools for Emacs supporting code
navigation and interactive evaluation.

<ul class="menu">
<li><a accesskey="1" href="#Introduction">Introduction</a>
<li><a accesskey="2" href="#Editing">Editing</a>
<li><a accesskey="3" href="#Interactive-Perl">Interactive Perl</a>
<li><a accesskey="4" href="#Customization">Customization</a>
<li><a accesskey="5" href="#Internals">Internals</a>
<li><a accesskey="6" href="#Credits">Credits</a>
<li><a accesskey="7" href="#Function-Index">Function Index</a>
</ul>

<!-- ============================================================ -->
<div class="node">
<p><hr>
<a name="Introduction"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Editing">Editing</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">1 Introduction</h2>

<p>Sepia is a set of tools for Perl development in Emacs.  Its goal is to
extend CPerl mode to support fast code navigation and interactive
development.  It is inspired by Emacs' current support for a number of
other languages, including Lisp, Python, and Emacs Lisp.

<ul class="menu">
<li><a accesskey="1" href="#Getting-Started">Getting Started</a>
<li><a accesskey="2" href="#Philosophy">Philosophy</a>
</ul>

<div class="node">
<p><hr>
<a name="Getting-Started"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Philosophy">Philosophy</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.1 Getting Started</h3>

<p>To install Sepia, its Emacs Lisp files must be in Emacs'
<code>load-path</code>, and the <samp><span class="file">lib</span></samp> directory must be in Perl's
<code>@INC</code>.  Assuming that Sepia has been unpacked in
<samp><span class="file">~/sepia</span></samp>, it can be installed by adding the following lines to
<samp><span class="file">~/.emacs</span></samp>:

<pre class="example">     (add-to-list 'load-path "~/sepia")
     (setq sepia-perl5lib (list (expand-file-name "~/sepia/lib")))
     (defalias 'perl-mode 'sepia-mode)
     (require 'sepia)
</pre>
   <p>Then to bring up the interactive Perl prompt, type <kbd>M-x sepia-repl</kbd>.

<div class="node">
<p><hr>
<a name="Philosophy"></a>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Getting-Started">Getting Started</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>

</div>

<h3 class="section">1.2 Philosophy</h3>

<p>A development environment should support three activities: code
spelunking, interaction, and customization.  Emacs as an environment for
developing Emacs Lisp thoroughly supports all of them: It has commands
to visit individual functions' code and documentation, commands to
evaluate or step through expressions, and an architecture that
encourages customization in Emacs Lisp.  As an environment for Perl,
however, it is lacking: there is limited interactivity with the Perl
debugger, and reasonable documentation browsing, but no support for
navigating, editing, and re-evaluating code.  Sepia attempts to remedy
the situation.

   <p>Modern IDEs also support these three activities, but do so awkwardly. 
Rather than having functions to visit definitions (<kbd>find-function</kbd>)
and search for functions (<kbd>apropos</kbd>), they clutter the screen with
class and file trees.  Rather than supporting interactive evaluation of
small pieces of code, they perform background semantic checking on whole
projects and highlight errors.  Rather than allowing minor
customizations to grow organically into features, they support limited
configuration files and baroque plug-in APIs.  Sepia tries to adhere to
the apparent Emacs philosophy that rich semantic information should be
unobtrusive, and that the best way to build working code is to start
by experimenting with small pieces.

   <p>Language support packages for Emacs vary widely in the degree to which
they make use of or replace existing Emacs features.  Minimal modes
provide keyword-based syntax highlighting and an unadorned comint buffer
as an interpreter.  Others provide their own specialized equivalents of
comint, eldoc, completion, and other Emacs features.  Sepia takes a
third approach by trying to do as much as possible with existing Emacs
features, even when they are not optimal for Perl.  For example, it uses
comint to communicate with the subprocess, eldoc to display
documentation, and grep to list source locations.

   <p>This approach has three advantages: First, it maximizes the number of
features that can be supported with limited development time.  Second,
it respects users' settings.  A seasoned Emacs user may have changed
hundreds of settings, so a mode that reimplements features will have to
support equivalent settings, and will force the user to re-specify them. 
Finally, this approach respects decades of development spent, as Neal
Stephenson put it, &ldquo;focused with maniacal intensity on the deceptively
simple-seeming problem of editing text.&rdquo;  Many non-obvious choices go
into making a polished interface, and while a reimplementation gets rid
of accumulated cruft, it must rediscover these hidden trade-offs.

   <p>Anyways, I hope you enjoy using Sepia.  Its development style is strange
for someone used Perl's typical mix of one-liners and edit-save-run, but
once you are accustomed to it, you may find it very effective.

<!-- ============================================================ -->
<div class="node">
<p><hr>
<a name="Editing"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Interactive-Perl">Interactive Perl</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">2 Editing</h2>

<p><a name="index-sepia_002dmode-1"></a>
Sepia's first contribution is a set of commands to explore a Perl
codebase.  These include commands to browse and display documentation,
to find function definitions, and to query a cross-reference database of
function and variable uses.  Sepia also provides intelligent symbol
completion.

<ul class="menu">
<li><a accesskey="1" href="#Completion">Completion</a>
<li><a accesskey="2" href="#Navigation">Navigation</a>
<li><a accesskey="3" href="#Documentation">Documentation</a>
</ul>

<div class="node">
<p><hr>
<a name="Completion"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Navigation">Navigation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Editing">Editing</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Editing">Editing</a>

</div>

<h3 class="section">2.1 Completion</h3>

<p>Sepia implements partial-word completion that communicates with the
inferior Perl process.  For example, `<samp><span class="samp">%S:X:v_u</span></samp>' completes to
`<samp><span class="samp">%Sepia::Xref::var_use</span></samp>' when Sepia is loaded.  This completion only
operates on functions and global variables known to the Perl
interpreter, so it works best when code and interpreter are in sync.

   <p>More precisely, completion examines the text before point and tries each
of the following in turn, using the first successful approach:

     <ol type=1 start=1>
<li>If the text looks like a method call (e.g. `<samp><span class="samp">$object-&gt;f</span></samp>' or
`<samp><span class="samp">Class-&gt;f</span></samp>'), complete on methods.

     <li>If it looks like a variable (e.g. `<samp><span class="samp">%hash</span></samp>' or `<samp><span class="samp">$scalar</span></samp>'),
complete on variables.

     <li>Complete on modules and functions.

     <li>Otherwise, complete on Perl built-in operators.
        </ol>

   <p>For each of the first three cases, completions candidates are first
generated by splitting the text on characters <code>[:_]</code> and matching
the resulting word parts.  For example, `<samp><span class="samp">X:a_b</span></samp>' will complete to
all symbols matching `<samp><span class="samp">^X[^:]*:+a[^:_]*_b</span></samp>' such as `<samp><span class="samp">Xref::a_bug</span></samp>'
and `<samp><span class="samp">X::always_bites_me</span></samp>'.  If no matches result, the text is
treated as an acronym.  For example, `<samp><span class="samp">dry</span></samp>' will complete to
`<samp><span class="samp">dont_repeat_yourself</span></samp>'.

   <p>Completion is performed by the following commands:
     <dl>
<dt><kbd>M-x sepia-complete-symbol</kbd><dd><a name="index-sepia_002dcomplete_002dsymbol-2"></a>Complete the symbol before point as described above.  Note that this
does not consider lexical scope, and is always case-sensitive,
independent of <code>completion-ignore-case</code>.

     <br><dt><kbd>TAB</kbd><dt><kbd>M-x sepia-indent-or-complete</kbd><dd><a name="index-sepia_002dindent_002dor_002dcomplete-3"></a>First try to reindent the current line.  If its indentation does not
change, then try to expand an abbrev at point (unless
<code>sepia-indent-expand-abbrev</code> is <code>nil</code>).  If no abbrev is
expanded, then call <code>sepia-complete-symbol</code>.

   </dl>

<div class="node">
<p><hr>
<a name="Navigation"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Documentation">Documentation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Completion">Completion</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Editing">Editing</a>

</div>

<h3 class="section">2.2 Navigation</h3>

<p>Sepia provides several commands for navigating program source.  All of
them rely on information from the inferior Perl process, so it is
important both that it be running, and that its internal representation
of the program match the program source.  The commands marked (Xref)
below also rely on a cross-reference database, which must be explicitly
rebuilt by calling <code>xref-rebuild</code> when the program changes.

   <p>There are two basic kinds of navigation commands.  The first kind jumps
directly to the first matching location when possible, prompting only if
no such location is found.  These commands find only a single location.

<!-- direct-jump commands -->
<dl>
<dt><kbd>M-. M-.</kbd><dt><kbd>M-x sepia-dwim</kbd><dd><a name="index-sepia_002ddwim-4"></a>Guess what kind of identifier is at point, and try to do the right
thing: for a function, find its definition(s); for a variable, find its
uses; for a module, view its documentation; otherwise, prompt for the
name of a function to visit.  <code>sepia-dwim</code> automatically goes to
the first function definition or variable use found.

     <br><dt><kbd>M-. l</kbd><dt><kbd>M-x sepia-location</kbd><dd><a name="index-sepia_002dlocation-5"></a>Jump directly to the definition of the function at point, prompting if
point is not on a known function.  If multiple definitions are found,
choose one arbitrarily.  This function is similar to <code>sepia-defs</code>,
and the two should probably be merged.

     <br><dt><kbd>M-. j</kbd><dt><kbd>M-x sepia-jump-to-symbol</kbd><dd><a name="index-sepia_002djump_002dto_002dsymbol-6"></a>Navigate to a function using &ldquo;ido&rdquo; interactive completion.  Within
interactive completion, press &lt;:&gt; to descend into a package,
&lt;DEL&gt; to ascend to a parent package, and &lt;RET&gt; to go to the
currently-selected function.

   </dl>

   <p>The second kind of navigation commands always prompts the user &ndash; though
usually with a sensible default value &ndash; and finds multiple locations. 
When called with a prefix argument, these commands present their results
in a <code>grep-mode</code> buffer.  When called <em>without</em> a prefix
argument, they place all results on the found-location ring and jump
directly to the first.  The remaining locations can be cycled through by
calls to <code>sepia-next</code>.

<!-- prompt-and-go commands -->
<dl>
<dt><kbd>M-. f </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-defs</kbd><dd><a name="index-sepia_002ddefs-7"></a>Find definition(s) of function <var>name</var>.

     <br><dt><kbd>M-. m </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-module-find </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dmodule_002dfind-8"></a>Find the source of module <var>name</var>.

     <br><dt><kbd>M-. a </kbd><var>regexp</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-apropos </kbd><var>regexp</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dapropos-9"></a>Find definitions of all functions whose names match <var>regexp</var>.

     <br><dt><kbd>M-. c </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-callers </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dcallers-10"></a>(Xref) Find calls to function <var>name</var>.

     <br><dt><kbd>M-. C </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-callees </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dcallees-11"></a>(Xref) Find the definitions of functions called by <var>name</var>.

     <br><dt><kbd>M-. v </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-var-uses </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dvar_002duses-12"></a>(Xref) Find uses of the global variable <var>name</var>.

     <br><dt><kbd>M-. V </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-var-defs </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dvar_002ddefs-13"></a>(Xref) Find definitions of global variable <var>name</var>.  Since Perl's
global variables are not declared, this is rarely useful

     <!-- XXX: broken, so don't mention it. -->
<!-- @item M-. A @var{regexp} @key{RET} -->
<!-- @itemx M-x sepia-var-apropos -->
<!-- @findex sepia-var-apropos -->
<!-- Find definitions of all variables whose names match @var{regexp}.  Since -->
<!-- this function does not handle lexical variables, and since Perl's global -->
<!-- variables are not declared, this is rarely useful. -->
</dl>

   <p>Finally, there are several other navigation-related commands that do not
fit into either of the above categories.

<!-- other commands -->
<dl>
<dt><kbd>M-,</kbd><dt><kbd>M-x sepia-next</kbd><dd><a name="index-sepia_002dnext-14"></a>Cycle through the definitions found by the previous &lt;M-.&gt; search.

     <br><dt><kbd>M-. r</kbd><dt><kbd>M-x sepia-rebuild</kbd><dd><a name="index-sepia_002drebuild-15"></a>Rebuild the cross-reference database by walking the op-tree and
stashes.

     <br><dt><kbd>M-. t</kbd><dt><kbd>M-x find-tag</kbd><dd>Execute the <code>find-tag</code> command typically bound to &lt;M-.&gt;.

   </dl>

<div class="node">
<p><hr>
<a name="Documentation"></a>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Navigation">Navigation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Editing">Editing</a>

</div>

<h3 class="section">2.3 Documentation</h3>

<p>Sepia can be used to browse installed modules' documentation, to format
and display the current buffer's POD, and to browse the list of modules
installed on the system.

     <dl>
<dt><kbd>M-. d </kbd><var>name</var><kbd> &lt;RET&gt;</kbd><dt><kbd>M-x sepia-perldoc-this</kbd><dd><a name="index-sepia_002dperldoc_002dthis-16"></a>View documentation for module <var>name</var> or Perl manual page <var>name</var>.

     <br><dt><kbd>C-c C-d</kbd><dt><kbd>M-x sepia-view-pod</kbd><dd><a name="index-sepia_002dview_002dpod-17"></a>Format and view the current buffer's documentation.

     <br><dt><kbd>sepia-package-list</kbd><dd><a name="index-sepia_002dpackage_002dlist-18"></a>Browse a tree of installed packages.  This lists only the top-level
packages from installed distributions, so if package <code>My::Stuff</code>
also provides <code>My::Stuff::Details</code>, it will not be displayed.  When
Emacs-w3m is available, each module is linked to its documentation.

     <br><dt><kbd>sepia-module-list</kbd><dd><a name="index-sepia_002dmodule_002dlist-19"></a>Browse a tree of both top-level and internal packages, like
<code>sepia-package-list</code>.

   </dl>

   <p><a name="index-sepia_002dinstall_002deldoc-20"></a>Sepia also integrates with eldoc (at least in GNU Emacs &gt;= 22). 
Documentation for Perl operators and control structures is taken from
CPerl mode.  Sepia will also display documentation for user-defined
functions if their POD is formatted in the standard way, with functions
described in a &ldquo;=head2&rdquo; or &ldquo;=item&rdquo; entry.  To load user
documentation, visit the relevant file and type <kbd>M-x
sepia-doc-update</kbd>.

   <p>If <code>Module::CoreList</code> is available, Sepia's eldoc function will
also display the first version of Perl with which a module was shipped. 
This is intended to give the programmer a sense of when he is creating
external dependencies.

<!-- ============================================================ -->
<div class="node">
<p><hr>
<a name="Interactive-Perl"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Customization">Customization</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Editing">Editing</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">3 Interactive Perl</h2>

<p><a name="index-sepia_002drepl-21"></a>Sepia's second main contribution is an interactive interface (REPL) to
an inferior Perl process.  The interface is based on GUD mode, and
inherits many of its bindings; this chapter discusses only the Sepia
extensions.  To start or switch to the repl, type <kbd>M-x sepia-repl</kbd>. 
As in Sepia mode, &lt;TAB&gt; in the REPL performs partial-word completion
with <code>sepia-complete-symbol</code>.

   <p>Sepia also provides a number of other ways to evaluate pieces of code in
Perl, and commands to process buffer text using the inferior process.

<ul class="menu">
<li><a accesskey="1" href="#Shortcuts">Shortcuts</a>
<li><a accesskey="2" href="#Debugger">Debugger</a>
<li><a accesskey="3" href="#Evaluation">Evaluation</a>
<li><a accesskey="4" href="#Mutilation">Mutilation</a>
<li><a accesskey="5" href="#Scratchpad">Scratchpad</a>
</ul>

<div class="node">
<p><hr>
<a name="Shortcuts"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Debugger">Debugger</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Interactive-Perl">Interactive Perl</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Interactive-Perl">Interactive Perl</a>

</div>

<h3 class="section">3.1 Shortcuts</h3>

<p>&ldquo;Shortcuts&rdquo; are commands handled specially by the REPL rather than
being evaluated as Perl code.  They either communicate with the REPL
function, or provide a convenient interface to variables in the Sepia
package.  Shortcuts are prefixed by a comma (&lt;,&gt;), and may be
abbreviated to the shortest unique prefix.

     <dl>
<dt><kbd>cd </kbd><var>dir</var><dd>Change Perl's current directory to <var>dir</var>.

     <br><dt><kbd>debug [</kbd><var>val</var><kbd>]</kbd><dd>Turn Sepia debugger hook on or off, or toggle if <var>val</var> is missing.

     <br><dt><kbd>define </kbd><var>name</var><kbd> ['</kbd><var>doc</var><kbd>'] </kbd><var>body...</var><dd>Define <var>name</var> as a shortcut for Perl code <var>body</var>, with optional
documentation <var>doc</var>, surrounded by single quotes.  <var>body</var> is
passed the raw command-line text as its first argument.

     <br><dt><kbd>delete</kbd><dd>Delete the current breakpoint.

     <br><dt><kbd>format </kbd><var>type</var><dd>Set the output format to <var>type</var>, either &ldquo;dumper&rdquo; (using
<code>Data::Dumper</code>), &ldquo;dump&rdquo; (<code>Data::Dump</code>), &ldquo;yaml&rdquo;
(<code>YAML</code>), or &ldquo;plain&rdquo; (stringification).  Default: &ldquo;dumper&rdquo;.

     <br><dt><kbd>help</kbd><dd>Display a list of shortcuts.

     <br><dt><kbd>lsbreak</kbd><dd>List breakpoints.

     <br><dt><kbd>methods </kbd><var>name</var><kbd> [</kbd><var>regexp</var><kbd>]</kbd><dd>Display a list of functions defined in package <var>name</var> and its
<code>ISA</code>-ancestors matching optional pattern <var>regexp</var>.

     <br><dt><kbd>package </kbd><var>name</var><dd>Set the default evaluation package to <var>name</var>.

     <br><dt><kbd>pwd</kbd><dd>Show the process's current working directory.

     <br><dt><kbd>quit</kbd><dd>Exit the inferior Perl process.

     <br><dt><kbd>reload</kbd><dd>Reload <samp><span class="file">Sepia.pm</span></samp> and recursively invoke the REPL.  This command is
mostly of interest when working on Sepia itself.

     <br><dt><kbd>shell [</kbd><var>command</var><kbd>]</kbd><dd>Execute shell command <var>command</var>, displaying its standard output and
standard error.

     <br><dt><kbd>strict [</kbd><var>val</var><kbd>]</kbd><dd>Set evaluation strictness to <var>val</var>, or toggle it if <var>val</var> is not
given.  Note that turning strictness off and on clears the REPL's
lexical environment.

     <br><dt><kbd>undef </kbd><var>name</var><dd>Undefine shortcut <var>name</var>.  <strong>Warning</strong>: this can equally be
used to remove built-in shortcuts.

     <br><dt><kbd>wantarray [</kbd><var>val</var><kbd>]</kbd><dd>Set the evaluation context to <var>val</var>, or toggle between scalar and
array context.

     <br><dt><kbd>who </kbd><var>package</var><kbd> [</kbd><var>regexp</var><kbd>]</kbd><dt><kbd>who [</kbd><var>regexp</var><kbd>]</kbd><dd>List identifiers in <var>package</var> (main by default) matching
optional <var>regexp</var>.

   </dl>

<div class="node">
<p><hr>
<a name="Debugger"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Evaluation">Evaluation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Shortcuts">Shortcuts</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Interactive-Perl">Interactive Perl</a>

</div>

<h3 class="section">3.2 Debugger</h3>

<p>Sepia uses Perl's debugger hooks and GUD mode to support conditional
breakpoints and single-stepping, and overrides Perl's <code>die()</code> to
invoke the debugger rather than unwind the stack.  This makes it
possible to produce a backtrace, inspect and modify global variables,
and even continue execution when a program tries to kill itself.  If the
PadWalker module is available, Sepia also provides functions to inspect
and modify lexical variables.

   <p>The debugger has its own set of shortcuts, also prefixed by a comma.

     <dl>
<dt><kbd>backtrace</kbd><dd>Show a backtrace.

     <br><dt><kbd>break </kbd><var>file</var><kbd>:</kbd><var>line</var><kbd> [</kbd><var>expr</var><kbd>]</kbd><dd>Set a breakpoint in <var>file</var> at <var>line</var>.  If <var>expr</var> is
supplied, stop only if it evaluates to true.

     <br><dt><kbd>down </kbd><var>n</var><dt><kbd>up </kbd><var>n</var><dd>Move the current stack frame up or down by <var>n</var> (or one) frames.

     <br><dt><kbd>inspect [</kbd><var>n</var><kbd>]</kbd><dd>Inspect lexicals in the current frame or frame <var>n</var>, counting upward
from 1.

     <br><dt><kbd>lsbreak</kbd><dd>List breakpoints.

     <br><dt><kbd>next [</kbd><var>n</var><kbd>]</kbd><dd>Advance <var>n</var> (or one) lines, skipping subroutine calls.

     <br><dt><kbd>quit</kbd><dt><kbd>die</kbd><dt><kbd>warn</kbd><dd>Continue as the program would have executed without debugger
intervention, dying if the debugger was called from <code>die()</code>.

     <br><dt><kbd>return </kbd><var>expr</var><dd>Continue execution as if <code>die()</code> had returned the value of
<var>expr</var>, which is evaluated in the global environment.

     <br><dt><kbd>step [</kbd><var>n</var><kbd>]</kbd><dd>Step forward <var>n</var> (or one) lines, descending into subroutines.

   </dl>

<div class="node">
<p><hr>
<a name="Evaluation"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Mutilation">Mutilation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Debugger">Debugger</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Interactive-Perl">Interactive Perl</a>

</div>

<h3 class="section">3.3 Evaluation</h3>

<p>When interactive Perl is running, Sepia can evaluate regions of code in
the inferior Perl process.  The following commands assume that this
process has already been started by calling <code>sepia-repl</code>.

     <dl>
<dt><kbd>C-M-x</kbd><dt><kbd>M-x sepia-eval-defun</kbd><dd><a name="index-sepia_002deval_002ddefun-22"></a>Evaluate the function around point in the inferior Perl process.  If it
contains errors, jump to the location of the first.

     <br><dt><kbd>C-c C-l</kbd><dt><kbd>M-x sepia-load-file</kbd><dd><a name="index-sepia_002dload_002dfile-23"></a>Save the current buffer, then reload its file and if warnings or errors
occur, display an error buffer.  With a prefix argument, also rebuild
the cross-reference index.

     <br><dt><kbd>C-c e</kbd><dt><kbd>M-x sepia-eval-expression &lt;RET&gt; </kbd><var>expr</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002deval_002dexpression-24"></a>Evaluate <var>expr</var> in scalar context and echo the result.  With a
prefix argument, evaluate in list context.

     <br><dt><kbd>C-c!</kbd><dt><kbd>sepia-set-cwd</kbd><dd>Set the REPL's working directory to the current buffer's directory.

   </dl>

<div class="node">
<p><hr>
<a name="Mutilation"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Scratchpad">Scratchpad</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Evaluation">Evaluation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Interactive-Perl">Interactive Perl</a>

</div>

<h3 class="section">3.4 Mutilation</h3>

<p>Sepia contains several functions to operate on regions of text using the
interactive Perl process.  These functions can be used like standard
one-liners (e.g. `<samp><span class="samp">perl -pe ...</span></samp>'), with the advantage that all of
the functions and variables in the interactive session are available.

     <dl>
<dt><kbd>M-x sepia-perl-pe-region &lt;RET&gt; </kbd><var>code</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dperl_002dpe_002dregion-25"></a>Evaluate <var>code</var> on each line in the region with <code>$_</code> bound to
the line text, collecting the resulting values of <code>$_</code>.  With a
prefix argument, replace the region with the result.

     <br><dt><kbd>M-x sepia-perl-ne-region &lt;RET&gt; </kbd><var>code</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dperl_002dne_002dregion-26"></a>Evaluate <var>code</var> as above, but collect the results instead.

     <br><dt><kbd>M-x sepia-perlize-region &lt;RET&gt; </kbd><var>code</var><kbd> &lt;RET&gt;</kbd><dd><a name="index-sepia_002dperlize_002dregion-27"></a>Evaluate <var>code</var> once with <code>$_</code> bound to the entire region,
collecting the final value of <code>$_</code>.  With a prefix argument,
replace the region.

   </dl>

<div class="node">
<p><hr>
<a name="Scratchpad"></a>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Mutilation">Mutilation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Interactive-Perl">Interactive Perl</a>

</div>

<h3 class="section">3.5 Scratchpad</h3>

<p><a name="index-sepia_002dscratch-28"></a>Sepia also supports a scratchpad, another form of interaction inspired
by Emacs' <code>*scratch*</code> buffer.  To create or switch to the
scratchpad, type <kbd>M-x sepia-scratch</kbd>.  Scratchpad mode is exactly
like Sepia mode, except &lt;C-j&gt; evaluates the current line and prints
the result on the next line.

<!-- ============================================================ -->
<div class="node">
<p><hr>
<a name="Customization"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Internals">Internals</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Interactive-Perl">Interactive Perl</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">4 Customization</h2>

<p>While Sepia can be customized in both the Perl and Emacs Lisp, most of
the user-accessible configuration is in the latter.

<ul class="menu">
<li><a accesskey="1" href="#Emacs-Variables">Emacs Variables</a>
<li><a accesskey="2" href="#Perl-Variables">Perl Variables</a>
</ul>

<div class="node">
<p><hr>
<a name="Emacs-Variables"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Perl-Variables">Perl Variables</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Customization">Customization</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Customization">Customization</a>

</div>

<h3 class="section">4.1 Emacs Variables</h3>

<p>Since Sepia tries where possible to reuse existing Emacs functionality,
its behavior should already be covered by existing customizations.  The
two variables most likely to need customization are
<kbd>sepia-program-name</kbd> and <kbd>sepia-perl5lib</kbd>.  General Sepia mode
configuration can be done with <kbd>sepia-mode-hook</kbd>, while
REPL-specific configuration can be done with <kbd>sepia-repl-mode-hook</kbd>.

     <dl>
<dt><kbd>sepia-complete-methods</kbd><dd>If non-<code>nil</code>, <code>sepia-complete-symbol</code> will complete
simple method calls of the form <code>$x-&gt;</code> or <code>Module-&gt;</code>.  Since
the former requires evaluation of <code>$x</code>, this can be disabled. 
Default: <code>T</code>.

     <br><dt><kbd>sepia-eval-defun-include-decls</kbd><dd>If non-<code>nil</code>, attempt to generate a declaration list for
<code>sepia-eval-defun</code>.  This is necessary when evaluating some code,
such as that calling functions without parentheses, because the presence
of declarations affects the parsing of barewords.  Default: <code>T</code>.

     <br><dt><kbd>sepia-indent-expand-abbrev</kbd><dd>If non-<code>nil</code>, <code>sepia-indent-or-complete</code> will, if
reindentation does not change the current line, expand an abbreviation
before point rather than performing completion.  Only if no abbreviation
is found will it perform completion.  Default: <code>T</code>.

     <br><dt><kbd>sepia-module-list-function</kbd><dd>The function to view a tree of installed modules.  Default:
<code>w3m-find-file</code> if Emacs-w3m is installed, or
<code>browse-url-of-buffer</code> otherwise.

     <br><dt><kbd>sepia-perldoc-function</kbd><dd>The function called to view installed modules' documentation.  Default:
<code>w3m-perldoc</code> if Emacs-w3m is installed, or <code>cperl-perldoc</code>
otherwise.

     <br><dt><kbd>sepia-perl5lib</kbd><dd>A list of directories to include in <code>PERL5LIB</code> when starting
interactive Perl.  Default: <code>nil</code>.

     <br><dt><kbd>sepia-prefix-key</kbd><dd>The prefix to use for for functions in <code>sepia-keymap</code>.  Default:
&lt;M-.&gt;.

     <br><dt><kbd>sepia-program-name</kbd><dd>The Perl program name for interactive Perl.  Default: &ldquo;perl&rdquo;.

     <br><dt><kbd>sepia-use-completion</kbd><dd>If non-<code>nil</code>, various Sepia functions will generate completion
candidates from interactive Perl when called interactively.  This may be
slow or undesirable in some situations.  Default: <code>T</code>.

     <br><dt><kbd>sepia-view-pod-function</kbd><dd>The function called to view the current buffer's documentation. 
Default: <code>sepia-w3m-view-pod</code> if Emacs-w3m is available, or
<code>sepia-perldoc-buffer</code> otherwise.

   </dl>

<div class="node">
<p><hr>
<a name="Perl-Variables"></a>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Emacs-Variables">Emacs Variables</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Customization">Customization</a>

</div>

<h3 class="section">4.2 Perl Variables</h3>

<p>When Sepia starts up, it evaluates the Perl script in <samp><span class="file">~/.sepiarc</span></samp>. 
The following variables in the Sepia package control various aspects of
interactive evaluation.

     <dl>
<dt><code>$PACKAGE</code><dd>The package in which user input is evaluated, determined automatically
when code is evaluated from a buffer.  Default: <code>main</code>.

     <br><dt><code>$PRINTER</code><dd>The function called to format interactive output, normally set with the
<code>printer</code> shortcut.

     <br><dt><code>$PRINT_PRETTY</code><dd>If true, format some values nicely independent of the value of
<code>$PRINTER</code>.  Currently, this means columnating lists of simple
scalars.  Default: true.

     <br><dt><code>$PS1</code><dd>The trailing end of the prompt string, which should end with &ldquo;&gt; &rdquo;. 
Default: <code>"&gt; "</code>.

     <br><dt><code>$STOPDIE</code><dd>If true, calls to <code>die</code> from interactive code will invoke the Sepia
debugger.  Default: true.

     <br><dt><code>$STOPWARN</code><dd>If true, calls to <code>warn</code> from interactive code will invoke the
Sepia debugger.  Default: false.

     <br><dt><code>$WANTARRAY</code><dd>If true, evaluate interactive expressions in list context.  Default: true.

   </dl>

   <p>Additional REPL shortcuts can be defined with
<kbd>Sepia::define_shortcut</kbd>.  For example

<pre class="example">     Sepia::define_shortcut time =&gt; sub { print scalar localtime, "\n"; 0 },
         'Display the current time.';
</pre>
   <p>defines a shortcut &ldquo;time&rdquo; that displays the current time.  For
details, see the code in <samp><span class="file">Sepia.pm</span></samp>.

<!-- ============================================================ -->
<div class="node">
<p><hr>
<a name="Internals"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Credits">Credits</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Customization">Customization</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="chapter">5 Internals</h2>

<p>Many things remain unexplained except by the code itself, and some
details mentioned above should probably be given less prominence.  For
developer documentation, please see the POD for <code>Sepia</code> and
<code>Sepia::Xref</code>, and the doc-strings in <samp><span class="file">sepia.el</span></samp>.

<div class="node">
<p><hr>
<a name="Credits"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="#Function-Index">Function Index</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Internals">Internals</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Credits</h2>

     <dl>
<dt>Hilko Bengen<dd>Found and motivated me to fix a bunch of bugs, created Debian packages.

     <br><dt>Ye Wenbin<dd>Found and fixed numerous bugs.

     <br><dt>Free Software<dd>Portions of the code were lifted from Emacs-w3m, SLIME, ido, and
B::Xref, all of which are Free software.

</dl>

<!-- ============================================================ -->
<div class="node">
<p><hr>
<a name="Function-Index"></a>
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Credits">Credits</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>

</div>

<h2 class="unnumbered">Function Index</h2>

<ul class="index-fn" compact>
<li><a href="#index-sepia_002dapropos-9"><code>sepia-apropos</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dcallees-11"><code>sepia-callees</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dcallers-10"><code>sepia-callers</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dcomplete_002dsymbol-2"><code>sepia-complete-symbol</code></a>: <a href="#Completion">Completion</a></li>
<li><a href="#index-sepia_002ddefs-7"><code>sepia-defs</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002ddwim-4"><code>sepia-dwim</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002deval_002ddefun-22"><code>sepia-eval-defun</code></a>: <a href="#Evaluation">Evaluation</a></li>
<li><a href="#index-sepia_002deval_002dexpression-24"><code>sepia-eval-expression</code></a>: <a href="#Evaluation">Evaluation</a></li>
<li><a href="#index-sepia_002dindent_002dor_002dcomplete-3"><code>sepia-indent-or-complete</code></a>: <a href="#Completion">Completion</a></li>
<li><a href="#index-sepia_002dinstall_002deldoc-20"><code>sepia-install-eldoc</code></a>: <a href="#Documentation">Documentation</a></li>
<li><a href="#index-sepia_002djump_002dto_002dsymbol-6"><code>sepia-jump-to-symbol</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dload_002dfile-23"><code>sepia-load-file</code></a>: <a href="#Evaluation">Evaluation</a></li>
<li><a href="#index-sepia_002dlocation-5"><code>sepia-location</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dmode-1"><code>sepia-mode</code></a>: <a href="#Editing">Editing</a></li>
<li><a href="#index-sepia_002dmodule_002dfind-8"><code>sepia-module-find</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dmodule_002dlist-19"><code>sepia-module-list</code></a>: <a href="#Documentation">Documentation</a></li>
<li><a href="#index-sepia_002dnext-14"><code>sepia-next</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dpackage_002dlist-18"><code>sepia-package-list</code></a>: <a href="#Documentation">Documentation</a></li>
<li><a href="#index-sepia_002dperl_002dne_002dregion-26"><code>sepia-perl-ne-region</code></a>: <a href="#Mutilation">Mutilation</a></li>
<li><a href="#index-sepia_002dperl_002dpe_002dregion-25"><code>sepia-perl-pe-region</code></a>: <a href="#Mutilation">Mutilation</a></li>
<li><a href="#index-sepia_002dperldoc_002dthis-16"><code>sepia-perldoc-this</code></a>: <a href="#Documentation">Documentation</a></li>
<li><a href="#index-sepia_002dperlize_002dregion-27"><code>sepia-perlize-region</code></a>: <a href="#Mutilation">Mutilation</a></li>
<li><a href="#index-sepia_002drebuild-15"><code>sepia-rebuild</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002drepl-21"><code>sepia-repl</code></a>: <a href="#Interactive-Perl">Interactive Perl</a></li>
<li><a href="#index-sepia_002dscratch-28"><code>sepia-scratch</code></a>: <a href="#Scratchpad">Scratchpad</a></li>
<li><a href="#index-sepia_002dvar_002ddefs-13"><code>sepia-var-defs</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dvar_002duses-12"><code>sepia-var-uses</code></a>: <a href="#Navigation">Navigation</a></li>
<li><a href="#index-sepia_002dview_002dpod-17"><code>sepia-view-pod</code></a>: <a href="#Documentation">Documentation</a></li>
</ul></body></html>