texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texmacs-dev] yes! Re: render-inactive Re: Manual closures


From: Sam Liddicott
Subject: [Texmacs-dev] yes! Re: render-inactive Re: Manual closures
Date: Mon, 28 May 2012 06:12:09 +0100

Rewrite-inactive works only when called from a macro.

This macro lets me define a macro and also show the definition in one go:
<assign|show|<macro|x|<surround|<arg|x>||<rewrite-inactive|<arg|x>|recurse*>>>>

I think the recurse* is wrong where I put it, it doesn't seem to matter what goes there

Sam

On Mon, May 28, 2012 at 5:29 AM, Sam Liddicott <address@hidden> wrote:
I've found that I can't un-render an inactive& block because <arg|x> is rendered as x, in a different colour, and picking out the with|...|color|brown|... is more hacky than I want to get.

In scheme mode "arg" is emitted but so is lots of other text that is hard to filter out.

So I'm back to making render-inactive work

Sam

On Thu, May 24, 2012 at 8:25 AM, Sam Liddicott <address@hidden> wrote:
I thought I'd try implementing closures in texmacs macros instead.

I want a macro that can be provided a list of variables and produce a new macro that is a "with" block of those variables, and then evaluates the parameters.

The produced macro would be of this form (although possibly I would use eval instead of compound):
<xmacro|x|<with|...|...|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>

It seems it would work as this example shows:
<xmacro|x|<with|a|AHA|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>

The producing macro must fill in ... according to the arguments it is passed, indicating the variables and their values to be preserved.

My first attempt at the constructing macro is:
<assign|enclose|<xmacro|w|<quasi|<xmacro|x|<quasi|<with|<unquote*|<quote-arg|w>>|<compound|<unquote*|<quote-arg|x>>>>>>>>>

Note the nested quasi. I need the first unquote* to be expanded by the first quasi, and the second quasi to be preserved along with the second unquote*, but nesting makes this hard, because the first quasi encloses the second quasi which encloses both unquote*

<assign|enclose|<xmacro|w|<quasi|<xmacro|x|<with|<unquote*|<quote-arg|w>>|<quote|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>>>>>

otherwise the idea works as this hard-wired version shows:
<assign|enclose|<xmacro|w|<quasi|<xmacro|x|<with|<unquote*|<quote-arg|w>>|Hello <value|a> there>>>>>

That hard wired version fixes the body, and can be executed with:
<assign|tc|<enclose|a|HEE HEE>>
<tc>

I tried deferring the body execution into an xcompound macro, like this:
<assign|xcompound|<xmacro|x|<quasi|<compound|<unquote*|<quote-arg|x>>>>>>

<assign|enclose|<xmacro|w|<quasi|<xmacro|x|<with|<unquote*|<quote-arg|w>>|<xcompound|<arg|x>>>>>>>

But then texmacs just segfaults. I guess to call xcompound still needs to be using quasi unquote* quote-arg

Can anyone help me preserve SECOND quasi and unquote* in the emitted macro while still allowing the FIRST unquote* in the with block to be expanded?

Sam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]