]> git.donarmstrong.com Git - lilypond.git/blobdiff - lilypond-font-lock.el
Marked files for deletion or moving to regression. Modified
[lilypond.git] / lilypond-font-lock.el
index cc2a7599bc5b580b243da33534736205232a20fc..6e1e6ee91b74015545afca457bbcd445d4f100ab 100644 (file)
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 1992,1993,1994  Tim Peters
 
-;; Author: 2001-2002: Heikki Junes
+;; Author: 2001-2003: Heikki Junes
 ;;  * Emacs-mode: new keywords, reserved words, identifiers, notenames, 
 ;;    some dynamics and brackets are font-lock-keywords
 ;;  * File lilypond.words gives keywords, identifiers and reserved words
@@ -10,8 +10,8 @@
 ;; Author: 1995-1996 Barry A. Warsaw
 ;;         1992-1994 Tim Peters
 ;; Created:       Feb 1992
-;; Version:       1.7.9
-;; Last Modified: 12DEC2002
+;; Version:       1.7.20
+;; Last Modified: 9JUN2003
 ;; Keywords: lilypond languages music notation
 
 ;; This software is provided as-is, without express or implied
 ;; ... (v) the right and the left side of '='-marks.
 ;; ... (v) reserved words, e.g., FiguredBass.
 ;; ... (t) notes and rests
+;; "on top", ... (s) lyrics-mode
 ;; "on top", ... (w) horizontal grouping
 ;; "on top", ... (f) vertical grouping
 ;; "on top", ... (b) expressional grouping
-;; "on top", ... (s) lyrics-mode
 ;; "on top", ... (s) (multiline-)scheme; urgh. one should count the slurs
 ;; "on top", ... (s) strings
 ;; "on top", ... (c) (multiline-)comments
       (cons (concat "\\(" rwregex "\\)") 'font-lock-variable-name-face)
 
 ;; ... note or rest with (an accidental and) a duration (multiplied), e.g., b,?16.*3/4
-      '("\\(^\\|[ <\{[~(!)\t\\\|]\\)\\(\\(\\(\\(bb\\|as[ae]s\\|eses\\|\\(do\\|re\\|[ms]i\\|[fl]a\\|sol\\)\\(bb?\\|dd?\\|ss?\\)?\\)\\|\\([a-h]\\(\\(flat\\)+\\|\\(sharp\\)+\\|is\\(siss\\|i?s\\)?\\|es\\(sess\\|e?s\\)?\\|ff?\\|ss?\\)?\\)\\)[,']*[?!]?\\|[srR]\\)\\([ \t]*\\(128\\|6?4\\|3?2\\|16?\\|8\\|\\\\\\(breve\\|longa\\)\\)[.]*\\([ \t]*[*][ \t]*[0-9]+\\(/[1-9][0-9]*\\)?\\)?\\)\\)" 2 font-lock-type-face)
+      '("\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(\\(bb\\|as[ae]s\\|eses\\|\\(do\\|re\\|[ms]i\\|[fl]a\\|sol\\)\\(bb?\\|dd?\\|ss?\\)?\\)\\|\\([a-h]\\(\\(flat\\)+\\|\\(sharp\\)+\\|is\\(siss\\|i?s\\)?\\|es\\(sess\\|e?s\\)?\\|ff?\\|ss?\\)?\\)\\)[,']*[?!]?\\|[srR]\\)\\([ \t]*\\(128\\|6?4\\|3?2\\|16?\\|8\\|\\\\\\(breve\\|longa\\)\\)[.]*\\([ \t]*[*][ \t]*[0-9]+\\(/[1-9][0-9]*\\)?\\)?\\)\\)" 2 font-lock-type-face)
 ;; ... note or rest (with an accidental), e.g., b,? -- allows cis\longaX
-      '("\\(^\\|[ <\{[~(!)\t\\\|]\\)\\(\\(\\(bb\\|as[ae]s\\|eses\\|\\(do\\|re\\|[ms]i\\|[fl]a\\|sol\\)\\(bb?\\|dd?\\|ss?\\)?\\)\\|\\([a-h]\\(\\(flat\\)+\\|\\(sharp\\)+\\|is\\(siss\\|i?s\\)?\\|es\\(sess\\|e?s\\)?\\|ff?\\|ss?\\)?\\)\\)[,']*[?!]?\\|[srR]\\)" 2 font-lock-type-face)
+      '("\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(bb\\|as[ae]s\\|eses\\|\\(do\\|re\\|[ms]i\\|[fl]a\\|sol\\)\\(bb?\\|dd?\\|ss?\\)?\\)\\|\\([a-h]\\(\\(flat\\)+\\|\\(sharp\\)+\\|is\\(siss\\|i?s\\)?\\|es\\(sess\\|e?s\\)?\\|ff?\\|ss?\\)?\\)\\)[,']*[?!]?\\|[srR]\\)" 2 font-lock-type-face)
+
+;; "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)
 
-;; "on top", ... horizontal grouping:
+;; "on top", ... horizontal grouping, also as postfix syntax '-*':
 ;;               - brackets '{[]}'
 ;;               - ties '~'
