all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Lockywolf <for_org-bugs_2023-09-01@lockywolf.net>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [BUG] Consider replacing bachload with batch in ob-maxima. [9.6.6 (release_9.6.6 @ /usr/share/emacs/30.0.50/lisp/org/)]
Date: Fri, 1 Sep 2023 18:33:40 +0000	[thread overview]
Message-ID: <87cyz1ivzw.fsf@t14.reltub.ca> (raw)
In-Reply-To: <874jkemrk2.fsf@laptop.lockywolf.net> (Lockywolf's message of "Fri, 01 Sep 2023 12:35:37 +0800")

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

On Fri, Sep 01 2023, Lockywolf <for_org-bugs_2023-09-01@lockywolf.net> wrote:

> Dear org developers,
>
> At the moment, ob-maxima has a straightforward way of evaluating
> babel blocks,
>
> #+begin_src shell
> maxima --very-quiet -r batchload\(\"/tmp/ob-maximaFOOBAR.mac\"\)\$
> #+end_src
>
> (line 87 of ob-maxima.el),
>
> I suggest replacing batchload with batch(), and changing line 73 from
> "gnuplot_close ()$" to 	"gnuplot_close ()$ \nquit();"
>
> The difference between "batch" and "batchload" is that "batch" can
> process :lisp expressions in addition to maxima's own, and it prints
> input/output labels. However, it is possible to customise label printing
> from maxima's own code, and being able to evaluate :lisp just seems
> uncontrovercially good.
>
> It might be that I am missing something, but batch seems a better fit
> for Org-Babel.

Hello,

I think that your request may be handled by one of two improvements:

1. Implement session support in ob-maxima.el; and
2. Many of the design decisions in the existing ob-maxima code should be
customizable.

I am attaching a patch to address 2. Please try it out, I think that it
will satisfy your requests. Feedback is welcome.

---

This old thread may also be relevant:
https://list.orgmode.org/87o7q5rw62.fsf@t14.reltub.ca/

Best,
Leo



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-On-ltb-ob-max-ob-maxima.el-add-customizations.patch --]
[-- Type: text/x-diff; name="0001-On-ltb-ob-max-ob-maxima.el-add-customizations.patch", Size: 3071 bytes --]

diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el
index d1d7c7424..848811628 100644
--- a/lisp/ob-maxima.el
+++ b/lisp/ob-maxima.el
@@ -48,6 +48,33 @@
   :group 'org-babel
   :type 'string)
 
+(defcustom org-babel-maxima-command-arguments
+  "--very-quiet"
+  "Command-line arguments used when calling the Maxima executable. See `org-babel-maxima-batch/load' and `org-babel-execute:maxima'."
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-maxima-batch/load
+  "batchload"
+  "The Maxima function used to read and execute Maxima code: `batchload' and `batch' are two alternatives, although a user-defined Maxima function may also be used. See `org-babel-execute:maxima'."
+  :options '("batchload" "batch")
+  :group 'org-babel
+  :type 'string)
+
+(defcustom org-babel-maxima-graphic-file-format-string
+  "(set_plot_option ('[gnuplot_term, png]), set_plot_option ('[gnuplot_out_file, %S]))$"
+  "A string with the Maxima code to set the graphic file terminal and name. It must contain `%S' to set the filename. See `org-babel-maxima-expand'."
+  :options '("(set_plot_option ('[gnuplot_term, png]), set_plot_option ('[gnuplot_out_file, %S]))$" "(load(draw), set_draw_option(terminal='pngcairo,file_name=%S))$")
+  :group 'org-babel
+  :type 'string)
+
+
+(defcustom org-babel-maxima-default-epilogue
+  "gnuplot_close ()$"
+  "A string with the final Maxima code executed. See `org-babel-maxima-expand'."
+  :group 'org-babel
+  :type 'string)
+
 (defun org-babel-maxima-expand (body params)
   "Expand a block of Maxima code according to its header arguments."
   (let ((vars (org-babel--get-vars params))
@@ -60,9 +87,7 @@
 		;; graphic output
 		(let ((graphic-file (ignore-errors (org-babel-graphical-output-file params))))
 		  (if graphic-file
-		      (format
-		       "set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]);"
-		       graphic-file)
+		      (format org-babel-maxima-graphic-file-format-string graphic-file)
 		    ""))
 		;; variables
 		(mapconcat 'org-babel-maxima-var-to-maxima vars "\n")
@@ -70,7 +95,7 @@
 		body
 		;; Any code from the specified epilogue at the end.
 		epilogue
-		"gnuplot_close ()$")
+		org-babel-maxima-default-epilogue)
 	       "\n")))
 
 (defun org-babel-execute:maxima (body params)
@@ -81,10 +106,11 @@ This function is called by `org-babel-execute-src-block'."
 	(result
 	 (let* ((cmdline (or (cdr (assq :cmdline params)) ""))
 		(in-file (org-babel-temp-file "maxima-" ".max"))
-		(cmd (format "%s --very-quiet -r %s %s"
+		(cmd (format "%s %s -r %s %s"
 			     org-babel-maxima-command
+                             org-babel-maxima-command-arguments
                              (shell-quote-argument
-                              (format "batchload(%S)$" in-file))
+                              (format "%s(%S)$" org-babel-maxima-batch/load in-file))
                              cmdline)))
 	   (with-temp-file in-file (insert (org-babel-maxima-expand body params)))
 	   (message cmd)

  reply	other threads:[~2023-09-01 18:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-01  4:35 [BUG] Consider replacing bachload with batch in ob-maxima. [9.6.6 (release_9.6.6 @ /usr/share/emacs/30.0.50/lisp/org/)] Lockywolf
2023-09-01 18:33 ` Leo Butler [this message]
2023-09-02  7:19   ` Ihor Radchenko
2023-09-02 18:12     ` Leo Butler
2023-09-05 10:57       ` [MAINTENANCE] On how much we can expose internals into defcustom (was: [BUG] Consider replacing bachload with batch in ob-maxima. [9.6.6 (release_9.6.6 @ /usr/share/emacs/30.0.50/lisp/org/)]) Ihor Radchenko
2023-09-06 19:39         ` [MAINTENANCE] On how much we can expose internals into defcustom Leo Butler
2023-09-07 11:35           ` Ihor Radchenko
2023-09-12 21:09             ` [PATCH] ob-maxima.el, etc. (was Re: [MAINTENANCE] On how much we can expose internals into defcustom) Leo Butler
2023-09-15  9:41               ` Ihor Radchenko
2023-09-15 15:13                 ` Leo Butler
2023-09-16  9:04                   ` Ihor Radchenko
2023-09-19 19:25                     ` Leo Butler
2023-09-20  9:17                       ` Ihor Radchenko
2023-09-20 15:02                         ` Leo Butler
2023-09-21  9:18                           ` Ihor Radchenko
2023-09-21 14:03                             ` Leo Butler
2023-09-22  9:43                               ` Ihor Radchenko
2023-10-02 16:01                                 ` Leo Butler
2023-10-04  8:38                                   ` Ihor Radchenko
2023-10-04 13:07                                     ` Leo Butler
2023-09-02  7:06 ` [BUG] Consider replacing bachload with batch in ob-maxima. [9.6.6 (release_9.6.6 @ /usr/share/emacs/30.0.50/lisp/org/)] Ihor Radchenko
2023-09-02 18:20   ` Leo Butler
2023-09-03  5:25     ` Vladimir Nikishkin

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

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

  git send-email \
    --in-reply-to=87cyz1ivzw.fsf@t14.reltub.ca \
    --to=leo.butler@umanitoba.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=for_org-bugs_2023-09-01@lockywolf.net \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.