Re: [LyX/master] Use \inputencoding auto for examples/aas_sample.lyx

2016-12-02 Thread Scott Kostyshak
On Fri, Dec 02, 2016 at 12:50:02PM +0100, Kornel Benko wrote:
> Am Donnerstag, 1. Dezember 2016 um 23:31:48, schrieb Scott Kostyshak 
> 
> > On Thu, Dec 01, 2016 at 10:52:25AM +, Guenter Milde wrote:
> > 
> > > If we assume that an up-to date TeXLive is a common requirement, we can
> > > also remove the patterns in unreliableTest:
> > 
> > We would have to first redefine Sublabel: varying_versions. Currently we
> > say:
> > 
> >   Test depending on TeX distribution, package versions or OS.
> > 
> > Should we require an *up-to-date* TeX Live for reliable tests?
> 
> Yes, we should. For a developer it is not hard. And the tests are not meant 
> for a
> typical user.

Indeed we already state in Development.lyx:
A full, up-to-date TeXLive installation is recommended to run the tests.
Otherwise, some tests will fail. Tests with additional requirements are
labeled “unreliable:nonstandard”.

So it is just a matter of defining the varying_versions sublabel now.

> > If so, we
> > would redefine the varying_versions sublabel to something like:
> > 
> >   Test depending on e.g. OS or version of a non-TeX-Live dependency
> > 
> > > Do as you prefer, I don't have a preference.
> > 
> > What are your thoughts, Kornel?
> 
> Looks good.

OK we'll go with this and tweak if necessary.

I made the change at 67094dd6.

Scott


signature.asc
Description: PGP signature


Re: [LyX/master] Use \inputencoding auto for examples/aas_sample.lyx

2016-12-02 Thread Kornel Benko
Am Donnerstag, 1. Dezember 2016 um 23:31:48, schrieb Scott Kostyshak 

> On Thu, Dec 01, 2016 at 10:52:25AM +, Guenter Milde wrote:
> 
> > If we assume that an up-to date TeXLive is a common requirement, we can
> > also remove the patterns in unreliableTest:
> 
> We would have to first redefine Sublabel: varying_versions. Currently we
> say:
> 
>   Test depending on TeX distribution, package versions or OS.
> 
> Should we require an *up-to-date* TeX Live for reliable tests?

Yes, we should. For a developer it is not hard. And the tests are not meant for 
a
typical user.


> If so, we
> would redefine the varying_versions sublabel to something like:
> 
>   Test depending on e.g. OS or version of a non-TeX-Live dependency
> 
> > Do as you prefer, I don't have a preference.
> 
> What are your thoughts, Kornel?

Looks good.

> Scott

Kornel

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


Re: ctests: need to edit preferences file to run needauth converters

2016-12-02 Thread Scott Kostyshak
On Fri, Dec 02, 2016 at 07:01:51PM +0100, Kornel Benko wrote:

> Like the attached. (prefTest.pl.in goes into lib/scripts, executable flags 
> should be set)

I just took a quick look, but it looks good to me. Thanks for working on
this.

Scott


signature.asc
Description: PGP signature


Re: [LyX/master] Fix display and output of math macros with optional arguments

2016-12-02 Thread Enrico Forestieri
On Fri, Dec 02, 2016 at 12:27:03AM +0100, Enrico Forestieri wrote:
> On Thu, Dec 01, 2016 at 04:31:44PM -0500, Richard Heck wrote:
> > 
> > I'm no expert on this part of the code, but this doesn't look too
> > dangerous. Since 2.2.3 is still a little ways away, is it worth
> > committing to stable?
> 
> I think it is not risky and I am attaching the version for stable here.
> However, it behaves a bit differently than in trunk, as the braces that
> are added when the macro appears in the argument of another macro are
> preserved on copy/paste.

I found the what is the problem here, and it is quite embarassing...
In trunk, WriteStream has only a constructor, while in stable it has two.
I had not realized this when backporting, so that the insidemacro_ member
was being initialized only in one of the constructors, causing the issue.
Note that I made the same mistake at 8a1f936f, which has to be corrected,
too. I am attaching here a revised backport that works as expected.

