jupyter-org--wrappable-element-p: Consider error comments wrappable

This commit is contained in:
Nathaniel Nicandro 2019-03-10 03:05:09 -05:00
parent fbbef48bee
commit 0cfb156a7e
No known key found for this signature in database
GPG key ID: C34814B309DD06B8

View file

@ -148,6 +148,8 @@ line in the previous source block. See
;;;;; `jupyter-org-error-location' ;;;;; `jupyter-org-error-location'
;; Inspiration from https://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/ ;; Inspiration from https://kitchingroup.cheme.cmu.edu/blog/2017/06/10/Adding-keymaps-to-src-blocks-via-org-font-lock-hook/
(defconst jupyter-org--goto-error-string "[goto error]")
(cl-defgeneric jupyter-org-error-location () (cl-defgeneric jupyter-org-error-location ()
"Return the line number corresponding to an error from a traceback. "Return the line number corresponding to an error from a traceback.
This method is called with `point' at `point-min' in a buffer This method is called with `point' at `point-min' in a buffer
@ -166,7 +168,7 @@ line number could not be found."
(jupyter-org-error-location))) (jupyter-org-error-location)))
0)) 0))
(point-marker)))) (point-marker))))
(propertize "[goto error]" (propertize jupyter-org--goto-error-string
'jupyter-error-loc loc 'jupyter-error-loc loc
'face 'link 'face 'link
'keymap jupyter-org-goto-error-map))) 'keymap jupyter-org-goto-error-map)))
@ -993,7 +995,14 @@ appear after the element."
(defun jupyter-org--wrappable-element-p (element) (defun jupyter-org--wrappable-element-p (element)
"Return non-nil if ELEMENT can be removed and wrapped in a drawer." "Return non-nil if ELEMENT can be removed and wrapped in a drawer."
(or (jupyter-org-babel-result-p element) (or (jupyter-org-babel-result-p element)
(memq (org-element-type) '(latex-fragment latex-environment)))) (let ((type (org-element-type element)))
(or (memq type '(latex-fragment latex-environment))
;; TODO: Figure out a better way. I predict there will be more
;; situations where a comment would be useful to add. That means
;; we would have to verify each one.
(and (eq type 'comment)
(equal jupyter-org--goto-error-string
(org-element-property :value element)))))))
;;;; Wrapping results ;;;; Wrapping results