Subject: mailing-list for TeXmacs Users
List archive
From : Joris van der Hoeven <address@hidden>- To: address@hidden
- Subject: Re: [TeXmacs] My first non-trivial macro
- Date: Tue, 4 Jul 2006 19:32:17 +0200
On Sun, Jul 02, 2006 at 07:25:34PM +0200, Henri Lesourd wrote:
> >However, I am having trouble creating a macro that builds a file name
> >and then includes it. I would like to do this because I am working on
> >course notes for an introductory CS course that can be delivered in
> >either C++ or Python (we need a multi-paradigm language), and I'd like
> >to have one central text in which I define the variable
> >coding-language to be, say, Python, and then write something like
> ><in-code|foo> to include the file Python/code/foo.py where I want an
> >example. Then by switching coding-language to C++ we would then be
> >including the file C++/code/foo.py.
> >
> >I have tried the following (copied right from my document while in
> >"Edit source tree" mode, and then formatted for easy reading -- delete
> >all spaces, tabs, and newlines to get exactly what came from TeXmacs):
> >
> > <assign|code-file|
> > <macro|basename|
> > <value|coding-language>
> > /code/
> > <arg|basename>
> > <case|<equal|<value|coding-language>|Python>|.py|
> > <equal|<value|coding-language>|C++>|.cc>>>
> >
> >I can use this successfully to build the desired file name:
> >
> > <code-file|temp-test>
> >
> >gives me
> >
> > Python/code/temp-test.py
> >
> >(I had to re-type that, since copying out of the document in normal
> >mode just gave me exactly what I got in "Edit source tree" mode). I
> >can use a regular
> >
> > <include|
> > Python/code/temp-test.py>
> >
> >to view the file, but when I use
> >
> > <include|
> > <code-file|temp-test>>
> >
> >I just get a blank line rather than the file. Needless to say, my
> >in-code macro that does this doesn't work either.
> >
> I just tried what you describe, and it seems that the <include>
> macro doesn't tolerate anything other than constant urls as a
> parameter.
Yes, that is indeed a problem, which I have just corrected on the CVS version.
Notice however that you also should use the "merge" primitive in order to
concatenate strings.
> >P.S. Is there any way to tell TeXmacs that I want to create a macro
> >but be given a warning if that name is already in use? This would be
> >like \newcommand in LaTeX. I have been just trying out names to see if
> >they are already taken, but of course that is no defense against
> >collisions with other style files I may choose to work with in the
> >future.
You have the "provides" primitive for that.
When entering a command with \, notice also that
only existing macros, commands, symbols, etc. are recognized.
Best wishes, Joris
- Re: [TeXmacs] My first non-trivial macro, Henri Lesourd, 07/02/2006
- Re: [TeXmacs] My first non-trivial macro, Joris van der Hoeven, 07/04/2006
- Re: [TeXmacs] My first non-trivial macro, David G. Wonnacott, 07/08/2006
- Re: [TeXmacs] My first non-trivial macro, Henri Lesourd, 07/09/2006
- Re: [TeXmacs] My first non-trivial macro, David G. Wonnacott, 07/11/2006
- Re: [TeXmacs] My first non-trivial macro, Henri Lesourd, 07/09/2006
- Re: [TeXmacs] My first non-trivial macro, David G. Wonnacott, 07/12/2006
- Re: [TeXmacs] My first non-trivial macro, David G. Wonnacott, 07/08/2006
- Re: [TeXmacs] My first non-trivial macro, David G. Wonnacott, 07/06/2006
- Re: [TeXmacs] My first non-trivial macro, Joris van der Hoeven, 07/04/2006
Archive powered by MHonArc 2.6.19.