Re: Different LaTeX output when exporting than when previewing

2017-07-24 Thread Scott Kostyshak
On Fri, Jul 21, 2017 at 08:57:41PM +, Guenter Milde wrote:

> > Good to know that this specific issue is not important, thanks Günter.
> > Yes, I'm still worried about the underlying bug.
> 
> I am not sure this difference is a bug, it may just be some indeterminalism,
> maybe caused by existence or non-existence of an auxiliary or chache file
> (changing the order in which the secondary languages are "identified" by LyX).

Perhaps, but I'm not sure it's not a bug. I thought that there were no
exceptions in theory that the LaTeX output of the LyX GUI should be
equivalent to the LaTeX output from the LyX CL. I think it is fair for
the user to expect that. I think that LyX must be compiled with Qt, so
even if some cache is being used by the GUI, I think it could also be
used from the CL.

Scott


Re: Different LaTeX output when exporting than when previewing

2017-07-21 Thread Guenter Milde
On 2017-07-21, Scott Kostyshak wrote:
> On Tue, Jul 18, 2017 at 08:00:36AM +, Guenter Milde wrote:
>> On 2017-07-03, Scott Kostyshak wrote:
>> > On Mon, Jul 03, 2017 at 03:02:31PM +0200, Jean-Marc Lasgouttes wrote:
>> >> Le 29/05/2017 à 18:06, Scott Kostyshak a écrit :
>> >> > If I do the above several times, I eventually get:
>> >> > 3c3
>> >> > <
>> >> > \documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
>> >> > ---
>> >> > > \documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
>> >> > --

>> >> Which document is it that eventually changes? This could be a
>> >> uninitialized variable.

>> > Not sure. I can spend some time looking into it, but I first wanted to
>> > make sure that at least one other person could reproduce before I start
>> > spending time on it.

>> While it may point to an underlying issue, the difference itself is
>> non-critical:

>> The export uses LuaTeX with 8-bit TeX fonts and the Babel language
>> package.

>> With Babel, the main document language must be given last, the
>> order of secondary languages does not matter, hence

>>   \documentclass[english,ngerman,spanish]{scrbook}

>> and

>>   \documentclass[ngerman,english,spanish]{scrbook}

>> produce identical output (unless there is some bug in Babel).

> Good to know that this specific issue is not important, thanks Günter.
> Yes, I'm still worried about the underlying bug.

I am not sure this difference is a bug, it may just be some indeterminalism,
maybe caused by existence or non-existence of an auxiliary or chache file
(changing the order in which the secondary languages are "identified" by LyX).

Günter



Re: Different LaTeX output when exporting than when previewing

2017-07-21 Thread Scott Kostyshak
On Tue, Jul 18, 2017 at 08:00:36AM +, Guenter Milde wrote:
> On 2017-07-03, Scott Kostyshak wrote:
> > On Mon, Jul 03, 2017 at 03:02:31PM +0200, Jean-Marc Lasgouttes wrote:
> >> Le 29/05/2017 à 18:06, Scott Kostyshak a écrit :
> >> > If I do the above several times, I eventually get:
> >> > 3c3
> >> > <
> >> > \documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
> >> > ---
> >> > > \documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
> >> > --
> 
> >> Which document is it that eventually changes? This could be a uninitialized
> >> variable.
> 
> > Not sure. I can spend some time looking into it, but I first wanted to
> > make sure that at least one other person could reproduce before I start
> > spending time on it.
> 
> While it may point to an underlying issue, the difference itself is
> non-critical:
> 
> The export uses LuaTeX with 8-bit TeX fonts and the Babel language
> package.
> 
> With Babel, the main document language must be given last, the
> order of secondary languages does not matter, hence
> 
>   \documentclass[english,ngerman,spanish]{scrbook}
> 
> and
> 
>   \documentclass[ngerman,english,spanish]{scrbook}
> 
> produce identical output (unless there is some bug in Babel).
> 
> Günter
> 

Good to know that this specific issue is not important, thanks Günter.
Yes, I'm still worried about the underlying bug.

Scott


Re: Different LaTeX output when exporting than when previewing

