Improving my org-capture workflow with shortcuts for moving from inbox to todo

There is a great browser plugin for capturing websites, sprig/org-capture-extension. I’m using this all the time to capture things to my inbox. A lot of what I capture is actually things I expect to start working on soon or even right away, like pull requests. This workflow was quite tedious; capture in browser, create todo, refile.

Luckily, this is Emacs, so we can easily improve our workflow. During capture, I can now press C-c C-t to “todoify”, i.e. finalize, mark as TODO and move to todo.org. The other improvement is C-c C-p which does the “todoify”, then changes it to WIP. Changing to WIP will also clock me in for the task.

These small functions both saves me a lot of time, but perhaps more importantly, doesn’t break my flow.

_20240823_202744screenshot.png

(after! org
  (defun sijo/org-todoify ()
    "Converts a inbox item to a todo item.

- Marks it as TODO
- Schedules for today
- Moves it to todo.org"
    (interactive)
    (save-excursion
      (let* ((org-todo-log-states nil)
             (org-log-refile nil)
             (target-file "todo.org")
             (target-headline "Tasks")
             (position (marker-position (org-find-exact-headline-in-buffer target-headline target-file))))
        (org-todo "TODO")
        (org-schedule 0 ".")
        (org-refile nil nil (list target-headline target-file nil position)))))

  (defun sijo/org-todoify-last-stored ()
    "Converts the last stored item to a todo item.

See `sijo/org-todoify' for more information"
    (interactive)
    (org-capture-goto-last-stored)
    (sijo/org-todoify)
    (org-refile-goto-last-stored)))

(after! org-capture
  (defun sijo//org-capture-todoify ()
    "Finalize and todoify"
    (interactive)
    (org-capture-finalize)
    (sijo/org-todoify-last-stored))

  (defun sijo//org-capture-todoify-wip ()
    "Finalize todoify and mark as WIP"
    (interactive)
    (sijo//org-capture-todoify)
    (org-todo "WIP"))

  (defun sijo//org-capture-todoify-set-header ()
    "Add todoify shortcuts to `header-line-format'"
    (setq-local header-line-format
                (concat (s-chop-right 1 header-line-format) ; remove trailing .
                        (substitute-command-keys
                         "\\<org-capture-mode-map>, todoify `\\[sijo//org-capture-todoify]', wip `\\[sijo//org-capture-todoify-wip]'."))))

  (define-key org-capture-mode-map (kbd "C-c C-t") 'sijo//org-capture-todoify)
  (define-key org-capture-mode-map (kbd "C-c C-p") 'sijo//org-capture-todoify-wip)

  (add-hook 'org-capture-mode-hook 'sijo//org-capture-todoify-set-header))

Date: 2024-08-23 Fri 00:00

Author: Simen Endsjø

Created: 2024-08-27 Tue 22:24