+ (message "Selected Spanish notes")
+ (sit-for 0 750)))
+ ((string= x "h")
+ (progn (message "Insert notes with fewer key strokes. For example \"i,5.f\" produces \"fis,32. \".") (sit-for 5 0)
+ (message "Add also \"a ~ a\"-ties, \"a ( ) b\"-slurs and \"< a b >\"-chords.") (sit-for 5 0)
+ (message "There are Du(t)ch, Fin(n)ish/Deutsch (hit 'n') and S(p)anish note names.") (sit-for 5 0)
+ (message "(B)ackspace deletes last note, Ret starts a new indented line and Esc (q)uits.") (sit-for 5 0)
+ (message "Insert note triplets \"\\times 2/3 { a b } \" by typing \"/23ab}\".") (sit-for 5 0)
+ (message "This mode is experimental. Use normal mode to add further details.") (sit-for 5 0)))
+ (t (progn (message "Quick notes mode. Press Esc or q to quit.") (sit-for 0 500)))))
+ (message "Normal editing mode."))
+
+(defun LilyPond-pre-word-search ()
+ "Fetch the alphabetic characters and \\ in front of the cursor."
+ (let ((pre "")
+ (prelen 0)
+ (ch (char-before (- (point) 0))))
+ (while (and ch (or (and (>= ch 65) (<= ch 90)) ; not bolp, A-Z
+ (and (>= ch 97) (<= ch 122)) ; a-z
+ (= ch 92))) ; \\
+ (setq pre (concat (char-to-string ch) pre))
+ (setq prelen (+ prelen 1))
+ (setq ch (char-before (- (point) prelen))))
+ pre))
+
+(defun LilyPond-post-word-search ()
+ "Fetch the alphabetic characters behind the cursor."
+ (let ((post "")
+ (postlen 0)
+ (ch (char-after (+ (point) 0))))
+ (while (and ch (or (and (>= ch 65) (<= ch 90)) ; not eolp, A-Z
+ (and (>= ch 97) (<= ch 122)))) ; a-z
+ (setq post (concat post (char-to-string ch)))
+ (setq postlen (+ postlen 1))
+ (setq ch (char-after (+ (point) postlen))))
+ post))
+
+(defun LilyPond-autocompletion ()
+ "Show completions in mini-buffer for the given word."
+ (interactive)
+ (let ((pre (LilyPond-pre-word-search))
+ (post (LilyPond-post-word-search))
+ (compsstr ""))
+ ;; insert try-completion and show all-completions
+ (if (> (length pre) 0)
+ (progn
+ (setq trycomp (try-completion pre (LilyPond-add-dictionary-word ())))
+ (if (char-or-string-p trycomp)
+ (if (string-equal (concat pre post) trycomp)
+ (goto-char (+ (point) (length post)))
+ (progn
+ (delete-region (point) (+ (point) (length post)))
+ (insert (substring trycomp (length pre) nil))))
+ (progn
+ (delete-region (point) (+ (point) (length post)))
+ (font-lock-fontify-buffer))) ; only inserting fontifies
+
+ (setq complist (all-completions pre (LilyPond-add-dictionary-word ())))
+ (while (> (length complist) 0)
+ (setq compsstr (concat compsstr "\"" (car complist) "\" "))
+ (setq complist (cdr complist)))
+ (message compsstr)
+ (sit-for 0 100)))))
+
+(defun LilyPond-info ()
+ "Launch Info for lilypond."
+ (interactive)
+ (info "lilypond"))
+
+(defun LilyPond-music-glossary-info ()
+ "Launch Info for music-glossary."
+ (interactive)
+ (info "music-glossary"))
+
+(defun LilyPond-internals-info ()
+ "Launch Info for lilypond-internals."
+ (interactive)
+ (info "lilypond-internals"))
+
+(defun LilyPond-info-index-search ()
+ "In `*info*'-buffer, launch `info lilypond --index-search word-under-cursor'"
+ (interactive)
+ (let ((str (concat (LilyPond-pre-word-search) (LilyPond-post-word-search))))
+ (if (and (> (length str) 0)
+ (string-equal (substring str 0 1) "\\"))
+ (setq str (substring str 1 nil)))
+ (LilyPond-info)
+ (Info-index str)))
+
+(defun LilyPond-insert-string (pre)
+ "Insert text to the buffer."
+ (insert pre)
+ (length pre))
+
+(defun LilyPond-insert-between (text pre post)
+ "Insert text to the buffer if non-empty string is given."
+ (let ((str (read-string text)))
+ (if (string-equal str "")
+ 0
+ (progn (setq pre_str_post (concat pre str post))
+ (insert pre_str_post)
+ (length pre_str_post)))))
+
+(defun LilyPond-insert-tag-notes ()