banner

LilyPond in TextWrangler

The package at the bottom of the page contains a LilyPond syntax colouring file and scripts to typeset LilyPond documents in TextWrangler.

Requirements

The scripts require my TeXShop engines for LilyPond. If you do not use TeXShop, you still need to download the above engines, but you will need to edit the scripts (see Customization below).

Installation

  1. In the Finder, browse to ~/Library/Applications Support/TextWrangler (~ is a shorthand for the path to your home folder).
  2. Copy LilyPond.plist into the Language Modules folder (create the folder if it does not exist).
  3. Copy Engrave.scpt and Engrave Book.scpt into the Scripts folder (create the folder if it does not exist).
  4. Re-open TextWrangler.
  5. Go to TextWrangler > Preferences… > Languages. In the Suffix Mappings list you should see that the .ly suffix is associated to LilyPond syntax.
  6. Add another suffix mapping by clicking on the Add… button. In the dialog, write .lytex in the Extension field and choose LilyPond from the Map to: pop-up menu. Click Add. Close the Preferences window.
  7. Go to Window > Palettes > Scripts to open the Scripts palette.
  8. Open a .ly or .lytex document, and double-click on Engrave or Engrave Book, respectively, in the Scripts palette.
  9. If there are no compilation errors, you should see the resulting PDF in TeXShop. If there are compilation errors, the log file is automatically opened in TextWrangler.

Customization

Q: How to change the PDF previewer?

A: Open each *.scpt file with the AppleScript Editor (which is located in /Applications/Utilities) and change the line that reads

property PDFVIEWER : "TeXShop"

to your favourite PDF viewer. For example, if you want to view the PDF in Skim, use

property PDFVIEWER : "Skim"

If you want to use Preview, use

property PDFVIEWER : "Preview"

and so on. Then compile and save the script.

Q: How to use the scripts without TeXShop?

A: First, change the default PDF previewer (see above). Then, download my TeXShop engines for LilyPond. Put them somewhere, say in ~/Documents/LilyPond-Engines. Then edit each *.scpt and change the ENGINE variable to point to the above location. For example:

set ENGINE to the POSIX path of (path to documents folder from user domain) & "LilyPond-Engines/" & LILYENGINE

Compile and save the script.

What’s new

1.0.2 (2012/4/12)

Adds compatibility with TextWrangler 4.x.