<?xml version="1.0" encoding="ISO-8859-1"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:axle="http://www.cs.odu.edu/~zeil/axle" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns0="http://www.cs.odu.edu/~zeil/axle" mode="ignore" id="emacscompile" ns0:xlinkuri="open/emacscompile.dbk" ns0:xpath="//*[@id='emacscompile']" ns0:page="emacscompile" foo="0 " ns0:last="/cocoon/~cs252/open/emacscompile/vimcompile.html"><head><title>Compiling in emacs</title><link type="text/css" href="_axle/docbookstyle.css" rel="stylesheet"/><link type="text/css" href="_axle/cppformat.css" rel="stylesheet"/><link type="text/css" href="_axle/overrides.css" rel="stylesheet"/><script src="_axle/docbook.js"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/emacscompile/vimcompile.html" title="Next" rel="next"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/emacscompile/vimcompile.html" title="Last" rel="last"/><script>function gotoNext() {top.location.href="/cocoon/~cs252/open/emacscompile/vimcompile.html";}
function gotoPrev() {}
function gotoUp() {}
</script><xhtml:link xmlns:xhtml="http://www.w3.org/1999/xhtml" rel="stylesheet" href="_axle/navigation.css" type="text/css"/><xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml" src="_axle/navigation.js"/></head><body><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Next" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/emacscompile/vimcompile.html"><img class="navigationBar" src="_axle/next.gif" alt="Next"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Last" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/emacscompile/vimcompile.html"><img class="navigationBar" src="_axle/last.gif" alt="Last"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/emacscompile/emacscompile.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table><br/><div class="info_article"><div class="title_article">Compiling in emacs</div><div class="author_article"><span class="firstname">Steven</span> <span class="othername" role="mi">J</span> <span class="surname">Zeil</span></div><div class="affiliation">
        <span class="orgname">Old Dominion University</span>
        <span class="orgdiv">Dept. of Computer Science</span>
      </div><table width="100%"><tr><td align="left"><span class="copyright">©<span class="year">2000-2006</span> <span class="holder">Steven J. Zeil, Old Dominion University</span></span></td><td/><td align="right"><span class="date">May. 26, 2006</span></td></tr></table></div><div class="TOC">Contents:<div class="TOC-section0"><a href="#section-1">1 Compiling with emacs</a></div><div class="TOC-section0"><a href="vimcompile.html#vimcompile">2 Compiling with vim</a></div></div>
  
  <div class="epigraph">
    <p class="para" align="center">
              (A printable version of this document is available 
              <a url="allPages.html" href="allPages.html">here</a>.)
            </p>
  </div>
  <p class="para">When your programs contain mistakes, compiling them in the shell can
result in large numbers of error messages scrolling by faster than you
can read them. For this reason, I find it best to compile from within
the <span class="code">emacs</span> editor.</p>


  <div class="sect1" axle:nopage="1" id="section-1"><div class="info_sect1"><div class="title_sect2">1. Compiling with emacs</div></div>
    

  <p class="para">Get into <span class="code">emacs</span> and call up one of the <span class="quote">
      &#8220;hello&#8221;
    </span> programs.
Change it so that it contains one or more syntax errors, and save this
file. Now give the <span class="code">emacs</span> command: <span class="code">M-x
compile</span>.
At the bottom of the screen, you will be asked for the compile
command. If the suggested command is not what you want (it won't be,
until you learn to use <span class="code">make</span> to manage your program compilations), 
then type in the proper command just as
if you were typing it into the shell. <span class="code">emacs</span> will invoke the
compiler, showing its output in a window. <a href="#emacserr">Figure 1: <span class="title_xref">Compiling a program in emacs, with syntax errors</span></a> shows
a typical emacs session after such a compilation.
<div class="figure" id="emacserr"><p class="para" align="center"><span class="inlinemediaobject"><img src="emacserr.jpg" fileref="emacserr.jpg"/></span></p><div class="info_figure"><div class="title_figure">Figure 1: Compiling a program in emacs, with syntax errors</div></div></div></p>
  <p class="para" id="emacs-next-error">In this case, there should be one or more error
messages. The <span class="code">emacs</span> <span class="emphasis-italic" role="italic">next-error</span> command 
(<span class="code">C-x `</span>) will move you to the source code location of the first
error. Each subsequent use of <span class="code">C-x `</span> will move you to the
next error location in turn, until all the reported error messages
have been dealt with.<a onmouseover="DBshowBriefly('fn_fref1_live')" name="fn_fref1" id="fn_fref1" class="footnotemark" href="#fn_fnote1">1</a><div class="footnote_live" id="fn_fref1_live">Note carefully that the second
character in the <span class="code">C-x `</span> command is the
<span class="quote">
      &#8220;backwards&#8221;
    </span> apostrophe, not the regular
one.</div></p>
<div name="fn_fnote1" id="fn_fnote1" class="footnote">1. Note carefully that the second
character in the <span class="code">C-x `</span> command is the
<span class="quote">
      &#8220;backwards&#8221;
    </span> apostrophe, not the regular
one. (<a href="#fn_fref1">back</a>)
    </div></div>


  <script type="text/javascript">
checkForAnchorOnOtherPage('vimcompile','vimcompile');
</script><script type="text/javascript">
checkForAnchorOnOtherPage('vimscreen','vimcompile');
</script>
<br/><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Next" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/emacscompile/vimcompile.html"><img class="navigationBar" src="_axle/next.gif" alt="Next"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Last" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/emacscompile/vimcompile.html"><img class="navigationBar" src="_axle/last.gif" alt="Last"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/emacscompile/emacscompile.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table></body></html>