Re: [O] [babel][patch] Make ob-lilypond audition calls asynchronous

2012-03-12 Thread Eric Schulte
Applied, thanks.

Martyn Jago  writes:

> Hi 
>
> A patch to make ob-lilypond audition calls asynchronous (and tests).
>
> Best, Martyn
>
>
> From 2e7cd607cd6dbc25edd5ff9972fbd2528d48416e Mon Sep 17 00:00:00 2001
> From: Martyn Jago 
> Date: Sat, 10 Mar 2012 15:00:57 +
> Subject: [PATCH] Make auditioning of midi and pdf generations asynchronous, 
> and add easy pdf generation.
>
> * lisp/ob-lilypond.el: Make auditioning of midi and pdf asynchronous,
>   and add easy pdf generation in the form of `ly-gen-pdf' variable.
>
> * testing/lisp/test-ob-lilypond.el: Tests for above.
> ---
>  lisp/ob-lilypond.el  |   68 ++---
>  testing/lisp/test-ob-lilypond.el |   22 +++-
>  2 files changed, 68 insertions(+), 22 deletions(-)
>
> diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
> index 0dde0de..fc9a639 100644
> --- a/lisp/ob-lilypond.el
> +++ b/lisp/ob-lilypond.el
> @@ -3,7 +3,7 @@
>  ;; Copyright (C) 2010-2012  Free Software Foundation, Inc.
>  
>  ;; Author: Martyn Jago
> -;; Keywords: babel language, literate programming
> +;; Keywords: babel language, literate programming, music score
>  ;; Homepage: https://github.com/mjago/ob-lilypond
>  
>  ;; This file is part of GNU Emacs.
> @@ -23,10 +23,14 @@
>  
>  ;;; Commentary:
>  
> -;; Installation / usage info, and examples are available at
> -;; https://github.com/mjago/ob-lilypond
> +;; Installation, ob-lilypond documentation, and examples are available at
> +;; http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
> +;;
> +;; Lilypond documentation can be found at
> +;; http://lilypond.org/manuals.html
>  
>  ;;; Code:
> +
>  (require 'ob)
>  (require 'ob-eval)
>  (require 'ob-tangle)
> @@ -37,9 +41,11 @@
>  (add-to-list 'org-babel-tangle-lang-exts '("LilyPond" . "ly"))
>  
>  (defvar org-babel-default-header-args:lilypond '()
> -  "Default header arguments for js code blocks.")
> +  "Default header arguments for lilypond code blocks.
> +NOTE: The arguments are determined at lilypond compile time.
> +See (ly-set-header-args)")
>  
> -(defconst ly-version "0.3"
> +(defconst ly-version "7.6"
>"The version number of the file ob-lilypond.el.")
>  
>  (defvar ly-compile-post-tangle t
> @@ -86,6 +92,10 @@ LY-GEN-SVG to t")
>  "HTML generation can be turned on by default by setting
>  LY-GEN-HTML to t")
>  
> +(defvar ly-gen-pdf nil
> +"PDF generation can be turned on by default by setting
> +LY-GEN-PDF to t")
> +
>  (defvar ly-use-eps nil
>  "You can force the compiler to use the EPS backend by setting
>  LY-USE-EPS to t")
> @@ -203,18 +213,20 @@ FILE-NAME is full path to lilypond (.ly) file"
>  (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-use-eps  "-dbackend=eps" ""))
> -(arg-8 (if ly-gen-svg  "-dbackend=svg" ""))
> -(arg-9 (concat "--output=" (file-name-sans-extension file-name)))
> -(arg-10 file-name))
> + (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-10 (concat "--output=" (file-name-sans-extension file-name)))
> +(arg-11 file-name))
>  (if test
> -`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5
> - ,arg-6 ,arg-7 ,arg-8 ,arg-9 ,arg-10)
> +`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5 ,arg-6
> + ,arg-7 ,arg-8 ,arg-9 ,arg-10, arg-11)
>(call-process
> -   arg-1 arg-2 arg-3 arg-4 arg-5
> -   arg-6 arg-7 arg-8 arg-9 arg-10
> +   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)
>"Check for compile error.
> @@ -307,8 +319,12 @@ If TEST is non-nil, the shell command is returned and is 
> not run"
>   (concat (ly-determine-pdf-path) " " pdf-file)))
>  (if test
>  cmd-string
> -  (shell-command cmd-string)))
> -(message  "No pdf file generated so can't display!")
> +   (start-process 
> +"\"Audition pdf\""
> +"*lilypond*"
> +(ly-determine-pdf-path)
> +pdf-file)))
> + (message  "No pdf file generated so can't display!")
>  
>  (defun ly-attempt-to-play-midi (file-name &optional test)
>"Attempt to play the generated MIDI file
> @@ -322,7 +338,11 @@ If TEST is non-nil, the shell command is returned and is 
> not run"
>   (concat (ly-determine-midi-path) " " midi-file)))
>  (if test
>  cmd-string
> -  (shell-command cmd-string))

[O] [babel][patch] Make ob-lilypond audition calls asynchronous

2012-03-10 Thread Martyn Jago
Hi 

A patch to make ob-lilypond audition calls asynchronous (and tests).

Best, Martyn

>From 2e7cd607cd6dbc25edd5ff9972fbd2528d48416e Mon Sep 17 00:00:00 2001
From: Martyn Jago 
Date: Sat, 10 Mar 2012 15:00:57 +
Subject: [PATCH] Make auditioning of midi and pdf generations asynchronous, and add easy pdf generation.

* lisp/ob-lilypond.el: Make auditioning of midi and pdf asynchronous,
  and add easy pdf generation in the form of `ly-gen-pdf' variable.

