Created
December 8, 2017 17:10
-
-
Save asimpson/8ee431618cb3cbd5df75606aab4025c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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