Re: [patch] Relyx on the fly

2007-05-15 Thread José Matos
On Wednesday 09 May 2007 13:13:53 hzluo wrote:
 Who can I ask for help if I have tex2lyx problems?
 Thanks in advance :)

  Ask to this mailing list. :-)

-- 
José Abílio


Re: [patch] Relyx on the fly

2007-05-15 Thread José Matos
On Wednesday 09 May 2007 13:13:53 hzluo wrote:
> Who can I ask for help if I have tex2lyx problems?
> Thanks in advance :)

  Ask to this mailing list. :-)

-- 
José Abílio


Re: [patch] Relyx on the fly

2007-05-09 Thread Andre Poenitz
On Tue, May 08, 2007 at 06:26:00PM -0400, hzluo wrote:
 Attached files are to enable relyx on the fly,
 i.e., when a latex syntaxed string is pasted
 into lyx, it is converted to lyx.

Nice idea.
 
 Currently the patch can only detect \cite{...}
 command embeded in a string. But it can be extended
 to support more latex syntax.
 
 Test:
 
 paste a string like:
 blabla bla \cite{someKey,otherKey} blabla
 
 
 Several users ask this features, certainly for
 more advanced version.
 
 The \cite{...} command is important for me. I use
 lyx on Windows, where lyxServer is unavailable.
 So JabRef can't push selections to lyx. With this
 patch, I can ask JabRef to copy as \cite{...} and
 paste into lyx easily. So I implement this command
 first.
 
 Any comment is welcome!

This won't go into the upcoming 1.5.0 but is a pretty nice thing to have
in early 1.6 (i.e. in a few weeks time).

Until then it'd be nice if the patch could made a bit more similar to
the rest of lyx on the 'cosmetic' side: I.e. spacing/indentation.

 If you are interested,
 I can extend it to support more latex syntax.

List lists and itemize environments? ;-)

 If possible, call tex2lyx and read the result
 out is also an option. But it may be a little
 bit slow.
 
 BTW, I don't know how to include the new files
 in the patch. So the two new files are attached
 separately...

That's fine.

Andre'


Re: [patch] Relyx on the fly

2007-05-09 Thread Abdelrazak Younes

Andre Poenitz wrote:

On Tue, May 08, 2007 at 06:26:00PM -0400, hzluo wrote:

Any comment is welcome!


This won't go into the upcoming 1.5.0 but is a pretty nice thing to have
in early 1.6 (i.e. in a few weeks time).


Christmas is still months away...

Abdel.



Re: [patch] Relyx on the fly

2007-05-09 Thread Abdelrazak Younes
hzluo wrote:

 Any comment is welcome! If you are interested,
 I can extend it to support more latex syntax.
 If possible, call tex2lyx and read the result
 out is also an option. But it may be a little
 bit slow.

I think we should try to integrate text2lyx (maybe as a library)
instead.But as Andre said, this is 1.6 stuff.

Abdel.



Re: [patch] Relyx on the fly

2007-05-09 Thread Jean-Marc Lasgouttes
 hzluo == hzluo  [EMAIL PROTECTED] writes:

hzluo Attached files are to enable relyx on the fly, i.e., when a
hzluo latex syntaxed string is pasted into lyx, it is converted to
hzluo lyx.

hzluo Currently the patch can only detect \cite{...} command embeded
hzluo in a string. But it can be extended to support more latex
hzluo syntax.

I do not think doing this in special code is the way to go. Did you
look at using tex2lyx for that? It would be much better that writing
yet another LaTeX scanner.

JMarc


Re: [patch] Relyx on the fly

2007-05-09 Thread hzluo

This won't go into the upcoming 1.5.0 but is a pretty nice thing to have
in early 1.6 (i.e. in a few weeks time).


Yes, I also do not expect it will be in 1.5.0.


Until then it'd be nice if the patch could made a bit more similar to
the rest of lyx on the 'cosmetic' side: I.e. spacing/indentation.



I think we should try to integrate text2lyx (maybe as a library)
instead.But as Andre said, this is 1.6 stuff.



I do not think doing this in special code is the way to go. Did you
look at using tex2lyx for that? It would be much better that writing
yet another LaTeX scanner.


I use current method because I just want to demo the capability,
and I need the \cite{} command badly now. I will check the tex2lyx
in the next step for sure, that's the utmost solution :)
I may need help for tex2lyx related work. I never checked its code before.
Maybe tex2lyx needs to be patched a little bit for this purpose.
Who can I ask for help if I have tex2lyx problems?
Thanks in advance :)


BTW, can anyone look at bug 3496?
http://bugzilla.lyx.org/show_bug.cgi?id=3496

It annoys me a lot when I need to compile or make a patch...
Thanks!

Sincerely,
Hangzai


Re: [patch] Relyx on the fly

2007-05-09 Thread Andre Poenitz
On Tue, May 08, 2007 at 06:26:00PM -0400, hzluo wrote:
> Attached files are to enable relyx on the fly,
> i.e., when a latex syntaxed string is pasted
> into lyx, it is converted to lyx.

Nice idea.
 
> Currently the patch can only detect \cite{...}
> command embeded in a string. But it can be extended
> to support more latex syntax.
> 
> Test:
> 
> paste a string like:
> blabla bla \cite{someKey,otherKey} blabla
> 
> 
> Several users ask this features, certainly for
> more advanced version.
> 
> The \cite{...} command is important for me. I use
> lyx on Windows, where lyxServer is unavailable.
> So JabRef can't push selections to lyx. With this
> patch, I can ask JabRef to copy as \cite{...} and
> paste into lyx easily. So I implement this command
> first.
> 
> Any comment is welcome!

This won't go into the upcoming 1.5.0 but is a pretty nice thing to have
in early 1.6 (i.e. in a few weeks time).

Until then it'd be nice if the patch could made a bit more similar to
the rest of lyx on the 'cosmetic' side: I.e. spacing/indentation.

> If you are interested,
> I can extend it to support more latex syntax.

List lists and itemize environments? ;-)

> If possible, call tex2lyx and read the result
> out is also an option. But it may be a little
> bit slow.
> 
> BTW, I don't know how to include the new files
> in the patch. So the two new files are attached
> separately...

That's fine.

Andre'


Re: [patch] Relyx on the fly

2007-05-09 Thread Abdelrazak Younes

Andre Poenitz wrote:

On Tue, May 08, 2007 at 06:26:00PM -0400, hzluo wrote:

Any comment is welcome!


This won't go into the upcoming 1.5.0 but is a pretty nice thing to have
in early 1.6 (i.e. in a few weeks time).


Christmas is still months away...

Abdel.



Re: [patch] Relyx on the fly

2007-05-09 Thread Abdelrazak Younes
hzluo wrote:

> Any comment is welcome! If you are interested,
> I can extend it to support more latex syntax.
> If possible, call tex2lyx and read the result
> out is also an option. But it may be a little
> bit slow.

I think we should try to integrate text2lyx (maybe as a library)
instead.But as Andre said, this is 1.6 stuff.

Abdel.



Re: [patch] Relyx on the fly

2007-05-09 Thread Jean-Marc Lasgouttes
> "hzluo" == hzluo  <[EMAIL PROTECTED]> writes:

hzluo> Attached files are to enable relyx on the fly, i.e., when a
hzluo> latex syntaxed string is pasted into lyx, it is converted to
hzluo> lyx.

hzluo> Currently the patch can only detect \cite{...} command embeded
hzluo> in a string. But it can be extended to support more latex
hzluo> syntax.

I do not think doing this in special code is the way to go. Did you
look at using tex2lyx for that? It would be much better that writing
yet another LaTeX scanner.

JMarc


Re: [patch] Relyx on the fly

2007-05-09 Thread hzluo

This won't go into the upcoming 1.5.0 but is a pretty nice thing to have
in early 1.6 (i.e. in a few weeks time).


Yes, I also do not expect it will be in 1.5.0.


Until then it'd be nice if the patch could made a bit more similar to
the rest of lyx on the 'cosmetic' side: I.e. spacing/indentation.



I think we should try to integrate text2lyx (maybe as a library)
instead.But as Andre said, this is 1.6 stuff.



I do not think doing this in special code is the way to go. Did you
look at using tex2lyx for that? It would be much better that writing
yet another LaTeX scanner.


I use current method because I just want to demo the capability,
and I need the \cite{} command badly now. I will check the tex2lyx
in the next step for sure, that's the utmost solution :)
I may need help for tex2lyx related work. I never checked its code before.
Maybe tex2lyx needs to be patched a little bit for this purpose.
Who can I ask for help if I have tex2lyx problems?
Thanks in advance :)


BTW, can anyone look at bug 3496?
http://bugzilla.lyx.org/show_bug.cgi?id=3496

It annoys me a lot when I need to compile or make a patch...
Thanks!

Sincerely,
Hangzai


[patch] Relyx on the fly

2007-05-08 Thread hzluo

Attached files are to enable relyx on the fly,
i.e., when a latex syntaxed string is pasted
into lyx, it is converted to lyx.

Currently the patch can only detect \cite{...}
command embeded in a string. But it can be extended
to support more latex syntax.


Test:

paste a string like:
blabla bla \cite{someKey,otherKey} blabla


Several users ask this features, certainly for
more advanced version.

The \cite{...} command is important for me. I use
lyx on Windows, where lyxServer is unavailable.
So JabRef can't push selections to lyx. With this
patch, I can ask JabRef to copy as \cite{...} and
paste into lyx easily. So I implement this command
first.

Any comment is welcome! If you are interested,
I can extend it to support more latex syntax.
If possible, call tex2lyx and read the result
out is also an option. But it may be a little
bit slow.

BTW, I don't know how to include the new files
in the patch. So the two new files are attached
separately...

Sincerely,
Hangzai


InlineRelyxOK.diff
Description: Binary data


InlineRelyx.h
Description: Binary data


InlineRelyx.cpp
Description: Binary data


[patch] Relyx on the fly

2007-05-08 Thread hzluo

Attached files are to enable relyx on the fly,
i.e., when a latex syntaxed string is pasted
into lyx, it is converted to lyx.

Currently the patch can only detect \cite{...}
command embeded in a string. But it can be extended
to support more latex syntax.


Test:

