mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:07:52 +00:00
Merge branch 'maint'
This commit is contained in:
commit
a1ca78d5b8
|
@ -308,9 +308,21 @@ last statement in BODY, as elisp."
|
|||
(list (format "open('%s', 'w').write(str(_))"
|
||||
(org-babel-process-file-name tmp-file
|
||||
'noquote)))))))
|
||||
(last-indent 0)
|
||||
(input-body (lambda (body)
|
||||
(mapc (lambda (line) (insert line) (funcall send-wait))
|
||||
(split-string body "[\r\n]"))
|
||||
(dolist (line (split-string body "[\r\n]"))
|
||||
;; Insert a blank line to end an indent
|
||||
;; block.
|
||||
(let ((curr-indent (string-match "\\S-" line)))
|
||||
(if curr-indent
|
||||
(progn
|
||||
(when (< curr-indent last-indent)
|
||||
(insert "")
|
||||
(funcall send-wait))
|
||||
(setq last-indent curr-indent))
|
||||
(setq last-indent 0)))
|
||||
(insert line)
|
||||
(funcall send-wait))
|
||||
(funcall send-wait)))
|
||||
(results
|
||||
(pcase result-type
|
||||
|
|
|
@ -118,6 +118,22 @@ return x
|
|||
(org-babel-next-src-block)
|
||||
(should (equal "20" (org-babel-execute-src-block)))))
|
||||
|
||||
(ert-deftest test-ob-python/insert-necessary-blank-line-when-sending-code-to-interpreter ()
|
||||
(org-test-with-temp-text "#+begin_src python :session :results value
|
||||
if True:
|
||||
1
|
||||
2
|
||||
#+end_src"
|
||||
;; Previously, while adding `:session' to a normal code block, also need to add extra blank lines
|
||||
;; to end indent block or indicate logical sections. Now, the `org-babel-python-evaluate-session'
|
||||
;; can do it automatically:
|
||||
;; >>> if True:
|
||||
;; >>> 1
|
||||
;; >>> <insert_blank_line_here>
|
||||
;; >>> 2
|
||||
(org-babel-execute-maybe)
|
||||
(should (equal 2 (org-babel-execute-src-block)))))
|
||||
|
||||
(provide 'test-ob-python)
|
||||
|
||||
;;; test-ob-python.el ends here
|
||||
|
|
Loading…
Reference in a new issue