<2024-08-15 Thu> Emacs Tutorial - Part 1

Home Blog Profile Now Page WIPs Finished Projects Feed

Why Emacs?

Skip the preamble, please

I chose to go with Emacs because I watched a video where someone made it sound like it ruined their life. I wish I was joking, but here's the link. After messing around with it for about almost a year now, I feel comfortable enough with it to actually make a few posts about actually using it from the perspective of a new user.

The Purpose of This Document

The point behind this post is to get you up to the point where you can effectively use a file to manage your journaling, TODOs, and other things, and to be able to use the agenda view in order to view specific portions of the diary based on tags.

Why Me?

  • I like the software and tend to pick things up relatively quickly
  • I am of the belief that there comes a point which people are too far in to really help beginners without being in the room with them.

It's the reason I don't really want to make an "Intro to Linux" series, despite having 15 years of experience with it. I don't know the problems that modern-day beginners have with it, because I started back when Steam didn't even have a native Linux port, though I am happy to answer questions people have when I can.

I'm still green enough that the problems a new user is having now are roughly the same as the problems I had when I started. I also understand that, to a new person, C-u C-u C-c C-x C-i means literally nothing (We'll get to what it means here shortly). I also still remember pretty well how I got here.

With all of that out of the way, though, let's begin!

The actual tutorial

Part 1: The Lingo

All keybindings here will be the vanilla default keybindings for things. If you're using doom emacs, spacemacs, or any other starter config these keybindings may not work, or may do something else. Please, please, please do not test out these keybindings in a file you care about.

This is more about keybind syntax, the thing I mentioned before

Keybinding Meaning
C-c Control + c
C-C Control + Shift + c
C-x h Control + x, then h without control pressed
C-x C-s Control + x, Control + s, control can be held down the whole time
RET Return, the enter key
M-x Meta (alt) + x

The letter will always be either a C or an M in official documentation. The C stands for control, the M stands for Meta, which is the alt key by default.

The only keybind you need to know to start is M-x, which lets you run commands, which is more or less what all of the keybinds run anyway. The main exception to these are things like copy, paste, etc, which ARE NOT bound to what you're used to. Copy is M-w, paste is C-y, select all is C-x h

Besides that my recommendations for when you're first starting out are just not to disable the top bar. It's extremely useful, and you can just click it instead of hitting F10 on the keyboard. Also F10 on the keyboard opens the menu bar (File, Edit, etc)

Part 2: Packages

So, for this we're going to install one package which is actually a few packages in a trench coat: ivy. There are a few alternatives, but Ivy is what I use, so we're all using it here. First we need to change the config a little bit to make our lives easier, so type

M-x customize

After that there's going to be a search bar at the top, go ahead and type "package archives" into the bar and hit enter. You'll be presented with 2 options, click the arrow to the left of "Package Archives:" and it will drop down.

Click INS at the bottom, and then for the archive name type "melpa" and for the URL or directory put https://melpa.org/packages/

Click INS again and then add "org" as the archive name and "https://orgmode.org/elpa/" as the URL

Go back to the top and click the button that says "Apply and Save"

Congrats, we've committed a sin together! Editing your config by hand is a pain, and I will steer us away from doing that for now. Maybe later on we'll get into that, but for now we're gonna pretend you can't directly edit the init.el file.

Now, to install ivy, type this:

M-x package-install RET ivy RET

It will download, install, and then it should enable automatically. Once you hit M-x again it should show a list of commands with a search bar at the top. If not run the command ivy-mode and then try again, it should work.

I normally wouldn't get into configuring this early on, but it helps enough that I feel it's worth it.

Part 2: Org mode

Org mode is a markup language, meaning it functions like markdown, but with different syntax, and with more features. The stuff you'll use most often for general notes is just * for headings. More stars = lower priority heading. Besides that, asterisks around a word bold it, forward slashes italicize, and links are done like this:

[[https://your.domain.tld/][This is the displayed text]]

For TODO lists, you literally just put the word TOOD between the asterisk and the heading text. There are alternatives, like using checkboxes by replacing TODO with [ ], or [/], or [%], which will give different displays if you have sub-tasks.

Tags are done by putting a word between colons, like :this:, at the end of a heading. This isn't super useful to org mode, but it is one of the most killer features of agenda, which is the next topic.

Before we get there, though, we should probably set up which file is our org-file. Mine is locared in my johnny.decimal system, but you can just plop yours in your home folder, or wherever else you want.

This is the part where I mention that I use Linux and folders might not work the same on your system, notably if it's Windows.

Pull up the customize window from before again, and then search for org files the same way we did before. This time we're looking for a line that says "Org Agenda Files". Hit INS, and then put the path to your document (e.g. ~/documents/org/diary.org or whatever you decided to name it, remember that directory paths and file names are case sensitive). After that click the Apply and Save button again, and we're good to go!

Part 3: Agenda

This is the big guns for managing your life right here. There's enough here that it will have it's own part, but typing:

M-x org-agenda

Will get you started. It brings up a second window with options of what you actually want to see. The big ones are going to be t, n, and m. My most commonly used one is m, followed by n.

For m, which is Match a TAGS/PROP/TODO, it will list everything that falls within whatever category you select. Want to see every single good thing that's happened to you in the past forever? You can do that if you've tagged those headings. It is such an absolute unit of a feature that I kind of want to get "C-c a m" in my favorite monospace font printed and framed, or tattood on me.

The next most used one is n, which lists the current agenda, and all TODOs. I like having both because some of my TODOs aren't scheduled, so they don't show up on the week's agenda. Not as much to say here, because it really is just for your todo list.

The last one is t, which just lists all TODOs. It's included in n, which is why it's last here.

Part 4: The Diary

The diary file ties this all together, and I have a template for mine uploaded here. You'll notice when you open it that everything is stored backwads (the years are newest to oldest, same with months and days), and this is to help with searchability. Everything shows up in the agenda view in the order it's in the diary file, so keeping the newer stuff up top helps with sorting through it later on.

Besides that, there is an example table with some math in there. We haven't touched on tables yet because I've just barely started to really understand them, but if you want to track your macros just fill in the blanks that don't say "Total", and then press C-c C-c on the formula at the bottom of the table, and it'll fill in the total blanks.

Also, the easy way to copy the templates is found in the top bar:

Org > Edit Structure > Copy Subtree

It's bound to C-c C-x M-w by default, helps with copying the templates. You can also use C-c @ M-w

Keys Effect
C-c C-x M-w Copy Subtree
C-c @ Select subtree
M-w Copy

End

One other tip before we go:

Over time you'll notice that, more often than not, keybinds will often start with the same key if they're from the same module. Most vanilla emacs commands start with C-x, most org-mode keybinds start with C-c.

I really hope this actually helps someone get into emacs a bit more smoothly than I did, because I had to love the potential of the software to even get to tomorrow as a user of the software. If you have any questions, or suggestions for this article, please reach out to me on The Fediverse.

If you like what I do here, consider donating through ko-fi

Theme used: Retro Dark

Site generator: Kristell's SSG

All works on this website are released under a Creative Commons Attribution ShareAlike 4.0 International License

Author: Kristell L.

Emacs 29.4 (Org mode 9.6.15)