[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Controlling example block export?
From: |
Thorsten Jolitz |
Subject: |
Re: [O] Controlling example block export? |
Date: |
Tue, 01 Apr 2014 16:52:16 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Heikki Lehvaslaiho <address@hidden> writes:
> Unless someone beats me to it, I'll write it one day. :)
What about:
#+begin_src emacs-lisp
(defun tj/toggle-example-and-comment-blocks ()
"Toggle example and comment blocks in current buffer."
(interactive)
(org-block-map
(lambda ()
(org-mark-element)
(when (use-region-p)
(let ((beg (region-beginning))
(end (region-end)))
(cond
((save-excursion
(re-search-forward "#\\+begin_comment"
(line-end-position) 'NOERROR))
(replace-string "#+begin_comment" "#+begin_example"
nil beg end)
(replace-string "#+end_comment" "#+end_example"
nil beg end))
((save-excursion
(re-search-forward "#\\+begin_example"
(line-end-position) 'NOERROR))
(replace-string "#+begin_example" "#+begin_comment"
nil beg end)
(replace-string "#+end_example" "#+end_comment"
nil beg end))
(t nil))
(deactivate-mark))))))
#+end_src
--
cheers,
Thorsten