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).