* testing/lisp/test-ob-lilypond.el: Tests for above.
---
 lisp/ob-lilypond.el  |   68 ++---
 testing/lisp/test-ob-lilypond.el |   22 +++-
 2 files changed, 68 insertions(+), 22 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 0dde0de..fc9a639 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2010-2012  Free Software Foundation, Inc.
 
 ;; Author: Martyn Jago
-;; Keywords: babel language, literate programming
+;; Keywords: babel language, literate programming, music score
 ;; Homepage: https://github.com/mjago/ob-lilypond
 
 ;; This file is part of GNU Emacs.
@@ -23,10 +23,14 @@
 
 ;;; Commentary:
 
-;; Installation / usage info, and examples are available at
-;; https://github.com/mjago/ob-lilypond
+;; Installation, ob-lilypond documentation, and examples are available at
+;; http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
+;;
+;; Lilypond documentation can be found at
+;; http://lilypond.org/manuals.html
 
 ;;; Code:
+
 (require 'ob)
 (require 'ob-eval)
 (require 'ob-tangle)
@@ -37,9 +41,11 @@
 (add-to-list 'org-babel-tangle-lang-exts '("LilyPond" . "ly"))
 
 (defvar org-babel-default-header-args:lilypond '()
-  "Default header arguments for js code blocks.")
+  "Default header arguments for lilypond code blocks.
+NOTE: The arguments are determined at lilypond compile time.
+See (ly-set-header-args)")
 
-(defconst ly-version "0.3"
+(defconst ly-version "7.6"
   "The version number of the file ob-lilypond.el.")
 
 (defvar ly-compile-post-tangle t
@@ -86,6 +92,10 @@ LY-GEN-SVG to t")
 "HTML generation can be turned on by default by setting
 LY-GEN-HTML to t")
 
+(defvar ly-gen-pdf nil
+"PDF generation can be turned on by default by setting
+LY-GEN-PDF to t")
+
 (defvar ly-use-eps nil
 "You can force the compiler to use the EPS backend by setting
 LY-USE-EPS to t")
@@ -203,18 +213,20 @@ FILE-NAME is full path to lilypond (.ly) file"
 (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-use-eps  "-dbackend=eps" ""))
-(arg-8 (if ly-gen-svg  "-dbackend=svg" ""))
-(arg-9 (concat "--output=" (file-name-sans-extension file-name)))
-(arg-10 file-name))
+	(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-10 (concat "--output=" (file-name-sans-extension file-name)))
+(arg-11 file-name))
 (if test
-`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5
- ,arg-6 ,arg-7 ,arg-8 ,arg-9 ,arg-10)
+`(,arg-1 ,arg-2 ,arg-3 ,arg-4 ,arg-5 ,arg-6
+ ,arg-7 ,arg-8 ,arg-9 ,arg-10, arg-11)
   (call-process
-   arg-1 arg-2 arg-3 arg-4 arg-5
-   arg-6 arg-7 arg-8 arg-9 arg-10
+   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)
   "Check for compile error.
@@ -307,8 +319,12 @@ If TEST is non-nil, the shell command is returned and is not run"
  (concat (ly-determine-pdf-path) " " pdf-file)))
 (if test
 cmd-string
-  (shell-command cmd-string)))
-(message  "No pdf file generated so can't display!")
+	  (start-process 
+	   "\"Audition pdf\""
+	   "*lilypond*"
+	   (ly-determine-pdf-path)
+	   pdf-file)))
+	(message  "No pdf file generated so can't display!")
 
 (defun ly-attempt-to-play-midi (file-name &optional test)
   "Attempt to play the generated MIDI file
@@ -322,7 +338,11 @@ If TEST is non-nil, the shell command is returned and is not run"
  (concat (ly-determine-midi-path) " " midi-file)))
 (if test
 cmd-string
-  (shell-command cmd-string)))
+  (start-process 
+   "\"Audition midi\""
+   "*lilypond*"
+   (ly-determine-midi-path)
+   midi-file)))
 (message "No midi file generated so can't play!")
 
 (defun ly-determine-ly-path (&optional test)
@@ -399,6 +419,15 @@ If TEST is non-nil, it contains