On Mon, Jun 10, 2013 at 11:14 PM, Alexander Wingård <
[email protected]> wrote:
>
> Maybe some day I will learn some LISP and teach it to navigate the
> hierarchical structure.
>
>
I actually got curious and gave this a try and here's what I came up with:
test.org:
* a
** b
*** h
** b
*** q
**** h
** c
*** d
Elisp:
(defun goto-notes ()
(interactive)
(find-file "~/test.org")
(org-goto-subtree '("a" "b" "q" "h"))
(org-show-context)
(org-show-entry)
(show-children))
(defun org-goto-subtree (path)
(let ((level 1))
(org-element-map
(org-element-parse-buffer 'headline)
'headline
(lambda (x)
(if (< (org-element-property :level x) level)
(setq level (org-element-property :level x)))
(if (and (= level (org-element-property :level x))
(string= (nth (- level 1) path) (org-element-property
:raw-value x)))
(progn (setq level (+ level 1))
(if (> level (list-length path))
(goto-char (org-element-property :begin x))))))
nil t)))
https://gist.github.com/AlexanderWingard/5814843
My very first attempt at programming Elisp so any feedback is appreciated.
Best regards
Alexander