<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[onecolumn,letterpaper,11pt]{article}

%===================================================================
\input{common_latex/common_latex_packages}
\input{common_latex/common_latex_definitions}
\input{common_latex/common_latex_help_format}
%===================================================================

\begin{document}

\begin{labcover}
\labtitle{Help Topic: Getting Emacs in GNU/Linux and MacOS}
\vspace{0.1in}
\labdate{Spring 2020}
\vspace{0.1in}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labline
\end{labcover}

\wikidoc{file=Help.EMCGet}
\wikidoc{auth=mikerb@mit.edu}

%====================================================================
\section*{Getting Emacs in GNU/Linux and OS X}
%====================================================================

Emacs is a very powerful text editor with support for software
development. We will be using it a lot in 2.680 and 2.S01. The first
step in using emacs is getting emacs.  In some cases it is already
installed on your machine. This page describes how to find out for
sure whether you have it installed, and if not, how to get it.

%====================================================================
\subsection*{How to tell if Emacs is already installed}

Your machine may already have a version of emacs installed,
with the full path name of /usr/bin/emacs. Verify this:

\vspace{0.15in}
\begin{consoleverb}
 $ which emacs
 /usr/bin/emacs
\end{consoleverb}
\vspace{0.15in}

\noindent
If you get a response like the one above, you're all set. If emacs is
not installed you will get a response like the one below:

\vspace{0.15in}
\begin{consoleverb}
 $ which emacs
 emacs: Command not found
\end{consoleverb}
\vspace{0.15in}

\noindent
If you don't see the love yet, it is most likely because you really don't
have emacs installed. However it is also possible that you simply don't have
\var{/usr/bin/} in your shell path. To rule this out, try the following:

\vspace{0.15in}
\begin{consoleverb}
 $ cd /usr/bin
 $ which ./emacs
 ./emacs
\end{consoleverb}
\vspace{0.15in}

\noindent 
If you see the above, it is simply a matter of adding \var{/usr/bin/} to 
your shell path. Do this now, or see the help topic on augmenting your shell path.

%====================================================================
\subsection*{Getting Emacs in Linux}

If you are running linux you very likely have access to a package manager
such as apt-get and already know how to use it to some degree. To get emacs, 
you will need root priveleges. Do the following, and enter your normal
login password when or if prompted:

\vspace{0.15in}
\begin{consoleverb}
 $ sudo apt-get install emacs
\end{consoleverb}
\vspace{0.15in}

\noindent
See the discussion above on how to confirm whether emacs has been 
successfully installed, and adjust your shell path if need be.

%====================================================================
\subsection*{Getting Emacs on the Mac - Flavor One}

If you are using a Mac there are two versions emacs worth installing.
The fist one is all you really need, and may be obtained by going to
\urlx{http://emacsformacosx.com} and follow the instructions for installing. 
You will need admin/root privileges for this. This will install the emacs
binary in:

\vspace{0.15in}
\begin{consoleverb}
  /Applications/Emacs.app/Contents/MacOS/
\end{consoleverb}
\vspace{0.15in}

\noindent 
You will need to add this directory to your shell path. If you don't know
how to do this, see the help topic on augmenting your shell path:

\urlxx{http://oceanai.mit.edu/ivpman/help/cmdline_augment_shell_path}

\noindent
Once this is done you can begin using emacs to create or edit a file by
typing the following on the command line:

\vspace{0.15in}
\begin{consoleverb}
 $ Emacs newfile
\end{consoleverb}
\vspace{0.15in}

\noindent
This will open a new window. You can quit by typing \var{control-x}
followed by \var{control-q}. Or if you want to save your edits,
type \var{control-x}, \var{control-s} before quitting.

\pskip

You may notice that, for saving and quitting, there are nice little
icons on the top of the window for saving a file, and you can
select \var{Quit Emacs} from the Emacs Apple pull-down menu.  {\em
Resist the temptation to use these!!!!} One of the goals in
introducing you to emacs is to help you become efficient. Use the
keyboard method for doing your business in emacs. If you have to touch
your mouse, you're probably doing things wrong/inefficiently. These
inefficiencies really add up over time. Furthermore, when you inevitably 
need to remotely log into a robot and use emacs to edit a remote file, 
you won't be able to use the GUI ways of navigating emacs. The keyboard
will be all you have. 

%====================================================================
\subsection*{Getting Emacs on the Mac - Flavor Two}

There is a second version of emacs I also typically install on my OS X
machines. It may be redundant, but I always do it anyway, since it's
easy, and I'm just comfortable having an emacs binary reside at the
conventional location of \var{/usr/bin/emacs}. This can be installed
with the MacPorts package manager.

\vspace{0.15in}
\begin{consoleverb}
 $ sudo port install emacs
\end{consoleverb}
\vspace{0.15in}

\noindent
Or, if you are using the \cmd{brew} package manager on the Mac, can be
installed with:

\vspace{0.15in}
\begin{consoleverb}
 $ brew install emacs
\end{consoleverb}
\vspace{0.15in}

\noindent
This version will have the binary name "emacs" with a lower-case
"e". So you will see the following on the command line:

\vspace{0.15in}
\begin{consoleverb}
 $ which emacs
 /usr/bin/emacs
 $ which Emacs
 /Applications/Emacs.app/Contents/MacOS/Emacs
\end{consoleverb}
\vspace{0.15in}

\noindent
When you invoke this emacs, it will launch {\em within} the terminal
in which it was invoked. A new window will not open. This is super
convenient for a quick edit of a file. The same behavior can be
achieved with the graphical emacs by invoking with the "-nw" command
line option for "no window".


\end{document}

</pre></body></html>