emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Buffer positions from `org-element-map'?


From: Charles C. Berry
Subject: [O] Buffer positions from `org-element-map'?
Date: Tue, 27 Jan 2015 17:48:42 -0800
User-agent: Alpine 2.00 (OSX 1167 2008-08-23)


I'd like to be able to determine the buffer position of (say) inline
src blocks as in the following and operate on them using
`org-element-map'. This might enable modification and replacement of a
few objects in a large buffer.

What I would like is to have the same values of :begin as would be
obtained by placing the cursor on each inline src block and evaluating
(org-element-context). As is evident below, :begin is sometimes a
relative position.

Suggestions on how to get the buffer position or some other way to do
in situ buffer modifications from `org-element-map' without
interpreting a complete parse tree (which I expect requires more
computation that doing selected `delete then insert' operations) are
welcome.

Chuck

--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC emacs-lisp
  (org-element-map (org-element-parse-buffer)
      'inline-src-block
    (lambda (x) (list
                 (org-element-property :begin x)
                 (org-element-property :value x))))
#+END_SRC

#+RESULTS:
| 326 | "not in headline" |
|   1 | "in head line"    |
| 395 | "not in headline" |

src_emacs-lisp{"not in headline"}

* src_emacs-lisp{"in head line"}

src_emacs-lisp{"not in headline"}


--8<---------------cut here---------------end--------------->8---




reply via email to

[Prev in Thread] Current Thread [Next in Thread]