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 setting up the Macaulay2 emacs interface. 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.
The aspects of this interface that we describe includeBefore 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 C-x 2 means to press x while holding down the control key, then to press 2; this time do not press enter.
Use the keystrokes C-x 2 to divide the buffer containing this file into two windows. Then press the f12 key or type M-x M2 to start up Macaulay2 in a buffer named *M2*. (The command line used to start Macaulay2 may be edited before being run if you use a prefix argument with the above command: press C-u just before.)
If f12 doesn't start up Macaulay2, one reason may be that your function keys are not operable. In that case press C-c m instead. Another reason may be that you have not installed Macaulay2 properly - the startup script (M2 or M2.bat) should be on your path.
You may use C-x o freely to switch from one window to the other. Verify that Macaulay2 is running by entering a command such as 2+2. 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.
R = QQ[x,y,z]
f = symmetricPower(2,vars R)
M = cokernel f
C = resolution M
betti C
Position the cursor on the first line of code, and press the f11 function key (or C-<return>) 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.
Here are some other useful keybindings:
printWidth=0; random(R^20,R^{6:-2})
Setting printWidth to zero removes line wrapping in the buffer, sometimes useful to view large matrices.
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 M-v and C-v, and scrolling left and right with the function key F3 (or C-x <) and the function key F4 (or C-x >). 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 C-e 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 f2 function key (or C-S-c .) to scroll the text so the cursor appears at the center of the screen. Use C-a to move to the beginning of the line and then the f2 function key (or C-S-c .) to bring the left margin back into view.
You may use C-S-c SPC to toggle whether long lines are truncated or wrapped; initially they are truncated.