Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread luigi scarso
On Sat, Oct 16, 2010 at 11:09 PM, Aditya Mahajan adit...@umich.edu wrote:
 Hi,

 In MkII, I can say

    \ReadFile{/tmp/filename}

 to read a file in /tmp directory. However, in MkIV, that fails because
 ReadFile is defined as

 \unexpanded\def\ReadFile     #1{\doreadfile{any}
 {.}{#1}\donothing\donothing}

 so it explicitly searches in the . (current) directory.

 Bug or feature?
What happen if you put a path like
./../../../../../tmp/filename
?
-- 
luigi
___
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
___


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Aditya Mahajan

On Sun, 17 Oct 2010, luigi scarso wrote:


On Sat, Oct 16, 2010 at 11:09 PM, Aditya Mahajan adit...@umich.edu wrote:

Hi,

In MkII, I can say

   \ReadFile{/tmp/filename}

to read a file in /tmp directory. However, in MkIV, that fails because
ReadFile is defined as

\unexpanded\def\ReadFile     #1{\doreadfile{any}
{.}{#1}\donothing\donothing}

so it explicitly searches in the . (current) directory.

Bug or feature?

What happen if you put a path like
./../../../../../tmp/filename


It works, but does not fit my need. I wanted to add an option to the 
filter module to allow the user to say:


\setupexternalfilters[directory=$TEMP]

and have all the tmp files created in $TEMP. Having to set this as a 
relative path will be really ugly.


I am just looking for macro that takes the filename as a (brace 
delimited) parameter and typesets it. I can define one on my own; but I 
thought that \ReadFile is already supposed to do that.


It is straight forward to fix \ReadFile so that absolute paths work:

\unexpanded\def\readfile #1{\doreadfile{any} \empty{#1}}
\unexpanded\def\ReadFile #1{\doreadfile{any} \empty{#1}\donothing\donothing}

I just wondering if the current behavior is a design decision or an 
oversight.


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


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Aditya Mahajan

On Sun, 17 Oct 2010, Aditya Mahajan wrote:

I am just looking for macro that takes the filename as a (brace delimited) 
parameter and typesets it.


Err.. I mean \inputs it.

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


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Wolfgang Schuster

Am 17.10.2010 um 19:21 schrieb Aditya Mahajan:

 It works, but does not fit my need. I wanted to add an option to the filter 
 module to allow the user to say:
 
 \setupexternalfilters[directory=$TEMP]
 
 and have all the tmp files created in $TEMP. Having to set this as a relative 
 path will be really ugly.
 
 I am just looking for macro that takes the filename as a (brace delimited) 
 parameter and typesets it. I can define one on my own; but I thought that 
 \ReadFile is already supposed to do that.
 
 It is straight forward to fix \ReadFile so that absolute paths work:
 
 \unexpanded\def\readfile #1{\doreadfile{any} \empty{#1}}
 \unexpanded\def\ReadFile #1{\doreadfile{any} 
 \empty{#1}\donothing\donothing}
 
 I just wondering if the current behavior is a design decision or an oversight.

What i get from the comments in the source is that \readfile looks for the 
requested file
in the current directory, the parent directories and the tex directory and 
\ReadFile is
a alternative form for \readfile without the second and third argument.

You can define your own command \ReadFilter which is based in \readsetfile or 
\readfixfile.

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
___


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Wolfgang Schuster

Am 17.10.2010 um 19:58 schrieb Aditya Mahajan:

 I wanted something that will work consistently in MkII and MkIV. I can do:
 
 \doifmodeelse{\s!mkii}
  {\let\ReadFilter\ReadFile}
  {\def\ReadFilter#1{\doreadfile{any}\empty{#1}\donothing\donothing}}
 
 but, I wanted to avoid such things if possible :-/

Does this work:

\def\ReadFilter#1%
  {\readsetfile{/tmp/}{#1}\donothing\donothing}

 (BTW, why is system mode *mkii not set in MkII?)

Maybe Hans forgot it for mkii but it doesn’t matter whether mkii/mkiv is a 
normal mode or a system mode.

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
___


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Aditya Mahajan

On Sun, 17 Oct 2010, Wolfgang Schuster wrote:



Am 17.10.2010 um 19:58 schrieb Aditya Mahajan:


I wanted something that will work consistently in MkII and MkIV. I can do:

\doifmodeelse{\s!mkii}
 {\let\ReadFilter\ReadFile}
 {\def\ReadFilter#1{\doreadfile{any}\empty{#1}\donothing\donothing}}

but, I wanted to avoid such things if possible :-/


Does this work:

\def\ReadFilter#1%
 {\readsetfile{/tmp/}{#1}\donothing\donothing}


Yes, for both MkII and MkIV. But this still does not fit the requirement 
of my module.


\setupexternalfilters
  [directory=,
   outputfile=~/output/\externalfilterinputfile.tex,
   readcommand=\ReadFilter]

will fail. (The above will generate all the *-*.tmp files in current 
directory, which can be purged by passing --purge. The output files are 
generated in ~/output directory for future reference. But \ReadFilter 
cannot read the file.


I think that I will go with separate definitions for MkII and MkIV, or 
perhaps even redefine \ReadFile just before the read function is defined.



(BTW, why is system mode *mkii not set in MkII?)


Maybe Hans forgot it for mkii but it doesn’t matter whether mkii/mkiv is a 
normal mode or a system mode.


IIRC, system modes cannot be reset using \(enable|disable)mode.

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


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Hans Hagen

On 17-10-2010 7:58, Aditya Mahajan wrote:

On Sun, 17 Oct 2010, Wolfgang Schuster wrote:



Am 17.10.2010 um 19:21 schrieb Aditya Mahajan:


It works, but does not fit my need. I wanted to add an option to the
filter module to allow the user to say:

\setupexternalfilters[directory=$TEMP]

and have all the tmp files created in $TEMP. Having to set this as a
relative path will be really ugly.

I am just looking for macro that takes the filename as a (brace
delimited) parameter and typesets it. I can define one on my own; but
I thought that \ReadFile is already supposed to do that.

It is straight forward to fix \ReadFile so that absolute paths work:

\unexpanded\def\readfile #1{\doreadfile{any} \empty{#1}}
\unexpanded\def\ReadFile #1{\doreadfile{any}
\empty{#1}\donothing\donothing}

I just wondering if the current behavior is a design decision or an
oversight.


What i get from the comments in the source is that \readfile looks for
the requested file
in the current directory, the parent directories and the tex directory
and \ReadFile is
a alternative form for \readfile without the second and third argument.


Then the MkII implementation is wrong because it allows absolute paths.


You can define your own command \ReadFilter which is based in
\readsetfile or \readfixfile.


I wanted something that will work consistently in MkII and MkIV. I can do:

\doifmodeelse{\s!mkii}
{\let\ReadFilter\ReadFile}
{\def\ReadFilter#1{\doreadfile{any}\empty{#1}\donothing\donothing}}

but, I wanted to avoid such things if possible :-/

(BTW, why is system mode *mkii not set in MkII?)


because you can do \doifnotmode{mkiv}


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Hans Hagen

On 17-10-2010 8:54, Aditya Mahajan wrote:


Maybe Hans forgot it for mkii but it doesn’t matter whether mkii/mkiv
is a normal mode or a system mode.


IIRC, system modes cannot be reset using \(enable|disable)mode.


there is nothing special about system modes: they just have a * in front 
so you can enable and disable them (but of course deep down they can be 
set as well)


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Aditya Mahajan

On Sun, 17 Oct 2010, Hans Hagen wrote:


On 17-10-2010 7:58, Aditya Mahajan wrote:

(BTW, why is system mode *mkii not set in MkII?)


because you can do \doifnotmode{mkiv}


:)

Documented on the wiki page on modes.

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


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Aditya Mahajan

On Sun, 17 Oct 2010, Hans Hagen wrote:


On 17-10-2010 8:54, Aditya Mahajan wrote:


Maybe Hans forgot it for mkii but it doesn’t matter whether mkii/mkiv
is a normal mode or a system mode.


IIRC, system modes cannot be reset using \(enable|disable)mode.


there is nothing special about system modes: they just have a * in front so 
you can enable and disable them (but of course deep down they can be set as 
well)


OK. So the * is just so that they are not accidently overwritten.

But I do not like the different treatment for MkII:

cont-new.mkii

 \enablemode[mkii]

cont-env.mkiv

  \enablemode[mkiv] \newsystemmode{mkiv} \setsystemmode{mkiv}

One more minor difference to remember.

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


Re: [NTG-context] \ReadFile in MkII vs MkIV

2010-10-17 Thread Hans Hagen

On 17-10-2010 11:02, Aditya Mahajan wrote:

On Sun, 17 Oct 2010, Hans Hagen wrote:


On 17-10-2010 8:54, Aditya Mahajan wrote:


Maybe Hans forgot it for mkii but it doesn’t matter whether mkii/mkiv
is a normal mode or a system mode.


IIRC, system modes cannot be reset using \(enable|disable)mode.


there is nothing special about system modes: they just have a * in
front so you can enable and disable them (but of course deep down they
can be set as well)


OK. So the * is just so that they are not accidently overwritten.

But I do not like the different treatment for MkII:

cont-new.mkii

\enablemode[mkii]

cont-env.mkiv

\enablemode[mkiv] \newsystemmode{mkiv} \setsystemmode{mkiv}

One more minor difference to remember.


Ah, ok, I can add that to mkii of course (actuallym, it shoul dnot be in 
cont-new any longer) ... I just had forgotten that there was a mkii mode 
at all.


Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___