[NTG-context] About the use of command handlers

2020-05-28 Thread Jairo A. del Rio
 Hello list! I was reading the following:

https://wiki.contextgarden.net/Style_Alternatives

I wanted to figure out how to make a simple module. However, there's a
point in the example below which I don't understand

% macros=mkvi
\startmodule[look]
\unprotect
\writestatus{loading}{ConTeXt User Module / look}

\installnamespace {look}
\installcommandhandler \look {look} \look

\appendtoks
\setuevalue{\currentlook}{\do_look{\currentlook}}
\to \everydefinelook

\unexpanded\def\do_look#id{%
\edef\currentlook{#id}%
\dosingleempty\do_do_look%
}

\def\do_do_look[#parms]#content{%
\begingroup
\iffirstargument\setupcurrentlook[#parms]\fi
%This handles style and color
\uselookstyleandcolor\c!style\c!color%
#content%
\endgroup%
}

\protect %%
\stopmodule

What have I to do if, instead of "color" or "style", I want to use another
keyword, as "dummy" and get its value? Something like

\definelook[lol][dummy = blabla]
\lol{words}
%e.g. words \emph{blabla} or something similar
so "lol" is a word, a number or whatever. I've read something about command
handlers, but I'm having a hard time trying to understand them. Thank you
in advance!
___
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] Checking existence of a macro (control sequence) by Lua

2020-05-28 Thread context

Hello,

one more question - why macros \Undefined and \DoNothing show "defined" 
although I (tried to) undefine them?



\starttext
  \def\MyMacro{Ahoj}
  \def\MyMac#1#2{Something}

  \def\Undefined{}
  \let\Undefined\undefined

  \def\DoNothing{}
  \let\DoNothing\donothing

  \startluacode
local str = { [true] = "defined", [false] = "undefined" }

local function whatever(s)
  context.type("\\" .. s)
  context(" is " .. (tokens.defined(s) and "defined" or 
"undefined")) --% Hans' way
  context(" and is " .. str[token.is_defined(s)] .. ".") --% Henri's 
way

  context.par()
end

whatever("MyMacro")
whatever("MyMacroD")
whatever(" ")
whatever("-")
whatever("Undefined")
whatever("DoNothing")
  \stopluacode

  %\Undefined % Causes "! Undefined control sequence"
\stoptext


Gives:

"
\MyMacro is defined and is defined.
\MyMacroD is undefined and is undefined.
\ is defined and is defined.
\- is defined and is defined.
\Undefined is defined and is defined.
\DoNothing is defined and is defined.
"

Lukas
___
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] referencing both real and user pagenumbers

2020-05-28 Thread Alan Bowen
I have a collection of papers printed previously that are to go into a
single volume so that, while the papers retain their original pagination
and internal cross-referencing, they are also paginated continuously. I
have managed to do this using userpagenumbers for the individual papers and
realpagenumbers for the volume as a whole.

Re cross-referencing: \at and \in etc. return userpagenumbers (which I
need). But I also need them (or something like them) to
return realpagenumbers as well. Is there a way to do this?

Alan
___
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] annotations in \insertpages

2020-05-28 Thread Pablo Rodriguez
Dear list,

I have the following sample:

\setupinteraction[state=start]
\starttext

