Skip to content

Commit 8439d2c

Browse files
committed
Consider deferred element properties in Org >= 9.7
closes #565 * jupyter-org-client.el (jupyter-org--prepare-context): Force computation of values. (jupyter-org--insert-nonstream): Remove spurious condition on when to add a newline after inserting a result. * test/jupyter-test.el (org-babel-jupyter-issue-565): New test.
1 parent a14e27d commit 8439d2c

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

jupyter-org-client.el

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,11 @@ new \"scalar\" result with the result of calling
14251425
"Delete an `org' ELEMENT from the buffer.
14261426
Leave its affiliated keywords and preserve any blank lines that
14271427
appear after the element."
1428+
;; Force deferred property to compute the properties before deleting
1429+
;; the element from the buffer, the ELEMENT is used elsewhere even
1430+
;; after it has been removed from the buffer. For Org >= 9.7.
1431+
(when (functionp 'org-element-properties-resolve)
1432+
(org-element-properties-resolve element t))
14281433
(delete-region (jupyter-org-element-begin-after-affiliated element)
14291434
(jupyter-org-element-end-before-blanks element)))
14301435

@@ -1747,8 +1752,7 @@ If INDENTATION is nil, it defaults to `current-indentation'."
17471752
(eq (org-element-type context) 'drawer))
17481753
result
17491754
(jupyter-org-results-drawer result))))))))
1750-
(when (or (/= (point) (line-beginning-position))
1751-
(eq (org-element-type context) 'example-block))
1755+
(when (/= (point) (line-beginning-position))
17521756
;; Org objects such as file links do not have a newline added when
17531757
;; converting to their string representation by
17541758
;; `org-element-interpret-data' so insert one in these cases.

test/jupyter-test.el

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,38 @@ print(2)"
30103010
(kill-buffer (org-babel-jupyter-initiate-session
30113011
(alist-get :session params) params))))))))
30123012

3013+
(ert-deftest org-babel-jupyer-issue-565 ()
3014+
:tags '(org)
3015+
(jupyter-org-test-src-block
3016+
"\
3017+
import logging
3018+
import time
3019+
logging.basicConfig(level=logging.INFO)
3020+
log = logging.getLogger(__name__)
3021+
for i in range(10):
3022+
log.info(\"here\")
3023+
time.sleep(0.1)
3024+
3025+
{1: 2}"
3026+
"\
3027+
:RESULTS:
3028+
#+begin_example
3029+
INFO:__main__:here
3030+
INFO:__main__:here
3031+
INFO:__main__:here
3032+
INFO:__main__:here
3033+
INFO:__main__:here
3034+
INFO:__main__:here
3035+
INFO:__main__:here
3036+
INFO:__main__:here
3037+
INFO:__main__:here
3038+
INFO:__main__:here
3039+
#+end_example
3040+
| 1: | 2 |
3041+
:END:
3042+
"
3043+
:async "yes"))
3044+
30133045
(ert-deftest org-babel-src-block-name-resolution ()
30143046
:tags '(org)
30153047
(let ((src (format "\

0 commit comments

Comments
 (0)