-      '("\\([][~}{]\\)" 0 font-lock-warning-face t)
+;;               - ligatures \[, \]
+      '("\\(-?[][~}{]\\|\\\\[][]\\)" 0 font-lock-warning-face t)
 
 ;; "on top", ... vertical grouping:
 ;;               - '<>'-chord brackets with '\\'-voice sep., not marcato '->'
 ;;               - '<< a b >>8' -chords
-      '("\\(\\(-.\\)+\\|[^-^_]\\)\\([<>]+\\(128\\|6?4\\|3?2\\|16?\\|8\\|\\\\\\(breve\\|longa\\)\\)?\\|\\\\\\\\\\)" 3 font-lock-function-name-face t)
+      '("\\(\\(-.\\)+\\|[^-^_]\\)\\([<>]+\\(\\(128\\|6?4\\|3?2\\|16?\\|8\\|\\\\\\(breve\\|longa\\)\\)[.]*\\([ \t]*[*][ \t]*[0-9]+\\(/[1-9][0-9]*\\)?\\)?\\)?\\|\\\\\\\\\\)" 3 font-lock-function-name-face t)
 
-;; "on top", ... expressional grouping:
-;;               - slurs \( () \)
+;; "on top", ... expressional grouping, also as postfix syntax '-*':
+;;               - slurs ( ), \( \), [-^_][()]
 ;;               - hairpins \<, \>, \! 
-      '("\\(\\\\[(<!>)]\\|[()]\\)" 0 font-lock-builtin-face t)
-
-;; "on top", ... lyrics-mode: fontify everything between '{' and '}'
-      '("\\(\\\\lyrics[^{]*{\\)\\([^}]*\\)" 2 font-lock-string-face t)
+      '("\\(-?\\\\[(<!>)]\\|[-^_]?[()]\\)" 0 font-lock-builtin-face 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 font-lock-string-face t)
 
-;; "on top", ... strings
-      '("\\([_^-]?\"\\([^\"\\\\]\\|\\\\.\\|\\\\\n\\)*\"\\)" 0 font-lock-string-face 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)
 
 ;; "on top", ... (multiline-)comments
       '("\\(%\\({[^%]*%\\(}\\|\\([^}][^%]*%\\)+}\\)\\|.*\\)\\)" 0 font-lock-comment-face t)
 (defvar LilyPond-mode-syntax-table nil
   "Syntax table used in `LilyPond-mode' buffers.")
 
-;;
 (if LilyPond-mode-syntax-table
     ()
   (setq LilyPond-mode-syntax-table (make-syntax-table))
+  ;; NOTE: Emacs knows only "13"-style (used), XEmacs knows also "1b3b", etc.
   (mapcar (function
           (lambda (x) (modify-syntax-entry
                        (car x) (cdr x) LilyPond-mode-syntax-table)))
-         '(( ?\( . "." ) ( ?\) . "." ) 
-           ( ?\[ . "(]" ) ( ?\] . ")[" ) ;; all the other paren characters are now handled by          
-           ( ?\{  .  ". 2b" )             ;; lily-specific indenting/matching code in lilypond-indent.el 
-           ( ?\}  .  ". 4b" )              
-           ( ?\< . "." )( ?\> . ".") 
+         '(
+           ;; all the paren characters are now handled by   
+           ;; lily-specific indenting/matching code in lilypond-indent.el
+           ;; Emacs' show-paren-function and XEmacs' paren-highlight use
+           ;; these slur-definitions through Lilypond specific scan-sexps.
+           ( ?\[ . "(]" ) ( ?\] . ")[" )
+           ( ?\( . "()" ) ( ?\) . ")(" ) 
+           ( ?\< . "(>" ) ( ?\> . ")<") 
+           ( ?\{  .  "(} 2" )  ; also 2nd char in begin of block-comment
+           ( ?\}  .  "){ 4" )  ; also 2nd char in end of block-comment
+           ( ?\%  .  "< 13" ) ; comment starter, 1st char in block-comments
+           ( ?\n . ">")       ; newline: comment ender
+           ( ?\r . ">")       ; formfeed: comment ender
+           ( ?\\ . "\\" )     ; escape characters (as '\n' in strings)
+           ( ?\" . "\"" )     ; string quote characters
+           ;; word constituents (e.g., belonging to a note)
+           ( ?\' . "w") ( ?\, . "w") ; transposing octaves
+           ;; punctuation characters (separate symbols from another)
            ( ?\$ . "." ) ( ?\& . "." )
-           ( ?\* . "." ) ( ?\+ . "." )
-           ( ?\/ . "." )  ( ?\= . "." )
-           ( ?\| . "." ) (?\\ . "\\" )
-           ( ?\- . "." ) ( ?\_ . "." ) ( ?\^ . "." ) ; accent positioners: puctuation characters
-           ( ?\' . "w") ( ?\, . "w") ; transposing octaves, parts of words (notes)
-           ( ?\" . "\"" ) ; string quote characters 
-           ( ?\%  .  "< 1b3b" ) ; (block-)comment starter (or ender)
-           ( ?\n . ">") ; newline: comment ender
-           ( ?\r . ">") ; formfeed: comment ender
+           ( ?\* . "." ) ( ?\+ . "." ) ( ?\/ . "." )  ( ?\= . "." )
+           ( ?\| . "." )      ; bar line
+           ( ?\- . "." ) ( ?\_ . "." ) ( ?\^ . "." ) ; accent positioners
            ))
   )