emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* problem with https://orgmode.org/manual/Results-of-Evaluation.html
@ 2024-01-15  8:32 Uwe Brauer via General discussions about Org-mode.
  2024-01-15 13:21 ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer via General discussions about Org-mode. @ 2024-01-15  8:32 UTC (permalink / raw)
  To: emacs-orgmode


Hi 

I tried to use the examples of the above link

#+NAME: many-cols
| a | b | c |
|---+---+---|
| d | e | f |
|---+---+---|
| g | h | i |

#+NAME: no-hline
#+BEGIN_SRC python :var tab=many-cols :hlines no
  return tab
#+END_SRC

Now already the first failed:
,----
| 
|   File "<stdin>", line 4
|     return tab
|     ^
| IndentationError: unexpected indent
| [ Babel evaluation exited with code 1 ]
`----

Problem could be that which python on my Ubuntu system returns
Python 2.7.12

I presume the code is for python 3.X. How can I tell org to use that
one?

Regards

Uwe Brauer 

-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 




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

* Re: problem with https://orgmode.org/manual/Results-of-Evaluation.html
  2024-01-15  8:32 problem with https://orgmode.org/manual/Results-of-Evaluation.html Uwe Brauer via General discussions about Org-mode.
@ 2024-01-15 13:21 ` Ihor Radchenko
  2024-01-15 13:39   ` Uwe Brauer via General discussions about Org-mode.
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2024-01-15 13:21 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

Uwe Brauer via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> I tried to use the examples of the above link
> ...
> #+NAME: no-hline
> #+BEGIN_SRC python :var tab=many-cols :hlines no
>   return tab
> #+END_SRC
>
> Now already the first failed:
> ,----
> | 
> |   File "<stdin>", line 4
> |     return tab
> |     ^
> | IndentationError: unexpected indent
> | [ Babel evaluation exited with code 1 ]
> `----
> ...
> I presume the code is for python 3.X. How can I tell org to use that
> one?

No, this is because you customized `org-src-preserve-indentation' or
`org-edit-src-content-indentation', while the provided example only
works with default indentation settings. Python is sensitive to
whitespace and your config prevents Org mode from removing the two
spaces in the example block.

I adjusted the manual to not indent src blocks.  Then, they should work
across more wide range of user settings.

Handled.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=78754cdcf

-- 
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] 6+ messages in thread

* Re: problem with https://orgmode.org/manual/Results-of-Evaluation.html
  2024-01-15 13:21 ` Ihor Radchenko
@ 2024-01-15 13:39   ` Uwe Brauer via General discussions about Org-mode.
  2024-01-15 21:15     ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer via General discussions about Org-mode. @ 2024-01-15 13:39 UTC (permalink / raw)
  To: emacs-orgmode

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


> Uwe Brauer via "General discussions about Org-mode."
> <emacs-orgmode@gnu.org> writes:


> No, this is because you customized `org-src-preserve-indentation' or
> `org-edit-src-content-indentation', while the provided example only
> works with default indentation settings. Python is sensitive to
> whitespace and your config prevents Org mode from removing the two
> spaces in the example block.

> I adjusted the manual to not indent src blocks.  Then, they should work
> across more wide range of user settings.

Thanks, I confirm that 

#+NAME: many-cols
| a | b | c |
| d | e | f |
| g | h | i |

#+NAME: hline-please
#+BEGIN_SRC python :var tab=many-cols :hlines yes
return tab
#+END_SRC

#+RESULTS: hline-please
| a | b | c |
| d | e | f |
| g | h | i |

Works, but I also hoped that I could use python to add hlines to table
without hline, but alas it does not work!


-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: problem with https://orgmode.org/manual/Results-of-Evaluation.html
  2024-01-15 13:39   ` Uwe Brauer via General discussions about Org-mode.
@ 2024-01-15 21:15     ` Ihor Radchenko
  2024-01-16 16:27       ` Uwe Brauer via General discussions about Org-mode.
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2024-01-15 21:15 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

Uwe Brauer via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> #+NAME: many-cols
> | a | b | c |
> | d | e | f |
> | g | h | i |
>
> #+NAME: hline-please
> #+BEGIN_SRC python :var tab=many-cols :hlines yes
> return tab
> #+END_SRC
>
> #+RESULTS: hline-please
> | a | b | c |
> | d | e | f |
> | g | h | i |
>
> Works, but I also hoped that I could use python to add hlines to table
> without hline, but alas it does not work!

:hlines controls filtering ---- from input. It does nothing about code
block output.

More specifically, ":hlines no" takes care about removing hlines from
the input. ":hlines yes" does not perform any filtering.

-- 
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] 6+ messages in thread

* Re: problem with https://orgmode.org/manual/Results-of-Evaluation.html
  2024-01-15 21:15     ` Ihor Radchenko
@ 2024-01-16 16:27       ` Uwe Brauer via General discussions about Org-mode.
  2024-01-16 16:45         ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer via General discussions about Org-mode. @ 2024-01-16 16:27 UTC (permalink / raw)
  To: emacs-orgmode

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

>>> "IR" == Ihor Radchenko <yantar92@posteo.net> writes:

> Uwe Brauer via "General discussions about Org-mode."
> <emacs-orgmode@gnu.org> writes:

>> #+NAME: many-cols
>> | a | b | c |
>> | d | e | f |
>> | g | h | i |
>> 
>> #+NAME: hline-please
>> #+BEGIN_SRC python :var tab=many-cols :hlines yes
>> return tab
>> #+END_SRC
>> 
>> #+RESULTS: hline-please
>> | a | b | c |
>> | d | e | f |
>> | g | h | i |
>> 
>> Works, but I also hoped that I could use python to add hlines to table
>> without hline, but alas it does not work!

> :hlines controls filtering ---- from input. It does nothing about code
> block output.

> More specifically, ":hlines no" takes care about removing hlines from
> the input. ":hlines yes" does not perform any filtering.

Ok understood, but then, who can I add hlines to table that does not
possess any?
-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine. 


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

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

* Re: problem with https://orgmode.org/manual/Results-of-Evaluation.html
  2024-01-16 16:27       ` Uwe Brauer via General discussions about Org-mode.
@ 2024-01-16 16:45         ` Ihor Radchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2024-01-16 16:45 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

Uwe Brauer via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> Ok understood, but then, who can I add hlines to table that does not
> possess any?

#+name: test
| 1 | 2 |
| 3 | 4 |

#+name: add-hlines
#+begin_src emacs-lisp :var table='(1 2) :results value
(let (result)
  (when table
    (unless (eq 'hline (car table)) (push 'hline result))
    (while table
      (push (pop table) result)
      (unless (eq 'hline (car result))
	(push 'hline result)))
    (nreverse result)))
#+end_src


#+begin_src python :var table=test :post add-hlines(table=*this*)
return [[1+x for x in row] for row in table]
#+end_src

#+RESULTS[63f00119cafb9b4a9e762f7f19db5d5c0b215d2d]:
|---+---|
| 2 | 3 |
|---+---|
| 4 | 5 |
|---+---|


-- 
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] 6+ messages in thread

end of thread, other threads:[~2024-01-16 16:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-15  8:32 problem with https://orgmode.org/manual/Results-of-Evaluation.html Uwe Brauer via General discussions about Org-mode.
2024-01-15 13:21 ` Ihor Radchenko
2024-01-15 13:39   ` Uwe Brauer via General discussions about Org-mode.
2024-01-15 21:15     ` Ihor Radchenko
2024-01-16 16:27       ` Uwe Brauer via General discussions about Org-mode.
2024-01-16 16:45         ` 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).