@Part(Compile, root "more.mss") @Chapter(Scribing and Compiling) People often use Emacs inefficiently when writing a program or Scribe manuscript. They edit the file, exit Emacs, compile the file, reenter Emacs, search for errors, fix them, then start the whole cycle over again. Nevermore! There are many facilities to speed up the whole process of compilation and debugging for both programming languages and the Scribe text formatter. @Section(Compiling) @Label(Compile) Emacs has a command which allows you to compile files without ever leaving Emacs. It is called, simply enough, @b[compile]. The command @b[scribe] does the same thing, except it only works with Scribe files. When executed, it first saves all the files. Next it asks you what command you want to execute. The default command is @b[make -k] for programs and @b[scribe] for document files. The @b[make] command uses a file called a @i{Makefile} to help compile multi-file programs, and is described in the @b[man] page of the same name. If you don't have (or don't wish to use) a makefile, you can specify any command you like: @b[cc], @b[f77], @b[lint], etc. Say you were editing the file @i{report.mss}. You want to Scribe a preliminary draft of it to see what it looks like. Since you will want to edit it again, you decide to use @b[compile] to do the entire process from within Emacs. Also, you don't want to hunt through the file manually to look for any errors that may occur. The first thing you type is: @Begin(Example) M-x compile @End(Example) This starts off the compilation process. Now the minibuffer shows: @Begin(Example) Compile command: scribe /mit/joeuser/report.mss @End(Example) If that is indeed what you want, you can type @b[RET] to accept that command. Otherwise, you can write over it using standard Emacs commands. If you have modified the file @i{report.mss}, it will ask you if you want to save that file. Just type "y" for yes. Emacs now splits the screen, creating a second window, and runs the specified command in the buffer @i{*compile*}. You can continue working in the first window, if you like. If you need to abort the compilation, use the command @b[kill-compilation]: @begin[example] M-x kill-compilation @end[example] Also, if you start up a new compilation, it will offer to kill off the old one. Otherwise, be sure to stay in two-window mode so you can use the error-finding routines. @Section(Finding Compilation Errors) @Label(FindError) Unless you are lucky, you now have a buffer full of errors. Each error has a file name and line number associated with it. For program compilers (not Scribe), Emacs can use this information to move directly to those errors. The command to do that is: @Begin(Description) C-x ` @\@b{[next-error]} Moves to the next error listed in @i{*compile*}. A numeric argument starts over from the first error. @End(Description) To start, just type @b[C-x `]. Notice that @b[`] is the backquote, or grave accent, not the apostrophe. This will move you to the first error listed in @i{*compile*}. Emacs will move backwards and forwards, and even load in new files if necessary. Once there, you can move around, insert and delete, and do whatever is necessary to fix the error. When you are ready, just type @b[C-x `] again to move on. The second window scrolls to follow which error you are on. You can stop at any time. To get rid of the second window, just type @b[C-x 1] or click @b[C-SHIFT-RIGHT], as described in Chapter @Ref(Window). For more information about compiling and debugging files within Emacs, consult Chapter 22 of the @p[GNU Emacs Manual].