6 ms·
I know the basics of Emacs as an editor, and I understand that it is possible to use Lisp to extend it, but I have not come in contact with a good resource to t
by jwrallie 4y ago
I know the basics of Emacs as an editor, and I understand that it is possible to use Lisp to extend it, but I have not come in contact with a good resource to teach me the fundamentals of how to do so. I know a bit of Lisp, I am more curious about how to expose the existing interfaces (API), where and what to look for. Does anybody have any suggestions? I like learning more by seeing somebody do it than by reading reference documentation if that helps.
- anon35 4y agoAn excellent tutorial that takes exactly this approach (building up to a novel Emacs mode for NYT Crosswords, of all things) is the O'Reilly book "Writing GNU Emacs Extensions, by Bob Glickstein.
- db48x 4y agoIf you like seeing how other people have extended Emacs, then I recommend reading the source code of existing Emacs extensions. Emacs comes bundled with more than a million lines of such code you could read, and there is another million or so available to download from the package archive. There really is no shortage of examples to choose from. Also the Emacs Manual and the Emacs Lisp Manual, which come with Emacs, very thoroughly document the Emacs extension interfaces.
- donio 4y agoThe Emacs Lisp Reference Manual is the obvious resource. It also comes with Emacs so once you are comfortable with the Info reader you can have it at your fingertips at all times. https://www.gnu.org/software/emacs/manual/elisp.html https://www.gnu.org/software/emacs/manual/elisp.html Emacs also has comprehensive and high quality docstrings on functions and variables. I find them to be much more useful than in most other languages. You can very often get by just reading the docstrings. And finally don't be afraid to look at the source. Bind find-function and find-variable to some convenient keys. For those who are new to Lisp or want a refresher the Elisp Intro is great too: https://www.gnu.org/software/emacs/manual/eintr.html https://www.gnu.org/software/emacs/manual/eintr.html Start simple. Find a personal itch to scratch, write some interactive functions that you can bind to keys. Or a hook to make something work way you'd prefer.
- m463 4y agoOther comments talk about the source code. What's interesting is that if you have emacs + the source code on your machine, you can use find-function to jump to not only the lisp source of a function, but also drill down into compiled functions. for instance, I did it for "(list" and found: DEFUN ("list", Flist, Slist, 0, MANY, 0, doc: /* Return a newly created list with specified arguments as elements. Any number of arguments, even zero arguments, are allowed. usage: (list &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { register Lisp_Object val; val = Qnil; ...
- kqr 4y agoIf you use Emacs and you are curious how something works, look up the function/command/keybinding with the built-in help. It will usually contain a link to the Emacs source code implementing it. At least I have learned a lot from reading how these things fit together in the code, and occasionally replacing a definition entirely or creating advice around it. It's a very easy environment to do so in, because the documentation is automatically linked to the relevant source code, so you never have to get stuck at something because you don't know what it does under the hood.