As my standard font-lock faces didn't go well with LilyPond scores, here are a couple of patches and a new elisp file to provide customization for the lilypond-mode's faces. Feel free to pore scorn on my choices of defaults; they're work in progress and (currently) go well with my color-theme.
Christopher diff -u orig/lilypond-mode.el new/lilypond-mode.el --- orig/lilypond-mode.el 2008-09-11 10:21:03.000000000 +0100 +++ new/lilypond-mode.el 2008-09-11 11:33:21.000000000 +0100 @@ -1191,6 +1191,7 @@ (interactive) (message "Using `LilyPond-mode' version %s" LilyPond-version)) +(load-library "lilypond-faces") (load-library "lilypond-font-lock") (load-library "lilypond-indent") (load-library "lilypond-what-beat") diff -u orig/lilypond-font-lock.el new/lilypond-font-lock.el --- orig/lilypond-font-lock.el 2008-04-03 15:08:31.000000000 +0100 +++ new/lilypond-font-lock.el 2008-09-11 23:26:05.000000000 +0100 @@ -53,56 +53,57 @@ ;; See, e.g., text in "http://emacs.kldp.org/emacs-21.1/etc/NEWS". ;; ... identifiers (defined above, see iregex) - (cons (concat "\\(\\([_^-]?\\(" iregex "\\)\\)+\\)\\($\\|[] \t(~{}>\\\\_()^*-]\\)") '(1 font-lock-function-name-face)) + (cons (concat "\\(\\([_^-]?\\(" iregex "\\)\\)+\\)\\($\\|[] \t(~{}>\\\\_()^*-]\\)") '(1 lilypond-identifiers)) ;; ... keywords (defined above, see kwregex) - (cons (concat "\\(\\([_^-]?\\(" kwregex "\\)\\)+\\)\\($\\|[] \t(~{}>\\\\_()^*-]\\)") '(1 font-lock-keyword-face)) + (cons (concat "\\(\\([_^-]?\\(" kwregex "\\)\\)+\\)\\($\\|[] \t(~{}>\\\\_()^*-]\\)") '(1 lilypond-keywords)) ;; ... user defined identifiers \[a-zA-Z]+ - '("\\([_^-]?\\\\\\([a-zA-Z][a-zA-Z]*\\)\\)" 1 font-lock-constant-face) + '("\\([_^-]?\\\\\\([a-zA-Z][a-zA-Z]*\\)\\)" 1 lilypond-user) ;; ... the left side of '=' -mark - '("\\([_a-zA-Z.0-9-]+\\)[ \t]*=[ \t]*" 1 font-lock-variable-name-face) + '("\\([_a-zA-Z.0-9-]+\\)[ \t]*=[ \t]*" 1 lilypond-LS) ;; ... the right side of '=' -mark - '("[ \t]*=[ \t]*\\([_a-zA-Z.0-9-]+\\)" 1 font-lock-variable-name-face) + '("[ \t]*=[ \t]*\\([_a-zA-Z.0-9-]+\\)" 1 lilypond-RS) ;; ... reserved words (defined above, see rwregex) - (cons (concat "\\(" rwregex "\\)") 'font-lock-variable-name-face) + (cons (concat "\\(" rwregex "\\)") 'lilypond-reserved) ;; ... note or rest with (an accidental and) a duration, e.g., b,?16.*3/4 - (cons (concat "\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(" ncrwregex "\\)[,']*[?!]?\\|[srR]\\)" duration "?\\)") '(2 font-lock-type-face)) + (cons (concat "\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(" ncrwregex "\\)[,']*[?!]?\\|[srR]\\)" duration "?\\)") '(2 lilypond-notes)) ;; "on top", ... notes and rests with a long duration - (cons (concat "\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(" ncrwregex "\\)[,']*[?!]?\\|[srR]\\)" longduration "\\)") '(2 font-lock-type-face t)) + (cons (concat "\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(" ncrwregex "\\)[,']*[?!]?\\|[srR]\\)" longduration "\\)") '(2 lilypond-notes t)) ;; "on top", ... lyrics-mode: fontify everything between '<'...'>' or '{'...'}' ; URGH, does not know anything about inner brackets. ; Multiple lines may need refontifying (C-c f). - '("\\(\\\\lyrics[^{<]*\\)\\({[^}]*\\|<[^>]*\\)" 2 font-lock-string-face t) + '("\\(\\\\lyric[^{<]*\\)\\({[^}]*\\|<[^>]*\\)" 2 lilypond-lyrics t) + '("\\(\\\\addlyrics[^{<]*\\)\\({[^}]*\\|<[^>]*\\)" 2 lilypond-lyrics t) ;; "on top", ... horizontal grouping, also as postfix syntax '-*': ;; - brackets '{[]}' ;; - ties '~' ;; - ligatures \[, \] - '("\\(-?[][~}{]\\|\\\\[][]\\)" 0 font-lock-reference-face t) + '("\\(-?[][~}{]\\|\\\\[][]\\)" 0 lilypond-horizontal-grouping t) ;; "on top", ... vertical grouping: ;; - '<>'-chord brackets with '\\'-voice sep., not marcato '->' ;; - '<< a b >>8' -chords - (cons (concat "\\(\\(-.\\)+\\|[^-^_]\\)\\([<>]+\\(" duration "\\|" longduration "\\)?\\|\\\\\\\\\\)") '(3 font-lock-function-name-face t)) + (cons (concat "\\(\\(-.\\)+\\|[^-^_]\\)\\([<>]+\\(" duration "\\|" longduration "\\)?\\|\\\\\\\\\\)") '(3 lilypond-vertical-grouping t)) ;; "on top", ... expressional grouping, also as postfix syntax '-*': ;; - slurs ( ), \( \), [-^_][()] ;; - hairpins \<, \>, \! - '("\\(-?\\\\[(<!>)]\\|[-^_]?[()]\\)" 0 font-lock-builtin-face t) + '("\\(-?\\\\[(<!>)]\\|[-^_]?[()]\\)" 0 lilypond-expressional-grouping t) ;; "on top", ... (multiline-)scheme: try find slurs up to 7th - '("[_^-]?#\\(#[ft]\\|-?[0-9.]+\\|\"[^\"]*\"\\|['`]?[a-zA-Z:-]+\\|['`]?([^()]*\\(([^()]*\\(([^()]*\\(([^()]*\\(([^()]*\\(([^()]*\\(([^)]*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*[^)]*)\\)" 0 font-lock-string-face t) + '("[_^-]?#\\(#[ft]\\|-?[0-9.]+\\|\"[^\"]*\"\\|['`]?[a-zA-Z:-]+\\|['`]?([^()]*\\(([^()]*\\(([^()]*\\(([^()]*\\(([^()]*\\(([^()]*\\(([^)]*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*)[^()]*\\)*[^)]*)\\)" 0 lilypond-scheme t) ;; "on top", ... strings, match also unending strings at eof: ;; if '\n' was not found, it must be '$' which is eof (?). - '("\\([_^-]?\"\\([^\"\\\\]\\|\\\\.\\|\\\\\n\\)*\\(\"\\|$\\)\\)" 0 font-lock-string-face t) + '("\\([_^-]?\"\\([^\"\\\\]\\|\\\\.\\|\\\\\n\\)*\\(\"\\|$\\)\\)" 0 lilypond-strings t) ;; "on top", ... (multiline-)comments '("\\(%\\({[^%]*%\\(}\\|\\([^}][^%]*%\\)+}\\)\\|.*\\)\\)" 0 font-lock-comment-face t) ;;; lilypond-faces.el --- syntax coloring for LilyPond mode ;; Author: 2008: Christopher Suckling ;; * Emacs-mode: faces to customize and use with Lilypond-mode ;; TODO: ;; - Better defaults, including defaults for dark backgrounds (defvar lilypond-identifiers 'lilypond-identifiers "Face name to use for identifiers.") (defface lilypond-identifiers '((((class color) (background light)) (:foreground "purple3")) (t (:foreground "purple3"))) "Face for LilyPond identifiers." :group 'lilypond-faces) (defvar lilypond-keywords 'lilypond-keywords "Face name to use for keywords.") (defface lilypond-keywords '((((class color) (background light)) (:foreground "firebrick4")) (t (:foreground "firebrick4"))) "Face for LilyPond keywords." :group 'lilypond-faces) (defvar lilypond-user 'lilypond-user "Face name to use for user.") (defface lilypond-user '((((class color) (background light)) (:foreground "purple3")) (t (:foreground "purple3"))) "Face for LilyPond user defined identifiers." :group 'lilypond-faces) (defvar lilypond-LS 'lilypond-LS "Face name to use for left side of =.") (defface lilypond-LS '((((class color) (background light)) (:foreground "purple3")) (t (:foreground "purple3"))) "Face for LilyPond left side of =." :group 'lilypond-faces) (defvar lilypond-RS 'lilypond-RS "Face name to use for right side of =.") (defface lilypond-RS '((((class color) (background light)) (:foreground "cyan4")) (t (:foreground "cyan4"))) "Face for LilyPond right side of =." :group 'lilypond-faces) (defvar lilypond-reserved 'lilypond-reserved "Face name to use for reserved.") (defface lilypond-reserved '((((class color) (background light)) (:foreground "black")) (t (:foreground "black"))) "Face for LilyPond reserved words." :group 'lilypond-faces) (defvar lilypond-notes 'lilypond-notes "Face name to use for notes.") (defface lilypond-notes '((((class color) (background light)) (:foreground "royalblue3" :weight bold :height 1.1)) (t (:foreground "royalblue3" :weight bold :height 1.1))) "Face for LilyPond note or rest with (an accidental and) a duration, e.g., b,?16.*3/4." :group 'lilypond-faces) (defvar lilypond-long-notes 'lilypond-long-notes "Face name to use for long-notes.") (defface lilypond-long-notes '((((class color) (background light)) (:foreground "royalblue3" :weight bold :height 1.1)) (t (:foreground "royalblue3" :weight bold :height 1.1))) "Face for LilyPond notes and rests with a long duration." :group 'lilypond-faces) (defvar lilypond-lyrics 'lilypond-lyrics "Face name to use for lyrics.") (defface lilypond-lyrics '((((class color) (background light)) (:foreground "black" :slant italic)) (t (:foreground "black" :slant italic))) "Face for LilyPond lyrics-mode: fontify everything between '<'...'>' or '{'...'}'." :group 'lilypond-faces) (defvar lilypond-horizontal-grouping 'lilypond-horizontal-grouping "Face name to use for horizontal-grouping.") (defface lilypond-horizontal-grouping '((((class color) (background light)) (:foreground "green4" :weight bold)) (t (:foreground "green4" :weight bold))) "Face for LilyPond horizontal grouping." :group 'lilypond-faces) (defvar lilypond-vertical-grouping 'lilypond-vertical-grouping "Face name to use for vertical-grouping.") (defface lilypond-vertical-grouping '((((class color) (background light)) (:foreground "green4" :weight bold)) (t (:foreground "green4" :weight bold))) "Face for LilyPond vertical grouping." :group 'lilypond-faces) (defvar lilypond-expressional-grouping 'lilypond-expressional-grouping "Face name to use for expressional-grouping.") (defface lilypond-expressional-grouping '((((class color) (background light)) (:foreground "firebrick4")) (t (:foreground "firebrick4"))) "Face for LilyPond expressional grouping." :group 'lilypond-faces) (defvar lilypond-scheme 'lilypond-scheme "Face name to use for scheme.") (defface lilypond-scheme '((((class color) (background light)) (:foreground "black")) (t (:foreground "black"))) "Face for LilyPond (multiline-)scheme: try find slurs up to 7th." :group 'lilypond-faces) (defvar lilypond-strings 'lilypond-strings "Face name to use for strings.") (defface lilypond-strings '((((class color) (background light)) (:foreground "black" :slant italic)) (t (:foreground "black" :slant italic))) "Face for LilyPond strings." :group 'lilypond-faces) (provide 'lilypond-faces) _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user