Re: [NTG-context] Compare contents of macros via \doif etc. alternatives

2017-07-22 Thread Jaroslav Hajtmar

Thanx Hans for reply.


also, it depends on what you want to achieve ... maybe comparing macros is not 
needed at all

You have right, that anytime compares are not needed, but for my very needed 
compares is not working in next eight examples. Problem is in expansions macros 
with optional argument. For “normal” macros are compares without problem as you 
see in last four examples….


mymacro

\doifelse{\mymacro}{123}{equal content}{not equal content}

\doifsamestringelse{\mymacro}{123}{equal content}{not equal content}

\doifinstringelse{\mymacro}{123}{equal content}{not equal content}

\doifincsnameelse{\mymacro}{123}{equal content}{not equal content}


\hairline

mymacro[123]

\doifelse{\mymacro[123]}{123}{equal content}{not equal content}

\doifsamestringelse{\mymacro[123]}{123}{equal content}{not equal content}

\doifinstringelse{\mymacro[123]}{123}{equal content}{not equal content}

\doifincsnameelse{\mymacro[123]}{123}{equal content}{not equal content}



\hairline


myothermacro

\doifelse{\myothermacro}{123}{equal content}{not equal content}

\doifsamestringelse{\myothermacro}{123}{equal content}{not equal content}

\doifinstringelse{\myothermacro}{123}{equal content}{not equal content}

\doifincsnameelse{\myothermacro}{123}{equal content}{not equal content}



there is not that much benefit defining these at the lua end if you directly 
feed back into tex anyway

sure, but I need define some macros automatically from luacode (is part of 
custom lua library)

Thanx
Jaroslav Hajtmar




22. 7. 2017 v 13:23, Hans Hagen >:

On 7/22/2017 3:58 AM, Henri wrote:
On Fri, 2017-07-21 at 11:25 +, Jaroslav Hajtmar wrote:
Hello ConTeXist.
Is there any way to evaluate of contents of two macros as I am showing in my 
minimal example?
I know, that problem is in expansion, but I dont know to resolve it.
My minimal example consist of piece lua code, because I am solving my problem 
in mixed codes (TeX
& Lua)
Something similar has been asked before and it is not possible.  The 
interfaces.definecommand
function defines a new macro using \protected\def.  To compare as equal in a 
\doif context, both
operands have to _expand_ to the same thing (here 123).  Here \mymacro is not 
expandable and thus
only \doifelse{\mymacro}{\mymacro} will ever compare true.
Furthermore, scanning for optional arguments (i.e. [...]) is inherently 
non-expandable.  To get
something expandable you must at least switch to mandatory arguments (i.e. 
{...}).  Still, using
interfaces.definecommand will still not be possible.  I believe that scanning 
arguments is better
done on the macro level than in Lua, but that's just my opinion.

also, it depends on what you want to achieve ... maybe comparing macros is not 
needed at all

Thanx for help.
Jaroslav Hajtmar
   \starttext
 \startluacode
interfaces.definecommand ("domymacro", {
arguments = { { "option", "string" }  },
macro = function (opt_1)
   if #opt_1>0 then
   context(opt_1)
   else
   context("123")
   end
end
   })
interfaces.definecommand("mymacro", {
macro = function ()
  context.dosingleempty()
  context["domymacro"]()
end
   })
\stopluacode

there is not that much benefit defining these at the lua end if you directly 
feed back into tex anyway

\def\myothermacro{123}
 \hairline
 \mymacro[123]
 \mymacro
 \myothermacro
 \hairline
 \doifelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
 \doifsamestringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
 \doifinstringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
 \doifincsnameelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
   \hairline
 \doifelse{\mymacro}{\myothermacro}{equal content}{not equal content}
 \doifsamestringelse{\mymacro}{\myothermacro}{equal content}{not equal content}
 \doifinstringelse{\mymacro}{\myothermacro}{equal content}{not equal content}
 \doifincsnameelse{\mymacro}{\myothermacro}{equal content}{not equal content}
 \stoptext
 
___
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 

Re: [NTG-context] Extensible arrows in ConTeXT

2017-07-22 Thread Alan Braslau
On Fri, 21 Jul 2017 12:31:33 +0200
Mathias Schickel  wrote:

