]> git.donarmstrong.com Git - lilypond.git/commitdiff
* buildscripts/lilypond.words: order words in search order,
authorhjunes <hjunes>
Mon, 22 Sep 2003 22:50:45 +0000 (22:50 +0000)
committerhjunes <hjunes>
Mon, 22 Sep 2003 22:50:45 +0000 (22:50 +0000)
        add lilypond.words.vim to be generated.

        * lilypond.vim: use lilypond.words.vim for keyword matching.

        * lilypond-mode.el: use search order. fix word selection rules.

        * lilypond-font-lock.el: fix fontifying long durations.

        * Documentation/topdocs/INSTALL.texi: doc lilypond.words.vim.

ChangeLog
Documentation/topdocs/INSTALL.texi
buildscripts/lilypond.words.py
lilypond-font-lock.el
lilypond-mode.el
lilypond.vim

index 5bda96224b6714e3305cbed3750916fd98d83d9e..0dd266e20c5a7f4b1b6aa43dc6b614d702289d37 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2003-09-23  Heikki Junes  <hjunes@cc.hut.fi>
+
+       * buildscripts/lilypond.words: order words in search order,
+       add lilypond.words.vim to be generated.
+
+       * lilypond.vim: use lilypond.words.vim for keyword matching.
+
+       * lilypond-mode.el: use search order. fix word selection rules.
+
+       * lilypond-font-lock.el: fix fontifying long durations.
+
+       * Documentation/topdocs/INSTALL.texi: doc lilypond.words.vim.
+
 2003-09-22  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * cygwin/mknetrel: Remove PYTHONPATH and manpage workarounds.
index dfde798a1a545cb46fad56e413f07ec64c39c583..9db4fcd3770ccd165f766d17fd190ec08a891296 100644 (file)
@@ -266,9 +266,9 @@ to your @var{load-path}. Append the following line (modified) to your
 A Vim mode for entering music and running LilyPond is contained in
 the source archive. Append the content of @file{vimrc} to @file{~/.vimrc}
 to get shortcuts. Install file @file{lilypond.words.el} to @file{~/.vim/} to 
-get auto-completion. Syntax highlighting you get by installing 
-@file{lilypond.vim} to @file{~/.vim/syntax/} and appending the following
-to @file{~/.vim/filetype.vim}:
+get auto-completion. Syntax highlighting you get by installing files
+@file{lilypond.vim} and @file{lilypond.words.vim} to @file{~/.vim/syntax/} 
+and appending the following to @file{~/.vim/filetype.vim}:
 @quotation
 @example
        " my filetype file
index 445fff7544ed0b26705ca0921e99b5ee53f37b37..63fd759bff5a6d175f1839aa3af7c95fcd990989 100755 (executable)
@@ -7,19 +7,20 @@ import string
 import re
 import sys
 
-outlines = []
-prekw = '\\\\'
+kw = []
+rw = []
+notes = []
 
 # keywords not otherwise found
 for line in ['include','maininput','version']:
-    outlines = outlines + [prekw + line]
+    kw = kw + [line]
 
 # the main keywords
 F = open('lily/my-lily-lexer.cc', 'r')
 for line in F.readlines():
     m = re.search(r"(\s*{\")(.*)(\",\s*.*},\s*\n)",line)
     if m:
-       outlines = outlines + [prekw + m.group(2)]
+       kw = kw + [m.group(2)]
 F.close()
 
 # keywords in markup
@@ -27,7 +28,7 @@ F = open('scm/new-markup.scm', 'r')
 for line in F.readlines():
     m = re.search(r"^(\s*\(cons\s*)([a-z-]*)(-markup)",line)
     if m:
-       outlines = outlines + [prekw + m.group(2)]
+       kw = kw + [m.group(2)]
 F.close()
 
 # identifiers and keywords
