From d33f798535b8f3b16d095380c38e956e41ff59e2 Mon Sep 17 00:00:00 2001 From: hjunes Date: Mon, 22 Sep 2003 22:50:45 +0000 Subject: [PATCH] * 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. --- ChangeLog | 13 +++++ Documentation/topdocs/INSTALL.texi | 6 +-- buildscripts/lilypond.words.py | 77 ++++++++++++++++++++---------- lilypond-font-lock.el | 8 ++-- lilypond-mode.el | 36 +++++++------- lilypond.vim | 24 +++++++--- 6 files changed, 110 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5bda96224b..0dd266e20c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2003-09-23 Heikki Junes + + * 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 * cygwin/mknetrel: Remove PYTHONPATH and manpage workarounds. diff --git a/Documentation/topdocs/INSTALL.texi b/Documentation/topdocs/INSTALL.texi index dfde798a1a..9db4fcd377 100644 --- a/Documentation/topdocs/INSTALL.texi +++ b/Documentation/topdocs/INSTALL.texi @@ -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 diff --git a/buildscripts/lilypond.words.py b/buildscripts/lilypond.words.py index 445fff7544..63fd759bff 100755 --- a/buildscripts/lilypond.words.py +++ b/buildscripts/lilypond.words.py @@ -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() diff --git a/lilypond-font-lock.el b/lilypond-font-lock.el index 7af3b347bc..c2e258a709 100644 --- a/lilypond-font-lock.el +++ b/lilypond-font-lock.el @@ -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. diff --git a/lilypond-mode.el b/lilypond-mode.el index 60e4e6ebb1..10b3147ff8 100644 --- a/lilypond-mode.el +++ b/lilypond-mode.el @@ -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. diff --git a/lilypond.vim b/lilypond.vim index 993f8a32f8..717730cbc6 100644 --- a/lilypond.vim +++ b/lilypond.vim @@ -2,7 +2,7 @@ " Language: LilyPond " Maintainer: Heikki Junes " 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 :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 -- 2.39.2