paste a string like:
blabla bla \cite{someKey,otherKey} blabla


Several users ask this features, certainly for
more advanced version.

The \cite{...} command is important for me. I use
lyx on Windows, where lyxServer is unavailable.
So JabRef can't push selections to lyx. With this
patch, I can ask JabRef to copy as \cite{...} and
paste into lyx easily. So I implement this command
first.

Any comment is welcome! If you are interested,
I can extend it to support more latex syntax.
If possible, call tex2lyx and read the result
out is also an option. But it may be a little
bit slow.

BTW, I don't know how to include the new files
in the patch. So the two new files are attached
separately...

Sincerely,
Hangzai


InlineRelyxOK.diff
Description: Binary data


InlineRelyx.h
Description: Binary data


InlineRelyx.cpp
Description: Binary data


Re: [patch] reLyX and \(...\)*

2003-02-11 Thread Jean-Marc Lasgouttes
 Angus == Angus Leeming [EMAIL PROTECTED] writes:

Angus Ok, JMarc. I dug deep enough to understand how it works and
Angus have developed a gruding admiration for it. I append
^^^grudging? (I had to look up the word in
  the webster. I learn everyday)
Angus 'lookAheadToken' (with some extra print statements). The guts
Angus of it is this line:

Angus $macro will match \X where X is: case 1: ')' (but not ')*').
Angus case 2: a single char 'not alphabetical, a-z or A-Z', followed
Angus by a single '*', if present, followed by an arbitrary amount of
Angus whitespace. Thus, matches both '\\' and '\\*'. case 3: a
Angus multi-char, alphabetical string, followed by a single '*', if
Angus present, followed by an arbitrary amount of whitespace. Thus,
Angus this matches both '\section' and '\section*'.

Angus In conclusion, therefore, my patch _is_ safe and does
Angus specialise the test so that '\)' (but not '\)*' is counted as a
Angus macro.

You have convinced me. But now I have another doubt: you take great
length to handle \)*, because this is what is pointed out in bug 9.
But as far as I can see, this is a rather rare occurence, not more
likely than for example \textbf* (which is \textbf{*}).

So a different algorithm could be: 

1/ grab the macro always with the star. 
2/ If this macro exists in syntax.default, then keep it. 
3/ Otherwise, if the macro exists in syntax.default without the star,
   then assume that * is a separate character
4/ Otherwise put the macro without * in ert, with a * after it

This may be a lot of work (is it?), but at least it would fix a bug
properly. I am not sure that I see the need to fix bug 9 per se. This
is adding special casing for a rare occurence.

As it is, I am not sure it is worth putting in 1.3.x.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-11 Thread Angus Leeming
On Tuesday 11 February 2003 1:38 pm, Jean-Marc Lasgouttes wrote:
 You have convinced me. But now I have another doubt: you take great
 length to handle \)*, because this is what is pointed out in bug 9.
 But as far as I can see, this is a rather rare occurence, not more
 likely than for example \textbf* (which is \textbf{*}).

 So a different algorithm could be:

 1/ grab the macro always with the star.
 2/ If this macro exists in syntax.default, then keep it.
 3/ Otherwise, if the macro exists in syntax.default without the star,
then assume that * is a separate character
 4/ Otherwise put the macro without * in ert, with a * after it

 This may be a lot of work (is it?), but at least it would fix a bug
 properly. I am not sure that I see the need to fix bug 9 per se. This
 is adding special casing for a rare occurence.

 As it is, I am not sure it is worth putting in 1.3.x.

All fair points. As I said yesterday, I will not rewrite the TeX.pm parser; it 
is a can or worms that will make a horrible mess if split open.

Let's bin the patch; at least we understand the logic of the code now.
Angus



Re: [patch] reLyX and \(...\)*

2003-02-11 Thread Jean-Marc Lasgouttes
 Angus == Angus Leeming [EMAIL PROTECTED] writes:

Angus All fair points. As I said yesterday, I will not rewrite the
Angus TeX.pm parser; it is a can or worms that will make a horrible
Angus mess if split open.

Yes, it does not need more special casing added here and there...

Angus Let's bin the patch; at least we understand the logic of the
Angus code now. Angus

Yes, and this is great progress. You can probably clse bug 9 as
WONTFIX.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-11 Thread Jean-Marc Lasgouttes
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:

Angus> Ok, JMarc. I dug deep enough to understand how it works and
Angus> have developed a gruding admiration for it. I append
^^^grudging? (I had to look up the word in
  the webster. I learn everyday)
Angus> 'lookAheadToken' (with some extra print statements). The guts
Angus> of it is this line:

Angus> $macro will match \X where X is: case 1: ')' (but not ')*').
Angus> case 2: a single char 'not alphabetical, a-z or A-Z', followed
Angus> by a single '*', if present, followed by an arbitrary amount of
Angus> whitespace. Thus, matches both '\\' and '\\*'. case 3: a
Angus> multi-char, alphabetical string, followed by a single '*', if
Angus> present, followed by an arbitrary amount of whitespace. Thus,
Angus> this matches both '\section' and '\section*'.

Angus> In conclusion, therefore, my patch _is_ safe and does
Angus> specialise the test so that '\)' (but not '\)*' is counted as a
Angus> macro.

You have convinced me. But now I have another doubt: you take great
length to handle \)*, because this is what is pointed out in bug 9.
But as far as I can see, this is a rather rare occurence, not more
likely than for example \textbf* (which is \textbf{*}).

So a different algorithm could be: 

1/ grab the macro always with the star. 
2/ If this macro exists in syntax.default, then keep it. 
3/ Otherwise, if the macro exists in syntax.default without the star,
   then assume that * is a separate character
4/ Otherwise put the macro without * in ert, with a * after it

This may be a lot of work (is it?), but at least it would fix a bug
properly. I am not sure that I see the need to fix bug 9 per se. This
is adding special casing for a rare occurence.

As it is, I am not sure it is worth putting in 1.3.x.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-11 Thread Angus Leeming
On Tuesday 11 February 2003 1:38 pm, Jean-Marc Lasgouttes wrote:
> You have convinced me. But now I have another doubt: you take great
> length to handle \)*, because this is what is pointed out in bug 9.
> But as far as I can see, this is a rather rare occurence, not more
> likely than for example \textbf* (which is \textbf{*}).
>
> So a different algorithm could be:
>
> 1/ grab the macro always with the star.
> 2/ If this macro exists in syntax.default, then keep it.
> 3/ Otherwise, if the macro exists in syntax.default without the star,
>then assume that * is a separate character
> 4/ Otherwise put the macro without * in ert, with a * after it
>
> This may be a lot of work (is it?), but at least it would fix a bug
> properly. I am not sure that I see the need to fix bug 9 per se. This
> is adding special casing for a rare occurence.
>
> As it is, I am not sure it is worth putting in 1.3.x.

All fair points. As I said yesterday, I will not rewrite the TeX.pm parser; it 
is a can or worms that will make a horrible mess if split open.

Let's bin the patch; at least we understand the logic of the code now.
Angus



Re: [patch] reLyX and \(...\)*

2003-02-11 Thread Jean-Marc Lasgouttes
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:

Angus> All fair points. As I said yesterday, I will not rewrite the
Angus> TeX.pm parser; it is a can or worms that will make a horrible
Angus> mess if split open.

Yes, it does not need more special casing added here and there...

Angus> Let's bin the patch; at least we understand the logic of the
Angus> code now. Angus

Yes, and this is great progress. You can probably clse bug 9 as
WONTFIX.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Jean-Marc Lasgouttes
 Angus == Angus Leeming [EMAIL PROTECTED] writes:

Angus This patch enables reLyX to handle \(...\)* correctly and not
Angus generate a pile of crap. I attach a test case so the
Angus inquisitive can try out reLyX both with and without the patch.

Can you explain a bit how this macro is used? Is there a list of
macros somewhere that accept an optional *? This should probably be
defined in the syntax tables. What happens actually is that * is not
part of the macro, but is a first optional argument to the given
macro. 

Do you handle for example starred version of \\? And also optional
argument to \\ (like \\*[2cm])?

I am not saying that your patch is wrong, I just want to understand
what is going on... It seems to me that your code implies that only
macros with alphabetic names can have optional *. This is completely
false, actually. I think the handling og * should be done at the same
place as the handling of [], if this is possible.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Angus Leeming
Jean-Marc Lasgouttes wrote:

 Angus == Angus Leeming [EMAIL PROTECTED] writes:
 
 Angus This patch enables reLyX to handle \(...\)* correctly and not
 Angus generate a pile of crap. I attach a test case so the
 Angus inquisitive can try out reLyX both with and without the
 patch.
 
 Can you explain a bit how this macro is used?

Not convincingly. I have been looking at this code hard over
the w/e in an effort to understand it. I'll get back to you when I do. 
Mean while, throw the patch away.

Here, however is my current state of knowledge (just for 
your delectation ;-)

Basically, the regex $macro is used by two subroutines, 
'lookAheadToken' and 'eatMultiToken'. Both subroutines are used both 
by the main TeX parser, TeX.pm, and by Amir's LyX-centric code.

For example, 'eat' is the main subroutine to read in a file and split 
it into tokens. Our own use of the TeX parser is so simple it may be 
written as
sub process {
my $txt = shift;
my $eaten;
while (defined ($eaten = $txt-eat)) {
;
}
}
The real process is more complex than this but we don't pass the 
other, optional args, so it collapses to this. As you see, 'eat' is 
fundamental. I am still trying to decipher it, but 'lookAheadToken' 
and 'eatMultiToken' are both central to its operation.

'lookAheadToken' is only a few lines long, so I hoped to be able to 
understand it:

# return next token without eating it. Return '' if end of paragraph
  sub lookAheadToken {  # If arg2, will eat one token - WHY!? -Ak
my $txt = shift;
# Call paragraph with no argument to say we're just looking
my $in = $txt-paragraph;
return '' unless $in;   # To be able to match without warnings
my $comment = undef;
if ($$in =~ 
/^(?:\s*)(?:$Text::TeX::commentpattern)?($Text::TeX::tokenpattern)/o) {
  if (defined $2) {return $1} #if 1 usualtokenclass char, return it ($1==$2)
  elsif (defined $3) {return \\$3} # Multiletter (\[a-zA-Z]+)
  elsif (defined $1) {return $1} # \ or notusualtokenclass
}
return '';
  }

