Skip to content

Instantly share code, notes, and snippets.

@asimpson
Created December 8, 2017 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asimpson/8ee431618cb3cbd5df75606aab4025c8 to your computer and use it in GitHub Desktop.
Save asimpson/8ee431618cb3cbd5df75606aab4025c8 to your computer and use it in GitHub Desktop.
(defun simpson-org-to-todo()
"Convert a line (or region) in an org file to a TODO"
(interactive)
(let ((heading "") (i 1) (number (read-number "What level?" 1)))
(while (<= i number)
(setq heading (concat heading "*"))
(setq i (+ i 1)))
(if (region-active-p)
(let ((strings (seq-map (lambda(x) (concat heading " TODO " x))
(split-string (buffer-substring-no-properties (region-beginning) (region-end)) "\n" t))))
(delete-active-region)
(insert (mapconcat 'identity strings "\n")))
(org-beginning-of-line)
(insert heading " TODO ") t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment