www.howardism.org
Babblings of an aging geek in love with the Absurd, his family, and his own hubris.... oh, and Lisp.

Quick Start to Learning Emacs

Fine. Let’s go, but I’ll divide this conversation into two levels:

Beginning the Journey

Installation

Since you are using a Mac, transitioning to Emacs will be easier with Aquamacs.

However, if you are a VI aficionado, then I suggest starting out with

Create an Initialization Script

Start Aquamacs and use it to edit your initialization script:

  • Hold down the Control key and type x (hereinafter referred to as C-x)
  • Type: C-f (yup, Control and then f)
  • Type: ~/.emacs.d/init.el
  • Hit the Return key

Copy and paste the following code into it:

;; Any cool Emacs Lisp programs I find go in this directory:

(let ((elisp-dir (concat (getenv "HOME") "/.emacs.d/elisp")))
  (add-to-list 'load-path elisp-dir)
  (if (not (file-exists-p elisp-dir))
      (make-directory elisp-dir)))

;; Emacs has an interactive package system. We will want some of the
;; later versions of stuff, because...

(require 'package)

(setq package-archives '(("org"       . "http://orgmode.org/elpa/")
                         ("gnu"       . "http://elpa.gnu.org/packages/")
                         ("melpa"     . "http://melpa.milkbox.net/packages/")
                         ("marmalade" . "http://marmalade-repo.org/packages/")))

(package-initialize)
(package-refresh-contents)

;; To view available packages, type: M-x package-list-packages

Save the file with Command and then s (just like a normal Mac program). Now quit (with Command and q) and restart.

That should be enough to get learning (click on the Emacs Tutorial link on the splash screen with the Gnu icon, or type C-h t). If you want to get a taste for extending Emacs, read on…

Customization

Aquamacs starts with some very nice defaults, however, adding a feature requires two parts:

  1. Installing a Package

    To install a new package, type Option (we call it Meta), and then x (hereinafter written as M-x), and then type: package-list-packages and hit Return.

    A few million packages will show up allowing you to search for things (with Command-F), clicking on interesting packages to learn more, and clicking on the Install button to install it.

  2. Using a Package

    Installing a package often isn’t enough. You may need to flip it on. Much of that is placed, as Emacs Lisp in the file we previously made, ~/.emacs.d/init.el

    Each package should have instructions for what it requires, but often it is just adding something like: (require 'some-package)

Installing Helm

Let’s practice the above by installing the popular Helm package.

  1. Install the helm package:
    • M-x package-list-packages
    • The packages are in alphabetical order, so scroll down to the H section, and you’ll see a lot of helm- entries. You want the helm package without a dash or extra words.
    • Click on the name, and in the window that appears, click the Install button.
  2. Turn on the helm package:
    • Edit the file, ~/.emacs.d/init.el
    • Append the following:

      (require 'helm-config)
      (helm-mode 1)
      

Now, when you type something like M-x, instead of a lonely prompt, you will see a transient section show up with lots of options. In this case, you can still type words, but you can use the right arrow to narrow the options based on what you typed, and the other arrows to help select what you want.

To learn more about Helm, look over here.

Was this opinionated quick start guide helpful? Let me know.