mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 17:41:40 -05:00
commit
d2232a9814
1 changed files with 20 additions and 2 deletions
|
@ -187,7 +187,8 @@ See also: https://github.com/tkf/emacs-ipython-notebook/issues/94"
|
||||||
"Notebook cell base class")
|
"Notebook cell base class")
|
||||||
|
|
||||||
(defclass ein:codecell (ein:basecell)
|
(defclass ein:codecell (ein:basecell)
|
||||||
((cell-type :initarg :cell-type :initform "code")
|
((traceback :initform nil :initarg :traceback :type list)
|
||||||
|
(cell-type :initarg :cell-type :initform "code")
|
||||||
(kernel :initarg :kernel :type ein:$kernel)
|
(kernel :initarg :kernel :type ein:$kernel)
|
||||||
(element-names :initform (:prompt :input :output :footer))
|
(element-names :initform (:prompt :input :output :footer))
|
||||||
(input-prompt-number :initarg :input-prompt-number
|
(input-prompt-number :initarg :input-prompt-number
|
||||||
|
@ -753,6 +754,7 @@ If END is non-`nil', return the location of next element."
|
||||||
;; instantaneously for now.
|
;; instantaneously for now.
|
||||||
(ein:log 'debug "cell-clear-output stdout=%s stderr=%s other=%s"
|
(ein:log 'debug "cell-clear-output stdout=%s stderr=%s other=%s"
|
||||||
stdout stderr other)
|
stdout stderr other)
|
||||||
|
(oset cell :traceback nil)
|
||||||
(let ((ewoc (oref cell :ewoc))
|
(let ((ewoc (oref cell :ewoc))
|
||||||
(output-nodes (ein:cell-element-get cell :output)))
|
(output-nodes (ein:cell-element-get cell :output)))
|
||||||
(if (and stdout stderr other)
|
(if (and stdout stderr other)
|
||||||
|
@ -808,6 +810,20 @@ If END is non-`nil', return the location of next element."
|
||||||
(intern (format "output-%s" (plist-get json :stream)))))))
|
(intern (format "output-%s" (plist-get json :stream)))))))
|
||||||
|
|
||||||
(defmethod ein:cell-append-output ((cell ein:codecell) json dynamic)
|
(defmethod ein:cell-append-output ((cell ein:codecell) json dynamic)
|
||||||
|
;; When there is a python error, we actually get two identical tracebacks back
|
||||||
|
;; from the kernel, one from the "shell" channel, and one from the "iopub"
|
||||||
|
;; channel. As a workaround, we remember the cell's traceback and ignore
|
||||||
|
;; traceback outputs that are identical to the one we already have.
|
||||||
|
(let ((new-tb (plist-get json :traceback))
|
||||||
|
(old-tb (oref cell :traceback)))
|
||||||
|
(when (or
|
||||||
|
(null old-tb)
|
||||||
|
(null new-tb)
|
||||||
|
(not (equalp new-tb old-tb)))
|
||||||
|
(ein:cell-actually-append-output cell json dynamic))
|
||||||
|
(oset cell :traceback new-tb)))
|
||||||
|
|
||||||
|
(defmethod ein:cell-actually-append-output ((cell ein:codecell) json dynamic)
|
||||||
(ein:cell-expand cell)
|
(ein:cell-expand cell)
|
||||||
;; (ein:flush-clear-timeout)
|
;; (ein:flush-clear-timeout)
|
||||||
(oset cell :outputs
|
(oset cell :outputs
|
||||||
|
@ -1198,7 +1214,9 @@ prettified text thus be used instead of HTML type."
|
||||||
|
|
||||||
(defmethod ein:cell-get-tb-data ((cell ein:codecell))
|
(defmethod ein:cell-get-tb-data ((cell ein:codecell))
|
||||||
(loop for out in (oref cell :outputs)
|
(loop for out in (oref cell :outputs)
|
||||||
when (equal (plist-get out :output_type) "pyerr")
|
when (and
|
||||||
|
(not (null (plist-get out :traceback)))
|
||||||
|
(member (plist-get out :output_type) '("pyerr" "error")))
|
||||||
return (plist-get out :traceback)))
|
return (plist-get out :traceback)))
|
||||||
|
|
||||||
(provide 'ein-cell)
|
(provide 'ein-cell)
|
||||||
|
|
Loading…
Add table
Reference in a new issue