jupyter-org--fixed-width-to-example-block: Use jupyter-org--delete-element

This commit is contained in:
Nathaniel Nicandro 2018-12-10 22:12:24 -06:00
parent 7e42bdd80e
commit 2e12acd8e3
No known key found for this signature in database
GPG key ID: C34814B309DD06B8

View file

@ -715,13 +715,19 @@ is a stream result. Otherwise return nil."
;;;; Appending stream results
(defun jupyter-org--delete-element (element)
"Delete an `org' ELEMENT from the buffer.
Leave its affiliated keywords and preserve and blank lines that
appear after the element."
(delete-region (or (org-element-property :post-affiliated element)
(org-element-property :begin element))
(jupyter-org-element-end-before-blanks element)))
(defun jupyter-org--fixed-width-to-example-block (element result keep-newline)
"Replace the fixed-width ELEMENT with an example-block.
Append RESULT to the contents of the block. If KEEP-NEWLINE is
non-nil, ensure that the appended RESULT begins on a newline."
(goto-char (or (org-element-property :post-affiliated element)
(org-element-property :begin element)))
(delete-region (point) (jupyter-org-element-end-before-blanks element))
(jupyter-org--delete-element element)
(insert (org-element-interpret-data
(jupyter-org-example-block
(concat
@ -840,13 +846,6 @@ Assumes `point' is at the end of the last source block result."
;; `org-element-interpret-data' already normalizes the string.
(org-element-put-property context :post-blank nil))))))
(defun jupyter-org--delete-element (element)
"Delete an `org' ELEMENT from the buffer.
Leave its affiliated keywords and preserve and blank lines that
appear after the element."
(delete-region (org-element-property :post-affiliated element)
(jupyter-org-element-end-before-blanks element)))
(defun jupyter-org--display-latex (limit)
"Show inline latex fragments between LIMIT and `point'."
(save-excursion