emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to insert/replace during `org-elemment-map' call?
@ 2014-08-07 11:27 Thorsten Jolitz
  2014-08-07 13:14 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Jolitz @ 2014-08-07 11:27 UTC (permalink / raw)
  To: emacs-orgmode


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-07 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-07 11:27 How to insert/replace during `org-elemment-map' call? Thorsten Jolitz
2014-08-07 13:14 ` Nicolas Goaziou
2014-08-07 16:11   ` Thorsten Jolitz
2014-08-07 19:32     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).