scimax icon indicating copy to clipboard operation
scimax copied to clipboard

`ob-ipython` output does not respect `org-babel-min-lines-for-block-output`

Open timehaven opened this issue 6 years ago • 3 comments

Is it possible to have ob-ipython output be consistent with other org mode src block results? Here is an example comparing sh, python and ipython src blocks with two different values of org-babel-min-lines-for-block-output, showing how to either prepend : or wrap all output in an example block.

Thank you.

#+BEGIN_SRC emacs-lisp
(setq org-babel-min-lines-for-block-output 10)
#+END_SRC

#+RESULTS:
: 10

#+BEGIN_SRC sh :results output
ls -l /tmp/* | head -4
#+END_SRC

#+RESULTS:
: srwxrwxrwx  1 root      wheel       0 Oct 27 21:45 /tmp/crdntcommandd
: srwxrwxrwx  1 rwoodard  wheel       0 Oct 27 21:45 /tmp/crdntemsevtmond.11243
: srwxrwxrwx  1 root      wheel       0 Oct 27 21:45 /tmp/crdntevtmond
: -rw-------  1 rwoodard  wheel   10551 Nov  5 08:18 /tmp/pulse8lSRUV

#+BEGIN_SRC python
print('\n'.join(map(str, range(4))))
#+END_SRC

#+RESULTS:
: 0
: 1
: 2
: 3

#+BEGIN_SRC ipython
print('\n'.join(map(str, range(4))))
#+END_SRC

#+RESULTS:
:RESULTS:
# Out[506]:
# output
: 0
: 1
: 2
: 3
: 
:END:

#+BEGIN_SRC emacs-lisp
(setq org-babel-min-lines-for-block-output 2)
#+END_SRC

#+RESULTS:
: 2

#+BEGIN_SRC sh :results output
ls -l /tmp/* | head -4
#+END_SRC

#+RESULTS:
#+begin_example
srwxrwxrwx  1 root      wheel       0 Oct 27 21:45 /tmp/crdntcommandd
srwxrwxrwx  1 rwoodard  wheel       0 Oct 27 21:45 /tmp/crdntemsevtmond.11243
srwxrwxrwx  1 root      wheel       0 Oct 27 21:45 /tmp/crdntevtmond
-rw-------  1 rwoodard  wheel   10551 Nov  5 08:18 /tmp/pulse8lSRUV
#+end_example

#+BEGIN_SRC python
print('\n'.join(map(str, range(4))))
#+END_SRC

#+RESULTS:
#+begin_example
0
1
2
3
#+end_example

#+BEGIN_SRC ipython
print('\n'.join(map(str, range(4))))
#+END_SRC

#+RESULTS:
:RESULTS:
# Out[507]:
# output
: 0
: 1
: 2
: 3
: 
:END:

timehaven avatar Nov 05 '18 17:11 timehaven

I have no objection. Care to make a pull request?

jkitchin avatar Nov 05 '18 18:11 jkitchin

Ah, would this be in upstream ob-ipython? Do you copy its latest or have you frozen your own version of ob-ipython within scimax?

Regardless, I'll dig into the code.

timehaven avatar Nov 05 '18 20:11 timehaven

If you can figure out where it goes, you could do a pull request on scimax-org-babel-ipython-upstream.el. There are a lot of functions that are redefined in there to get desired behavior like this.

jkitchin avatar Nov 05 '18 20:11 jkitchin