From b1d8ad12349d922c2778d72c5fbc49af14a9026d Mon Sep 17 00:00:00 2001 From: finalpatch Date: Wed, 25 Apr 2018 20:56:28 +1000 Subject: [PATCH 1/7] fix async execution of 'silent' blocks --- ob-ipython.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ob-ipython.el b/ob-ipython.el index 043fb9a..b33e9a3 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -593,6 +593,7 @@ This function is called by `org-babel-execute-src-block'." (let* ((file (cdr (assoc :ipyfile params))) (session (cdr (assoc :session params))) (result-type (cdr (assoc :result-type params))) + (result-params (cdr (assoc :result-params params))) (sentinel (ipython--async-gen-sentinel))) (ob-ipython--create-kernel (ob-ipython--normalize-session session) (cdr (assoc :kernel params))) @@ -600,10 +601,11 @@ This function is called by `org-babel-execute-src-block'." (org-babel-expand-body:generic (encode-coding-string body 'utf-8) params (org-babel-variable-assignments:python params)) (ob-ipython--normalize-session session) - (lambda (ret sentinel buffer file result-type) - (let ((replacement (ob-ipython--process-response ret file result-type))) - (ipython--async-replace-sentinel sentinel buffer replacement))) - (list sentinel (current-buffer) file result-type)) + (lambda (ret sentinel buffer file result-type result-params) + (unless (member "silent" result-params) + (let ((replacement (ob-ipython--process-response ret file result-type))) + (ipython--async-replace-sentinel sentinel buffer replacement)))) + (list sentinel (current-buffer) file result-type result-params)) (format "%s - %s" (length ob-ipython--async-queue) sentinel))) (defun ob-ipython--execute-sync (body params) From 1e167a1bb70c88ac1866575a034f0c4b855c6280 Mon Sep 17 00:00:00 2001 From: finalpatch Date: Wed, 25 Apr 2018 20:56:48 +1000 Subject: [PATCH 2/7] fix pandas DataFrame output header alignment --- ob-ipython.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ob-ipython.el b/ob-ipython.el index b33e9a3..73005cd 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -658,7 +658,7 @@ This function is called by `org-babel-execute-src-block'." (let ((lines (s-lines value))) (if (cdr lines) (->> lines - (-map 's-trim) + (-map 's-trim-right) (s-join "\n ") (s-concat " ") (format "#+BEGIN_EXAMPLE\n%s\n#+END_EXAMPLE")) From 4297b42c23e05e16dad91cb886d99740ad4bc79d Mon Sep 17 00:00:00 2001 From: finalpatch Date: Sat, 23 Mar 2019 23:49:41 +1100 Subject: [PATCH 3/7] PR 194 --- ob-ipython.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ob-ipython.el b/ob-ipython.el index 73005cd..3f1182b 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -313,7 +313,7 @@ a new kernel will be started." (defun ob-ipython--maybe-run-async () (when (not (ob-ipython--running-p)) - (when-let (val (ob-ipython--dequeue 'ob-ipython--async-queue)) + (-when-let (val (ob-ipython--dequeue 'ob-ipython--async-queue)) (cl-destructuring-bind (code name callback args) val (ob-ipython--run-async code name callback args))))) From 6e56af40fb81e52283846b9614e78a69cc63dd8d Mon Sep 17 00:00:00 2001 From: finalpatch Date: Sat, 23 Mar 2019 23:53:49 +1100 Subject: [PATCH 4/7] PR 187 --- ob-ipython.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ob-ipython.el b/ob-ipython.el index 3f1182b..7b868ec 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -64,6 +64,10 @@ "Directory where resources (e.g images) are stored so that they can be displayed.") +(defcustom ob-ipython-suppress-execution-count nil + "If non-nil do not show the execution count in output." + :group 'ob-ipython) + ;; utils (defun ob-ipython--write-string-to-file (file string) @@ -628,11 +632,13 @@ This function is called by `org-babel-execute-src-block'." output (ob-ipython--output output nil) (s-concat - (format "# Out[%d]:\n" (cdr (assoc :exec-count ret))) - (s-join "\n" (->> (-map (-partial 'ob-ipython--render file) - (list (cdr (assoc :value result)) - (cdr (assoc :display result)))) - (remove-if-not nil))))))) + (if ob-ipython-suppress-execution-count + "" + (format "# Out[%d]:\n" (cdr (assoc :exec-count ret))) + (s-join "\n" (->> (-map (-partial 'ob-ipython--render file) + (list (cdr (assoc :value result)) + (cdr (assoc :display result)))) + (remove-if-not nil)))))))) (defun ob-ipython--render (file-or-nil values) (let ((org (lambda (value) value)) From 9a47fcca26908f29c727226921a2f4ca4b0d2781 Mon Sep 17 00:00:00 2001 From: finalpatch Date: Sun, 24 Mar 2019 00:00:14 +1100 Subject: [PATCH 5/7] PR 132 --- ob-ipython.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ob-ipython.el b/ob-ipython.el index 7b868ec..cefdf3c 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -169,10 +169,12 @@ can be displayed.") (apply 'start-process name buf (car cmd) (cdr cmd)))) (defun ob-ipython--get-python () - (locate-file (if (eq system-type 'windows-nt) - "python.exe" - (or python-shell-interpreter "python")) - exec-path)) + (let* ((python-candidate (if (eq system-type 'windows-nt) + "python.exe" + "python"))) + (locate-file (or python-shell-interpreter + python-candidate) + exec-path))) (defun ob-ipython--create-kernel (name &optional kernel) (when (and (not (ignore-errors (process-live-p (get-process (format "kernel-%s" name))))) From fcddf92afbf65247de8e1d57546619ba5101332d Mon Sep 17 00:00:00 2001 From: finalpatch Date: Sun, 24 Mar 2019 00:19:53 +1100 Subject: [PATCH 6/7] Revert "PR 132" This reverts commit 9a47fcca26908f29c727226921a2f4ca4b0d2781. --- ob-ipython.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ob-ipython.el b/ob-ipython.el index cefdf3c..7b868ec 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -169,12 +169,10 @@ can be displayed.") (apply 'start-process name buf (car cmd) (cdr cmd)))) (defun ob-ipython--get-python () - (let* ((python-candidate (if (eq system-type 'windows-nt) - "python.exe" - "python"))) - (locate-file (or python-shell-interpreter - python-candidate) - exec-path))) + (locate-file (if (eq system-type 'windows-nt) + "python.exe" + (or python-shell-interpreter "python")) + exec-path)) (defun ob-ipython--create-kernel (name &optional kernel) (when (and (not (ignore-errors (process-live-p (get-process (format "kernel-%s" name))))) From 2ae885da5f0582e34b82fd54de6a1421e6b4ba9c Mon Sep 17 00:00:00 2001 From: finalpatch Date: Sun, 24 Mar 2019 00:21:14 +1100 Subject: [PATCH 7/7] fix PR 187 --- ob-ipython.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ob-ipython.el b/ob-ipython.el index 7b868ec..4dd9129 100644 --- a/ob-ipython.el +++ b/ob-ipython.el @@ -634,11 +634,11 @@ This function is called by `org-babel-execute-src-block'." (s-concat (if ob-ipython-suppress-execution-count "" - (format "# Out[%d]:\n" (cdr (assoc :exec-count ret))) - (s-join "\n" (->> (-map (-partial 'ob-ipython--render file) - (list (cdr (assoc :value result)) - (cdr (assoc :display result)))) - (remove-if-not nil)))))))) + (format "# Out[%d]:\n" (cdr (assoc :exec-count ret)))) + (s-join "\n" (->> (-map (-partial 'ob-ipython--render file) + (list (cdr (assoc :value result)) + (cdr (assoc :display result)))) + (remove-if-not nil))))))) (defun ob-ipython--render (file-or-nil values) (let ((org (lambda (value) value))