The DevOps Blog

Calendar Organization with Org

I have been having some issues with my calendar. Recurring stuff have been going out of wack for some reason. In general, the setup I've had for the past few years have now become a problem I need to fix.

I decided to turn to my trusted emacs, like I usually do. Doom comes bundled with something. Let's figure out what it is and how to configure it together.

Calendar in Emacs

I dug deeper into Doom's Calendar module and I found out that it is using calfw.

I went to GitHub and checked the project out. It's another emacs package, I'm going to assume you know how to install it.

Let's look at the configuration example.

(require 'calfw-cal)
(require 'calfw-ical)
(require 'calfw-howm)
(require 'calfw-org)

(defun my-open-calendar ()
  (interactive)
  (cfw:open-calendar-buffer
   :contents-sources
   (list
    (cfw:org-create-source "Green")  ; orgmode source
    (cfw:howm-create-source "Blue")  ; howm source
    (cfw:cal-create-source "Orange") ; diary source
    (cfw:ical-create-source "Moon" "~/moon.ics" "Gray")  ; ICS source1
    (cfw:ical-create-source "gcal" "https://..../basic.ics" "IndianRed") ; google calendar ICS
   )))

That looks like an extensive example. We don't need all of it, I only need the part pertaining to org.

Configuration

The example looks straight forward. I'm going to keep only the pieces I'm interested in. The configuration looks like the following.

(require 'calfw-cal)
(require 'calfw-org)

(defun my-blog-calendar ()
  (interactive)
  (cfw:open-calendar-buffer
   :contents-sources
   (list
    (cfw:org-create-file-source "Blog" "~/blog.org" "Orange")  ; our blog organizational calendar
   )))

That was easy. but before we jump to the next step, let's talk a bit about what we just did. We, basically, created a new function which we can call later with M-x to open our calendar. We configured the function to include the org files we want it to keep track of. In this case, we only have one. We named it Blog and we gave it the color Orange.

Creating our org file

After we have configured calfw, we can create the blog.org file.

#+TITLE: Blog
#+AUTHOR: Who
#+DESCRIPTION: Travels of Doctor Who
#+TAGS: organizer organization calendar todo tasks

* Introduction

  This is the /calendar/ of *Dr Who* for the next week.

* Travels

** DONE Travel to Earth 1504
   CLOSED: <2021-07-03 za 09:18> SCHEDULED: <2021-07-02 vr>

   - CLOSING NOTE <2021-07-03 za 09:18> \\
     The doctor already traveled to earth /1504/ for his visit to the /Mayans/.

   A quick visit to the /Mayan/ culture to save them from a deep lake monster stealing all their gold.

** TODO Travel back to Earth 2021
   SCHEDULED: <2021-07-04 zo>

   Traveling back to earth 2021 to drop the companion before running again.

** TODO Travel to the Library
   SCHEDULED: <2021-07-04 zo>

    The doctor visits the /Library/ to save it again from paper eating bacteria.

** TODO Travel to Midnight
   SCHEDULED: <2021-07-08 do>

    The doctor visits *Midnight* in the /Xion System/.

** TODO Travel to Earth 2021
   SCHEDULED: <2021-07-09 vr>

    Snatching back the companion for another travel advanture.

Let's get the party started

Now that we have everything set into place. We can either reload emacs or simply run the code snippet that declares our function.

Next step is checking out if it works. Let's run M-x then call our function my-blog-calendar.

Calendar organization with Org

If we go to a date with hjkl and hit return or enter, we get to see what we have to work with.

Calendar day overview

We can take a look at closed items with time too.

Calendar day with closed item

That looks pretty nice.

Conclusion

I thought it was going to be more extensive to configure the calendaring feature in emacs. I couldn't be further away from the truth. Not only was it a breeze to configure, it was even easier to create the calendar and maintain it. If you are already familiar with org, then you're already there. Point the calendar to your org file, iCal file or even Google Calendar link and you're all set. The bottom line of working with org is the ease of use, to me. If you already use it to organize some aspects of your life, you can just as easily create calendars for all these events.