From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Buffer positions from `org-element-map'? Date: Wed, 28 Jan 2015 03:24:02 +0100 Message-ID: <87pp9zskvx.fsf@gmx.us> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGIIf-0005dn-71 for emacs-orgmode@gnu.org; Tue, 27 Jan 2015 21:24:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGIIb-0005VC-W2 for emacs-orgmode@gnu.org; Tue, 27 Jan 2015 21:24:13 -0500 Received: from plane.gmane.org ([80.91.229.3]:50097) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGIIb-0005V8-PI for emacs-orgmode@gnu.org; Tue, 27 Jan 2015 21:24:09 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YGIIa-0001CS-6A for emacs-orgmode@gnu.org; Wed, 28 Jan 2015 03:24:08 +0100 Received: from tsn109-201-154-200.dyn.nltelcom.net ([109.201.154.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Jan 2015 03:24:08 +0100 Received: from rasmus by tsn109-201-154-200.dyn.nltelcom.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 28 Jan 2015 03:24:08 +0100 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: emacs-orgmode@gnu.org Hi Charles, "Charles C. Berry" writes: > 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. OK > 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. Regexp and cl! Note, if you want it do always do it on the whole file use org-with-wide-buffer. You might also want to wrap it in a save-match-data. --8<---------------cut here---------------start------------->8--- #+BEGIN_SRC emacs-lisp :results code (save-excursion (goto-char (point-min)) (cl-loop while (search-forward-regexp org-babel-inline-src-block-regexp nil t) collect (list :begin (match-beginning 1) :at-heading (org-at-heading-p)))) #+END_SRC #+RESULTS: #+BEGIN_SRC emacs-lisp ((:begin 424 :at-heading nil) (:begin 461 :at-heading t) (:begin 493 :at-heading nil)) #+END_SRC src_emacs-lisp{"not in headline"} * src_emacs-lisp{"in head line"} src_emacs-lisp{"not in headline"} --8<---------------cut here---------------end--------------->8--- Hope it helps, Rasmus -- Governments should be afraid of their people