|
@@ -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 a simulation of the OS for test purposes"
|
|
|
(message (concat "HTML generation has been "
|
|
|
(if ly-gen-html "ENABLED." "DISABLED."))))
|
|
|
|
|
|
+(defun ly-toggle-pdf-generation ()
|
|
|
+ "Toggle whether pdf will be generated by compilation"
|
|
|
+
|
|
|
+ (interactive)
|
|
|
+ (setq ly-gen-pdf
|
|
|
+ (not ly-gen-pdf))
|
|
|
+ (message (concat "PDF generation has been "
|
|
|
+ (if ly-gen-pdf "ENABLED." "DISABLED."))))
|
|
|
+
|
|
|
(defun ly-toggle-arrange-mode ()
|
|
|
"Toggle whether in Arrange mode or Basic mode"
|
|
|
|
|
@@ -428,6 +457,7 @@ mode i.e. ARRANGE-MODE is t"
|
|
|
'((:tangle . "yes")
|
|
|
(:noweb . "yes")
|
|
|
(:results . "silent")
|
|
|
+ (:cache . "yes")
|
|
|
(:comments . "yes")))
|
|
|
(t
|
|
|
'((:results . "file")
|
|
@@ -441,6 +471,4 @@ dependent on LY-ARRANGE-MODE"
|
|
|
|
|
|
(provide 'ob-lilypond)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
;;; ob-lilypond.el ends here
|