Make even more unique edit-cell buffer names. Check that an edit-cell-buffer
does not already exits before creating one.

Also try to be even more aggressive in limiting output in backtraces when
debugging ein.
This commit is contained in:
John Miller 2017-04-02 08:59:02 -05:00
parent 2547226f2e
commit e88f7f3d5f
3 changed files with 18 additions and 8 deletions

View file

@ -148,8 +148,8 @@ previous value."
(interactive)
(let (ein:src--allow-write-back) (ein:edit-cell-exit)))
(defun ein:construct-cell-edit-buffer-name (bufname cell-type)
(concat "*EIN Src " bufname "[ " cell-type " ]*" ))
(defun ein:construct-cell-edit-buffer-name (bufname cid cell-type)
(concat "*EIN Src " bufname "[ " cid "/" cell-type " ]*" ))
(defun ein:get-mode-for-kernel (kernelspec)
(if (null kernelspec)
@ -201,9 +201,15 @@ appropriate language major mode. Functionality is very similar to
(error "Must be called from inside an EIN worksheet cell.")))
(nb (ein:notebook--get-nb-or-error))
(ws (ein:worksheet--get-ws-or-error))
(contents (ein:cell-get-text cell))
(type (slot-value cell 'cell-type))
(name (ein:construct-cell-edit-buffer-name (buffer-name) type))
(name (ein:construct-cell-edit-buffer-name (buffer-name) (ein:cell-id cell) type)))
(ein:aif (get-buffer name)
(switch-to-buffer-other-window it)
(ein:create-edit-cell-buffer name cell nb ws))))
(defun ein:create-edit-cell-buffer (name cell notebook worksheet)
(let* ((contents (ein:cell-get-text cell))
(type (slot-value cell 'cell-type))
(buffer (generate-new-buffer-name name))
(overlay (ein:make-source-overlay (ein:cell-input-pos-min cell)
(ein:cell-input-pos-max cell)
@ -214,17 +220,18 @@ appropriate language major mode. Functionality is very similar to
'(display nil invisible nil intangible nil))
(set-buffer-modified-p nil)
(setq buffer-file-name buffer) ;; Breaks anaconda-mode without this special fix.
(condition-case e
(ein:case-equal type
(("markdown") (markdown-mode))
(("code")
(case (ein:get-mode-for-kernel (ein:$notebook-kernelspec nb))
(case (ein:get-mode-for-kernel (ein:$notebook-kernelspec notebook))
(python (python-mode)))))
(error (message "Language mode `%s' fails with: %S"
type (nth 1 e))))
(set (make-local-variable 'ein:src--overlay) overlay)
(set (make-local-variable 'ein:src--cell) cell)
(set (make-local-variable 'ein:src--ws) ws)
(set (make-local-variable 'ein:src--ws) worksheet)
(set (make-local-variable 'ein:src--allow-write-back) t)
(ein:edit-cell-mode)))

View file

@ -184,7 +184,8 @@ See also: https://github.com/tkf/emacs-ipython-notebook/issues/94"
(metadata :initarg :metadata :initform nil :type list) ;; For nbformat >= 4
(events :initarg :events :type ein:events)
(slidetype :initarg :slidetype :initform "-" :type string)
(cell-id :initarg :cell-id :initform (ein:utils-uuid) :type string))
(cell-id :initarg :cell-id :initform (ein:utils-uuid) :type string
:accessor ein:cell-id))
"Notebook cell base class")
(defclass ein:codecell (ein:basecell)

View file

@ -80,7 +80,9 @@ As code cells hold base64-encoded image data, backtrace tends to
be VERY long. So I am setting `print-level' to *1*. Note that
setting it globally via `setq' does not work because the value
for debugger is hard-coded. See `debugger-setup-buffer'."
(let ((print-level 1))
(let ((print-level 1)
(print-length 1)
(print-circle t))
ad-do-it))
(defun ein:dev-patch-backtrace ()