2017-07-18 Thread Guenter Milde
On 2017-07-03, Scott Kostyshak wrote:
> On Mon, Jul 03, 2017 at 03:02:31PM +0200, Jean-Marc Lasgouttes wrote:
>> Le 29/05/2017 à 18:06, Scott Kostyshak a écrit :
>> > If I do the above several times, I eventually get:
>> > 3c3
>> > <
>> > \documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
>> > ---
>> > > \documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
>> > --

>> Which document is it that eventually changes? This could be a uninitialized
>> variable.

> Not sure. I can spend some time looking into it, but I first wanted to
> make sure that at least one other person could reproduce before I start
> spending time on it.

While it may point to an underlying issue, the difference itself is
non-critical:

The export uses LuaTeX with 8-bit TeX fonts and the Babel language
package.

With Babel, the main document language must be given last, the
order of secondary languages does not matter, hence

  \documentclass[english,ngerman,spanish]{scrbook}

and

  \documentclass[ngerman,english,spanish]{scrbook}

produce identical output (unless there is some bug in Babel).

Günter



Re: Different LaTeX output when exporting than when previewing

2017-07-03 Thread Scott Kostyshak
On Mon, Jul 03, 2017 at 03:02:31PM +0200, Jean-Marc Lasgouttes wrote:
> Le 29/05/2017 à 18:06, Scott Kostyshak a écrit :
> > If I do the above several times, I eventually get:
> > 3c3
> > <
> > \documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
> > ---
> > > \documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
> > --
> 
> Which document is it that eventually changes? This could be a uninitialized
> variable.

Not sure. I can spend some time looking into it, but I first wanted to
make sure that at least one other person could reproduce before I start
spending time on it.

Scott


Re: Different LaTeX output when exporting than when previewing

2017-07-03 Thread Jean-Marc Lasgouttes

Le 29/05/2017 à 18:06, Scott Kostyshak a écrit :

If I do the above several times, I eventually get:
3c3
<
\documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
---

\documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}

--


Which document is it that eventually changes? This could be a 
uninitialized variable.


JMarc


Re: Different LaTeX output when exporting than when previewing

2017-07-01 Thread Scott Kostyshak
On Mon, May 29, 2017 at 12:06:42PM -0400, Scott Kostyshak wrote:
> On Wed, Nov 02, 2016 at 09:23:23PM -0400, Scott Kostyshak wrote:
> > On Wed, Nov 02, 2016 at 09:43:05PM +0100, Jürgen Spitzmüller wrote:
> > 
> > > I would like to investigate, but if we cannot reproduce, there is not
> > > much we can do.
> > 
> > OK, I don't have an idea either.
> 
> I can reproduce with the following:
> 
> To use the below, "lyx" is the binary from current master for me.
> 
> # cd to the git repository
> cd lib/doc/es
> testFile="EmbeddedObjects"
> lyx -E luatex "${testFile}_CL.tex" "${testFile}.lyx"
> lyx -x "command-sequence buffer-export luatex" "${testFile}.lyx"
> # exit LyX.
> diff "${testFile}_CL.tex" "${testFile}.tex"
> 
> If I do the above several times, I eventually get:
> 3c3
> <
> \documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
> ---
> > \documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
> --
> 
> Can anyone else reproduce if they do the above a few times?

I'm still curious if anyone else can reproduce. I've been thinking about
how to approach debugging this.

Scott


signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2017-05-29 Thread Scott Kostyshak
On Wed, Nov 02, 2016 at 09:23:23PM -0400, Scott Kostyshak wrote:
> On Wed, Nov 02, 2016 at 09:43:05PM +0100, Jürgen Spitzmüller wrote:
> 
> > I would like to investigate, but if we cannot reproduce, there is not
> > much we can do.
> 
> OK, I don't have an idea either.

I can reproduce with the following:

To use the below, "lyx" is the binary from current master for me.

# cd to the git repository
cd lib/doc/es
testFile="EmbeddedObjects"
lyx -E luatex "${testFile}_CL.tex" "${testFile}.lyx"
lyx -x "command-sequence buffer-export luatex" "${testFile}.lyx"
# exit LyX.
diff "${testFile}_CL.tex" "${testFile}.tex"

