Drawers

#-- mode: org --

What are drawers?

This section contains basic information about drawers

  • They allow for general text information one needs to access only sporadically
  • Drawer information is marked by a :HEADING: and an :END:
  • One cannot nest drawers
  • One can have as many drawers as one likes under a given heading
  • One can choose to export drawers.
  • Customize the variable org-export-with-drawers
  • Tab cycles drawer information

An example of a drawer

Any kind of information

  • One can use the command org-insert-drawer to insert a drawer into a heading
  • Drawers can have almost any name you assign (some names are reserved)
  • You can select a region of text and then, when you run org-insert-drawer it will treat the region as new drawer content and prompt for a drawer name.
  • This is an example of a drawer

The PROPERTIES Drawer

  • This is a special kind of drawer that stores information about the properties of a header.
  • One inserts a properties drawer by invoking org-insert-drawer with a C-u prefix argument.
  • Property drawers have property names unlike ordinary drawers, i.e. they contain metadata in a key-value pair format
  • Property drawers are generally indented because of their special relation to the header
  • They allow for greater specificity of information than regular drawers
* Task to complete
:PROPERTIES:
:ID:       20240402T1020
:Effort:   1:00
:Priority: A
:END:
  • One can autocomplete drawer information using Esc Tab

Custom keyboard shortcut

(defun my-org-insert-drawer-correctly (arg)
  "Insert a drawer or a PROPERTIES drawer with a prefix ARG.
Places the cursor correctly in the newly inserted PROPERTIES drawer."
  (interactive "P")
  (if arg
      (let ((start (point)))
        (org-insert-property-drawer)
        ;; Find the beginning of the drawer inserted at point or after.
        (goto-char start)
        (when (re-search-forward ":PROPERTIES:" nil t)
          ;; Move to the line after :PROPERTIES:
          (forward-line 1)))
    (call-interactively 'org-insert-drawer)))

(define-key org-mode-map (kbd "C-c i") 'my-org-insert-drawer-correctly)

Logbook Drawer

  • Note taken on [2024-04-02 Tue 13:26]
    Type in a note
  • There is another kind of drawer called the LOGBOOK drawer. It logs changes to the state of a task and clock times.
  • You can add a note to a LOGBOOK drawer using C-c C-z
  • But C-c C-z can be used to quickly add a note to any heading. This adds a timestamped note.

When to use C-c C-z and when to use ordinary drawers?

  • Use C-c C-z when the note is directly related to the progress or status of a task, especially when you want to keep a timestamped record within a LOGBOOK drawer.
  • Use ordinary drawers for more structured, categorized information storage that does not fit the brief, timestamped format of LOGBOOK entries.