From: Xavier Garrido <garrido@lal.in2p3.fr>
To: Robert Klein <roklein@roklein.de>,
"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Wrapping section within LaTeX environment
Date: Wed, 16 Dec 2015 09:48:21 +0100 [thread overview]
Message-ID: <56712555.5090609@lal.in2p3.fr> (raw)
In-Reply-To: <5670DD65.9020402@roklein.de>
Hi Robert,
Le 16/12/2015 04:41, Robert Klein a écrit :
> 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).
As far as I understand emacs-lisp, the (when ...) is within the else so
when the string match condition is not valid. That's why I do not
understand why this complicated filter was not working. Anyway, my
second try was much better and easier to understand (I also apply
suggestion from John to avoid inclusion of "correction" section title).
Thanks for having a look,
Xavier
--
|
|__ GARRIDO Xavier Laboratoire de l'Accélérateur Linéaire
/\ NEMO Université Paris-Sud 11
/--\ garrido@lal.in2p3.fr UMR 8607
| garrido@in2p3.fr Batiment 200
|__ +33 1.64.46.84.28 91898 Orsay Cedex, France
prev parent reply other threads:[~2015-12-16 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56712555.5090609@lal.in2p3.fr \
--to=garrido@lal.in2p3.fr \
--cc=emacs-orgmode@gnu.org \
--cc=roklein@roklein.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).