\attachment[file=https://kbdeveloper.qoppa.com/wp-content/uploads/blank_signed.pdf]

\insertpages[https://kbdeveloper.qoppa.com/wp-content/uploads/blank_signed.pdf][interaction=all]
\stoptext

Is there any way to get the annotation image in the inserted page?

Many thanks for your help,

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
___


[NTG-context] Unicode chars and \insertpages (Win7)

2020-05-28 Thread Pablo Rodriguez
Dear list,

I have the following sample:

  \startext
\insertpages[ξ_file.pdf]
  \stoptext

Using latest on Linux, it works perfectly fine. On Windows (I’m still on
Win7), it doesn’t work unless I replace "ξ" with an ASCII character.

Could this be fixed or is it really a limiatation of Windows?

Many thanks for your help,

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
___


Re: [NTG-context] Dangerous bend metafont/post code?

2020-05-28 Thread Gerben Wierda
I’ve used:\startMPpage[instance=doublefun]% Inspired by and largely copied from Donald Knuth's METAFONT dangerous bend glyphh=11;u=h/15;w=h*8.5/4.6;heavyline=2;y1=25/27h;x4=0;x1+x1=x1a+x1b=x4b+x2a=x4+x2=x4a+x2b=x3b+x3a=x3+x3=w;x4a=x4b=x4+u; x3b=x1a=x1-2u;y4+y4=y4a+y4b=y3b+y1a=y3+y1=y3a+y1b=y2b+y2a=y2+y2=0;y1a=y1b=y1-2/27h; y4b=y2a=y4+4/27h;path signboard; signboard := z1a..z1..z1b---z2a..z2..z2b---  z3a..z3..z3b---z4a..z4..z4b---cycle;  % signboardfill signboard withcolor yellow;x10=x11=x12=x13=(.5w-u); x14=x15=x16=x17=w-x10;y10=y14=28/27h+epsilon; y13=-h*(6.6/4.1);z11=(z10..z13) intersectionpoint (z1a{z1a-z4b}..z1{right});y15=y11; y16=y12=-y11; y17=y20=y21=y13;path toppost; toppost := z1 -- z11 -- z10 -- z14 -- z15 -- cycle;path bottompost; bottompost := z3 -- z16 -- z17 -- z13 -- z12 -- cycle;fill toppost withcolor .5white;fill bottompost withcolor .5white;draw signboard;draw z11--z10--z14--z15; draw z12--z13; draw z16--z17;  % signpostx20=w-x21; x21-x20=16u; draw z20--z21;  % ground levelx38=w-x31; x38-x31=8u; x32=x34=x38; x31=x35=x37;y31=-y38=12/27h; y32=-y37=9/27h; y34=-y35=3/27h;pickup pencircle scaled heavyline;draw z32{z32-z31}..z34---z35..z37{z38-z37};  % the dangerous bendpickup penrazor xscaled heavyline rotated (angle(z32-z31)+90);draw z31--z32; draw z37--z38;    % upper and lower bars\stopMPpagewhich results in:

dbend.pdf
Description: Adobe PDF document
On 27 May 2020, at 21:50, Herbert Voss  wrote:Am 27.05.20 um 21:19 schrieb Gerben Wierda:To honour Donald Knuth, I’ve use his ‘dangerous bend’ (with attribution of course) in one of my publications. But I only had a low res image. Is the code of this symbol available somewhere so I can do it proper justice in a next edition?Knuth used\input manmac\dbend\byeHerbert___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-contextwebpage  : http://www.pragma-ade.nl / http://context.aanhet.netarchive  : 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] 'debug' version of METAPOST draw?

2020-05-28 Thread Keith McKay
Would Chapter 11, section 11.1 Showing Paths of the MetaPost manual, be 
any help here?


Below is a MWE of a random path of curves and straight lines. The points 
are shown using drawpoints. The arrow path and control lines are also 
shown and are better described in the Metapost manual.


MWE%%%

\setuppapersize [A4,landscape]

\starttext

\startMPpage[instance=doublefun]

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

path p ;

path pat;

pat := (5cm,5cm);

for a = 1 step 1 until 10:

x:= uniformdeviate(10) +10;

y:= uniformdeviate(10) +10;

if odd a:

pat := pat .. (x*cm,y*cm);

else:

pat := pat -- (x*cm,y*cm);

fi;

draw pat withpen pencircle scaled 5mm withcolor .5green;

endfor;

drawarrowpath pat;

drawpoints pat;

drawcontrollines pat withcolor .625red ;

StopPage;

\stopMPpage

\stoptext

%%% end MWE %

A better coder than me may be able to incorporate it into what you require.

Best Wishes

Keith McKay

On 28/05/2020 12:33, Gerben Wierda wrote:

I would like to be able (during development) to draw paths where the points of 
the path (and maybe thing slike directions) are visualised. E.g. a path where 
each pair in teh path is also drawn as a dot and maybe teh directions drawn as 
small arrows.

Does someone have such a beast lying around?

G
___
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] bug in \doifinset

2020-05-28 Thread Pablo Rodriguez
On 5/28/20 12:23 AM, Hans Hagen wrote:
> On 5/27/2020 10:39 PM, Wolfgang Schuster wrote:
>> Pablo Rodriguez schrieb am 27.05.2020 um 22:31:
>>> [...]
>>> I think this may be a bug, since the sample above would only get "yes"
>>> with { i7}.
>>
>> No spaces are allowed in these lists. Older versions of the command
>> removed the spaces before the entries but the current version is stricter.
>
> we can use the old one, so only the raw variants then ignore the space;
> best to be downward compatible, even if this was never the formal spec
> (more a side effect)

Just in case it might be relevant.

I have been using \doifinsetelse for two months now.

Backwards compatibility is not an issue for me (after Luigi provided a
better approach to the issue)

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
___


Re: [NTG-context] bug in \doifinset

2020-05-28 Thread Pablo Rodriguez
On 5/27/20 11:58 PM, luigi scarso wrote:
>> On Wed, May 27, 2020 at 11:28 PM Pablo Rodriguez wrote:
>> Without commas, lists are harder both to read and to write (at least, to me).
>
> what about
>
> \starttext
> \startTEXpage[offset=1em]
> \doifinsetelse{i7}{%
> i4,%
> i5,%
> i7,%
> }
>         {yes}{no}
> \stopTEXpage
> \stoptext
>
> here seems to work.

Many thanks for your reply, Luigi.

This is a better approach for me.

Many thanks for help,

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
___


Re: [NTG-context] LMTX: different output if dots are used in the file name

2020-05-28 Thread Marco Patzer
On Thu, 28 May 2020 18:18:51 +0200
Hans Hagen  wrote:

> > MkIV (everything's predictable and fine):
> > 10.10.10.tex → 10.10.10.pdf
> > 10.10.11.tex → 10.10.11.pdf
> > 11.10.11.tex → 11.10.11.pdf
> > 
> > LMTX:
> > 10.10.10.tex → 10.10 (not even a PDF suffix)
> > 10.10.11.tex → 10.10 (file 10.10 is over-written)
> > 11.10.11.tex → 11.10 (no suffix)
> > 
> > MkIV is way more predictable and consistent in that regard.  
> I'll look at it but not today ... first I need to play with some
> other (neat) stuff and run tests.

OK, thanks. No hurry. The production projects run on some oldish
2019 MkIVs anyway. I'm trying to get my feet wet with lmtx and run
it on some projects to check how usable and compatible it is.

Marco
___
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] LMTX: different output if dots are used in the file name

2020-05-28 Thread Hans Hagen

On 5/28/2020 5:59 PM, Marco Patzer wrote:

On Thu, 28 May 2020 17:33:19 +0200
Hans Hagen  wrote:


On 5/28/2020 2:49 PM, Marco Patzer wrote:

Hi!

LMTX and MkIV behave differently if dots are used in the file
name. Example:

printf '%s\n' '\starttext\null\stoptext' > foo.10.tex && context
foo.10.tex

MkIV: → foo.10.pdf
LMTX: → foo.pdf

Is this intentional?


consider it to be so


That's unfortunate.

1) The editor workflow with simple suffix replacement .tex → .pdf to
open the corresponding PDF file doesn't work any more with lmtx.
New logic is needed to find the correct pdf file name.

