emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Wrapping section within LaTeX environment
@ 2015-12-13 14:00 Xavier Garrido
  2015-12-14  1:39 ` John Kitchin
  2015-12-16  3:41 ` Robert Klein
  0 siblings, 2 replies; 6+ messages in thread
From: Xavier Garrido @ 2015-12-13 14:00 UTC (permalink / raw)
  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-12-16  8:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13 14:00 Wrapping section within LaTeX environment Xavier Garrido
2015-12-14  1:39 ` John Kitchin
2015-12-14  7:06   ` Xavier Garrido
2015-12-14 11:32     ` John Kitchin
2015-12-16  3:41 ` Robert Klein
2015-12-16  8:48   ` Xavier Garrido

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).