Hi Ihor, On Thu, Nov 03 2022, Ihor Radchenko <yanta...@posteo.net> wrote:
> Leo Butler <leo.but...@umanitoba.ca> writes: > >> In worg's documentation of ob-maxima.el[fn:1], there are several bugs. > > Thanks for reporting! Thank you for the feedback. I will comment inline below. > >> 1. In the subsection `Inline Display of Maxima LaTeX Output', the >> results are missing. > > It is because source block evaluation is disabled on server side when > generating WORG website from org sources. Ahhh! Of course. > > You basically need to evaluate the code block manually to have it > present in the original file without a need to evaluate during export. > > I do not have maxima on my system. It would be welcome if you evaluate > the code blocks with missing results manually and submit a patch with. Attached. > >> ... This is because the code block is named >> `solve-maxima', the same as in the section `Solver'. Export results in >> that output being put in the `Solver' section (I don't know if that >> should be considered a bug in Org). > > No, the source block in the Solver section is different. It just has > the same name. Name duplicate should be fixed indeed. That was fixed in the patch I sent, and the attached one. > >> 2. In `3D Plots', the header arguments do not result in a link to a >> generated file being created on evaluation of the code block. I am >> unsure if this is a bug in Org, ob-maxima.el or ob-doc-maxima.org or >> what. >> On reading the description of the =:results graphics= >> header[fn:2], it looks like there is blame to go around. > > Makes sense. Can you please report this inconsistency in more details in > a separate email? It looks like something is not right with ob-maxima > code in the treatment of :results graphics. Sure. I was playing with ob-doc-octave.org, too, and I see that there is a similar problem there. > >> @@ -145,7 +151,7 @@ This example is from >> [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto >> ,#+name: 3d-maxima >> ,#+header: :file images/maxima-3d.png >> ,#+header: :exports results >> -,#+header: :results graphics >> +,#+header: :results graphics file > > Using graphics together with file does not make sense. Ok. But I am not sure the code agrees with you. In ob-core.el, `org-babel-graphical-output-file' is defined as: (defun org-babel-graphical-output-file (params) "File where a babel block should send graphical output, per PARAMS. Return nil if no graphical output is expected. Raise an error if the output file is ill-defined." (let ((file (cdr (assq :file params)))) (cond (file (and (member "graphics" (cdr (assq :result-params params))) file)) ... Is it, in your opinion, ob-maxima's responsibility to add "graphics" to :result-params when :results file is specified? > We should probably fix ob-maxima with :results file first. > Ideally, the code here should be simply > ,#+header: :results file The attached patch to lisp/ob-maxima.el makes the example work with your suggested header. > >> #+begin_example >> -,#+NAME: solve-maxima >> -,#+HEADER: :exports none >> -,#+BEGIN_SRC maxima :results raw >> +,#+NAME: tex-maxima >> +,#+HEADER: :exports results >> +,#+BEGIN_SRC maxima :results latex > > This will break WORG page. We are exporting to HTML, not latex and the > results wrapped into #+begin_export latex will not be exported to the > website. What's wrong with raw? Yes, you are right about WORG. I was testing by building a pdf and didn't think to build the html page. My mistake. The patch I am sending builds a working html page. There is a problem, though. When evaluating the code block #+NAME: tex-maxima #+HEADER: :exports results #+BEGIN_SRC maxima :results raw tex(exp(-x)/x); #+END_SRC multiple times, the results are appended below each other. Adding the option `drawer', or changing the results to latex (or html), prevents this. I will open a separate email report about this. Leo
diff --git a/org-contrib/babel/languages/ob-doc-maxima.org b/org-contrib/babel/languages/ob-doc-maxima.org index 810c9ef4..eb760eff 100644 --- a/org-contrib/babel/languages/ob-doc-maxima.org +++ b/org-contrib/babel/languages/ob-doc-maxima.org @@ -111,7 +111,9 @@ powers of 12, where the powers are passed with a variable. print(12^x); #+end_src -#+results: test-maxima +Which produces the result: + +#+RESULTS: test-maxima : 26.06280316745402 ** Solver @@ -137,6 +139,14 @@ Of course, =maxima= is more than a calculator. print(solution); #+end_src +Which produces the result: + +#+RESULTS: solve-maxima +: solve: solution: +: x = - 4 +: x = 4 +: [%t1, %t2] + ** 3D plots With =gnuplot= installed (4.0 or higher), 3D graphics are possible. This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tutorial on the maxima/gnuplot interface]]. @@ -145,7 +155,7 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto ,#+name: 3d-maxima ,#+header: :file images/maxima-3d.png ,#+header: :exports results -,#+header: :results graphics +,#+header: :results file ,#+begin_src maxima programmode: false; plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true]); @@ -154,15 +164,25 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto #+name: 3d-maxima #+header: :file images/maxima-3d.png -#+header: :results graphics #+header: :exports results +#+header: :results file #+begin_src maxima programmode: false; plot3d(atan(-x^2+y^3/4),[x,-4,4],[y,-4,4],[grid,50,50],[gnuplot_pm3d,true]); #+end_src -#+results: 3d-maxima +Which produces the code: + +#+begin_example +,#+RESULTS: 3d-maxima [[file:images/maxima-3d.png]] +#+end_example + +and the image: + +#+RESULTS: 3d-maxima +[[https://orgmode.org/worg/org-contrib/babel/languages/images/maxima-3d.png]] + ** Inline Display of Maxima LaTeX Output [[http://maxima.sourceforge.net/][Maxima]] code can be evaluated and displayed inline in Org mode @@ -170,19 +190,28 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto example. #+begin_example -,#+NAME: solve-maxima -,#+HEADER: :exports none +,#+NAME: tex-maxima +,#+HEADER: :exports results ,#+BEGIN_SRC maxima :results raw tex(exp(-x)/x); ,#+END_SRC #+end_example -#+NAME: solve-maxima +#+NAME: tex-maxima #+HEADER: :exports results #+BEGIN_SRC maxima :results raw tex(exp(-x)/x); #+END_SRC +Which produces the code: +#+begin_example +,#+RESULTS: tex-maxima +$${{e^ {- x }}\over{x}}$$ +#+end_example +that is rendered as: +#+RESULTS: tex-maxima +$${{e^ {- x }}\over{x}}$$ + *** Toggle inline display of latex code Latex code in org mode can be displayed inline by 'C-c C-x C-l'. To remove the inline display 'C-c C-c' is used. This is
diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el index e3dfbb668..03310e958 100644 --- a/lisp/ob-maxima.el +++ b/lisp/ob-maxima.el @@ -77,6 +77,9 @@ "Execute a block of Maxima entries with org-babel. This function is called by `org-babel-execute-src-block'." (message "Executing Maxima source code block") + ;; Make `:results file' imply `:results graphics file' + (when (member "file" (assq :result-params params)) + (push "graphics" (alist-get :result-params params))) (let ((result-params (split-string (or (cdr (assq :results params)) ""))) (result (let* ((cmdline (or (cdr (assq :cmdline params)) ""))