2) A project (of mine) that uses item numbers as file names
(containing dots) compile to the same pdf:

MkIV (everything's predictable and fine):
10.10.10.tex → 10.10.10.pdf
10.10.11.tex → 10.10.11.pdf
11.10.11.tex → 11.10.11.pdf

LMTX:
10.10.10.tex → 10.10 (not even a PDF suffix)
10.10.11.tex → 10.10 (file 10.10 is over-written)
11.10.11.tex → 11.10 (no suffix)

MkIV is way more predictable and consistent in that regard.
I'll look at it but not today ... first I need to play with some other 
(neat) stuff and run tests.


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] LMTX: different output if dots are used in the file name

2020-05-28 Thread Marco Patzer
On Thu, 28 May 2020 17:33:19 +0200
Hans Hagen  wrote:

> On 5/28/2020 2:49 PM, Marco Patzer wrote:
> > Hi!
> > 
> > LMTX and MkIV behave differently if dots are used in the file
> > name. Example:
> > 
> >printf '%s\n' '\starttext\null\stoptext' > foo.10.tex && context
> > foo.10.tex
> > 
> > MkIV: → foo.10.pdf
> > LMTX: → foo.pdf
> > 
> > Is this intentional?  
> 
> consider it to be so

That's unfortunate.

1) The editor workflow with simple suffix replacement .tex → .pdf to
   open the corresponding PDF file doesn't work any more with lmtx.
   New logic is needed to find the correct pdf file name.

