Red Green Repeat Adventures of a Spec Driven Junkie

Enhancing org-mode Agenda File Configurations

I’ve been loving org-mode and want to share recent insights that I have found useful.

I will share the specific configurations I use to enhance emacs and org-mode.

If you’re using org-mode, you will learn how to configure emacs to load all files in a directory into the agenda, load files that do not end in .org, and tell Emacs to treat a file as an org-mode file, even when the ending is not .org.

This article will take you two minutes to read.

Vincent Van Gogh - Irises source and more information

Introduction

Emacs’ org-mode and its agenda feature is becoming a bigger part of my workflow. Where I am in it just as much as any other application I use for work (i.e. email, web browser, chat, etc.)

org-mode out of the box is a bit intimidating and I’ve shared how to get started with org-mode agenda’s scheduling.

This time, I will share enhancements I learned to work with org-mode:

  • loading all the files in an folder for org-mode’s agenda
  • loading different file types for org-mode’s agenda
  • File mode override

Load All .org Files in a Directory

From my getting started in org-mode agenda article org-mode Agenda loads from specific files. You can add specific files for org-mode to use:

(add-to-list 'org-agenda-files "~/file1.org")

Which is nice, what if you have 100 files?? Well, this is where setting the value as:

(setq org-agenda-files '("/<path>/<to>/<agenda>/<files>"))

Would load all the .org files in /<path>/<to>/<agenda>/<files>.

Load .org.txt Files

As I’m using Dropbox with Emacs, I want to edit my org-mode files in Dropbox.

Dropbox will only allow editing of files ending in:

  • .txt - standard text files
  • .md - markdown files

As org-mode are just text files, files ending with .org are the same as .txt.

Not in Dropbox. 🙁

To get Dropbox to open .org files, I change the file ending to: .org.txt, which allows Dropbox to open the files.

Now, how do I get org-mode agenda to load them, especially from a directory??

Simple: modify the org-agenda-file-regexp, duh! :-)

The following will set org-agenda to load *.org.txt files instead of *.org:

(setq org-agenda-file-regexp ".*\.org\.txt$")

If you have another file ending, modify ".*\.org\.txt$ to the appropriate regular expression.

File Mode Override

Having the following in the first line of the file ensures Emacs treats the file as an org file:

-*- mode: org -*-

or setting this in the init.el:

(add-to-list 'auto-mode-alist '("\\.org\.txt\\'" . org-mode))

Save yourself from typing M-x org-mode every time.

Conclusion

Using org-mode’s agenda has been great and adding small tweaks here and there makes working with org-mode agenda even better, such as:

  • having Emacs treat the file as an org-file, even if its ending is .txt.
  • Using any file ending as agenda input into the org-mode agenda, like .txt.
  • Loading all files in a directory as agenda input files.

org-mode’s power of just using plain text for everything allows me to use it in Emacs as well as applications with plain editors, like Dropbox on mobile.

If you want to learn more about Emacs and org-mode, contact me and I’ll help you out.