Skip to content

Instantly share code, notes, and snippets.

@allencch
Created July 27, 2017 10:00
Show Gist options
  • Save allencch/12945a4c18b7b4ae63ce6c8fad7fbfe3 to your computer and use it in GitHub Desktop.
Save allencch/12945a4c18b7b4ae63ce6c8fad7fbfe3 to your computer and use it in GitHub Desktop.
;;; org-mode-extend --- Extra org-mode functions
;;; Commentary:
;;; Code:
(defun org-outline-to-checklist (start end)
"Convert outline to checklist from START to END."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^*+" nil t)
(replace-match "- [ ]") nil t)))
(defun org-outline-to-plainlist (start end)
"Convert outline to plain list from START to END."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^*+" nil t)
(replace-match "-") nil t)))
(defun org-plainlist-to-outline (start end)
"Convert plain list to outline from START to END."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^[:space:]*\\- " nil t)
(replace-match "* ") nil t)))
(defun org-plainlist-to-checklist (start end)
"Convert plain list to checklist from START to END."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^[:space:]*\\- " nil t)
(replace-match "- [ ] ") nil t)))
(defun org-checklist-to-plainlist (start end)
"Convert checklist to plain list from START to END."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^[:space:]*\\- \\[.] " nil t)
(replace-match "- ") nil t)))
(defun org-checklist-to-outline (start end)
"Convert checklist to outline from START to END."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "^[:space:]*\\- \\[.] " nil t)
(replace-match "* ") nil t)))
(provide 'org-mode-extend)
;;; org-mode-extend.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment