From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xavier Garrido Subject: Wrapping section within LaTeX environment Date: Sun, 13 Dec 2015 15:00:00 +0100 Message-ID: <566D79E0.3030704@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a87C5-0001sf-4D for emacs-orgmode@gnu.org; Sun, 13 Dec 2015 09:00:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a87C1-0002U4-Tu for emacs-orgmode@gnu.org; Sun, 13 Dec 2015 09:00:09 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:36206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a87C1-0002SJ-OH for emacs-orgmode@gnu.org; Sun, 13 Dec 2015 09:00:05 -0500 Received: by mail-wm0-x230.google.com with SMTP id n186so86742389wmn.1 for ; Sun, 13 Dec 2015 06:00:04 -0800 (PST) Received: from [192.168.0.11] ([88.162.233.171]) by smtp.googlemail.com with ESMTPSA id z10sm11722178wmg.4.2015.12.13.06.00.03 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 13 Dec 2015 06:00:03 -0800 (PST) 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" Dear orgers, I would like to wrap a given org section between =\begin,\end= LaTeX environment. These sections are identified by a special tag :correction: and to initiate the =\begin= flag I have basically no problem by using the org-export-filter-headline-function filter. The problem comes when I want to close the environment i.e. when another section starts. I have try this piece of code #+BEGIN_SRC emacs-lisp (setq correction-flag nil) (defun cpp-correction-headline (contents backend info) (if (and (org-export-derived-backend-p backend 'latex) (string-match "\\`.*correction.*\n" (downcase contents))) (progn (setq correction-flag t) (replace-match "\\\\begin{correction}" nil nil contents) ) (when correction-flag (setq correction-flag nil) (concat "\\end{correction}" contents)) ) ) (add-to-list 'org-export-filter-headline-functions 'cpp-correction-headline) #+END_SRC but I get several =\end{correction}= in the produced LaTeX file. Actually this is much more a emacs-lisp related question since the boolean =correction-flag= seems not to work and I don't know why (of course I have very little knowledge in lisp). Can some emacs-lisp experts helps me understand why the above code just does not work. Thanks a lot, Xavier