Hacker News new | ask | show | jobs
by blablabla123 2792 days ago
Do you know maybe a good documentation for it? The official manual seems a bit verbose, not containing much code :-)
2 comments

Personally, I regard the reflective and introspective capabilities of Emacs as extremely powerful tools for learning more about Elisp and the entire environment.

For example, every time you press a key (or key sequence) that results in any action, Emacs internally invokes a function (most of them written in Elisp, some of them in C) that achieves this action. So, when you want to automate a task and have a rough idea how to achieve it by pressing key sequences, you can inspect their associated functions and their source code, and study how they are called and even how they do it.

As a quick start, you can—using Emacs itself!—display a list of all functions that are bound to any key sequence. To get this, simply press:

    C-h b
This gives a good first indication of which functions are important for editing, because functions that are very frequently needed are typically available via a predefined key sequence.

But then, your next question may be: What did C-h b actually do? That is, which function did this actually invoke? Of course, one straight-forward way is to simply search for "C-h b" in the buffer that shows all these key bindings, because you know it must appear there. Another way is to use C-h k C-h b.

But then, what did C-h k actually do?

To find out, we apply C-h k to its own key binding:

    C-h k C-h k
and from this, you see that C-h k internally invokes the Elisp function "describe-key".

At this point, it is essential that you also have the (Elisp) source code installed. If you have it, then you can simply browse the Elisp definition of describe-key, and see how it achieves its task.

The same goes for every other function you may be interested in: You can browse its definition, copy it (for example) into the scratch buffer, change it, evaluate it and run it. You will find that not much is needed to get started with Elisp, because many tasks can simply be written as a sequence of standard commands of which C-h b provides a good first overview. You can also press C-h l to get a list of the last few input keystrokes and the invoked commands.

In addition to that, to automate simple tasks in Elisp, you often only need a few simple commands that let you fetch text from any position in the buffer and to insert it (see for example the functions buffer-substring-no-properties and insert), the ability to launch external processes (the "Processes" chapter in the Elisp info documentation is great) and a way to perform editing operations in a temporary buffer (see with-temp-buffer). To find out more about these functions, simply use C-h f.

And, of course, you can simply use C-h k C-h f to see what C-h f does!

One essential point: To make Emacs keybindings more convenient, I recommend to turn Caps Lock into an additional Ctrl key.

If you're not already a lisper I would recommend learning Common Lisp from one of the many excellent books. Learning the differences for Emacs Lisp afterwards is a breeze, and you get a much a more general purpose view of Lisp.
Already have a basic experience with that. But it seems Emacs provides a lot of APIs, for instance for Widgets.