From: Richard Heck Date: Thu, 4 Nov 2010 12:38:56 +0000 (+0000) Subject: Simplify revert_paragraph_indentation. X-Git-Tag: 2.0.0~2075 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4a1558855c0afe3c2f21e02181aede0385ec650d;p=features.git Simplify revert_paragraph_indentation. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36040 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 8e4094249e..fc4d1dec7f 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -974,25 +974,18 @@ def revert_branch_filename(document): def revert_paragraph_indentation(document): " Revert custom paragraph indentation to preamble code " - i = 0 - while True: - i = find_token(document.header, "\\paragraph_indentation", i) - if i == -1: - break - # only remove the preamble line if default - # otherwise also write the value to the preamble - length = get_value(document.header, "\\paragraph_indentation", i) - if length == "default": - del document.header[i] - break - else: - # handle percent lengths - # latex_length returns "bool,length" - length = latex_length(length).split(",")[1] - add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) - add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"]) - del document.header[i] - i = i + 1 + i = find_token(document.header, "\\paragraph_indentation", i) + if i == -1: + return + length = get_value(document.header, "\\paragraph_indentation", i) + # we need only remove the line if indentation is default + if length != "default": + # handle percent lengths + # latex_length returns "bool,length" + length = latex_length(length).split(",")[1] + add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) + add_to_preamble(document, ["\\setlength{\\parindent}{" + length + "}"]) + del document.header[i] def revert_percent_skip_lengths(document):