> > $\xrightarrow{}{}$
> 
> This throws errors. Any idea why?
> 
> > $\xrightoverleftarrow{}{33°C}$
> 
> This does work. Sadly it is not the arrow I want to have.

MWE:

\starttext
$A \xrightarrow{}{} B$
\stoptext

No problem here.

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] Compare contents of macros via \doif etc. alternatives

2017-07-22 Thread Jaroslav Hajtmar
Hello ConTeXist.

Is there any way to evaluate of contents of two macros as I am showing in my 
minimal example? 

I know, that problem is in expansion, but I dont know to resolve it.

My minimal example consist of piece lua code, because I am solving my problem 
in mixed codes (TeX & Lua)

 

Thanx for help.

Jaroslav Hajtmar

 

 

\starttext

 

\startluacode

    interfaces.definecommand ("domymacro", {

        arguments = { { "option", "string" }  },

        macro = function (opt_1)

       if #opt_1>0 then

   context(opt_1)

   else

   context("123")

   end

        end

   })

    interfaces.definecommand("mymacro", {

        macro = function ()

      context.dosingleempty()

      context["domymacro"]()

        end

   })

\stopluacode

 

\def\myothermacro{123}

 

\hairline

 

\mymacro[123]

 

\mymacro

 

\myothermacro

 

\hairline

 

\doifelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}

 

\doifsamestringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}

 

\doifinstringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}

 

\doifincsnameelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}

 

 

\hairline

 

\doifelse{\mymacro}{\myothermacro}{equal content}{not equal content}

 

\doifsamestringelse{\mymacro}{\myothermacro}{equal content}{not equal content}

 

\doifinstringelse{\mymacro}{\myothermacro}{equal content}{not equal content}

 

\doifincsnameelse{\mymacro}{\myothermacro}{equal content}{not equal content}

 

 

 

\stoptext

___
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] Compare contents of macros via \doif etc. alternatives

2017-07-22 Thread Hans Hagen

On 7/22/2017 3:58 AM, Henri wrote:

On Fri, 2017-07-21 at 11:25 +, Jaroslav Hajtmar wrote:

Hello ConTeXist.
Is there any way to evaluate of contents of two macros as I am showing in my 
minimal example?
I know, that problem is in expansion, but I dont know to resolve it.
My minimal example consist of piece lua code, because I am solving my problem 
in mixed codes (TeX
& Lua)


Something similar has been asked before and it is not possible.  The 
interfaces.definecommand
function defines a new macro using \protected\def.  To compare as equal in a 
\doif context, both
operands have to _expand_ to the same thing (here 123).  Here \mymacro is not 
expandable and thus
only \doifelse{\mymacro}{\mymacro} will ever compare true.

Furthermore, scanning for optional arguments (i.e. [...]) is inherently 
non-expandable.  To get
something expandable you must at least switch to mandatory arguments (i.e. 
{...}).  Still, using
interfaces.definecommand will still not be possible.  I believe that scanning 
arguments is better
done on the macro level than in Lua, but that's just my opinion.


also, it depends on what you want to achieve ... maybe comparing macros 
is not needed at all



Thanx for help.
Jaroslav Hajtmar
  
  
\starttext
  
\startluacode

 interfaces.definecommand ("domymacro", {
 arguments = { { "option", "string" }  },
 macro = function (opt_1)
if #opt_1>0 then
context(opt_1)
else
context("123")
end
 end
})
 interfaces.definecommand("mymacro", {
 macro = function ()
   context.dosingleempty()
   context["domymacro"]()
 end
})
\stopluacode


there is not that much benefit defining these at the lua end if you 
directly feed back into tex anyway



\def\myothermacro{123}
  
\hairline
  
\mymacro[123]
  
\mymacro
  
\myothermacro
  
\hairline
  
\doifelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
  
\doifsamestringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
  
\doifinstringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
  
\doifincsnameelse{\mymacro}{\mymacro[123]}{equal content}{not equal content}
  
  
\hairline
  
\doifelse{\mymacro}{\myothermacro}{equal content}{not equal content}
  
\doifsamestringelse{\mymacro}{\myothermacro}{equal content}{not equal content}
  
\doifinstringelse{\mymacro}{\myothermacro}{equal content}{not equal content}
  
\doifincsnameelse{\mymacro}{\myothermacro}{equal content}{not equal content}
  
  
  
\stoptext
  
  
  
___

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
___




--

-
  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
___