[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Restrict include to some backend
From: |
Clément Pit--Claudel |
Subject: |
Re: [O] Restrict include to some backend |
Date: |
Mon, 12 Sep 2016 23:14:31 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
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 <address@hidden
> <mailto:address@hidden>> wrote:
>
> Hello,
>
> Clément Pit--Claudel <address@hidden <mailto:address@hidden>> 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
>
signature.asc
Description: OpenPGP digital signature
- [O] Restrict include to some backend, Fabrice Popineau, 2016/09/06
- Re: [O] Restrict include to some backend, Clément Pit--Claudel, 2016/09/06
- Re: [O] Restrict include to some backend, Clément Pit--Claudel, 2016/09/06
- Re: [O] Restrict include to some backend, Nicolas Goaziou, 2016/09/06
- Re: [O] Restrict include to some backend, Clément Pit--Claudel, 2016/09/06
- Re: [O] Restrict include to some backend, Nicolas Goaziou, 2016/09/06
- Re: [O] Restrict include to some backend, Kaushal Modi, 2016/09/12
- Re: [O] Restrict include to some backend,
Clément Pit--Claudel <=
- Re: [O] Restrict include to some backend, Kaushal Modi, 2016/09/14
- Re: [O] Restrict include to some backend, Clément Pit--Claudel, 2016/09/14
- Re: [O] Restrict include to some backend, Kaushal Modi, 2016/09/14
Re: [O] Restrict include to some backend, Fabrice Popineau, 2016/09/06