The guts of the routine lies in that regex, which I'm still trying 
to deciper. In turn, $Text::TeX::tokenpattern is a string made up of 
other strings.

$macro = '(?:[^a-zA-Z]\*?|([a-zA-Z]+\*?)\s*)'; # Has one level of grouping
$active = $macro|\\\$\\\$|\\^\\^.|$notusualtokenclass; # 1 level of grouping
$tokenpattern = ($usualtokenclass)|$active; # Two levels of grouping

So, when I understand these 3 regexes and the one in lookAheadToken 
and I'll understand that subroutine.

 Is there a list of macros somewhere that accept an optional *?

See lib/reLyX/syntax.default. Macros are defined explicitly as
\section
\section*

However, this is used after the initial parsing of the TeX file using
'lookAheadToken' and 'eatMultiToken'. At least that's my understanding 
to date. So, $macro is absolutely crucial to the success of the whole
scheme. If it fails, nothing will work.

 macros somewhere that accept an optional *? This should probably be
 defined in the syntax tables. What happens actually is that * is not
 part of the macro, but is a first optional argument to the given
 macro.
 
 Do you handle for example starred version of \\? And also optional
 argument to \\ (like \\*[2cm])?

Don't know yet.

 I am not saying that your patch is wrong, I just want to understand
 what is going on... It seems to me that your code implies that only
 macros with alphabetic names can have optional *. This is completely
 false, actually. I think the handling og * should be done at the
 same place as the handling of [], if this is possible.

I will not rewrite the TeX parser. I propose a match that fixes a
bug. As I see it, the use of the regex in question is so fundamental 
to the operation of the TeX parser that the change will either work or 
it won't. There will be no 'half-way house'. 

However, I do understand your concerns (indeed, I share them), and
willl attempt to understand the code properly.

regards,
Angus

ps. perl is foul and I parser built out of regexes is fouler.





Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Jean-Marc Lasgouttes
 Angus == Angus Leeming [EMAIL PROTECTED] writes:

Angus Not convincingly. I have been looking at this code hard over
Angus the w/e in an effort to understand it. I'll get back to you
Angus when I do. Mean while, throw the patch away.

OK.

Angus Here, however is my current state of knowledge (just for your
Angus delectation ;-)

:) It seems to be an interesting mess...

 Is there a list of macros somewhere that accept an optional *?

Angus See lib/reLyX/syntax.default. Macros are defined explicitly as
Angus \section \section*

So they are considered as diffrent macros, right?

Angus I will not rewrite the TeX parser. I propose a match that fixes
Angus a bug. As I see it, the use of the regex in question is so
Angus fundamental to the operation of the TeX parser that the change
Angus will either work or it won't. There will be no 'half-way
Angus house'.

That's fair.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Angus Leeming
On Monday 10 February 2003 3:53 pm, Jean-Marc Lasgouttes wrote:
  Is there a list of macros somewhere that accept an optional *?

 Angus See lib/reLyX/syntax.default. Macros are defined explicitly as
 Angus \section \section*

 So they are considered as diffrent macros, right?

Yes. The preliminary parsing of the file by TeX.pm's 'eat' subroutine uses the 
$macro regex to decide what is a macro. It therefore recognises \section and 
\section* as valid 'possible' macro names as I understand it. I haven't yet 
established exactly what part syntax.default plays in all this, but it is 
certainly downstream of the preliminary parsing using $macro.

Angus




Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Angus Leeming
Jean-Marc Lasgouttes wrote:

 Angus == Angus Leeming [EMAIL PROTECTED] writes:
 
 Angus Not convincingly. I have been looking at this code hard over
 Angus the w/e in an effort to understand it. I'll get back to you
 Angus when I do. Mean while, throw the patch away.
 
 OK.
 
 Angus Here, however is my current state of knowledge (just for your
 Angus delectation ;-)
 
 :) It seems to be an interesting mess...

Ok, JMarc. I dug deep enough to understand how it works and have developed a 
gruding admiration for it. I append 'lookAheadToken' (with some extra print 
statements). The guts of it is this line:

