emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jamie Bayne <jtbayne@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ob-lilypond: allow user configuration of header-args
Date: Sun, 10 Jan 2021 14:25:40 +0000	[thread overview]
Message-ID: <CANwLyLNCUDEqrtLe9DxB+xZg9T-DWfmfHzrPMuqcUZLZW347Tg@mail.gmail.com> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 888 bytes --]

Hi all,

I hit the problem described in
https://www.mail-archive.com/emacs-orgmode@gnu.org/msg127317.html - I
couldn't see that anyone else had fixed it so I had a go.

The problem is that, unusually, ob-lilypond has some conditional logic on
its header-args. Its solution is to set the header-args internally when
required, which overrides any user-specified value.

The quickest way I could see to preserve the conditional logic was to add a
new variable to hold the user configuration, which I called
ob-lilypond-header-args. Now the conditional logic sets
org-babel-header-args:lilypond to the new variable's value when appropriate.

Another way would be to create a context which sets the variable when
needed and then resets it. I opted against this as I'm not sure it would
have the same behaviour in all cases. Happy to have a go if it would be
preferable, though.


[-- Attachment #1.2: Type: text/html, Size: 1151 bytes --]

[-- Attachment #2: 0001-Allow-user-to-set-ob-lilypond-header-arguments.patch --]
[-- Type: text/x-patch, Size: 1758 bytes --]

From f413a36ac9b7ca7c990ee1ab6456cc237ebccf3d Mon Sep 17 00:00:00 2001
From: Jamie Bayne <jamiebayne@hotmail.com>
Date: Sat, 2 Jan 2021 02:18:37 +0000
Subject: [PATCH] Allow user to set ob-lilypond header arguments

* ob-lilypond.el (org-babel-lilypond-set-header-args): Replace
hard-coded settings with user-configurable variable.
(org-babel-header-args:lilypond): Modify documentation.
(ob-lilypond-header-args): New variable.

 lisp/ob-lilypond.el | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index fbdd905a5..11ae9ae88 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -43,6 +43,15 @@
 (defvar org-babel-default-header-args:lilypond '()
   "Default header arguments for lilypond code blocks.
 NOTE: The arguments are determined at lilypond compile time.
+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'
 See `org-babel-lilypond-set-header-args'.")
 (defvar org-babel-lilypond-compile-post-tangle t
@@ -403,9 +412,8 @@ These depend upon whether we are in Arrange mode i.e. MODE is t."
            (:results . "silent")
            (:cache . "yes")
            (:comments . "yes")))
-        (t
-         '((:results . "file")
-           (:exports . "results")))))
+        (t 
+          ob-lilypond-header-args)))
 (defun org-babel-lilypond-set-header-args (mode)
   "Set org-babel-default-header-args:lilypond

             reply	other threads:[~2021-01-10 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-10 14:25 Jamie Bayne [this message]
2021-01-12 12:40 ` [PATCH] ob-lilypond: allow user configuration of header-args Jonathan Gregory
2021-04-26  8:27 ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANwLyLNCUDEqrtLe9DxB+xZg9T-DWfmfHzrPMuqcUZLZW347Tg@mail.gmail.com \
    --to=jtbayne@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).