[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fix 1816: Lilypond-Book: don't clear the auto-detected line-with, r
From: |
reinhold . kainhofer |
Subject: |
Re: Fix 1816: Lilypond-Book: don't clear the auto-detected line-with, rather modify it (issue 4888046) |
Date: |
Mon, 15 Aug 2011 21:50:52 +0000 |
Reviewers: Graham Percival,
http://codereview.appspot.com/4888046/diff/1/python/book_snippets.py
File python/book_snippets.py (left):
http://codereview.appspot.com/4888046/diff/1/python/book_snippets.py#oldcode424
python/book_snippets.py:424: if type == 'lilypond':
On 2011/08/15 21:34:16, Graham Percival wrote:
This part is only executed if we do not have a line width (line 404).
Nope. In line 404 the dictionary contains just the explicitly given
options. The default (e.g. auto-detected from LaTeX) are then later
inserted in line 412.
has_line_width == True means that line-width was explicitly given as a
snippet option.
But I
thought we were getting the line width from latex? Does that info not
get
stored in self.option_dict for some reason?
That's what lines 410-412 are doing.
I'm content to trust you that it works, but I'm having trouble
following the
logic of has_line_width and self.option_dict[LINE_WIDTH].
That's why I added those two comments in lines 404 and 410 ;-)
Description:
Lilypond-Book: don't clear the auto-detected line-with, rather modify it
Please review this at http://codereview.appspot.com/4888046/
Affected files:
M python/book_snippets.py
Index: python/book_snippets.py
diff --git a/python/book_snippets.py b/python/book_snippets.py
index
b7c3ddf0d67d369acfec84b3db605a54860b4db9..abb56d737ccca2eadd6cc0fb989048857e8cc936
100644
--- a/python/book_snippets.py
+++ b/python/book_snippets.py
@@ -401,12 +401,13 @@ class LilypondSnippet (Snippet):
# If LINE_WIDTH is used without parameter, set it to default.
+ # Store if we have an explicit line-width given
has_line_width = self.option_dict.has_key (LINE_WIDTH)
if has_line_width and self.option_dict[LINE_WIDTH] == None:
has_line_width = False
del self.option_dict[LINE_WIDTH]
- # TODO: Can't we do that more efficiently (built-in python func?)
+ # Use default options (i.e. auto-detected line-width, etc)
for k in self.formatter.default_snippet_options:
if k not in self.option_dict:
self.option_dict[k] =
self.formatter.default_snippet_options[k]
@@ -421,18 +422,6 @@ class LilypondSnippet (Snippet):
if type == 'lilypond' or FRAGMENT in self.option_dict:
self.option_dict[RAGGED_RIGHT] = None
- if type == 'lilypond':
- if LINE_WIDTH in self.option_dict:
- del self.option_dict[LINE_WIDTH]
- else:
- if RAGGED_RIGHT in self.option_dict:
- if LINE_WIDTH in self.option_dict:
- del self.option_dict[LINE_WIDTH]
-
- if QUOTE in self.option_dict or type == 'lilypond':
- if LINE_WIDTH in self.option_dict:
- del self.option_dict[LINE_WIDTH]
-
if not INDENT in self.option_dict:
self.option_dict[INDENT] = '0\\mm'
- Re: Fix 1816: Lilypond-Book: don't clear the auto-detected line-with, rather modify it (issue 4888046),
reinhold . kainhofer <=