How to learn Emacs Lisp

An overview of how to get started from scratch with Emacs Lisp


Starting out with Emacs

So you've installed Emacs. Now what?

Well, you can start the tutoral by pressing C-h t, and that's not a bad place to start. The tutorial will teach you the basics of editing, searching, and navigating in Emacs.

If you're completely new to Emacs, it can make sense to grab a starter kit, which comes with a set of configurations and packages already set up.

The Emacs Prelude package offers a nice set of sensible defaults and packages.

To install Emacs Prelude run the following in a terminal:

curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh

and make sure to check out the installation guide for further instructions.

If you are familiar with vim you might be interested in the Doom Emacs starter kit, which integrates vim emulation powered by evil-mode.

To install Doom Emacs run the following in a terminal:

git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.emacs.d
~/.emacs.d/bin/doom install

and make sure to check the installation guide for further instructions.

Setting up syntax checking and linting

Setting up syntax checking and linting with Flycheck is recommended.

If you don't already have added the MELPA repository to your Emacs, do this by adding the following to your init file

(require 'package)

(add-to-list 'package-archives
             '("MELPA Stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)

Installation and setup of Flycheck without use-package is done by adding the following to your init file

(package-install 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)

Installation and setup of Flycheck with use-package is done by adding the following to your init file

(use-package flycheck
  :ensure t
  :init (global-flycheck-mode))

For further information and trouble shooting please check the Flycheck documentation.

Learning Emacs Lisp

The best documentation on Emacs Lisp is... shipped with Emacs itself! to access the Emacs Lisp Reference, type C-h i and find the Elisp entry, or select Help → More Manuals → Emacs Lisp Reference. Note that the manual may be missing in some distributions, in which case you can find it online.

If you are brand new to Elisp, you can read the Introduction to Emacs Lisp, which is opened the same way.

Emacs Lisp best practices and conventions

The Emacs Manual contains a section on Emacs Lisp Coding Conventions. There is also a community driven Style Guide maintained on GitHub.