From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Buffer positions from `org-element-map'? Date: Tue, 27 Jan 2015 17:48:42 -0800 Message-ID: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGHkQ-0002o3-8T for emacs-orgmode@gnu.org; Tue, 27 Jan 2015 20:48:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGHkN-0002R1-2k for emacs-orgmode@gnu.org; Tue, 27 Jan 2015 20:48:50 -0500 Received: from iport-acv2-out.ucsd.edu ([132.239.0.174]:34001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGHkM-0002Qi-ON for emacs-orgmode@gnu.org; Tue, 27 Jan 2015 20:48:47 -0500 Received: from [137.110.34.62] (unknown [137.110.34.62]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: ccberry@ad.ucsd.edu) by act-bufferout-b2.ucsd.edu (Postfix) with ESMTPSA id 47734E3C0E for ; Tue, 27 Jan 2015 17:48:43 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-Mode mailing list 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---