Textedit url handling for LilyPond in Gnome
Python Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Textedit url handling for GNU LilyPond in Gnome

These files and documentation are to aid in making point-and-click urls embedded in PDF files produced by GNU LilyPond more useable in Gnome. The script textedit.py differs in functionality only slightly from lilypond-invoke-editor which is distributed with LilyPond:

  • it places the cursor at the character number in the url, rather than one character to the left;

  • it focusses the editor window --- for this functionality, xdotool should be installed.

See notes below for using lilypond-invoke-editor with Emacs.


The install script places textedit.py in ~/.local/bin by default, to override this, supply an alternative directory as the argument.

./install.sh [/optional/path/to/script]


  1. touch /tmp/lytextedit.log && tail -f /tmp/lytextedit.log

  2. Open a LilyPond-produced pdf in Evince.

  3. Click a notehead.


The default configuration file will be created on install if it doesn't exist.

# executable name
editor = gvim
# command to pass to editor
command = --remote +:{line}:normal{start} "{file}"

# lots of info to the log file
verbose = true
# runs xdotool to focus the editor window
focus = false

This can be edited to launch your preferred editor. Fields available for the command option:

- file
- line
- start
- end

These are taken from the url embedded in the LilyPond pdf.

Example for using gedit:

editor = gedit
command = "{file}" +{line}:{start}

Once everything is working properly, you can edit ~/.config/lytextedit.cfg, changing verbose = false.


On Ubuntu, AppArmor may prevent Evince from opening external links. In that case:

$ sudo ln -s /etc/apparmor.d/usr.bin.evince /etc/apparmor.d/disable/usr.bin.evince
$ sudo service apparmor restart

See here for further details. Thanks to Rutger Hofman on the lilypond-user list.

Using with GNU Emacs in lilypond-mode

  1. Put textedit.desktop into $HOME/.local/share/applications and edit mimeapps.list as described above.

  2. Edit textedit.desktop, changing the line Exec=textedit.py %u to Exec=lilypond-invoke-editor %u

  3. Create a file lilypond-view-pdf somewhere in your $PATH and make it executable, with the following content:

evince $1 &


    $ cd /usr/local/bin/
    $ sudo echo -e '#!/bin/sh\nevince $1 &\n' > lilypond-view-pdf
    $ sudo chmod a+x lilypond-view-pdf
  1. Open Emacs.

    • Open a lilypond source file to automatically load lilypond-mode.
    • Issue the command M-x customize-group
    • On the prompt enter LilyPond and press return.
    • On the LilyPond customization group page scroll down to the entry Lilypond Pdf Command.
    • Enter lilypond-view-pdf in the edit field, click on the "State" button below "Lilypond Pdf Command" and select "Set for Current Session" and "Save for Future Sessions".

Thanks to Orm Finnendahl on the lilypond-user list for these instructions.


  • send to correct [g]vim instance - is there a way to discover if the file is open in which server?