<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="robots" content="index,nofollow">



<title>EmacsDefUseMode - MLton Standard ML Compiler (SML Compiler)</title>
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="all" href="common.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="print" href="print.css">


<link rel="Start" href="Home">


</head>

<body lang="en" dir="ltr">

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-833377-1";
urchinTracker();
</script>
<table bgcolor = lightblue cellspacing = 0 style = "border: 0px;" width = 100%>
  <tr>
    <td style = "
		border: 0px;
		color: darkblue; 
		font-size: 150%;
		text-align: left;">
      <a class = mltona href="Home">MLton MLTONWIKIVERSION</a>
    <td style = "
		border: 0px;
		font-size: 150%;
		text-align: center;
		width: 50%;">
      EmacsDefUseMode
    <td style = "
		border: 0px;
		text-align: right;">
      <table cellspacing = 0 style = "border: 0px">
        <tr style = "vertical-align: middle;">
      </table>
  <tr style = "background-color: white;">
    <td colspan = 3
	style = "
		border: 0px;
		font-size:70%;
		text-align: right;">
      <a href = "Home">Home</a>
      &nbsp;<a href = "Index">Index</a>
      &nbsp;
</table>
<div id="content" lang="en" dir="ltr">
MLton provides an <a href="CompileTimeOptions">option</a>, <tt>-show-def-use</tt> <tt>file</tt>, to output precise and accurate whole-program def-use information to a file.  Unlike typical tags facilities, the information includes local variables and distinguishes between different definitions even when they have the same name.  The def-use Emacs mode uses the information to provide navigation support, which can be particularly useful while reading SML programs compiled with MLton (such as the MLton compiler itself). <h3 id="head-fc338f87a058158eb824b53705961801516a9460">Features</h3>

    <ul>

    <li>
<p>
 Highlighting of definitions and uses. 
</p>
</li>
    <li>
<p>
 Navigation: <tt>jump-to-def</tt>, <tt>jump-to-next</tt>, and  <tt>jump-to-prev</tt>. 
</p>
</li>
    <li>
<p>
 Listing, visiting and marking of all references to a definition  (within a program). 
</p>
</li>
    <li>
<p>
 Loads def-use files in the background. 
</p>
</li>
    <li>
<p>
 Automatically reloads updated def-use files. 
</p>
</li>
    <li>
<p>
 Supports both <a class="external" href="http://www.gnu.org/software/emacs/"><img src="moin-www.png" alt="[WWW]" height="11" width="11">Gnu Emacs</a> and  <a class="external" href="http://www.xemacs.org"><img src="moin-www.png" alt="[WWW]" height="11" width="11">XEmacs</a>. 
</p>
</li>

    </ul>


<h3 id="head-a479c9c34e878d07b4d67a73a48f432ad7dc53c8">Download</h3>
<p>
There is no package for the def-use mode at the moment.  To install the mode you need to fetch the Emacs lisp, <tt>*.el</tt>, files from the MLton repository: <a class="external" href="http://mlton.org/cgi-bin/viewsvn.cgi/mlton/trunk/ide/emacs/"><img src="moin-www.png" alt="[WWW]" height="11" width="11">emacs</a>. 
</p>
<h3 id="head-cdd7bb2816b7a8f88bce0e47be39943bc369516b">Setup</h3>
<p>
The easiest way to load def-use mode is to first tell Emacs where to find the files.  For example, add 
</p>

            <ul>

   
<pre class=code>
(add-to-list 'load-path (file-truename <B><FONT COLOR="#BC8F8F">&quot;path-to-the-el-files&quot;</FONT></B>))
</PRE>
<p>
 
</p>

            </ul>


<p>
to your <tt>~/.emacs</tt> or <tt>~/.xemacs/init.el</tt>.  You'll probably also want to start <tt>def-use-mode</tt> automatically by adding 
</p>

            <ul>

   
<pre class=code>
(require 'esml-du-mlton)
(def-use-mode)
</PRE>
<p>
 
</p>

            </ul>


<p>
to your Emacs init file.  Once the def-use mode is activated, you should see the <tt>DU</tt> indicator on the mode line. 
</p>
<h3 id="head-0bb18642b70b9f8a9c12ccf39487328f306b8e19">Usage</h3>
<p>
To use def-use mode one typically first sets up the program's makefile or build script so that the def-use information is saved each time the program is compiled.  In addition to the <tt>-show-def-use</tt> <tt>file</tt> option, the <tt>-prefer-abs-paths</tt> <tt>true</tt> expert option is required.  Note that the time it takes to save the information is small (compared to type-checking), so it is recommended to simply add the options to the MLton invocation that type-checks or compiles the program. 
</p>
<p>
Finally, one needs to tell the mode where to find the def-use information.  This is done with the <tt>esml-du-mlton</tt> command.  The esml-du package can also load recently used def-use files automatically at startup. 
</p>
<p>
After doing all of the above, find an SML file covered by the def-use information, and place the cursor at some variable (definition or use, it doesn't matter). 
</p>
</div>



<p>
<hr>
Last edited on 2007-08-23 04:24:24 by <span title="c-71-57-91-146.hsd1.il.comcast.net"><a href="MatthewFluet">MatthewFluet</a></span>.
</body></html>
