Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell-wk
Last active March 5, 2018 03:09
Show Gist options
  • Save dustinlacewell-wk/e71cad4fcfb71c5f511fa17275c6158c to your computer and use it in GitHub Desktop.
Save dustinlacewell-wk/e71cad4fcfb71c5f511fa17275c6158c to your computer and use it in GitHub Desktop.

dnd-helm-characters

(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))

Helm Jump

helm-org–candidates

(defvar helm-org--candidates nil)

helm-org-subheadings

(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)))))))))))

helm-org–olp-subheadings

(defun helm-org--olp-subheadings (olp)
  (goto-char (org-find-olp olp 't))
  (helm-org--subheadings))

helm-org–file-olp-subheadings

(defun helm-org--file-olp-subheadings (file-name olp)
  (find-file (expand-file-name file-name))
  (helm-org--olp-subheadings olp))

helm-org-file-olp-select

(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