I see a potential bug here: (org-element-parse-buffer) with VISIBLE-ONLY does not include regions made visible with (org-with-wide-buffer).
Test (Have h2.2.1 collapsed before running it.):
>>>
* h1
** h2
*** h2.1
*** h2.2
#+begin_src elisp
(org-with-wide-buffer
(org-narrow-to-subtree)
(goto-char (point-min))
(list
(--map (cadr it)
(s-match-strings-all "^\\*+ \\(.*\\)$"
(buffer-substring-no-properties
(point-min) (point-max))))
(org-element-map (caddr (org-element-parse-buffer 'object t)) 'headline
(lambda (it) (org-element-property :raw-value it))))
)
#+end_src
#+RESULTS:
| h2.2 | h2.2.1 | h2.2.1.1 |
| h2.2 | h2.2.1 | |
**** h2.2.1
***** h2.2.1.1
aaaaa
*** h2.3
* h3
<<<
I would expect both output rows to be identical. But it seems that (org-with-wide-buffer) has no effect on (org-element-parse-buffer) with VISIBLE-ONLY argument.
While I believe this is a bug, I would also appreciate hearing about possible work-arounds.
thx