Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 5293

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>using Macaulay2 with emacs after it has been set up</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_editing_sp__Macaulay2_spcode_spwith_spemacs.html">next</a> | <a href="_running_sp__Macaulay2_spin_spemacs.html">previous</a> | <a href="_editing_sp__Macaulay2_spcode_spwith_spemacs.html">forward</a> | <a href="_running_sp__Macaulay2_spin_spemacs.html">backward</a> | <a href="_using_sp__Macaulay2_spwith_spemacs.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="_getting_spstarted.html" title="">getting started</a> > <a href="_using_sp__Macaulay2_spwith_spemacs.html" title="">using Macaulay2 with emacs</a> > <a href="_using_sp__Macaulay2_spwith_spemacs_spafter_spit_sphas_spbeen_spset_spup.html" title="">using Macaulay2 with emacs after it has been set up</a></div>
<hr/>
<div><h1>using Macaulay2 with emacs after it has been set up</h1>
<div><p>In this section, we show by example how to use the Macaulay2 emacs interface.  We assume that you have already set up this interface, as described in <a href="_setting_spup_spthe_sp__Macaulay2_spemacs_spinterface.html" title="">setting up the Macaulay2 emacs interface</a>.  After creating or changing the .emacs file mentioned there, you need to exit and restart emacs.  For the rest of this section, we assume that you are running emacs.</p>
The aspects of this interface that we describe include<ul><li>Starting Macaulay2 with the f12 key, or with M-x M2</li>
<li>Working with two buffers</li>
<li>Sending lines or selected text to Macaulay2 using the f11 key</li>
<li>Command completion with TAB</li>
<li>Horizontal scrolling with f3,f4,f5,f6,f7</li>
</ul>
<p>Before starting, note that when we say to type M-x M2, what we really mean is: press the x key while holding down the meta key (on Macs this is either the option key or the apple key, depending on how your emacs is set up); type M2; and then press the return (or enter) key after that.  Similarly, C-c means to press the c key while holding down the control key, and <tt>C-x 2</tt> means to press x while holding down the control key, then to press 2; this time do not press enter.</p>
<p>Use the keystrokes <tt>C-x 2</tt> to divide the buffer containing this file into two windows.  Then press the <tt>f12</tt> key or type <tt>M-x M2</tt> to start up Macaulay2 in a buffer named <tt>*M2*</tt>.  (The command line used to start Macaulay2 may be edited before being run if you use a prefix argument with the above command: press <tt>C-u</tt> just before.)</p>
<p>If f12 doesn't start up Macaulay2, one reason may be that your function keys are not operable.  In that case press <tt>C-c m</tt> instead.  Another reason may be that you have not installed Macaulay2 properly - the startup script (<tt>M2</tt> or <tt>M2.bat</tt>) should be on your path.  A third reason may be that you are in Windows-98 and are using anti-virus software such as <tt>Dr. Solomon's</tt>, which can interfere with emacs when it tries to run a subprocess.</p>
<p>You may use <tt>C-x o</tt> freely to switch from one window to the other.  Verify that Macaulay2 is running by entering a command such as <tt>2+2</tt>.  Now create (using C-x C-f) a file, named something like foo.m2 (the final .m2 is important, as it informs emacs to use the Macaulay2 mode).  Paste the following text into a buffer.  If you wish, save the file using C-x C-s.</p>
<pre>    R = QQ[x,y,z]
    f = symmetricPower(2,vars R)
    M = cokernel f
    C = resolution M
    betti C</pre>
<p>Position the cursor on the first line of code, and press the <tt>f11</tt> function key repeatedly to present each line to Macaulay2.  If you select several lines using the mouse, then pressing f11 will present the entire selection to Macaulay2.  Try this on some of these lines.</p>
<hr/>
Now go to the very end of the <tt>*M2*</tt> buffer with <tt>M-></tt> and experiment with keyword completion.  Type <tt>reso</tt> and then press the <tt>TAB</tt> key.  Notice how the word is completed to <tt>resolution</tt> for you.  Delete the word with <tt>M-DEL</tt>, type <tt>res</tt> and then press the <tt>TAB</tt> key.  The possible completions are displayed in a window.  Switch to it with the <tt>F8</tt> key, move to the desired completion, select it with the <tt>RETURN</tt> key, and then return to the <tt>*M2*</tt> buffer with <tt>C-x o</tt>.  Alternatively, if you have a mouse, use the middle button to select the desired completion. (On the mac, hold down the option key while clicking the mouse)<hr/>
<p/>
Experiment with command line history in the <tt>*M2*</tt> buffer.  Position your cursor at the end of the buffer, and then use <tt>M-p</tt> and <tt>M-n</tt> to move to the previous and next line of input remembered in the history.  When you get to one you'd like to run again, simply press return to do so.  Or edit it slightly to change it before pressing return.<hr/>
<p/>
Now let's see how we can handle wide and tall Macaulay2 output.  Execute the following line of code (put it in your foo.m2 buffer, and then press f11)<p/>
<pre>printWidth=0; random(R^20,R^{6:-2})</pre>
Setting printWidth to zero removes line wrapping in the buffer, sometimes useful to view large matrices.<p/>
Notice that the long lines in the Macaulay2 window, instead of being wrapped around to the next line, simply disappear off the right side of the screen, as indicated by the dollar signs or little arrows in the rightmost column.  Switch to the other window and practice scrolling up and down with <tt>M-v</tt> and <tt>C-v</tt>, and scrolling left and right with the function key <tt>F3</tt> (or <tt>C-c &lt;</tt>) and the function key <tt>LinearAlgebra</tt> (or <tt>C-c ></tt>).  In modern emacs implementations where mouse clicking works, click on the arrow to scroll in that direction.  In these versions of emacs, typing C-e, or C-a to get at the end or beginning of the line also horizontally scrolls the text to that position.  Older emacs tend to need a bit more: Notice how the use of <tt>C-e</tt> to go to the end of the line sends the cursor to the dollar sign at the right hand side of the screen; that's where the cursor will appear whenever you go to a position off the screen to the right.  Then use the <tt>f2</tt> function key (or <tt>C-c .</tt>) to scroll the text so the cursor appears at the center of the screen.  Use <tt>C-a</tt> to move to the beginning of the line and then the <tt>f2</tt> function key (or <tt>C-c .</tt>) to bring the left margin back into view.<p/>
You may use the <tt>f5</tt> function key or (or <tt>C-c ?</tt>) to toggle whether long lines are truncated or wrapped; initially they are truncated.</div>
</div>
</body>
</html>