mailing-list for TeXmacs Users

Text archives Help


Re: [TeXmacs] How do I create a multi-argument macro?


Chronological Thread 
  • From: Sam Liddicott <address@hidden>
  • To: address@hidden
  • Subject: Re: [TeXmacs] How do I create a multi-argument macro?
  • Date: Thu, 1 Mar 2012 08:07:31 +0000
  • Authentication-results: mr.google.com; spf=pass (google.com: domain of address@hidden designates 10.182.8.69 as permitted sender) smtp.mail=address@hidden



On Thu, Mar 1, 2012 at 12:33 AM, Karl Hegbloom <address@hidden> wrote:
Shortly after I posted saying I'd gotten it to work... and it really did work... Then after I closed TeXmacs and restarted it, the same macro did not work any more! It is very frustrating.


In what way did it no longer work? This can happen if your macro is defined in more than one file, especially if an old version is cached. "Tools -> Update -> Styles" menu command may fix this.

 
Q: Is there a difference between using "merge" inside the macro, with one macro argument consumed for each argument of the "merge" form, vs one long in-line statement, without the "merge"?

I didn't understand the question, you would need to post some examples to help me see what you mean.

Here is a multi-arg macro I defined to make insertion of "key" renderings easier by calling "key" for each argument but inserting a space between each output.
(The points marked **** should contain a single space, otherwise there are no spaces in the macro)

<assign|keys|<xmacro|args|<with|c|0|m|<length|<map-args|identity|tuple|args>>|<while|<less|<value|c>|<value|m>>|<if|<greater|<value|c>|0>|<if|<greater|<length|<arg|args|<value|c>>>|1>|****
>><key|<arg|args|<value|c>>><if|<less|<plus|<value|c>|1>|<value|m>>|<if|<and|<greater|<length|<arg|args|<value|c>>>|1>|<not|<greater|<length|<arg|args|<plus|<value|c>|1>>>|1>>>|****
>><assign|c|<plus|<value|c>|1>>>>>>

I found it hard to get the number of arguments and eventually settled for this way which worked without crashing:
<length|<map-args|identity|tuple|args>>

To use the macro I type:
\keys ENTER a CMD-right b CMD-right ENTER

I can press CMD-right as many times as I need to enter additional arguments.



Archive powered by MHonArc 2.6.19.

Top of page