if ($$in =~ 
/^(?:\s*)(?:$Text::TeX::commentpattern)?($Text::TeX::tokenpattern)/o) {

This says: if this regex matches '$$in' then...

It could be rewritten as
if ($$in =~ /^{?:$RE1)(?:$RE2)?($RE3) {

which says: 
if $RE1 is matched, store the match in $1
if $RE2 is matched, store the match in $2
else execute $RE3.
$RE1 is ALWAYS matched so long as $$in is not ''.
$RE3 contains our friend $macro.

$macro = '(?:\)|((([^a-zA-Z)])|([a-zA-Z]+))\*?)\s*)';
# 4 321  1 1 12   3   4

This says, if there is a match throw away the leading '\' and store the 
remainder. In this case, it is stored in $3.

$macro will match \X where X is:
case 1: ')' (but not ')*').
case 2: a single char 'not alphabetical, a-z or A-Z', followed by a single 
'*', if present, followed by an arbitrary amount of whitespace.
Thus, matches both '\\' and '\\*'.
case 3: a multi-char, alphabetical string, followed by a single '*', if 
present, followed by an arbitrary amount of whitespace.
Thus, this matches both '\section' and '\section*'.

In conclusion, therefore, my patch _is_ safe and does specialise the test so 
that '\)' (but not '\)*' is counted as a macro.

Convinced yet? If not, add the three print statements below to 
'lookAheadToken' and run 
$ reLyX -f yourfile.tex | less
You'll see it parsing 'syntax.default'.

Angus

  sub lookAheadToken {  # If arg2, will eat one token - WHY!? -Ak
my $txt = shift;
# Call paragraph with no argument to say we're just looking
my $in = $txt-paragraph;
return '' unless $in;   # To be able to match without warnings
my $comment = undef;
if ($$in =~ 
/^(?:\s*)(?:$Text::TeX::commentpattern)?($Text::TeX::tokenpattern)/o) {
+   print \$1 is '$1'\n if (defined $1);
+   print \t\$2 is '$2'\n if (defined $2);
+   print \t\$3 is '$3'\n if (defined $3);
  if (defined $2) {return $1} #if 1 usualtokenclass char, return it 
($1==$2)
  elsif (defined $3) {return \\$3} # Multiletter (\[a-zA-Z]+)
  elsif (defined $1) {return $1} # \ or notusualtokenclass
}
return '';
  }





Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Jean-Marc Lasgouttes
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:

Angus> This patch enables reLyX to handle \(...\)* correctly and not
Angus> generate a pile of crap. I attach a test case so the
Angus> inquisitive can try out reLyX both with and without the patch.

Can you explain a bit how this macro is used? Is there a list of
macros somewhere that accept an optional *? This should probably be
defined in the syntax tables. What happens actually is that * is not
part of the macro, but is a first optional argument to the given
macro. 

Do you handle for example starred version of \\? And also optional
argument to \\ (like \\*[2cm])?

I am not saying that your patch is wrong, I just want to understand
what is going on... It seems to me that your code implies that only
macros with alphabetic names can have optional *. This is completely
false, actually. I think the handling og * should be done at the same
place as the handling of [], if this is possible.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Angus Leeming
Jean-Marc Lasgouttes wrote:

>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
> 
> Angus> This patch enables reLyX to handle \(...\)* correctly and not
> Angus> generate a pile of crap. I attach a test case so the
> Angus> inquisitive can try out reLyX both with and without the
> patch.
> 
> Can you explain a bit how this macro is used?

Not convincingly. I have been looking at this code hard over
the w/e in an effort to understand it. I'll get back to you when I do. 
Mean while, throw the patch away.

Here, however is my current state of knowledge (just for 
your delectation ;-)

Basically, the regex $macro is used by two subroutines, 
'lookAheadToken' and 'eatMultiToken'. Both subroutines are used both 
by the main TeX parser, TeX.pm, and by Amir's LyX-centric code.

For example, 'eat' is the main subroutine to read in a file and split 
it into tokens. Our own use of the TeX parser is so simple it may be 
written as
sub process {
my $txt = shift;
my $eaten;
while (defined ($eaten = $txt->eat)) {
;
}
}
The real process is more complex than this but we don't pass the 
other, optional args, so it collapses to this. As you see, 'eat' is 
fundamental. I am still trying to decipher it, but 'lookAheadToken' 
and 'eatMultiToken' are both central to its operation.

'lookAheadToken' is only a few lines long, so I hoped to be able to 
understand it:

# return next token without eating it. Return '' if end of paragraph
  sub lookAheadToken {  # If arg2, will eat one token - WHY!? -Ak
my $txt = shift;
# Call paragraph with no argument to say we're "just looking"
my $in = $txt->paragraph;
return '' unless $in;   # To be able to match without warnings
my $comment = undef;
if ($$in =~ 
/^(?:\s*)(?:$Text::TeX::commentpattern)?($Text::TeX::tokenpattern)/o) {
  if (defined $2) {return $1} #if 1 usualtokenclass char, return it ($1==$2)
  elsif (defined $3) {return "\\$3"} # Multiletter (\[a-zA-Z]+)
  elsif (defined $1) {return $1} # \" or notusualtokenclass
}
return '';
  }

The guts of the routine lies in that regex, which I'm still trying 
to deciper. In turn, $Text::TeX::tokenpattern is a string made up of 
other strings.

$macro = '(?:[^a-zA-Z]\*?|([a-zA-Z]+\*?)\s*)'; # Has one level of grouping
$active = "$macro|\\\$\\\$|\\^\\^.|$notusualtokenclass"; # 1 level of grouping
$tokenpattern = "($usualtokenclass)|$active"; # Two levels of grouping

So, when I understand these 3 regexes and the one in lookAheadToken 
and I'll understand that subroutine.

> Is there a list of macros somewhere that accept an optional *?

See lib/reLyX/syntax.default. Macros are defined explicitly as
\section
\section*

However, this is used after the initial parsing of the TeX file using
'lookAheadToken' and 'eatMultiToken'. At least that's my understanding 
to date. So, $macro is absolutely crucial to the success of the whole
scheme. If it fails, nothing will work.

> macros somewhere that accept an optional *? This should probably be
> defined in the syntax tables. What happens actually is that * is not
> part of the macro, but is a first optional argument to the given
> macro.
> 
> Do you handle for example starred version of \\? And also optional
> argument to \\ (like \\*[2cm])?

Don't know yet.

> I am not saying that your patch is wrong, I just want to understand
> what is going on... It seems to me that your code implies that only
> macros with alphabetic names can have optional *. This is completely
> false, actually. I think the handling og * should be done at the
> same place as the handling of [], if this is possible.

I will not rewrite the TeX parser. I propose a match that fixes a
bug. As I see it, the use of the regex in question is so fundamental 
to the operation of the TeX parser that the change will either work or 
it won't. There will be no 'half-way house'. 

However, I do understand your concerns (indeed, I share them), and
willl attempt to understand the code properly.

regards,
Angus

ps. perl is foul and I parser built out of regexes is fouler.





Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Jean-Marc Lasgouttes
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:

Angus> Not convincingly. I have been looking at this code hard over
Angus> the w/e in an effort to understand it. I'll get back to you
Angus> when I do. Mean while, throw the patch away.

OK.

Angus> Here, however is my current state of knowledge (just for your
Angus> delectation ;-)

:) It seems to be an interesting mess...

>> Is there a list of macros somewhere that accept an optional *?

Angus> See lib/reLyX/syntax.default. Macros are defined explicitly as
Angus> \section \section*

So they are considered as diffrent macros, right?

Angus> I will not rewrite the TeX parser. I propose a match that fixes
Angus> a bug. As I see it, the use of the regex in question is so
Angus> fundamental to the operation of the TeX parser that the change
Angus> will either work or it won't. There will be no 'half-way
Angus> house'.

That's fair.

JMarc



Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Angus Leeming
On Monday 10 February 2003 3:53 pm, Jean-Marc Lasgouttes wrote:
> >> Is there a list of macros somewhere that accept an optional *?
>
> Angus> See lib/reLyX/syntax.default. Macros are defined explicitly as
> Angus> \section \section*
>
> So they are considered as diffrent macros, right?

Yes. The preliminary parsing of the file by TeX.pm's 'eat' subroutine uses the 
$macro regex to decide what is a macro. It therefore recognises \section and 
\section* as valid 'possible' macro names as I understand it. I haven't yet 
established exactly what part syntax.default plays in all this, but it is 
certainly downstream of the preliminary parsing using $macro.

Angus




Re: [patch] reLyX and \(...\)*

2003-02-10 Thread Angus Leeming
Jean-Marc Lasgouttes wrote:

>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
> 
> Angus> Not convincingly. I have been looking at this code hard over
> Angus> the w/e in an effort to understand it. I'll get back to you
> Angus> when I do. Mean while, throw the patch away.
> 
> OK.
> 
> Angus> Here, however is my current state of knowledge (just for your
> Angus> delectation ;-)
> 
> :) It seems to be an interesting mess...

Ok, JMarc. I dug deep enough to understand how it works and have developed a 
gruding admiration for it. I append 'lookAheadToken' (with some extra print 
statements). The guts of it is this line:

if ($$in =~ 
/^(?:\s*)(?:$Text::TeX::commentpattern)?($Text::TeX::tokenpattern)/o) {

This says: if this regex matches '$$in' then...

It could be rewritten as
if ($$in =~ /^{?:$RE1)(?:$RE2)?($RE3) {

which says: 
if $RE1 is matched, store the match in $1
if $RE2 is matched, store the match in $2
else execute $RE3.
$RE1 is ALWAYS matched so long as $$in is not ''.
$RE3 contains our friend $macro.

$macro = '(?:\)|((([^a-zA-Z)])|([a-zA-Z]+))\*?)\s*)';
# 4 321  1 1 12   3   4

This says, if there is a match throw away the leading '\' and store the 
remainder. In this case, it is stored in $3.

$macro will match \X where X is:
case 1: ')' (but not ')*').
case 2: a single char 'not alphabetical, a-z or A-Z', followed by a single 
'*', if present, followed by an arbitrary amount of whitespace.
Thus, matches both '\\' and '\\*'.
case 3: a multi-char, alphabetical string, followed by a single '*', if 
present, followed by an arbitrary amount of whitespace.
Thus, this matches both '\section' and '\section*'.

In conclusion, therefore, my patch _is_ safe and does specialise the test so 
that '\)' (but not '\)*' is counted as a macro.

Convinced yet? If not, add the three print statements below to 
'lookAheadToken' and run 
$ reLyX -f yourfile.tex | less
You'll see it parsing 'syntax.default'.

Angus

  sub lookAheadToken {  # If arg2, will eat one token - WHY!? -Ak
my $txt = shift;
# Call paragraph with no argument to say we're "just looking"
my $in = $txt->paragraph;
return '' unless $in;   # To be able to match without warnings
my $comment = undef;
if ($$in =~ 
/^(?:\s*)(?:$Text::TeX::commentpattern)?($Text::TeX::tokenpattern)/o) {
+   print "\$1 is '$1'\n" if (defined $1);
+   print "\t\$2 is '$2'\n" if (defined $2);
+   print "\t\$3 is '$3'\n" if (defined $3);
  if (defined $2) {return $1} #if 1 usualtokenclass char, return it 
($1==$2)
  elsif (defined $3) {return "\\$3"} # Multiletter (\[a-zA-Z]+)
  elsif (defined $1) {return $1} # \" or notusualtokenclass
}
return '';
  }





[patch] reLyX and \(...\)*

2003-02-07 Thread Angus Leeming
This patch enables reLyX to handle \(...\)* correctly and not generate a 
pile of crap. I attach a test case so the inquisitive can try out reLyX 
both with and without the patch.

The last time I applied this, I wasn't careful enough and broke reLyX in 
other respects. I have been more careful this time, exporting the UserGuide 
to tex, running that through reLyX and re-exporting to tex. The resultant 
tex files are functionally the same and are broken only because reLyX 
doesn't import:
\usepackage{rotating}
\IfFileExists{url.sty}{\usepackage{url}}

and gets confused in a tabular. The errors are identical, with and without 
my patch. I'll try to get to the bottom of them, but for now I'm going to 
apply this to the 1.4.x tree.

JMarc, please consider for the 1.3.x branch.

-- 
Angus
Index: lib/reLyX/Text/TeX.pm
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/Text/TeX.pm,v
retrieving revision 1.3
diff -u -p -r1.3 TeX.pm
--- lib/reLyX/Text/TeX.pm	1 Feb 2003 17:46:18 -	1.3
+++ lib/reLyX/Text/TeX.pm	7 Feb 2003 14:01:02 -
@@ -96,13 +96,22 @@ $notusualtoks =  . '\${}^_~@%'; #
 $notusualtokenclass = [$notusualtoks];
 $usualtokenclass = [^$notusualtoks];
 
-# Original $macro wouldn't recognize, e.g., '\section*'. Added '\*?' - Ak
-# (Had to add it for \section and \\ separately.)
-#\ or \frac, e.g. Note that it eats whitespace AFTER the token. This is
-# correct LaTeX behavior, but if text follows such a macro, and you just
-# print out the macro  then the text, they will run together.
-$macro = '(?:[^a-zA-Z]\*?|([a-zA-Z]+\*?)\s*)'; # Has one level of grouping
-#$macro = '(?:[^a-zA-Z]|([a-zA-Z]+)\s*)'; # Contains one level of grouping
+# The $macro RE matches LaTeX macros. Here's exactly what it does:
+# $macro = (?:RE)
+# This matches either '\\' or \RE where RE = RE1 or RE2
+# RE1 = '\)', so $macro will match the end of a math environment, '\)'
+# RE2 = (((RE3 or RE4)\*?)\s*) where
+# RE3 and RE4 can each be followed by zero or one asterisks. Either is still
+# a macro. Ditto, trailing whitespace is included in the token because that's
+# what LaTeX does.
+# RE3 = '([^a-zA-Z)])' matches a single non-alphabetic char. We already
+# test for '\)', so that is explictly excluded from RE3 because '\)*' is not
+# a macro. Rather it is '\)' followed by an asterisk.
+# RE4 = '([a-zA-Z]+\*?)'
+# Ie, one or more alphabetic chars followed by zero or 1 asterisks
+# Eg, \section or \section*
+# Putting all this together:
+$macro = '(?:\)|((([^a-zA-Z)])|([a-zA-Z]+))\*?)\s*)';
 
 # active is a backslashed macro or $$ (same as \[) or ^^ followed by a char
 #(^^A means ASCII(1), e.g. See the TeXbook) or a special character like ~

\documentclass{article}
\begin{document}

a block of math followed by a '*': \(a=b\)*. The asterisk is part of the text.
\end{document}



[patch] reLyX and \(...\)*

2003-02-07 Thread Angus Leeming
This patch enables reLyX to handle \(...\)* correctly and not generate a 
pile of crap. I attach a test case so the inquisitive can try out reLyX 
both with and without the patch.

The last time I applied this, I wasn't careful enough and broke reLyX in 
other respects. I have been more careful this time, exporting the UserGuide 
to tex, running that through reLyX and re-exporting to tex. The resultant 
tex files are functionally the same and are broken only because reLyX 
doesn't import:
\usepackage{rotating}
\IfFileExists{url.sty}{\usepackage{url}}

and gets confused in a tabular. The errors are identical, with and without 
my patch. I'll try to get to the bottom of them, but for now I'm going to 
apply this to the 1.4.x tree.

JMarc, please consider for the 1.3.x branch.

-- 
Angus
Index: lib/reLyX/Text/TeX.pm
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/Text/TeX.pm,v
retrieving revision 1.3
diff -u -p -r1.3 TeX.pm
--- lib/reLyX/Text/TeX.pm	1 Feb 2003 17:46:18 -	1.3
+++ lib/reLyX/Text/TeX.pm	7 Feb 2003 14:01:02 -
@@ -96,13 +96,22 @@ $notusualtoks = "" . '\${}^_~&@%'; #
 $notusualtokenclass = "[$notusualtoks]";
 $usualtokenclass = "[^$notusualtoks]";
 
-# Original $macro wouldn't recognize, e.g., '\section*'. Added '\*?' - Ak
-# (Had to add it for \section and \\ separately.)
-#\" or \frac, e.g. Note that it eats whitespace AFTER the token. This is
-# correct LaTeX behavior, but if text follows such a macro, and you just
-# print out the macro & then the text, they will run together.
-$macro = '(?:[^a-zA-Z]\*?|([a-zA-Z]+\*?)\s*)'; # Has one level of grouping
-#$macro = '(?:[^a-zA-Z]|([a-zA-Z]+)\s*)'; # Contains one level of grouping
+# The $macro RE matches LaTeX macros. Here's exactly what it does:
+# $macro = (?:RE)
+# This matches either '\\' or \RE where RE = RE1 or RE2
+# RE1 = '\)', so $macro will match the end of a math environment, '\)'
+# RE2 = (((RE3 or RE4)\*?)\s*) where
+# RE3 and RE4 can each be followed by zero or one asterisks. Either is still
+# a macro. Ditto, trailing whitespace is included in the token because that's
+# what LaTeX does.
+# RE3 = '([^a-zA-Z)])' matches a single non-alphabetic char. We already
+# test for '\)', so that is explictly excluded from RE3 because '\)*' is not
+# a macro. Rather it is '\)' followed by an asterisk.
+# RE4 = '([a-zA-Z]+\*?)'
+# Ie, one or more alphabetic chars followed by zero or 1 asterisks
+# Eg, \section or \section*
+# Putting all this together:
+$macro = '(?:\)|((([^a-zA-Z)])|([a-zA-Z]+))\*?)\s*)';
 
 # active is a backslashed macro or $$ (same as \[) or ^^ followed by a char
 #(^^A means ASCII(1), e.g. See the TeXbook) or a special character like ~

\documentclass{article}
\begin{document}

a block of math followed by a '*': \(a=b\)*. The asterisk is part of the text.
\end{document}



Re: [patch] relyx

2003-01-21 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| [EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:
| 
| | Can some of you relyx people have a look at case 638 and see if this
| | patch has any relevance?
| | 
| | It kindo seems that it fixes things, but I won't apply anything until
| | I have confirmations.

This patch became a bit larger than intended, due to ws changes.

This is the cut down version. 

| @@ -1400,7 +1400,8 @@ sub ConvertToLayout {
|  print \nChanging $dummy $name to layout $layout if $debug_on;
|  
|  # Nest if the layout stack has more than just Standard in it
| -if ($#{$CurrentLayoutStack}  0) {
| +if ($#{$CurrentLayoutStack}  0
| +  $CurrentLayoutStack =~ /^$ListLayouts$/o) {
|   # Die here for sections  things that can't be nested!
|   print  Nesting! if $debug_on;
|   print OUTFILE \n\\begin_deeper ;
| @@ -1474,7 +1475,8 @@ sub EndLayout {
|  # \end_deeper \begin_deeper in the LyX file. It's sloppy
|  # but it works, and LyX will get rid of it when it
|  # resaves the file.
| -if ($#{$CurrentLayoutStack}  0) {
| +if ($#{$CurrentLayoutStack}  0
| +  $CurrentLayoutStack =~ /^$ListLayouts$/o) {
|   print  End Nesting! if $debug_on;
|   print OUTFILE \n\\end_deeper ;
|  }

-- 
Lgb



Re: [patch] relyx

2003-01-21 Thread José Matos
On Tuesday 21 January 2003 09:19, Lars Gullik Bjønnes wrote:

 This patch became a bit larger than intended, due to ws changes.

  I noticed that, it was the reason why I didn't look to it before. :-)

 This is the cut down version.

 | @@ -1400,7 +1400,8 @@ sub ConvertToLayout {
 |  print \nChanging $dummy $name to layout $layout if $debug_on;
 |
 |  # Nest if the layout stack has more than just Standard in it
 | -if ($#{$CurrentLayoutStack}  0) {
 | +if ($#{$CurrentLayoutStack}  0
 | +$CurrentLayoutStack =~ /^$ListLayouts$/o) {
 | # Die here for sections  things that can't be nested!
 | print  Nesting! if $debug_on;
 | print OUTFILE \n\\begin_deeper ;
 | @@ -1474,7 +1475,8 @@ sub EndLayout {
 |  # \end_deeper \begin_deeper in the LyX file. It's sloppy
 |  # but it works, and LyX will get rid of it when it
 |  # resaves the file.
 | -if ($#{$CurrentLayoutStack}  0) {
 | +if ($#{$CurrentLayoutStack}  0
 | +$CurrentLayoutStack =~ /^$ListLayouts$/o) {
 | print  End Nesting! if $debug_on;
 | print OUTFILE \n\\end_deeper ;
 |  }

  I am not a reLyX people :-), but I see the logic of your change and I say go 
with it. To be on the safe side you need Kayvan's opinion. :-)
-- 
José Abílio



Re: [patch] relyx

2003-01-21 Thread Lars Gullik Bjønnes
José  Matos [EMAIL PROTECTED] writes:

|   I am not a reLyX people :-), but I see the logic of your change and I say go 
| with it. To be on the safe side you need Kayvan's opinion. :-)

Some more testing on tex files is also needed.

-- 
Lgb



Re: [patch] relyx

2003-01-21 Thread Juergen Spitzmueller
Juergen Spitzmueller wrote:
 This does still loop on my test file (export -- reimport the attached LyX
 file).

If I change the order in the reLyXed lyx file:

\layout Enumerate
+ \begin_deeper
\begin_float tab
- \begin_deeper
\layout Standard
\align center
\LyXTable
...

then lyx reads the file correctly.

HTH,
Jürgen.



Re: [patch] relyx

2003-01-21 Thread Juergen Spitzmueller
Lars Gullik Bjønnes wrote:
 This is the cut down version.

 | @@ -1400,7 +1400,8 @@ sub ConvertToLayout {
 |  print \nChanging $dummy $name to layout $layout if $debug_on;
 |  
 |  # Nest if the layout stack has more than just Standard in it
 | -if ($#{$CurrentLayoutStack}  0) {
 | +if ($#{$CurrentLayoutStack}  0
 | +  $CurrentLayoutStack =~ /^$ListLayouts$/o) {
 |   # Die here for sections  things that can't be nested!
 |   print  Nesting! if $debug_on;
 |   print OUTFILE \n\\begin_deeper ;
 | @@ -1474,7 +1475,8 @@ sub EndLayout {
 |  # \end_deeper \begin_deeper in the LyX file. It's sloppy
 |  # but it works, and LyX will get rid of it when it
 |  # resaves the file.
 | -if ($#{$CurrentLayoutStack}  0) {
 | +if ($#{$CurrentLayoutStack}  0
 | +  $CurrentLayoutStack =~ /^$ListLayouts$/o) {
 |   print  End Nesting! if $debug_on;
 |   print OUTFILE \n\\end_deeper ;
 |  }

This does still loop on my test file (export -- reimport the attached LyX 
file).

Jürgen.
#LyX 1.3 created this file. For more info see http://www.lyx.org/
\lyxformat 221
\textclass article
\language ngerman
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language german
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Enumerate

one
\layout Enumerate


\begin_inset Float table
wide false
collapsed true

\layout Standard
\align center 

\begin_inset  Tabular
lyxtabular version=3 rows=1 columns=1
features
column alignment=center valignment=top leftline=true rightline=true width=0(null)
row topline=true bottomline=true
cell alignment=center valignment=top topline=true leftline=true rightline=true usebox=none
\begin_inset Text

\layout Standard

\end_inset 
/cell
/row
/lyxtabular

\end_inset 


\layout Caption

a table
\end_inset 


\layout Enumerate

three
\the_end



Re: [patch] relyx

2003-01-21 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Juergen Spitzmueller) writes:

| Juergen Spitzmueller wrote:
|  This does still loop on my test file (export -- reimport the attached LyX
|  file).
| 
| If I change the order in the reLyXed lyx file:
| 
| \layout Enumerate
| + \begin_deeper
| \begin_float tab
| - \begin_deeper
| \layout Standard
| \align center
| \LyXTable
| ...
| 
| then lyx reads the file correctly.

Yes, and this is part of the problem... when entering a float the
current layoutstack should be pushed on a stack...

and popped again when the float is handled.

-- 
Lgb



Re: [patch] relyx

2003-01-21 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| [EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:
| 
| | Can some of you relyx people have a look at case 638 and see if this
| | patch has any relevance?
| | 
| | It kindo seems that it fixes things, but I won't apply anything until
| | I have confirmations.

This patch became a bit larger than intended, due to ws changes.

This is the cut down version. 

| @@ -1400,7 +1400,8 @@ sub ConvertToLayout {
|  print "\nChanging $dummy $name to layout $layout" if $debug_on;
|  
|  # Nest if the layout stack has more than just "Standard" in it
| -if ($#{$CurrentLayoutStack} > 0) {
| +if ($#{$CurrentLayoutStack} > 0
| + && $CurrentLayoutStack =~ /^$ListLayouts$/o) {
|   # Die here for sections & things that can't be nested!
|   print " Nesting!" if $debug_on;
|   print OUTFILE "\n\\begin_deeper ";
| @@ -1474,7 +1475,8 @@ sub EndLayout {
|  # \end_deeper \begin_deeper in the LyX file. It's sloppy
|  # but it works, and LyX will get rid of it when it
|  # resaves the file.
| -if ($#{$CurrentLayoutStack} > 0) {
| +if ($#{$CurrentLayoutStack} > 0
| + && $CurrentLayoutStack =~ /^$ListLayouts$/o) {
|   print " End Nesting!" if $debug_on;
|   print OUTFILE "\n\\end_deeper ";
|  }

-- 
Lgb



Re: [patch] relyx

2003-01-21 Thread José Matos
On Tuesday 21 January 2003 09:19, Lars Gullik Bjønnes wrote:
>
> This patch became a bit larger than intended, due to ws changes.

  I noticed that, it was the reason why I didn't look to it before. :-)

> This is the cut down version.
>
> | @@ -1400,7 +1400,8 @@ sub ConvertToLayout {
> |  print "\nChanging $dummy $name to layout $layout" if $debug_on;
> |
> |  # Nest if the layout stack has more than just "Standard" in it
> | -if ($#{$CurrentLayoutStack} > 0) {
> | +if ($#{$CurrentLayoutStack} > 0
> | +   && $CurrentLayoutStack =~ /^$ListLayouts$/o) {
> | # Die here for sections & things that can't be nested!
> | print " Nesting!" if $debug_on;
> | print OUTFILE "\n\\begin_deeper ";
> | @@ -1474,7 +1475,8 @@ sub EndLayout {
> |  # \end_deeper \begin_deeper in the LyX file. It's sloppy
> |  # but it works, and LyX will get rid of it when it
> |  # resaves the file.
> | -if ($#{$CurrentLayoutStack} > 0) {
> | +if ($#{$CurrentLayoutStack} > 0
> | +   && $CurrentLayoutStack =~ /^$ListLayouts$/o) {
> | print " End Nesting!" if $debug_on;
> | print OUTFILE "\n\\end_deeper ";
> |  }

  I am not a reLyX people :-), but I see the logic of your change and I say go 
with it. To be on the safe side you need Kayvan's opinion. :-)
-- 
José Abílio



Re: [patch] relyx

2003-01-21 Thread Lars Gullik Bjønnes
José  Matos <[EMAIL PROTECTED]> writes:

|   I am not a reLyX people :-), but I see the logic of your change and I say go 
| with it. To be on the safe side you need Kayvan's opinion. :-)

Some more testing on tex files is also needed.

-- 
Lgb



Re: [patch] relyx

2003-01-21 Thread Juergen Spitzmueller
Juergen Spitzmueller wrote:
> This does still loop on my test file (export -- reimport the attached LyX
> file).

If I change the order in the reLyXed lyx file:

\layout Enumerate
+ \begin_deeper
\begin_float tab
- \begin_deeper
\layout Standard
\align center
\LyXTable
...

then lyx reads the file correctly.

HTH,
Jürgen.



Re: [patch] relyx

2003-01-21 Thread Juergen Spitzmueller
Lars Gullik Bjønnes wrote:
> This is the cut down version.
>
> | @@ -1400,7 +1400,8 @@ sub ConvertToLayout {
> |  print "\nChanging $dummy $name to layout $layout" if $debug_on;
> |  
> |  # Nest if the layout stack has more than just "Standard" in it
> | -if ($#{$CurrentLayoutStack} > 0) {
> | +if ($#{$CurrentLayoutStack} > 0
> | + && $CurrentLayoutStack =~ /^$ListLayouts$/o) {
> |   # Die here for sections & things that can't be nested!
> |   print " Nesting!" if $debug_on;
> |   print OUTFILE "\n\\begin_deeper ";
> | @@ -1474,7 +1475,8 @@ sub EndLayout {
> |  # \end_deeper \begin_deeper in the LyX file. It's sloppy
> |  # but it works, and LyX will get rid of it when it
> |  # resaves the file.
> | -if ($#{$CurrentLayoutStack} > 0) {
> | +if ($#{$CurrentLayoutStack} > 0
> | + && $CurrentLayoutStack =~ /^$ListLayouts$/o) {
> |   print " End Nesting!" if $debug_on;
> |   print OUTFILE "\n\\end_deeper ";
> |  }

This does still loop on my test file (export -- reimport the attached LyX 
file).

Jürgen.
#LyX 1.3 created this file. For more info see http://www.lyx.org/
\lyxformat 221
\textclass article
\language ngerman
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language german
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Enumerate

one
\layout Enumerate


\begin_inset Float table
wide false
collapsed true

\layout Standard
\align center 

\begin_inset  Tabular





\begin_inset Text

\layout Standard

\end_inset 




\end_inset 


\layout Caption

a table
\end_inset 


\layout Enumerate

three
\the_end



Re: [patch] relyx

2003-01-21 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Juergen Spitzmueller) writes:

| Juergen Spitzmueller wrote:
| > This does still loop on my test file (export -- reimport the attached LyX
| > file).
| 
| If I change the order in the reLyXed lyx file:
| 
| \layout Enumerate
| + \begin_deeper
| \begin_float tab
| - \begin_deeper
| \layout Standard
| \align center
| \LyXTable
| ...
| 
| then lyx reads the file correctly.

Yes, and this is part of the problem... when entering a float the
current layoutstack should be pushed on a stack...

and popped again when the float is handled.

-- 
Lgb



[patch] relyx

2003-01-19 Thread Lars Gullik Bjønnes

Can some of you relyx people have a look at case 638 and see if this
patch has any relevance?

It kindo seems that it fixes things, but I won't apply anything until
I have confirmations.


-- 
Lgb



Re: [patch] relyx

2003-01-19 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| Can some of you relyx people have a look at case 638 and see if this
| patch has any relevance?
| 
| It kindo seems that it fixes things, but I won't apply anything until
| I have confirmations.


? relyx.diff
Index: BasicLyX.pm
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/BasicLyX.pm,v
retrieving revision 1.5
diff -u -p -r1.5 BasicLyX.pm
--- BasicLyX.pm	7 Jan 2003 14:30:52 -	1.5
+++ BasicLyX.pm	19 Jan 2003 11:05:59 -
@@ -185,13 +185,13 @@ my %TextTransTable = (
 # E.g., \ref{foo} -'\begin_inset LatexCommand \ref{foo}\n\n\end_inset \n'
 # (Some take arguments, others don't)
 my @LatexCommands = map {\\$_} qw(ref pageref label cite bibliography
-	 index printindex tableofcontents
- listofalgorithms listoftables listoffigures);
+ index printindex tableofcontents
+ listofalgorithms listoftables listoffigures);
 my @IncludeCommands = map {\\$_} qw(input include);
 # Included postscript files
 # LyX 1.0 can't do \includegraphics*!
 my @GraphicsCommands = map {\\$_} qw(epsf epsffile epsfbox
-   psfig epsfig includegraphics);
+   psfig epsfig includegraphics);
 
 # Accents. Most of these take an argument -- the thing to accent
 # (\l and \L are handled as InsetLatexAccents, so they go here too)
@@ -238,7 +238,7 @@ sub call_parser {
 #Type=report_args and count=1
 # Note that we don't have to bother putting in tokens which will be simply
 #translated (e.g., from %TextTokenTransTable).
-my %MyTokens = ( 
+my %MyTokens = (
 	'{' = $Text::TeX::Tokens{'{'},
 	'}' = $Text::TeX::Tokens{'}'},
 	'\begin' = $Text::TeX::Tokens{'\begin'},
@@ -264,7 +264,7 @@ sub call_parser {
 	# Just pretend they actually ARE new paragraph markers!
 	'\maketitle' = {'class' = 'Text::TeX::Paragraph'},
 );
-
+
 # Now add to MyTokens all of the commands that were read from the
 #commands file by package ReadCommands
 ReadCommands::Merge(\%MyTokens);
@@ -311,8 +311,8 @@ sub basic_lyx {
 #(2) allows us to use things like next and last
 TYPESW: for ($type) {
 
-# some pre-case work
-s/^Text::TeX:://o or die unknown token?!;
+	# some pre-case work
+	s/^Text::TeX:://o or die unknown token?!;
 	my ($dummy, $tok);
 	my ($thistable);
 
@@ -332,8 +332,8 @@ sub basic_lyx {
 	}
 	}
 
-# Handle blank lines.
-if (m/^Paragraph$/o) {
+	# Handle blank lines.
+	if (m/^Paragraph$/o) {
 	# $INP 0 means We will need a new layout command
 	$IsNewParagraph = 1;
 
@@ -341,22 +341,22 @@ sub basic_lyx {
 	#unless there's an \item command
 	$MayBeDeeper = 1;
 
-last TYPESW;
-}
+	last TYPESW;
+	}
 
 	# If, e.g., there's just a comment in this token, don't do anything
 	# This actually shouldn't happen if CleanTeX has already removed them
 	last TYPESW if !defined $eaten-print;
-
-# Handle LaTeX tokens
-if (/^Token$/o) {
+
+	# Handle LaTeX tokens
+	if (/^Token$/o) {
 
 	my $name = $eaten-token_name; # name of the token, e.g., \large
 	print '$name'  if $debug_on;
 
 	# Tokens which turn into a bit of LyX text
 	if (exists $TextTokenTransTable{$name}) {
-	CheckForNewParagraph; #Start new paragraph if necessary
+		CheckForNewParagraph; #Start new paragraph if necessary
 
 		my $to_print = $TextTokenTransTable{$name};
 
@@ -383,8 +383,8 @@ sub basic_lyx {
 	# Handle tokens that LyX translates as a LatexCommand inset
 	} elsif (grep {$_ eq $name} @LatexCommands) {
 		CheckForNewParagraph; #Start new paragraph if necessary
-	print OUTFILE $pre_space\n\\begin_inset LatexCommand ,
-		   $name,
+		print OUTFILE $pre_space\n\\begin_inset LatexCommand ,
+			   $name,
 			  \n\n\\end_inset \n\n;
 
 	# Math -- copy verbatim until you're done
@@ -400,13 +400,13 @@ sub basic_lyx {
 		print OUTFILE $dummy;
 
 	} elsif ($name eq '\)' || $name eq '\]') {
-	# end math
+		# end math
 		print OUTFILE $name\n\\end_inset \n\n;
 		print \nDone copying math ending with '$name' if $debug_on;
 
 	# Items in list environments
 	} elsif ($name eq '\item') {
-		
+
 		# What if we had a nested Standard paragraph?
 		# Then write \end_deeper to finish the standard layout
 		# before we write the new \layout ListEnv command
@@ -414,10 +414,10 @@ sub basic_lyx {
 		pop (@$CurrentLayoutStack); # take Standard off the stack
 		print OUTFILE \n\\end_deeper ;
 		print \nCurrent Layout Stack: @$CurrentLayoutStack
-		  if $debug_on;
+			  if $debug_on;
 		} # end deeper if
 
-		# Upcoming text (the item) will be a new paragraph, 
+		# Upcoming text (the item) will be a new paragraph,
 		#requiring a new layout command based on whichever
 		#kind of list environment we're in
 		

[patch] relyx

2003-01-19 Thread Lars Gullik Bjønnes

Can some of you relyx people have a look at case 638 and see if this
patch has any relevance?

It kindo seems that it fixes things, but I won't apply anything until
I have confirmations.


-- 
Lgb



Re: [patch] relyx

2003-01-19 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:

| Can some of you relyx people have a look at case 638 and see if this
| patch has any relevance?
| 
| It kindo seems that it fixes things, but I won't apply anything until
| I have confirmations.


? relyx.diff
Index: BasicLyX.pm
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/BasicLyX.pm,v
retrieving revision 1.5
diff -u -p -r1.5 BasicLyX.pm
--- BasicLyX.pm	7 Jan 2003 14:30:52 -	1.5
+++ BasicLyX.pm	19 Jan 2003 11:05:59 -
@@ -185,13 +185,13 @@ my %TextTransTable = (
 # E.g., \ref{foo} ->'\begin_inset LatexCommand \ref{foo}\n\n\end_inset \n'
 # (Some take arguments, others don't)
 my @LatexCommands = map {"\\$_"} qw(ref pageref label cite bibliography
-	 index printindex tableofcontents
- listofalgorithms listoftables listoffigures);
+ index printindex tableofcontents
+ listofalgorithms listoftables listoffigures);
 my @IncludeCommands = map {"\\$_"} qw(input include);
 # Included postscript files
 # LyX 1.0 can't do \includegraphics*!
 my @GraphicsCommands = map {"\\$_"} qw(epsf epsffile epsfbox
-   psfig epsfig includegraphics);
+   psfig epsfig includegraphics);
 
 # Accents. Most of these take an argument -- the thing to accent
 # (\l and \L are handled as InsetLatexAccents, so they go here too)
@@ -238,7 +238,7 @@ sub call_parser {
 #Type=>report_args and count=>1
 # Note that we don't have to bother putting in tokens which will be simply
 #translated (e.g., from %TextTokenTransTable).
-my %MyTokens = ( 
+my %MyTokens = (
 	'{' => $Text::TeX::Tokens{'{'},
 	'}' => $Text::TeX::Tokens{'}'},
 	'\begin' => $Text::TeX::Tokens{'\begin'},
@@ -264,7 +264,7 @@ sub call_parser {
 	# Just pretend they actually ARE new paragraph markers!
 	'\maketitle' => {'class' => 'Text::TeX::Paragraph'},
 );
-
+
 # Now add to MyTokens all of the commands that were read from the
 #commands file by package ReadCommands
 ::Merge(\%MyTokens);
@@ -311,8 +311,8 @@ sub basic_lyx {
 #(2) allows us to use things like next and last
 TYPESW: for ($type) {
 
-# some pre-case work
-s/^Text::TeX:://o or die "unknown token?!";
+	# some pre-case work
+	s/^Text::TeX:://o or die "unknown token?!";
 	my ($dummy, $tok);
 	my ($thistable);
 
@@ -332,8 +332,8 @@ sub basic_lyx {
 	}
 	}
 
-# Handle blank lines.
-if (m/^Paragraph$/o) {
+	# Handle blank lines.
+	if (m/^Paragraph$/o) {
 	# $INP <>0 means We will need a new layout command
 	$IsNewParagraph = 1;
 
@@ -341,22 +341,22 @@ sub basic_lyx {
 	#unless there's an \item command
 	$MayBeDeeper = 1;
 
-last TYPESW;
-}
+	last TYPESW;
+	}
 
 	# If, e.g., there's just a comment in this token, don't do anything
 	# This actually shouldn't happen if CleanTeX has already removed them
 	last TYPESW if !defined $eaten->print;
-
-# Handle LaTeX tokens
-if (/^Token$/o) {
+
+	# Handle LaTeX tokens
+	if (/^Token$/o) {
 
 	my $name = $eaten->token_name; # name of the token, e.g., "\large"
 	print "'$name' " if $debug_on;
 
 	# Tokens which turn into a bit of LyX text
 	if (exists $TextTokenTransTable{$name}) {
-	 #Start new paragraph if necessary
+		 #Start new paragraph if necessary
 
 		my $to_print = $TextTokenTransTable{$name};
 
@@ -383,8 +383,8 @@ sub basic_lyx {
 	# Handle tokens that LyX translates as a "LatexCommand" inset
 	} elsif (grep {$_ eq $name} @LatexCommands) {
 		 #Start new paragraph if necessary
-	print OUTFILE "$pre_space\n\\begin_inset LatexCommand ",
-		   $name,
+		print OUTFILE "$pre_space\n\\begin_inset LatexCommand ",
+			   $name,
 			  "\n\n\\end_inset \n\n";
 
 	# Math -- copy verbatim until you're done
@@ -400,13 +400,13 @@ sub basic_lyx {
 		print OUTFILE $dummy;
 
 	} elsif ($name eq '\)' || $name eq '\]') {
-	# end math
+		# end math
 		print OUTFILE "$name\n\\end_inset \n\n";
 		print "\nDone copying math ending with '$name'" if $debug_on;
 
 	# Items in list environments
 	} elsif ($name eq '\item') {
-		
+
 		# What if we had a nested "Standard" paragraph?
 		# Then write \end_deeper to finish the standard layout
 		# before we write the new \layout ListEnv command
@@ -414,10 +414,10 @@ sub basic_lyx {
 		pop (@$CurrentLayoutStack); # take "Standard" off the stack
 		print OUTFILE "\n\\end_deeper ";
 		print "\nCurrent Layout Stack: @$CurrentLayoutStack"
-		  if $debug_on;
+			  if $debug_on;
 		} # end deeper if
 
-		# Upcoming text (the item) will be a new paragraph, 
+		# Upcoming text (the item) will be a new paragraph,
 		#requiring a new layout command based on whichever
 		#kind of list environment we're in
 		$IsNewParagraph = 1;
@@ -472,7 +472,7 @@ 

Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Dekel Tsur
On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
 Index: lib/lyx2lyx/lyxconvert_218.py
 ===
 RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
 retrieving revision 1.28
 diff -u -r1.28 lyxconvert_218.py
 --- lib/lyx2lyx/lyxconvert_218.py 2003/01/15 14:17:56 1.28
 +++ lib/lyx2lyx/lyxconvert_218.py 2003/01/16 01:34:36
 @@ -473,7 +473,7 @@
   i = find_token(lines, \\begin_inset LatexCommand \\listof, i)
   if i == -1:
   break
 -type = lines[i][33:-3]
 +type = lines[i][33:-1]
  lines[i] = \\begin_inset FloatList +type
  i = i+1

This is wrong, as files created with LyX uses 
\begin_inset LatexCommand \listoffigures{}
The shortest solution is to use a regular expression:

type = re.search(rlistof(\w*), lines[i]).group(1)[:-1]



Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Michael Schmitt
On Fri, 17 Jan 2003, Dekel Tsur wrote:

 On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
  Index: lib/lyx2lyx/lyxconvert_218.py
  ===
  RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
  retrieving revision 1.28
  diff -u -r1.28 lyxconvert_218.py
  --- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
  +++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
  @@ -473,7 +473,7 @@
  i = find_token(lines, \\begin_inset LatexCommand \\listof, i)
  if i == -1:
  break
  -type = lines[i][33:-3]
  +type = lines[i][33:-1]
   lines[i] = \\begin_inset FloatList +type
   i = i+1

In principle, we should fix reLyX in that case. However, a quick look at
the code tells me that it is probably much more difficult.

If the regex solves the problem, we should commit your proposal.

Michael








Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Dekel Tsur
On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
> Index: lib/lyx2lyx/lyxconvert_218.py
> ===
> RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
> retrieving revision 1.28
> diff -u -r1.28 lyxconvert_218.py
> --- lib/lyx2lyx/lyxconvert_218.py 2003/01/15 14:17:56 1.28
> +++ lib/lyx2lyx/lyxconvert_218.py 2003/01/16 01:34:36
> @@ -473,7 +473,7 @@
>   i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
>   if i == -1:
>   break
> -type = lines[i][33:-3]
> +type = lines[i][33:-1]
>  lines[i] = "\\begin_inset FloatList "+type
>  i = i+1

This is wrong, as files created with LyX uses 
\begin_inset LatexCommand \listoffigures{}
The shortest solution is to use a regular expression:

type = re.search(r"listof(\w*)", lines[i]).group(1)[:-1]



Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Michael Schmitt
On Fri, 17 Jan 2003, Dekel Tsur wrote:

> On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
> > Index: lib/lyx2lyx/lyxconvert_218.py
> > ===
> > RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
> > retrieving revision 1.28
> > diff -u -r1.28 lyxconvert_218.py
> > --- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
> > +++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
> > @@ -473,7 +473,7 @@
> > i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
> > if i == -1:
> > break
> > -type = lines[i][33:-3]
> > +type = lines[i][33:-1]
> >  lines[i] = "\\begin_inset FloatList "+type
> >  i = i+1

In principle, we should fix reLyX in that case. However, a quick look at
the code tells me that it is probably much more difficult.

If the regex solves the problem, we should commit your proposal.

Michael








[PATCH] reLyX and lyx2lyx patches

2003-01-15 Thread Michael Schmitt
Hi,

below please find two patches for lyx2lyx and reLyX. I have already 
posted the patch for reLyX but I am not sure whether I used plain text 
when sending the email.

The following two bugs are fixed:

 - lyx2lyx does not translate listoffigures/listoftables correctly
 - reLyX fails if there is a directory with the same name as
   the basename of a TeX file that is used in an \include statement

Quite trivial stuff, I hope.

As usual, please check and commit.

Michael
Index: lib/lyx2lyx/lyxconvert_218.py
===
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
retrieving revision 1.28
diff -u -r1.28 lyxconvert_218.py
--- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
+++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
@@ -473,7 +473,7 @@
i = find_token(lines, \\begin_inset LatexCommand \\listof, i)
if i == -1:
break
-type = lines[i][33:-3]
+type = lines[i][33:-1]
 lines[i] = \\begin_inset FloatList +type
 i = i+1
 
Index: lib/reLyX/reLyXmain.pl
===
RCS file: /cvs/lyx/lyx-devel/lib/reLyX/reLyXmain.pl,v
retrieving revision 1.4
diff -u -r1.4 reLyXmain.pl
--- lib/reLyX/reLyXmain.pl  2001/08/31 07:54:05 1.4
+++ lib/reLyX/reLyXmain.pl  2003/01/16 01:34:43
@@ -145,9 +145,9 @@
 # Read personal syntax.default, or system-wide if there isn't a personal one
 # Then read other syntax files, given by the -s option
 my $default_file = $dot_lyxdir/reLyX/$syntaxname;
-if (! -e $default_file) {
+if (! -f $default_file) {
 $default_file = $lyxdir/reLyX/$syntaxname;
-die cannot find default syntax file $default_file unless -e $default_file;
+die cannot find default syntax file $default_file unless -f $default_file;
 }
 my @syntaxfiles = ($default_file);
 push (@syntaxfiles, (split(/,/,$opt_s))) if defined $opt_s;
@@ -288,9 +288,9 @@
 #$path .= '/' unless $path =~ /\/$/; # fix BUG in perl5.002 fileparse!
 
 # Try adding .tex to filename if you can't find the file the user input
-unless (-e $File) {
+unless (-f $File) {
 if (! $suffix) { # didn't have a valid suffix. Try adding one
-   if (-e $File.tex) {
+   if (-f $File.tex) {
$suffix = .tex;
} else {
warn \nCan't find input file $File or $File.tex\n;
@@ -322,7 +322,10 @@
 # Check for files that already exist
 my $lname = $PathBase . .lyx;
 if (-e $lname) {
-   if ($opt_f) {
+   if (-d $lname) {
+   warn \nLyX file $lname already exists and is a directory.\n;
+   return @return_error;
+   } elsif ($opt_f) {
warn Will overwrite file $lname\n if $opt_d;
} else {
warn \nLyX file $lname already exists. Use -f to overwrite\n;



[PATCH] reLyX and lyx2lyx patches

2003-01-15 Thread Michael Schmitt
Hi,

below please find two patches for lyx2lyx and reLyX. I have already 
posted the patch for reLyX but I am not sure whether I used plain text 
when sending the email.

The following two bugs are fixed:

 - lyx2lyx does not translate listoffigures/listoftables correctly
 - reLyX fails if there is a directory with the same name as
   the basename of a TeX file that is used in an "\include" statement

Quite trivial stuff, I hope.

As usual, please check and commit.

Michael
Index: lib/lyx2lyx/lyxconvert_218.py
===
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
retrieving revision 1.28
diff -u -r1.28 lyxconvert_218.py
--- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
+++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
@@ -473,7 +473,7 @@
i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
if i == -1:
break
-type = lines[i][33:-3]
+type = lines[i][33:-1]
 lines[i] = "\\begin_inset FloatList "+type
 i = i+1
 
Index: lib/reLyX/reLyXmain.pl
===
RCS file: /cvs/lyx/lyx-devel/lib/reLyX/reLyXmain.pl,v
retrieving revision 1.4
diff -u -r1.4 reLyXmain.pl
--- lib/reLyX/reLyXmain.pl  2001/08/31 07:54:05 1.4
+++ lib/reLyX/reLyXmain.pl  2003/01/16 01:34:43
@@ -145,9 +145,9 @@
 # Read personal syntax.default, or system-wide if there isn't a personal one
 # Then read other syntax files, given by the -s option
 my $default_file = "$dot_lyxdir/reLyX/$syntaxname";
-if (! -e $default_file) {
+if (! -f $default_file) {
 $default_file = "$lyxdir/reLyX/$syntaxname";
-die "cannot find default syntax file $default_file" unless -e $default_file;
+die "cannot find default syntax file $default_file" unless -f $default_file;
 }
 my @syntaxfiles = ($default_file);
 push (@syntaxfiles, (split(/,/,$opt_s))) if defined $opt_s;
@@ -288,9 +288,9 @@
 #$path .= '/' unless $path =~ /\/$/; # fix BUG in perl5.002 fileparse!
 
 # Try adding .tex to filename if you can't find the file the user input
-unless (-e $File) {
+unless (-f $File) {
 if (! $suffix) { # didn't have a valid suffix. Try adding one
-   if (-e "$File.tex") {
+   if (-f "$File.tex") {
$suffix = ".tex";
} else {
warn "\nCan't find input file $File or $File.tex\n";
@@ -322,7 +322,10 @@
 # Check for files that already exist
 my $lname = $PathBase . ".lyx";
 if (-e $lname) {
-   if ($opt_f) {
+   if (-d $lname) {
+   warn "\nLyX file $lname already exists and is a directory.\n";
+   return @return_error;
+   } elsif ($opt_f) {
warn "Will overwrite file $lname\n" if $opt_d;
} else {
warn "\nLyX file $lname already exists. Use -f to overwrite\n";



Re: [patch] reLyX: handle documentclasses with non-alpha characters

2000-11-02 Thread Amir Karger

On Wed, Nov 01, 2000 at 03:35:07PM +0100, Yves Bastide wrote:
 
 reLyX cannot handle document class names with non `word' characters
 (not in [A-Za-z_]), such as article-hermes.  This patch therefore replaces
 \w by \S (non blank) in the regular expression.

Good point.

 Note this is not foolproof, either: perhaps better would be \s*(\S+)\s* or
 something like that.  

Sure, I suppose. New patch below. Jean-Marc, could you apply?

 And verifying if the pattern was found (a class name
 of `2000/06/06' looks surprising :-)

Feel free to add some checks if you'd like. Noone's actually working on
reLyX right now.

-Amir


--- /usr/X11R6/share/lyx/reLyX/MakePreamble.pm  Wed Sep  6 12:44:58 2000
+++ /misc/rlin/usr/X11R6/share/lyx/reLyX/MakePreamble.pmSat Oct 28 17:35:22 
+2000
@@ -179,7 +179,7 @@
 
 # Read the document class, in braces, then convert it to a textclass
 # However, if the user input a different class with the -c option, use that
-s/\s*\{(\w+)\}//;
+s/\s*\{(\S+)\s*\}//;
 my $class = $1;
 $class = $true_class if $true_class; # override from -c option
 die "no document class in file, no -c option given\n" unless $class;




Re: [patch] reLyX: handle documentclasses with non-alpha characters

2000-11-02 Thread Jean-Marc Lasgouttes

 "Amir" == Amir Karger [EMAIL PROTECTED] writes:

Amir Sure, I suppose. New patch below. Jean-Marc, could you apply?

Done.

JMarc



Re: [patch] reLyX: handle documentclasses with non-alpha characters

2000-11-02 Thread Amir Karger

On Wed, Nov 01, 2000 at 03:35:07PM +0100, Yves Bastide wrote:
> 
> reLyX cannot handle document class names with non `word' characters
> (not in [A-Za-z_]), such as article-hermes.  This patch therefore replaces
> \w by \S (non blank) in the regular expression.

Good point.

> Note this is not foolproof, either: perhaps better would be \s*(\S+)\s* or
> something like that.  

Sure, I suppose. New patch below. Jean-Marc, could you apply?

> And verifying if the pattern was found (a class name
> of `2000/06/06' looks surprising :-)

Feel free to add some checks if you'd like. Noone's actually working on
reLyX right now.

-Amir


--- /usr/X11R6/share/lyx/reLyX/MakePreamble.pm  Wed Sep  6 12:44:58 2000
+++ /misc/rlin/usr/X11R6/share/lyx/reLyX/MakePreamble.pmSat Oct 28 17:35:22 
+2000
@@ -179,7 +179,7 @@
 
 # Read the document class, in braces, then convert it to a textclass
 # However, if the user input a different class with the -c option, use that
-s/\s*\{(\w+)\}//;
+s/\s*\{(\S+)\s*\}//;
 my $class = $1;
 $class = $true_class if $true_class; # override from -c option
 die "no document class in file, no -c option given\n" unless $class;




Re: [patch] reLyX: handle documentclasses with non-alpha characters

2000-11-02 Thread Jean-Marc Lasgouttes

> "Amir" == Amir Karger <[EMAIL PROTECTED]> writes:

Amir> Sure, I suppose. New patch below. Jean-Marc, could you apply?

Done.

JMarc



[patch] reLyX: handle documentclasses with non-alpha characters

2000-11-01 Thread Yves Bastide

My last patch for today (-:

reLyX cannot handle document class names with non `word' characters
(not in [A-Za-z_]), such as article-hermes.  This patch therefore replaces
\w by \S (non blank) in the regular expression.
Note this is not foolproof, either: perhaps better would be \s*(\S+)\s* or
something like that.  And verifying if the pattern was found (a class name
of `2000/06/06' looks surprising :-)

Stid

-- 
Yves Bastide| Limos
| +33 (0)4 73 40 77 73


--- /usr/X11R6/share/lyx/reLyX/MakePreamble.pm  Wed Sep  6 12:44:58 2000
+++ /misc/rlin/usr/X11R6/share/lyx/reLyX/MakePreamble.pmSat Oct 28 17:35:22 
+2000
@@ -179,7 +179,7 @@
 
 # Read the document class, in braces, then convert it to a textclass
 # However, if the user input a different class with the -c option, use that
-s/\s*\{(\w+)\}//;
+s/\s*\{(\S+)\}//;
 my $class = $1;
 $class = $true_class if $true_class; # override from -c option
 die "no document class in file, no -c option given\n" unless $class;



[patch] reLyX: handle documentclasses with non-alpha characters

2000-11-01 Thread Yves Bastide

My last patch for today (-:

reLyX cannot handle document class names with non `word' characters
(not in [A-Za-z_]), such as article-hermes.  This patch therefore replaces
\w by \S (non blank) in the regular expression.
Note this is not foolproof, either: perhaps better would be \s*(\S+)\s* or
something like that.  And verifying if the pattern was found (a class name
of `2000/06/06' looks surprising :-)

Stid

-- 
Yves Bastide| Limos
| +33 (0)4 73 40 77 73


--- /usr/X11R6/share/lyx/reLyX/MakePreamble.pm  Wed Sep  6 12:44:58 2000
+++ /misc/rlin/usr/X11R6/share/lyx/reLyX/MakePreamble.pmSat Oct 28 17:35:22 
+2000
@@ -179,7 +179,7 @@
 
 # Read the document class, in braces, then convert it to a textclass
 # However, if the user input a different class with the -c option, use that
-s/\s*\{(\w+)\}//;
+s/\s*\{(\S+)\}//;
 my $class = $1;
 $class = $true_class if $true_class; # override from -c option
 die "no document class in file, no -c option given\n" unless $class;