On Tue, Oct 2, 2012 at 12:53 PM, Michael Lachmann
<address@hidden> wrote:
I'm working with fangle in TeXmacs, and I'm trying to make it easier
to extract chunks...
currently I use the following command:
--
(define (fangle-extract part)
(with file (url->unix (url-temp))
(with file2 (if extract-remote (url->unix (url-temp)) part)
(export-buffer file)
(with res (system
(string-append "fangle -R " part " " file " >" file2
" 2>/tmp/fang.err")
)
(with res2 (if (and extract-remote (= res 0))
(system (string-append
"scp " file2 " " rem-path "/" part ) )
0 )
(delete-file file)
(if extract-remote (delete-file file2) )
(if (and extract-remote (= res 0)) (list res res2)
(if (= res 0) "ok" (eval-system "cat /tmp/fang.err") ))
) ) ) ) )
-- (this is fairly bad scheme code, I'm still learning -but it works for me...)
and then, I define
(define extract-remote #t) or (define extract-remote #f)
depending on if I want to copy the result to a remote location,
and
(define rem-path "bionc02:projects/Neandertal/resampling")
For the remote path.
Then I insert a scheme session in the file, and issue the command:
Scheme] (fangle-extract "name-of-chunk.C")
Which will either extract the chunk to TeXmacs current directory, or
to a remote directory (I work a lot on remote servers)
What I'd like to do is for the chunk name to be determined automatically.
What I thought is that after or in a chunk, that chunk will be
exported, and that one
can somehow define a chunk to be the "main" chunk, and there will be a
command to export that.
Miguel from the TeXmacs-dev mailing list said:
> However, you have the choice of redefining your nf-chunk macro to set an
> environment variable (say, "current-nf-chunk" to the value you want, then
> read that variable at any point in your document to decide where you are.
I'm not totally sure how to do that... do I just add
<assign|current-nf-chunk|name> inside nf-chunk, or do I need to do
other things?
Yes, that is how you do it. You would need to be careful where you put it as it evaluates to an implied <concat> block, but you could put it anywhere where output already was, probably where the chunk header is emitted (but not in the macro that does the chunk header)
I also thought about some system where you can unfold nf-ref to what
they represent, or open all such references in a chunk. I think it
should be fairly easy to do this in scheme, so we'd have some version
of fangle in scheme.
This would be great.
One question that I had was that if you wouldn't use scheme, but the
original fangle, it would be nice if I could ask fangle to extract
just the 3rd part of a multipart chunk - because when I am near such a
part, I'd want to just extract it, and not the whole document.
There was a notation for this for includes so that a function definition could be in the first chunklet and the body in subsequent chunklets. You would then include the first chunklet only in the header file chunk, like <<blah-function[0]>>
It would be reasonable to include this support in fangle too.
Sam