]> git.donarmstrong.com Git - lilypond.git/commitdiff
File lilypond.words gives keywords, identifiers and reserved words.
authorHeikki Junes <heikki.junes@hut.fi>
Sat, 23 Nov 2002 15:09:24 +0000 (15:09 +0000)
committerHeikki Junes <heikki.junes@hut.fi>
Sat, 23 Nov 2002 15:09:24 +0000 (15:09 +0000)
ChangeLog
Documentation/topdocs/INSTALL.texi
lilypond-font-lock.el
lilypond-init.el
lilypond-mode.el

index 60163968e427ae962aecb389d1f8f6deee0049b4..d3b0bc2272404227d40cd8b675a1a26557d5d35f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,12 @@
        inserts try-completion and shows all-completions.
 
        * lilypond.words: '\' -> '\\'
+
+       * lilypond-mode.el: load libraries in the end, lilypond.words defines
+       LilyPond-keywords, LilyPond-identifiers and LilyPond-reserved-words.
+       
+       * lilypond-font-lock.el: Use LilyPond-keywords, LilyPond-identifiers
+       and LilyPond-reserved-words.
        
 2002-11-22  Heikki Junes <hjunes@cc.hut.fi>
 
index fd131e91a6fd0a3dfc482a6c3d161e4839acb684..eefc5e563791683d75f9a08b207fa8068ee0d2bd 100644 (file)
@@ -322,7 +322,8 @@ and for the profiling version, I specify a different configuration.
 
 An Emacs mode for entering music and running LilyPond is contained in
 the source archive as @file{lilypond-mode.el},
-@file{lilypond-indent.el} and @file{lilypond-font-lock.el}. 
+@file{lilypond-indent.el}, @file{lilypond-font-lock.el} and 
+@file{lilypond.words}.
 You should install these files to a directory included in your 
 @var{load-path}. File @file{lilypond-init.el} should be placed to 
 @var{load-path}@file{/site-start.d/} or appended to your @file{~/.emacs}
index 8d34f5ded395b2f5fa3534fdee53e2a46fc7b7ee..c3bcfaf22ab86cc5738b3b66bd3ccae36cf01f2a 100644 (file)
@@ -2,15 +2,16 @@
 
 ;; Copyright (C) 1992,1993,1994  Tim Peters
 
-;; Author: 2001: Heikki Junes
+;; Author: 2001-2002: 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
 ;; Author: 1997: Han-Wen Nienhuys
 ;; Author: 1995-1996 Barry A. Warsaw
 ;;         1992-1994 Tim Peters
 ;; Created:       Feb 1992
