emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] ob-doc-maxima.org and ob-maxima.el
@ 2022-11-02 19:39 Leo Butler
  2022-11-03  6:51 ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Butler @ 2022-11-02 19:39 UTC (permalink / raw)
  To: Org Mode Mailing List

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

Hi,

In worg's documentation of ob-maxima.el[fn:1], there are several bugs.


1. In the subsection `Inline Display of Maxima LaTeX Output', the
results are missing. 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). On the webpage, the errant output
has been deleted. The correct output in both sections should be
included.

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. Related: in
ob-doc-octave.org, the graphics example only includes a =:results file=
header argument.

The attached patch to ob-doc-maxima.org fixes only the documentation
issues:

1. Present the correct output of code block `solve-maxima'.
2. Add the header argument `file' to the `3d-maxima' example to create a
correct link and graphics file.
3. Rename the tex code block to `tex-maxima' and change the results type
to =latex= to generate correct output.

TIA,
Leo Butler

[fn:1]
https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-maxima.html
[fn:2] (info "(org) Results of Evaluation")


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

diff --git a/org-contrib/babel/languages/ob-doc-maxima.org b/org-contrib/babel/languages/ob-doc-maxima.org
index 810c9ef4..f1388187 100644
--- a/org-contrib/babel/languages/ob-doc-maxima.org
+++ b/org-contrib/babel/languages/ob-doc-maxima.org
@@ -137,6 +137,12 @@ Of course, =maxima= is more than a calculator.
   print(solution);
 #+end_src
 
+#+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 +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
 ,#+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,14 +160,14 @@ 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 graphics 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
+#+RESULTS: 3d-maxima
 [[file:images/maxima-3d.png]]
 
 ** Inline Display of Maxima LaTeX Output
@@ -170,19 +176,24 @@ This example is from [[http://maxima.sourceforge.net/maxima-gnuplot.html][a tuto
   example.
 
 #+begin_example
-,#+NAME: solve-maxima
-,#+HEADER: :exports none
-,#+BEGIN_SRC maxima :results raw
+,#+NAME: tex-maxima
+,#+HEADER: :exports results
+,#+BEGIN_SRC maxima :results latex
   tex(exp(-x)/x);
 ,#+END_SRC
 #+end_example
 
-#+NAME: solve-maxima
+#+NAME: tex-maxima
 #+HEADER: :exports results
-#+BEGIN_SRC maxima :results raw
+#+BEGIN_SRC maxima :results latex
   tex(exp(-x)/x);
 #+END_SRC
 
+#+RESULTS: tex-maxima
+#+begin_export latex
+$${{e^ {- x }}\over{x}}$$
+#+end_export
+
 *** 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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [BUG] ob-doc-maxima.org and ob-maxima.el
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-11-03  6:51 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

> In worg's documentation of ob-maxima.el[fn:1], there are several bugs.

Thanks for reporting!

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

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.

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

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

> @@ -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.
We should probably fix ob-maxima with :results file first.
Ideally, the code here should be simply
,#+header: :results file

>  #+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?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] ob-doc-maxima.org and ob-maxima.el
  2022-11-03  6:51 ` Ihor Radchenko
@ 2022-11-03 18:15   ` Leo Butler
  2022-11-04  3:38     ` Ihor Radchenko
  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
  0 siblings, 2 replies; 10+ messages in thread
From: Leo Butler @ 2022-11-03 18:15 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org Mode Mailing List

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [BUG] ob-doc-maxima.org and ob-maxima.el
  2022-11-03 18:15   ` Leo Butler
@ 2022-11-04  3:38     ` Ihor Radchenko
  2022-11-04 20:49       ` 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
  1 sibling, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-11-04  3:38 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

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

There is no need to wrap the results into example blocks. They will
better be as is. Org export will take care about choosing what to
export: code, results, or both.

>> 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:

Let's discuss it in a separate thread. I will need to study the code a
bit more to understand what we promise in the manual vs. actual state of
the code.

>  #+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]]
> +

I am a bit confused here. Did you hand-craft the results?
  
> -#+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}}$$

Please make #+RESULTS a separate paragraph. It may otherwise not be
correctly recognized.

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

Let's move the ob-maxima changes and discussion about graphics to a
separate thread.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Clarification on :results file vs. :results graphics file (was: [BUG] ob-doc-maxima.org and ob-maxima.el)
  2022-11-03 18:15   ` Leo Butler
  2022-11-04  3:38     ` Ihor Radchenko
@ 2022-11-04  4:03     ` 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
  1 sibling, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2022-11-04  4:03 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode Mailing List

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

