all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: Buffer positions from `org-element-map'?
Date: Tue, 27 Jan 2015 17:48:42 -0800	[thread overview]
Message-ID: <alpine.OSX.2.00.1501271726400.663@charles-berrys-macbook.local> (raw)


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	other threads:[~2015-01-28  1:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28  1:48 Charles C. Berry [this message]
2015-01-28  2:24 ` Buffer positions from `org-element-map'? Rasmus
2015-01-28  7:32 ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.00.1501271726400.663@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.