Help Topic: Getting Started with Spring 2020 Michael Benjamin, [email protected] Department of Mechanical Engineering, CSAIL MIT, Cambridge MA 02139

Getting Started with Emacs

If you are using your own machine, or your own Mac in 2.680, chances are you already are familiar with Emacs or a suitably equivalent . This page is written with the new Mac user in mind who has never used Emacs. It may be useful for others as well.

The pre-installed emacs Most likely your machine already has a version of emacs installed, with the full path name of /usr/bin/emacs. Verify this:

$ which emacs /usr/bin/emacs

If this is not the case, install it. On the Mac:

$ sudo port install emacs

In Linux:

$ sudo apt-get install emacs

The absolute minimal emacs There are many things you can do in emacs. Here we describe how to (1) open a file, (2) save a few changes, and (3) quit. This at least allows us to do a few things in emacs before learning further.

1. Open a file in emacs:

$ /usr/bin/emacs testfile

We use the full emacs pathname in the off chance that /usr/bin/ may not be in your shell path. You can try it without the /usr/bin/. You should be able to just type text, and use the arrow keys, backspace, delete etc., to just compose a sample for yourself.

1 2. Save a file in emacs: To save a file, type the following two commands: Ctrl-x, then Ctrl-s. You should see a line at the very bottom of your emacs window like:

Wrote /Users/myname/testfile

If not, type Ctrl-g in the emacs window (a useful way of resetting any weird state you may have gotten yourself into), and try the save again. 3. Quitting emacs: To quit emacs, type the following two commands: Ctrl-x, then Ctrl-.

Getting a more graphical Emacs

The emacs in /usr/bin/emacs is fine for editing a text file right in the Terminal window, but normally you will want to edit files in a more graphical version of Emacs. We recommend also installing the emacs found at: www.emacsformacosx.com. After installation you will need to add the following to your shell path:

/Applications/Emacs.app/Contents/MacOS

Resources for Learning Emacs • Learning GNU Emacs, Debra Cameron, James Elliot, Marc Loy, Eric Raymond, and Bill Rosenblatt, 3rd Edition, 2005. • MIT E Library • Emacs Cheat Sheet (Bob Rogers), here. • Emacs Cheat Sheet (Hains/Princeton) here. • ”Emacs vs. ”, Editor War

2