lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Doc: LM: Reformat ly code.


From: Mark Polesky
Subject: [PATCH] Doc: LM: Reformat ly code.
Date: Sun, 2 May 2010 03:45:49 -0700 (PDT)

So I guess I'm working towards a more formal standard for
LilyPond code formatting.  I combed through the LM
attempting to improve the ly code that's already there.  In
the process I gleaned what I think are some reasonable
standards (some of which are already in CG 4.3.4 -- see
below).

If anyone is up to it, I'd like someone to look over the
patch to see if I've made anything worse.  I made very
slight changes to a few of the examples for convenience's
sake, but these should all be trivial.  For example,

LM 4.1.4 Tweaking methods, first example.

was:
  c d
  \override NoteHead #'color = #red
  e f g
  \override NoteHead #'color = #green
  a b c

changed it to:
  c4 d
  \override NoteHead #'color = #red
  e4 f
  \override NoteHead #'color = #green
  g4 a b c

Anyway, the patch is at
http://codereview.appspot.com/1056041.

Thanks.
- Mark


* * * * * * * * * *


Doc: LM: Reformat ly code.

* Except for Scheme code, add exactly two spaces (never
  tabs) for each additional level of indentation.
* Do not exceed one measure per line of code.
* Specify durations for the first note of every line.
* Specify durations after every `{' or `}'.
* Otherwise, specify durations only when they change.
* In \markup blocks, keep individual expressions on
  their own lines.
* Keep these commands on their own lines
  (and in this order):
    \clef
    \key
    \time
    \partial
* Use `\clef treble' instead of `\clef "treble"', etc.
* Use bar-checks (`|') only when barring is unclear.
* Do not put two `{'s on the same line unless the first
  `{' closes with a `}' before the second `{'
* Put a newline after `{' (and indent) if its '}' is not
  on the same line.
* Put a newline before `}' (and unindent) if its `{' is
  not on the same line.
* Put a single space before and after `{' and `}' unless
  it begins or ends a line.
* Put an empty line after the last \include.
* Surround with empty lines things like:
    #(set-global-staff-size x)
    #(ly:set-option x y)
* Put an empty line before and after multiline variable
  definitions or multiline blocks that start in the
  first column.
* For music function definitions:
  - put `functionName =' alone on the first line.
  - put `#(define-music-function' alone on the second.
  - indent `(parser location ...)' with 5 spaces.
  - indent `(type? ...)' with 5 spaces.
  - indent `#{' and `#}' with 3 spaces.
  - indent the contents of `#{ ... #}' with 5 spaces.
* For multiline variable definitions:
  - if `=' is immediately followed by `{', put a newline
    after `{'.
  - otherwise put a newline after `='.
* Always use curly braces with \markup.


      




reply via email to

[Prev in Thread] Current Thread [Next in Thread]