emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Robert Klein <roklein@roklein.de>
To: Xavier Garrido <xavier.garrido@gmail.com>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Wrapping section within LaTeX environment
Date: Wed, 16 Dec 2015 04:41:25 +0100	[thread overview]
Message-ID: <5670DD65.9020402@roklein.de> (raw)
In-Reply-To: <566D79E0.3030704@gmail.com>

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
> 

  parent reply	other threads:[~2015-12-16  3:41 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 [this message]
2015-12-16  8:48   ` Xavier Garrido

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=5670DD65.9020402@roklein.de \
    --to=roklein@roklein.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=xavier.garrido@gmail.com \
    /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).