From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Controlling example block export? Date: Tue, 01 Apr 2014 16:52:16 +0200 Message-ID: <87a9c5m7a7.fsf@gmail.com> References: <87k3b9mkcb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV024-0005ag-QE for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 10:51:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WV01x-0000Oc-5e for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 10:51:20 -0400 Received: from plane.gmane.org ([80.91.229.3]:38304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV01w-0000Mz-Up for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 10:51:13 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WV01r-0006HF-MW for emacs-orgmode@gnu.org; Tue, 01 Apr 2014 16:51:07 +0200 Received: from e178190017.adsl.alicedsl.de ([85.178.190.17]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Apr 2014 16:51:07 +0200 Received: from tjolitz by e178190017.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Apr 2014 16:51:07 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Heikki Lehvaslaiho 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