2) A project (of mine) that uses item numbers as file names
   (containing dots) compile to the same pdf:

   MkIV (everything's predictable and fine):
   10.10.10.tex → 10.10.10.pdf
   10.10.11.tex → 10.10.11.pdf
   11.10.11.tex → 11.10.11.pdf

   LMTX:
   10.10.10.tex → 10.10 (not even a PDF suffix)
   10.10.11.tex → 10.10 (file 10.10 is over-written)
   11.10.11.tex → 11.10 (no suffix)

MkIV is way more predictable and consistent in that regard.

Marco
___
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] LMTX: different output if dots are used in the file name

2020-05-28 Thread Marco Patzer
On Thu, 28 May 2020 17:33:19 +0200
Hans Hagen  wrote:

> On 5/28/2020 2:49 PM, Marco Patzer wrote:
> > Hi!
> > 
> > LMTX and MkIV behave differently if dots are used in the file
> > name. Example:
> > 
> >printf '%s\n' '\starttext\null\stoptext' > foo.10.tex && context
> > foo.10.tex
> > 
> > MkIV: → foo.10.pdf
> > LMTX: → foo.pdf
> > 
> > Is this intentional?  
> 
> consider it to be so

That's unfortunate.

1) The editor workflow with simple suffix replacement .tex → .pdf to
   open the corresponding PDF file doesn't work any more with lmtx.
   New logic is needed to find the correct pdf file name.

2) A project (of mine) that uses item numbers as file names
   (containing dots) compile to the same pdf:

   MkIV (everything's predictable and fine):
   10.10.10.tex → 10.10.10.pdf
   10.10.11.tex → 10.10.11.pdf
   11.10.11.tex → 11.10.11.pdf

   LMTX:
   10.10.10.tex → 10.10 (not even a PDF suffix)
   10.10.11.tex → 10.10 (file 10.10 is over-written)
   11.10.11.tex → 11.10 (no suffix)

MkIV is way more predictable and consistent in that regard.

Marco
___
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] \Umathcodenum and get...dir in lmtx

2020-05-28 Thread Hans Hagen

On 5/28/2020 4:03 PM, Marcel Fabian Krüger wrote:

Hi,

I had two issues with luametatex:

The manual documents getters and setters for the directions:

The direction states can be queried and set with:
tex.gettextdir() tex.getpardir()  tex.setmathdir()
tex.getlinedir() tex.settextdir() tex.setpardir()
tex.getmathdir() tex.setlinedir()

While there is no problem with the set...dir commands, the get...dir
commands don't actually exists. (They can be implemented using tex.get,
but it would be nice if either they were added to luametatex or if they
were removed from te documentation to avoid confusion.)


they're cheap to add (but linedir is just text dir and boxdir can be get 
otherwise as with all these other box properties)



Additionally the scanning variant of \Umathcodenum seems broken:

Take the example document

\starttext
\directlua{
   print('gettextdir:', tex.gettextdir)
}
\the\Umathcodenum`a
\stoptext

It works in ConTeXt mkiv, but in lmtx it shown a (non-informative) error:

   gettextdir:  nil

   tex error   > tex error on line 5 in file ./contfail.tex: ! This can't 
happen (scan char)


the scanning part is ok, but the serializer ignores that one (i'll add it)


   l.5 \the\Umathcodenum`a



   1 \starttext
   2 \directlua{
   3   print('gettextdir:', tex.gettextdir)
   4 }
   5 >>  \the\Umathcodenum`a
   6 \stoptext
   7


   I'm broken. Please show this to someone who can fix me.


   mtx-context | fatal error: return code: 256

(\Umathcodenum`a=123 seems to work though)

Also especially these "This can't happen" errors a a it of pain debug
without having the option to look into the source which I can't find


normally can't happens are not supposed to show up in a run as they 
indicate a not-yet-taken-care-of situation (which can happen when one 
adds a primitive)



anywhere. Has that been released? Is it still planned to make it
available at some point?
sure, when we have organized the repositories which is part of a larger 
reorganization effort which takes time (and motivation) which is kind of 
fuzzy this year (i originally planned early this year, then around bt, 
now we're somewhat later .. we'll see when)


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
___


