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-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.
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
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
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
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
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
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
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
]:
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 [
'//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()
;; 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
(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]*\\)?\\)?\\)")
)
(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.
(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"
(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))
(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
(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.
" 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
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
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 "[(~)]"
HiLink lilyComment Comment
HiLink lilyNote Identifier
+ HiLink lilyKeyword Keyword
+ HiLink lilyReservedWord Type
+
HiLink lilyNumber Constant
- HiLink lilyStatement Statement
HiLink lilySpecial Special
HiLink lilySlur ModeMsg