emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: No Wayman <iarchivedmywholelife@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH] refactor org-babel-lilypond-compile-lilyfile
Date: Thu, 24 Aug 2023 09:48:00 -0400	[thread overview]
Message-ID: <87jztk1rdc.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]


The attached patch:

- Improves the compilation message. (The target is the file, not 
  LilyPond itself).
- Refactors the body of the function to remove the many 
  nondescript arg-n local variables.
- Removes the optional TEST parameter, which is unused and better 
  served through debugging tools.  



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ob-lilypond.el-refactor-org-babel-lilypond-comp.patch --]
[-- Type: text/x-patch, Size: 2772 bytes --]

From 5765891b9de22260454d2cee8365c14841d0d744 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Thu, 24 Aug 2023 09:32:27 -0400
Subject: [PATCH] lisp/ob-lilypond.el: refactor
 org-babel-lilypond-compile-lilyfile

* ob-lilypond.el (org-babel-lilypond-compile-lilyfile):
Correct compilation message.
Remove superfluous local variables.
Remove unused ad-hoc debugging TEST parameter.
---
 lisp/ob-lilypond.el | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 8b2bd231f..92cd59685 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -247,27 +247,21 @@ org-babel-lilypond-execute-tangled-ly
 	(org-babel-lilypond-attempt-to-open-pdf org-babel-lilypond-temp-file)
 	(org-babel-lilypond-attempt-to-play-midi org-babel-lilypond-temp-file)))))
 
-(defun org-babel-lilypond-compile-lilyfile (file-name &optional test)
+(defun org-babel-lilypond-compile-lilyfile (file-name)
   "Compile lilypond file and check for compile errors.
 FILE-NAME is full path to lilypond (.ly) file."
-  (message "Compiling LilyPond...")
-  (let ((arg-1 org-babel-lilypond-ly-command) ;program
-        ;; (arg-2 nil)                    ;infile
-        (arg-3 "*lilypond*")           ;buffer
-	(arg-4 t)                      ;display
-	(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" ""))
-        (arg-10 (concat "--output=" (file-name-sans-extension file-name)))
-        (arg-11 file-name))
-    (if test
-        `(,arg-1 ,nil ,arg-3 ,arg-4 ,arg-5 ,arg-6 ;; arg-2
-                 ,arg-7 ,arg-8 ,arg-9 ,arg-10 ,arg-11)
-      (call-process
-       arg-1 nil arg-3 arg-4 arg-5 arg-6 ;; arg-2
-       arg-7 arg-8 arg-9 arg-10 arg-11))))
+  (message "Compiling %s..." file-name)
+  (let ((args
+         (delq nil (list
+                    (and org-babel-lilypond-gen-png  "--png")
+                    (and org-babel-lilypond-gen-html "--html")
+                    (and org-babel-lilypond-gen-pdf  "--pdf")
+                    (and org-babel-lilypond-use-eps  "-dbackend=eps")
+                    (and org-babel-lilypond-gen-svg  "-dbackend=svg")
+                    (concat "--output=" (file-name-sans-extension file-name))
+                    file-name))))
+    (apply #'call-process org-babel-lilypond-ly-command nil
+           "*lilypond*" 'display args)))
 
 (defun org-babel-lilypond-check-for-compile-error (file-name &optional test)
   "Check for compile error.
-- 
2.41.0


             reply	other threads:[~2023-08-24 13:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 13:48 No Wayman [this message]
2023-08-25  8:06 ` Org mode version 9.7-pre (9.7-pre-n/a-g63e8ca @ /home/n/.emacs.d/elpaca/builds/org/); [PATCH] refactor org-babel-lilypond-compile-lilyfile Ihor Radchenko
2023-09-03 19:35   ` No Wayman
2023-09-04  7:47     ` Ihor Radchenko
2023-09-06  1:11       ` No Wayman
2023-09-06  9:35         ` Ihor Radchenko

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://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87jztk1rdc.fsf@gmail.com \
    --to=iarchivedmywholelife@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
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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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