Subject: mailing-list for TeXmacs Users
List archive
From : "Corey Sweeney" <address@hidden>- To: address@hidden
- Cc: address@hidden, address@hidden
- Subject: Re: [TeXmacs] macros, passing paramaters to with, and using includes
- Date: Fri, 10 Mar 2006 12:37:21 -0600
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=bXHtcZFWottDHbw81UWQAvladhu/woo/ME8C5lTgwUDEDQoB6TyrSAbuQ5QeaKm4sF2KdDIlT/Lssz9xYjNYEJsAMF/9WdQFX1lkajS+xCUG22GePbVISYsRH6OQSj62Sssfoq/spnOQa6nL/u++yRPv7YzkfbgKCzDm9QVhU78=
quick note: I found my "arg" problem was that i *had* to enter args via the toolbar, and could not type \arg{enter}intro
I got a chance to try this:
<assign|include-with-intro-x|<macro|filename|intro-text|<with|intro|<arg|intro-text>|<extern|(lambda
(x) (tree-load-inclusion ((eval-string (string-append "tree-" (substring
"\<gtr\>" 4 5) "stree")) x)))|<arg|filename>>>>>
<include-with-intro-x|queries.tm|this is my introductary text>
This works on loading the include, and does properly display the "this is my introductary text" in the middle of the document. (which is just a "<value|intro-text>" in the document). So much progress has been made. However when I try to place the cursor inside "this is my introductary text" to edit it (inside the embedded document that is now displaying), it won't edit. It would edit when i made macros for my web page. Made a macro that would add borders, and you were automatically able to type on the inside, in a wysiwyg manner.
This also happens with the simpler version:
<assign|include-with-intro|<\macro|filename|intro>
<\with|intro-text|<arg|intro>>
<include|/home/corey/Course.network.for.dls/sql-queries.tm>
</with>
</macro>>
<include-with-intro|/home/corey/Course.network.for.dls/sql-queries.tm|in the
begining...>
Corey
P.S. Let me know if your gonna add something like that "> converter" to the texmacs scheme libraries. Also let me know what char you'd use, so I don't have to go change my files when I start using it.
On 3/8/06, Henri Lesourd <address@hidden> wrote:
Corey Sweeney wrote:
> I tried this:
>
> <assign|include-with-intro|<\macro|filename|intro>
> <\with|intro-text|intro>
> <include|/home/corey/sql- queries.tm <http://queries.tm>>
> </with>
> </macro>>
>
> However, the parameter "intro" in <with|intro-text|intro|... refuses
> to become a paramater from the macro (i.e. brown and italicized), and
> becomes the literal text "intro". Usually it happens automatically
> when I hit tab. Is there a way to force this to happen?
>
> I did try this first:
> <assign|include-with-intro|<\macro|filename|intro-text>
> <include|/home/corey/sql-queries.tm < http://queries.tm>>
> </macro>>
>
> But then the included file believed that intro-text was not defined at
> all.
>
>
I tried to do what you want ; I discovered that in any case, for some
obscure reason, the use of <include|...> inside a macro just doesn't
work :
[[
<macro|inc0|<macro|x|<include|<arg|x>>>
]]
Thus the solution to this problem is to use Scheme for loading the
file. After having a look in build-glue-basic.scm, one can see that
there is a Scheme primitive that can perform loading a .tm file,
namely (tree-load-inclusion). Thus we write :
[[
<macro|inc0|<macro|x|<extern|tree-load-inclusion|<arg|x>>>
]]
but it doesn't work, because before being a parameter
of (tree-load-inclusion), the <arg|x> must be converted
to the string type. Thus we (would) write :
[[
<macro|inc0|<macro|x|<extern|(lambda (x) (tree-load-inclusion
(tree->string x)))|<arg|x>>>
]]
But this one *still* doesn't work, due to f!@#$%g problems of
symbol encoding (for the symbol ">" in "tree->string"...), because
we want to write the Scheme code directly inside the TeXmacs <extern>
markup (the clean alternative solution would be to write a Scheme
plugin where we could safely write our Scheme functions. But then
we would have to deal with the current bug in the recently implemented
lazy evaluation of Scheme plugins ; I'm afraid that discussing this
would lead us even farther in designing hacks...).
Thus we need to trick it ; the following way works :
[[
<macro|inc0|<macro|x|<extern|(lambda (x) (tree-load-inclusion
((eval-string (string-append "tree-" (substring ">" 4 5) "stree"))
x)))|<arg|x>>>
]]
[it works because the ">" symbol is encoded by TeXmacs
as "<gtr>", thus {{ (substring ">" 4 5) }} is in fact
(after encoding) {{ (substring "<gtr>" 4 5) }}, thus
it yields ">" ; then the surrounding (string-append ...)
builds the name "tree->stree", and (eval-strings) turns
this name into the corresponding lambda ; finally, this
lambda is applied to the parameter 'x' ...].
Hope it helps :=P
Best, Henri
P.S. : Look at the two attached files, they contain an
implementation of <include-file|filename|comment> that
works, along with the different intermediary steps to
build it.
<TeXmacs|1.0.6>
<style|generic>
<\body>
<value|intro-text>
A
\;
\;
\;
Hello!
\;
\;
\;
B
</body>
<\initial>
<\collection>
<associate|language|english>
<associate|page-bot|1in>
<associate|page-even|1in>
<associate|page-odd|1in>
<associate|page-right|1in>
<associate|page-top|1in>
<associate|page-type|letter>
<associate|par-width|6.5in>
<associate|preamble|false>
</collection>
</initial>
<TeXmacs|1.0.6>
<style|generic>
<\body>
<hrule>
Initial include text :
<with|intro-text|12345|<include|hello.tm>>
<hrule>
Initial version of the inc0 macro (that doesn't work) :
<assign|inc0|<\macro|x>
<include|<arg|x>>
</macro>>
<\inc0>
hello.tm
</inc0>
<hrule>
2nd version of inc0 (that works) :
<assign|inc0|<macro|x|<extern|(lambda (x) (tree-load-inclusion
((eval-string (string-append "tree-" (substring "\<gtr\>" 4 5) "stree"))
x)))|<arg|x>>>>
<inc0|hello.tm>
<hrule>
Finally, the macro that does what we want :
<assign|include-file|<macro|file|intro|<with|intro-text|<arg|intro>|<inc0|<arg|file>>>>>
<include-file|hello.tm|This is my introductary text>
<hrule>
</body>
<\initial>
<\collection>
<associate|page-type|letter>
<associate|preamble|true>
</collection>
</initial>
--
((lambda (y) (y y)) (lambda (y) (y y)))
- macros, passing paramaters to with, and using includes, Corey Sweeney, 03/07/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/08/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Corey Sweeney, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Corey Sweeney, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Corey Sweeney, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/11/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Corey Sweeney, 03/15/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/11/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Corey Sweeney, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Corey Sweeney, 03/10/2006
- Re: [TeXmacs] macros, passing paramaters to with, and using includes, Henri Lesourd, 03/08/2006
Archive powered by MHonArc 2.6.19.