]> git.donarmstrong.com Git - lilypond.git/blobdiff - elisp/lilypond-mode.el
dist emacs patches too.
[lilypond.git] / elisp / lilypond-mode.el
index 9330df71a528d35a41f3ab13b93697c9a8d07abd..d27487c6edb8c9cb12086a511f7b5f38665946e3 100644 (file)
@@ -3,7 +3,7 @@
 ;;;;
 ;;;; source file of the GNU LilyPond music typesetter
 ;;;;  
-;;;; (c) 1999--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; (c) 1999--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;; 
 ;;;; Changed 2001--2003 Heikki Junes <heikki.junes@hut.fi>
 ;;;;    * Add PS-compilation, PS-viewing and MIDI-play (29th Aug 2001)
@@ -367,6 +367,13 @@ in LilyPond-include-path."
   (interactive)
   (LilyPond-command (LilyPond-command-menu "MidiAll") 'LilyPond-get-master-file))
 
+(defun count-matches-as-number (re)
+  "Count-matches in emacs 22 backwards-incompatibly returns a number"
+  (let ((result (count-matches re)))
+    (if (stringp result)
+       (string-to-number result)
+      result)))
+    
 (defun count-rexp (start end rexp)
   "Print number of found regular expressions in the region."
   (interactive "r")
@@ -374,7 +381,7 @@ in LilyPond-include-path."
     (save-restriction
       (narrow-to-region start end)
       (goto-char (point-min))
-      (count-matches rexp))))
+      (count-matches-as-number rexp))))
 
 (defun count-midi-words ()
   "Check number of midi-scores before the curser."
@@ -393,8 +400,8 @@ in LilyPond-include-path."
   (let ((fnameprefix (if (eq LilyPond-command-current 'LilyPond-command-master)
                         (substring (LilyPond-get-master-file) 0 -3); suppose ".ly"
                       LilyPond-region-file-prefix))
-       (allcount (string-to-number (substring (count-midi-words) 0 -12)))
-       (count (string-to-number (substring (count-midi-words-backwards) 0 -12))))
+       (allcount (count-midi-words))
+       (count (count-midi-words-backwards)))
     (concat  fnameprefix
             (if (and (> allcount 1) (> count 0)) ; not first score
                 (if (eq count allcount)          ; last score
@@ -407,7 +414,7 @@ in LilyPond-include-path."
   (let ((fnameprefix (if (eq LilyPond-command-current 'LilyPond-command-master)
                         (substring (LilyPond-get-master-file) 0 -3); suppose ".ly"
                       LilyPond-region-file-prefix))
-       (allcount (string-to-number (substring (count-midi-words) 0 -12))))
+       (allcount (count-midi-words)))
     (concat (if (> allcount 0)  ; at least one midi-score
                (concat fnameprefix ".midi "))
            (if (> allcount 1)  ; more than one midi-score
@@ -425,8 +432,7 @@ in LilyPond-include-path."
     ("LilyPond" . (,(concat LilyPond-lilypond-command " %s") "%s" "%l" "View"))
     ("TeX" . ("tex '\\nonstopmode\\input %t'" "%t" "%d" "ViewDVI"))
     ("2Dvi" . (,(concat LilyPond-lilypond-command " -b tex %s") "%s" "%d" "LaTeX"))
-    ("2PS" . (,(concat LilyPond-lilypond-command "-b ps %s") "%s" "%p" "ViewPS"))
-    ("2Midi" . (,(concat LilyPond-lilypond-command " -m %s") "%s" "%m" "Midi"))
+    ("2PS" . (,(concat LilyPond-lilypond-command " -f ps %s") "%s" "%p" "ViewPS"))
     ("2Gnome" . (,(concat LilyPond-lilypond-command " -b gnome %s")))
 
     ("Book" . ("lilypond-book %x" "%x" "%l" "LaTeX"))
@@ -440,9 +446,9 @@ in LilyPond-include-path."
 
     ;; The following are refreshed in LilyPond-command:
     ;; - current-midi depends on cursor position and
-    ("Midi" . (,(concat LilyPond-midi-command " " (LilyPond-string-current-midi)))) ; 
+    ("Midi" . ("")) ; 
     ;; - all-midi depends on number of midi-score.
-    ("MidiAll" . (,(concat LilyPond-all-midi-command " " (LilyPond-string-all-midi))))
+    ("MidiAll" . (""))
     )
 
   "AList of commands to execute on the current document.