[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] How to insert/replace during `org-elemment-map' call?
From: |
Thorsten Jolitz |
Subject: |
[O] How to insert/replace during `org-elemment-map' call? |
Date: |
Thu, 07 Aug 2014 13:27:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
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
- [O] How to insert/replace during `org-elemment-map' call?,
Thorsten Jolitz <=