-- 
Enrico
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 7e302c8..0701244 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -713,12 +713,15 @@ void MathData::collectOptionalParameters(Cursor * cur,
if (operator[](pos)->getChar() != '[')
break;
 
-   // found possible optional argument, look for "]"
+   // found possible optional argument, look for pairing "]"
+   int count = 1;
size_t right = pos + 1;
for (; right < size(); ++right) {
MathAtom & cell = operator[](right);
 
-   if (cell->getChar() == ']')
+   if (cell->getChar() == '[')
+   ++count;
+   else if (cell->getChar() == ']' && --count == 0)
// found right end
break;
 
diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp
index 9fe6e15..06d5a2c 100644
--- a/src/mathed/MathMacro.cpp
+++ b/src/mathed/MathMacro.cpp
@@ -938,6 +938,15 @@ void MathMacro::write(WriteStream & os) const
// we should be ok to continue even if this fails.
LATTEST(d->macro_);
 
+   // We may already be in the argument of a macro
+   bool const inside_macro = os.insideMacro();
+   os.insideMacro(true);
+
+   // Enclose in braces to avoid latex errors with xargs if we have
+   // optional arguments and are in the optional argument of a macro
+   if (d->optionals_ && inside_macro)
+   os << '{';
+
// Always protect macros in a fragile environment
if (os.fragile())
os << "\\protect";
@@ -976,9 +985,13 @@ void MathMacro::write(WriteStream & os) const
first = false;
}
 
-   // add space if there was no argument
-   if (first)
+   // Close the opened brace or add space if there was no argument
+   if (d->optionals_ && inside_macro)
+   os << '}';
+   else if (first)
os.pendingSpace(true);
+
+   os.insideMacro(inside_macro);
 }
 
 
diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 7ea6ab7..64e4866 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -125,17 +125,19 @@ WriteStream & operator<<(WriteStream & ws, docstring 
const & s)
 WriteStream::WriteStream(otexrowstream & os, bool fragile, bool latex,
 OutputType output, Encoding 
const * encoding)
: os_(os), fragile_(fragile), firstitem_(false), latex_(latex),
- output_(output), pendingspace_(false), pendingbrace_(false),
- textmode_(false), locked_(0), ascii_(0), canbreakline_(true),
- mathsout_(false), ulemcmd_(NONE), line_(0), encoding_(encoding)
+ output_(output), insidemacro_(false), pendingspace_(false),
+ pendingbrace_(false), textmode_(false), locked_(0), ascii_(0),
+ canbreakline_(true), mathsout_(false), ulemcmd_(NONE), line_(0),
+ encoding_(encoding)
 {}
 
 
 WriteStream::WriteStream(otexrowstream & os)
: os_(os), fragile_(false), firstitem_(false), latex_(false),
- output_(wsDefault), pendingspace_(false), pendingbrace_(false),
- textmode_(false), locked_(0), ascii_(0), canbreakline_(true),
- line_(0), encoding_(0) 
+ output_(wsDefault), insidemacro_(false), pendingspace_(false),
+ pendingbrace_(false), textmode_(false), locked_(0), ascii_(0),
+ canbreakline_(true), mathsout_(false), ulemcmd_(NONE), line_(0),
+ encoding_(0)
 {}
 
 
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index b2a7992..977947b 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -80,6 +80,10 @@ public:
void ulemCmd(UlemCmdType ulemcmd) { ulemcmd_ = ulemcmd; }
/// tell which ulem command type we are inside
UlemCmdType 

Re: ctests: need to edit preferences file to run needauth converters

2016-12-02 Thread Kornel Benko
Am Mittwoch, 30. November 2016 um 10:48:03, schrieb Scott Kostyshak 

> On Wed, Nov 30, 2016 at 04:10:38PM +0100, Kornel Benko wrote:
>
> > Selected parameters in prefTest.pl will remain until next call to 
> > prefTest.pl.
> > The call sequence could be:
> > # prefTest.pl ...
> > # ctest ... (this is the same as prefTest.pl with previous params)
> > # ctest ...
> > ...
> > # prefTest.pl (with new values)
> > # ctest ...
>
> Ah I see. So by default we would configure CMake to automatically run
> prefTest.pl to point to the preferences file that allows knitr to run
> without error. So we would still be able to do:
>
> cmake
> make
> ctest

It will work this way too, yes.
What I have in mid is:
# cmake
Now the file prefTest.pl is in the build directory, so you 
could immediately use
# prefTest.pl use_converter_needauth_forbidden�lse 
use_converter_needauth�lse -j3 -R export

> and knitr and Sweave would have successful exports.
>
> Then if we wanted to e.g. run the tests with different preferences we
> could do:
>
> prefTest.pl (with new values)
> ctest ...

Yes

> If I understood correctly, that seems good to me.
>
> Scott

Like the attached. (prefTest.pl.in goes into lib/scripts, executable flags 
should be set)

Kornel

prefTest.pl.in
Description: Perl program
diff --git a/lib/scripts/CMakeLists.txt b/lib/scripts/CMakeLists.txt
index a9439b7..d39e4fb 100644
--- a/lib/scripts/CMakeLists.txt
+++ b/lib/scripts/CMakeLists.txt
@@ -9,4 +9,5 @@ if (UNIX)
 	set(_project "scripts")
 	# include(../PyCompile)
 endif()
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/prefTest.pl.in" "${CMAKE_BINARY_DIR}/prefTest.pl" @ONLY)



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