<p><ahref="http://factor.sourceforge.net">Factor</a> is a programming language with postfix syntax. The Factor plugin for <ahref="http://www.jedit.org">jEdit</a> provides many nifty time-saving features for working with Factor code.<p>
<h2class="fancy-heading">Introduction</h2>
If Factor is compiled with the jEdit classes in the class path, the resulting <code>Factor.jar</code> can then be placed in <code>$HOME/.jedit/jars/</code> and loaded by jEdit.<p>
Note that while the Factor plugin requires jEdit 4.2pre15, you will need to download and install the Factor edit mode separately from the <ahref="http://factor.sf.net">Factor home page</a>. If you are running jEdit 4.2final, this edit mode is already included.
<p>The plugin embeds a Factor interpreter inside jEdit that gets lazily loaded when first used. The interpreter communicates with the plugin and vice versa to perform various useful tasks.</p>
<p>The <b>Run current file</b> and <b>Evaluate selection</b> commands can be used to send text from jEdit to the interpreter.<p>
<imgclass="nice-box"src="listener.png">
<p>If you have CFactor installed, it is possible to embed it in jEdit using the <code>inferior.factor</code> socket protocol. Add the following to your <code>$HOME/.factor-rc</code>:
<p>Now, start CFactor and type the following phrase:</p>
<preclass="nice-box">inf</pre>
<p>Then open the Factor listener window in jEdit, and type the following phrase:</p>
<preclass="nice-box">cfactor</pre>
<p>You will now be talking to the CFactor interpreter prompt. Styled text output and hyperlinks will be transmitted using the <code>inferior.factor</code> socket protocol.</p>
<h2class="fancy-heading">Cross-referencing</h2>
<p>The <b>Edit word at caret</b> command opens the source file containing the definition of the word at the caret. <b>See word at caret</b> shows the definition of the word at the caret in the Factor listener window.</p>
<p>The <b>Edit word</b> command opens a dialog box where the name of a word can be typed -- while the word is being typed, the possible completions is instantly updated, and selecting one opens the source file containing the definition of that word:</p>
<imgclass="nice-box"src="edit-word.png">
<p>To be able to edit definitions of standard library words, add a phrase like the following to your <code>$HOME/.factor-rc</code>:</p>
<preclass="nice-box"><SPANCLASS="syntax13">"</SPAN><SPANCLASS="syntax13">/home/slava/Factor/</SPAN><SPANCLASS="syntax13">"</SPAN><SPANCLASS="syntax13">"</SPAN><SPANCLASS="syntax13">resource-path</SPAN><SPANCLASS="syntax13">"</SPAN> set
</PRE>
<p>The <b>Word usages at caret</b> command displays a list of words that refer to the word at the caret in the Factor listener window. Clicking on words in the listener shows a popup menu with various useful actions.</p>
<imgclass="nice-box"src="usages.png">
<p>Here we see the result of selecting <b>Describe</b>.</p>
<imgclass="nice-box"src="describe.png">
<h2class="fancy-heading">Error checking</h2>
<p>Factor files are parsed in a background thread and checked for errors, using the framework provided by the SideKick plugin. Errors are underlined in the text area (and listed in the <b>ErrorList</b> plugin window).</p>
<p>A common error is a missing <code>USE:</code> declaration. The <b>Use word at caret</b> command searches for the word at the caret in all vocabularies, and adds a <code>USE:</code> declaration for the vocabulary to the start of the source file -- in this case, <code>ifte</code> is found in the <code>combinators</code> vocabulary, and the parse error instantly goes away:</p>
<h2class="fancy-heading">Completion and browsing</h2>
<p>The stack effect of the word at the caret is shown in the status bar.</p>
<imgclass="nice-box"src="status.png">
<p>Invoking <b>Plugins</b>><b>SideKick</b>><b>Show Completion Popup</b> displays a popup of possible completions for the word at the caret -- bind this to <code>C+SPACE</code> for quick access:</p>
<imgclass="nice-box"src="complete.png">
<p>The <b>Plugins</b>><b>SideKick</b>><b>Structure Browser</b> displays a list of all words defined in the current buffer:</p>