archive2015

Org-mode as an engineering notebook: a simple file layout

How I keep project notes, commands and decisions in Emacs Org-mode files so I can find and reuse them later.

2 min read#dev#emacs#org-mode

Last month I rebuilt the OpenCV setup on the Pi and could not remember half of the steps from the first time. They were in my shell history on a card I had already wiped. Since then everything goes into Org-mode files in Emacs. This is the layout, and I am trying to keep it simple.

One file per project, one inbox

~/notes/
  inbox.org          # quick capture, sorted later
  pi-sensors.org     # one file per project
  home-server.org
  snippets.org       # commands and configs that are not tied to one project

The folder is in Git, and I commit at the end of the day. That gives history and a backup.

A project file

#+TITLE: Pi sensors
#+STARTUP: overview

* Overview
  What the project does, where it runs, links to the repository.
* Setup
  Steps to install from zero. Keep these up to date. They are the most useful part.
* Decisions
** 2015-06-20 Use MQTT retained messages for sensor values
   Reason: dashboards show the last value at once after restart.
* Log
** 2015-07-10
   DHT22 read failures went up after moving the Pi into the case. Cause: heat.
* Snippets
  #+BEGIN_SRC sh
  mosquitto_sub -h raspberrypi.local -t 'home/#' -v
  #+END_SRC

I used to skip the Decisions section. Now it is the part I read most. A year later I do not remember why I chose a library, and one line with the date and the reason saves me from doing the same research again.

The Org features I use

TAB on a heading opens and closes it, and S-TAB cycles the whole file, so a long file stays readable.

Source blocks (#+BEGIN_SRC with a language) get syntax highlighting, and C-c ' opens the block in its own buffer with the right major mode.

org-capture adds a note to inbox.org from anywhere in Emacs. My whole config for it:

(setq org-default-notes-file "~/notes/inbox.org")
(global-set-key (kbd "C-c c") 'org-capture)

For search, M-x rgrep over ~/notes is usually enough. org-agenda can search too. And C-c C-e exports to HTML or Markdown when I need to share a note.

How I try to use it

I write the note while I do the work. If I plan to write it later, I never do. I paste the real command that worked, not one from memory. When I rebuild something from the Setup section and a step is missing, I fix the note right away.

The notebook has no TODO states and no tags. I tried tags for a week and stopped using them.