texmacs-dev
[Top][All Lists]
Advanced

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

Re: [Texmacs-dev] macros with variable number of arguments?


From: Joris van der Hoeven
Subject: Re: [Texmacs-dev] macros with variable number of arguments?
Date: Wed, 2 Oct 2013 22:37:22 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Andrey,

Sorry for my very late reply.

On Sun, May 19, 2013 at 09:17:20PM +0700, address@hidden wrote:
> Suppose I have
> 
> (tm-define (name . args) <body>)
> 
> This seems OK. But how can I use it from the editor? In the preamble
> I can set
> 
> <assign|name|<macro|name|arg|<extern|name|<arg|arg>>>>
> 
> for 1 argument. Then I can call the scheme function with 1 argument
> (this works). But how can I do the same for any number of arguments?

This could be done using the 'quasi' and 'unquote'/'unquote*' primitives,
but I do not recommend this.

Instead, it is better to define a function with a fixed arity in Scheme,
and an xmacro in TeXmacs (I assume that you want a TeXmacs macro with
a variable number of arguments).

Here are some examples in the current SVN version:

Castafiore:src vdhoeven$ tm-search --tm xmacro | grep extern
TeXmacs/packages/header/title-base.ts:146:   
<assign|doc-data|<xmacro|args|<extern|doc-data|<quote-arg|args>>>>
TeXmacs/packages/header/title-base.ts:202:   
<assign|author-data|<xmacro|args|<extern|author-data|<quote-arg|args>>>>
TeXmacs/packages/header/title-base.ts:283:   
<assign|abstract-data|<xmacro|args|<extern|abstract-data|<quote-arg|args>>>>
TeXmacs/packages/standard/std-pattern.ts:80:   
<assign|select|<xmacro|x|<extern|ext-select|<arg|x|0>|<quote-arg|x>>>>
TeXmacs/packages/test/macro-editor.ts:31:   
<assign|edit-macro|<xmacro|args|<extern|ext-edit-macro|<quote-arg|args>>>>
TeXmacs/styles/revtex/aip.ts:379:   
<assign|doc-data|<xmacro|args|<with|par-columns|1|<extern|doc-data|<quote-arg|args>>>>>
TeXmacs/styles/revtex/aps.ts:364:   
<assign|doc-data|<xmacro|args|<with|par-columns|1|<extern|doc-data|<quote-arg|args>>>>>

Please also notice that it is often better to use 'quote-arg'
instead of 'arg' when passing macro arguments to the external Scheme function.
Although there is usually no difference in the rendering, there may be
problems with cursor accessability when using 'arg'.

Best wishes, --Joris



reply via email to

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