As far as I know, the next meeting of EmacsATX, the Austin Emacs Meetup group, has a planned topic: Org mode. Like Emacs itself, it is a powerful, versatile, customizable tool that will change your life. It is the Emacs of Emacs. This post will present some of the Org functions I use most frequently, as well as a few other things I use in Org. It is a sequel to my post about common Emacs commands I used before I started getting serious about Emacs and started to use M-x to call functions.
Just as with Emacs, I have barely scratched the surface of Org. But if you find it overwhelming, trying out these commands might help you get started on your Org journey.
I took Rainer König’s Org course on Udemy, and I only got halfway through. I got so much out of the first half that I just started using Org and so far have not gotten around to finishing. I have not read the Org manual from beginning to end, so I admit there are gaps in my knowledge. I do not use key chords for most Emacs commands, and I honestly do not know too many of the key chords for Org. There are a lot of packages out there, and there are a lot of key chords to learn.
One thing I do is I customize the Org headers in my files. I made a function to insert this into my Org files:
#+STARTUP: indent
#+STARTUP: overview
#+SEQ_TODO: REPEATING (e) TODO(t) INPROGRESS(i) IN-USE (u) | DONE(d) CANCELLED(c)
#+TITLE: Emacs Is the Best Editor Ever
#+html_head_extra: <link rel="stylesheet" type="text/css" href="style.css" />
#+OPTIONS: \n:t
The “STARTUP: indent” line will indent subheadings, so everything is not lined with the left margin. “STARTUP: OVERVIEW” opens the file with the tree collapsed. “SEQ_TODO” gives the status options available to me when I give a heading a “TODO” status.
By default, Org gives “TODO” and “DONE”. Options to the left of the vertical bar are for items that have not been started (they still start with “TODO”) as well as possible options for items in progress, and options to the right are options for when you want to mark something complete. You can select options with the left- and right-arrows, or use letters. You can change the status of an item with org-todo. When you mark an item as finished with one of your completion options, Org will insert the date below the status line.
Headings are the basis of Org, and there a few commands that I use: org-insert-heading and org-insert-subheading. They do what you think they would do. Sometimes I want to add two sub-headings at the same level, but I call org-insert-subheading twice, and I get more nesting than I want. You can change the level of a heading with a few functions: org-do-promote and org-do-demote can promote items. If you use them on a tree of items, they will only affect the item you use them on, and leave the sub-headings underneath unchanged. To move an entire subtree, use org-promote-subtree and org-demote-subtree.
You can move headings up and down with org-metaup and org-metadown, which are not intuitive names. These will only move an heading up and down within a tree. If you want to move an item to another subtree (or past many items within the same tree) you can use org-cut-subtree and org-paste-subtree. There are functions named org-move-item-down and org-move-item-up, but when I tried them, I got the message “Not at an item”.
There are commands to expand and collapse item trees. I use show-children, which will just show the child headings of an item if there are any. Any text in the item and any items on levels further down will not be shown. show-subtree will show everything. show-entry will show any text for an item, but not display any child items. hide-subtree will collapse the tree. These commands are obsolete per my Messages buffer. The preferred commands are org-fold-show-children or outline-show-children to show children, outline-show-subtree, org-show-subtree or org-fold-show-subtree to show subtrees, outline-show-entry or org-fold-show-entry to show entries, org-fold-hide-entry to hide entries, and outline-hide-subtree or org-fold-hide-subtree to hide subtrees.
I will stick with the shorter obsolete commands for now. I might use them for function names for functions to call the correct commands when the obsolete ones stop working. Or I just might use the TAB key to toggle trees. This is one place I might make an exception to my preference for calling M-x.
I use the Org agenda view to keep track of my schedule. I schedule an item with org-schedule. One thing to note is that if you are scheduling an item for a time of day after noon, you have to be careful when entering the time. Org displays the times with 24-hour notation, or military time. You either have to use military time (like “18:00”) or add the “PM” with no space: “6:00PM”. Once I typed “6:00 PM”, but Org saved the time as “06:00:00” instead of “18:00:00”.
If you want to make a task a repeating task, you need to add it with org-schedule, give it a status of “REPEATING”, and alter the timestamps and add some symbols to the timestamp. To edit the timestamp, I have to run org-toggle-timestamp-overlay, edit the timestamp, and call org-toggle-timestamp-overlay again when I am done. There might be an easier way to do it, but it took me so long to find this one, I have stuck with it. Here are a few examples:
****✸ REPEATING Pay Rent
SCHEDULED: <2024-02-01 +1m>
****✸ REPEATING Check tire pressure
SCHEDULED: <2024-01-09 .+1m>
****✸ REPEATING Clean barnacles off the hull
SCHEDULED: <2024-01-06 .+6d>
****✸ REPEATING Submit weekly expense report
SCHEDULED: <2024-01-10 ++7d>
****✸ REPEATING Mother-in-law's Birthday
SCHEDULED: <2024-05-01 +1y>
So you have a number and a letter for the interval: “d” for days, “w” for weeks, “m” for months, “y” for years. A couple of them have a plus sign in front, some have two plus signs, and some have a period and a plus. The ones with one or two plus signs both seem to push something ahead by the interval from the last due date, even if you are late. At least that is what I have noticed. I am not clear what the difference is. I found the manual and Rainer König’s couse a bit unclear. The rent is due every month. Birthdays do not change. You could lose your job if you submit expense reports late. However, while checking the tire pressure and cleaning barnacles off the hull need to be done regularly, you will probably be okay if they are a day or two late.
When I complete them, I run org-todo, chose “DONE”, and the status stays as “REPEATING” and the due date gets updated.
Here are some notes I made on this:
+1m (no dot) will push due date one month ahead from last due date, even if you are early or late.
++1m also seems to push ahead by the interval from last date, even if late
.+1m (with dot) will push due date ahead from when you mark as complete for that cycle.
I also make tables in Org, using Org table functions instead of Emacs table functions. Org tables are easier, and you can put formulas in cells and make plots with them. They are easier to manage in Org, but one serious limitation is that a table cell cannot have a line break in Org tables. To my knowledge, there is no workaround for this.
org-table-create will create a table, and you will be prompted in the minibuffer for the number of columns and rows. You can insert a row with org-table-insert-row; this inserts above where you are. To make one below, hit enter at the end of the row you want to put a row underneath, and add 2 “|” characters and hit the tab key. It will create the correct number of cells. Or hit TAB at the end of last row next to the border. To delete a row, you can just type C-k. org-table-insert-column inserts to right of column you are in. To delete a column, you can call org-table-delete-column. This deletes the column you are in.
I also add this line to the top of an Org table which will add borders for the cells when you export the Org buffer to an HTML file:
#+ATTR_HTML: :border 2 :rules all :frame border
I write these posts in Org, then I run org-export-dispatch and select “h” twice (lower-case both times) to export the files to HTML. I select the text, and copy it into the WordPress classic editor. The block editor is a disaster.
Image from the Khitrovo Gospels, a 14th-century manuscript housed at the Russian State Library; image from Wikimedia, assumed allowed under public domain; the image may have been cropped and had colors enhanced via ImageMagick.