]> git.donarmstrong.com Git - lilypond.git/blob - lilypond-mode.el
patch::: 1.5.26.jcn1
[lilypond.git] / lilypond-mode.el
1 ;;;
2 ;;; lilypond-mode.el --- Major mode for editing GNU LilyPond music scores
3 ;;;
4 ;;; source file of the GNU LilyPond music typesetter
5 ;;; 
6 ;;; (c) 1999--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;; 
8 ;;; Changed 2001 Heikki Junes <heikki.junes@hut.fi>
9 ;;;    * Add PS-compilation, PS-viewing and MIDI-play (29th Aug 2001)
10 ;;;    * Keyboard shortcuts (12th Sep 2001)
11 ;;;    * Inserting tags, inspired on sgml-mode (11th Oct 2001)
12
13 ;;; Inspired on auctex
14
15 ;;;
16 ;;; Add this to your ~/.emacs or ~/.emacs.el
17 ;;;     (load-library "lilypond-mode.el")
18 ;;;     (setq auto-mode-alist
19 ;;;      (append '(("\\.ly$" . LilyPond-mode) auto-mode-alist)))
20 ;;; 
21
22 (load-library "lilypond-font-lock")
23
24 (require 'easymenu)
25 (require 'compile)
26
27 (defconst LilyPond-version "1.3.143"
28   "`LilyPond-mode' version number.")
29
30 (defconst LilyPond-help-address "bug-gnu-music@gnu.org"
31   "Address accepting submission of bug reports.")
32
33 (defvar LilyPond-mode-hook nil
34   "*Hook called by `LilyPond-mode'.")
35
36 (defvar LilyPond-kick-xdvi nil
37   "If true, no simultaneous xdvi's are started, but reload signal is sent.")
38
39 (defvar LilyPond-command-history nil
40   "Command history list.")
41         
42 (defvar LilyPond-regexp-alist
43   '(("\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2))
44   "Regexp used to match LilyPond errors.  See `compilation-error-regexp-alist'.")
45
46 (defcustom LilyPond-include-path ".:/tmp"
47   "* LilyPond include path."
48   :type 'string
49   :group 'LilyPond)
50
51
52 (defun LilyPond-check-files (derived originals extensions)
53   "Check that DERIVED is newer than any of the ORIGINALS.
54 Try each original with each member of EXTENSIONS, in all directories
55 in LilyPond-include-path."
56   (let ((found nil)
57         (regexp (concat "\\`\\("
58                         (mapconcat (function (lambda (dir)
59                                       (regexp-quote (expand-file-name dir))))
60                                    LilyPond-include-path "\\|")
61                         "\\).*\\("
62                         (mapconcat 'regexp-quote originals "\\|")
63                         "\\)\\.\\("
64                         (mapconcat 'regexp-quote extensions "\\|")
65                         "\\)\\'"))
66         (buffers (buffer-list)))
67     (while buffers
68       (let* ((buffer (car buffers))
69              (name (buffer-file-name buffer)))
70         (setq buffers (cdr buffers))
71         (if (and name (string-match regexp name))
72             (progn
73               (and (buffer-modified-p buffer)
74                    (or (not LilyPond-save-query)
75                        (y-or-n-p (concat "Save file "
76                                          (buffer-file-name buffer)
77                                          "? ")))
78                    (save-excursion (set-buffer buffer) (save-buffer)))
79               (if (file-newer-than-file-p name derived)
80                   (setq found t))))))
81     found))
82
83 (defun LilyPond-running ()
84   (let ((process (get-process "lilypond")))
85   (and process
86        (eq (process-status process) 'run))))
87
88 (defun LilyPond-kill-job ()
89   "Kill the currently running LilyPond job."
90   (interactive)
91   ;; What bout TeX, Xdvi?
92   (quit-process (get-process "lilypond") t))
93
94 ;; URG, should only run LilyPond-compile for LilyPond
95 ;; not for tex,xdvi (ly2dvi?)
96 (defun LilyPond-compile-file (command name)
97   ;; We maybe should know what we run here (Lily, ly2dvi, tex)
98   ;; and adjust our error-matching regex ?
99   (compile-internal command "No more errors" name ))
100
101 ;; do we still need this, now that we're using compile-internal?
102 (defun LilyPond-save-buffer ()
103   (if (buffer-modified-p) (save-buffer)))
104
105 ;;; return (dir base ext)
106 (defun split-file-name (name)
107   (let* ((i (string-match "[^/]*$" name))
108          (dir (if (> i 0) (substring name 0 i) "./"))
109          (file (substring name i (length name)))
110          (i (string-match "[^.]*$" file)))
111     (if (and
112          (> i 0)
113          (< i (length file)))
114         (list dir (substring file 0 (- i 1)) (substring file i (length file)))
115       (list dir file ""))))
116
117
118 ;; Should check whether in command-alist?
119 (defcustom LilyPond-command-default "LilyPond"
120   "Default command. Must identify a member of LilyPond-command-alist."
121
122   :group 'LilyPond
123   :type 'string)
124 ;;;(make-variable-buffer-local 'LilyPond-command-last)
125
126 (defvar LilyPond-command-current 'LilyPond-command-master)
127 ;;;(make-variable-buffer-local 'LilyPond-command-master)
128
129
130 ;; If non-nil, LilyPond-command-query will return the value of this
131 ;; variable instead of quering the user. 
132 (defvar LilyPond-command-force nil)
133
134 (defcustom LilyPond-xdvi-command "xdvik"
135   "Command used to display DVI files."
136
137   :group 'LilyPond
138   :type 'string)
139
140 (defcustom LilyPond-gv-command "gv -watch"
141   "Command used to display PS files."
142
143   :group 'LilyPond
144   :type 'string)
145
146 (defcustom LilyPond-gv-command "gv -watch"
147   "Command used to display PS files."
148
149   :group 'LilyPond
150   :type 'string)
151
152 (defcustom LilyPond-midi-command "timidity"
153   "Command used to play MIDI files."
154
155   :group 'LilyPond
156   :type 'string)
157
158 ;; This is the major configuration variable.
159 (defcustom LilyPond-command-alist
160   `(
161     ("LilyPond" . ("lilypond %s" . "TeX"))
162     ("TeX" . ("tex '\\nonstopmode\\input %t'" . "View"))
163
164     ("2Dvi" . ("ly2dvi %s" . "View"))
165     ("2PS" . ("ly2dvi -P %s" . "View"))
166
167     ("Book" . ("lilypond-book %x" . "LaTeX"))
168     ("LaTeX" . ("latex '\\nonstopmode\\input %l'" . "View"))
169
170     ;; point-n-click (arg: exits upop USR1)
171     ("SmartView" . ("xdvi %d" . "LilyPond"))
172     
173     ;; refreshes when kicked USR1
174     ("View" . (,(concat LilyPond-xdvi-command " %d") . "LilyPond"))
175
176     ("ViewPS" . (,(concat LilyPond-gv-command " %p") . "LilyPond"))
177
178     ("Midi" . (,(concat LilyPond-midi-command " %m") . "LilyPond"))
179     )
180
181   "AList of commands to execute on the current document.
182
183 The key is the name of the command as it will be presented to the
184 user, the value is a cons of the command string handed to the shell
185 after being expanded, and the next command to be executed upon
186 success.  The expansion is done using the information found in
187 LilyPond-expand-list.
188 "
189   :group 'LilyPond
190   :type '(repeat (cons :tag "Command Item"
191                        (string :tag "Key")
192                        (cons :tag "How"
193                         (string :tag "Command")
194                         (string :tag "Next Key")))))
195
196 ;; drop this?
197 (defcustom LilyPond-file-extensions '(".ly" ".sly" ".fly")
198   "*File extensions used by manually generated TeX files."
199   :group 'LilyPond
200   :type '(repeat (string :format "%v")))
201
202
203 (defcustom LilyPond-expand-alist 
204   '(
205     ("%s" . ".ly")
206     ("%t" . ".tex")
207     ("%d" . ".dvi")
208     ("%p" . ".ps")
209     ("%l" . ".latex")
210     ("%x" . ".tely")
211     ("%m" . ".midi")
212     )
213     
214   "Alist of expansion strings for LilyPond command names."
215   :group 'LilyPond
216   :type '(repeat (cons :tag "Alist item"
217                   (string :tag "Symbol")
218                   (string :tag "Expansion")))) 
219
220
221 (defcustom LilyPond-command-Show "View"
222   "*The default command to show (view or print) a LilyPond file.
223 Must be the car of an entry in `LilyPond-command-alist'."
224   :group 'LilyPond
225   :type 'string)
226   (make-variable-buffer-local 'LilyPond-command-Show)
227
228 (defcustom LilyPond-command-Print "Print"
229   "The name of the Print entry in LilyPond-command-Print."
230   :group 'LilyPond
231   :type 'string)
232
233 (defun xLilyPond-compile-sentinel (process msg)
234   (if (and process
235            (= 0 (process-exit-status process)))
236       (setq LilyPond-command-default
237               (cddr (assoc LilyPond-command-default LilyPond-command-alist)))))
238
239 ;; FIXME: shouldn't do this for stray View/xdvi
240 (defun LilyPond-compile-sentinel (buffer msg)
241   (if (string-match "^finished" msg)
242       (setq LilyPond-command-default
243             (cddr (assoc LilyPond-command-default LilyPond-command-alist)))))
244
245 ;;(make-variable-buffer-local 'compilation-finish-function)
246 (setq compilation-finish-function 'LilyPond-compile-sentinel)
247
248 (defun LilyPond-command-query (name)
249   "Query the user for what LilyPond command to use."
250   (let* ((default (cond ((if (string-equal name "emacs-lily")
251                              (LilyPond-check-files (concat name ".tex")
252                                                    (list name)
253                                                    LilyPond-file-extensions)
254                            ;; FIXME
255                            (LilyPond-save-buffer)
256                            ;;"LilyPond"
257                            LilyPond-command-default))
258                         (t LilyPond-command-default)))
259          
260          (answer (or LilyPond-command-force
261                      (completing-read
262                       (concat "Command: (default " default ") ")
263                       LilyPond-command-alist nil t nil 'LilyPond-command-history))))
264
265     ;; If the answer is "LilyPond" it will not be expanded to "LilyPond"
266     (let ((answer (car-safe (assoc answer LilyPond-command-alist))))
267       (if (and answer
268                (not (string-equal answer "")))
269           answer
270         default))))
271
272
273 ;; FIXME: find ``\score'' in buffers / make settable?
274 (defun LilyPond-master-file ()
275   ;; duh
276   (buffer-file-name))
277
278 (defun LilyPond-command-master ()
279   "Run command on the current document."
280   (interactive)
281   (LilyPond-command (LilyPond-command-query (LilyPond-master-file))
282                     'LilyPond-master-file))
283
284 (defun LilyPond-command-formatdvi ()
285   "Format the dvi output of the current document."
286   (interactive)
287   (LilyPond-command (LilyPond-command-menu "2Dvi") 'LilyPond-master-file)
288 )
289
290 (defun LilyPond-command-formatps ()
291   "Format the ps output of the current document."
292   (interactive)
293   (LilyPond-command (LilyPond-command-menu "2PS") 'LilyPond-master-file)
294 )
295
296 (defun LilyPond-command-smartview ()
297   "View the dvi output of current document."
298   (interactive)
299   (LilyPond-command (LilyPond-command-menu "SmartView") 'LilyPond-master-file)
300 )
301
302 (defun LilyPond-command-view ()
303   "View the dvi output of current document."
304   (interactive)
305   (LilyPond-command (LilyPond-command-menu "View") 'LilyPond-master-file)
306 )
307
308 (defun LilyPond-command-viewps ()
309   "View the ps output of current document."
310   (interactive)
311   (LilyPond-command (LilyPond-command-menu "ViewPS") 'LilyPond-master-file)
312 )
313
314 (defun LilyPond-command-midi ()
315   "Play midi corresponding to the current document."
316   (interactive)
317   (LilyPond-command (LilyPond-command-menu "Midi") 'LilyPond-master-file)
318 )
319
320 (defun count-rexp (start end rexp)
321   "Print number of found regular expressions in the region."
322   (interactive "r")
323   (save-excursion
324     (save-restriction
325       (narrow-to-region start end)
326       (goto-char (point-min))
327       (count-matches rexp))))
328
329 (defun count-midi-words ()
330   "Print number of scores before the curser."
331   (interactive)
332   (count-rexp (point-min) (point-max) "\\\\midi"))
333  
334 (defun count-midi-words-backwards ()
335   "Print number of scores before the curser."
336   (interactive)
337   (count-rexp (point-min) (point) "\\\\midi"))
338  
339 (defun LilyPond-command-next-midi ()
340   "Play next midi score of the current document."
341   (interactive)
342   (LilyPond-compile-file 
343    (let ((allscores (count-midi-words))
344          (scores (count-midi-words-backwards))
345          (fname (LilyPond-master-file)))
346      (let ((count (string-to-number (substring scores 0 (+ (length scores) -12)))))
347        (concat  LilyPond-midi-command " "
348                 (substring fname 0 (+ (length fname) -3)) ; suppose ".ly"
349                 (if (not (string= "1 occurrences" allscores)) ; only one score
350                     (if (not (eq count 0))                    ; first score
351                         (if (string= scores allscores)        ; last score
352                             (concat "-" (number-to-string (+ count -1)))
353                           (concat "-" (number-to-string count)))))
354                 ".midi")))
355    "Midi"))
356
357 ;; FIXME, this is broken
358 (defun LilyPond-region-file (begin end)
359   (let (
360         ;; (dir "/tmp/")
361         ;; urg
362         (dir "./")
363         (base "emacs-lily")
364         ;; Hmm
365         (ext (if (string-match "^[\\]score" (buffer-substring begin end))
366                  ".ly"
367                (if (< 50 (abs (- begin end)))
368                    ".fly"
369                  ".sly"))))
370     (concat dir base ext)))
371
372 (defun LilyPond-command-region (begin end)
373   "Run LilyPond on the current region."
374   (interactive "r")
375   (write-region begin end (LilyPond-region-file begin end) nil 'nomsg)
376   (LilyPond-command (LilyPond-command-query
377                      (LilyPond-region-file begin end))
378                     '(lambda () (LilyPond-region-file begin end))))
379
380 (defun LilyPond-command-buffer ()
381   "Run LilyPond on buffer."
382   (interactive)
383   (LilyPond-command-region (point-min) (point-max)))
384
385 (defun LilyPond-command-expand (string file)
386   (let ((case-fold-search nil))
387     (if (string-match "%" string)
388         (let* ((b (match-beginning 0))
389                (e (+ b 2))
390                (l (split-file-name file))
391                (dir (car l))
392                (base (cadr l)))
393           (LilyPond-command-expand
394            (concat (substring string 0 b)
395                    dir
396                    base
397                    (let ((entry (assoc (substring string b e)
398                                        LilyPond-expand-alist)))
399                      (if entry (cdr entry) ""))
400                    (substring string e))
401            file))
402       string)))
403
404 (defun LilyPond-shell-process (name buffer command)
405   (let ((old (current-buffer)))
406     (switch-to-buffer-other-window buffer)
407     ;; If we empty the buffer don't see messages scroll by.
408     ;; (erase-buffer)
409     
410     (start-process-shell-command name buffer command)
411     (switch-to-buffer-other-window old)))
412   
413
414 (defun LilyPond-command (name file)
415   "Run command NAME on the file you get by calling FILE.
416
417 FILE is a function return a file name.  It has one optional argument,
418 the extension to use on the file.
419
420 Use the information in LilyPond-command-alist to determine how to run the
421 command."
422   
423   (let ((entry (assoc name LilyPond-command-alist)))
424     (if entry
425         (let ((command (LilyPond-command-expand (cadr entry)
426                                                 (apply file nil))))
427           (if (string-equal name "View")
428               (let ((buffer-xdvi (get-buffer-create "*view*")))
429                 (if LilyPond-kick-xdvi
430                   (let ((process-xdvi (get-buffer-process buffer-xdvi)))
431                     (if process-xdvi
432                         (signal-process (process-id process-xdvi) 'SIGUSR1)
433                       (LilyPond-shell-process name buffer-xdvi command)))
434                   (LilyPond-shell-process name buffer-xdvi command)))
435             (progn
436               (setq LilyPond-command-default name)
437               (LilyPond-compile-file command name)))))))
438           
439 ;; XEmacs stuff
440 ;; Sadly we need this for a macro in Emacs 19.
441 (eval-when-compile
442   ;; Imenu isn't used in XEmacs, so just ignore load errors.
443   (condition-case ()
444       (require 'imenu)
445     (error nil)))
446
447
448 ;;; Keymap
449
450 (defvar LilyPond-mode-map ()
451   "Keymap used in `LilyPond-mode' buffers.")
452
453 ;; Note:  if you make changes to the map, you must do
454 ;;    M-x set-variable LilyPond-mode-map nil
455 ;;    M-x eval-buffer
456 ;;    M-x LilyPond-mode
457 ;; to let the changest take effect
458
459 (if LilyPond-mode-map
460     ()
461   (setq LilyPond-mode-map (make-sparse-keymap))
462   (define-key LilyPond-mode-map "\C-c\C-r" 'LilyPond-command-region)
463   (define-key LilyPond-mode-map "\C-c\C-b" 'LilyPond-command-buffer)
464   (define-key LilyPond-mode-map "\C-c\C-k" 'LilyPond-kill-job)
465   (define-key LilyPond-mode-map "\C-c\C-c" 'LilyPond-command-master)
466   (define-key LilyPond-mode-map "\C-c\C-d" 'LilyPond-command-formatdvi)
467   (define-key LilyPond-mode-map "\C-c\C-f" 'LilyPond-command-formatps)
468   (define-key LilyPond-mode-map "\C-c\C-s" 'LilyPond-command-smartview)
469   (define-key LilyPond-mode-map "\C-c\C-v" 'LilyPond-command-view)
470   (define-key LilyPond-mode-map "\C-c\C-p" 'LilyPond-command-viewps)
471   (define-key LilyPond-mode-map "\C-c\C-m" 'LilyPond-command-next-midi)
472   (define-key LilyPond-mode-map "\C-cn" 'LilyPond-insert-tag-notes)
473   (define-key LilyPond-mode-map "\C-cs" 'LilyPond-insert-tag-score)
474   )
475
476 ;;; Menu Support
477
478 (define-skeleton LilyPond-insert-tag-notes
479   "LilyPond notes tag."
480   nil
481 ;  (if (bolp) nil ?\n)
482   "\\notes"
483   (if (y-or-n-p "Set \"\\relative\" attribute? ")
484       (concat " \\relative " (skeleton-read "Relative: " "" str)))
485   " { " _ " }")
486
487 (define-skeleton LilyPond-insert-tag-score
488   "LilyPond score tag."
489   nil
490   (if (bolp) nil ?\n)
491   "\\score {\n"
492   "   " _ "\n"
493   "   \\paper {  }\n"
494   (if (y-or-n-p "Insert \"\\header\" field? ")
495       (concat "   \\header {\n      " 
496               (skeleton-read "Piece: " "piece = " str) "\n"
497               (if (y-or-n-p "Insert \"opus\" field? ")
498                   (concat "      " (skeleton-read "Opus: " "opus = " str) "\n"))
499               "   }\n"))
500   (if (y-or-n-p "Insert \"\\midi\" field? ")
501       (concat "   \\midi { " 
502               (skeleton-read "Midi: " "\\tempo 4 = " str)  
503               " }\n"))
504   "}\n")
505
506 (defun LilyPond-command-menu-entry (entry)
507   ;; Return LilyPond-command-alist ENTRY as a menu item.
508   (let ((name (car entry)))
509     (cond ((and (string-equal name LilyPond-command-Print)
510                 LilyPond-printer-list)
511            (let ((command LilyPond-print-command)
512                  (lookup 1))
513              (append (list LilyPond-command-Print)
514                      (mapcar 'LilyPond-command-menu-printer-entry
515                              LilyPond-printer-list))))
516           (t
517            (vector name (list 'LilyPond-command-menu name) t)))))
518
519
520 (easy-menu-define LilyPond-mode-menu
521     LilyPond-mode-map
522     "Menu used in LilyPond mode."
523   (append '("Command")
524           '(("Command on"
525              [ "Master File" LilyPond-command-select-master
526                :keys "C-c C-c" :style radio
527                :selected (eq LilyPond-command-current 'LilyPond-command-master) ]
528              [ "Buffer" LilyPond-command-select-buffer
529                :keys "C-c C-b" :style radio
530                :selected (eq LilyPond-command-current 'LilyPond-command-buffer) ]
531              [ "Region" LilyPond-command-select-region
532                :keys "C-c C-r" :style radio
533                :selected (eq LilyPond-command-current 'LilyPond-command-region) ]))
534           '(("Insert"
535              [ "\\notes..."  LilyPond-insert-tag-notes
536                :keys "C-c n" ]
537              [ "\\score..."  LilyPond-insert-tag-score
538                :keys "C-c s" ]
539              ))
540 ;         (let ((file 'LilyPond-command-on-current))
541 ;           (mapcar 'LilyPond-command-menu-entry LilyPond-command-alist))
542 ;;; Some kind of mapping which includes :keys might be more elegant
543           '([ "LilyPond" (LilyPond-command (LilyPond-command-menu "ViewPS") 'LilyPond-master-file) ])
544           '([ "TeX" (LilyPond-command (LilyPond-command-menu "TeX") 'LilyPond-master-file) ])
545           '([ "2Dvi" (LilyPond-command (LilyPond-command-menu "2Dvi") 'LilyPond-master-file) :keys "C-c C-d"])
546           '([ "2PS" (LilyPond-command (LilyPond-command-menu "2PS") 'LilyPond-master-file) :keys "C-c C-f"])
547           '([ "Book" (LilyPond-command (LilyPond-command-menu "Book") 'LilyPond-master-file) ])
548           '([ "LaTeX" (LilyPond-command (LilyPond-command-menu "LaTeX") 'LilyPond-master-file) ])
549           '([ "SmartView" (LilyPond-command (LilyPond-command-menu "SmartView") 'LilyPond-master-file) :keys "C-c C-s"])
550           '([ "View" (LilyPond-command (LilyPond-command-menu "View") 'LilyPond-master-file) :keys "C-c C-v"])
551           '([ "ViewPS" (LilyPond-command (LilyPond-command-menu "ViewPS") 'LilyPond-master-file) :keys "C-c C-p"])
552           '([ "Midi" (LilyPond-command-next-midi) :keys "C-c C-m"])
553           ))
554
555 (defconst LilyPond-imenu-generic-re "^\\([a-zA-Z_][a-zA-Z0-9_]*\\) *="
556   "Regexp matching Identifier definitions.")
557
558 (defvar LilyPond-imenu-generic-expression
559   (list (list nil LilyPond-imenu-generic-re 1))
560   "Expression for imenu")
561
562 (defun LilyPond-command-select-master ()
563   (interactive)
564   (message "Next command will be on the master file")
565   (setq LilyPond-command-current 'LilyPond-command-master))
566
567 (defun LilyPond-command-select-buffer ()
568   (interactive)
569   (message "Next command will be on the buffer")
570   (setq LilyPond-command-current 'LilyPond-command-buffer))
571
572 (defun LilyPond-command-select-region ()
573   (interactive)
574   (message "Next command will be on the region")
575   (setq LilyPond-command-current 'LilyPond-command-region))
576
577 (defun LilyPond-command-menu (name)
578   ;; Execute LilyPond-command-alist NAME from a menu.
579   (let ((LilyPond-command-force name))
580     (funcall LilyPond-command-current)))
581
582 (defun LilyPond-mode ()
583   "Major mode for editing LilyPond music files.
584
585 This mode knows about LilyPond keywords and line comments, not about
586 indentation or block comments.  It features easy compilation, error
587 finding and viewing of a LilyPond source buffer or region.
588
589 COMMANDS
590 \\{LilyPond-mode-map}
591 VARIABLES
592
593 LilyPond-command-alist\t\talist from name to command
594 LilyPond-xdvi-command\t\tcommand to display dvi files -- bit superfluous"
595   (interactive)
596   ;; set up local variables
597   (kill-all-local-variables)
598
599   (make-local-variable 'font-lock-defaults)
600   (setq font-lock-defaults '(LilyPond-font-lock-keywords))
601
602   (make-local-variable 'paragraph-separate)
603   (setq paragraph-separate "^[ \t]*$")
604
605   (make-local-variable 'paragraph-start)
606   (setq paragraph-start "^[ \t]*$")
607
608   (make-local-variable 'comment-start)
609   (setq comment-start "%")
610
611   (make-local-variable 'comment-start-skip)
612   (setq comment-start-skip "%{? *")
613
614   (make-local-variable 'comment-end)
615   (setq comment-end "")
616
617   (make-local-variable 'block-comment-start)
618   (setq block-comment-start "%{")
619
620   (make-local-variable 'block-comment-end)  
621   (setq block-comment-end   "%}")
622
623   (make-local-variable 'indent-line-function)
624   (setq indent-line-function 'indent-relative-maybe)
625  
626     (set-syntax-table LilyPond-mode-syntax-table)
627   (setq major-mode 'LilyPond-mode)
628   (setq mode-name "LilyPond")
629   (setq local-abbrev-table LilyPond-mode-abbrev-table)
630   (use-local-map LilyPond-mode-map)
631
632   (make-local-variable 'imenu-generic-expression)
633   (setq imenu-generic-expression LilyPond-imenu-generic-expression)
634   (imenu-add-to-menubar "Index")
635
636     ;; run the mode hook. LilyPond-mode-hook use is deprecated
637   (run-hooks 'LilyPond-mode-hook))
638
639 (defun LilyPond-version ()
640   "Echo the current version of `LilyPond-mode' in the minibuffer."
641   (interactive)
642   (message "Using `LilyPond-mode' version %s" LilyPond-version))
643
644 (provide 'lilypond-mode)
645 ;;; lilypond-mode.el ends here
646