]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/ja/usage/updating.itely
New upstream version 2.19.80
[lilypond.git] / Documentation / ja / usage / updating.itely
1 @c -*- coding: utf-8; mode: texinfo; documentlanguage: ja -*-
2
3 @ignore
4     Translation of GIT committish: 5fb3f8cf17ce7b57d22584429d736f188e4827d7
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  For details, see the Contributors'
8     Guide, node Updating translation committishes..
9 @end ignore
10
11 @c \version "2.16.0"
12
13 @c Translators: Tomohiro Tatejima, Yoshiki Sawada
14 @c Translation status: post-GDP
15
16
17 @node convert-ly を使ってファイルを更新する
18 @chapter @command{convert-ly} を使ってファイルを更新する
19 @translationof Updating files with convert-ly
20
21 @cindex Updating a LilyPond file (LilyPond ファイルを更新する)
22 @cindex convert-ly
23
24 LilyPond が改善していくにつれ、いくつかのコマンドや関数の構文 (入力言語) は@c
25 変わることがあります。このことによって、昔のバージョンの LilyPond で作られた@c
26 入力ファイルを新しいバージョンで使う時に、予期しないエラーや警告、あるいは@c
27 誤った出力を引き起こす可能性があります。
28
29 これに対処するため、このような昔の入力ファイルを新しい構文に更新する
30 @command{convert-ly} コマンドを使うことができます。
31
32 @menu
33 * 何故構文は変更されるのか?::
34 * convert-ly を呼び出す::
35 * convert-ly のコマンド ライン オプション::
36 * convert-ly の問題点::
37 * 手動変換::
38 * 複数のバージョンに対応するコードを書く::
39 @end menu
40
41 @node 何故構文は変更されるのか?
42 @section 何故構文は変更されるのか?
43 @translationof Why does the syntax change?
44
45 @cindex convert-ly
46 @cindex updating old input files (古い入力ファイルを更新する)
47
48 入力ファイルを読みやすく、書きやすくするために、しばしば構文は変更されますが、@c
49 時により既存の関数が、新しい機能や改善に合わせて変更されることがあります。
50
51 これが実際にあった例です:
52
53 @code{\paper} と @code{\layout} のプロパティ名は全て、@c
54 @code{first-second-third} という形式で記述することになっています。@c
55 しかしながら、バージョン 2.11.60 で @code{printallheaders} プロパティが@c
56 この規則に従っていないことが判明しました。@c
57 放置すべきでしょうか?
58 (新しいユーザはつじつまの合わない入力形式で混乱するでしょう。)
59 それとも、変更すべきでしょうか?
60 (既存の楽譜を持つユーザには煩わしいことです。)
61
62 このケースでは、プロパティ名を  @code{print-all-headers} に変更することを@c
63 決断しました。そして、昔のユーザは @command{convert-ly} コマンドによって@c
64 既にある入力ファイルを自動的にアップデートすることができました。
65
66 しかし、@c
67 @command{convert-ly} はすべての変更を処理できるわけではありません。@c
68 例えば、バージョン 2.4.2 以前の LilyPond では、@c
69 アクセント文字と非英語文字を LaTeX の記法を用いて入力していました。
70 例えば Christmas のフランス語は @code{No\"el} のように入力されていました。@c
71 しかしながら、バージョン 2.6 以降の LilyPond では、@c
72 特殊文字 @code{ë} を UTF-8 文字として直接 LilyPond ファイルに@c
73 入力しなければならなくなりました。@c
74 @command{convert-ly} はすべての LaTeX の特殊文字を UTF-8 文字に変換する@c
75 ことはできません。@c
76 手動で古い LilyPond 入力ファイルを更新する必要があります。
77
78 @command{convert-ly} コマンドの変換ルールは、テキストのパターンマッチングと@c
79 置換によって動作しています (つまり、与えられた入力ファイルの中で何が@c
80 変更されたかの文脈を@q{理解}してはいないということです)。
81 これはいくつかの結果をもたらします:
82
83 @itemize @bullet
84 @item
85 変換の信頼性は、それぞれの適用されるルールセットの品質と、@c
86 対応する変更の複雑さ次第です。変換が、追加・手動の修正を要求することが@c
87 あります。ですから万が一のために、変換前の入力ファイルは比較のために@c
88 残しておくべきです。
89
90 @item
91 より新しいバージョンへの構文の変更のみが可能です: LilyPond の昔のバージョンへ@c
92 変換するルールセットは存在しません。そのため、入力ファイルを更新@c
93 するのは、昔のバージョンの LilyPond がもうメンテナンスされていない時に限る@c
94 べきです。繰り返しますが、万が一のために変換前の入力ファイルは残しておくべき@c
95 です。Git のようなバージョン管理システムを使うと、複数のバージョンの@c
96 入力ファイルを管理するのに役立つかもしれません。
97
98 @item
99 LilyPond は処理の際、余計に配置された、あるいは省略された空白に@c
100 左右されません。しかし、@command{convert-ly} で用いられるルールはコードの@c
101 スタイルにいくらかの仮定を置く場合があります。ですから、正常な変換を@c
102 行うために、LilyPond のマニュアルで用いられるスタイルに従うことを推奨します。@c
103 特にマニュアル自体、すべての例が @command{convert-ly} コマンドで@c
104 更新されています。
105 @end itemize
106
107
108 @node convert-ly を呼び出す
109 @section @command{convert-ly} を呼び出す
110 @translationof Invoking convert-ly
111
112 @command{convert-ly} コマンドは古いバージョンを検出するために@c
113 入力ファイルの @code{version} 番号を使用します。@c
114 たいていの場合、あなたの入力ファイルを更新するには、@c
115 その入力ファイルを保持しているディレクトリで以下を実行するだけで十分です:
116
117 @example
118 convert-ly -e myfile.ly
119 @end example
120
121 @noindent
122 これにより、@code{myfile.ly} はその場で更新され、@c
123 オリジナル ファイルは @code{myfile.ly~} に名前が変更されて保存されます。@c
124 更新された入力ファイルの @code{\version} 番号も、必要な構文の更新に合わせて@c
125 変更されます。
126
127 @command{convert-ly} コマンドが実行される時、変換が行われるバージョンの番号を@c
128 出力します。バージョン番号が出力されなかった場合、そのファイルは既に@c
129 更新されており、最新の LilyPond 構文を使用しています。
130
131 @warning{LilyPond の新しいバージョンごとに、新しい @command{convert-ly}
132 コマンドが作られます。しかし、全てのバージョンがその前のバージョンの@c
133 入力ファイルから構文の変更を必要とするわけではありません。つまり
134 @command{convert-ly} コマンドは、入力ファイルをその時点の最新の構文にまで@c
135 しか変換しないということであり、逆に言えば、変換されたファイルの
136 @code{\version} 番号が @command{convert-ly} コマンド自体のバージョンより@c
137 前のバージョンになる場合もあるということです。}
138
139 単一のディレクトリにある全ての入力ファイルを変換するには、以下のようにします:
140
141 @example
142 convert-ly -e *.ly
143 @end example
144
145 Linux や MacOS@tie{}X のユーザーは、適当なターミナルからこのコマンドを@c
146 実行できますが、MacOS@tie{}X のユーザーは、メニューの
147 @code{Compile > Update syntax} からも直接コマンドを実行できます。
148
149 Windows ユーザーがコマンド ラインを用いる場合はこのようになります:
150
151 @example
152 convert-ly.py -e *.ly
153 @end example
154
155 @noindent
156 これを、@code{コマンド プロンプト}から実行します。@c
157 @code{コマンド プロンプト}は通常、@c
158 @code{スタート > アクセサリ > コマンド プロンプト}にありますが、@c
159 Windows 8 ユーザーであるなら、検索ウィンドウに@q{コマンド プロンプト}と@c
160 入力することでも実行できます。
161
162 複数のサブディレクトリ内にある全ての入力ファイルを変換するには、@c
163 以下のようにします:
164
165 @example
166 find . -name '*.ly' -exec convert-ly -e '@{@}' \;
167 @end example
168
169 この例は、現在のディレクトリとその下にある全てのディレクトリに存在する@c
170 入力ファイルを、再帰的に見つけ出し変換します。変換されたファイルは@c
171 リネームされた元のファイルと同じディレクトリに配置されます。これは
172 MacOS@tie{}X でも動作するはずです (ターミナルからの実行のみとなりますが)。
173
174 Windows ユーザーは以下のようにします:
175
176 @example
177 forfiles /s /M *.ly /c "cmd /c convert-ly.py -e @@file"
178 @end example
179
180 代わりに、@code{/p} オプションを使って、入力ファイルを含む全てのサブフォルダを@c
181 保持したトップレベルのフォルダを指定することができます:
182
183 @example
184 forfiles /s /p C:\Documents\MyScores /M *.ly /c "cmd /c convert-ly.py -e @@file"
185 @end example
186
187 トップレベルのフォルダへのパスにスペースが含まれる場合には、パス全体を@c
188 ダブルクォートで括る必要があります:
189
190 @example
191 forfiles /s /p "C:\Documents\My Scores" /M *.ly /c "cmd /c convert-ly.py -e @@file"
192 @end example
193
194
195 @node convert-ly のコマンド ライン オプション
196 @section @command{convert-ly} のコマンド ライン オプション
197 @translationof Command line options for convert-ly
198
199 一般に、このプログラムは以下のように呼び出されます:
200
201 @example
202 convert-ly [@var{option}]@dots{} @var{filename}@dots{}
203 @end example
204
205 以下のオプションを与えることができます:
206
207 @table @code
208 @item -d, --diff-version-update
209 ファイルが実際に変更された場合にのみ @code{\version} を更新します。
210 これを指定した場合のバージョン番号は、最後に実際に変換が行われた後の@c
211 バージョンに対応します。不安定版のバージョン番号は、ターゲットの@c
212 バージョン番号を超えない限り、次の安定版のバージョン番号に上げられます。@c
213 このオプションを指定しないと、最後の変換を@emph{行おうとした}バージョンに更新@c
214 されます。
215
216 @item -e, --edit
217 入力ファイルをその場で直接変換します。@c
218 変換元のファイルは @file{myfile.ly~} のように名前が変更されます。@c
219 このバックアップファイルは、オペレーティングシステムによっては@c
220 隠しファイルとして扱われているかもしれません。@c
221 古い入力ファイルに @code{~} を付加する @code{-e} を使わずに、@c
222 更新されたファイルの名前を別に指定したい場合は、代わりに@c
223 出力をリダイレクトすることができます:
224
225 @example
226 convert-ly myfile.ly > mynewfile.ly
227 @end example
228
229 Windows ユーザーは:
230
231 @example
232 convert-ly.py myfile.ly > mynewfile.ly
233 @end example
234
235 @item -b, --backup-numbered
236 @samp{-e} オプションと同時に用いた場合、前のバージョンのファイルが上書き@c
237 されないように、バックアップファイルの名前に番号が付きます。@c
238 バックアップファイルは、オペレーティングシステムによっては@c
239 隠されているかもしれません。
240
241 @item -f, --from=@var{from-patchlevel}
242 変換元のバージョンをセットします。@c
243 これがセットされていない場合、@c
244 @command{convert-ly} は入力ファイルの中にある
245 @code{version} 文字列を基に推測します。@c
246 例: @option{--from=2.10.25}
247
248 @item -h, --help
249 ヘルプ (使い方) を表示します。
250
251 @item -l @var{loglevel}, --loglevel=@var{loglevel}
252 出力の饒舌さを @var{loglevel} にセットします。@c
253 取り得る値は、大文字で、@code{PROGRESS} (デフォルト), @code{NONE},
254 @code{WARNING}, @code{ERROR}, それに @code{DEBUG} です。
255
256 @item -n, --no-version
257 通常、@command{convert-ly} は @code{\version} インジケータを@c
258 出力に付け加えます。@c
259 このオプションを指定すると、それを抑制します。
260
261 @item -s, --show-rules
262 すべての変換を表示して、終了します。
263
264 @item -t, --to=@var{to-patchlevel}
265 変換先のバージョンを明示してセットします。@c
266 明示されない場合は、デフォルトで最新バージョンにセットします。@c
267 変換元のバージョンよりも高くなっている必要があります。
268
269 @example
270 convert-ly --to=2.14.1 myfile.ly
271 @end example
272
273 @end table
274
275 texinfo ファイルの中にある LilyPond 断片を更新するには@c
276 以下を使用してください:
277
278 @example
279 convert-ly --from=@dots{} --to=@dots{} --no-version *.itely
280 @end example
281
282 2 つのバージョン間での LilyPond 構文の変更を調べるには、@c
283 以下を使用してください:
284
285 @example
286 convert-ly --from=@dots{} --to=@dots{} -s
287 @end example
288
289
290 @node convert-ly の問題点
291 @section @code{convert-ly} の問題点
292 @translationof Problems running convert-ly
293
294 Windows の @q{コマンド プロンプト} ウィンドウから@c
295 スペースを含むファイル名やパスを持つファイルに対して@c
296 convert-ly を実行する場合、@c
297 入力ファイル名全体を 3 つ (!) のダブル クォートで囲む必要があります:
298
299 @example
300 convert-ly """D:/My Scores/Ode.ly""" > "D:/My Scores/new Ode.ly"
301 @end example
302
303 @command{convert-ly -e *.ly} コマンドが@c
304 展開時に長くなりすぎて失敗する場合、@c
305 @command{convert-ly} コマンドをループさせてやります。@c
306 以下の例は UNIX 用であり、@c
307 カレント ディレクトリの中にあるすべての @code{.ly} ファイルを@c
308 更新します:
309
310 @example
311 for f in *.ly; do convert-ly -e $f; done;
312 @end example
313
314 Windows の @q{コマンド プロンプト} ウィンドウでの@c
315 上の例に対応するコマンドは以下の通りです:
316
317 @example
318 for %x in (*.ly) do convert-ly -e """%x"""
319 @end example
320
321 言語の変更がすべて処理されるわけではありません。@c
322 指定できる出力オプションは 1 つだけです。@c
323 自動的に Scheme と更新することと
324 LilyPond の Scheme インタフェイスを更新することはまったく異なります。@c
325 Scheme コードの調整は手動で行う覚悟でいてください。
326
327
328 @node 手動変換
329 @section 手動変換
330 @translationof Manual conversions
331
332 @c not yet
333 理論的には、@c
334 @command{convert-ly} のようなプログラムはすべての構文変更を処理できます。
335 After all, a computer program interprets the old
336 version and the new version, so another computer program can
337 translate one file into another@footnote{At least, this is
338 possible in any LilyPond file which does not contain scheme.  If
339 there is scheme in the file, then the LilyPond file contains a
340 Turing-complete language, and we run into problems with the famous
341 @qq{Halting Problem} in computer science.}.
342
343 しかしながら、LilyPond プロジェクトの資源には限りがあり、@c
344 すべての変換を自動化することはできません。@c
345 以下は既知の問題のリストです。
346
347 @verbatim
348 1.6->2.0:
349  Doesn't always convert figured bass correctly, specifically things like {<
350 >}.  Mats' comment on working around this:
351    To be able to run convert-ly
352    on it, I first replaced all occurrences of '{<' to some dummy like '{#'
353    and similarly I replaced '>}' with '&}'.  After the conversion, I could
354    then change back from '{ #' to '{ <' and from '& }' to '> }'.
355  Doesn't convert all text markup correctly.  In the old markup syntax,
356  it was possible to group a number of markup commands together within
357 parentheses, e.g.
358    -#'((bold italic) "string")
359    This will incorrectly be converted into
360    -\markup{{\bold italic} "string"}
361    instead of the correct
362    -\markup{\bold \italic "string"}
363 2.0->2.2:
364  Doesn't handle \partcombine
365  Doesn't do \addlyrics => \lyricsto, this breaks some scores with multiple
366 stanzas.
367 2.0->2.4:
368  \magnify isn't changed to \fontsize.
369     - \magnify #m => \fontsize #f, where f = 6ln(m)/ln(2)
370  remove-tag isn't changed.
371     - \applyMusic #(remove-tag '. . .) => \keepWithTag #'. . .
372  first-page-number isn't changed.
373     - first-page-number no => print-first-page-number = ##f
374  Line breaks in header strings aren't converted.
375     - \\\\  as line break in \header strings => \markup \center-align <
376       "First Line" "Second Line" >
377  Crescendo and decrescendo terminators aren't converted.
378     - \rced => \!
379     - \rc => \!
380 2.2->2.4:
381  \turnOff (used in \set Staff.VoltaBracket = \turnOff) is not properly
382 converted.
383 2.4.2->2.5.9
384  \markup{ \center-align <{ ... }> } should be converted to:
385  \markup{ \center-align {\line { ... }} }
386  but now, \line is missing.
387 2.4->2.6
388  Special LaTeX characters such as $~$ in text are not converted to UTF8.
389 2.8
390  \score{} must now begin with a music expression.  Anything else
391  (particularly \header{}) must come after the music.
392 @end verbatim
393
394
395 @node 複数のバージョンに対応するコードを書く
396 @section 複数のバージョンに対応するコードを書く
397 @translationof Writing code to support multiple versions
398
399 いくつかの場面で、特に@emph{ライブラリの}コードを書く場合、破壊的な構文変更を@c
400 含んだ複数の LilyPond バージョンをサポートすることは望ましいでしょう。@c
401 これは、バージョンによって変更が必要な部分を、現在実行されている
402 LilyPond のバージョンで分岐する条件文で囲むことで実現できます。@c
403 Scheme 関数 @code{ly:version?} は比較演算子 @var{op} と、比較の対象となる@c
404 バージョンを 3 つまでの整数のリストで表現した @var{ver} を引数に取ります。
405 整数の数が足りない場合は無視されます。例えば、@code{'(2 20)} は@c
406 @emph{全ての} 2.20 の系列のバージョンと等しくなります。@c
407 このような表記が可能です:
408
409 @verbatim
410 #(cond
411   ((ly:version? > '(2 20))
412    (ly:message "This is code to run for LilyPond after 2.20"))
413   ((ly:version? = '(2 19 57))
414    (ly:message "This will only be executed with LilyPond 2.19.57"))
415   (else (ly:message "This will be executed in any other version")))
416 @end verbatim
417
418 通常、これは (訳注: バージョンによって) 別の構文が使えるようにするために@c
419 ライブラリ関数に組み込まれますが、以下の例のように、比較を直接音楽の中に@c
420 用いることもできます:
421
422 @verbatim
423 {
424   c' d' e' f'
425   #(if (ly:version? = '(2 21))
426        #{ \override NoteHead.color = #red #}
427        #{ \override NoteHead.color = #blue #})
428   g' a' b' c''
429 }
430 @end verbatim
431
432 @strong{注意:} この関数は LilyPond 2.19.57 で導入されました。@c
433 そのため、それより古いバージョンと比較することはできません。