mailing-list for TeXmacs Users

Text archives Help


Re: Conditional definition of Scheme functions and typesetting of trees


Chronological Thread 
  • From: Massimiliano Gubinelli <address@hidden>
  • To: Giovanni Piredda <address@hidden>
  • Cc: address@hidden
  • Subject: Re: Conditional definition of Scheme functions and typesetting of trees
  • Date: Tue, 17 Nov 2020 22:32:53 +0100

Dear Giovanni,

> On 17. Nov 2020, at 19:25, Giovanni Piredda <address@hidden> wrote:
>
>
> I have defined a Scheme function with the following:
>
> (tm-define (unitSpacer) ; default, will be used in regular text
> `(hspace "0.5spc"))
> (tm-define (unitSpacer)
> (:require (in-math?))
> "*")
>
> As far as I understand, the first definition is the default and it is
> overridden by the second when I am in math.
>
> In my tests, this happens only in open documents. At the first opening of a
> document, only the first definition is used. Does anyone have a hint on
> what is happening? Developers ;-) ?
>

You should give more info. In which sense the macros "are used"? Scheme
macros can be evaluated in two ways, essentially: either due to input from
the user (e.g. keypress) or because you put some \extern markup in the
document and TeXmacs is typesetting it, in particular evaluating the markup
language and arrives to your macro.

I think scheme code in \extern markup is evaluated every time is needed, you
do not have much control of that.

Can you explain how you use those macros?

> ===
>
> Second issue.
>
> In math mode, the program I wrote outputs groups of letters, each wrapped
> in a <with|math-font-shape|right primitive, and interleaved with the
> character "*".
>
> Example of output, copied from the terminal using (display ...)
>
> <tree 2 <with|math-font-shape|right|kg>*<with|math-font-shape|right|m>>
>
> I call this from a TeXmacs macro in math mode and I get a typeset output
> where the asterisk appears as such (while I would like it to be interpreted
> as an implicit multiplication)
>

I do not think that this output can be read again, especially from scheme. If
you really want to have a scheme description of some markup then you need to
select the markup, do a "Copy to TeXmacs Scheme" and then a "Paste to
Verbatim" to obtain the corresponding ASCII representation of the scheme
code.
I obtain something of the form

(concat (text "a") "*" (text "b"))

and if I define

(define (my-func) '(concat (text "a") "*" (text "b")))

then by putting <extern|my-func> in an equation, I obtain what I expect.

> If I copy the output from the terminal, strip the outermost <tree primitive
> and place it inside a math primitive (opening the .tm file with a text
> editor) the asterisks do not appear (as I thought they shouldn't).
>
> Again, suggestions?
>
>

Max





Archive powered by MHonArc 2.6.19.

Top of page