From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Controlling example block export?
Date: Tue, 01 Apr 2014 16:52:16 +0200 [thread overview]
Message-ID: <87a9c5m7a7.fsf@gmail.com> (raw)
In-Reply-To: CAK=ukca7cyZEG=VTDUQNfUQ5ESkrVjPS398r230deWpDhRP=XA@mail.gmail.com
Heikki Lehvaslaiho <heikki.lehvaslaiho@gmail.com> 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
next prev parent reply other threads:[~2014-04-01 14:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 9:20 Controlling example block export? Heikki Lehvaslaiho
2014-04-01 10:10 ` Thorsten Jolitz
2014-04-01 12:40 ` Heikki Lehvaslaiho
2014-04-01 14:52 ` Thorsten Jolitz [this message]
2014-04-01 15:16 ` Thorsten Jolitz
2014-04-01 15:38 ` Nicolas Goaziou
2014-04-01 15:34 ` Nicolas Goaziou
2014-04-01 16:33 ` Charles Berry
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=87a9c5m7a7.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.