[NTG-context] 'debug' version of METAPOST draw?

2020-05-28 Thread Gerben Wierda
I would like to be able (during development) to draw paths where the points of 
the path (and maybe thing slike directions) are visualised. E.g. a path where 
each pair in teh path is also drawn as a dot and maybe teh directions drawn as 
small arrows.

Does someone have such a beast lying around?

G
___
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] LMTX: different output if dots are used in the file name

2020-05-28 Thread Hans Hagen

On 5/28/2020 2:49 PM, Marco Patzer wrote:

Hi!

LMTX and MkIV behave differently if dots are used in the file
name. Example:

   printf '%s\n' '\starttext\null\stoptext' > foo.10.tex && context foo.10.tex

MkIV: → foo.10.pdf
LMTX: → foo.pdf

Is this intentional?


consider it to be so

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] Checking existence of a macro (control sequence) by Lua

2020-05-28 Thread context

Hello,

thanks Henri and Hans for all solutions!

On 2020-05-28 10:34, Hans Hagen wrote:

On 5/28/2020 12:42 AM, cont...@vivaldi.net wrote:

Hello,

is it possible to check whether a macro exists (or - is it a 
non-\undefined control sequence) with Lua? Suppose:



\starttext
   \def\MyMacro{Ahoj}
   \def\MyMac#1#2{Something}

   \startluacode
     IsDefined = function(ctl_seq)
   print("CS " .. ctl_seq ..
     (tex.IsCS(ctl_seq) -- Or what to come 
here?
    "is defined" or 
"is unknown") .. ".")

     end

     -- So the function should print to the console:

     IsDefined("MyMacro") --> "CS MyMacro is defined."
     IsDefined("MyMac") --> "CS MyMac is defined."
     IsDefined("bf") --> "CS bf is defined."
     IsDefined("dummy") --> "CS dummy is unknown."

   \stopluacode
\stoptext


Is it possible?

A lot is possible. Take this:

   \def\MyMacroA{Ahoj A}
\unexpanded\def\MyMacroB{Ahoj B}
\frozen\def\MyMacroC{Ahoj C} % in lmtx
 % \def\MyMacroC{Ahoj C} % barks

At the tex end you can check for several properties:

\ifusercmd \hbox Y\else N\fi % in lmtx
\iffrozen  \hbox Y\else N\fi % in lmtx
\ifusercmd \MyMacroA Y\else N\fi % in lmtx
\iffrozen  \MyMacroA Y\else N\fi % in lmtx
\iffrozen  \MyMacroC Y\else N\fi % in lmtx

At the Lua end you can check for being defined:

\startluacode
local function whatever(s)
context.type("\\" .. s)
context(" is %s", tokens.defined(s) and "defined" or 
"undefined")

context.par()
end
whatever("MyMacroA")
whatever("MyMacroD")
whatever(" ")
whatever("-")
\stopluacode

alternatively you can say:

\startluacode
   local t = token.create("MyMacro")
   print(t.cmdname == "undefined_cs")
\stopluacode

which is less efficient unless you want to access more properties.

Hans


(@Hans: I'm using vivaldi's mail account in "good will" - I didn't 
suppose it would cause any unwanted actions, like resending mails or 
whatever.)


Bets regards,

Lukas
___
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] \Umathcodenum and get...dir in lmtx

2020-05-28 Thread Marcel Fabian Krüger
Hi,

I had two issues with luametatex:

The manual documents getters and setters for the directions:

The direction states can be queried and set with:
tex.gettextdir() tex.getpardir()  tex.setmathdir()
tex.getlinedir() tex.settextdir() tex.setpardir()
tex.getmathdir() tex.setlinedir() 

While there is no problem with the set...dir commands, the get...dir
commands don't actually exists. (They can be implemented using tex.get,
but it would be nice if either they were added to luametatex or if they
were removed from te documentation to avoid confusion.)

Additionally the scanning variant of \Umathcodenum seems broken:

Take the example document

