Configuring Aquamacs (OSX) to work with LilyPond

This configuration will let you edit (with syntax highlight), compile and open the generated pdf with your default reader, all from Aquamacs with LilyPond-mode.

Usefull shortcuts in Aquamacs:
C-x Control + x
M-x Alt + x
A-x Command + x
C-x C-f Control + x and then Control + f


download and install the last LilyPond binaries for OSX

2 download and install Aquamacs

3 give the path of LilyPond binary folder to the system (so you can type "lilypond" from your terminal in any directory and the system will find it)

    open Aquamacs and create a textfile under /etc/paths.d/
    here a used the name "lily"

        C-x C-f

    copy the path to the bin subfolder of your LilyPond.app package...



                C-x C-s

4 Configure Aquamacs to run in lilypond-mode (i.e. you can edit and compile your . ly files in the same environment)

      create/edit your ~/.emacs file (it's a file that configures aquamacs for your user)

        C-x C-f

       copy these lines (change the paths if you didn't installed LilyPond in the default Applications folder)
   (setq load-path (append (list (expand-file-name"/Applications/LilyPond.app/Contents/Resources/share/emacs/site-lisp")) load-path))
   (autoload 'LilyPond-mode "lilypond-mode" "LilyPond Editing Mode" t)
   (add-to-list 'auto-mode-alist '("\\.ly$" . LilyPond-mode))
   (add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock)))


                C-x C-s

5 Edit lilypond-mode.el to use your default pdf reader (like Preview or Skim) to use "open" command instead of "xpf" (which you can also install with MacPorts, if you want to)

        find the file

        C-x C-f

        find the defcustom "LilyPond-pdf-command"


        replace "xpdf" with "open" to let the definition like that:

(defcustom LilyPond-pdf-command "open"
  "Command used to display PDF files."

  :group 'LilyPond
  :type 'string)

if you want to set another preferences (like play midi with Quicktime) replace the respective commands in the respectives defcustoms with "open" (just like you did with the pdf reader).

6 close and open Aquamacs to load you new ./emacs configurations.

7 load the LilyPond-mode to see if it is working


        create a file with the . ly extension in your Desktop or somewhere

        C-x C-f

      OBS: when you create or open a file with the .ly extension, Aquamacs will load the LilyPond-mode autmoatically

      now, try it:

   \relative {c d e f}

                C-x C-s
                C-x C-s

                C-c C-l

      and open the pdf with your default reader
                C-c C-s