emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Butler <Leo.Butler@umanitoba.ca>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [BUG] ob-doc-maxima.org and ob-maxima.el
Date: Thu, 3 Nov 2022 18:15:18 +0000	[thread overview]
Message-ID: <87edujkiq2.fsf@t14.reltub.ca> (raw)
In-Reply-To: <87wn8c7cpn.fsf@localhost> (Ihor Radchenko's message of "Thu, 03 Nov 2022 06:51:16 +0000")

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

Hi Ihor,

On Thu, Nov 03 2022, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch to worg's ob-doc-maxima.org.diff --]
[-- Type: text/x-diff; name="ob-doc-maxima.org.diff", Size: 3011 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Patch to org's ob-maxima.el that makes :results file equivalent to :results file graphics.diff --]
[-- Type: text/x-diff; name="ob-maxima.el.diff", Size: 643 bytes --]

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

  reply	other threads:[~2022-11-03 18:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 19:39 [BUG] ob-doc-maxima.org and ob-maxima.el Leo Butler
2022-11-03  6:51 ` Ihor Radchenko
2022-11-03 18:15   ` Leo Butler [this message]
2022-11-04  3:38     ` Ihor Radchenko
2022-11-04 20:49       ` Leo Butler
2022-11-05  3:40         ` Ihor Radchenko
2022-11-07 14:24           ` Leo Butler
2022-11-04  4:03     ` Clarification on :results file vs. :results graphics file (was: [BUG] ob-doc-maxima.org and ob-maxima.el) Ihor Radchenko
2022-11-04 19:11       ` Clarification on :results file vs. :results graphics file Leo Butler
2022-11-05  3:41       ` Clarification on :results file vs. :results graphics file (was: [BUG] ob-doc-maxima.org and ob-maxima.el) 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=87edujkiq2.fsf@t14.reltub.ca \
    --to=leo.butler@umanitoba.ca \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@posteo.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 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).