Emacs for Everything

Table of Contents

1 Introduction to this series

Emacs has completely changed how I use my computer. Probably 80% of my time in front of the computer is from within Emacs, and I would love to get that as close as I can to 100%.

The reason is of course, that Emacs is much more than a text editor. My goal for this series is to document all of those other things I use it for. Things like personal organization and time management, streaming internet audio, and managing encrypted files.

In this series of posts, I'm not going to mention every command and option available for them, because that's what the info manuals are for. But if something here looks interesting and you want to try it out, you will be able to easily jump into the relevant documentation inside of Emacs. You should have some very basic familiarity with Emacs, and should have at least worked through the interactive tutorial.

And speaking of Emacs documentation, the first entry to this series will be about learning the help system within Emacs. If you take the time to become proficient with it, it will be like having a travel guide with you when you first visit a foreign country, ready to answer any question you might have.

Changelog

As I add new content, it will be reflected in this changelog.

Added section Learn to RTFM [2016-12-13 Tue 11:45]

2 Learn to RTFM

Don't worry, Emacs makes this easy! After all, it is proclaimed to be "The extensible self-documenting real-time display editor."

The first version of Emacs began development in the mid 1970s. It is a really old application. If you look under the covers (it's free software after all) you'd surely uncover a twisted history of hacks and quirks, stories of good intentions gone wrong, and of course all of the amazing aspects of it that has allowed it to continue to be very relevant all these years later.

In other words, Emacs has seen some shit. And it has all kinds of wisdom to pass on to those willing to listen. The reason I mention this, is that one of the first things you should learn from Emacs is that having the ability to quickly look up information you need from documentation will make you much more efficient (and generally give you much higher quality answers than online resources).

Emacs comes with the tools needed to do this easily, hence the "self-documenting" description. It comes with tons of help commands and info manuals to enable you find what you're looking for. Also, almost every function and command you use will contain a docstring which documents what it's used for and is displayed when you look them up. And it's all offline, bundled with Emacs! Go ahead and close your web browser. If you learn how to RTFM1 in Emacs, you won't need it. Emacs will teach you Emacs.

So turn off your network connection so you're distraction free, grab a hot drink, sit by the fireplace and enjoy.

Info

The first thing you should do after the Emacs tutorial, is learn how to use Info. It is a program for reading documentation. You will be using info constantly, so spend the time to learn the basics.

Emacs will have a bunch of info manuals available from the get-go. The type of manuals you will find include things like the Emacs manual, and many of the packages that come preinstalled such as Org-mode. When you install packages yourself, many times they include info manuals. Your operating system probably has a whole bunch of the installed for you as well, all available from within Emacs. Manuals for things like Tar, Bash, Coreutils. They're all there2.

Of course, having a whole bunch of manuals available for you doesn't help a lot if you can't quickly find what you're looking for inside of them. So Info provides features to do text searches, search the indices of the manuals, and quickly browse the structure of the manual to find the relevant section.

I should also mention the info-apropos command, which lets you search through the indices of every info manual installed on your system, and then be presented with a menu to browse the results.

Emacs has an interactive Info tutorial built in, which is the best way to learn it. Access it by pressing C-h i h, or M-x info <RET> h.

The Help Commands

The help commands are a great jump off point to find the documentation relevant to your task at hand. You can use it to narrow down into the type of help you're looking for. Depending on what you need, it might refer you to a page in an info manual, or to the docstring in a command, function or variable.

All help commands are accessible through the prefix key C-h. After your press it, the minibuffer will prompt you asking what you need help with. The next key you press will depend on what you're trying to look up.

If you don't know what key to press (which is not an uncommon situation to find yourself in, especially as you're getting the hang of Emacs) Press C-h, a second time (or C-h ?) and Emacs will display the help-for-help buffer – a list of the help commands. Use <SPACE> and <BACKSPACE> to scroll through the help commands.

As you scroll through the commands in help-for-help, you'll see the many options available. Some of the highlights of what you can do:

  • You can search for commands and functions.
  • See what command a key-binding invokes.
  • You can see what key-binding invokes a command.
  • Look up the current value of a variable
  • Jump straight to the info manual describing a command.
  • And much more…

What I meant by the help commands being a "jump off point" is that you'll notice a lot of times the help commands send you to an info manual, or to other systems like Apropos (which we are about to take a look at) to actually give you the documentation.

Apropos

Apropos is the tool you use when you know what you're trying to do, but looking for a command to do it. You give apropos a word, list of words, or a regex, and it searches for items that match.

Because there are so many commands and keybindings, this is essential for when you can't quite remember what they keybinding is for a function, or what the command is to begin with.

You can also use apropos to search for variables used for user options or elisp functions. Results for these contain the docstring which will give you some additional information for how they're used.

That's a lot to Remember…

It kind of is, but just remember how to jump into help, and you can look up everything else that you can't remember!

So to summarize: C-h brings up help, and you can jump off from here to everything you need.

After pressing C-h you can:

  • Press i to start the info reader, and from there press ? or H if you can't remember how to use info.
  • Press C-h (again) or ? to display help-for-help which will show you what key to press to use apropos among everything else mentioned and more.

And if you can't remember how you did something earlier, C-h l displays your last 300 keystrokes and their commands.

That should cover all you really need to know because again, you can always discover the rest. After some practice, using these tools will be come second nature and you will very rarely find yourself lost inside the depths of Emacs.

Footnotes:

1

Wikipedia: "Read the Fucking Manual" - https://en.wikipedia.org/wiki/RTFM

2

To find out where Emacs looks for the info manuals on your system, look at the value of the Info-directory-list variable (C-h v Info-directory-list <RET>).

Author: Caleb Gossler

Last Modified: 2016-12-13 Tue 12:17