ob-ipython
ob-ipython copied to clipboard
Graphic problems - issue #12 is back
I am experiencing the the issue exactly as described in #12 with emacs 25 and or 8.3 with ob-python freshly installed from MELPA, version 20151010.307 I am running on Linux Mint 17.3 Rosa.
+BEGIN_SRC emacs-lisp
(emacs-version)
+END_SRC
+RESULTS:
: GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.10.8) : of 2016-02-19
+BEGIN_SRC emacs-lisp
(org-version)
+END_SRC
+RESULTS:
: 8.3.4
I have tracked down the problem to having
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
in my .emacs
I have since found out that this is obsolete/deprecated, but it once used to be a popular/recommended way to prevent trailing whitespace in code. Removing the above solves the problem for me, but given the number of people who reported experiencing this in #12 and #3, it is worth recording this somewhere for future reference
Here is a minimal or file to reproduce the problem started with emacs -Q
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+TITLE: Image display in ob-ipython is incomatible with 'delete-trailing-whitespace in writefile-hooks
- Minimal Org Customization #+BEGIN_SRC emacs-lisp (custom-set-variables '(python-shell-completion-native-enable nil) '(org-confirm-babel-evaluate nil)) #+END_SRC
- The cause of the problem
The problem only manifests if this command is executed
#+BEGIN_SRC emacs-lisp (add-hook 'write-file-hooks 'delete-trailing-whitespace) #+END_SRC
-
Initialization ** Initialize emacs packages
#+BEGIN_SRC emacs-lisp (package-initialize) (require 'ob-ipython) (org-toggle-inline-images) #+END_SRC
** Set up matplotlib
#+BEGIN_SRC ipython :session %matplotlib inline import matplotlib.pyplot as plt import numpy as np #+END_SRC
-
Trigger the problem
#+BEGIN_SRC ipython :session :file image.png :exports both plt.hist(np.random.randn(20000), bins=200) #+END_SRC
I faced a similar issue. For me, it was because I was cleaning up extra whitespace in before-save-hook
.
I fixed it by excluding whitespace cleanup while in a buffer that is in image-mode
.