-;; Version:       1.5.52
-;; Last Modified: 13APR2002
+;; Version:       1.7.8
+;; Last Modified: 23NOV2002
 ;; Keywords: lilypond languages music notation
 
 ;; This software is provided as-is, without express or implied
 ;;   - handle lexer modes (\header, \melodic, \lyric) etc.
 
 (defconst LilyPond-font-lock-keywords
-  (let* ((keywords '( ; need special order due to over[lapping] of words
-
-;; all letters are lowercase
-"accent" "accepts" "accompany" "\\(add\\)?lyrics" 
-"\\(aeol\\|dor\\|ion\\|locr\\|\\(mixo\\)?lyd\\|phryg\\)ian" 
-"alias" "\\(altern\\|rel\\)ative" "apply" "arpeggio" "autochange" "bar" "break"
-"breathe" "beamintervals" "broken" "blend" "\\(bc\\|end\\)incipit" 
-"ch\\(ar\\)?" "cg" "chord\\(s\\|stest\\|\\(chord\\)?modifiers\\)?"
-"clef[ \t]*\"?\\(F\\|G\\|alto\\|baritone\\|bass\\|\\(mezzo\\)?soprano\\|treble\\|violin\\|tenor\\)?\"?"
-"clipping" "[cm]m" "coda" "complex" 
-"\\(command\\)?spanrequest" "consists\\(end\\)?"
-"context" "contrabasso" "\\(de\\)?cr" "default" "denies" "different" "dirs"
-"down\\(bow\\|prall\\)?" "duration" "\\(text\\)?script"
-"eccentric" "eg" "embeddedps" "elementdescriptions" "\\(end\\)?cresc"
-"ex\\(treme\\)?" "fermata" "f+" "figures" "font" "flageolet" "fp" "fragment" 
-"s?fz" "gliss\\(ando\\)?" "gg" "gmsus" "grace" "gr\\(and\\)?staff"
-"header" "\\(h\\|v\\)size" "in\\(clude\\|versions\\|visible\\)?" 
-"key\\(s\\(ignature\\)?\\)?" "lag" "\\(l\\|r\\)heel" "line\\(break\\|prall\\)"
-"longa" "lower" "\\(l\\|r\\)toe"
-"mark" "marcato" "maxima" "mel\\(isma\\|ody\\)?" "midi" "m\\(aj\\|in\\)or"
-"\\(up\\|down\\)?mordent" "monstrous" "multipart" "music"
-"\\(musical\\)?pitch" "m\\(p\\|f\\|m\\)?" "name" "newpage" "noise\\(beat\\)?"
-"normal\\(key\\|size\\)" "\\(note\\|pitch\\)?names" "notes" "nt?"
-"one\\(staff\\)?" "open" "\\(output\\)?property" "over\\(ride\\)?"
-"part\\(combine\\|ial\\)" "penalty" "p+" "pt" 
-"prall\\(down\\|mordent\\|prall\\|up\\)?" "quickmeasure" "rc\\(ed\\)?" "remove"
-"repeat[ \t]*\\(\\(un\\)?fold\\|percent\\|\\|tremolo\\|volta\\)?" "rest"
-"revert" "\\(reverse\\)?turn" "rfz?" "rhythm"
-"right" "scales?" "scheme" "\\(sc\\)?paper" "\\(sc\\)?score" "sd"
-"segno" "sequential" "set\\(tings\\)?" "shortlong"
-"simultaneous" "singlepart" "skip" "small" "\\(smart\\)?transpose"
-"s[pf]+" "staccat\\(issim\\)?o" "staff\\(height\\|space\\)" "start" 
-"stop\\(ped\\)?"
-"st\\(paper\\|score\\)" "stuff" "su" "tab" "tempo" "tenuto" 
-"thenotes" "thrd" "threevoice" "thumb" "tilt\\(down\\|up\\)" 
-"timb" "times?" "tiny" "toeters" "touch" "translator" 
-"trill" "type" "t\\(wo\\(voice\\(steminvert\\)?\\)?\\)?" 
-"un\\(der\\|set\\)" "up\\(bow\\|per\\|prall\\)?" "version" 
-"visible" "voicedefault" "x"
-
-                     ))
-
-  (identifiers '( 
-
-;; in principle, have one or more uppercase letters
-"\\(\\(BarNumbering\\|\\(Inner\\)?Choir\\|Grand\\|HaraKiri\\|OrchestralPart\\|Piano\\|Rhythmic\\)?Staff\\|\\(Cue\\|Lyrics\\)?Voice\\|\\(Orchestral\\)?Score\\|ChordNames\\|FiguredBass\\|Grace\\|Lyrics\\|NoteNames\\|\\(Inner\\)?Staff\\(Group\\|Container\\)?\\|Thread\\)Context" ; *Context
-"\\(script\\|dots\\|dynamic\\|slur\\|stem\\|sustain\\|sostenuto\\|unaCorda\\|treCorde\\|tie\\|tuplet\\)\\(Both\\|Down\\|Up\\)" ; *(Both/Down/Up)
-"\\(slur\\|tie\\)\\(Dotted\\|Solid\\)" ; *(Dotted/Solid)
-"\\(autoBeam\\|cadenza\\|impro\\|turn\\)\\(Off\\|On\\)" ; *(On/Off)
-"\\(empty\\|fat\\)Text" ; *Text
-"shift\\(On+\\|Off\\|I\\|II\\|III\\|IV\\|V\\)" ; shift*
-"EasyNotation"
-"\\(hide\\|show\\)StaffSwitch"
-"\\(lower\\|upper\\)Voice"
-"voice\\(One\\|Two\\|Three\\|Four\\|B\\|C\\|D\\|E\\)" ; voice*
-"paper\\(Eleven\\|Sixteen\\|Thirteen\\|TwentySix\\)" ; paper*
-"\\(lower\\|upper\\)\\(Octave\\|One\\)" ; (lower/upper)*
-"hairyChord" "\\(Piano\\|Rhythmic\\)\\(Staff\\)?"
-"\\(clarinetti\\|fagotti\\|flauti\\|melodic\\|oboi\\|\\(quite\\|rather\\|somewhat\\)LongLyrics\\|violinoII?\\)?\\(Staff\\)?" ; *Staff
-"\\(archi\\|bassi\\|legni\\|ottoni\\|timpani\\|viole\\|violini\\)\\(Group\\)" ; *Group
-"melisma\\(End\\)?" "staff\\(One\\|Two\\)?" "rests\\(II\\)?" "specialKey"
-"noBreak" "paperTwentysix" "endHorizScript" "FontBody" "text(I)+"
-"\\(modern\\|forget\\)Accidental" ; *Accidentals
-"noResetKey" "modern\\(Voice\\)?Cautionaries" "unaCorda" "treCorde"
-
-                      ))
-
-  (reservedwords '(
-
-;; Other words which look nicer when colored
-"Accidental" "autoBeamSettings" "BarLine" "Beam"
-"ChordName\\([s]?\\|s.[a-zA-Z]*\\)" "Dots" "DynamicText"
-"FiguredBass" "Hairpin" "\\(\\(Inner\\)?Choir\\|Grand\\|Piano\\|Tab\\)Staff"
-"Slur" "Stem" "SpacingSpanner" "System\\(StartDelimiter\\)?"
-"\\(Grace\\|Lyrics\\|Note\\(Head\\|Names\\)\\|Score\\|\\(Rhythmic\\)?Staff\\(Symbol\\)?\\|Thread\\|Voice\\)\\(.[a-zA-Z]*\\)?" ; combine below, if possible
-"\\(Grace\\|Lyrics\\|Note\\(Head\\|Names\\)\\|Score\\|\\(Rhythmic\\)?Staff\\(Symbol\\)?\\|Thread\\|Voice\\)[ \t]*\\(.[ \t]*[a-zA-Z]*\\)?" 
-"TextScript" "TimeSignature" "VerticalAlignment"
-
-                     ))
-
-       (kwregex (mapconcat (lambda (x) (concat "\\\\" x))  keywords "\\|"))
-       (iregex (mapconcat (lambda (x) (concat "\\\\" x))  identifiers "\\|"))
-       (rwregex (mapconcat (lambda (x) (concat "" x))  reservedwords "\\|"))
+  (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 "\\|"))
 )
 
     (list 
index d6488828afcb1a5ad0c2b50e22025a82473faf76..919b3b5635b88fa54fdaaaf6e1d69adb70672c93 100644 (file)
@@ -3,10 +3,11 @@
 ;; Instructions, extracted from Documentation/topdocs/INSTALL.texi: 
 
 ;; Emacs mode for entering music and running LilyPond is contained in
-;; the source archive as `lilypond-mode.el', `lilypond-indent.el' and 
-;; `lilypond-font-lock.el'. You should install these files to a directory 
-;; included in your `load-path'. File `lilypond-init.el' should be placed to 
-;; `load-path/site-start.d/' or appended to your `~/.emacs' or `~/.emacs.el'. 
+;; the source archive as `lilypond-mode.el', `lilypond-indent.el',
+;; `lilypond-font-lock.el' and `lilypond.words'. You should install 
+;; these files to a directory included in your `load-path'. 
+;; File `lilypond-init.el' should be placed to `load-path/site-start.d/' 
+;; or appended to your `~/.emacs' or `~/.emacs.el'. 
 
 ;; As a user, you may want add your source path or, e.g., `~/site-lisp/' to
 ;; your `load-path'. Append the following line (modified) to your `~/.emacs':
index cdc36101bbded170816ab0e645bd65ef863918a2..9f8ef06e0b7c77e0503c7e512e611ca931d499ee 100644 (file)
@@ -18,9 +18,6 @@
 ;;; Look lilypond-init.el or Documentation/topdocs/INSTALL.texi
 ;;; for installing instructions.
 
-(load-library "lilypond-font-lock")
-(load-library "lilypond-indent")
-
 (require 'easymenu)
 (require 'compile)
 
@@ -60,6 +57,62 @@ Finds file lilypond-words from load-path."
          (progn (setq fn nil) (setq lp (cdr lp)))))
     fn))
 
