]> git.donarmstrong.com Git - lilypond.git/commitdiff
* buildscripts/lilypond.words.py: extract note names.
authorHeikki Junes <heikki.junes@hut.fi>
Thu, 18 Sep 2003 20:48:44 +0000 (20:48 +0000)
committerHeikki Junes <heikki.junes@hut.fi>
Thu, 18 Sep 2003 20:48:44 +0000 (20:48 +0000)
        * lilypond-mode.el: take note names from lilypond.words -file.
        small fix in the use of string-match.

        * lilypond-font-lock.el: use lilypond.words for note names, add
        maxima to note a duration.

ChangeLog
buildscripts/lilypond.words.py
lilypond-font-lock.el
lilypond-mode.el

index 3fd2b92780539366353dfdddbbb716dc3dab2fc2..bad9fb76a4144342773a5ff07d68e6f2f03dfac7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-09-18  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * buildscripts/lilypond.words.py: extract note names.
+
+       * lilypond-mode.el: take note names from lilypond.words -file.
+       small fix in the use of string-match.
+
+       * lilypond-font-lock.el: use lilypond.words for note names, add 
+       maxima to note a duration.
+
 2003-09-18  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        *  debian/rules: small corrections in the (Pedro K)
index 32fcbf2f4dddcb24480192f43ac814e039d2bcb1..c21202b0517812d8ce7f6daad4e764be6c6942fb 100755 (executable)
@@ -74,6 +74,53 @@ for name in [
            outlines = outlines + [prekw + m.group(2)]
     F.close()
 
+# more identifiers
+for name in [
+'ly/declarations-init.ly',
+'ly/paper11-init.ly',
+'ly/paper13-init.ly',
+'ly/paper16-init.ly',
+'ly/paper19-init.ly',
+'ly/paper20-init.ly',
+'ly/paper23-init.ly',
+'ly/paper26-init.ly',
+'ly/paper-as5-init.ly',
+'ly/paper-as9-init.ly',
+'ly/paper-init.ly',
+'ly/params-init.ly',
+'ly/params-as-init.ly',
+]:
+    F = open(name, 'r')
+    for line in F.readlines():
+        m = re.search(r"^(\s*)([a-zA-Z]+)(\s*=)",line)
+        if m:
+           outlines = outlines + [prekw + m.group(2)]
+    F.close()
+
+# note names
+for name in [
+'ly/catalan.ly',
+'ly/deutsch.ly',
+'ly/drumpitch-init.ly',
+'ly/english.ly',
+'ly/espanol.ly',
+'ly/italiano.ly',
+'ly/nederlands.ly',
+'ly/norsk.ly',
+'ly/suomi.ly',
+'ly/svenska.ly',
+]:
+    F = open(name, 'r')
+    for line in F.readlines():
+       for pattern in [
+       r"^(\s*\()([a-z]+)([^l]+ly:make-pitch)",
+       ]:
+           m = re.search(pattern,line)
+           if m:
+                print(m.group(2))
+               outlines = outlines + ['' + m.group(2)]
+    F.close()
+    
 # reserved words
 for name in [
 'ly/engraver-init.ly',
index cb07b331d75f0db39381d356091610c49e768491..511db9e3882d306762476e6499fe2598c494793a 100644 (file)
@@ -5,14 +5,15 @@
 ;; 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
+;;  * File lilypond.words contains \keywords, \Identifiers and 
+;;    ReservedWords notenames.
 ;;  * context-dependent syntax-tables
 ;; Author: 1997: Han-Wen Nienhuys
 ;; Author: 1995-1996 Barry A. Warsaw
 ;;         1992-1994 Tim Peters
 ;; Created:       Feb 1992
-;; Version:       1.7.25
-;; Last Modified: 20JUL2003
+;; Version:       1.9.7
+;; Last Modified: 18SEP2003
 ;; Keywords: lilypond languages music notation
 
 ;; This software is provided as-is, without express or implied
 (defconst LilyPond-font-lock-keywords
   (let* ((kwregex (mapconcat (lambda (x) (concat "\\" x))  LilyPond-keywords "\\|"))
         (iregex (mapconcat (lambda (x) (concat "\\" x))  LilyPond-identifiers "\\|"))
-        (rwregex (mapconcat (lambda (x) (concat "" x))  LilyPond-reserved-words "\\|"))
+        (ncrwregex (mapconcat (lambda (x) (concat "" x))  LilyPond-non-capitalized-reserved-words "\\|"))
+        (rwregex (mapconcat (lambda (x) (concat "" x))  LilyPond-Capitalized-Reserved-Words "\\|"))
+        (duration "\\([ \t]*\\(\\\\breve\\|128\\|6?4\\|3?2\\|16?\\|8\\)[.]*\\([ \t]*[*][ \t]*[0-9]+\\(/[1-9][0-9]*\\)?\\)?\\)") 
+        (longduration "\\([ \t]*\\(\\\\\\(longa\\|breve\\|maxima\\)\\)[.]*\\([ \t]*[*][ \t]*[0-9]+\\(/[1-9][0-9]*\\)?\\)?\\)") 
 )
 
     (list 
@@ -64,8 +68,8 @@
 ;; ... keywords (defined above, see kwregex)
       (cons (concat "\\(\\([_^-]?\\(" kwregex "\\)\\)+\\)\\($\\|[] \t(~{}>\\\\_()^*-]\\)") '(1 font-lock-keyword-face))
 
-;; ... user defined identifiers \[a-zA-Z]+, but not \breve or \longa (durations)
-      '("\\([_^-]?\\\\\\([ac-km-zA-Z]\\|l[a-np-zA-Z]\\|b[a-qs-zA-Z]\\|lo[a-mo-zA-Z]\\|br[a-df-zA-Z]\\|lon[a-fh-zA-Z]\\|bre[a-uw-zA-Z]\\|long[b-zA-Z]\\|brev[a-df-zA-Z]\\|\\(longa\\|breve\\)[a-zA-Z]\\)[a-zA-Z]*\\)" 1 font-lock-constant-face)
+;; ... user defined identifiers \[a-zA-Z]+
+      '("\\([_^-]?\\\\\\([a-zA-Z][a-zA-Z]*\\)\\)" 1 font-lock-constant-face)
 
 ;; ... the left side of '=' -mark
       '("\\([_a-zA-Z.0-9-]+\\)[ \t]*=[ \t]*" 1 font-lock-variable-name-face)
 ;; ... reserved words (defined above, see rwregex)
       (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)
-;; ... 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)
+;; ... 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))
+
+;; "on top", ... notes and rests with a long duration
+      (cons (concat longduration) '(0 font-lock-type-face t))
 
 ;; "on top", ... lyrics-mode: fontify everything between '<'...'>' or '{'...'}'
 ;            URGH, does not know anything about inner brackets.
 ;; "on top", ... vertical grouping:
 ;;               - '<>'-chord brackets with '\\'-voice sep., not marcato '->'
 ;;               - '<< a b >>8' -chords
-      '("\\(\\(-.\\)+\\|[^-^_]\\)\\([<>]+\\(\\(128\\|6?4\\|3?2\\|16?\\|8\\|\\\\\\(breve\\|longa\\)\\)[.]*\\([ \t]*[*][ \t]*[0-9]+\\(/[1-9][0-9]*\\)?\\)?\\)?\\|\\\\\\\\\\)" 3 font-lock-function-name-face t)
+      (cons (concat "\\(\\(-.\\)+\\|[^-^_]\\)\\([<>]+\\(" duration "\\|" longduration "\\)?\\|\\\\\\\\\\)") '(3 font-lock-function-name-face t))
 
 ;; "on top", ... expressional grouping, also as postfix syntax '-*':
 ;;               - slurs ( ), \( \), [-^_][()]
index 2a55aece089107dcd153250fefd8b05eb0f36a37..8672c1f239e42d2bc529fc2096ad40929174920c 100644 (file)
@@ -115,7 +115,11 @@ Finds file lilypond-words from load-path."
        (setq currword (car co))
        (if (> (length currword) 1)
            (if (and (string-equal "\\" (substring currword 0 1))
-                    (not (string-match "[^a-zA-Z-]" (substring currword 1)))
+                    (progn (string-match "[a-z-]+" currword)
+                           (= (match-end 0) (length currword)))
+                    (not (string-equal "\\longa" currword))
+                    (not (string-equal "\\breve" currword))
+                    (not (string-equal "\\maxima" currword))
                     (string-equal (downcase currword) currword))
                (add-to-list 'wordlist currword)))
        (if (string-equal "-" (car (setq co (cdr co))))
@@ -132,7 +136,8 @@ Finds file lilypond-words from load-path."
        (setq currword (car co))
        (if (> (length currword) 1)
            (if (and (string-equal "\\" (substring currword 0 1))
-                    (not (string-match "[^a-zA-Z-]" (substring currword 1)))
+                    (progn (string-match "[a-zA-Z-]+" currword)
+                           (= (match-end 0) (length currword)))
                     (not (string-equal (downcase currword) currword)))
                (add-to-list 'wordlist currword)))
        (if (string-equal "-" (car (setq co (cdr co))))
@@ -141,14 +146,33 @@ Finds file lilypond-words from load-path."
       wordlist))
   "LilyPond \\Identifiers")
 
-(defconst LilyPond-reserved-words 
+(defconst LilyPond-Capitalized-Reserved-Words 
   (let ((wordlist '("Staff")) ; add ReservedWords to lilypond.words
        (co (all-completions "" (LilyPond-add-dictionary-word ()))))
     (progn
       (while (> (length co) 0)
        (setq currword (car co))
        (if (> (length currword) 0)
-           (if (not (string-match "[^a-zA-Z]" currword))
+           (if (and (progn (string-match "[a-zA-Z_]+" currword)
+                           (= (match-end 0) (length currword)))
+                    (not (string-equal (downcase currword) currword)))
+               (add-to-list 'wordlist currword)))
+       (if (string-equal "-" (car (setq co (cdr co))))
+           (while (and (> (length co) 0)
+                       (not (string-equal "-" (car (setq co (cdr co)))))))))
+      wordlist))
+  "LilyPond ReservedWords")
+
+(defconst LilyPond-non-capitalized-reserved-words
+  (let ((wordlist '("c")) ; add note names lilypond.words
+       (co (all-completions "" (LilyPond-add-dictionary-word ()))))
+    (progn
+      (while (> (length co) 0)
+       (setq currword (car co))
+       (if (> (length currword) 0)
+           (if (and (progn (string-match "[a-z]+" currword)
+                           (= (match-end 0) (length currword)))
+                    (string-equal (downcase currword) currword))
                (add-to-list 'wordlist currword)))
        (if (string-equal "-" (car (setq co (cdr co))))
            (while (and (> (length co) 0)