2015-10-26 00:56:00 +00:00
|
|
|
;;; ob-lilypond.el --- Babel Functions for Lilypond -*- lexical-binding: t; -*-
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2021-01-01 19:55:31 +00:00
|
|
|
;; Copyright (C) 2010-2021 Free Software Foundation, Inc.
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2011-06-30 18:06:22 +00:00
|
|
|
;; Author: Martyn Jago
|
2012-03-17 15:28:46 +00:00
|
|
|
;; Keywords: babel language, literate programming
|
2018-01-16 16:22:00 +00:00
|
|
|
;; Homepage: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2011-06-30 18:06:22 +00:00
|
|
|
;; This file is part of GNU Emacs.
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2011-06-30 18:06:22 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2011-06-29 00:40:17 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2011-06-30 18:06:22 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2011-06-29 00:40:17 +00:00
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-06-30 18:06:22 +00:00
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-06-29 00:40:17 +00:00
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
2011-06-30 18:06:22 +00:00
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2011-06-30 18:06:22 +00:00
|
|
|
;;; Commentary:
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2012-03-19 20:38:12 +00:00
|
|
|
;; Installation, ob-lilypond documentation, and examples are available at
|
2018-01-16 16:22:00 +00:00
|
|
|
;; https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lilypond.html
|
2012-03-19 20:38:12 +00:00
|
|
|
;;
|
|
|
|
;; Lilypond documentation can be found at
|
2021-03-21 18:55:14 +00:00
|
|
|
;; https://lilypond.org/manuals.html
|
2014-05-09 12:54:33 +00:00
|
|
|
;;
|
2021-03-21 18:55:14 +00:00
|
|
|
;; This depends on epstopdf --- See https://www.ctan.org/pkg/epstopdf.
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2011-06-30 18:06:22 +00:00
|
|
|
;;; Code:
|
2011-06-29 00:40:17 +00:00
|
|
|
(require 'ob)
|
2017-12-06 15:03:23 +00:00
|
|
|
|
|
|
|
(declare-function org-show-all "org" (&optional types))
|
|
|
|
|
2011-06-29 00:40:17 +00:00
|
|
|
(defalias 'lilypond-mode 'LilyPond-mode)
|
2011-07-08 01:33:56 +00:00
|
|
|
|
2011-06-29 00:40:17 +00:00
|
|
|
(add-to-list 'org-babel-tangle-lang-exts '("LilyPond" . "ly"))
|
|
|
|
|
2011-07-08 01:33:56 +00:00
|
|
|
(defvar org-babel-default-header-args:lilypond '()
|
2012-03-19 20:38:12 +00:00
|
|
|
"Default header arguments for lilypond code blocks.
|
|
|
|
NOTE: The arguments are determined at lilypond compile time.
|
2021-01-02 02:18:37 +00:00
|
|
|
See `org-babel-lilypond-set-header-args'
|
|
|
|
To configure, see `ob-lilypond-header-args'
|
|
|
|
.")
|
|
|
|
|
|
|
|
(defvar ob-lilypond-header-args
|
|
|
|
'((:results . "file") (:exports . "results"))
|
|
|
|
"User-configurable header arguments for lilypond code blocks.
|
|
|
|
NOTE: The final value used by org-babel is computed at compile-time
|
|
|
|
and stored in `org-babel-default-header-args:lilypond'
|
2019-09-20 22:27:53 +00:00
|
|
|
See `org-babel-lilypond-set-header-args'.")
|
2011-07-08 01:33:56 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-compile-post-tangle t
|
2011-06-29 00:40:17 +00:00
|
|
|
"Following the org-babel-tangle (C-c C-v t) command,
|
2014-08-20 19:10:00 +00:00
|
|
|
org-babel-lilypond-compile-post-tangle determines whether ob-lilypond should
|
2011-06-29 00:40:17 +00:00
|
|
|
automatically attempt to compile the resultant tangled file.
|
|
|
|
If the value is nil, no automated compilation takes place.
|
2019-09-20 22:27:53 +00:00
|
|
|
Default value is t.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-display-pdf-post-tangle t
|
2011-06-29 00:40:17 +00:00
|
|
|
"Following a successful LilyPond compilation
|
2014-08-20 19:10:00 +00:00
|
|
|
org-babel-lilypond-display-pdf-post-tangle determines whether to automate the
|
2012-08-11 17:10:44 +00:00
|
|
|
drawing / redrawing of the resultant pdf. If the value is nil,
|
2019-09-20 22:27:53 +00:00
|
|
|
the pdf is not automatically redrawn. Default value is t.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-play-midi-post-tangle t
|
2011-06-29 00:40:17 +00:00
|
|
|
"Following a successful LilyPond compilation
|
2014-08-20 19:10:00 +00:00
|
|
|
org-babel-lilypond-play-midi-post-tangle determines whether to automate the
|
2012-08-11 17:10:44 +00:00
|
|
|
playing of the resultant midi file. If the value is nil,
|
|
|
|
the midi file is not automatically played. Default value is t")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2015-05-26 19:37:04 +00:00
|
|
|
(defvar org-babel-lilypond-ly-command ""
|
|
|
|
"Command to execute lilypond on your system.
|
|
|
|
Do not set it directly. Customize `org-babel-lilypond-commands' instead.")
|
2020-02-11 07:51:30 +00:00
|
|
|
|
2015-05-26 19:37:04 +00:00
|
|
|
(defvar org-babel-lilypond-pdf-command ""
|
|
|
|
"Command to show a PDF file on your system.
|
|
|
|
Do not set it directly. Customize `org-babel-lilypond-commands' instead.")
|
2020-02-11 07:51:30 +00:00
|
|
|
|
2015-05-26 19:37:04 +00:00
|
|
|
(defvar org-babel-lilypond-midi-command ""
|
|
|
|
"Command to play a MIDI file on your system.
|
|
|
|
Do not set it directly. Customize `org-babel-lilypond-commands' instead.")
|
2020-02-11 07:51:30 +00:00
|
|
|
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(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"))
|
2017-09-07 20:56:11 +00:00
|
|
|
:version "24.4"
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
:package-version '(Org . "8.2.7")
|
|
|
|
:set
|
2020-02-11 07:51:30 +00:00
|
|
|
(lambda (symbol value)
|
|
|
|
(set symbol value)
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(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))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-gen-png nil
|
2015-05-26 19:37:04 +00:00
|
|
|
"Non-nil means image generation (PNG) is turned on by default.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-gen-svg nil
|
2015-05-26 19:37:04 +00:00
|
|
|
"Non-nil means image generation (SVG) is be turned on by default.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-gen-html nil
|
2015-05-26 19:37:04 +00:00
|
|
|
"Non-nil means HTML generation is turned on by default.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-gen-pdf nil
|
2015-05-26 19:37:04 +00:00
|
|
|
"Non-nil means PDF generation is be turned on by default.")
|
2012-03-19 20:38:12 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-use-eps nil
|
2015-05-26 19:37:04 +00:00
|
|
|
"Non-nil forces the compiler to use the EPS backend.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defvar org-babel-lilypond-arrange-mode nil
|
2015-05-26 19:37:04 +00:00
|
|
|
"Non-nil turns Arrange mode on.
|
|
|
|
In Arrange mode the following settings are altered from default:
|
2011-07-06 13:17:29 +00:00
|
|
|
:tangle yes, :noweb yes
|
|
|
|
:results silent :comments yes.
|
|
|
|
In addition lilypond block execution causes tangling of all lilypond
|
2015-05-26 19:37:04 +00:00
|
|
|
blocks.")
|
2011-06-29 00:40:17 +00:00
|
|
|
|
|
|
|
(defun org-babel-expand-body:lilypond (body params)
|
|
|
|
"Expand BODY according to PARAMS, return the expanded body."
|
2015-10-29 19:26:11 +00:00
|
|
|
(let ((vars (org-babel--get-vars params)))
|
2011-06-29 00:40:17 +00:00
|
|
|
(mapc
|
|
|
|
(lambda (pair)
|
|
|
|
(let ((name (symbol-name (car pair)))
|
|
|
|
(value (cdr pair)))
|
|
|
|
(setq body
|
|
|
|
(replace-regexp-in-string
|
2015-09-17 23:08:20 +00:00
|
|
|
(concat "$" (regexp-quote name))
|
2011-06-29 00:40:17 +00:00
|
|
|
(if (stringp value) value (format "%S" value))
|
|
|
|
body))))
|
|
|
|
vars)
|
|
|
|
body))
|
2012-03-19 20:38:12 +00:00
|
|
|
|
2011-06-29 00:40:17 +00:00
|
|
|
(defun org-babel-execute:lilypond (body params)
|
|
|
|
"This function is called by `org-babel-execute-src-block'.
|
2011-07-06 13:17:29 +00:00
|
|
|
Depending on whether we are in arrange mode either:
|
|
|
|
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)"
|
2014-08-20 19:10:00 +00:00
|
|
|
(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)))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-tangle ()
|
2011-06-29 00:40:17 +00:00
|
|
|
"ob-lilypond specific tangle, attempts to invoke
|
2012-08-11 17:10:44 +00:00
|
|
|
=ly-execute-tangled-ly= if tangle is successful. Also passes
|
2019-09-20 22:27:53 +00:00
|
|
|
specific arguments to =org-babel-tangle=."
|
2011-06-29 00:40:17 +00:00
|
|
|
(interactive)
|
|
|
|
(if (org-babel-tangle nil "yes" "lilypond")
|
2014-08-20 19:10:00 +00:00
|
|
|
(org-babel-lilypond-execute-tangled-ly) nil))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-process-basic (body params)
|
2012-07-30 08:08:15 +00:00
|
|
|
"Execute a lilypond block in basic mode."
|
2016-09-22 17:45:15 +00:00
|
|
|
(let* ((out-file (cdr (assq :file params)))
|
|
|
|
(cmdline (or (cdr (assq :cmdline params))
|
2011-07-06 13:17:29 +00:00
|
|
|
""))
|
2011-07-08 01:33:56 +00:00
|
|
|
(in-file (org-babel-temp-file "lilypond-")))
|
2011-07-06 13:17:29 +00:00
|
|
|
|
|
|
|
(with-temp-file in-file
|
2011-07-08 01:33:56 +00:00
|
|
|
(insert (org-babel-expand-body:generic body params)))
|
2011-07-06 13:17:29 +00:00
|
|
|
(org-babel-eval
|
|
|
|
(concat
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
org-babel-lilypond-ly-command
|
2011-07-06 13:17:29 +00:00
|
|
|
" -dbackend=eps "
|
|
|
|
"-dno-gs-load-fonts "
|
|
|
|
"-dinclude-eps-fonts "
|
2013-02-07 00:51:14 +00:00
|
|
|
(or (cdr (assoc (file-name-extension out-file)
|
2013-01-31 10:17:18 +00:00
|
|
|
'(("pdf" . "--pdf ")
|
|
|
|
("ps" . "--ps ")
|
|
|
|
("png" . "--png "))))
|
|
|
|
"--png ")
|
2011-07-06 13:17:29 +00:00
|
|
|
"--output="
|
|
|
|
(file-name-sans-extension out-file)
|
|
|
|
" "
|
|
|
|
cmdline
|
2012-07-30 08:08:15 +00:00
|
|
|
in-file) "")) nil)
|
2011-07-06 13:17:29 +00:00
|
|
|
|
2015-10-26 00:56:00 +00:00
|
|
|
(defun org-babel-prep-session:lilypond (_session _params)
|
2011-06-29 00:40:17 +00:00
|
|
|
"Return an error because LilyPond exporter does not support sessions."
|
|
|
|
(error "Sorry, LilyPond does not currently support sessions!"))
|
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-execute-tangled-ly ()
|
2011-06-29 00:40:17 +00:00
|
|
|
"Compile result of block tangle with lilypond.
|
2019-09-20 22:27:53 +00:00
|
|
|
If error in compilation, attempt to mark the error in lilypond org file."
|
2014-08-20 19:10:00 +00:00
|
|
|
(when org-babel-lilypond-compile-post-tangle
|
|
|
|
(let ((org-babel-lilypond-tangled-file (org-babel-lilypond-switch-extension
|
2011-06-29 00:40:17 +00:00
|
|
|
(buffer-file-name) ".lilypond"))
|
2014-08-20 19:10:00 +00:00
|
|
|
(org-babel-lilypond-temp-file (org-babel-lilypond-switch-extension
|
2011-06-29 00:40:17 +00:00
|
|
|
(buffer-file-name) ".ly")))
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(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))
|
2020-02-17 08:04:19 +00:00
|
|
|
(org-switch-to-buffer-other-window "*lilypond*")
|
2011-06-29 00:40:17 +00:00
|
|
|
(erase-buffer)
|
2014-08-20 19:10:00 +00:00
|
|
|
(org-babel-lilypond-compile-lilyfile org-babel-lilypond-temp-file)
|
2011-06-29 00:40:17 +00:00
|
|
|
(goto-char (point-min))
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(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)))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-compile-lilyfile (file-name &optional test)
|
2019-09-20 22:27:53 +00:00
|
|
|
"Compile lilypond file and check for compile errors.
|
|
|
|
FILE-NAME is full path to lilypond (.ly) file."
|
2011-06-29 00:40:17 +00:00
|
|
|
(message "Compiling LilyPond...")
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(let ((arg-1 org-babel-lilypond-ly-command) ;program
|
2021-03-11 18:07:37 +00:00
|
|
|
;; (arg-2 nil) ;infile
|
2011-06-29 00:40:17 +00:00
|
|
|
(arg-3 "*lilypond*") ;buffer
|
2012-03-19 20:38:12 +00:00
|
|
|
(arg-4 t) ;display
|
2014-08-20 19:10:00 +00:00
|
|
|
(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" ""))
|
2012-03-19 20:38:12 +00:00
|
|
|
(arg-10 (concat "--output=" (file-name-sans-extension file-name)))
|
|
|
|
(arg-11 file-name))
|
2011-06-29 00:40:17 +00:00
|
|
|
(if test
|
2021-03-11 18:07:37 +00:00
|
|
|
`(,arg-1 ,nil ,arg-3 ,arg-4 ,arg-5 ,arg-6 ;; arg-2
|
2012-03-19 20:38:12 +00:00
|
|
|
,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
|
2011-06-29 00:40:17 +00:00
|
|
|
(call-process
|
2021-03-11 18:07:37 +00:00
|
|
|
arg-1 nil arg-3 arg-4 arg-5 arg-6 ;; arg-2
|
2012-03-19 20:38:12 +00:00
|
|
|
arg-7 arg-8 arg-9 arg-10 arg-11))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-check-for-compile-error (file-name &optional test)
|
2011-06-29 00:40:17 +00:00
|
|
|
"Check for compile error.
|
|
|
|
This is performed by parsing the *lilypond* buffer
|
|
|
|
containing the output message from the compilation.
|
|
|
|
FILE-NAME is full path to lilypond file.
|
|
|
|
If TEST is t just return nil if no error found, and pass
|
2019-09-20 22:27:53 +00:00
|
|
|
nil as file-name since it is unused in this context."
|
2011-06-29 00:40:17 +00:00
|
|
|
(let ((is-error (search-forward "error:" nil t)))
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(if test
|
|
|
|
is-error
|
|
|
|
(when is-error
|
|
|
|
(org-babel-lilypond-process-compile-error file-name)))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-process-compile-error (file-name)
|
2011-06-29 00:40:17 +00:00
|
|
|
"Process the compilation error that has occurred.
|
2019-09-20 22:27:53 +00:00
|
|
|
FILE-NAME is full path to lilypond file."
|
2014-08-20 19:10:00 +00:00
|
|
|
(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)
|
2011-06-29 00:40:17 +00:00
|
|
|
(error "Error: Compilation Failed!"))))
|
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-mark-error-line (file-name line)
|
2011-06-29 00:40:17 +00:00
|
|
|
"Mark the erroneous lines in the lilypond org buffer.
|
|
|
|
FILE-NAME is full path to lilypond file.
|
2019-09-20 22:27:53 +00:00
|
|
|
LINE is the erroneous line."
|
2020-02-17 08:04:19 +00:00
|
|
|
(org-switch-to-buffer-other-window
|
2011-06-29 00:40:17 +00:00
|
|
|
(concat (file-name-nondirectory
|
2014-08-20 19:10:00 +00:00
|
|
|
(org-babel-lilypond-switch-extension file-name ".org"))))
|
2011-06-29 00:40:17 +00:00
|
|
|
(let ((temp (point)))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(setq case-fold-search nil)
|
|
|
|
(if (search-forward line nil t)
|
|
|
|
(progn
|
2017-12-06 15:03:23 +00:00
|
|
|
(org-show-all)
|
2011-06-29 00:40:17 +00:00
|
|
|
(set-mark (point))
|
|
|
|
(goto-char (- (point) (length line))))
|
|
|
|
(goto-char temp))))
|
2012-03-19 20:38:12 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-parse-line-num (&optional buffer)
|
2011-06-29 00:40:17 +00:00
|
|
|
"Extract error line number."
|
2015-10-26 00:56:00 +00:00
|
|
|
(when buffer (set-buffer buffer))
|
2011-06-29 00:40:17 +00:00
|
|
|
(let ((start
|
|
|
|
(and (search-backward ":" nil t)
|
|
|
|
(search-backward ":" nil t)
|
|
|
|
(search-backward ":" nil t)
|
2015-10-26 00:56:00 +00:00
|
|
|
(search-backward ":" nil t))))
|
|
|
|
(when start
|
|
|
|
(forward-char)
|
|
|
|
(let ((num (string-to-number
|
|
|
|
(buffer-substring
|
|
|
|
(+ 1 start)
|
|
|
|
(- (search-forward ":" nil t) 1)))))
|
|
|
|
(and (numberp num) num)))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-parse-error-line (file-name lineNo)
|
2019-09-20 22:27:53 +00:00
|
|
|
"Extract the erroneous line from the tangled .ly file.
|
2011-06-29 00:40:17 +00:00
|
|
|
FILE-NAME is full path to lilypond file.
|
2019-09-20 22:27:53 +00:00
|
|
|
LINENO is the number of the erroneous line."
|
2011-07-01 19:22:05 +00:00
|
|
|
(with-temp-buffer
|
2014-08-20 19:10:00 +00:00
|
|
|
(insert-file-contents (org-babel-lilypond-switch-extension file-name ".ly")
|
2011-07-01 19:22:05 +00:00
|
|
|
nil nil nil t)
|
|
|
|
(if (> lineNo 0)
|
|
|
|
(progn
|
|
|
|
(goto-char (point-min))
|
|
|
|
(forward-line (- lineNo 1))
|
|
|
|
(buffer-substring (point) (point-at-eol)))
|
|
|
|
nil)))
|
2012-03-19 20:38:12 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-attempt-to-open-pdf (file-name &optional test)
|
2019-09-20 22:27:53 +00:00
|
|
|
"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."
|
2014-08-20 19:10:00 +00:00
|
|
|
(when org-babel-lilypond-display-pdf-post-tangle
|
|
|
|
(let ((pdf-file (org-babel-lilypond-switch-extension file-name ".pdf")))
|
2011-06-29 00:40:17 +00:00
|
|
|
(if (file-exists-p pdf-file)
|
|
|
|
(let ((cmd-string
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(concat org-babel-lilypond-pdf-command " " pdf-file)))
|
2011-06-29 00:40:17 +00:00
|
|
|
(if test
|
|
|
|
cmd-string
|
2012-03-19 20:38:12 +00:00
|
|
|
(start-process
|
|
|
|
"\"Audition pdf\""
|
|
|
|
"*lilypond*"
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
org-babel-lilypond-pdf-command
|
2012-03-19 20:38:12 +00:00
|
|
|
pdf-file)))
|
|
|
|
(message "No pdf file generated so can't display!")))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-attempt-to-play-midi (file-name &optional test)
|
2019-09-20 22:27:53 +00:00
|
|
|
"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."
|
2014-08-20 19:10:00 +00:00
|
|
|
(when org-babel-lilypond-play-midi-post-tangle
|
|
|
|
(let ((midi-file (org-babel-lilypond-switch-extension file-name ".midi")))
|
2011-06-29 00:40:17 +00:00
|
|
|
(if (file-exists-p midi-file)
|
|
|
|
(let ((cmd-string
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
(concat org-babel-lilypond-midi-command " " midi-file)))
|
2011-06-29 00:40:17 +00:00
|
|
|
(if test
|
|
|
|
cmd-string
|
2012-03-19 20:38:12 +00:00
|
|
|
(start-process
|
|
|
|
"\"Audition midi\""
|
|
|
|
"*lilypond*"
|
ob-lilypond: Code cleanup
* lisp/ob-lilypond.el (org-babel-lilypond-OSX-ly-path,
org-babel-lilypond-OSX-pdf-path, org-babel-lilypond-OSX-midi-path,
org-babel-lilypond-nix-ly-path, org-babel-lilypond-nix-pdf-path,
org-babel-lilypond-nix-midi-path, org-babel-lilypond-w32-ly-path,
org-babel-lilypond-w32-pdf-path, org-babel-lilypond-w32-midi-path,
org-babel-lilypond-determine-ly-path,
org-babel-lilypond-determine-pdf-path,
org-babel-lilypond-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: Do test for new variables and
replace removed function calls with the appropriate variable
content. Exercise the new defcustom thoroughly.
2014-08-17 08:29:24 +00:00
|
|
|
org-babel-lilypond-midi-command
|
2012-03-19 20:38:12 +00:00
|
|
|
midi-file)))
|
2011-06-29 00:40:17 +00:00
|
|
|
(message "No midi file generated so can't play!")))))
|
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-toggle-midi-play ()
|
2012-07-30 08:08:15 +00:00
|
|
|
"Toggle whether midi will be played following a successful compilation."
|
2011-06-29 00:40:17 +00:00
|
|
|
(interactive)
|
2014-08-20 19:10:00 +00:00
|
|
|
(setq org-babel-lilypond-play-midi-post-tangle
|
|
|
|
(not org-babel-lilypond-play-midi-post-tangle))
|
2011-06-29 00:40:17 +00:00
|
|
|
(message (concat "Post-Tangle MIDI play has been "
|
2014-08-20 19:10:00 +00:00
|
|
|
(if org-babel-lilypond-play-midi-post-tangle
|
2011-06-29 00:40:17 +00:00
|
|
|
"ENABLED." "DISABLED."))))
|
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-toggle-pdf-display ()
|
2012-07-30 08:08:15 +00:00
|
|
|
"Toggle whether pdf will be displayed following a successful compilation."
|
2011-06-29 00:40:17 +00:00
|
|
|
(interactive)
|
2014-08-20 19:10:00 +00:00
|
|
|
(setq org-babel-lilypond-display-pdf-post-tangle
|
|
|
|
(not org-babel-lilypond-display-pdf-post-tangle))
|
2011-06-29 00:40:17 +00:00
|
|
|
(message (concat "Post-Tangle PDF display has been "
|
2014-08-20 19:10:00 +00:00
|
|
|
(if org-babel-lilypond-display-pdf-post-tangle
|
2011-06-29 00:40:17 +00:00
|
|
|
"ENABLED." "DISABLED."))))
|
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-toggle-png-generation ()
|
2012-07-30 08:08:15 +00:00
|
|
|
"Toggle whether png image will be generated by compilation."
|
2011-06-29 00:40:17 +00:00
|
|
|
(interactive)
|
2014-08-20 19:10:00 +00:00
|
|
|
(setq org-babel-lilypond-gen-png (not org-babel-lilypond-gen-png))
|
2011-06-29 00:40:17 +00:00
|
|
|
(message (concat "PNG image generation has been "
|
2014-08-20 19:10:00 +00:00
|
|
|
(if org-babel-lilypond-gen-png "ENABLED." "DISABLED."))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-toggle-html-generation ()
|
2012-07-30 08:08:15 +00:00
|
|
|
"Toggle whether html will be generated by compilation."
|
2011-06-29 00:40:17 +00:00
|
|
|
(interactive)
|
2014-08-20 19:10:00 +00:00
|
|
|
(setq org-babel-lilypond-gen-html (not org-babel-lilypond-gen-html))
|
2011-06-29 00:40:17 +00:00
|
|
|
(message (concat "HTML generation has been "
|
2014-08-20 19:10:00 +00:00
|
|
|
(if org-babel-lilypond-gen-html "ENABLED." "DISABLED."))))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-toggle-pdf-generation ()
|
2012-07-30 08:08:15 +00:00
|
|
|
"Toggle whether pdf will be generated by compilation."
|
2012-03-19 20:38:12 +00:00
|
|
|
(interactive)
|
2014-08-20 19:10:00 +00:00
|
|
|
(setq org-babel-lilypond-gen-pdf (not org-babel-lilypond-gen-pdf))
|
2012-03-19 20:38:12 +00:00
|
|
|
(message (concat "PDF generation has been "
|
2014-08-20 19:10:00 +00:00
|
|
|
(if org-babel-lilypond-gen-pdf "ENABLED." "DISABLED."))))
|
2012-03-19 20:38:12 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-toggle-arrange-mode ()
|
2012-07-30 08:08:15 +00:00
|
|
|
"Toggle whether in Arrange mode or Basic mode."
|
2011-07-06 13:17:29 +00:00
|
|
|
(interactive)
|
2014-08-20 19:10:00 +00:00
|
|
|
(setq org-babel-lilypond-arrange-mode
|
|
|
|
(not org-babel-lilypond-arrange-mode))
|
2011-07-06 13:17:29 +00:00
|
|
|
(message (concat "Arrange mode has been "
|
2014-08-20 19:10:00 +00:00
|
|
|
(if org-babel-lilypond-arrange-mode "ENABLED." "DISABLED."))))
|
2011-07-06 13:17:29 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-switch-extension (file-name ext)
|
2019-09-20 22:27:53 +00:00
|
|
|
"Utility command to swap current FILE-NAME extension with EXT."
|
2011-06-29 00:40:17 +00:00
|
|
|
(concat (file-name-sans-extension
|
2020-02-18 22:24:09 +00:00
|
|
|
file-name)
|
|
|
|
ext))
|
2011-06-29 00:40:17 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-get-header-args (mode)
|
2019-09-20 22:27:53 +00:00
|
|
|
"Default arguments to use when evaluating a lilypond source block.
|
|
|
|
These depend upon whether we are in Arrange mode i.e. MODE is t."
|
2011-07-06 13:17:29 +00:00
|
|
|
(cond (mode
|
|
|
|
'((:tangle . "yes")
|
|
|
|
(:noweb . "yes")
|
|
|
|
(:results . "silent")
|
2012-03-19 20:38:12 +00:00
|
|
|
(:cache . "yes")
|
2011-07-06 13:17:29 +00:00
|
|
|
(:comments . "yes")))
|
|
|
|
(t
|
2021-01-02 02:18:37 +00:00
|
|
|
ob-lilypond-header-args)))
|
2011-07-06 13:17:29 +00:00
|
|
|
|
2014-08-20 19:10:00 +00:00
|
|
|
(defun org-babel-lilypond-set-header-args (mode)
|
2011-07-06 13:17:29 +00:00
|
|
|
"Set org-babel-default-header-args:lilypond
|
2019-09-20 22:27:53 +00:00
|
|
|
dependent on ORG-BABEL-LILYPOND-ARRANGE-MODE."
|
2011-07-06 13:17:29 +00:00
|
|
|
(setq org-babel-default-header-args:lilypond
|
2014-08-20 19:10:00 +00:00
|
|
|
(org-babel-lilypond-get-header-args mode)))
|
2011-07-06 13:17:29 +00:00
|
|
|
|
2011-06-29 00:40:17 +00:00
|
|
|
(provide 'ob-lilypond)
|
2011-06-30 18:06:22 +00:00
|
|
|
|
2011-06-29 00:40:17 +00:00
|
|
|
;;; ob-lilypond.el ends here
|