Leo Butler <Leo.Butler@umanitoba.ca> writes:

>>> @@ -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?

No. Let me put what the manual says on the question:

- :results header argument has multiple argument classes

    Each code block can take only one option per class:
    
    Collection
         For how the results should be collected from the code block;
    
    Type
         For which type of result the code block will return; affects how
         Org processes and inserts results in the Org buffer;
    
    Format
         For the result; affects how Org processes results;
    
    Handling
         For inserting results once they are properly formatted.

:results file is the Type class.
:results graphics is the Format class.

They can be used together. I was wrong in my earlier reply.

‘file’
     Interpret as a filename.  Save the results of execution of the code
     block to that file, then insert a link to it.  You can control both
     the filename and the description associated to the link.

‘graphics’
     When used along with ‘file’ type, the result is a link to the file
     specified in ‘:file’ header argument.  However, unlike plain ‘file’
     type, nothing is written to the disk.  The block is used for its
     side-effects only, as in the following example:

(Note: I'd say "nothing is written to the disk" is a bit misleading
here. I am attaching a patch with clarification)

When we have :file foo.png :results file, Org will take the command
output, write it to foo.png, and insert the link to foo.png as code
block result.

When we have :file foo.png :results file graphics, Org will not write to
foo.png itself. Instead, it will expect the code execution to create
foo.png as a side effect. The code output will be ignored and the link
to foo.png will be inserted.

Note: ob-maxima wraps `org-babel-graphical-output-file' into
ignore-errors, which will hide missing :file spec error from user.
Unsure about the reasons behind it.

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

This will be wrong, as I explained above. :results file and :results
graphics file are expected to behave differently in the manual.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-manual-Clarify-results-file-graphics-header-argu.patch --]
[-- Type: text/x-patch, Size: 1561 bytes --]

From 73821c511e723e324e3f7aa9424003b8993ed412 Mon Sep 17 00:00:00 2001
Message-Id: <73821c511e723e324e3f7aa9424003b8993ed412.1667534563.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Fri, 4 Nov 2022 12:01:19 +0800
Subject: [PATCH] org-manual: Clarify :results file graphics header argument
 meaning

* doc/org-manual.org (Format): Clarify the difference between
:results file and :results file graphics.  Update the example to
something that can be tried locally.
---
 doc/org-manual.org | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index dc2fc57cd..b3071ec6d 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -18408,13 +18408,17 @@ *** Format
 
   When used along with =file= type, the result is a link to the file
   specified in =:file= header argument.  However, unlike plain =file=
-  type, nothing is written to the disk.  The block is used for its
-  side-effects only, as in the following example:
+  type, code block output is not written to the disk.  The block is
+  expected to generate the file by its side-effects only, as in the
+  following example:
 
   #+begin_example
-  ,#+begin_src shell :results file link :file "download.tar.gz"
-  wget -c "https://example.com/download.tar.gz"
+  ,#+begin_src shell :results file link :file "org-mode-unicorn.svg"
+    wget -c "https://orgmode.org/resources/img/org-mode-unicorn.svg"
   ,#+end_src
+
+  ,#+RESULTS:
+  [[file:org-mode-unicorn.svg]]
   #+end_example
 
 - =org= ::
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Clarification on :results file vs. :results graphics file
  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       ` 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
  1 sibling, 0 replies; 10+ messages in thread
From: Leo Butler @ 2022-11-04 19:11 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org Mode Mailing List

On Fri, Nov 04 2022, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>>>> @@ -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,
>>                      ...
>>
>> Is it, in your opinion, ob-maxima's responsibility to add "graphics" to
>> :result-params when :results file is specified?
>
> No.

Thank you for correcting yourself and me. I had arrived at the same
conclusion and was going to retract that `patch' to ob-maxima.el.

Leo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] ob-doc-maxima.org and ob-maxima.el
  2022-11-04  3:38     ` Ihor Radchenko
@ 2022-11-04 20:49       ` Leo Butler
  2022-11-05  3:40         ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Butler @ 2022-11-04 20:49 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org Mode Mailing List

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

On Fri, Nov 04 2022, Ihor Radchenko <yantar92@posteo.net> wrote:

>> +#+RESULTS: 3d-maxima
>> +[[https://orgmode.org/worg/org-contrib/babel/languages/images/maxima-3d.png]]
>> +
>
> I am a bit confused here. Did you hand-craft the results?

I did, based on what I see in ob-doc-octave.org. In the present patch
(attached), I have left the results alone.

>   
>> -#+NAME: solve-maxima
>> +#+NAME: tex-maxima
>>  #+HEADER: :exports results
>>  #+BEGIN_SRC maxima :results raw
>>    tex(exp(-x)/x);
>>  #+END_SRC
>
> Please make #+RESULTS a separate paragraph. It may otherwise not be
> correctly recognized.

Ok, I have done this in the attached patch.

>
> Let's move the ob-maxima changes and discussion about graphics to a
> separate thread.

Ok.

I believe the attached patch fixes all the problems that you saw with
the previous versions.

Leo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-contrib-babel-languages-ob-doc-maxima.org-correc.patch --]
[-- Type: text/x-diff; name="0001-org-contrib-babel-languages-ob-doc-maxima.org-correc.patch", Size: 3440 bytes --]

From a4db0ed4af22e43e817ebca110872e7ee5222c2d Mon Sep 17 00:00:00 2001
From: Leo Butler <leo.butler@umanitoba.ca>
Date: Fri, 4 Nov 2022 15:23:27 -0500
Subject: [PATCH] org-contrib/babel/languages/ob-doc-maxima.org: correct docs

* include the results of test-maxima and solve-maxima examples;
* correct the :results header of graphics example;
* rename the tex example to tex-maxima and include the results;
* add an empty line before each #+results: as suggested by Ihor.

Ref: https://list.orgmode.org/87k04b5qyf.fsf@localhost/T/#t
---
 org-contrib/babel/languages/ob-doc-maxima.org | 32 +++++++++++++++----
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/org-contrib/babel/languages/ob-doc-maxima.org b/org-contrib/babel/languages/ob-doc-maxima.org
index 810c9ef4..a6b403dc 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
+HTML export of the result:
+
+#+RESULTS: test-maxima
 : 26.06280316745402
 
 ** Solver
@@ -137,6 +139,14 @@ Of course, =maxima= is more than a calculator.
   print(solution);
 #+end_src
 
+HTML export of 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 graphics
 ,#+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,35 +164,43 @@ 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 graphics
 #+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
+HTML export of the Maxima code block result:
+
+#+RESULTS: 3d-maxima
 [[file: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
   through babel [fn:1] as in the example below, based on RS initial
   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
 
+HTML export of the result:
+
+#+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
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [BUG] ob-doc-maxima.org and ob-maxima.el
  2022-11-04 20:49       ` Leo Butler
@ 2022-11-05  3:40         ` Ihor Radchenko
  2022-11-07 14:24           ` Leo Butler
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-11-05  3:40 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode Mailing List

Leo Butler <Leo.Butler@umanitoba.ca> writes:

> I believe the attached patch fixes all the problems that you saw with
> the previous versions.

Thanks!
Applied onto master.
https://git.sr.ht/~bzg/worg/commit/c1440ba5f98634adf08209631d305c1814fb7f9a

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Clarification on :results file vs. :results graphics file (was: [BUG] ob-doc-maxima.org and ob-maxima.el)
  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       ` Ihor Radchenko
  1 sibling, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2022-11-05  3:41 UTC (permalink / raw)
  To: Leo Butler; +Cc: Org Mode Mailing List

Ihor Radchenko <yantar92@posteo.net> writes:

> (Note: I'd say "nothing is written to the disk" is a bit misleading
> here. I am attaching a patch with clarification)

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f5c89ba5f91a876e1111cbcc940e849adbb16fe2

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] ob-doc-maxima.org and ob-maxima.el
  2022-11-05  3:40         ` Ihor Radchenko
@ 2022-11-07 14:24           ` Leo Butler
  0 siblings, 0 replies; 10+ messages in thread
From: Leo Butler @ 2022-11-07 14:24 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org Mode Mailing List

On Sat, Nov 05 2022, Ihor Radchenko <yantar92@posteo.net> wrote:

> Leo Butler <Leo.Butler@umanitoba.ca> writes:
>
>> I believe the attached patch fixes all the problems that you saw with
>> the previous versions.
>
> Thanks!
> Applied onto master.
> https://git.sr.ht/~bzg/worg/commit/c1440ba5f98634adf08209631d305c1814fb7f9a

Thanks, Ihor. I can see the new page already.

https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-maxima.html

Best,
Leo

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-07 14:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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