+(defun LilyPond-add-dictionary-word (x)
+  "Contains all words: keywords, identifiers, reserved words."
+  (nconc '(("" . 1)) x))
+
+; creates dictionary if empty
+(if (eq (length (LilyPond-add-dictionary-word ())) 1)
+    (progn
+      (setq fn (LilyPond-words-filename))
+      (setq b (find-file-noselect fn t t))
+      (setq m (set-marker (make-marker) 1 (get-buffer b)))
+      (setq i 1)
+      (while (> (buffer-size b) (marker-position m))
+       (setq i (+ i 1))
+       (setq copy (copy-alist (list (eval (symbol-name (read m))))))
+       (setcdr copy i)
+       (LilyPond-add-dictionary-word (list copy)))
+      (kill-buffer b)))
+
+(defconst LilyPond-keywords 
+  (let ((wordlist ())
+       (co (all-completions "" (LilyPond-add-dictionary-word ()))))
+    (progn
+      (while (> (length co) 0)
+       (if (> (length (car co)) 1)
+           (if (and (string-equal "\\" (substring (car co) 0 1))
+                    (string-equal (downcase (car co)) (car co)))
+               (add-to-list 'wordlist (car co))))
+       (setq co (cdr co)))
+      wordlist))
+  "LilyPond \\keywords")
+
+(defconst LilyPond-identifiers 
+  (let ((wordlist ())
+       (co (all-completions "" (LilyPond-add-dictionary-word ()))))
+    (progn
+      (while (> (length co) 0)
+       (if (> (length (car co)) 1)
+           (if (and (string-equal "\\" (substring (car co) 0 1))
+                    (not (string-equal (downcase (car co)) (car co))))
+               (add-to-list 'wordlist (car co))))
+       (setq co (cdr co)))
+      wordlist))
+  "LilyPond \\Identifiers")
+
+(defconst LilyPond-reserved-words 
+  (let ((wordlist ())
+       (co (all-completions "" (LilyPond-add-dictionary-word ()))))
+    (progn
+      (while (> (length co) 0)
+       (if (> (length (car co)) 0)
+           (if (not (string-equal "\\" (substring (car co) 0 1)))
+               (add-to-list 'wordlist (car co))))
+       (setq co (cdr co)))
+      wordlist))
+  "LilyPond ReservedWords")
+
 (defun LilyPond-check-files (derived originals extensions)
   "Check that DERIVED is newer than any of the ORIGINALS.
 Try each original with each member of EXTENSIONS, in all directories
@@ -639,22 +692,6 @@ command."
 (defun LilyPond-autocompletion ()
   "Show completions in mini-buffer for the given word."
   (interactive)
-  (defun add-dictionary-word (x)
-    (nconc '(("" . 1)) x))
-  ; creates dictionary if empty
-  (if (eq (length (add-dictionary-word ())) 1)
-    (progn
-      (setq fn (LilyPond-words-filename))
-      (setq b (find-file-noselect fn t t))
-      (setq m (set-marker (make-marker) 1 (get-buffer b)))
-      (setq i 1)
-      (while (> (buffer-size b) (marker-position m))
-       (setq i (+ i 1))
-       (setq copy (copy-alist (list (eval (symbol-name (read m))))))
-       (setcdr copy i)
-       (add-dictionary-word (list copy))
-       )
-      (kill-buffer b)))
 
   ; search the begin of word
   (setq beg "")
@@ -681,7 +718,7 @@ command."
   ; insert try-completion and show all-completions
   (if (> i 0)
       (progn
-       (setq tryc (try-completion beg (add-dictionary-word ())))
+       (setq tryc (try-completion beg (LilyPond-add-dictionary-word ())))
        (if (char-or-string-p tryc)
            (if (string-equal (concat beg end) tryc)
                (goto-char (+ (point) (length end)))
@@ -693,7 +730,7 @@ command."
            (font-lock-fontify-buffer)))
        
        (setq others "")
-       (setq co (all-completions beg (add-dictionary-word ())))
+       (setq co (all-completions beg (LilyPond-add-dictionary-word ())))
        (while (> (length co) 0)
          (setq others (concat others "\"" (car co) "\" "))
          (setq co (cdr co)))
@@ -918,6 +955,9 @@ LilyPond-xdvi-command\t\tcommand to display dvi files -- bit superfluous"
   (interactive)
   (message "Using `LilyPond-mode' version %s" LilyPond-version))
 
+(load-library "lilypond-font-lock")
+(load-library "lilypond-indent")
+
 (provide 'lilypond-mode)
 ;;; lilypond-mode.el ends here