@@ -48,7 +49,7 @@ for name in [
     for line in F.readlines():
         m = re.search(r"^([a-zA-Z]+)(\s*=)",line)
         if m:
-           outlines = outlines + [prekw + m.group(1)]
+           kw = kw + [m.group(1)]
     F.close()
 
 # more identifiers
@@ -71,7 +72,7 @@ for name in [
     for line in F.readlines():
         m = re.search(r"^(\s*)([a-zA-Z]+)(\s*=)",line)
         if m:
-           outlines = outlines + [prekw + m.group(2)]
+           kw = kw + [m.group(2)]
     F.close()
 
 # note names
@@ -91,7 +92,7 @@ for name in [
     for line in F.readlines():
        m = re.search(r"^(\s*\()([a-z]+)([^l]+ly:make-pitch)",line)
        if m:
-           outlines = outlines + ['' + m.group(2)]
+           notes = notes + ['' + m.group(2)]
     F.close()
 
 # (short) drum names
@@ -102,8 +103,7 @@ for name in [
     for line in F.readlines():
        m = re.search(r"^(\s*\([a-z]+\s*)([a-z]+)(\s*,\(ly:make-pitch)",line)
        if m:
-           print(m.group(2))
-           outlines = outlines + ['' + m.group(2)]
+           notes = notes + ['' + m.group(2)]
     F.close()
     
 # reserved words
@@ -120,14 +120,50 @@ for name in [
        ]:
            m = re.search(pattern,line)
            if m:
-               outlines = outlines + ['' + m.group(2)]
+               rw = rw + ['' + m.group(2)]
     F.close()
 
 # the output file
 if sys.argv[1:] == []:
-  out = open('lilypond.words.el', 'w')
+  out_el = open('lilypond.words.el', 'w')
+  out_vim = open('lilypond.words.vim', 'w')
 else:
-  out = open(sys.argv[1]+'/lilypond.words.el', 'w')
+  out_el = open(sys.argv[1]+'/lilypond.words.el', 'w')
+  out_vim = open(sys.argv[1]+'/lilypond.words.vim', 'w')
+   
+# alphabetically ordered words
+kw.sort()
+kw.reverse()
+prevline = ''
+out_vim.write('syn match lilyKeyword \"[-_^]\\?\\\\\\(');
+for line in kw:
+    if line != prevline:
+        out_el.write('\\\\' + line + '\n')
+       out_vim.write(line + '\\|')
+    prevline = line
+out_vim.write('n\\)\\(\\A\\|\\n\\)\"me=e-1\n')
+
+rw.sort()
+rw.reverse()
+prevline = ''
+out_vim.write('syn match lilyReservedWord \"\\(\\A\\|\\n\\)\\(');
+for line in rw:
+    if line != prevline:
+        out_el.write(line + '\n')
+       out_vim.write(line + '\\|')
+    prevline = line
+out_vim.write('Score\\)\\(\\A\\|\\n\\)\"ms=s+1,me=e-1\n')
+
+notes.sort()
+notes.reverse()
+prevline = ''
+out_vim.write('syn match lilyNote \"\\<\\(\\(\\(');
+for line in notes:
+    if line != prevline:
+        out_el.write(line + '\n')
+       out_vim.write(line + '\\|')
+    prevline = line
+out_vim.write('a\\)\\([,\']\\)\\{,4}\\([?!]\\)\\?\\)\\|s\\|r\\)\\(\\(128\\|64\\|32\\|16\\|8\\|4\\|2\\|1\\|\\\\breve\\|\\\\longa\\|\\\\maxima\\)[.]\\{,8}\\)\\?\\(\\A\\|\\n\\)\"me=e-1\n')
 
 # the menu in lilypond-mode.el
 for line in [
@@ -153,14 +189,7 @@ for line in [
 '//transpose - % { _ } -',
 ]:
     # urg. escape char '/' is replaced with '\\' which python writes as a '\'.
-    out.write(string.join(string.split(line,'/'),'\\') + '\n')
-    
-# alphabetically ordered words
-outlines.sort()
-prevline = ''
-for line in outlines:
-    if line != prevline:
-        out.write(line + '\n')
-    prevline = line
-
-out.close()
+    out_el.write(string.join(string.split(line,'/'),'\\') + '\n')
+out_el.close()
+out_vim.close()
index 7af3b347bc180135c4f03c875f93c40e90d9c0f2..c2e258a709bbe9d8f9c2d9d581414ee109f54b20 100644 (file)
@@ -10,8 +10,8 @@
 ;; Author: 1995-1996 Barry A. Warsaw
 ;;         1992-1994 Tim Peters
 ;; Created:       Feb 1992
-;; Version:       1.9.7
-;; Last Modified: 18SEP2003
+;; Version:       1.9.9
+;; Last Modified: 23SEP2003
 ;; Keywords: lilypond languages music notation
 
 ;; This software is provided as-is, without express or implied
@@ -32,7 +32,7 @@
         (iregex (mapconcat (lambda (x) (concat "\\" x))  LilyPond-identifiers "\\|"))
         (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]*\\)?\\)?\\)") 
+        (duration "\\([ \t]*\\(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]*\\)?\\)?\\)") 
 )
 
@@ -82,7 +82,7 @@
       (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))
