From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Klein Subject: Re: Wrapping section within LaTeX environment Date: Wed, 16 Dec 2015 04:41:25 +0100 Message-ID: <5670DD65.9020402@roklein.de> References: <566D79E0.3030704@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a92yG-0002ej-E0 for emacs-orgmode@gnu.org; Tue, 15 Dec 2015 22:41:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a92yD-0006K9-7W for emacs-orgmode@gnu.org; Tue, 15 Dec 2015 22:41:44 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:65355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a92yC-0006Jy-U7 for emacs-orgmode@gnu.org; Tue, 15 Dec 2015 22:41:41 -0500 In-Reply-To: <566D79E0.3030704@gmail.com> 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: Xavier Garrido , "emacs-orgmode@gnu.org" Hi On 12/13/2015 03:00 PM, Xavier Garrido wrote: > 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 If I read this right, you are writing the \end{correction} when the headline function is called for the /following/ headline. Then the (when...) should be outside the (if..) (because the string-match condition isn't valid anymore). Of course you still get issues when two consecutive sections are tagged for correction -- and there has to be a follow-up heading to the one tagged for correction. Your code from your second mail does the job perfectly, but I've been intrigued in figuring this one out :) Best regards Robert > > 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 >