If I do the above several times, I eventually get:
3c3
<
\documentclass[12pt,english,ngerman,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
---
> \documentclass[12pt,ngerman,english,spanish,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table]{scrbook}
--

Can anyone else reproduce if they do the above a few times?

Scott


signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2016-11-02 Thread Scott Kostyshak
On Wed, Nov 02, 2016 at 09:43:05PM +0100, Jürgen Spitzmüller wrote:

> I would like to investigate, but if we cannot reproduce, there is not
> much we can do.

OK, I don't have an idea either.

Scott


signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2016-11-02 Thread Jürgen Spitzmüller
Am Mittwoch, den 02.11.2016, 15:08 -0400 schrieb Scott Kostyshak:
> Thanks for taking a look and the fix. I also always get an error now.
> Do
> you think we should be concerned about the other bug? That is, do you
> think there's a chance that the bug was serious and we were lucky to
> have a way to reproduce it, and now for whatever reason (e.g. memory
> is
> stored slightly differently) we can no longer reproduce it but it
> could
> still be there lurking in the shadows?

I would like to investigate, but if we cannot reproduce, there is not
much we can do.

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: Different LaTeX output when exporting than when previewing

2016-11-02 Thread Scott Kostyshak
On Wed, Nov 02, 2016 at 06:15:57PM +0100, Jürgen Spitzmüller wrote:
> Am Dienstag, den 01.11.2016, 17:42 +0100 schrieb Jürgen Spitzmüller:
> > Am Dienstag, den 01.11.2016, 13:43 +0100 schrieb Jürgen Spitzmüller:
> > > The second bug is that OutputParams::LUATEX does not use
> > > polyglossia's
> > > language varieties in the \setotherlanguage macro. This is what
> > > causes
> > > the LaTeX errors.
> > 
> > I've solved this part of the puzzle.
> 
> I have fixed this both in master and stable. Now I seem unable to
> reproduce the other issue. That is, the export now always triggers an
> error, as expected.

Thanks for taking a look and the fix. I also always get an error now. Do
you think we should be concerned about the other bug? That is, do you
think there's a chance that the bug was serious and we were lucky to
have a way to reproduce it, and now for whatever reason (e.g. memory is
stored slightly differently) we can no longer reproduce it but it could
still be there lurking in the shadows?

Scott


signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2016-11-02 Thread Jürgen Spitzmüller
Am Dienstag, den 01.11.2016, 17:42 +0100 schrieb Jürgen Spitzmüller:
> Am Dienstag, den 01.11.2016, 13:43 +0100 schrieb Jürgen Spitzmüller:
> > The second bug is that OutputParams::LUATEX does not use
> > polyglossia's
> > language varieties in the \setotherlanguage macro. This is what
> > causes
> > the LaTeX errors.
> 
> I've solved this part of the puzzle.

I have fixed this both in master and stable. Now I seem unable to
reproduce the other issue. That is, the export now always triggers an
error, as expected.

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: Different LaTeX output when exporting than when previewing

2016-11-01 Thread Jürgen Spitzmüller
Am Dienstag, den 01.11.2016, 13:43 +0100 schrieb Jürgen Spitzmüller:
> The second bug is that OutputParams::LUATEX does not use
> polyglossia's
> language varieties in the \setotherlanguage macro. This is what
> causes
> the LaTeX errors.

I've solved this part of the puzzle.
 
In LaTeXFeatures::getPolyglossiaLanguages(), we used a map to collect the polyglossia languages and varieties. The
polyglossia name was the key. Now when we have two varieties of a
language, only one is recorded, since the key must be unique. In the
given case, the empty variety of "english" overwrote the variety option
of "british". In other cases, when british was recorded after english,
the opposite happened.

Having thought about this whole thing carefully, I came to the
conclusion that we should not output the language options in
\setotherlanguage at all. Why? Because they are output in the language
switching commands anyway, and if we have multiple varieties, we run
into trouble.

However, it also became clear to me that we need to output also the
standard varieties of the languages. Consider a document with default
language austrian and other language german. This would come out as:

\setdefaultlanguage[variant=austrian,babelshorthands=true]{german}
\begin{document}
Austrian \textgerman[babelshorthands=true]{German}
\end{document}

whereas it is supposed to be

\setdefaultlanguage[variant=austrian,babelshorthands=true]{german}
\begin{document}
Austrian \textgerman[variant=german,babelshorthands=true]{German}
\end{document}

All this is addressed by the attached patch.

Thoughts?

Jürgendiff --git a/lib/languages b/lib/languages
index d56d030..7c98444 100644
--- a/lib/languages
+++ b/lib/languages
@@ -138,7 +138,7 @@ Language ancientgreek
 	\languageattribute{greek}{ancient}
 	EndPostBabelPreamble
 	PolyglossiaName   greek
-	PolyglossiaOpts   variant=ancient
+	PolyglossiaOpts   "variant=ancient"
 	QuoteStylefrench
 	Encoding  iso8859-7
 	InternalEncoding  true
@@ -409,6 +409,7 @@ Language english
 	HasGuiSupporttrue
 	BabelNameenglish
 	PolyglossiaName  english
+	PolyglossiaOpts  "variant=american"
 	QuoteStyle   english
 	Encoding iso8859-15
 	LangCode en_US
@@ -507,7 +508,7 @@ Language german
 	GuiName  "German (old spelling)"
 	BabelNamegerman
 	PolyglossiaName  german
-	PolyglossiaOpts  "spelling=old,babelshorthands=true"
+	PolyglossiaOpts  "variant=german,spelling=old,babelshorthands=true"
 	QuoteStyle   german
 	Encoding iso8859-15
 	LangCode de
@@ -519,7 +520,7 @@ Language ngerman
 	HasGuiSupporttrue
 	BabelNamengerman
 	PolyglossiaName  german
-	PolyglossiaOpts  "babelshorthands=true"
+	PolyglossiaOpts  "variant=german,babelshorthands=true"
 	QuoteStyle   german
 	Encoding iso8859-15
 	LangCode de_DE
@@ -559,6 +560,7 @@ Language greek
 	HasGuiSupport true
 	BabelName greek
 	PolyglossiaName   greek
+	PolyglossiaOpts   "variant=monotonic"
 	QuoteStylefrench
 	Encoding  iso8859-7
 	InternalEncoding  true
@@ -909,6 +911,7 @@ Language serbian
 	HasGuiSupporttrue
 	BabelNameserbianc
 	PolyglossiaName  serbian
+	PolyglossiaOpts  "script=cyrillic"
 	QuoteStyle   german
 	Encoding utf8
 	FontEncoding T2A
@@ -920,7 +923,7 @@ Language serbian-latin
 	GuiName  "Serbian (Latin)"
 	BabelNameserbian
 	PolyglossiaName  serbian
-	PolyglossiaOpts  "script=Latin"
+	PolyglossiaOpts  "script=latin"
 	QuoteStyle   german
 	Encoding iso8859-2
 	LangCode sr_RS-Latin
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 6af82c1..3f0f44a 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2173,14 +2173,17 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 			lyxpreamble += "[" + from_ascii(language->polyglossiaOpts()) + "]";
 		lyxpreamble += "{" + from_ascii(language->polyglossia()) + "}\n";
 		// now setup the other languages
-		std::map const polylangs =
+		set const polylangs =
 			features.getPolyglossiaLanguages();
-		for (std::map::const_iterator mit = polylangs.begin();
+		for (set::const_iterator mit = polylangs.begin();
 		 mit != polylangs.end() ; ++mit) {
+			// We do not output the options here; they are output in
+			// the language switch commands. This is safer if multiple
+			// varieties are used.
+			if (*mit == language->polyglossia())
+continue;
 			lyxpreamble += "\\setotherlanguage";
-			if (!mit->second.empty())
-lyxpreamble += "[" + from_ascii(mit->second) + "]";
-			lyxpreamble += "{" + from_ascii(mit->first) + "}\n";
+			lyxpreamble += "{" + from_ascii(*mit) + "}\n";
 		}
 	}
 
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 96f0ced..15d4370 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -740,15 +740,16 @@ string LaTeXFeatures::getBabelLanguages() 

Re: Different LaTeX output when exporting than when previewing

2016-11-01 Thread Jürgen Spitzmüller
Am Montag, den 31.10.2016, 17:58 -0400 schrieb Scott Kostyshak:
> A separate issue is that for the same set of actions, sometimes LyX
> produces one LaTeX export (which leads to the error) and sometimes
> LyX
> produces a different LaTeX export (which does not lead to the error).
> It
> is this random behavior that bothers me (even if neither of the LaTeX
> versions produced an error).

Confirmed. The attached diff shows the difference of the two variants.
Obviously, in the case that succeeds [!], the export is done
erroneously with OutputParams::XETEX, the one that fails uses correctly
OutputParams::LUATEX (this can be seen since only XeTeX requires
xunicode and XeTeX uses, for backwards compatibility reasons
"Mapping=tex-text", whereas LuaTeX uses "Ligatures=TeX").

So the first bug here is that the wrong output param is used.

The second bug is that OutputParams::LUATEX does not use polyglossia's
language varieties in the \setotherlanguage macro. This is what causes
the LaTeX errors.

Both bugs are a mystery to me.

Jürgen

--- /home/juergen/Intro1.tex
+++ /tmp/meld-tmp7D0IaQ
@@ -2,9 +2,9 @@
 \makeatletter
 \def\input@path{{/home/juergen/test/}}
 \makeatother
-\documentclass[12pt,english,british,slovak]{article}
+\documentclass[12pt,british,english,slovak]{article}
 \usepackage{fontspec}
-\setmainfont[Mapping=tex-text]{DejaVu Sans}
+\setmainfont[Ligatures=TeX]{DejaVu Sans}
 \setcounter{tocdepth}{2}
 \usepackage{color}
 \usepackage{url}
@@ -50,10 +50,9 @@
 
 \makeatother
 
-\usepackage{xunicode}
 \usepackage{polyglossia}
 \setdefaultlanguage{slovak}
-\setotherlanguage[variant=british]{english}
+\setotherlanguage{english}
 \begin{document}
 
 \title{Úvod do \LyX{}u}



signature.asc
Description: This is a digitally signed message part


Re: Different LaTeX output when exporting than when previewing

2016-10-31 Thread Scott Kostyshak
On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:
> Am Sonntag, den 25.09.2016, 19:02 -0400 schrieb Scott Kostyshak:
> > To reproduce on current master:
> > 
> > 1. open lib/doc/sk/Intro.lyx
> > 2. go to Document > Settings > Fonts, check "Use non-TeX fonts" and
> > set
> > all to e.g. DejaVu Sans
> > 3. File > Export > PDF (LuaTeX)

> I get the error both with Preview and Export.

Jürgen, could you please try the recipe again a few times? There are two
issues here: one is why an error is produced sometimes. I think you got
to the bottom of that issue with your bug report on the polyglossia
github.

A separate issue is that for the same set of actions, sometimes LyX
produces one LaTeX export (which leads to the error) and sometimes LyX
produces a different LaTeX export (which does not lead to the error). It
is this random behavior that bothers me (even if neither of the LaTeX
versions produced an error).

I propose the following recipe which makes it easier to run multiple
times and still yields the random behavior.

1. open lib/doc/sk/Intro.lyx
2. go to Document > Settings > Fonts, check "Use non-TeX fonts" and
set
all to e.g. DejaVu Sans
2.5 save the file (to a diff file name if you want)
3. File > Export > PDF (LuaTeX)

Quit LyX, and start LyX again from the file that you saved in step 2.5.
Repeat step 3. Note that for me it is necessary to quit LyX before
trying again.

If you repeat 10 times, do you get at least one time where there is no
error and at least one time where there is an error?

This could of course depend on compiler, etc., so I would not be so
surprised if you cannot reproduced. But I wanted to check.

Scott


signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2016-10-01 Thread Jürgen Spitzmüller
Am Montag, den 26.09.2016, 21:30 +0200 schrieb Enrico Forestieri:
> On Mon, Sep 26, 2016 at 08:46:51PM +0200, Enrico Forestieri wrote:
> > On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:
> > > 
> > > I get the error both with Preview and Export.
> > > 
> > > This is this polyglossia bug, caused by the changes to gloss-
> > > english.ldf in this commit:
> > > https://github.com/reutenauer/polyglossia/commit/d74a64b681b12555
> > > f61f30
> > > e4a73af3c891c22155
> > > 
> > > A workaround for our case is to use us english (instead of
> > > british) in
> > > this doc.
> > > 
> > > I reported the bug at 
> > > https://github.com/reutenauer/polyglossia/issues/163
> > 
> > 
> > Jürgen, in that report you mention polyglossia 1.42.4, but this is
> > the
> > same version available in MiKTeX and I don't experience any issue.
> 
> 
> What is your babel version? When compiling the test case, I see in
> the log:
> 
> Babel <3.9n> and hyphenation patterns for 69 languages loaded.
> 
> Maybe it is a bad interaction between polyglossia and a specific
> babel
> version.

The crucial component seems to be LuaTeX. See Arthur's comment in the
ticket.

Jürgen

> 
> 

signature.asc
Description: This is a digitally signed message part


Re: Different LaTeX output when exporting than when previewing

2016-09-30 Thread Scott Kostyshak
On Mon, Sep 26, 2016 at 02:46:48PM -0400, Scott Kostyshak wrote:
> On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:
> 
> > I get the error both with Preview and Export.
> 
> I tested again and in three tries (starting with a fresh LyX session)
> with only Preview, two times I got the error and one time I did not.
> I'm curious how others would approach debugging this issue. Am I right
> that two likely possibilities are an uninitialized member variable and a
> threading issue? Are there other likely candidates for this type of bug
> where the behavior seems somewhat random?

To reproduce, apply the attached patch to master and compile. Then:

1. Open lib/doc/sk/Intro.lyx
2. Preview as PDF (LuaTeX)

Sometimes the above will give an error, sometimes it won't. When it is
successful, the following output (added with the patch) is shown:

"mit_second is not empty!"

Within a given LyX session, the compile will always give an error or
always not give an error (even if you force a recompile by adding text,
so not using the cache).

So to test multiple times, remember to exit LyX and then reopen
sk/Intro.lyx.

Scott
From 14a8daf7eee4127b822fd4a7a481eaa0242aea3c Mon Sep 17 00:00:00 2001
From: Scott Kostyshak 
Date: Sat, 1 Oct 2016 01:13:17 -0400
Subject: [PATCH] Debug code for bug

---
 lib/doc/sk/Intro.lyx | 16 +---
 src/BufferParams.cpp |  4 +++-
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/doc/sk/Intro.lyx b/lib/doc/sk/Intro.lyx
index 58073ef..c7b5b5d 100644
--- a/lib/doc/sk/Intro.lyx
+++ b/lib/doc/sk/Intro.lyx
@@ -1,5 +1,5 @@
-#LyX 2.2 created this file. For more info see http://www.lyx.org/
-\lyxformat 508
+#LyX 2.3 created this file. For more info see http://www.lyx.org/
+\lyxformat 512
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -31,18 +31,19 @@
 \language_package default
 \inputencoding auto
 \fontencoding global
-\font_roman "palatino" "default"
-\font_sans "helvet" "default"
-\font_typewriter "courier" "default"
+\font_roman "palatino" "FreeSans"
+\font_sans "helvet" "FreeSans"
+\font_typewriter "courier" "FreeSans"
 \font_math "auto" "auto"
 \font_default_family default
-\use_non_tex_fonts false
+\use_non_tex_fonts true
 \font_sc false
 \font_osf false
 \font_sf_scale 100 100
 \font_tt_scale 100 100
+\use_microtype false
 \graphics default
-\default_output_format pdf2
+\default_output_format default
 \output_sync 0
 \bibtex_command default
 \index_command default
@@ -2094,6 +2095,7 @@ type "mailto:;
 
 , spolu s 
 \begin_inset Branch english
+inverted 0
 status collapsed
 
 \begin_layout Standard
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index eff684d..785532b 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2187,8 +2187,10 @@ bool BufferParams::writeLaTeX(otexstream & os, 
LaTeXFeatures & features,
for (std::map::const_iterator mit = 
polylangs.begin();
 mit != polylangs.end() ; ++mit) {
lyxpreamble += "\\setotherlanguage";
-   if (!mit->second.empty())
+   if (!mit->second.empty()) {
+   lyxerr << "mit_second is not empty!" << 
std::endl;
lyxpreamble += "[" + from_ascii(mit->second) + 
"]";
+   }
lyxpreamble += "{" + from_ascii(mit->first) + "}\n";
}
}
-- 
2.7.4



signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2016-09-26 Thread Enrico Forestieri
On Mon, Sep 26, 2016 at 08:46:51PM +0200, Enrico Forestieri wrote:
> On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:
> > 
> > I get the error both with Preview and Export.
> > 
> > This is this polyglossia bug, caused by the changes to gloss-
> > english.ldf in this commit:
> > https://github.com/reutenauer/polyglossia/commit/d74a64b681b12555f61f30
> > e4a73af3c891c22155
> > 
> > A workaround for our case is to use us english (instead of british) in
> > this doc.
> > 
> > I reported the bug at 
> > https://github.com/reutenauer/polyglossia/issues/163
> 
> Jürgen, in that report you mention polyglossia 1.42.4, but this is the
> same version available in MiKTeX and I don't experience any issue.

What is your babel version? When compiling the test case, I see in the log:

Babel <3.9n> and hyphenation patterns for 69 languages loaded.

Maybe it is a bad interaction between polyglossia and a specific babel
version.

-- 
Enrico


Re: Different LaTeX output when exporting than when previewing

2016-09-26 Thread Guenter Milde
On 2016-09-26, Scott Kostyshak wrote:

> [-- Type: text/plain, Encoding: quoted-printable --]

> On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:

>> I get the error both with Preview and Export.

I get the error with Preview, too.
One ineresting point is, that it works with XeTeX.

> I tested again and in three tries (starting with a fresh LyX session)
> with only Preview, two times I got the error and one time I did not.

I did not manage to compile without error.

> I'm curious how others would approach debugging this issue. Am I right
> that two likely possibilities are an uninitialized member variable and a
> threading issue? Are there other likely candidates for this type of bug
> where the behavior seems somewhat random?

We have a similar problem in the ctests (unreliableTests):

  Sublabel: erratic
  #
  # Tests depending on local configuration, or the phase of the moon.
  
  # Export fails the first time but works the second time. (Why?)
  export/doc/es/Customization_pdf4_texF

My guess it that the auxiliary files in the compiling directory play a
role...

>> This is this polyglossia bug, caused by the changes to gloss-
>> english.ldf in this commit:
>> https://github.com/reutenauer/polyglossia/commit/d74a64b681b12555f61f30
>> e4a73af3c891c22155

>> A workaround for our case is to use us english (instead of british) in
>> this doc.

In case of this doc, consistent use of either "british" or "english"
is not just a workaround but "the right thing" anyway.


Günter



Re: Different LaTeX output when exporting than when previewing

2016-09-26 Thread Scott Kostyshak
On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:

> I get the error both with Preview and Export.

I tested again and in three tries (starting with a fresh LyX session)
with only Preview, two times I got the error and one time I did not.
I'm curious how others would approach debugging this issue. Am I right
that two likely possibilities are an uninitialized member variable and a
threading issue? Are there other likely candidates for this type of bug
where the behavior seems somewhat random?

> This is this polyglossia bug, caused by the changes to gloss-
> english.ldf in this commit:
> https://github.com/reutenauer/polyglossia/commit/d74a64b681b12555f61f30
> e4a73af3c891c22155
> 
> A workaround for our case is to use us english (instead of british) in
> this doc.
> 
> I reported the bug at 
> https://github.com/reutenauer/polyglossia/issues/163

Thanks for doing that.

Scott


signature.asc
Description: PGP signature


Re: Different LaTeX output when exporting than when previewing

2016-09-26 Thread Enrico Forestieri
On Mon, Sep 26, 2016 at 09:48:52AM +0200, Jürgen Spitzmüller wrote:
> 
> I get the error both with Preview and Export.
> 
> This is this polyglossia bug, caused by the changes to gloss-
> english.ldf in this commit:
> https://github.com/reutenauer/polyglossia/commit/d74a64b681b12555f61f30
> e4a73af3c891c22155
> 
> A workaround for our case is to use us english (instead of british) in
> this doc.
> 
> I reported the bug at 
> https://github.com/reutenauer/polyglossia/issues/163

Jürgen, in that report you mention polyglossia 1.42.4, but this is the
same version available in MiKTeX and I don't experience any issue.

-- 
Enrico


Re: Different LaTeX output when exporting than when previewing

2016-09-26 Thread Jürgen Spitzmüller
Am Sonntag, den 25.09.2016, 19:02 -0400 schrieb Scott Kostyshak:
> To reproduce on current master:
> 
> 1. open lib/doc/sk/Intro.lyx
> 2. go to Document > Settings > Fonts, check "Use non-TeX fonts" and
> set
> all to e.g. DejaVu Sans
> 3. File > Export > PDF (LuaTeX)
> 
> I get an error:
> 
>   ! Undefined control sequence.
>   \english@language ->\language =\l@ukenglish 
>   \xpg@set@language@luate
> x@ii {uke...
>   l.222 \textenglish[variant=british]{independent}
> 
> In step 3, if instead of exporting I preview with PDF (LuaTeX), there
> is
> no error.

I get the error both with Preview and Export.

This is this polyglossia bug, caused by the changes to gloss-
english.ldf in this commit:
https://github.com/reutenauer/polyglossia/commit/d74a64b681b12555f61f30
e4a73af3c891c22155

A workaround for our case is to use us english (instead of british) in
this doc.

I reported the bug at 
https://github.com/reutenauer/polyglossia/issues/163

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: Different LaTeX output when exporting than when previewing

2016-09-26 Thread Enrico Forestieri
On Sun, Sep 25, 2016 at 07:02:26PM -0400, Scott Kostyshak wrote:

> To reproduce on current master:
> 
> 1. open lib/doc/sk/Intro.lyx
> 2. go to Document > Settings > Fonts, check "Use non-TeX fonts" and set
> all to e.g. DejaVu Sans
> 3. File > Export > PDF (LuaTeX)
> 
> I get an error:
> 
>   ! Undefined control sequence.
>   \english@language ->\language =\l@ukenglish 
>   \xpg@set@language@luatex@ii 
> {uke...
>   l.222 \textenglish[variant=british]{independent}
> 
> In step 3, if instead of exporting I preview with PDF (LuaTeX), there is
> no error.

I cannot reproduce. Both export and preview work fine for me.

> Here is the diff of the exported Intro.tex files in each case (taken
> from the temporary directory):
> 
> $ diff bad/Intro.tex good/Intro.tex
> 5c5
> < \documentclass[12pt,british,english,slovak]{article}
> ---
> > \documentclass[12pt,english,british,slovak]{article}
> 57c57
> < \setotherlanguage{english}
> ---
> > \setotherlanguage[variant=british]{english}
> $

I get these same differences (and many unrelevant others related to the
different way the latex source is generated for preview and export), though.
Maybe the differences above are also related to the nice vs not-nice export,
but they do not cause any error for me.

-- 
Enrico


Different LaTeX output when exporting than when previewing

2016-09-25 Thread Scott Kostyshak
To reproduce on current master:

1. open lib/doc/sk/Intro.lyx
2. go to Document > Settings > Fonts, check "Use non-TeX fonts" and set
all to e.g. DejaVu Sans
3. File > Export > PDF (LuaTeX)

I get an error:

  ! Undefined control sequence.
  \english@language ->\language =\l@ukenglish 
  \xpg@set@language@luatex@ii 
{uke...
  l.222 \textenglish[variant=british]{independent}

In step 3, if instead of exporting I preview with PDF (LuaTeX), there is
no error.

Here is the diff of the exported Intro.tex files in each case (taken
from the temporary directory):

$ diff bad/Intro.tex good/Intro.tex
5c5
< \documentclass[12pt,british,english,slovak]{article}
---
> \documentclass[12pt,english,british,slovak]{article}
57c57
< \setotherlanguage{english}
---
> \setotherlanguage[variant=british]{english}
$

Scott


signature.asc
Description: PGP signature