Juergen Spitzmueller wrote: > Thanks, but given my complete and utter python ignorance, I'd rather rely > on José's offer, once we decided on the spelling.
I did it nevertheless. José, can you have a look if the lyx2lyx changes are o.k.? And then we need to come to a conclucion about the spelling of the InsetSpace types. Jürgen
Index: development/FORMAT =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/development/FORMAT,v retrieving revision 1.41 diff -u -r1.41 FORMAT --- development/FORMAT 29 Jul 2005 09:39:17 -0000 1.41 +++ development/FORMAT 27 Sep 2005 07:36:11 -0000 @@ -1,6 +1,13 @@ LyX file-format changes ----------------------- +2005-09-24 Jürgen Spitzmüller <[EMAIL PROTECTED]> + + * format incremented to 244. Rename '\InsetSpace \,' + to '\InsetSpace \thinspace{}', because the comma was + not parsed by lyxlex, and '\InsetSpace \space' to + '\InsetSpace \space{}' in favour of consistency. + 2005-07-18 José Matos <[EMAIL PROTECTED]> * format incremented to 243. Index: lib/lyx2lyx/LyX.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/LyX.py,v retrieving revision 1.24 diff -u -r1.24 LyX.py --- lib/lyx2lyx/LyX.py 19 Sep 2005 11:31:26 -0000 1.24 +++ lib/lyx2lyx/LyX.py 27 Sep 2005 07:37:20 -0000 @@ -46,7 +46,7 @@ ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]), ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]), ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3"]), - ("1_4", range(222,244), ["1.4.0cvs","1.4"])] + ("1_4", range(222,245), ["1.4.0cvs","1.4"])] def formats_list(): Index: lib/lyx2lyx/lyx_1_4.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx_1_4.py,v retrieving revision 1.52 diff -u -r1.52 lyx_1_4.py --- lib/lyx2lyx/lyx_1_4.py 20 Sep 2005 12:47:45 -0000 1.52 +++ lib/lyx2lyx/lyx_1_4.py 27 Sep 2005 07:37:25 -0000 @@ -65,8 +65,40 @@ def revert_spaces(file): + regexp = re.compile(r'(\\InsetSpace\s+)(\S+)') + i = 0 + while 1: + i = find_re(file.body, regexp, i) + if i == -1: + break + space = regexp.match(file.body[i]).group(2) + if space == '~': + file.body[i] = regexp.sub('\\SpecialChar ~', file.body[i]) + i = i + 1 + else: + file.body[i] = regexp.sub('', file.body[i]) + file.body[i+1:i+1] = '' + if space == "\\normal{}": + space2 = "\\ " + if space == "\\thinspace{}": + space2 = "\\," + else: + space2 = space + i = insert_ert(file.body, i+1, 'Collapsed', space2, file.format-1) + +## +# \InsetSpace \, -> \InsetSpace \thinspace{} +# \InsetSpace \normal -> \InsetSpace \normal{} +# +def rename_spaces(file): + for i in range(len(file.body)): + file.body[i] = replace(file.body[i],"\\InsetSpace \\normal","\\InsetSpace \\normal{}") + file.body[i] = replace(file.body[i],"\\InsetSpace \,","\\InsetSpace \\thinspace{}") + +def revert_space_names(file): for i in range(len(file.body)): - file.body[i] = replace(file.body[i],"\\InsetSpace ~", "\\SpecialChar ~") + file.body[i] = replace(file.body[i],"\\InsetSpace \\normal{}","\\InsetSpace \\normal") + file.body[i] = replace(file.body[i],"\\InsetSpace \\thinspace{}","\\InsetSpace \\,") ## @@ -2255,9 +2287,11 @@ [240, [convert_output_changes]], [241, [convert_ert_paragraphs]], [242, [convert_french]], - [243, [remove_paperpackage]]] + [243, [remove_paperpackage]], + [244, [rename_spaces]]] -revert = [[242, []], +revert = [[243, [revert_space_names]], + [242, []], [241, []], [240, [revert_ert_paragraphs]], [239, [revert_output_changes]], Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.627 diff -u -r1.627 buffer.C --- src/buffer.C 18 Jul 2005 14:25:19 -0000 1.627 +++ src/buffer.C 27 Sep 2005 07:48:09 -0000 @@ -144,7 +144,7 @@ namespace { -int const LYX_FORMAT = 243; +int const LYX_FORMAT = 244; } // namespace anon Index: src/insets/insetspace.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetspace.C,v retrieving revision 1.25 diff -u -r1.25 insetspace.C --- src/insets/insetspace.C 23 Nov 2004 23:04:48 -0000 1.25 +++ src/insets/insetspace.C 27 Sep 2005 07:48:18 -0000 @@ -106,13 +106,13 @@ string command; switch (kind_) { case NORMAL: - command = "\\space"; + command = "\\space{}"; break; case PROTECTED: command = "~"; break; case THIN: - command = "\\,"; + command = "\\thinspace{}"; break; case QUAD: command = "\\quad{}"; @@ -134,17 +134,16 @@ } -// This function will not be necessary when lyx3 void InsetSpace::read(Buffer const &, LyXLex & lex) { lex.next(); string const command = lex.getString(); - if (command == "\\space") + if (command == "\\space{}") kind_ = NORMAL; else if (command == "~") kind_ = PROTECTED; - else if (command == "\\,") + else if (command == "\\thinspace{}") kind_ = THIN; else if (command == "\\quad{}") kind_ = QUAD;