Re: Backwards compatibility with 2.1 and older?

2017-06-01 Thread Enrico Forestieri
On Thu, Jun 01, 2017 at 08:52:18PM +, Guenter Milde wrote:

> Dear Enrico,
> 
> thank you for the patch.
> 
> On 2017-06-01, Enrico Forestieri wrote:
> > On Thu, Jun 01, 2017 at 02:12:56PM +, Guenter Milde wrote:
> 
> > Please, try the attached. I don't know what you are trying to do,
> > but I hope you are not trying to sabotage the last fixes to the
> > en/emdash mess. 
> > I would be really upset to see all of them as ert.
> > If this is a first step toward a really clean solution (to solve I
> > don't know what), that would be fine, though.
> 
> I am trying to clean up the mess after the last fixes just moved the
> problems to another area (see http://www.lyx.org/trac/ticket/10543, comment
> 3 section "LyX 2.3dev").
> 
> ERT is the only fully backwards compatible solution for 2.2. 
> 
> It can be converted to plain -- or --- in backward conversion from 2.2 to
> 2.1.
> 
> For 2.3, we can use a new "SpecialChar" inset.
> Then, 
> 
> * a "ligature dash" can be back-converted to "\twohyphens" or
>   "\threehyphens" with lyx2lyx. It will become ERT in 2.2 and
>   (unmarked) -- or --- in 2.1 and earlier.
> 
> * an ERT with just -- or --- can be converted to the SpecialChar
>   inset with lyx2lyx forward conversion from 2.2. to 2.3.

I really don't want to go again through all this, but I am fiercely
opposed to having en/em-dashes as ERT because you end up with a
mess if you have to edit those documents, unless you want to also
enter in ERT all dashes that you may need to add.
But maybe I am simply misunderstanding.
I think that the actual solution is the lesser evil. You have
problems only if the document was later edited with 2.2.
And having to manually select a preference to adjust things
is not that intolerable, IMO. And I don't consider decisive
the fact that literal and ligatures dashes may have been
mixed together. In the past I had to adapt to more cumbersome
changes.

-- 
Enrico


Re: Backwards compatibility with 2.1 and older?

2017-06-01 Thread Guenter Milde
Dear Enrico,

thank you for the patch.

On 2017-06-01, Enrico Forestieri wrote:
> On Thu, Jun 01, 2017 at 02:12:56PM +, Guenter Milde wrote:

> Please, try the attached. I don't know what you are trying to do,
> but I hope you are not trying to sabotage the last fixes to the
> en/emdash mess. 
> I would be really upset to see all of them as ert.
> If this is a first step toward a really clean solution (to solve I
> don't know what), that would be fine, though.

I am trying to clean up the mess after the last fixes just moved the
problems to another area (see http://www.lyx.org/trac/ticket/10543, comment
3 section "LyX 2.3dev").

ERT is the only fully backwards compatible solution for 2.2. 

It can be converted to plain -- or --- in backward conversion from 2.2 to
2.1.

For 2.3, we can use a new "SpecialChar" inset.
Then, 

* a "ligature dash" can be back-converted to "\twohyphens" or
  "\threehyphens" with lyx2lyx. It will become ERT in 2.2 and
  (unmarked) -- or --- in 2.1 and earlier.

* an ERT with just -- or --- can be converted to the SpecialChar
  inset with lyx2lyx forward conversion from 2.2. to 2.3.

Günter



Re: Backwards compatibility with 2.1 and older?

2017-06-01 Thread Enrico Forestieri
On Thu, Jun 01, 2017 at 02:12:56PM +, Guenter Milde wrote:
> 
> Below is a "stub patch", that tries to achieve this but fails due to my
> limite understanding of C++ and LyX code.
> I copy-pasted from Text.cpp and factory.cpp and did some edits.
> However, in a test file (2.1 file containing ---), the inserted ERT was
> empty and the console showed
> 
>   Lexer.cpp (934): Missing 'ert'-tag in InsetERT::string2params. Got -- 
> instead. Line: 0
> 
> Also, I would prefer the new-created ERT-insets to be "closed" (less
> distractive in the GUI).

Please, try the attached. I don't know what you are trying to do,
but I hope you are not trying to sabotage the last fixes to the
en/emdash mess. I would be really upset to see all of them as ert.
If this is a first step toward a really clean solution (to solve I
don't know what), that would be fine, though.

-- 
Enrico
diff --git a/src/Text.cpp b/src/Text.cpp
index 038553ba44..617e782701 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -52,6 +52,7 @@
 #include "insets/InsetText.h"
 #include "insets/InsetBibitem.h"
 #include "insets/InsetCaption.h"
+#include "insets/InsetERT.h"
 #include "insets/InsetNewline.h"
 #include "insets/InsetNewpage.h"
 #include "insets/InsetArgument.h"
@@ -508,10 +509,15 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
else
par.insert(par.size(), from_ascii("---"), font, 
change);
} else {
-   if (token == "\\twohyphens")
-   par.insertChar(par.size(), 0x2013, font, 
change);
-   else
-   par.insertChar(par.size(), 0x2014, font, 
change);
+   InsetERT * ert = new InsetERT(buf, 
InsetCollapsable::Collapsed);
+   if (token == "\\twohyphens") {
+   ert->setText(from_ascii("--"), font,
+buf->params().track_changes);
+   } else {
+   ert->setText(from_ascii("---"), font,
+buf->params().track_changes);
+   }
+   par.insertInset(par.size(), ert, font, change);
}
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);


Re: Backwards compatibility with 2.1 and older?

2017-06-01 Thread Guenter Milde
Dear Richard,

On 2017-05-31, Richard Heck wrote:
> On 04/26/2017 03:49 PM, Guenter Milde wrote:
>> Dear LyX developers,

>> How important is backwards compatibility for documents generated with LyX
>> 2.1 or older?

>>a) no need to restore after it's broken by 2.2.
>>b) good but not required 
>>c) small changes tolerable as long as documents
>>   open and compile
>>d) 100% backwards compatibility whenever possible.

