mailing-list for TeXmacs Users

Text archives Help


Re: Conditional definition of Scheme functions and typesetting of trees


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

I am going to answer your previous message (thanks for that by the way) but before that: I do not follow the explanation in this message on the in-math? predicate, I have an idea of what you might mean, but maybe the idea is wrong :-)

Let me write it down here.

Starting from:

"As I open the file, where I have the macro (which calls Scheme code via extern) both inside math and outside math, they are all executed as if in text mode.

If I edit one of them, now the predicate in-math? has effect."

you say that when I open the file TeXmacs is only typesetting (and therefore uses the default function, as (in math?) returns always #f), but when I am editing TeXmacs knows what I am editing and lets Scheme know. Is it that?

The follow-up question in this case is how can I obtain what I want, that is a different function being called ever time the macro is executed, that is also at the opening of the file. The aim seems sensible to me - typesetting something in one way when in math and in one way when in text (as I said above, now it is working when I write/edit, it is not working if I close and open again a document).

Besides, doing Document->Update all hangs the document for a one/two minutes (Ubuntu 20.10, I observed it in another document too), makes the macros work well (upright in math, no asterisks, so it is recognizing the math), which is pretty surprising, but destroys the page setup (margins are lost).

G.


On 17.11.20 22:50, Massimiliano Gubinelli wrote:
Going back to your attempt: I think that the predicate in-math? cannot be
used to check whether the typesetter is working on an equation or not. No
information is passed to Scheme about the internal status of the typesetter
when you call a \extern markup. You can pass informations only via
parameters. So your unitSpacer has no way to know if the evaluation is inside
some math markup or not.

The predicates in-math?, etc.. are just to check if the editor is in text,
prog, or math mode, for example. Thats is completely separate on the status
of the typesetter.

HTH,

Max



On 17. Nov 2020, at 19:25, Giovanni Piredda <address@hidden> wrote:

I post this here because I think that while being about Scheme in TeXmacs is
still of general interest. I have found a way of circumventing both issues
(which may be ok, in case I will ask about this in another post) but I am
curious to know the reason of the behaviours I observe.

First issue.

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 ;-) ?

===

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)

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?





Archive powered by MHonArc 2.6.19.

Top of page