jupyter-org--wrap-result-maybe: Use cond

This commit is contained in:
Nathaniel Nicandro 2019-06-11 15:22:27 -05:00
parent 87bd83c99b
commit 44e3823a93

View file

@ -1130,19 +1130,20 @@ appear after the element."
(defun jupyter-org--wrap-result-maybe (context result)
"Depending on CONTEXT, wrap RESULT in a drawer."
;; If a keyword is the context, this is the first result.
(if (eq (org-element-type context) 'keyword)
(cond
((eq (org-element-type context) 'keyword)
;; Only wrap the result if it can't be removed by `org-babel'.
(if (jupyter-org-babel-result-p result) result
(jupyter-org-results-drawer result))
(if (jupyter-org--wrappable-element-p context)
(jupyter-org-results-drawer result)))
((jupyter-org--wrappable-element-p context)
(prog1 (jupyter-org-results-drawer context result)
;; Ensure that a #+RESULTS: line is not prepended to context
;; when calling `org-element-interpret-data'.
;; Ensure that a #+RESULTS: line is not prepended to context when calling
;; `org-element-interpret-data'.
(org-element-put-property context :results nil)
;; Ensure there is no post-blank since
;; `org-element-interpret-data' already normalizes the string.
(org-element-put-property context :post-blank nil))
;; Ensure there is no post-blank since `org-element-interpret-data'
;; already normalizes the string.
(org-element-put-property context :post-blank nil)))
(t
result)))
;;;; Stream results