> I believe the rule is (d).

>> Unfortunately, LyX 2.2 breaks backwards compatibility regarding the
>> line-break behaviour of em-dash and en-dash (changed behaviour for
>> documents using "ligature dashes").

>> Full backwards compatibility with pre-2.2 documents requires separate
>> representations for "ligature dashes" and "literal dashes". As 2.2 has
>> only "literal dashes", we would need a representation for
>> "ligature-dashes" in documents generated with LyX 2.1 or older.

>> Which of the alternatives do you prefer in case we want to restore
>> compatibility?

>> a) -- and --- as ERT

> This seems the simplest.

Below is a "stub patch", that tries to achieve this but fails due to my
limite understanding of C++ and LyX code.
I copy-pasted from Text.cpp and factory.cpp and did some edits.
However, in a test file (2.1 file containing ---), the inserted ERT was
empty and the console showed

  Lexer.cpp (934): Missing 'ert'-tag in InsetERT::string2params. Got -- 
instead. Line: 0

Also, I would prefer the new-created ERT-insets to be "closed" (less
distractive in the GUI).

Günter

diff --git a/src/Text.cpp b/src/Text.cpp
index 4e593ddf23..790d0bf354 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -52,6 +52,7 @@
 #include "insets/InsetText.h"
 #include "insets/InsetBibitem.h"
 #include "insets/InsetCaption.h"
+#include "insets/InsetERT.h"
 #include "insets/InsetNewline.h"
 #include "insets/InsetNewpage.h"
 #include "insets/InsetArgument.h"
@@ -516,10 +517,15 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
else
par.insert(par.size(), from_ascii("---"), font, 
change);
} else {
+   auto_ptr inset;
if (token == "\\twohyphens")
-   par.insertChar(par.size(), 0x2013, font, 
change);
+   inset.reset(new InsetERT(buf,
+   
InsetERT::string2params(to_utf8(_("--");
else
-   par.insertChar(par.size(), 0x2014, font, 
change);
+   inset.reset(new InsetERT(buf,
+   
InsetERT::string2params(to_utf8(_("--");
+   /* inset->setBuffer(*buf); */
+   par.insertInset(par.size(), inset.release(), font, 
change);
}
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);




Re: Backwards compatibility with 2.1 and older?

2017-05-31 Thread Richard Heck
On 04/26/2017 03:49 PM, Guenter Milde wrote:
> Dear LyX developers,
>
> How important is backwards compatibility for documents generated with LyX
> 2.1 or older?
>   
>a) no need to restore after it's broken by 2.2.
>b) good but not required 
>c) small changes tolerable as long as documents
>   open and compile
>d) 100% backwards compatibility whenever possible.

I believe the rule is (d).

> Unfortunately, LyX 2.2 breaks backwards compatibility regarding the 
> line-break behaviour of em-dash and en-dash (changed behaviour for documents 
> using "ligature dashes").
>
> Full backwards compatibility with pre-2.2 documents requires
> separate representations for "ligature dashes" and "literal dashes". As 2.2 
> has only "literal dashes", we would need a representation for 
> "ligature-dashes" in documents generated with LyX 2.1 or older.
>
> Which of the alternatives do you prefer in case we want to restore
> compatibility?
>
> a) -- and --- as ERT

This seems the simplest.

Richard



Backwards compatibility with 2.1 and older?

2017-04-26 Thread Guenter Milde
Dear LyX developers,

How important is backwards compatibility for documents generated with LyX
2.1 or older?
  
   a) no need to restore after it's broken by 2.2.
   b) good but not required 
   c) small changes tolerable as long as documents
  open and compile
   d) 100% backwards compatibility whenever possible.


Unfortunately, LyX 2.2 breaks backwards compatibility regarding the
line-break behaviour of em-dash and en-dash (changed behaviour for
documents using "ligature dashes").

Full backwards compatibility with pre-2.2 documents requires
separate representations for "ligature dashes" and "literal dashes".
As 2.2 has only "literal dashes", we would need a representation for
"ligature-dashes" in documents generated with LyX 2.1 or older.

Which of the alternatives do you prefer in case we want to restore
compatibility?

a) -- and --- as ERT

b) new special characters

It no 100% backwards compatibility is required, there are also the
alternatives

c) literal dash + specialchar allowbreak (cf. #10585)

d) literal dash with export setting "use_ligature_dashes" set based on content

See http://www.lyx.org/trac/ticket/10543 for details.