[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texmacs-dev] How to create a convertor like texmacs->verbatim
From: |
Michael Lachmann |
Subject: |
[Texmacs-dev] How to create a convertor like texmacs->verbatim |
Date: |
Wed, 27 Jul 2011 02:19:46 +0200 |
I am trying to make it easier to work with R in TeXmacs. What often happens is
that in an interactive session I type
in many commands one after the other - each in its own input. at some point
everything works, and I'd like to just copy them all into a script, or maybe
into one multiline input.
So, I'd like to be able to select text, and copy just the R part. That would be
parts between
<|input>
and
</input>
Since I don't know scheme well, or maybe not at all, I thought to pipe
selection through an external program.
To do that, I first duplicated the end of
progs/convert/rewrite/init-rewrite.scm into my init-r.scm (the part that deals
with converting to verbatim), and modified verbatim to read verbatimR. I did
manage to have that pipe though an external program. But I am encountering a
strange problem:
When I select regular text, and do edit->copy to->verbatimR
all works well, the text I select is piped to the external program.
However, if I select several input/output fields from an R session, then I seem
to get nothing. Even for a simple expression with a formula in it, nothing is
copied.
Below is the code - this just duplicates the functionality of "verbatim", with
a new name "verbatimR". (i.e. no piping to external program, yet)
This code works for simple text, but not for complicated text, and I don't
understand why...
-------
(tm-define (texmacs->verbatimR x . opts)
(if (list-1? opts) (set! opts (car opts)))
(let* ((wrap? (== (assoc-ref opts "texmacs->verbatimR:wrap") "on"))
(enc (or (assoc-ref opts "texmacs->verbatimR:encoding") "iso-8859-1")))
(cpp-texmacs->verbatim x wrap? enc)))
(tm-define (verbatimR->texmacs x . opts)
(if (list-1? opts) (set! opts (car opts)))
(let* ((wrap? (== (assoc-ref opts "verbatimR->texmacs:wrap") "on"))
(enc (or (assoc-ref opts "verbatimR->texmacs:encoding") "iso-8859-1")))
(cpp-verbatim->texmacs x wrap? enc)))
(tm-define (verbatimR-snippet->texmacs x . opts)
(if (list-1? opts) (set! opts (car opts)))
(let* ((wrap? (== (assoc-ref opts "verbatimR->texmacs:wrap") "on"))
(enc (or (assoc-ref opts "verbatimR->texmacs:encoding") "iso-8859-1")))
(cpp-verbatim-snippet->texmacs x wrap? enc)))
(define-format verbatimR
(:name "VerbatimR")
(:suffix "txtR"))
(converter verbatimR-document texmacs-tree
(:function-with-options verbatimR->texmacs)
(:option "verbatimR->texmacs:wrap" "off")
(:option "verbatimR->texmacs:encoding" "utf-8"))
(converter verbatimR-snippet texmacs-tree
(:function-with-options verbatimR-snippet->texmacs)
(:option "verbatimR->texmacs:wrap" "off")
(:option "verbatimR->texmacs:encoding" "utf-8"))
(converter texmacs-tree verbatimR-document
(:function-with-options texmacs->verbatimR)
(:option "texmacs->verbatimR:wrap" "off")
(:option "texmacs->verbatimR:encoding" "utf-8"))
(converter texmacs-tree verbatimR-snippet
(:function-with-options texmacs->verbatimR)
(:option "texmacs->verbatimR:wrap" "off")
(:option "texmacs->verbatimR:encoding" "utf-8"))
------------
Does anyone have an idea what the problem is?
Thanks,
Michael
- [Texmacs-dev] How to create a convertor like texmacs->verbatim,
Michael Lachmann <=
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Michael Lachmann, 2011/07/27
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Michael Lachmann, 2011/07/27
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Miguel de Benito Delgado, 2011/07/27
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Michael Lachmann, 2011/07/27
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Michael Lachmann, 2011/07/27
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Sam Liddicott, 2011/07/28
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Miguel de Benito Delgado, 2011/07/29
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Michael Lachmann, 2011/07/29
- Re: [Texmacs-dev] How to create a convertor like texmacs->verbatim, Miguel de Benito Delgado, 2011/07/29