+      (cons (concat "\\(^\\|[ <\{[/~(!)\t\\\|]\\)\\(\\(\\(" ncrwregex "\\)[,']*[?!]?\\|[srR]\\)" longduration "\\)") '(2 font-lock-type-face t))
 
 ;; "on top", ... lyrics-mode: fontify everything between '<'...'>' or '{'...'}'
 ;            URGH, does not know anything about inner brackets.
index 60e4e6ebb1192c25809c427a7527129350ddd05a..10b3147ff8db599692f3813d618930ddd67b41da 100644 (file)
@@ -19,7 +19,7 @@
 (require 'easymenu)
 (require 'compile)
 
-(defconst LilyPond-version "1.8.0"
+(defconst LilyPond-version "1.9.9"
   "`LilyPond-mode' version number.")
 
 (defconst LilyPond-help-address "bug-lilypond@gnu.org"
@@ -115,8 +115,9 @@ Finds file lilypond-words.el from load-path."
        (setq currword (car co))
        (if (> (length currword) 1)
            (if (and (string-equal "\\" (substring currword 0 1))
-                    (progn (string-match "[a-z-]+" currword)
-                           (= (match-end 0) (length currword)))
+                    (string-match "[a-z-]+" currword)
+                    (= (match-beginning 0) 1)
+                    (= (match-end 0) (length currword))
                     (not (string-equal "\\longa" currword))
                     (not (string-equal "\\breve" currword))
                     (not (string-equal "\\maxima" currword))
@@ -125,7 +126,7 @@ Finds file lilypond-words.el from load-path."
        (if (string-equal "-" (car (setq co (cdr co))))
            (while (and (> (length co) 0)
                        (not (string-equal "-" (car (setq co (cdr co)))))))))
-      wordlist))
+      (reverse wordlist)))
   "LilyPond \\keywords")
 
 (defconst LilyPond-identifiers 
@@ -136,49 +137,52 @@ Finds file lilypond-words.el from load-path."
        (setq currword (car co))
        (if (> (length currword) 1)
            (if (and (string-equal "\\" (substring currword 0 1))
-                    (progn (string-match "[a-zA-Z-]+" currword)
-                           (= (match-end 0) (length currword)))
+                    (string-match "[a-zA-Z-]+" currword)
+                    (= (match-beginning 0) 1)
+                    (= (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))
+      (reverse wordlist)))
   "LilyPond \\Identifiers")
 
 (defconst LilyPond-Capitalized-Reserved-Words 
-  (let ((wordlist '("Staff"))
+  (let ((wordlist '("StaffContext"))
        (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-zA-Z_]+" currword)
-                           (= (match-end 0) (length currword)))
+           (if (and (string-match "[a-zA-Z_]+" currword)
+                    (= (match-beginning 0) 0)
+                    (= (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))
+      (reverse wordlist)))
   "LilyPond ReservedWords")
 
 (defconst LilyPond-non-capitalized-reserved-words
-  (let ((wordlist '("c"))
+  (let ((wordlist '("cessess"))
        (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)))
+           (if (and (string-match "[a-z]+" currword)
+                    (= (match-beginning 0) 0)
+                    (= (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)
                        (not (string-equal "-" (car (setq co (cdr co)))))))))
-      wordlist))
-  "LilyPond ReservedWords")
+      (reverse wordlist)))
+  "LilyPond notenames")
 
 (defun LilyPond-check-files (derived originals extensions)
   "Check that DERIVED is newer than any of the ORIGINALS.
index 993f8a32f872ef3a5fea386cbeb048fc1325a86b..717730cbc6fb496bc08ade7e1bbb48321d92f125 100644 (file)
@@ -2,7 +2,7 @@
 " Language:    LilyPond
 " Maintainer:  Heikki Junes <hjunes@cc.hut.fi>
 " Created:      Oct 17, 2002
-" Last Change: Sep 20, 2003
+" Last Change: Sep 23, 2003
 " Version:     6.1-1
 " Latest:
 " http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lilypond.vim
@@ -15,15 +15,26 @@ elseif exists("b:current_syntax")
   finish
 endif
 
+" Read the LilyPond syntax match groups: 
+"   lilyKeyword, lilyReservedWord, lilyNote
+if version < 600
+  so <sfile>:p:h/lilypond.words.vim
+else
+  runtime! syntax/lilypond.words.vim
+  if exists("b:current_syntax")
+    unlet b:current_syntax
+  endif
+endif
+
 " Match also parethesis of angle type
 set mps+=<:>
 
 " Case matters
 syn case match
 
-syn cluster lilyMatchGroup     contains=lilyMatcher,lilyString,lilyComment,lilyStatement,lilyNote,lilyNumber,lilyEquation,lilySlur,lilySpecial
+syn cluster lilyMatchGroup     contains=lilyMatcher,lilyString,lilyComment,lilyStatement,lilyNumber,lilyEquation,lilySlur,lilySpecial,lilyNote,lilyKeyword,lilyReservedWord
 
-syn region lilyMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{<>}]"    end="}" contains=@lilyMatchGroup fold
+syn region lilyMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[<>]"      end="}" contains=@lilyMatchGroup fold
 syn region lilyMatcher matchgroup=Delimiter start="\["         end="]" contains=@lilyMatchGroup fold
 syn region lilyMatcher matchgroup=Delimiter start="<" skip="\\\\\|\\[{<>}]" end=">"    contains=@lilyMatchGroup fold
 
@@ -31,9 +42,6 @@ syn region lilyString start=/"/ end=/"/ skip=/\\"/
 syn region lilyComment start="%{" skip="%$" end="%}"
 syn region lilyComment start="%\([^{]\|$\)" end="$"
 
-syn match lilyStatement        "[-_^]\?\\\(\a[-]\?\)\+"
-syn match lilyNote     "\<\(\(\(bb\|as[ae]s\|[ae]s\|eses\|[a-h]\(\|is\|isis\|es\|eses\)\)\([,']\)\{,4}\([?!]\)\?\|[srR]\)\(\(128\|6\?4\|3\?2\|16\?\|8\|\\breve\|\\longa\|\\maxima\)[.]*\)\?\)\(\A\|\n\)"me=e-1
-syn match lilyNote     "\<\(\(\(bb\|as[ae]s\|[ae]s\|eses\|[a-h]\(\|is\|isis\|es\|eses\)\)\([,']\)\{,4}\([?!]\)\?\|[srR]\)\(\(128\|6\?4\|3\?2\|16\?\|8\|\\breve\|\\longa\|\\maxima\)[.]*\)\?\)$"
 syn match lilyNumber   "[-_^.]\?\d\+[.]\?"
 syn match lilyEquation "\(#['`]\)\?\(\a*[-]\)*\a*\s*=\s*\(#[#'`]\?\)\?\a*"
 syn match lilySlur     "[(~)]"
@@ -59,8 +67,10 @@ if version >= 508 || !exists("did_lily_syn_inits")
   HiLink lilyComment   Comment
  
   HiLink lilyNote      Identifier
+  HiLink lilyKeyword   Keyword
+  HiLink lilyReservedWord      Type
+
   HiLink lilyNumber    Constant
-  HiLink lilyStatement Statement
   HiLink lilySpecial   Special
   HiLink lilySlur      ModeMsg