emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ob-lilypond code cleanup
@ 2014-08-17 10:10 Achim Gratz
  2014-08-18 11:17 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Achim Gratz @ 2014-08-17 10:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]


Triggered by the discussion about it, I've looked at ob-lilypond and
found that it should be cleaned up a bit.  The defvars holding the
various commands should really be defcustoms, but I've ran out of time
for now.  If anybody thinks this should go to maint please say so,
otherwise I will commit on master.


[-- Attachment #2: 0001-ob-lilypond-Code-cleanup.patch --]
[-- Type: text/x-patch, Size: 39322 bytes --]

From b7dd71aa6bb15a31eecf794c6f1c07dd38b834cd Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Sun, 17 Aug 2014 10:29:24 +0200
Subject: [PATCH] ob-lilypond: Code cleanup

* lisp/ob-lilypond.el: Change ly- prefix to org-babel-lilypond
  throughout.
  (ly-OSX-ly-path, ly-OSX-pdf-path, ly-OSX-midi-path, ly-nix-ly-path,
  ly-nix-pdf-path, ly-nix-midi-path, ly-w32-ly-path, ly-w32-pdf-path,
  ly-w32-midi-path, ly-determine-ly-path, ly-determine-pdf-path,
  ly-determine-midi-path): Remove.
  (org-babel-lilypond-ly-command, org-babel-lilypond-midi-command,
  org-babel-lilypond-pdf-command): Replacement for removed variables
  and functions.  Adapt all calls to the removed functions to use
  these variables instead.  Use xdg-open instead of hard-coded
  executable names on *NIX.
  (org-babel-lilypond-execute-tangled-ly,
  org-babel-lilypond-check-for-compile-error): Revert conditions to
  avoid superfluous forms.  Remove unused return values.
* testing/lisp/test-ob-lilypond.el: Change ly- prefix to
  org-babel-lilypond throughout.  Do not test for removed variables
  and replace removed function calls with the appropriate variable
  content.
---
 lisp/ob-lilypond.el              | 272 ++++++++++++++++--------------------
 testing/lisp/test-ob-lilypond.el | 292 ++++++++++++++++-----------------------
 2 files changed, 244 insertions(+), 320 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index fbfac88..ae8563c 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -41,62 +41,70 @@ (defalias 'lilypond-mode 'LilyPond-mode)
 (defvar org-babel-default-header-args:lilypond '()
   "Default header arguments for lilypond code blocks.
 NOTE: The arguments are determined at lilypond compile time.
-See (ly-set-header-args)")
+See (org-babel-lilypond-set-header-args)")
 
-(defvar ly-compile-post-tangle t
+(defvar org-babel-lilypond-compile-post-tangle t
   "Following the org-babel-tangle (C-c C-v t) command,
-ly-compile-post-tangle determines whether ob-lilypond should
+org-babel-lilypond-compile-post-tangle determines whether ob-lilypond should
 automatically attempt to compile the resultant tangled file.
 If the value is nil, no automated compilation takes place.
 Default value is t")
 
-(defvar ly-display-pdf-post-tangle t
+(defvar org-babel-lilypond-display-pdf-post-tangle t
   "Following a successful LilyPond compilation
-ly-display-pdf-post-tangle determines whether to automate the
+org-babel-lilypond-display-pdf-post-tangle determines whether to automate the
 drawing / redrawing of the resultant pdf.  If the value is nil,
 the pdf is not automatically redrawn.  Default value is t")
 
-(defvar ly-play-midi-post-tangle t
+(defvar org-babel-lilypond-play-midi-post-tangle t
   "Following a successful LilyPond compilation
-ly-play-midi-post-tangle determines whether to automate the
+org-babel-lilypond-play-midi-post-tangle determines whether to automate the
 playing of the resultant midi file.  If the value is nil,
 the midi file is not automatically played.  Default value is t")
 
-(defvar ly-OSX-ly-path
-  "/Applications/lilypond.app/Contents/Resources/bin/lilypond")
-(defvar ly-OSX-pdf-path "open")
-(defvar ly-OSX-midi-path "open")
-
-(defvar ly-nix-ly-path "/usr/bin/lilypond")
-(defvar ly-nix-pdf-path "evince")
-(defvar ly-nix-midi-path "timidity")
-
-(defvar ly-w32-ly-path "lilypond")
-(defvar ly-w32-pdf-path "")
-(defvar ly-w32-midi-path "")
-
-(defvar ly-gen-png nil
+(defvar org-babel-lilypond-ly-command
+  "Command to execute lilypond on your system."
+  (pcase system-type
+    ("darwin"     "/Applications/lilypond.app/Contents/Resources/bin/lilypond")
+    ("windows-nt" "lilypond")
+    (_            "lilypond")))
+
+(defvar org-babel-lilypond-pdf-command
+  "Command to show a PDF file on your system."
+  (pcase system-type
+    ("darwin"     "open")
+    ("windows-nt" "")
+    (_            "xdg-open")))
+
+(defvar org-babel-lilypond-midi-command
+  "Command to play a MIDI file on your system."
+  (pcase system-type
+    ("darwin"     "open")
+    ("windows-nt" "")
+    (_            "xdg-open")))
+
+(defvar org-babel-lilypond-gen-png nil
   "Image generation (png) can be turned on by default by setting
-LY-GEN-PNG to t")
+ORG-BABEL-LILYPOND-GEN-PNG to t")
 
-(defvar ly-gen-svg nil
+(defvar org-babel-lilypond-gen-svg nil
   "Image generation (SVG) can be turned on by default by setting
-LY-GEN-SVG to t")
+ORG-BABEL-LILYPOND-GEN-SVG to t")
 
-(defvar ly-gen-html nil
+(defvar org-babel-lilypond-gen-html nil
   "HTML generation can be turned on by default by setting
-LY-GEN-HTML to t")
+ORG-BABEL-LILYPOND-GEN-HTML to t")
 
-(defvar ly-gen-pdf nil
+(defvar org-babel-lilypond-gen-pdf nil
   "PDF generation can be turned on by default by setting
-LY-GEN-PDF to t")
+ORG-BABEL-LILYPOND-GEN-PDF to t")
 
-(defvar ly-use-eps nil
+(defvar org-babel-lilypond-use-eps nil
   "You can force the compiler to use the EPS backend by setting
-LY-USE-EPS to t")
+ORG-BABEL-LILYPOND-USE-EPS to t")
 
-(defvar ly-arrange-mode nil
-  "Arrange mode is turned on by setting LY-ARRANGE-MODE
+(defvar org-babel-lilypond-arrange-mode nil
+  "Arrange mode is turned on by setting ORG-BABEL-LILYPOND-ARRANGE-MODE
 to t.  In Arrange mode the following settings are altered
 from default...
 :tangle yes,    :noweb yes
@@ -125,20 +133,20 @@ (defun org-babel-execute:lilypond (body params)
 1. Attempt to execute lilypond block according to header settings
   (This is the default basic mode)
 2. Tangle all lilypond blocks and process the result (arrange mode)"
-  (ly-set-header-args ly-arrange-mode)
-  (if ly-arrange-mode
-      (ly-tangle)
-    (ly-process-basic body params)))
+  (org-babel-lilypond-set-header-args org-babel-lilypond-arrange-mode)
+  (if org-babel-lilypond-arrange-mode
+      (org-babel-lilypond-tangle)
+    (org-babel-lilypond-process-basic body params)))
 
-(defun ly-tangle ()
+(defun org-babel-lilypond-tangle ()
   "ob-lilypond specific tangle, attempts to invoke
 =ly-execute-tangled-ly= if tangle is successful.  Also passes
 specific arguments to =org-babel-tangle="
   (interactive)
   (if (org-babel-tangle nil "yes" "lilypond")
-      (ly-execute-tangled-ly) nil))
+      (org-babel-lilypond-execute-tangled-ly) nil))
 
-(defun ly-process-basic (body params)
+(defun org-babel-lilypond-process-basic (body params)
   "Execute a lilypond block in basic mode."
   (let* ((result-params (cdr (assoc :result-params params)))
 	 (out-file (cdr (assoc :file params)))
@@ -150,7 +158,7 @@ (defun ly-process-basic (body params)
       (insert (org-babel-expand-body:generic body params)))
     (org-babel-eval
      (concat
-      (ly-determine-ly-path)
+      org-babel-lilypond-ly-command
       " -dbackend=eps "
       "-dno-gs-load-fonts "
       "-dinclude-eps-fonts "
@@ -169,45 +177,43 @@ (defun org-babel-prep-session:lilypond (session params)
   "Return an error because LilyPond exporter does not support sessions."
   (error "Sorry, LilyPond does not currently support sessions!"))
 
-(defun ly-execute-tangled-ly ()
+(defun org-babel-lilypond-execute-tangled-ly ()
   "Compile result of block tangle with lilypond.
 If error in compilation, attempt to mark the error in lilypond org file"
-  (when ly-compile-post-tangle
-    (let ((ly-tangled-file (ly-switch-extension
+  (when org-babel-lilypond-compile-post-tangle
+    (let ((org-babel-lilypond-tangled-file (org-babel-lilypond-switch-extension
                             (buffer-file-name) ".lilypond"))
-          (ly-temp-file (ly-switch-extension
+          (org-babel-lilypond-temp-file (org-babel-lilypond-switch-extension
                          (buffer-file-name) ".ly")))
-      (if (file-exists-p ly-tangled-file)
-          (progn
-            (when (file-exists-p ly-temp-file)
-              (delete-file ly-temp-file))
-            (rename-file ly-tangled-file
-                         ly-temp-file))
-        (error "Error: Tangle Failed!") t)
+      (if (not (file-exists-p org-babel-lilypond-tangled-file))
+	  (error "Error: Tangle Failed!")
+	(when (file-exists-p org-babel-lilypond-temp-file)
+	  (delete-file org-babel-lilypond-temp-file))
+	(rename-file org-babel-lilypond-tangled-file
+		     org-babel-lilypond-temp-file))
       (switch-to-buffer-other-window "*lilypond*")
       (erase-buffer)
-      (ly-compile-lilyfile ly-temp-file)
+      (org-babel-lilypond-compile-lilyfile org-babel-lilypond-temp-file)
       (goto-char (point-min))
-      (if (not (ly-check-for-compile-error ly-temp-file))
-          (progn
-            (other-window -1)
-            (ly-attempt-to-open-pdf ly-temp-file)
-            (ly-attempt-to-play-midi ly-temp-file))
-        (error "Error in Compilation!")))) nil)
-
-(defun ly-compile-lilyfile (file-name &optional test)
+      (if (org-babel-lilypond-check-for-compile-error org-babel-lilypond-temp-file)
+	  (error "Error in Compilation!")
+	(other-window -1)
+	(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
+	(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)))))
+
+(defun org-babel-lilypond-compile-lilyfile (file-name &optional test)
   "Compile lilypond file and check for compile errors
 FILE-NAME is full path to lilypond (.ly) file"
   (message "Compiling LilyPond...")
-  (let ((arg-1 (ly-determine-ly-path)) ;program
+  (let ((arg-1 org-babel-lilypond-ly-command) ;program
         (arg-2 nil)                    ;infile
         (arg-3 "*lilypond*")           ;buffer
 	(arg-4 t)                      ;display
-	(arg-5 (if ly-gen-png  "--png"  "")) ;&rest...
-	(arg-6 (if ly-gen-html "--html" ""))
-        (arg-7 (if ly-gen-pdf "--pdf" ""))
-        (arg-8 (if ly-use-eps  "-dbackend=eps" ""))
-        (arg-9 (if ly-gen-svg  "-dbackend=svg" ""))
+	(arg-5 (if org-babel-lilypond-gen-png  "--png"  "")) ;&rest...
+	(arg-6 (if org-babel-lilypond-gen-html "--html" ""))
+        (arg-7 (if org-babel-lilypond-gen-pdf "--pdf" ""))
+        (arg-8 (if org-babel-lilypond-use-eps  "-dbackend=eps" ""))
+        (arg-9 (if org-babel-lilypond-gen-svg  "-dbackend=svg" ""))
         (arg-10 (concat "--output=" (file-name-sans-extension file-name)))
         (arg-11 file-name))
     (if test
@@ -217,7 +223,7 @@ (defun ly-compile-lilyfile (file-name &optional test)
        arg-1 arg-2 arg-3 arg-4 arg-5 arg-6
        arg-7 arg-8 arg-9 arg-10 arg-11))))
 
-(defun ly-check-for-compile-error (file-name &optional test)
+(defun org-babel-lilypond-check-for-compile-error (file-name &optional test)
   "Check for compile error.
 This is performed by parsing the *lilypond* buffer
 containing the output message from the compilation.
@@ -225,27 +231,26 @@ (defun ly-check-for-compile-error (file-name &optional test)
 If TEST is t just return nil if no error found, and pass
 nil as file-name since it is unused in this context"
   (let ((is-error (search-forward "error:" nil t)))
-    (if (not test)
-        (if (not is-error)
-            nil
-          (ly-process-compile-error file-name))
-      is-error)))
+    (if test
+	is-error
+      (when is-error
+	(org-babel-lilypond-process-compile-error file-name)))))
 
-(defun ly-process-compile-error (file-name)
+(defun org-babel-lilypond-process-compile-error (file-name)
   "Process the compilation error that has occurred.
 FILE-NAME is full path to lilypond file"
-  (let ((line-num (ly-parse-line-num)))
-    (let ((error-lines (ly-parse-error-line file-name line-num)))
-      (ly-mark-error-line file-name error-lines)
+  (let ((line-num (org-babel-lilypond-parse-line-num)))
+    (let ((error-lines (org-babel-lilypond-parse-error-line file-name line-num)))
+      (org-babel-lilypond-mark-error-line file-name error-lines)
       (error "Error: Compilation Failed!"))))
 
-(defun ly-mark-error-line (file-name line)
+(defun org-babel-lilypond-mark-error-line (file-name line)
   "Mark the erroneous lines in the lilypond org buffer.
 FILE-NAME is full path to lilypond file.
 LINE is the erroneous line"
   (switch-to-buffer-other-window
    (concat (file-name-nondirectory
-            (ly-switch-extension file-name ".org"))))
+            (org-babel-lilypond-switch-extension file-name ".org"))))
   (let ((temp (point)))
     (goto-char (point-min))
     (setq case-fold-search nil)
@@ -256,7 +261,7 @@ (defun ly-mark-error-line (file-name line)
           (goto-char (- (point) (length line))))
       (goto-char temp))))
 
-(defun ly-parse-line-num (&optional buffer)
+(defun org-babel-lilypond-parse-line-num (&optional buffer)
   "Extract error line number."
   (when buffer
     (set-buffer buffer))
@@ -278,12 +283,12 @@ (defun ly-parse-line-num (&optional buffer)
               nil)))
       nil)))
 
-(defun ly-parse-error-line (file-name lineNo)
+(defun org-babel-lilypond-parse-error-line (file-name lineNo)
   "Extract the erroneous line from the tangled .ly file
 FILE-NAME is full path to lilypond file.
 LINENO is the number of the erroneous line"
   (with-temp-buffer
-    (insert-file-contents (ly-switch-extension file-name ".ly")
+    (insert-file-contents (org-babel-lilypond-switch-extension file-name ".ly")
 			  nil nil nil t)
     (if (> lineNo 0)
 	(progn
@@ -292,128 +297,95 @@ (defun ly-parse-error-line (file-name lineNo)
 	  (buffer-substring (point) (point-at-eol)))
       nil)))
 
-(defun ly-attempt-to-open-pdf (file-name &optional test)
+(defun org-babel-lilypond-attempt-to-open-pdf (file-name &optional test)
   "Attempt to display the generated pdf file
 FILE-NAME is full path to lilypond file
 If TEST is non-nil, the shell command is returned and is not run"
-  (when ly-display-pdf-post-tangle
-    (let ((pdf-file (ly-switch-extension file-name ".pdf")))
+  (when org-babel-lilypond-display-pdf-post-tangle
+    (let ((pdf-file (org-babel-lilypond-switch-extension file-name ".pdf")))
       (if (file-exists-p pdf-file)
           (let ((cmd-string
-                 (concat (ly-determine-pdf-path) " " pdf-file)))
+                 (concat org-babel-lilypond-pdf-command " " pdf-file)))
             (if test
                 cmd-string
 	      (start-process
 	       "\"Audition pdf\""
 	       "*lilypond*"
-	       (ly-determine-pdf-path)
+	       org-babel-lilypond-pdf-command
 	       pdf-file)))
 	(message  "No pdf file generated so can't display!")))))
 
-(defun ly-attempt-to-play-midi (file-name &optional test)
+(defun org-babel-lilypond-attempt-to-play-midi (file-name &optional test)
   "Attempt to play the generated MIDI file
 FILE-NAME is full path to lilypond file
 If TEST is non-nil, the shell command is returned and is not run"
-  (when ly-play-midi-post-tangle
-    (let ((midi-file (ly-switch-extension file-name ".midi")))
+  (when org-babel-lilypond-play-midi-post-tangle
+    (let ((midi-file (org-babel-lilypond-switch-extension file-name ".midi")))
       (if (file-exists-p midi-file)
           (let ((cmd-string
-                 (concat (ly-determine-midi-path) " " midi-file)))
+                 (concat org-babel-lilypond-midi-command " " midi-file)))
             (if test
                 cmd-string
               (start-process
                "\"Audition midi\""
                "*lilypond*"
-               (ly-determine-midi-path)
+               org-babel-lilypond-midi-command
                midi-file)))
         (message "No midi file generated so can't play!")))))
 
-(defun ly-determine-ly-path (&optional test)
-  "Return correct path to ly binary depending on OS
-If TEST is non-nil, it contains a simulation of the OS for test purposes"
-  (let ((sys-type
-         (or test system-type)))
-    (cond ((string= sys-type  "darwin")
-           ly-OSX-ly-path)
-          ((string= sys-type "windows-nt")
-           ly-w32-ly-path)
-          (t ly-nix-ly-path))))
-
-(defun ly-determine-pdf-path (&optional test)
-  "Return correct path to pdf viewer depending on OS
-If TEST is non-nil, it contains a simulation of the OS for test purposes"
-  (let ((sys-type
-         (or test system-type)))
-    (cond ((string= sys-type  "darwin")
-           ly-OSX-pdf-path)
-          ((string= sys-type "windows-nt")
-           ly-w32-pdf-path)
-          (t ly-nix-pdf-path))))
-
-(defun ly-determine-midi-path (&optional test)
-  "Return correct path to midi player depending on OS
-If TEST is non-nil, it contains a simulation of the OS for test purposes"
-  (let ((sys-type
-         (or test test system-type)))
-    (cond ((string= sys-type  "darwin")
-           ly-OSX-midi-path)
-          ((string= sys-type "windows-nt")
-           ly-w32-midi-path)
-          (t ly-nix-midi-path))))
-
-(defun ly-toggle-midi-play ()
+(defun org-babel-lilypond-toggle-midi-play ()
   "Toggle whether midi will be played following a successful compilation."
   (interactive)
-  (setq ly-play-midi-post-tangle
-        (not ly-play-midi-post-tangle))
+  (setq org-babel-lilypond-play-midi-post-tangle
+        (not org-babel-lilypond-play-midi-post-tangle))
   (message (concat "Post-Tangle MIDI play has been "
-                   (if ly-play-midi-post-tangle
+                   (if org-babel-lilypond-play-midi-post-tangle
                        "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-pdf-display ()
+(defun org-babel-lilypond-toggle-pdf-display ()
   "Toggle whether pdf will be displayed following a successful compilation."
   (interactive)
-  (setq ly-display-pdf-post-tangle
-        (not ly-display-pdf-post-tangle))
+  (setq org-babel-lilypond-display-pdf-post-tangle
+        (not org-babel-lilypond-display-pdf-post-tangle))
   (message (concat "Post-Tangle PDF display has been "
-                   (if ly-display-pdf-post-tangle
+                   (if org-babel-lilypond-display-pdf-post-tangle
                        "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-png-generation ()
+(defun org-babel-lilypond-toggle-png-generation ()
   "Toggle whether png image will be generated by compilation."
   (interactive)
-  (setq ly-gen-png (not ly-gen-png))
+  (setq org-babel-lilypond-gen-png (not org-babel-lilypond-gen-png))
   (message (concat "PNG image generation has been "
-                   (if ly-gen-png "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-gen-png "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-html-generation ()
+(defun org-babel-lilypond-toggle-html-generation ()
   "Toggle whether html will be generated by compilation."
   (interactive)
-  (setq ly-gen-html (not ly-gen-html))
+  (setq org-babel-lilypond-gen-html (not org-babel-lilypond-gen-html))
   (message (concat "HTML generation has been "
-                   (if ly-gen-html "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-gen-html "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-pdf-generation ()
+(defun org-babel-lilypond-toggle-pdf-generation ()
   "Toggle whether pdf will be generated by compilation."
   (interactive)
-  (setq ly-gen-pdf (not ly-gen-pdf))
+  (setq org-babel-lilypond-gen-pdf (not org-babel-lilypond-gen-pdf))
   (message (concat "PDF generation has been "
-                   (if ly-gen-pdf "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-gen-pdf "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-arrange-mode ()
+(defun org-babel-lilypond-toggle-arrange-mode ()
   "Toggle whether in Arrange mode or Basic mode."
   (interactive)
-  (setq ly-arrange-mode
-        (not ly-arrange-mode))
+  (setq org-babel-lilypond-arrange-mode
+        (not org-babel-lilypond-arrange-mode))
   (message (concat "Arrange mode has been "
-                   (if ly-arrange-mode "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-arrange-mode "ENABLED." "DISABLED."))))
 
-(defun ly-switch-extension (file-name ext)
+(defun org-babel-lilypond-switch-extension (file-name ext)
   "Utility command to swap current FILE-NAME extension with EXT"
   (concat (file-name-sans-extension
            file-name) ext))
 
-(defun ly-get-header-args (mode)
+(defun org-babel-lilypond-get-header-args (mode)
   "Default arguments to use when evaluating a lilypond
 source block.  These depend upon whether we are in arrange
 mode i.e.  ARRANGE-MODE is t"
@@ -427,11 +399,11 @@ (defun ly-get-header-args (mode)
          '((:results . "file")
            (:exports . "results")))))
 
-(defun ly-set-header-args (mode)
+(defun org-babel-lilypond-set-header-args (mode)
   "Set org-babel-default-header-args:lilypond
-dependent on LY-ARRANGE-MODE"
+dependent on ORG-BABEL-LILYPOND-ARRANGE-MODE"
   (setq org-babel-default-header-args:lilypond
-        (ly-get-header-args mode)))
+        (org-babel-lilypond-get-header-args mode)))
 
 (provide 'ob-lilypond)
 
diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el
index abf6a48..6409e27 100644
--- a/testing/lisp/test-ob-lilypond.el
+++ b/testing/lisp/test-ob-lilypond.el
@@ -24,7 +24,7 @@
 
 (save-excursion
   (set-buffer (get-buffer-create "test-ob-lilypond.el"))
-  (setq ly-here
+  (setq org-babel-lilypond-here
         (file-name-directory
          (or load-file-name (buffer-file-name)))))
 
@@ -52,81 +52,57 @@
 
 (ert-deftest ob-lilypond/ly-compile-lilyfile ()
   (should (equal
-           `(,(ly-determine-ly-path)    ;program
+           `(,org-babel-lilypond-ly-command    ;program
              nil                        ;infile
              "*lilypond*"               ;buffer
              t                          ;display
-             ,(if ly-gen-png  "--png"  "") ;&rest...
-             ,(if ly-gen-html "--html" "")
-             ,(if ly-gen-pdf "--pdf" "")
-             ,(if ly-use-eps  "-dbackend=eps" "")
-             ,(if ly-gen-svg  "-dbackend=svg" "")
+             ,(if org-babel-lilypond-gen-png  "--png"  "") ;&rest...
+             ,(if org-babel-lilypond-gen-html "--html" "")
+             ,(if org-babel-lilypond-gen-pdf "--pdf" "")
+             ,(if org-babel-lilypond-use-eps  "-dbackend=eps" "")
+             ,(if org-babel-lilypond-gen-svg  "-dbackend=svg" "")
              "--output=test-file"
              "test-file.ly")
-           (ly-compile-lilyfile "test-file.ly" t))))
+           (org-babel-lilypond-compile-lilyfile "test-file.ly" t))))
 
 (ert-deftest ob-lilypond/ly-compile-post-tangle ()
-  (should (boundp 'ly-compile-post-tangle)))
+  (should (boundp 'org-babel-lilypond-compile-post-tangle)))
 
 (ert-deftest ob-lilypond/ly-display-pdf-post-tangle ()
-  (should (boundp 'ly-display-pdf-post-tangle)))
+  (should (boundp 'org-babel-lilypond-display-pdf-post-tangle)))
 
 (ert-deftest ob-lilypond/ly-play-midi-post-tangle ()
-  (should (boundp 'ly-play-midi-post-tangle)))
+  (should (boundp 'org-babel-lilypond-play-midi-post-tangle)))
 
-(ert-deftest ob-lilypond/ly-OSX-ly-path ()
-  (should (boundp 'ly-OSX-ly-path))
-  (should (stringp ly-OSX-ly-path)))
+(ert-deftest ob-lilypond/ly-ly-command ()
+  (should (boundp 'org-babel-lilypond-ly-command))
+  (should (stringp org-babel-lilypond-ly-command)))
 
-(ert-deftest ob-lilypond/ly-OSX-pdf-path ()
-  (should (boundp 'ly-OSX-pdf-path))
-  (should (stringp ly-OSX-pdf-path)))
+(ert-deftest ob-lilypond/ly-pdf-command ()
+  (should (boundp 'org-babel-lilypond-pdf-command))
+  (should (stringp org-babel-lilypond-pdf-command)))
 
-(ert-deftest ob-lilypond/ly-OSX-midi-path ()
-  (should (boundp 'ly-OSX-midi-path))
-  (should (stringp ly-OSX-midi-path)))
-
-(ert-deftest ob-lilypond/ly-nix-ly-path ()
-  (should (boundp 'ly-nix-ly-path))
-  (should (stringp ly-nix-ly-path)))
-
-(ert-deftest ob-lilypond/ly-nix-pdf-path ()
-  (should (boundp 'ly-nix-pdf-path))
-  (should (stringp ly-nix-pdf-path)))
-
-(ert-deftest ob-lilypond/ly-nix-midi-path ()
-  (should (boundp 'ly-nix-midi-path))
-  (should (stringp ly-nix-midi-path)))
-
-(ert-deftest ob-lilypond/ly-w32-ly-path ()
-  (should (boundp 'ly-w32-ly-path))
-  (should (stringp ly-w32-ly-path)))
-
-(ert-deftest ob-lilypond/ly-w32-pdf-path ()
-  (should (boundp 'ly-w32-pdf-path))
-  (should (stringp ly-w32-pdf-path)))
-
-(ert-deftest ob-lilypond/ly-w32-midi-path ()
-  (should (boundp 'ly-w32-midi-path))
-  (should (stringp ly-w32-midi-path)))
+(ert-deftest ob-lilypond/ly-midi-command ()
+  (should (boundp 'org-babel-lilypond-midi-command))
+  (should (stringp org-babel-lilypond-midi-command)))
 
 (ert-deftest ob-lilypond/ly-gen-png ()
-  (should (boundp 'ly-gen-png)))
+  (should (boundp 'org-babel-lilypond-gen-png)))
 
 (ert-deftest ob-lilypond/ly-gen-svg ()
-  (should (boundp 'ly-gen-svg)))
+  (should (boundp 'org-babel-lilypond-gen-svg)))
 
 (ert-deftest ob-lilypond/ly-gen-html ()
-  (should (boundp 'ly-gen-html)))
+  (should (boundp 'org-babel-lilypond-gen-html)))
 
 (ert-deftest ob-lilypond/ly-gen-html ()
-  (should (boundp 'ly-gen-pdf)))
+  (should (boundp 'org-babel-lilypond-gen-pdf)))
 
 (ert-deftest ob-lilypond/use-eps ()
-  (should (boundp 'ly-use-eps)))
+  (should (boundp 'org-babel-lilypond-use-eps)))
 
 (ert-deftest ob-lilypond/ly-arrange-mode ()
-  (should (boundp 'ly-arrange-mode)))
+  (should (boundp 'org-babel-lilypond-arrange-mode)))
 
 ;; (ert-deftest ob-lilypond/org-babel-default-header-args:lilypond ()
 ;;   (should (equal  '((:tangle . "yes")
@@ -140,32 +116,32 @@
   (should (equal "This is a test"
                  (org-babel-expand-body:lilypond "This is a test" ()))))
 
-;;TODO (ert-deftest ly-test-org-babel-execute:lilypond ())
+;;TODO (ert-deftest org-babel-lilypond-test-org-babel-execute:lilypond ())
 (ert-deftest ob-lilypond/ly-check-for-compile-error ()
   (set-buffer (get-buffer-create "*lilypond*"))
   (erase-buffer)
-  (should (not (ly-check-for-compile-error nil t)))
-  (insert-file-contents (concat ly-here
+  (should (not (org-babel-lilypond-check-for-compile-error nil t)))
+  (insert-file-contents (concat org-babel-lilypond-here
                                 "../examples/ob-lilypond-test.error")
                         nil nil nil t)
   (goto-char (point-min))
-  (should (ly-check-for-compile-error nil t))
+  (should (org-babel-lilypond-check-for-compile-error nil t))
   (kill-buffer "*lilypond*"))
 
 (ert-deftest ob-lilypond/ly-process-compile-error ()
   (find-file-other-window (concat
-                           ly-here
+                           org-babel-lilypond-here
                            "../examples/ob-lilypond-broken.org"))
   (set-buffer (get-buffer-create "*lilypond*"))
   (insert-file-contents (concat
-                         ly-here
+                         org-babel-lilypond-here
                          "../examples/ob-lilypond-test.error")
                         nil nil nil t)
   (goto-char (point-min))
   (search-forward "error:" nil t)
   (should-error
-   (ly-process-compile-error (concat
-                              ly-here
+   (org-babel-lilypond-process-compile-error (concat
+                              org-babel-lilypond-here
                               "../examples/ob-lilypond-broken.ly"))
    :type 'error)
   (set-buffer "ob-lilypond-broken.org")
@@ -177,13 +153,13 @@
 
 (ert-deftest ob-lilypond/ly-mark-error-line ()
   (let ((file-name (concat
-                    ly-here
+                    org-babel-lilypond-here
                     "../examples/ob-lilypond-broken.org"))
         (expected-point-min 198)
         (expected-point-max 205)
         (line "line 20"))
     (find-file-other-window file-name)
-    (ly-mark-error-line file-name line)
+    (org-babel-lilypond-mark-error-line file-name line)
     (should (equal expected-point-min (point)))
 
     (exchange-point-and-mark)
@@ -193,174 +169,150 @@
 (ert-deftest ob-lilypond/ly-parse-line-num ()
   (with-temp-buffer
     (insert-file-contents (concat
-                           ly-here
+                           org-babel-lilypond-here
                            "../examples/ob-lilypond-test.error")
                           nil nil nil t)
     (goto-char (point-min))
     (search-forward "error:")
-    (should (equal 25 (ly-parse-line-num (current-buffer))))))
+    (should (equal 25 (org-babel-lilypond-parse-line-num (current-buffer))))))
 
 (ert-deftest ob-lilypond/ly-parse-error-line ()
-  (let ((ly-file (concat
-                  ly-here
+  (let ((org-babel-lilypond-file (concat
+                  org-babel-lilypond-here
                   "../examples/ob-lilypond-broken.ly")))
     (should (equal "line 20"
-                   (ly-parse-error-line ly-file 20)))
-    (should (not (ly-parse-error-line ly-file 0)))))
+                   (org-babel-lilypond-parse-error-line org-babel-lilypond-file 20)))
+    (should (not (org-babel-lilypond-parse-error-line org-babel-lilypond-file 0)))))
 
 (ert-deftest ob-lilypond/ly-attempt-to-open-pdf ()
-  (let ((post-tangle ly-display-pdf-post-tangle)
-        (ly-file (concat
-                  ly-here
+  (let ((post-tangle org-babel-lilypond-display-pdf-post-tangle)
+        (org-babel-lilypond-file (concat
+                  org-babel-lilypond-here
                   "../examples/ob-lilypond-test.ly"))
         (pdf-file (concat
-                   ly-here
+                   org-babel-lilypond-here
                    "../examples/ob-lilypond-test.pdf")))
-    (setq ly-display-pdf-post-tangle t)
+    (setq org-babel-lilypond-display-pdf-post-tangle t)
     (when (not (file-exists-p pdf-file))
       (set-buffer (get-buffer-create (file-name-nondirectory pdf-file)))
       (write-file pdf-file))
     (should (equal
              (concat
-              (ly-determine-pdf-path) " " pdf-file)
-             (ly-attempt-to-open-pdf ly-file t)))
+              org-babel-lilypond-pdf-command " " pdf-file)
+             (org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-file t)))
     (delete-file pdf-file)
     (kill-buffer (file-name-nondirectory pdf-file))
     (should (equal
              "No pdf file generated so can't display!"
-             (ly-attempt-to-open-pdf pdf-file)))
-    (setq ly-display-pdf-post-tangle post-tangle)))
+             (org-babel-lilypond-attempt-to-open-pdf pdf-file)))
+    (setq org-babel-lilypond-display-pdf-post-tangle post-tangle)))
 
 (ert-deftest ob-lilypond/ly-attempt-to-play-midi ()
-  (let ((post-tangle ly-play-midi-post-tangle)
-        (ly-file (concat
-                  ly-here
+  (let ((post-tangle org-babel-lilypond-play-midi-post-tangle)
+        (org-babel-lilypond-file (concat
+                  org-babel-lilypond-here
                   "../examples/ob-lilypond-test.ly"))
         (midi-file (concat
-                    ly-here
+                    org-babel-lilypond-here
                     "../examples/ob-lilypond-test.midi")))
-    (setq ly-play-midi-post-tangle t)
+    (setq org-babel-lilypond-play-midi-post-tangle t)
     (when (not (file-exists-p midi-file))
       (set-buffer (get-buffer-create (file-name-nondirectory midi-file)))
       (write-file midi-file))
     (should (equal
              (concat
-              (ly-determine-midi-path) " " midi-file)
-             (ly-attempt-to-play-midi ly-file t)))
+              org-babel-lilypond-midi-command " " midi-file)
+             (org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-file t)))
     (delete-file midi-file)
     (kill-buffer (file-name-nondirectory midi-file))
     (should (equal
              "No midi file generated so can't play!"
-             (ly-attempt-to-play-midi midi-file)))
-    (setq ly-play-midi-post-tangle post-tangle)))
-
-(ert-deftest ob-lilypond/ly-determine-ly-path ()
-  (should (equal ly-OSX-ly-path
-                 (ly-determine-ly-path "darwin")))
-  (should (equal ly-w32-ly-path
-                 (ly-determine-ly-path "windows-nt")))
-  (should (equal ly-nix-ly-path
-                 (ly-determine-ly-path "nix"))))
-
-(ert-deftest ob-lilypond/ly-determine-pdf-path ()
-  (should (equal ly-OSX-pdf-path
-                 (ly-determine-pdf-path "darwin")))
-  (should (equal ly-w32-pdf-path
-                 (ly-determine-pdf-path "windows-nt")))
-  (should (equal ly-nix-pdf-path
-                 (ly-determine-pdf-path "nix"))))
-
-(ert-deftest ob-lilypond/ly-determine-midi-path ()
-  (should (equal ly-OSX-midi-path
-                 (ly-determine-midi-path "darwin")))
-  (should (equal ly-w32-midi-path
-                 (ly-determine-midi-path "windows-nt")))
-  (should (equal ly-nix-midi-path
-                 (ly-determine-midi-path "nix"))))
+             (org-babel-lilypond-attempt-to-play-midi midi-file)))
+    (setq org-babel-lilypond-play-midi-post-tangle post-tangle)))
 
 (ert-deftest ob-lilypond/ly-toggle-midi-play-toggles-flag ()
-  (if ly-play-midi-post-tangle
+  (if org-babel-lilypond-play-midi-post-tangle
       (progn
-        (ly-toggle-midi-play)
-         (should (not ly-play-midi-post-tangle))
-        (ly-toggle-midi-play)
-        (should ly-play-midi-post-tangle))
-    (ly-toggle-midi-play)
-    (should ly-play-midi-post-tangle)
-    (ly-toggle-midi-play)
-    (should (not ly-play-midi-post-tangle))))
+        (org-babel-lilypond-toggle-midi-play)
+         (should (not org-babel-lilypond-play-midi-post-tangle))
+        (org-babel-lilypond-toggle-midi-play)
+        (should org-babel-lilypond-play-midi-post-tangle))
+    (org-babel-lilypond-toggle-midi-play)
+    (should org-babel-lilypond-play-midi-post-tangle)
+    (org-babel-lilypond-toggle-midi-play)
+    (should (not org-babel-lilypond-play-midi-post-tangle))))
 
 (ert-deftest ob-lilypond/ly-toggle-pdf-display-toggles-flag ()
-  (if ly-display-pdf-post-tangle
+  (if org-babel-lilypond-display-pdf-post-tangle
       (progn
-        (ly-toggle-pdf-display)
-         (should (not ly-display-pdf-post-tangle))
-        (ly-toggle-pdf-display)
-        (should ly-display-pdf-post-tangle))
-    (ly-toggle-pdf-display)
-    (should ly-display-pdf-post-tangle)
-    (ly-toggle-pdf-display)
-    (should (not ly-display-pdf-post-tangle))))
+        (org-babel-lilypond-toggle-pdf-display)
+         (should (not org-babel-lilypond-display-pdf-post-tangle))
+        (org-babel-lilypond-toggle-pdf-display)
+        (should org-babel-lilypond-display-pdf-post-tangle))
+    (org-babel-lilypond-toggle-pdf-display)
+    (should org-babel-lilypond-display-pdf-post-tangle)
+    (org-babel-lilypond-toggle-pdf-display)
+    (should (not org-babel-lilypond-display-pdf-post-tangle))))
 
 (ert-deftest ob-lilypond/ly-toggle-pdf-generation-toggles-flag ()
-  (if ly-gen-pdf
+  (if org-babel-lilypond-gen-pdf
       (progn
-        (ly-toggle-pdf-generation)
-         (should (not ly-gen-pdf))
-        (ly-toggle-pdf-generation)
-        (should ly-gen-pdf))
-    (ly-toggle-pdf-generation)
-    (should ly-gen-pdf)
-    (ly-toggle-pdf-generation)
-    (should (not ly-gen-pdf))))
+        (org-babel-lilypond-toggle-pdf-generation)
+         (should (not org-babel-lilypond-gen-pdf))
+        (org-babel-lilypond-toggle-pdf-generation)
+        (should org-babel-lilypond-gen-pdf))
+    (org-babel-lilypond-toggle-pdf-generation)
+    (should org-babel-lilypond-gen-pdf)
+    (org-babel-lilypond-toggle-pdf-generation)
+    (should (not org-babel-lilypond-gen-pdf))))
 
 (ert-deftest ob-lilypond/ly-toggle-arrange-mode ()
-  (if ly-arrange-mode
+  (if org-babel-lilypond-arrange-mode
       (progn
-        (ly-toggle-arrange-mode)
-        (should (not ly-arrange-mode))
-        (ly-toggle-arrange-mode)
-        (should ly-arrange-mode))
-    (ly-toggle-arrange-mode)
-    (should ly-arrange-mode)
-    (ly-toggle-arrange-mode)
-    (should (not ly-arrange-mode))))
+        (org-babel-lilypond-toggle-arrange-mode)
+        (should (not org-babel-lilypond-arrange-mode))
+        (org-babel-lilypond-toggle-arrange-mode)
+        (should org-babel-lilypond-arrange-mode))
+    (org-babel-lilypond-toggle-arrange-mode)
+    (should org-babel-lilypond-arrange-mode)
+    (org-babel-lilypond-toggle-arrange-mode)
+    (should (not org-babel-lilypond-arrange-mode))))
 
 (ert-deftest ob-lilypond/ly-toggle-png-generation-toggles-flag ()
-  (if ly-gen-png
+  (if org-babel-lilypond-gen-png
       (progn
-        (ly-toggle-png-generation)
-         (should (not ly-gen-png))
-        (ly-toggle-png-generation)
-        (should ly-gen-png))
-    (ly-toggle-png-generation)
-    (should ly-gen-png)
-    (ly-toggle-png-generation)
-    (should (not ly-gen-png))))
+        (org-babel-lilypond-toggle-png-generation)
+         (should (not org-babel-lilypond-gen-png))
+        (org-babel-lilypond-toggle-png-generation)
+        (should org-babel-lilypond-gen-png))
+    (org-babel-lilypond-toggle-png-generation)
+    (should org-babel-lilypond-gen-png)
+    (org-babel-lilypond-toggle-png-generation)
+    (should (not org-babel-lilypond-gen-png))))
 
 (ert-deftest ob-lilypond/ly-toggle-html-generation-toggles-flag ()
-  (if ly-gen-html
+  (if org-babel-lilypond-gen-html
       (progn
-        (ly-toggle-html-generation)
-         (should (not ly-gen-html))
-        (ly-toggle-html-generation)
-        (should ly-gen-html))
-    (ly-toggle-html-generation)
-    (should ly-gen-html)
-    (ly-toggle-html-generation)
-    (should (not ly-gen-html))))
+        (org-babel-lilypond-toggle-html-generation)
+         (should (not org-babel-lilypond-gen-html))
+        (org-babel-lilypond-toggle-html-generation)
+        (should org-babel-lilypond-gen-html))
+    (org-babel-lilypond-toggle-html-generation)
+    (should org-babel-lilypond-gen-html)
+    (org-babel-lilypond-toggle-html-generation)
+    (should (not org-babel-lilypond-gen-html))))
 
 (ert-deftest ob-lilypond/ly-switch-extension-with-extensions ()
   (should (equal "test-name.xyz"
-                 (ly-switch-extension "test-name" ".xyz")))
+                 (org-babel-lilypond-switch-extension "test-name" ".xyz")))
   (should (equal "test-name.xyz"
-                 (ly-switch-extension "test-name.abc" ".xyz")))
+                 (org-babel-lilypond-switch-extension "test-name.abc" ".xyz")))
   (should (equal "test-name"
-                 (ly-switch-extension "test-name.abc" ""))))
+                 (org-babel-lilypond-switch-extension "test-name.abc" ""))))
 
 (ert-deftest ob-lilypond/ly-switch-extension-with-paths ()
   (should (equal "/some/path/to/test-name.xyz"
-                  (ly-switch-extension "/some/path/to/test-name" ".xyz"))))
+                  (org-babel-lilypond-switch-extension "/some/path/to/test-name" ".xyz"))))
 
 (ert-deftest ob-lilypond/ly-get-header-args ()
   (should (equal '((:tangle . "yes")
@@ -368,20 +320,20 @@
                    (:results . "silent")
                    (:cache . "yes")
                    (:comments . "yes"))
-                 (ly-set-header-args t)))
+                 (org-babel-lilypond-set-header-args t)))
   (should (equal '((:results . "file")
                    (:exports . "results"))
-                 (ly-set-header-args nil))))
+                 (org-babel-lilypond-set-header-args nil))))
 
 (ert-deftest ob-lilypond/ly-set-header-args ()
-  (ly-set-header-args t)
+  (org-babel-lilypond-set-header-args t)
   (should (equal '((:tangle . "yes")
                    (:noweb . "yes")
                    (:results . "silent")
                    (:cache . "yes")
                    (:comments . "yes"))
                  org-babel-default-header-args:lilypond))
-  (ly-set-header-args nil)
+  (org-babel-lilypond-set-header-args nil)
   (should (equal '((:results . "file")
                    (:exports . "results"))
                  org-babel-default-header-args:lilypond)))
-- 
2.0.4


[-- Attachment #3: Type: text/plain, Size: 216 bytes --]


Comments welcome.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for KORG EX-800 and Poly-800MkII V0.9:
http://Synth.Stromeko.net/Downloads.html#KorgSDada

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: ob-lilypond code cleanup
  2014-08-17 10:10 ob-lilypond code cleanup Achim Gratz
@ 2014-08-18 11:17 ` Nicolas Goaziou
  2014-08-18 17:32   ` Achim Gratz
  2014-08-20 20:28   ` Achim Gratz
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2014-08-18 11:17 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode

Hello,

Achim Gratz <Stromeko@nexgo.de> writes:

> Triggered by the discussion about it, I've looked at ob-lilypond and
> found that it should be cleaned up a bit.  The defvars holding the
> various commands should really be defcustoms, but I've ran out of time
> for now.  If anybody thinks this should go to maint please say so,
> otherwise I will commit on master.

FWIW, I think prefix conformance should go to maint.

Also, you shouldn't use `pcase' as Org preserves compatibility with
Emacs 23.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ob-lilypond code cleanup
  2014-08-18 11:17 ` Nicolas Goaziou
@ 2014-08-18 17:32   ` Achim Gratz
  2014-08-18 20:01     ` Achim Gratz
  2014-08-20 20:28   ` Achim Gratz
  1 sibling, 1 reply; 5+ messages in thread
From: Achim Gratz @ 2014-08-18 17:32 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou writes:
> FWIW, I think prefix conformance should go to maint.

OK.

> Also, you shouldn't use `pcase' as Org preserves compatibility with
> Emacs 23.

Thanks for the reminder.  In any case, these will need to become
defcustoms as well.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ob-lilypond code cleanup
  2014-08-18 17:32   ` Achim Gratz
@ 2014-08-18 20:01     ` Achim Gratz
  0 siblings, 0 replies; 5+ messages in thread
From: Achim Gratz @ 2014-08-18 20:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 206 bytes --]

Achim Gratz writes:
> Thanks for the reminder.  In any case, these will need to become
> defcustoms as well.

Improved patch now with defcustom.  I hope I did get that defcustom
stuff right, please check.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-lilypond-Code-cleanup.patch --]
[-- Type: text/x-patch, Size: 40060 bytes --]

From 35c3be896c159fcd9fb727b39273750fc0264592 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Sun, 17 Aug 2014 10:29:24 +0200
Subject: [PATCH] ob-lilypond: Code cleanup

* lisp/ob-lilypond.el: Change ly- prefix to org-babel-lilypond
  throughout.
  (ly-OSX-ly-path, ly-OSX-pdf-path, ly-OSX-midi-path, ly-nix-ly-path,
  ly-nix-pdf-path, ly-nix-midi-path, ly-w32-ly-path, ly-w32-pdf-path,
  ly-w32-midi-path, ly-determine-ly-path, ly-determine-pdf-path,
  ly-determine-midi-path): Remove.
  (org-babel-lilypond-ly-command, org-babel-lilypond-midi-command,
  org-babel-lilypond-pdf-command): Replacement for removed variables
  and functions.  Adapt all calls to the removed functions to use
  these variables instead.
  (org-babel-lilypond-commands): New defcustom for setting up
  the *-command variables.  Keep different defaults for different
  systems as the original code did to avoid tripping up unsuspecting
  users.
  (org-babel-lilypond-execute-tangled-ly,
  org-babel-lilypond-check-for-compile-error): Revert conditions to
  avoid superfluous forms.  Remove unused return values.
* testing/lisp/test-ob-lilypond.el: Change ly- prefix to
  org-babel-lilypond throughout.  Do not test for removed variables
  and replace removed function calls with the appropriate variable
  content.
---
 lisp/ob-lilypond.el              | 284 ++++++++++++++++++-------------------
 testing/lisp/test-ob-lilypond.el | 292 ++++++++++++++++-----------------------
 2 files changed, 256 insertions(+), 320 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index fbfac88..43433a3 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -41,62 +41,82 @@ (defalias 'lilypond-mode 'LilyPond-mode)
 (defvar org-babel-default-header-args:lilypond '()
   "Default header arguments for lilypond code blocks.
 NOTE: The arguments are determined at lilypond compile time.
-See (ly-set-header-args)")
+See (org-babel-lilypond-set-header-args)")
 
-(defvar ly-compile-post-tangle t
+(defvar org-babel-lilypond-compile-post-tangle t
   "Following the org-babel-tangle (C-c C-v t) command,
-ly-compile-post-tangle determines whether ob-lilypond should
+org-babel-lilypond-compile-post-tangle determines whether ob-lilypond should
 automatically attempt to compile the resultant tangled file.
 If the value is nil, no automated compilation takes place.
 Default value is t")
 
-(defvar ly-display-pdf-post-tangle t
+(defvar org-babel-lilypond-display-pdf-post-tangle t
   "Following a successful LilyPond compilation
-ly-display-pdf-post-tangle determines whether to automate the
+org-babel-lilypond-display-pdf-post-tangle determines whether to automate the
 drawing / redrawing of the resultant pdf.  If the value is nil,
 the pdf is not automatically redrawn.  Default value is t")
 
-(defvar ly-play-midi-post-tangle t
+(defvar org-babel-lilypond-play-midi-post-tangle t
   "Following a successful LilyPond compilation
-ly-play-midi-post-tangle determines whether to automate the
+org-babel-lilypond-play-midi-post-tangle determines whether to automate the
 playing of the resultant midi file.  If the value is nil,
 the midi file is not automatically played.  Default value is t")
 
-(defvar ly-OSX-ly-path
-  "/Applications/lilypond.app/Contents/Resources/bin/lilypond")
-(defvar ly-OSX-pdf-path "open")
-(defvar ly-OSX-midi-path "open")
-
-(defvar ly-nix-ly-path "/usr/bin/lilypond")
-(defvar ly-nix-pdf-path "evince")
-(defvar ly-nix-midi-path "timidity")
-
-(defvar ly-w32-ly-path "lilypond")
-(defvar ly-w32-pdf-path "")
-(defvar ly-w32-midi-path "")
-
-(defvar ly-gen-png nil
+(defconst org-babel-lilypond-ly-command
+  "Command to execute lilypond on your system.")
+(defconst org-babel-lilypond-pdf-command
+  "Command to show a PDF file on your system.")
+(defconst org-babel-lilypond-midi-command
+  "Command to play a MIDI file on your system.")
+(defcustom org-babel-lilypond-commands
+  (cond
+   ((eq system-type 'darwin)
+    '("/Applications/lilypond.app/Contents/Resources/bin/lilypond" "open" "open"))
+   ((eq system-type 'windows-nt)
+    '("lilypond" "" ""))
+   (t
+    '("lilypond" "xdg-open" "xdg-open")))
+  "Commands to run lilypond and view or play the results.
+These should be executables that take a filename as an argument.
+On some system it is possible to specify the filename directly
+and the viewer or player will be determined from the file type;
+you can leave the string empty on this case."
+  :group 'org-babel
+  :type '(list
+	  (string :tag "Lilypond   ")
+	  (string :tag "PDF Viewer ")
+	  (string :tag "MIDI Player"))
+  :version "24.3"
+  :package-version '(Org . "8.2.7")
+  :set
+  (lambda (symbol value)
+    (setq
+     org-babel-lilypond-ly-command   (nth 0 value)
+     org-babel-lilypond-pdf-command  (nth 1 value)
+     org-babel-lilypond-midi-command (nth 2 value))))
+
+(defvar org-babel-lilypond-gen-png nil
   "Image generation (png) can be turned on by default by setting
-LY-GEN-PNG to t")
+ORG-BABEL-LILYPOND-GEN-PNG to t")
 
-(defvar ly-gen-svg nil
+(defvar org-babel-lilypond-gen-svg nil
   "Image generation (SVG) can be turned on by default by setting
-LY-GEN-SVG to t")
+ORG-BABEL-LILYPOND-GEN-SVG to t")
 
-(defvar ly-gen-html nil
+(defvar org-babel-lilypond-gen-html nil
   "HTML generation can be turned on by default by setting
-LY-GEN-HTML to t")
+ORG-BABEL-LILYPOND-GEN-HTML to t")
 
-(defvar ly-gen-pdf nil
+(defvar org-babel-lilypond-gen-pdf nil
   "PDF generation can be turned on by default by setting
-LY-GEN-PDF to t")
+ORG-BABEL-LILYPOND-GEN-PDF to t")
 
-(defvar ly-use-eps nil
+(defvar org-babel-lilypond-use-eps nil
   "You can force the compiler to use the EPS backend by setting
-LY-USE-EPS to t")
+ORG-BABEL-LILYPOND-USE-EPS to t")
 
-(defvar ly-arrange-mode nil
-  "Arrange mode is turned on by setting LY-ARRANGE-MODE
+(defvar org-babel-lilypond-arrange-mode nil
+  "Arrange mode is turned on by setting ORG-BABEL-LILYPOND-ARRANGE-MODE
 to t.  In Arrange mode the following settings are altered
 from default...
 :tangle yes,    :noweb yes
@@ -125,20 +145,20 @@ (defun org-babel-execute:lilypond (body params)
 1. Attempt to execute lilypond block according to header settings
   (This is the default basic mode)
 2. Tangle all lilypond blocks and process the result (arrange mode)"
-  (ly-set-header-args ly-arrange-mode)
-  (if ly-arrange-mode
-      (ly-tangle)
-    (ly-process-basic body params)))
+  (org-babel-lilypond-set-header-args org-babel-lilypond-arrange-mode)
+  (if org-babel-lilypond-arrange-mode
+      (org-babel-lilypond-tangle)
+    (org-babel-lilypond-process-basic body params)))
 
-(defun ly-tangle ()
+(defun org-babel-lilypond-tangle ()
   "ob-lilypond specific tangle, attempts to invoke
 =ly-execute-tangled-ly= if tangle is successful.  Also passes
 specific arguments to =org-babel-tangle="
   (interactive)
   (if (org-babel-tangle nil "yes" "lilypond")
-      (ly-execute-tangled-ly) nil))
+      (org-babel-lilypond-execute-tangled-ly) nil))
 
-(defun ly-process-basic (body params)
+(defun org-babel-lilypond-process-basic (body params)
   "Execute a lilypond block in basic mode."
   (let* ((result-params (cdr (assoc :result-params params)))
 	 (out-file (cdr (assoc :file params)))
@@ -150,7 +170,7 @@ (defun ly-process-basic (body params)
       (insert (org-babel-expand-body:generic body params)))
     (org-babel-eval
      (concat
-      (ly-determine-ly-path)
+      org-babel-lilypond-ly-command
       " -dbackend=eps "
       "-dno-gs-load-fonts "
       "-dinclude-eps-fonts "
@@ -169,45 +189,43 @@ (defun org-babel-prep-session:lilypond (session params)
   "Return an error because LilyPond exporter does not support sessions."
   (error "Sorry, LilyPond does not currently support sessions!"))
 
-(defun ly-execute-tangled-ly ()
+(defun org-babel-lilypond-execute-tangled-ly ()
   "Compile result of block tangle with lilypond.
 If error in compilation, attempt to mark the error in lilypond org file"
-  (when ly-compile-post-tangle
-    (let ((ly-tangled-file (ly-switch-extension
+  (when org-babel-lilypond-compile-post-tangle
+    (let ((org-babel-lilypond-tangled-file (org-babel-lilypond-switch-extension
                             (buffer-file-name) ".lilypond"))
-          (ly-temp-file (ly-switch-extension
+          (org-babel-lilypond-temp-file (org-babel-lilypond-switch-extension
                          (buffer-file-name) ".ly")))
-      (if (file-exists-p ly-tangled-file)
-          (progn
-            (when (file-exists-p ly-temp-file)
-              (delete-file ly-temp-file))
-            (rename-file ly-tangled-file
-                         ly-temp-file))
-        (error "Error: Tangle Failed!") t)
+      (if (not (file-exists-p org-babel-lilypond-tangled-file))
+	  (error "Error: Tangle Failed!")
+	(when (file-exists-p org-babel-lilypond-temp-file)
+	  (delete-file org-babel-lilypond-temp-file))
+	(rename-file org-babel-lilypond-tangled-file
+		     org-babel-lilypond-temp-file))
       (switch-to-buffer-other-window "*lilypond*")
       (erase-buffer)
-      (ly-compile-lilyfile ly-temp-file)
+      (org-babel-lilypond-compile-lilyfile org-babel-lilypond-temp-file)
       (goto-char (point-min))
-      (if (not (ly-check-for-compile-error ly-temp-file))
-          (progn
-            (other-window -1)
-            (ly-attempt-to-open-pdf ly-temp-file)
-            (ly-attempt-to-play-midi ly-temp-file))
-        (error "Error in Compilation!")))) nil)
-
-(defun ly-compile-lilyfile (file-name &optional test)
+      (if (org-babel-lilypond-check-for-compile-error org-babel-lilypond-temp-file)
+	  (error "Error in Compilation!")
+	(other-window -1)
+	(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
+	(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)))))
+
+(defun org-babel-lilypond-compile-lilyfile (file-name &optional test)
   "Compile lilypond file and check for compile errors
 FILE-NAME is full path to lilypond (.ly) file"
   (message "Compiling LilyPond...")
-  (let ((arg-1 (ly-determine-ly-path)) ;program
+  (let ((arg-1 org-babel-lilypond-ly-command) ;program
         (arg-2 nil)                    ;infile
         (arg-3 "*lilypond*")           ;buffer
 	(arg-4 t)                      ;display
-	(arg-5 (if ly-gen-png  "--png"  "")) ;&rest...
-	(arg-6 (if ly-gen-html "--html" ""))
-        (arg-7 (if ly-gen-pdf "--pdf" ""))
-        (arg-8 (if ly-use-eps  "-dbackend=eps" ""))
-        (arg-9 (if ly-gen-svg  "-dbackend=svg" ""))
+	(arg-5 (if org-babel-lilypond-gen-png  "--png"  "")) ;&rest...
+	(arg-6 (if org-babel-lilypond-gen-html "--html" ""))
+        (arg-7 (if org-babel-lilypond-gen-pdf "--pdf" ""))
+        (arg-8 (if org-babel-lilypond-use-eps  "-dbackend=eps" ""))
+        (arg-9 (if org-babel-lilypond-gen-svg  "-dbackend=svg" ""))
         (arg-10 (concat "--output=" (file-name-sans-extension file-name)))
         (arg-11 file-name))
     (if test
@@ -217,7 +235,7 @@ (defun ly-compile-lilyfile (file-name &optional test)
        arg-1 arg-2 arg-3 arg-4 arg-5 arg-6
        arg-7 arg-8 arg-9 arg-10 arg-11))))
 
-(defun ly-check-for-compile-error (file-name &optional test)
+(defun org-babel-lilypond-check-for-compile-error (file-name &optional test)
   "Check for compile error.
 This is performed by parsing the *lilypond* buffer
 containing the output message from the compilation.
@@ -225,27 +243,26 @@ (defun ly-check-for-compile-error (file-name &optional test)
 If TEST is t just return nil if no error found, and pass
 nil as file-name since it is unused in this context"
   (let ((is-error (search-forward "error:" nil t)))
-    (if (not test)
-        (if (not is-error)
-            nil
-          (ly-process-compile-error file-name))
-      is-error)))
+    (if test
+	is-error
+      (when is-error
+	(org-babel-lilypond-process-compile-error file-name)))))
 
-(defun ly-process-compile-error (file-name)
+(defun org-babel-lilypond-process-compile-error (file-name)
   "Process the compilation error that has occurred.
 FILE-NAME is full path to lilypond file"
-  (let ((line-num (ly-parse-line-num)))
-    (let ((error-lines (ly-parse-error-line file-name line-num)))
-      (ly-mark-error-line file-name error-lines)
+  (let ((line-num (org-babel-lilypond-parse-line-num)))
+    (let ((error-lines (org-babel-lilypond-parse-error-line file-name line-num)))
+      (org-babel-lilypond-mark-error-line file-name error-lines)
       (error "Error: Compilation Failed!"))))
 
-(defun ly-mark-error-line (file-name line)
+(defun org-babel-lilypond-mark-error-line (file-name line)
   "Mark the erroneous lines in the lilypond org buffer.
 FILE-NAME is full path to lilypond file.
 LINE is the erroneous line"
   (switch-to-buffer-other-window
    (concat (file-name-nondirectory
-            (ly-switch-extension file-name ".org"))))
+            (org-babel-lilypond-switch-extension file-name ".org"))))
   (let ((temp (point)))
     (goto-char (point-min))
     (setq case-fold-search nil)
@@ -256,7 +273,7 @@ (defun ly-mark-error-line (file-name line)
           (goto-char (- (point) (length line))))
       (goto-char temp))))
 
-(defun ly-parse-line-num (&optional buffer)
+(defun org-babel-lilypond-parse-line-num (&optional buffer)
   "Extract error line number."
   (when buffer
     (set-buffer buffer))
@@ -278,12 +295,12 @@ (defun ly-parse-line-num (&optional buffer)
               nil)))
       nil)))
 
-(defun ly-parse-error-line (file-name lineNo)
+(defun org-babel-lilypond-parse-error-line (file-name lineNo)
   "Extract the erroneous line from the tangled .ly file
 FILE-NAME is full path to lilypond file.
 LINENO is the number of the erroneous line"
   (with-temp-buffer
-    (insert-file-contents (ly-switch-extension file-name ".ly")
+    (insert-file-contents (org-babel-lilypond-switch-extension file-name ".ly")
 			  nil nil nil t)
     (if (> lineNo 0)
 	(progn
@@ -292,128 +309,95 @@ (defun ly-parse-error-line (file-name lineNo)
 	  (buffer-substring (point) (point-at-eol)))
       nil)))
 
-(defun ly-attempt-to-open-pdf (file-name &optional test)
+(defun org-babel-lilypond-attempt-to-open-pdf (file-name &optional test)
   "Attempt to display the generated pdf file
 FILE-NAME is full path to lilypond file
 If TEST is non-nil, the shell command is returned and is not run"
-  (when ly-display-pdf-post-tangle
-    (let ((pdf-file (ly-switch-extension file-name ".pdf")))
+  (when org-babel-lilypond-display-pdf-post-tangle
+    (let ((pdf-file (org-babel-lilypond-switch-extension file-name ".pdf")))
       (if (file-exists-p pdf-file)
           (let ((cmd-string
-                 (concat (ly-determine-pdf-path) " " pdf-file)))
+                 (concat org-babel-lilypond-pdf-command " " pdf-file)))
             (if test
                 cmd-string
 	      (start-process
 	       "\"Audition pdf\""
 	       "*lilypond*"
-	       (ly-determine-pdf-path)
+	       org-babel-lilypond-pdf-command
 	       pdf-file)))
 	(message  "No pdf file generated so can't display!")))))
 
-(defun ly-attempt-to-play-midi (file-name &optional test)
+(defun org-babel-lilypond-attempt-to-play-midi (file-name &optional test)
   "Attempt to play the generated MIDI file
 FILE-NAME is full path to lilypond file
 If TEST is non-nil, the shell command is returned and is not run"
-  (when ly-play-midi-post-tangle
-    (let ((midi-file (ly-switch-extension file-name ".midi")))
+  (when org-babel-lilypond-play-midi-post-tangle
+    (let ((midi-file (org-babel-lilypond-switch-extension file-name ".midi")))
       (if (file-exists-p midi-file)
           (let ((cmd-string
-                 (concat (ly-determine-midi-path) " " midi-file)))
+                 (concat org-babel-lilypond-midi-command " " midi-file)))
             (if test
                 cmd-string
               (start-process
                "\"Audition midi\""
                "*lilypond*"
-               (ly-determine-midi-path)
+               org-babel-lilypond-midi-command
                midi-file)))
         (message "No midi file generated so can't play!")))))
 
-(defun ly-determine-ly-path (&optional test)
-  "Return correct path to ly binary depending on OS
-If TEST is non-nil, it contains a simulation of the OS for test purposes"
-  (let ((sys-type
-         (or test system-type)))
-    (cond ((string= sys-type  "darwin")
-           ly-OSX-ly-path)
-          ((string= sys-type "windows-nt")
-           ly-w32-ly-path)
-          (t ly-nix-ly-path))))
-
-(defun ly-determine-pdf-path (&optional test)
-  "Return correct path to pdf viewer depending on OS
-If TEST is non-nil, it contains a simulation of the OS for test purposes"
-  (let ((sys-type
-         (or test system-type)))
-    (cond ((string= sys-type  "darwin")
-           ly-OSX-pdf-path)
-          ((string= sys-type "windows-nt")
-           ly-w32-pdf-path)
-          (t ly-nix-pdf-path))))
-
-(defun ly-determine-midi-path (&optional test)
-  "Return correct path to midi player depending on OS
-If TEST is non-nil, it contains a simulation of the OS for test purposes"
-  (let ((sys-type
-         (or test test system-type)))
-    (cond ((string= sys-type  "darwin")
-           ly-OSX-midi-path)
-          ((string= sys-type "windows-nt")
-           ly-w32-midi-path)
-          (t ly-nix-midi-path))))
-
-(defun ly-toggle-midi-play ()
+(defun org-babel-lilypond-toggle-midi-play ()
   "Toggle whether midi will be played following a successful compilation."
   (interactive)
-  (setq ly-play-midi-post-tangle
-        (not ly-play-midi-post-tangle))
+  (setq org-babel-lilypond-play-midi-post-tangle
+        (not org-babel-lilypond-play-midi-post-tangle))
   (message (concat "Post-Tangle MIDI play has been "
-                   (if ly-play-midi-post-tangle
+                   (if org-babel-lilypond-play-midi-post-tangle
                        "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-pdf-display ()
+(defun org-babel-lilypond-toggle-pdf-display ()
   "Toggle whether pdf will be displayed following a successful compilation."
   (interactive)
-  (setq ly-display-pdf-post-tangle
-        (not ly-display-pdf-post-tangle))
+  (setq org-babel-lilypond-display-pdf-post-tangle
+        (not org-babel-lilypond-display-pdf-post-tangle))
   (message (concat "Post-Tangle PDF display has been "
-                   (if ly-display-pdf-post-tangle
+                   (if org-babel-lilypond-display-pdf-post-tangle
                        "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-png-generation ()
+(defun org-babel-lilypond-toggle-png-generation ()
   "Toggle whether png image will be generated by compilation."
   (interactive)
-  (setq ly-gen-png (not ly-gen-png))
+  (setq org-babel-lilypond-gen-png (not org-babel-lilypond-gen-png))
   (message (concat "PNG image generation has been "
-                   (if ly-gen-png "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-gen-png "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-html-generation ()
+(defun org-babel-lilypond-toggle-html-generation ()
   "Toggle whether html will be generated by compilation."
   (interactive)
-  (setq ly-gen-html (not ly-gen-html))
+  (setq org-babel-lilypond-gen-html (not org-babel-lilypond-gen-html))
   (message (concat "HTML generation has been "
-                   (if ly-gen-html "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-gen-html "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-pdf-generation ()
+(defun org-babel-lilypond-toggle-pdf-generation ()
   "Toggle whether pdf will be generated by compilation."
   (interactive)
-  (setq ly-gen-pdf (not ly-gen-pdf))
+  (setq org-babel-lilypond-gen-pdf (not org-babel-lilypond-gen-pdf))
   (message (concat "PDF generation has been "
-                   (if ly-gen-pdf "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-gen-pdf "ENABLED." "DISABLED."))))
 
-(defun ly-toggle-arrange-mode ()
+(defun org-babel-lilypond-toggle-arrange-mode ()
   "Toggle whether in Arrange mode or Basic mode."
   (interactive)
-  (setq ly-arrange-mode
-        (not ly-arrange-mode))
+  (setq org-babel-lilypond-arrange-mode
+        (not org-babel-lilypond-arrange-mode))
   (message (concat "Arrange mode has been "
-                   (if ly-arrange-mode "ENABLED." "DISABLED."))))
+                   (if org-babel-lilypond-arrange-mode "ENABLED." "DISABLED."))))
 
-(defun ly-switch-extension (file-name ext)
+(defun org-babel-lilypond-switch-extension (file-name ext)
   "Utility command to swap current FILE-NAME extension with EXT"
   (concat (file-name-sans-extension
            file-name) ext))
 
-(defun ly-get-header-args (mode)
+(defun org-babel-lilypond-get-header-args (mode)
   "Default arguments to use when evaluating a lilypond
 source block.  These depend upon whether we are in arrange
 mode i.e.  ARRANGE-MODE is t"
@@ -427,11 +411,11 @@ (defun ly-get-header-args (mode)
          '((:results . "file")
            (:exports . "results")))))
 
-(defun ly-set-header-args (mode)
+(defun org-babel-lilypond-set-header-args (mode)
   "Set org-babel-default-header-args:lilypond
-dependent on LY-ARRANGE-MODE"
+dependent on ORG-BABEL-LILYPOND-ARRANGE-MODE"
   (setq org-babel-default-header-args:lilypond
-        (ly-get-header-args mode)))
+        (org-babel-lilypond-get-header-args mode)))
 
 (provide 'ob-lilypond)
 
diff --git a/testing/lisp/test-ob-lilypond.el b/testing/lisp/test-ob-lilypond.el
index abf6a48..6409e27 100644
--- a/testing/lisp/test-ob-lilypond.el
+++ b/testing/lisp/test-ob-lilypond.el
@@ -24,7 +24,7 @@
 
 (save-excursion
   (set-buffer (get-buffer-create "test-ob-lilypond.el"))
-  (setq ly-here
+  (setq org-babel-lilypond-here
         (file-name-directory
          (or load-file-name (buffer-file-name)))))
 
@@ -52,81 +52,57 @@
 
 (ert-deftest ob-lilypond/ly-compile-lilyfile ()
   (should (equal
-           `(,(ly-determine-ly-path)    ;program
+           `(,org-babel-lilypond-ly-command    ;program
              nil                        ;infile
              "*lilypond*"               ;buffer
              t                          ;display
-             ,(if ly-gen-png  "--png"  "") ;&rest...
-             ,(if ly-gen-html "--html" "")
-             ,(if ly-gen-pdf "--pdf" "")
-             ,(if ly-use-eps  "-dbackend=eps" "")
-             ,(if ly-gen-svg  "-dbackend=svg" "")
+             ,(if org-babel-lilypond-gen-png  "--png"  "") ;&rest...
+             ,(if org-babel-lilypond-gen-html "--html" "")
+             ,(if org-babel-lilypond-gen-pdf "--pdf" "")
+             ,(if org-babel-lilypond-use-eps  "-dbackend=eps" "")
+             ,(if org-babel-lilypond-gen-svg  "-dbackend=svg" "")
              "--output=test-file"
              "test-file.ly")
-           (ly-compile-lilyfile "test-file.ly" t))))
+           (org-babel-lilypond-compile-lilyfile "test-file.ly" t))))
 
 (ert-deftest ob-lilypond/ly-compile-post-tangle ()
-  (should (boundp 'ly-compile-post-tangle)))
+  (should (boundp 'org-babel-lilypond-compile-post-tangle)))
 
 (ert-deftest ob-lilypond/ly-display-pdf-post-tangle ()
-  (should (boundp 'ly-display-pdf-post-tangle)))
+  (should (boundp 'org-babel-lilypond-display-pdf-post-tangle)))
 
 (ert-deftest ob-lilypond/ly-play-midi-post-tangle ()
-  (should (boundp 'ly-play-midi-post-tangle)))
+  (should (boundp 'org-babel-lilypond-play-midi-post-tangle)))
 
-(ert-deftest ob-lilypond/ly-OSX-ly-path ()
-  (should (boundp 'ly-OSX-ly-path))
-  (should (stringp ly-OSX-ly-path)))
+(ert-deftest ob-lilypond/ly-ly-command ()
+  (should (boundp 'org-babel-lilypond-ly-command))
+  (should (stringp org-babel-lilypond-ly-command)))
 
-(ert-deftest ob-lilypond/ly-OSX-pdf-path ()
-  (should (boundp 'ly-OSX-pdf-path))
-  (should (stringp ly-OSX-pdf-path)))
+(ert-deftest ob-lilypond/ly-pdf-command ()
+  (should (boundp 'org-babel-lilypond-pdf-command))
+  (should (stringp org-babel-lilypond-pdf-command)))
 
-(ert-deftest ob-lilypond/ly-OSX-midi-path ()
-  (should (boundp 'ly-OSX-midi-path))
-  (should (stringp ly-OSX-midi-path)))
-
-(ert-deftest ob-lilypond/ly-nix-ly-path ()
-  (should (boundp 'ly-nix-ly-path))
-  (should (stringp ly-nix-ly-path)))
-
-(ert-deftest ob-lilypond/ly-nix-pdf-path ()
-  (should (boundp 'ly-nix-pdf-path))
-  (should (stringp ly-nix-pdf-path)))
-
-(ert-deftest ob-lilypond/ly-nix-midi-path ()
-  (should (boundp 'ly-nix-midi-path))
-  (should (stringp ly-nix-midi-path)))
-
-(ert-deftest ob-lilypond/ly-w32-ly-path ()
-  (should (boundp 'ly-w32-ly-path))
-  (should (stringp ly-w32-ly-path)))
-
-(ert-deftest ob-lilypond/ly-w32-pdf-path ()
-  (should (boundp 'ly-w32-pdf-path))
-  (should (stringp ly-w32-pdf-path)))
-
-(ert-deftest ob-lilypond/ly-w32-midi-path ()
-  (should (boundp 'ly-w32-midi-path))
-  (should (stringp ly-w32-midi-path)))
+(ert-deftest ob-lilypond/ly-midi-command ()
+  (should (boundp 'org-babel-lilypond-midi-command))
+  (should (stringp org-babel-lilypond-midi-command)))
 
 (ert-deftest ob-lilypond/ly-gen-png ()
-  (should (boundp 'ly-gen-png)))
+  (should (boundp 'org-babel-lilypond-gen-png)))
 
 (ert-deftest ob-lilypond/ly-gen-svg ()
-  (should (boundp 'ly-gen-svg)))
+  (should (boundp 'org-babel-lilypond-gen-svg)))
 
 (ert-deftest ob-lilypond/ly-gen-html ()
-  (should (boundp 'ly-gen-html)))
+  (should (boundp 'org-babel-lilypond-gen-html)))
 
 (ert-deftest ob-lilypond/ly-gen-html ()
-  (should (boundp 'ly-gen-pdf)))
+  (should (boundp 'org-babel-lilypond-gen-pdf)))
 
 (ert-deftest ob-lilypond/use-eps ()
-  (should (boundp 'ly-use-eps)))
+  (should (boundp 'org-babel-lilypond-use-eps)))
 
 (ert-deftest ob-lilypond/ly-arrange-mode ()
-  (should (boundp 'ly-arrange-mode)))
+  (should (boundp 'org-babel-lilypond-arrange-mode)))
 
 ;; (ert-deftest ob-lilypond/org-babel-default-header-args:lilypond ()
 ;;   (should (equal  '((:tangle . "yes")
@@ -140,32 +116,32 @@
   (should (equal "This is a test"
                  (org-babel-expand-body:lilypond "This is a test" ()))))
 
-;;TODO (ert-deftest ly-test-org-babel-execute:lilypond ())
+;;TODO (ert-deftest org-babel-lilypond-test-org-babel-execute:lilypond ())
 (ert-deftest ob-lilypond/ly-check-for-compile-error ()
   (set-buffer (get-buffer-create "*lilypond*"))
   (erase-buffer)
-  (should (not (ly-check-for-compile-error nil t)))
-  (insert-file-contents (concat ly-here
+  (should (not (org-babel-lilypond-check-for-compile-error nil t)))
+  (insert-file-contents (concat org-babel-lilypond-here
                                 "../examples/ob-lilypond-test.error")
                         nil nil nil t)
   (goto-char (point-min))
-  (should (ly-check-for-compile-error nil t))
+  (should (org-babel-lilypond-check-for-compile-error nil t))
   (kill-buffer "*lilypond*"))
 
 (ert-deftest ob-lilypond/ly-process-compile-error ()
   (find-file-other-window (concat
-                           ly-here
+                           org-babel-lilypond-here
                            "../examples/ob-lilypond-broken.org"))
   (set-buffer (get-buffer-create "*lilypond*"))
   (insert-file-contents (concat
-                         ly-here
+                         org-babel-lilypond-here
                          "../examples/ob-lilypond-test.error")
                         nil nil nil t)
   (goto-char (point-min))
   (search-forward "error:" nil t)
   (should-error
-   (ly-process-compile-error (concat
-                              ly-here
+   (org-babel-lilypond-process-compile-error (concat
+                              org-babel-lilypond-here
                               "../examples/ob-lilypond-broken.ly"))
    :type 'error)
   (set-buffer "ob-lilypond-broken.org")
@@ -177,13 +153,13 @@
 
 (ert-deftest ob-lilypond/ly-mark-error-line ()
   (let ((file-name (concat
-                    ly-here
+                    org-babel-lilypond-here
                     "../examples/ob-lilypond-broken.org"))
         (expected-point-min 198)
         (expected-point-max 205)
         (line "line 20"))
     (find-file-other-window file-name)
-    (ly-mark-error-line file-name line)
+    (org-babel-lilypond-mark-error-line file-name line)
     (should (equal expected-point-min (point)))
 
     (exchange-point-and-mark)
@@ -193,174 +169,150 @@
 (ert-deftest ob-lilypond/ly-parse-line-num ()
   (with-temp-buffer
     (insert-file-contents (concat
-                           ly-here
+                           org-babel-lilypond-here
                            "../examples/ob-lilypond-test.error")
                           nil nil nil t)
     (goto-char (point-min))
     (search-forward "error:")
-    (should (equal 25 (ly-parse-line-num (current-buffer))))))
+    (should (equal 25 (org-babel-lilypond-parse-line-num (current-buffer))))))
 
 (ert-deftest ob-lilypond/ly-parse-error-line ()
-  (let ((ly-file (concat
-                  ly-here
+  (let ((org-babel-lilypond-file (concat
+                  org-babel-lilypond-here
                   "../examples/ob-lilypond-broken.ly")))
     (should (equal "line 20"
-                   (ly-parse-error-line ly-file 20)))
-    (should (not (ly-parse-error-line ly-file 0)))))
+                   (org-babel-lilypond-parse-error-line org-babel-lilypond-file 20)))
+    (should (not (org-babel-lilypond-parse-error-line org-babel-lilypond-file 0)))))
 
 (ert-deftest ob-lilypond/ly-attempt-to-open-pdf ()
-  (let ((post-tangle ly-display-pdf-post-tangle)
-        (ly-file (concat
-                  ly-here
+  (let ((post-tangle org-babel-lilypond-display-pdf-post-tangle)
+        (org-babel-lilypond-file (concat
+                  org-babel-lilypond-here
                   "../examples/ob-lilypond-test.ly"))
         (pdf-file (concat
-                   ly-here
+                   org-babel-lilypond-here
                    "../examples/ob-lilypond-test.pdf")))
-    (setq ly-display-pdf-post-tangle t)
+    (setq org-babel-lilypond-display-pdf-post-tangle t)
     (when (not (file-exists-p pdf-file))
       (set-buffer (get-buffer-create (file-name-nondirectory pdf-file)))
       (write-file pdf-file))
     (should (equal
              (concat
-              (ly-determine-pdf-path) " " pdf-file)
-             (ly-attempt-to-open-pdf ly-file t)))
+              org-babel-lilypond-pdf-command " " pdf-file)
+             (org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-file t)))
     (delete-file pdf-file)
     (kill-buffer (file-name-nondirectory pdf-file))
     (should (equal
              "No pdf file generated so can't display!"
-             (ly-attempt-to-open-pdf pdf-file)))
-    (setq ly-display-pdf-post-tangle post-tangle)))
+             (org-babel-lilypond-attempt-to-open-pdf pdf-file)))
+    (setq org-babel-lilypond-display-pdf-post-tangle post-tangle)))
 
 (ert-deftest ob-lilypond/ly-attempt-to-play-midi ()
-  (let ((post-tangle ly-play-midi-post-tangle)
-        (ly-file (concat
-                  ly-here
+  (let ((post-tangle org-babel-lilypond-play-midi-post-tangle)
+        (org-babel-lilypond-file (concat
+                  org-babel-lilypond-here
                   "../examples/ob-lilypond-test.ly"))
         (midi-file (concat
-                    ly-here
+                    org-babel-lilypond-here
                     "../examples/ob-lilypond-test.midi")))
-    (setq ly-play-midi-post-tangle t)
+    (setq org-babel-lilypond-play-midi-post-tangle t)
     (when (not (file-exists-p midi-file))
       (set-buffer (get-buffer-create (file-name-nondirectory midi-file)))
       (write-file midi-file))
     (should (equal
              (concat
-              (ly-determine-midi-path) " " midi-file)
-             (ly-attempt-to-play-midi ly-file t)))
+              org-babel-lilypond-midi-command " " midi-file)
+             (org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-file t)))
     (delete-file midi-file)
     (kill-buffer (file-name-nondirectory midi-file))
     (should (equal
              "No midi file generated so can't play!"
-             (ly-attempt-to-play-midi midi-file)))
-    (setq ly-play-midi-post-tangle post-tangle)))
-
-(ert-deftest ob-lilypond/ly-determine-ly-path ()
-  (should (equal ly-OSX-ly-path
-                 (ly-determine-ly-path "darwin")))
-  (should (equal ly-w32-ly-path
-                 (ly-determine-ly-path "windows-nt")))
-  (should (equal ly-nix-ly-path
-                 (ly-determine-ly-path "nix"))))
-
-(ert-deftest ob-lilypond/ly-determine-pdf-path ()
-  (should (equal ly-OSX-pdf-path
-                 (ly-determine-pdf-path "darwin")))
-  (should (equal ly-w32-pdf-path
-                 (ly-determine-pdf-path "windows-nt")))
-  (should (equal ly-nix-pdf-path
-                 (ly-determine-pdf-path "nix"))))
-
-(ert-deftest ob-lilypond/ly-determine-midi-path ()
-  (should (equal ly-OSX-midi-path
-                 (ly-determine-midi-path "darwin")))
-  (should (equal ly-w32-midi-path
-                 (ly-determine-midi-path "windows-nt")))
-  (should (equal ly-nix-midi-path
-                 (ly-determine-midi-path "nix"))))
+             (org-babel-lilypond-attempt-to-play-midi midi-file)))
+    (setq org-babel-lilypond-play-midi-post-tangle post-tangle)))
 
 (ert-deftest ob-lilypond/ly-toggle-midi-play-toggles-flag ()
-  (if ly-play-midi-post-tangle
+  (if org-babel-lilypond-play-midi-post-tangle
       (progn
-        (ly-toggle-midi-play)
-         (should (not ly-play-midi-post-tangle))
-        (ly-toggle-midi-play)
-        (should ly-play-midi-post-tangle))
-    (ly-toggle-midi-play)
-    (should ly-play-midi-post-tangle)
-    (ly-toggle-midi-play)
-    (should (not ly-play-midi-post-tangle))))
+        (org-babel-lilypond-toggle-midi-play)
+         (should (not org-babel-lilypond-play-midi-post-tangle))
+        (org-babel-lilypond-toggle-midi-play)
+        (should org-babel-lilypond-play-midi-post-tangle))
+    (org-babel-lilypond-toggle-midi-play)
+    (should org-babel-lilypond-play-midi-post-tangle)
+    (org-babel-lilypond-toggle-midi-play)
+    (should (not org-babel-lilypond-play-midi-post-tangle))))
 
 (ert-deftest ob-lilypond/ly-toggle-pdf-display-toggles-flag ()
-  (if ly-display-pdf-post-tangle
+  (if org-babel-lilypond-display-pdf-post-tangle
       (progn
-        (ly-toggle-pdf-display)
-         (should (not ly-display-pdf-post-tangle))
-        (ly-toggle-pdf-display)
-        (should ly-display-pdf-post-tangle))
-    (ly-toggle-pdf-display)
-    (should ly-display-pdf-post-tangle)
-    (ly-toggle-pdf-display)
-    (should (not ly-display-pdf-post-tangle))))
+        (org-babel-lilypond-toggle-pdf-display)
+         (should (not org-babel-lilypond-display-pdf-post-tangle))
+        (org-babel-lilypond-toggle-pdf-display)
+        (should org-babel-lilypond-display-pdf-post-tangle))
+    (org-babel-lilypond-toggle-pdf-display)
+    (should org-babel-lilypond-display-pdf-post-tangle)
+    (org-babel-lilypond-toggle-pdf-display)
+    (should (not org-babel-lilypond-display-pdf-post-tangle))))
 
 (ert-deftest ob-lilypond/ly-toggle-pdf-generation-toggles-flag ()
-  (if ly-gen-pdf
+  (if org-babel-lilypond-gen-pdf
       (progn
-        (ly-toggle-pdf-generation)
-         (should (not ly-gen-pdf))
-        (ly-toggle-pdf-generation)
-        (should ly-gen-pdf))
-    (ly-toggle-pdf-generation)
-    (should ly-gen-pdf)
-    (ly-toggle-pdf-generation)
-    (should (not ly-gen-pdf))))
+        (org-babel-lilypond-toggle-pdf-generation)
+         (should (not org-babel-lilypond-gen-pdf))
+        (org-babel-lilypond-toggle-pdf-generation)
+        (should org-babel-lilypond-gen-pdf))
+    (org-babel-lilypond-toggle-pdf-generation)
+    (should org-babel-lilypond-gen-pdf)
+    (org-babel-lilypond-toggle-pdf-generation)
+    (should (not org-babel-lilypond-gen-pdf))))
 
 (ert-deftest ob-lilypond/ly-toggle-arrange-mode ()
-  (if ly-arrange-mode
+  (if org-babel-lilypond-arrange-mode
       (progn
-        (ly-toggle-arrange-mode)
-        (should (not ly-arrange-mode))
-        (ly-toggle-arrange-mode)
-        (should ly-arrange-mode))
-    (ly-toggle-arrange-mode)
-    (should ly-arrange-mode)
-    (ly-toggle-arrange-mode)
-    (should (not ly-arrange-mode))))
+        (org-babel-lilypond-toggle-arrange-mode)
+        (should (not org-babel-lilypond-arrange-mode))
+        (org-babel-lilypond-toggle-arrange-mode)
+        (should org-babel-lilypond-arrange-mode))
+    (org-babel-lilypond-toggle-arrange-mode)
+    (should org-babel-lilypond-arrange-mode)
+    (org-babel-lilypond-toggle-arrange-mode)
+    (should (not org-babel-lilypond-arrange-mode))))
 
 (ert-deftest ob-lilypond/ly-toggle-png-generation-toggles-flag ()
-  (if ly-gen-png
+  (if org-babel-lilypond-gen-png
       (progn
-        (ly-toggle-png-generation)
-         (should (not ly-gen-png))
-        (ly-toggle-png-generation)
-        (should ly-gen-png))
-    (ly-toggle-png-generation)
-    (should ly-gen-png)
-    (ly-toggle-png-generation)
-    (should (not ly-gen-png))))
+        (org-babel-lilypond-toggle-png-generation)
+         (should (not org-babel-lilypond-gen-png))
+        (org-babel-lilypond-toggle-png-generation)
+        (should org-babel-lilypond-gen-png))
+    (org-babel-lilypond-toggle-png-generation)
+    (should org-babel-lilypond-gen-png)
+    (org-babel-lilypond-toggle-png-generation)
+    (should (not org-babel-lilypond-gen-png))))
 
 (ert-deftest ob-lilypond/ly-toggle-html-generation-toggles-flag ()
-  (if ly-gen-html
+  (if org-babel-lilypond-gen-html
       (progn
-        (ly-toggle-html-generation)
-         (should (not ly-gen-html))
-        (ly-toggle-html-generation)
-        (should ly-gen-html))
-    (ly-toggle-html-generation)
-    (should ly-gen-html)
-    (ly-toggle-html-generation)
-    (should (not ly-gen-html))))
+        (org-babel-lilypond-toggle-html-generation)
+         (should (not org-babel-lilypond-gen-html))
+        (org-babel-lilypond-toggle-html-generation)
+        (should org-babel-lilypond-gen-html))
+    (org-babel-lilypond-toggle-html-generation)
+    (should org-babel-lilypond-gen-html)
+    (org-babel-lilypond-toggle-html-generation)
+    (should (not org-babel-lilypond-gen-html))))
 
 (ert-deftest ob-lilypond/ly-switch-extension-with-extensions ()
   (should (equal "test-name.xyz"
-                 (ly-switch-extension "test-name" ".xyz")))
+                 (org-babel-lilypond-switch-extension "test-name" ".xyz")))
   (should (equal "test-name.xyz"
-                 (ly-switch-extension "test-name.abc" ".xyz")))
+                 (org-babel-lilypond-switch-extension "test-name.abc" ".xyz")))
   (should (equal "test-name"
-                 (ly-switch-extension "test-name.abc" ""))))
+                 (org-babel-lilypond-switch-extension "test-name.abc" ""))))
 
 (ert-deftest ob-lilypond/ly-switch-extension-with-paths ()
   (should (equal "/some/path/to/test-name.xyz"
-                  (ly-switch-extension "/some/path/to/test-name" ".xyz"))))
+                  (org-babel-lilypond-switch-extension "/some/path/to/test-name" ".xyz"))))
 
 (ert-deftest ob-lilypond/ly-get-header-args ()
   (should (equal '((:tangle . "yes")
@@ -368,20 +320,20 @@
                    (:results . "silent")
                    (:cache . "yes")
                    (:comments . "yes"))
-                 (ly-set-header-args t)))
+                 (org-babel-lilypond-set-header-args t)))
   (should (equal '((:results . "file")
                    (:exports . "results"))
-                 (ly-set-header-args nil))))
+                 (org-babel-lilypond-set-header-args nil))))
 
 (ert-deftest ob-lilypond/ly-set-header-args ()
-  (ly-set-header-args t)
+  (org-babel-lilypond-set-header-args t)
   (should (equal '((:tangle . "yes")
                    (:noweb . "yes")
                    (:results . "silent")
                    (:cache . "yes")
                    (:comments . "yes"))
                  org-babel-default-header-args:lilypond))
-  (ly-set-header-args nil)
+  (org-babel-lilypond-set-header-args nil)
   (should (equal '((:results . "file")
                    (:exports . "results"))
                  org-babel-default-header-args:lilypond)))
-- 
2.0.4


[-- Attachment #3: Type: text/plain, Size: 191 bytes --]



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: ob-lilypond code cleanup
  2014-08-18 11:17 ` Nicolas Goaziou
  2014-08-18 17:32   ` Achim Gratz
@ 2014-08-20 20:28   ` Achim Gratz
  1 sibling, 0 replies; 5+ messages in thread
From: Achim Gratz @ 2014-08-20 20:28 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou writes:
> FWIW, I think prefix conformance should go to maint.

Patch has been split and just the prefix conformance committed to maint
in b8bd2147cb.

Introduction of defcustom, some code cleanups and associated tests
committed to master in 64821bd967.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-20 20:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-17 10:10 ob-lilypond code cleanup Achim Gratz
2014-08-18 11:17 ` Nicolas Goaziou
2014-08-18 17:32   ` Achim Gratz
2014-08-18 20:01     ` Achim Gratz
2014-08-20 20:28   ` Achim Gratz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).