Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save takumikinjo/433251 to your computer and use it in GitHub Desktop.
Save takumikinjo/433251 to your computer and use it in GitHub Desktop.
;; http://article.gmane.org/gmane.emacs.orgmode/10256
(defun org-get-heading-title ()
"Returns the heading of the current entry as a string, without the leading stars, the TODO keyword or the tags."
(let ((title-with-props (org-get-heading t))
(keyword (org-get-todo-state)))
(substring-no-properties title-with-props (if keyword (1+ (length keyword))))))
(defun org-insert-heading-category ()
"Insert a :CATEGORY: property and it's value to the PROPERTY drawer at point."
(interactive)
(let ((point (point)))
(org-entry-put point "CATEGORY" (org-get-heading-title))))
(defun org-insert-heading-categories-all ()
"Insert :CATEGORY: properties to each headlines indented level 2."
(interactive)
(org-map-entries
(lambda ()
(if (eq 2 (org-current-level))
(org-insert-heading-category)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment