Emacs Lisp Ressources
This page presents links to noticeable Emacs lisp tutorials out there. They are somewhat sorted by difficulty.
- 1 Bastien Guerry's beginners tutorial
- 2 Xah Lee's code snippets
- 3 An introduction to Emacs Lips by cjohansen
- 4 Chrisdone's Elisp guide
- 5 Very complete tutorial with a lot of code snippets, by caiorss
- 6 Learn functionnal programming
- 7 Official tutorials
- 8 Read a good book: Writing GNU Emacs extensions
- 9 Wikemacs
- 10 See also
Bastien Guerry's beginners tutorial
I think you should read Bastien Guerry's Emacs_Lisp_in_15_minutes. It is targeted at newbies. In the end you know how to write functions, move around and search regexps.
Did I say Bastien was the mainainer of org-mode for many years ?
Xah Lee's code snippets
Xah Lee has a number of very useful lisp tutorials that show many practical aspects of the language, with a down-to-earth attitude. They are concise and ready to use.
In elisp-basics he covers the basics of the language: printing, arithmetics, true and false, global and local variables, tests, iterations, blocks of expressions, data structures, the concept of symbol.
But we wouldn't know what to do with the basics of the language without the basics of Emacs functions: how do we build useful functions ? In "common elisp functions" he covers:
- getting the cursor position
- moving the cursor and searching,
- text editing,
- grabbing text,
- preserving point and mark,
- buffers and files basics.
An introduction to Emacs Lips by cjohansen
This tutorial is written by a beginner and may not be beautiful or concise elisp (it received a couple of contributions from readers though), but it is then super suited for a beginner who wants to extend emacs. Cjohansen wants to write elisp code to help him do an editing task. He uses the classical approach of searching text around and applying changes. Thus he shows how to:
- define variables
- move and restore point
- looking around without moving the point (save-recursion)
- check that the current line contains what we want
- find the closing bracket
- write interactive functions (to call with M-x)
- define local variables (the let construct)
and in the end we have well constructed code and I think all the concepts of lisp were introduced (conditions, loops, predicates, etc).
Chrisdone's Elisp guide
Chrisdone's elisp guide is a quick but complete guide to writing useful functions in emacs lisp, targeted at programmers who have been using emacs for a while, want to start extending their editor and know how to consult emacs's builtin documentation. He doesn't explain the elisp language itself in any detail. According to him, there are a bunch of existing guides, but they don't strike the right balance of useful and helpful. Some just list functions, others try to explain Emacs Lisp from the ground up as a language. You don't need to know everything right away. He shows a lot of useful things but one will still need additional reading from the manual.
Very complete tutorial with a lot of code snippets, by caiorss
It may be missing links to popular and much useful libraries like dash.el, s.el and f.el (for list, string and file manipulation).
Learn functionnal programming
So you looked at some elisp but you don't feel very comfortable with the map construct, that is, with functionnal programming. I think it's time you have a look at it before going deeper into elisp. Reading a specific tutorial did much help me to get the elisp's way of doing. You have the choice: (E)Lisp and Clojure from the lisp family, or Haskell, Ocaml and others are functional languages. You'll find a lisp dialect for every language out there, like for Python (Hy language), C,… I myself liked very much the online tutorial of Haskell: http://tryhaskell.org/ . It quickly introduces you to the basic concepts shared by those languages. If you want, you can jump to lesson 14 to experiment with functions (map, filter, etc).
The official tutorial is located here: https://www.gnu.org/software/emacs/manual/html_node/eintr/
You can read it inside Emacs with C-h i m Emacs Lisp Intro RET (all in one go).
Read a good book: Writing GNU Emacs extensions
Many blog posts won't replace a good book. If you're into writing elisp functions, you must read "Writing GNU Emacs extensions" written by Bob Glickstein (O'Reilly). It covers many more things than we've seen up till now, in a tutorial style: it begins gently and then takes the reader by the hand to the process of writing an extension and introduces a lot of concepts and good practices. You should buy it (you'll easily find a pirate copy on the net though).
Don't forget to check wikemacs' pages on Elisp !
community's style guide
This Emacs Lisp style guide recommends best practices so that real-world Emacs Lisp programmers can write code that can be maintained by other real-world Emacs Lisp programmers. A style guide that reflects real-world usage gets used, and a style guide that holds to an ideal that has been rejected by the people it is supposed to help risks not getting used at all — no matter how good it is.