mailing-list for TeXmacs Users

Text archives Help


Re: Macro for inserting blocks of code won't work properly


Chronological Thread 
  • From: Massimiliano Gubinelli <address@hidden>
  • To: Nicolas Chouvalidzé <address@hidden>
  • Cc: texmacs-users <address@hidden>
  • Subject: Re: Macro for inserting blocks of code won't work properly
  • Date: Fri, 27 Nov 2020 00:04:56 +0100

Yes, TeXmacs macro are great. And when you realise that the number of primitives is quite small (see manual) and that all the rest is coded via macro, then is even more interesting.

I should say that I do not understand precisely why your first attempt do not work. Indeed the \numbered macro by itself allows editing of the argument, so in my understanding it should work also wrapped inside other macros. For some reason it doesn't. It would be nice if Joris can tell us why. :)

Anyway the trick in my macro is \datoms which allow to run a macro when the typesetter is going thru the material, here in particular the macro is run for every line. Is not a very nice approach because can break very easily. But ok, was my 5 min attempt.

Max


On 26. Nov 2020, at 23:31, Nicolas Chouvalidzé <address@hidden> wrote:

Dear Massimiliano,

Thank you for your solution ! I works great on my computer.
I have yet to understand fully how your macros work precisely, but I think it will become clearer with experience. I have just discovered the existence of macros, and I have to admit that they really revolutionised my usage of TeXmacs.

I also ignored the existence of the official Twitter account : it seems there are many interesting tips over there, and I will definitely check it out more frequently.

Thank you for your help,
Nicolas.


Le jeu. 26 nov. 2020 à 22:27, Massimiliano Gubinelli <address@hidden> a écrit :
I made a small presentation out of this example: 



:)
enjoy.
m


On 26. Nov 2020, at 21:29, Massimiliano Gubinelli <address@hidden> wrote:

It seems to be a problem with the numbered macro. Indeed if I remove it leaving the python-code macro alone it works for me.
Maybe TeXmacs cannot deal with editing arguments for extern macros.
I coded  something that works using \datoms. You can find it in the attached file.

Best,
Max

<line-numbers-and-table.tm>

On 26. Nov 2020, at 19:34, Nicolas Chouvalidzé <address@hidden> wrote:

Dear Texmacs users,

I want to create a macro for inserting blocks of code in python, with the following characteristics :
  • a block with a grey background, to separate the code from the rest of the text in the document
  • numbered lines
  • two columns : one for the code and one for comments about the code (putting the comments in a second column allows to make all comments aligned)
Following the instructions given in the Jolly Writer, I created the block I wanted in my document, and then copied it into a new macro. I specified two entries : one for the code in the first column (left) and a second for the comments which will go in the second column (right).

When I use the macro, however, I can only add text in the column intended for commentaries. The column intended for the code itself (the left one) displays the name of the variable, and does not allow further input.
I find it quite weird that one part of the macro works and the other does not, although they should be exactly the same...

I attached the file to this email so that you can look at how the macro works. I would really appreciate any help.

Thank you very much for your time,
Nicolas.
<Environnement python.tm>






Archive powered by MHonArc 2.6.19.

Top of page