I'm trying to get familiar with Emacs Lisp, its syntax, data structures etc, so I was wondering what are some built-in packages whose source could help me better understand how to use the language and learn its idioms?
2 Answers
I can recommend Ruby Mode in ruby-mode.el
and Python Mode in python.el
, for some aspects of their implementation. The former is a particularly great source for advanced indentation and navigation code based on the new SMIE engine. However, neither uses data structures in any particularly clever or advanced way.
I would also recommend some parts of Org Mode 8, for its design. Notably the exporter framework of Org 8 shows how to create an generic, extensible, object-like framework in plain Emacs Lisp. However, I'd recommend against most other parts of Org, for reasons already stated in comments: It's old, and full of legacy and harmful practices (e.g. find-file-noselect
to read files non-interactively).
Gnus is also said to have good code, but again I'd be careful to determine how well-maintained the particular piece of code is that you are looking at.
Since Emacs itself is very old, and only superficially maintained in many places, the average quality of its code is actually rather low by modern standards. There's many legacy stuff in there. For instance, even in core parts such as the byte compiler you'll find “TODO”s and “DUNNO”s dating back years, if not decades. Also, since Emacs is very slow to take code and developers from the “outside” community due to the restrictive policies established by the FSF, the overall quality increases only slowly.
All in all, you are more likely to find good code in popular 3rd party packages maintained by high-profile community members, e.g. Magit, Projectile, etc.
-
2
-
3Those planning on taking a dive into gnus' code: Please do take care. Those are deep waters and we wouldn't want to loose anyone. Sep 25, 2014 at 13:27
-
2
-
2Do you have anything to backup your last claim? I would strongly expect the opposite...– rasmusNov 19, 2014 at 23:32
-
1What I had in mind was: "[...] Emacs is [...] superficially maintained in many places, the average quality of its code is actually rather low" versus "you are more likely to find good code in popular 3rd party packages". But "Emacs is very slow to take code and developers from the “outside”" also seems like nonsense IMO (do you read the
debbugs
?)...– rasmusNov 20, 2014 at 0:42
info
file ? Some built-in functions are explained and detailed.