]> git.donarmstrong.com Git - lilypond.git/blob - lilypond-font-lock.el
patch::: 1.5.4.jcn1
[lilypond.git] / lilypond-font-lock.el
1 ;;; lilypond-font-lock.el --- syntax coloring for LilyPond mode
2
3 ;; Copyright (C) 1992,1993,1994  Tim Peters
4
5 ;; Author: 1997: Han-Wen Nienhuys
6 ;; Author: 1995-1996 Barry A. Warsaw
7 ;;         1992-1994 Tim Peters
8 ;; Created:       Feb 1992
9 ;; Version:       0.0
10 ;; Last Modified: 12SEP97
11 ;; Keywords: lilypond languages music notation
12
13 ;; This software is provided as-is, without express or implied
14 ;; warranty.  Permission to use, copy, modify, distribute or sell this
15 ;; software, without fee, for any purpose and by any individual or
16 ;; organization, is hereby granted, provided that the above copyright
17 ;; notice and this paragraph appear in all copies.
18
19 ;; This started out as a cannabalised version of python-mode.el, by hwn
20 ;; For changes see the LilyPond ChangeLog
21 ;;
22 ;; TODO:
23 ;;   - should handle block comments too.
24 ;;   - handle lexer modes (\header, \melodic, \lyric) etc.
25 ;;   - indentation
26 ;;   - notenames?
27 ;;   - fontlock: \melodic \melodic
28
29 (defconst LilyPond-font-lock-keywords
30   (let* ((keywords '(
31
32 "apply" "arpeggio" "autochange" "spanrequest" "commandspanrequest"
33 "simultaneous" "sequential" "accepts" "alternative" "bar" "breathe"
34 "char" "chordmodifiers" "chords" "clef" "cm" "consists" "consistsend"
35 "context" "denies" "duration" "dynamicscript" "elementdescriptions"
36 "font" "grace" "header" "in" "lyrics" "key" "mark" "musicalpitch"
37 "time" "times" "midi" "mm" "name" "notenames" "notes" "outputproperty"
38 "override" "set" "revert" "partial" "paper" "penalty" "property" "pt"
39 "relative" "remove" "repeat" "addlyrics" "partcombine" "score"
40 "script" "stylesheet" "skip" "textscript" "tempo" "translator"
41 "transpose" "type" "unset" 
42                       ))
43        (kwregex (mapconcat (lambda (x) (concat "\\\\" x))  keywords "\\|")))
44
45     (list 
46       (concat ".\\(" kwregex "\\)[^a-zA-Z]")
47       (concat "^\\(" kwregex "\\)[^a-zA-Z]")
48       '(".\\(\\\\[a-zA-Z][a-zA-Z]*\\)" 1 font-lock-variable-name-face)
49       '("^[\t ]*\\([a-zA-Z][_a-zA-Z]*\\) *=" 1 font-lock-variable-name-face)     
50     ))
51   "Additional expressions to highlight in LilyPond mode.")
52
53 ;; define a mode-specific abbrev table for those who use such things
54 (defvar LilyPond-mode-abbrev-table nil
55   "Abbrev table in use in `LilyPond-mode' buffers.")
56
57 (define-abbrev-table 'LilyPond-mode-abbrev-table nil)
58
59 (defvar LilyPond-mode-syntax-table nil
60   "Syntax table used in `LilyPond-mode' buffers.")
61
62 ;;
63 (if LilyPond-mode-syntax-table
64     ()
65   (setq LilyPond-mode-syntax-table (make-syntax-table))
66   (mapcar (function
67            (lambda (x) (modify-syntax-entry
68                         (car x) (cdr x) LilyPond-mode-syntax-table)))
69           '(( ?\( . "()" ) ( ?\) . ")(" )   ; need matching parens for inline lisp
70             ( ?\[ . "." ) ( ?\] . "." )
71             ( ?\{ . "(}" ) ( ?\} . "){" )
72             ( ?\< . "(>" )( ?\> . ")>") 
73             ( ?\$ . "." ) ( ?\% . "." ) ( ?\& . "." )
74             ( ?\* . "." ) ( ?\+ . "." ) ( ?\- . "." )
75             ( ?\/ . "." )  ( ?\= . "." )
76             ( ?\| . "." ) (?\\ . "\\" )
77             ( ?\_ . "." )       
78             ( ?\' . "w")        
79             ( ?\" . "\"" )
80             ( ?\% . "<")
81             ( ?\n . ">")
82
83 ; FIXME
84 ;           ( ?%  .  ". 124b" )
85 ;           ( ?{  .  ". 23" )
86             ))
87
88   )     
89