Org-mode mailing list
 help / color / mirror / 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
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.

Cheers,
Jamie

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

TINYCHANGE
---
 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
-- 
2.29.2


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-10 14:25 Jamie Bayne [this message]
2021-01-12 12:40 ` Jonathan Gregory

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://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 \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git