(defun dnd-helm-characters () (interactive)
(let* ((title "Pick a character")
(file "~/life/life.org")
(olp '("D&D" "Characters"))
(sources (helm-org-file-olp-select title file olp))))
(helm :sources sources))
Last active
March 5, 2018 03:09
-
-
Save dustinlacewell-wk/e71cad4fcfb71c5f511fa17275c6158c to your computer and use it in GitHub Desktop.
(defvar helm-org--candidates nil)
(defun helm-org--subheadings (&optional recursive)
"Return a list of subheadings. If RECURSIVE is truthy return a
list of all headings in subheading subtrees."
(org-save-outline-visibility t
(save-excursion
(let ((pred (lambda () (org-entry-get nil "ITEM"))))
(if recursive
(org-map-entries pred nil 'tree)
(progn
(org-back-to-heading t)
(org-show-subtree)
(if (org-goto-first-child)
(cl-loop collect (funcall pred)
until (let ((pos (point)))
(null (org-forward-heading-same-level nil t))
(eq pos (point)))))))))))
(defun helm-org--olp-subheadings (olp)
(goto-char (org-find-olp olp 't))
(helm-org--subheadings))
(defun helm-org--file-olp-subheadings (file-name olp)
(find-file (expand-file-name file-name))
(helm-org--olp-subheadings olp))
(defun helm-org-file-olp-select (prompt file olp)
(setq helm-org--file-name (expand-file-name file))
(setq helm-org--candidates (helm-org--file-olp-subheadings file olp))
`((name . ,prompt)
(candidates . helm-org--candidates)
(action . (lambda (candidate)
(find-file helm-org--file-name)
(goto-char (org-find-exact-headline-in-buffer candidate))))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment