Re: [NTG-context] How to write readable source files?

2021-05-29 Thread Hans Hagen

On 5/29/2021 8:29 PM, Nicola wrote:


So, is it correct that the XML files are automatically generated from
the source code, and kept in sync with it? If so, how is that done? Or


the xml files are maintained by Wolfgang who knows context inside out 
and has ways to keep track of additions (although some commands became 
obsolete when we went mkiv, like those dealing with font encoding and 
so) we're mostly talking about additions



are they manually curated? I'd be willing to contribute to make progress
on the MetaFun part.


ok, but let's first wait what Wolfgang says .. we probably first have to 
check if we need to add some to the xml definitions


(btw, the lmt metapost commands i.e. the key/value macros fit in well in 
the optional argument appeoach, the more low level ones more resemble 
the low level context commands for which we have specific definitions)



Whatever you think is more appropriate... Provided that it can be parsed
automatically.

so what does vim expect? isn't there some kind of common format for lexers?

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to write readable source files?

2021-05-29 Thread Nicola
On 2021-05-29, Hans Hagen  wrote:
> On 5/29/2021 5:03 PM, Nicola wrote:
>>> these lists are generated by mtx-interface so we can add more if needed
>>
>> Could you please elaborate on the (automatic?) data flow from ConTeXt's
>> source files to data files for each application? Is it:
>>
>> source code -> XML -> .lua -> mtx-interface -> data?
>>
>> In particular, it is not clear to me how i-*.xml files are related to
>> mtx-interface, as the latter does not use them directly, AFAICS.
>
> for sure it does

Ok, my cursory look was then… too cursory. I'll dig better.

>> Anyway, mtx-interface seems exactly what I am looking for, and I would
>> like to use it to generate ConTeXt keywords for Vim. Can I patch that
>> script?
>
> basically we only need
>
> function flushers.vim(collected)
> end

Ok.

>> For MetaFun keywords I don't know yet: do those XML files contain enough
>> information about the content of all mp-* source files? E.g., the fact
>> that `hlingrid` is a def? Looking at the Scite files, I see only
>> internals and commands, and they seem to cover only the "main" MetaFun
>> names.
>
> it is still on the agenda to make xml files for metafun but there is no
> timeline for that

So, is it correct that the XML files are automatically generated from
the source code, and kept in sync with it? If so, how is that done? Or
are they manually curated? I'd be willing to contribute to make progress
on the MetaFun part.

> just look at the files in the scite path ... much info is available, for
> context it comes from the xml files, for the tex engine and meta* it
> comes from mult* lua files

Ok, I'll look there.

> adding more detail (not sure if distinguishing between def and vardef
> makes sense ... we more use the 'primitive', 'lowlevel', 'interface'
> kind of grouping

Whatever you think is more appropriate... Provided that it can be parsed
automatically.

Nicola

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Synctex broken in LMTX ?

2021-05-29 Thread Nicola
On 2021-05-16, Hans Hagen  wrote:
> now, here is something to think about:
>
> >mtxrun --script synctex --list
> mtx-synctex | invalid synctex log file %a

I've got a positive feedback, and an agenda, from Richard Koch for
supporting ConTeXt's syncing mechanism (including the PDF->TeX
direction, which hopefully will land soon in beta, if it hasn't
already).

Just one clarification: does this work only for ConTeXt, or is it based
on LuaTeX regardless of what is being typeset?

Nicola


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to write readable source files?

2021-05-29 Thread Hans Hagen

On 5/29/2021 5:03 PM, Nicola wrote:

On 2021-04-25, Hans Hagen  wrote:

If there is a way to automatically get a list of all ConTeXt commands
and options (and, ideally, MetaFun defs, types, and other keywords), I'd
be happy to improve omni-completion for ConTeXt in Vim.

All is in xml files (i-*.xml) in the distribution maintained by
Wolfgang. We ship with this for editors:


dir t:\texmf\context\data


04/21/2021  11:40 AM  scite
04/21/2021  11:40 AM  textadept
04/21/2021  11:40 AM  texworks
04/21/2021  11:40 AM  vscode

these lists are generated by mtx-interface so we can add more if needed


Could you please elaborate on the (automatic?) data flow from ConTeXt's
source files to data files for each application? Is it:

source code -> XML -> .lua -> mtx-interface -> data?

In particular, it is not clear to me how i-*.xml files are related to
mtx-interface, as the latter does not use them directly, AFAICS.


for sure it does

in the early days of context mkii we had \startsetups kind of 
definitions that got filtered from the source but when xml support was 
built that moved to an xml file


then Wolfgang did an excellent job on checking each xml snippet and 
added many more and these i-* files showed up, we extended the xml a 
bit, redid the rendering of these lists etc


wolfgang is in charge of this so when something specific in the files is 
needed ...



Anyway, mtx-interface seems exactly what I am looking for, and I would
like to use it to generate ConTeXt keywords for Vim. Can I patch that
script?


basically we only need

function flushers.vim(collected)
end


For MetaFun keywords I don't know yet: do those XML files contain enough
information about the content of all mp-* source files? E.g., the fact
that `hlingrid` is a def? Looking at the Scite files, I see only
internals and commands, and they seem to cover only the "main" MetaFun
names.


it is still on the agenda to make xml files for metafun but there is no 
timeline for that


now, when it comes to highlighting, the reference is the scite one 
(which supports several of the languages that we use, and also supports 
mixed lua/mp/tex/... lexing) ... right from the start the way it shows 
up in an editor determined how the user interface evolved ... believe it 
or not, but for a long time we used texedit (written in modula, was 
pretty ok in 640K mem, also fast and one could scroll files in the 
sidebar and see them instantly; it used the character based windowing 
i'd written as a student for terminals connected to a dec vax .. just 
for fun ... i'm that old) ... when modula disappeared i actually rewrote 
that one in perl/tk and it still works but then decided to use scite


anyway, so scite is still my reference (i looked to vscode but seeing 
all this extra stuff, the need for 'servers', the lack of simply running 
a command based on suffix ... not now)


that said, we can support whatever editor one uses makes much sense (one 
should really use the editor, word processor, operating system etc one 
feels most comfortable with) so just make a prototype (or tell me what 
kind of lists you need, because it's rather trivial to generate them)



I have used a custom script in the past for fine-grained keyword
extraction from MetaFun's source code. By fine-grained, I mean that the
output contains information about the kind of keyword (def, primary def,
vardef, constant, variable, etc.) I could update it to Lua and mp-*.mpxl
if that interests you—unless that has already been done, of course.
just look at the files in the scite path ... much info is available, for 
context it comes from the xml files, for the tex engine and meta* it 
comes from mult* lua files


adding more detail (not sure if distinguishing between def and vardef 
makes sense ... we more use the 'primitive', 'lowlevel', 'interface' 
kind of grouping


let's see what Wolfgang thinks of it ...

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] ctxlua percentage format escape

2021-05-29 Thread Hans Hagen

On 5/29/2021 3:02 PM, Jairo A. del Rio wrote:
Hi, Adam. There are some ways to do it. I'm sure there are many more, 
but I don't remember them right now. Hi, Hans. There's a bug (?) in 
syst-lua.lua related to \expression in MkIV (xmath and xcomplex aren't 
defined). Please fix that


something

local result = CONTEXTLMTXMODE > 0 and
{ "local xmath = xmath local xcomplex = xcomplex return " }
 or { "local xmath =  math local xcomplex = { }  return " }

you can test it


%Temporary hack for MkIV

%Only use it in case \expression ... \relax doesn't work


kind of old (hacky experiment) that one ... i probably need to adapt it 
to lmtx anyway


\luaexpr and \mathexpr are probably better for this kind of stuff (no 
need for the % then when the optional format arg is used)


Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] How to write readable source files?

2021-05-29 Thread Nicola
On 2021-04-25, Hans Hagen  wrote:
>> If there is a way to automatically get a list of all ConTeXt commands
>> and options (and, ideally, MetaFun defs, types, and other keywords), I'd
>> be happy to improve omni-completion for ConTeXt in Vim.
> All is in xml files (i-*.xml) in the distribution maintained by
> Wolfgang. We ship with this for editors:
>
> >dir t:\texmf\context\data
>
> 04/21/2021  11:40 AM  scite
> 04/21/2021  11:40 AM  textadept
> 04/21/2021  11:40 AM  texworks
> 04/21/2021  11:40 AM  vscode
>
> these lists are generated by mtx-interface so we can add more if needed

Could you please elaborate on the (automatic?) data flow from ConTeXt's
source files to data files for each application? Is it:

source code -> XML -> .lua -> mtx-interface -> data?

In particular, it is not clear to me how i-*.xml files are related to
mtx-interface, as the latter does not use them directly, AFAICS.

Anyway, mtx-interface seems exactly what I am looking for, and I would
like to use it to generate ConTeXt keywords for Vim. Can I patch that
script?

For MetaFun keywords I don't know yet: do those XML files contain enough
information about the content of all mp-* source files? E.g., the fact
that `hlingrid` is a def? Looking at the Scite files, I see only
internals and commands, and they seem to cover only the "main" MetaFun
names.

I have used a custom script in the past for fine-grained keyword
extraction from MetaFun's source code. By fine-grained, I mean that the
output contains information about the kind of keyword (def, primary def,
vardef, constant, variable, etc.) I could update it to Lua and mp-*.mpxl
if that interests you—unless that has already been done, of course.

Nicola

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] ctxlua percentage format escape

2021-05-29 Thread Adam Reviczky
Thank you Jairo!

I have tried playing around with letterpercent/catcodes as well, not sure
what I did wrong, but your examples work just fine, so thanks again.

Adam

On Sat, May 29, 2021 at 2:04 PM Jairo A. del Rio 
wrote:

> Hi, Adam. There are some ways to do it. I'm sure there are many more, but
> I don't remember them right now. Hi, Hans. There's a bug (?) in
> syst-lua.lua related to \expression in MkIV (xmath and xcomplex aren't
> defined). Please fix that
>
>
> %Temporary hack for MkIV
>
> %Only use it in case \expression ... \relax doesn't work
>
> \startmkivmode
>
> \startluacode
>
> xmath = xmath or math
>
> xcomplex = xcomplex or {} --maybe math too???
>
> \stopluacode
>
> \stopmkivmode
>
> \starttext
>
> $\pi = \ctxlua{context("\letterpercent.6f", math.pi)}$
>
>
> $\pi = \expression string.format("\letterpercent.6f", pi)\relax$
>
>
> %Changing catcodes so $ and % are letter characters
>
> \startasciimode
>
> \m{\pi = \expression ("%.6f"):format(pi) \relax}
>
>
> \m{\pi = \ctxlua{context("%.6f", math.pi)}}
>
> \stopasciimode
>
> \stoptext
>
> Regards,
>
>
> Jairo
>
> El sáb, 29 de may. de 2021 a la(s) 07:32, Adam Reviczky (
> revic...@gmail.com) escribió:
>
>> Hi,
>>
>> I was trying to use a quick calculation like the new mathfun in lmtx for
>> an older mkiv document.
>>
>> MWE from the wiki:
>> https://wiki.contextgarden.net/Programming_in_LuaTeX#Examples
>>
>> \starttext
>> $\pi = \ctxlua{context("\%.6f", math.pi)}$
>> \stoptext
>>
>> But that gives an error (actually for both lmtx and mkiv): token call,
>> syntax: [ctxlua]:1: invalid escape sequence near '"\%'
>>
>> Whereas
>>
>> \starttext
>> $\pi = \startluacode context("%.6f", math.pi) \stopluacode$
>> \stoptext
>>
>> Works fine as expected.
>>
>> Is there a way to escape the percentage sign in ctxlua as a format value?
>>
>> Adam
>>
>> ___
>> If your question is of interest to others as well, please add an entry to
>> the Wiki!
>>
>> maillist : ntg-context@ntg.nl /
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
>> archive  : https://bitbucket.org/phg/context-mirror/commits/
>> wiki : http://contextgarden.net
>>
>> ___
>>
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] ctxlua percentage format escape

2021-05-29 Thread Jairo A. del Rio
Hi, Adam. There are some ways to do it. I'm sure there are many more, but I
don't remember them right now. Hi, Hans. There's a bug (?) in syst-lua.lua
related to \expression in MkIV (xmath and xcomplex aren't defined). Please
fix that


%Temporary hack for MkIV

%Only use it in case \expression ... \relax doesn't work

\startmkivmode

\startluacode

xmath = xmath or math

xcomplex = xcomplex or {} --maybe math too???

\stopluacode

\stopmkivmode

\starttext

$\pi = \ctxlua{context("\letterpercent.6f", math.pi)}$


$\pi = \expression string.format("\letterpercent.6f", pi)\relax$


%Changing catcodes so $ and % are letter characters

\startasciimode

\m{\pi = \expression ("%.6f"):format(pi) \relax}


\m{\pi = \ctxlua{context("%.6f", math.pi)}}

\stopasciimode

\stoptext

Regards,


Jairo

El sáb, 29 de may. de 2021 a la(s) 07:32, Adam Reviczky (revic...@gmail.com)
escribió:

> Hi,
>
> I was trying to use a quick calculation like the new mathfun in lmtx for
> an older mkiv document.
>
> MWE from the wiki:
> https://wiki.contextgarden.net/Programming_in_LuaTeX#Examples
>
> \starttext
> $\pi = \ctxlua{context("\%.6f", math.pi)}$
> \stoptext
>
> But that gives an error (actually for both lmtx and mkiv): token call,
> syntax: [ctxlua]:1: invalid escape sequence near '"\%'
>
> Whereas
>
> \starttext
> $\pi = \startluacode context("%.6f", math.pi) \stopluacode$
> \stoptext
>
> Works fine as expected.
>
> Is there a way to escape the percentage sign in ctxlua as a format value?
>
> Adam
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] ctxlua percentage format escape

2021-05-29 Thread Adam Reviczky
Hi,

I was trying to use a quick calculation like the new mathfun in lmtx for an
older mkiv document.

MWE from the wiki:
https://wiki.contextgarden.net/Programming_in_LuaTeX#Examples

\starttext
$\pi = \ctxlua{context("\%.6f", math.pi)}$
\stoptext

But that gives an error (actually for both lmtx and mkiv): token call,
syntax: [ctxlua]:1: invalid escape sequence near '"\%'

Whereas

\starttext
$\pi = \startluacode context("%.6f", math.pi) \stopluacode$
\stoptext

Works fine as expected.

Is there a way to escape the percentage sign in ctxlua as a format value?

Adam
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] Fwd: --luatex option failing

2021-05-29 Thread Pablo Rodriguez
On 5/29/21 2:38 AM, jbf wrote:
> Pablo, thanks for the assistance you gave me... it made me look at the
> cache inside the lmtx folders and I could see that the entire luatex
> folder was missing. I did try your --erase and --generate moves, but
> that did nothing to resolve things, so I installed the latest 2021.05.27
> 14:15 and the problem is resolved.

Julian,

glad to read it worked fine with current latest.

Pablo
--
http://www.ousia.tk
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___