\starttext
\directlua{
  print('gettextdir:', tex.gettextdir)
}
\the\Umathcodenum`a
\stoptext

It works in ConTeXt mkiv, but in lmtx it shown a (non-informative) error:

  gettextdir:   nil

  tex error   > tex error on line 5 in file ./contfail.tex: ! This can't 
happen (scan char)

  l.5 \the\Umathcodenum`a
   

  1 \starttext
  2 \directlua{
  3   print('gettextdir:', tex.gettextdir)
  4 }
  5 >>  \the\Umathcodenum`a
  6 \stoptext
  7 


  I'm broken. Please show this to someone who can fix me.


  mtx-context | fatal error: return code: 256

(\Umathcodenum`a=123 seems to work though)

Also especially these "This can't happen" errors a a it of pain debug
without having the option to look into the source which I can't find
anywhere. Has that been released? Is it still planned to make it
available at some point?


Best regards,
Marcel Krüger
___
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] LMTX: different output if dots are used in the file name

2020-05-28 Thread Marco Patzer
Hi!

LMTX and MkIV behave differently if dots are used in the file
name. Example:

  printf '%s\n' '\starttext\null\stoptext' > foo.10.tex && context foo.10.tex

MkIV: → foo.10.pdf
LMTX: → foo.pdf

Is this intentional?

This is LuaMetaTeX, Version 2.06.05
current version: 2020.05.25 23:39

Marco
___
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] LMTX: natural table error namespace 'naturaltablelocal', key ', '

2020-05-28 Thread Marco Patzer
Hi!

With LMTX the following example results in

  setup   > error in line 7, namespace 'naturaltablelocal', key ','
  setup   > error in line 7, namespace 'naturaltablelocal', key ','

The file runs without error in MkIV. Has something changed or is it
a bug?

  \starttext
\bTABLE
  \bTR
\bTD \samplefile{knuth} \eTD
\bTD \samplefile{knuth} \eTD
  \eTR
\eTABLE
  \stoptext


This is LuaMetaTeX, Version 2.06.05
current version: 2020.05.25 23:39

Marco
___
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] Checking existence of a macro (control sequence) by Lua

2020-05-28 Thread Hans Hagen

On 5/28/2020 12:42 AM, cont...@vivaldi.net wrote:

Hello,

is it possible to check whether a macro exists (or - is it a 
non-\undefined control sequence) with Lua? Suppose:



\starttext
   \def\MyMacro{Ahoj}
   \def\MyMac#1#2{Something}

   \startluacode
     IsDefined = function(ctl_seq)
   print("CS " .. ctl_seq ..
     (tex.IsCS(ctl_seq) -- Or what to come 
here?
    "is defined" or "is 
unknown") .. ".")

     end

     -- So the function should print to the console:

     IsDefined("MyMacro") --> "CS MyMacro is defined."
     IsDefined("MyMac") --> "CS MyMac is defined."
     IsDefined("bf") --> "CS bf is defined."
     IsDefined("dummy") --> "CS dummy is unknown."

   \stopluacode
\stoptext


Is it possible?

A lot is possible. Take this:

   \def\MyMacroA{Ahoj A}
\unexpanded\def\MyMacroB{Ahoj B}
\frozen\def\MyMacroC{Ahoj C} % in lmtx
 % \def\MyMacroC{Ahoj C} % barks

At the tex end you can check for several properties:

\ifusercmd \hbox Y\else N\fi % in lmtx
\iffrozen  \hbox Y\else N\fi % in lmtx
\ifusercmd \MyMacroA Y\else N\fi % in lmtx
\iffrozen  \MyMacroA Y\else N\fi % in lmtx
\iffrozen  \MyMacroC Y\else N\fi % in lmtx

At the Lua end you can check for being defined:

\startluacode
local function whatever(s)
context.type("\\" .. s)
context(" is %s", tokens.defined(s) and "defined" or "undefined")
context.par()
end
whatever("MyMacroA")
whatever("MyMacroD")
whatever(" ")
whatever("-")
\stopluacode

alternatively you can say:

\startluacode
   local t = token.create("MyMacro")
   print(t.cmdname == "undefined_cs")
\stopluacode

which is less efficient unless you want to access more properties.

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] Checking existence of a macro (control sequence) by Lua

2020-05-28 Thread Hans Hagen

On 5/28/2020 12:49 AM, luigi scarso wrote:



On Thu, May 28, 2020 at 12:43 AM > wrote:


Off-topic:
your email are always marked as spam by my gmail . Are you sure that 
your address setup is ok  ?
also, a reply to that vivaldi address always bounces (same for gmx 
accounts, so don't expect answers to those adresses)


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
___