I/O
===


Reopening Abjad PDFs
--------------------

After you build a piece of notation and open with ``show()`` you will usually
close the resulting PDF and continue working:

<abjad>
staff = Staff("c'8 d'8 e'8 f'8 g'8 a'8 b'8 c''8")
show(staff)
</abjad>

But what if you need to go back and open the resulting PDF again? Abjad
provides ``systemtools.pdf()`` for this purpose. 

Call ``systemtools.pdf()`` to open the most recent PDF written by Abjad:

::

    >>> systemtools.pdf()

Pass a ``-1`` to ``systemtools.pdf()`` if you want to open not the next-to-most
recent PDF generated by Abjad:

::

    >>> systemtools.pdf(target=-1)

Pass a ``-2`` to ``systemtools.pdf()`` if you want to open next-to-next-to-most
recent PDF generated by Abjad, and so on:

::

    >>> systemtools.pdf(target=-2)


Looking at LilyPond input files
-------------------------------

Abjad generates a LilyPond ``.ly`` file for every Abjad expression that you
build and ``show()``. Use ``systemtools.ly()`` to look at the LilyPond input files
that Abjad builds behind the scenes:

::

   >>> systemtools.ly()

Abjad opens the LilyPond input file in favorite text editor:

::

   % Abjad revision 12362
   % 2013-10-17 9:29

   \version "2.17.28"
   \langauge "english"

   \header {
       tagline = \markup {  }

   \score {
        \new Staff {
            c'8
            d'8
            e'8
            f'8
            g'8
            a'8
            b'8
            c''8
        }
    }

The LilyPond input files that Abjad generates all have the same basic
structure: the current version of Abjad and the date appear first, followed by
the mandatory LilyPond version string and LilyPond directive for English note
names. The remainder of the file is reserved for the LilyPond input code
corresponding to the expression you just built in Abjad.

You can pass values like ``-1`` and ``-2`` to ``systemtools.ly()`` just like you
can to ``systemtools.pdf()``:

::

    >>> systemtools.ly(-1)

Quit you text editor to return to the Abjad interpreter when you are done
looking at the LilyPond input file.
   

Looking at the LilyPond log
---------------------------

It may be helpful to examine the output that LilyPond writes to the LilyPond
log when you call ``show()`` or one of the other Abjad functions that call
LilyPond behind the scenes:

::

   >>> systemtools.log()

This is the normal output that LilyPond generates every time it runs:

::

   GNU LilyPond 2.17.28
   Processing `4960.ly'
   Parsing...
   Interpreting music...
   Preprocessing graphical objects...
   Finding the ideal number of pages...
   Fitting music on 1 page...
   Drawing systems...
   Layout output to `4960.ps'...
   Converting to `./4960.pdf'...

The ``systemtools.log()`` function takes no input arguments because the output of
only the most recent invocation of LilyPond is saved to disk.

Quit your text editor to return to the Abjad interpreter when you are done
looking at the LilyPond log.
