Hello, and welcome to the DailyDrip emacs topic.

In this video we're going to teach you to fish. The emacs documentation is plentiful and very complete, and it would be a shame to not use it because it is so easily available.

I am going to teach you four keybindings to get help, and one keybinding to discover further behavior.

So, let's get started.

We can get help with C-h. C-h is summarized as "Act" + "Help". At the bottom it will show a ? recommended if we don't know what to do, and if we press it, we will find a whole lot of options for how to get help. We will ignore this for now and you can discover this yourself later.

setq is a function and so are require and package-intialize and so forth. It's very easy to get help on these functions by pressing C-h f, "f" for "function". And since the point was on that function name, emacs will recognize that it can provide help on this, and suggest it as a default. In this case, that is what we want, so we can press RET, and voila! A buffer with documentation.

How about package-install ? Place the point on it, C-h f RET, and there we go!

C-h f is how you get help for a function.

If you wanted to find information on a variable, you would do C-h v, "v" for variable. So if you place the point on package-enable-at-startup and press C-h v, emacs will recognize it can provide help on this symbol and suggest it. Again this is what we want, so press RET. Again we find documentation, and it's valuable here to see that emacs tells us the original value and the current value. This is very helpful to troubleshoot or remember how you may have changed emacs prior to saving the configuration.

So:

  1. C-h f for functions
  2. C-h v for variables

We can get help on the modes in the current buffer by hitting C-h m. This gives us a list of enabled minor modes, as well as the major mode, and the keybindings that are defined.

Finally, to get the help for a key, there is C-h k, "k" for "key". In the first video, I told you about M-e, so if you do C-h k M-e you will learn that M-e is forward-sentence. Similarly, I told you about C-x d, and if you do C-h k C-x d you will learn that it is a command called dired, for "directory editor", so if you did C-x d RET you would open a directory, which is nice! Okay, let's close that with q and move on.

So far:

  1. C-h f for functions
  2. C-h v for variables
  3. C-h m for current modes
  4. C-h k for keys

So what if you wanted to learn more about sequences of keys? Let's say you were in a SQL buffer, and you had pressed C-x but weren't sure what to do next. You could press C-h (so -- C-x C-h) and it would show you a list of all the following keybindings. A keybinding marked as a Prefix command means there are more keybindings after this, so for instance you could do C-x 8 " C-h to learn what keybindings follow C-x 8 ". This might seem ridiculous, but this is also probably the most complex example emacs has. Most of the time it will be much simpler. In the SQL buffer you could hit C-c C-h to find another list of keybindings.

So, you've been taught to fish, you have your bait, you have your line, and you are ready to attack.

  1. C-h f for functions
  2. C-h v for variables
  3. C-h m for current modes
  4. C-h k for keys
  5. <anything> C-h to discover follow-up keybindings.

Thank you for watching, and join us next time.