ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Macro "inside" \component.
@ 2012-10-06 22:41 Andre Caldas
  2012-10-07  7:29 ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Andre Caldas @ 2012-10-06 22:41 UTC (permalink / raw)
  To: ConTeXt users

Hi!

This works:

\startproduct assorted
\project math_video_classes

\unexpanded\def\pathrelativetome%
{src/products/assorted/open_mapping_theorem/notes}

%    \component{\pathrelativetome}
    \component{src/products/assorted/open_mapping_theorem/notes}
\stopproduct

But this does not work (no PDF is generated):

\startproduct assorted
\project math_video_classes

\unexpanded\def\pathrelativetome%
{src/products/assorted/open_mapping_theorem/notes}

    \component{\pathrelativetome}
%    \component{src/products/assorted/open_mapping_theorem/notes}
\stopproduct


WHY?

Thank you,
André Caldas.
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro "inside" \component.
  2012-10-06 22:41 Macro "inside" \component Andre Caldas
@ 2012-10-07  7:29 ` Wolfgang Schuster
  2012-10-07 15:49   ` Andre Caldas
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2012-10-07  7:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 07.10.2012 um 00:41 schrieb Andre Caldas <andre.em.caldas@gmail.com>:

> Hi!
> 
> This works:
> 
> \startproduct assorted
> \project math_video_classes
> 
> \unexpanded\def\pathrelativetome%
> {src/products/assorted/open_mapping_theorem/notes}
> 
> %    \component{\pathrelativetome}
>    \component{src/products/assorted/open_mapping_theorem/notes}
> \stopproduct
> 
> But this does not work (no PDF is generated):
> 
> \startproduct assorted
> \project math_video_classes
> 
> \unexpanded\def\pathrelativetome%
> {src/products/assorted/open_mapping_theorem/notes}
> 
>    \component{\pathrelativetome}
> %    \component{src/products/assorted/open_mapping_theorem/notes}
> \stopproduct
> 
> 
> WHY?

Why don’t you use the \usepath command.

\startproduct assorted

\usepath[src/products/assorted/open_mapping_theorem]

\component notes

\stopproduct

I don’t know if this works with so many subdirectories because you do normally set
the first level subdirectory with \usepath[…] (can be a list of directories) and the second
level inside the first level with \usesubpath[…]. When you put now “\component …” or
“\component […]” in your product file context will look for the requested file in the given
subdirectories.

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro "inside" \component.
  2012-10-07  7:29 ` Wolfgang Schuster
@ 2012-10-07 15:49   ` Andre Caldas
  2012-10-07 20:30     ` Peter Münster
  0 siblings, 1 reply; 7+ messages in thread
From: Andre Caldas @ 2012-10-07 15:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello!

> Why don’t you use the \usepath command.

Because it is too magical. We DO need magic to locate system
libraries. But we DO NOT need magic to locate our own project files.
For this reason, the C language has
#include <system_lib.h>
and
#include "local_lib.h"

I don't want the file to be searched in a pile of directories. I know
exactly where the component is: it is, here:
open_mapping_theorem/notes.tex
but this location is relative to the product directory:
products/functional_analysis.
Which is relative to the project directory.

The recommended project structure is: project/products/components.
Each product is aware of its own components. And each component is
aware of its "sub-components". But the components or the subcomponents
do not need to know anything about where exactly they live inside the
project. The only magic the products need, for example, is that
project wide environments are loaded automatically.

Suppose I have a project with a 100 products with 20 components each.
With all magic provided by the usepath, my components will have to be
too much aware of the remaining other 100 projects. Files will have to
have unique names, even if they are in different products.

I don't really know the internals of it, but the
\ctxloadluafile{module} looks like an example. In my system there is
the file:
/usr/share/texmf/tex/context/base/file-job.mkiv
inside it, there is a \ctxloadluafile to load "file-job.lua". It seems
to me that ctxloadluafile looks for the lua file in the same directory
of the mkiv file that includes it. If this is not the way
ctxloadluafile is implemented, I would suggest that it be. If you load
the module using
context --usemodule=my_lib/my_module.mkiv my_product.tex, then, the
best bet is to load the my_module.lua from the same directory where
my_module.mkiv lives in. I am not sure, but I guess this is the
behaviour that makes most sense.

Another example is the PHP language. The behaviour of the "required()"
command is to look on the current working directory. And for that
reason, the PHP codes are full of:
require(dirname(__FILE__)."/path/relative/file_to_include.php");

I believe thing should be:
1. Predictable.
2. Local.

For that reason, I don't want to use "\usepath".

But even if this was not the case, it makes no sense to me that I
cannot call "\component \macroname". Isn't it an expected behaviour?


André Caldas.
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro "inside" \component.
  2012-10-07 15:49   ` Andre Caldas
@ 2012-10-07 20:30     ` Peter Münster
  2012-10-07 20:45       ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Münster @ 2012-10-07 20:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sun, Oct 07 2012, Andre Caldas wrote:

> it makes no sense to me that I cannot call "\component \macroname".
> Isn't it an expected behaviour?

I don't know the answer, but there is a workaround:

\def\MyMacro{my-component}
\def\MyComponent#1{\cldcontext{"\\component " .. "#1"}}
\startproduct test
  \MyComponent{\MyMacro}
\stopproduct

-- 
           Peter
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro "inside" \component.
  2012-10-07 20:30     ` Peter Münster
@ 2012-10-07 20:45       ` Wolfgang Schuster
  2012-10-11 17:24         ` Andre Caldas
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2012-10-07 20:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 07.10.2012 um 22:30 schrieb Peter Münster <pmlists@free.fr>:

> On Sun, Oct 07 2012, Andre Caldas wrote:
> 
>> it makes no sense to me that I cannot call "\component \macroname".
>> Isn't it an expected behaviour?
> 
> I don't know the answer, but there is a workaround:
> 
> \def\MyMacro{my-component}
> \def\MyComponent#1{\cldcontext{"\\component " .. "#1"}}
> \startproduct test
>  \MyComponent{\MyMacro}
> \stopproduct

\startproduct text
\component [\MyMacro]
\stopproduct

Wolfgang

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro "inside" \component.
  2012-10-07 20:45       ` Wolfgang Schuster
@ 2012-10-11 17:24         ` Andre Caldas
  2012-10-11 18:39           ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Andre Caldas @ 2012-10-11 17:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> \startproduct text
> \component [\MyMacro]
> \stopproduct

Didn't work for me... does it work for you?
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Macro "inside" \component.
  2012-10-11 17:24         ` Andre Caldas
@ 2012-10-11 18:39           ` Wolfgang Schuster
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2012-10-11 18:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 11.10.2012 um 19:24 schrieb Andre Caldas <andre.em.caldas@gmail.com>:

>> \startproduct text
>> \component [\MyMacro]
>> \stopproduct
> 
> Didn't work for me... does it work for you?

This works for me:

\def\Knuth{knuth}

\startproduct test
\component [\Knuth]
\stopproduct

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-10-11 18:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-06 22:41 Macro "inside" \component Andre Caldas
2012-10-07  7:29 ` Wolfgang Schuster
2012-10-07 15:49   ` Andre Caldas
2012-10-07 20:30     ` Peter Münster
2012-10-07 20:45       ` Wolfgang Schuster
2012-10-11 17:24         ` Andre Caldas
2012-10-11 18:39           ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).