Quick Start to Learning Emacs
- Do you want to start the Dark Arts of Computer Programming by learning Emacs?
- Do you already know Emacs, but want to level up in customizations?
- Do you trust me as a virtual mentor and don’t want to think about the decisions I mentioned over here?
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:
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.
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.
- 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 thehelm
package without a dash or extra words. - Click on the name, and in the window that appears, click the Install button.
- Turn on the
helm
package:- Edit the file,
~/.emacs.d/init.el
Append the following:
(require 'helm-config) (helm-mode 1)
- Edit the file,
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.