From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: How to insert/replace during `org-elemment-map' call?
Date: Thu, 07 Aug 2014 13:27:25 +0200 [thread overview]
Message-ID: <87d2cca6aq.fsf@gmail.com> (raw)
Hi List,
when I change the signature of my new function `tj/rewire-element' by
adding an mandatory 'element' argument, it can be used in
`org-element-map' calls too:
#+begin_src emacs-lisp
(defun* tj/rewire-element (element &optional replace &rest args &key type &allow-other-keys)
"..."
(let* ((elem (or element (org-element-at-point))) ...)))
#+end_src
e.g. for converting all src-blocks in a buffer to example blocks:
#+begin_src emacs-lisp
(org-element-map ptree 'src-block
(lambda (--elem)
(tj/rewire-element --elem nil
:type 'example-block
:header nil)))
#+end_src
but the above just returns a list of strings with the created
example-blocks because argument 'replace' is nil:
,----
| (tj/rewire-element --elem nil ...)
`----
When I set that argument to non-nil (t or 'append or 'prepend), things
stop working because replacing/appending changes the parsed buffer,
but the :begin and :end properties of the already parsed elements are
not adjusted and I use them e.g. to delete a region.
Without using the export-framework (which seems overkill in this
case), is there a way to make this work anyway?
--
cheers,
Thorsten
next reply other threads:[~2014-08-07 11:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-07 11:27 Thorsten Jolitz [this message]
2014-08-07 13:14 ` How to insert/replace during `org-elemment-map' call? Nicolas Goaziou
2014-08-07 16:11 ` Thorsten Jolitz
2014-08-07 19: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=87d2cca6aq.fsf@gmail.com \
--to=tjolitz@gmail.com \
--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.