From: "Clément Pit--Claudel" <clement.pit@gmail.com>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Restrict include to some backend
Date: Mon, 12 Sep 2016 23:14:31 -0400 [thread overview]
Message-ID: <475d2764-542a-6bb0-bc3a-ff7fd7294097@gmail.com> (raw)
In-Reply-To: <CAFyQvY22fpijEsMN7sHsaOz6Lv8k8NKOKOcUud87H3dCmNmT2Q@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1775 bytes --]
Sure thing :) Here it is:
(defun ~/filter-begin-only (type)
"Remove BEGIN_ONLY %s blocks whose %s doesn't equal TYPE.
For those that match, only remove the delimiters."
(goto-char (point-min))
(while (re-search-forward " *#\\+BEGIN_ONLY \\([a-z]+\\)\n" nil t)
(let ((begin-block-type (match-string-no-properties 1))
(begin-from (match-beginning 0))
(begin-to (match-end 0)))
(re-search-forward " *#\\+END_ONLY \\([a-z]+\\)\n")
(let ((end-block-type (match-string-no-properties 1))
(end-from (match-beginning 0))
(end-to (match-end 0)))
(cl-assert (string= begin-block-type end-block-type))
(cond
((string= type begin-block-type)
(delete-region end-from end-to)
(delete-region begin-from begin-to))
(t
(message "Removing %s block" begin-block-type)
(delete-region begin-from end-to)))))))
I call this before calling `org-latex-export-to-latex'. The syntax it accepts is a bit weird:
#+BEGIN_ONLY tex
…
#+END_ONLY tex
Please share improvements :)
Cheers,
Clément.
On 2016-09-12 23:10, Kaushal Modi wrote:
> I am looking forward to the BEGIN_ONLY/END_ONLY kind of solution too.
>
> @Clément Would you please share your draft solution?
>
> Thanks.
>
> On Tue, Sep 6, 2016 at 5:39 PM Nicolas Goaziou <mail@nicolasgoaziou.fr <mailto:mail@nicolasgoaziou.fr>> wrote:
>
> Hello,
>
> Clément Pit--Claudel <clement.pit@gmail.com <mailto:clement.pit@gmail.com>> writes:
>
> > Do you think so? Wouldn't BEGIN_ONLY … END_ONLY work? It would be similar to BEGIN_EXPORT, right?
> > Or it could even be an option to begin_export?
>
> --
>
> Kaushal Modi
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-09-13 3:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 5:13 Restrict include to some backend Fabrice Popineau
2016-09-06 13:59 ` Clément Pit--Claudel
2016-09-06 14:59 ` Clément Pit--Claudel
2016-09-06 15:58 ` Nicolas Goaziou
2016-09-06 18:15 ` Clément Pit--Claudel
2016-09-06 20:32 ` Nicolas Goaziou
2016-09-13 3:10 ` Kaushal Modi
2016-09-13 3:14 ` Clément Pit--Claudel [this message]
2016-09-14 11:55 ` Kaushal Modi
2016-09-14 12:21 ` Clément Pit--Claudel
2016-09-14 12:33 ` Kaushal Modi
2016-09-06 20:10 ` Fabrice Popineau
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=475d2764-542a-6bb0-bc3a-ff7fd7294097@gmail.com \
--to=clement.pit@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=kaushal.modi@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).