mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 09:01:40 -05:00
Merge pull request #531 from dickmao/issue-530
If you see something, say something
This commit is contained in:
commit
74e79c7b94
5 changed files with 48 additions and 37 deletions
|
@ -46,6 +46,7 @@ Scenario: Collapse doesn't break undo
|
|||
And I press "C-<up>"
|
||||
And I press "C-c C-e"
|
||||
And I press "C-/"
|
||||
And I dump buffer
|
||||
Then the cursor should be at point "77"
|
||||
And I undo again
|
||||
Then the cursor should be at point "55"
|
||||
|
|
|
@ -95,10 +95,6 @@
|
|||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python",
|
||||
"name": "python3"
|
||||
},
|
||||
"name": "undo.ipynb"
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
@ -162,7 +162,10 @@ This function may raise an error."
|
|||
(set-keymap-parent ein:notebook-multilang-mode-map ess-r-mode-map))))
|
||||
|
||||
(defun ein:ml-lang-setup (kernelspec)
|
||||
(funcall (intern (concat "ein:ml-lang-setup-" (ein:$kernelspec-language kernelspec)))))
|
||||
(let ((setup-func (intern (concat "ein:ml-lang-setup-" (ein:$kernelspec-language kernelspec)))))
|
||||
(if (fboundp setup-func)
|
||||
(funcall setup-func)
|
||||
(error "ein:ml-lang-setup: kernelspec language '%s' unsupported" (ein:$kernelspec-language kernelspec)))))
|
||||
|
||||
;; (defun ein:ml-lang-setup-markdown ()
|
||||
;; "Use `markdown-mode-map'. NOTE: This function is not used now."
|
||||
|
|
|
@ -403,22 +403,25 @@ where `created' indicates a new notebook or an existing one.
|
|||
(ein:notebook-maybe-set-kernelspec notebook (plist-get (ein:$content-raw-content content) :metadata))
|
||||
(ein:notebook-install-kernel notebook)
|
||||
(ein:notebook-from-json notebook (ein:$content-raw-content content))
|
||||
;; Start websocket only after worksheet is rendered
|
||||
;; because ein:notification-bind-events only gets called after worksheet's
|
||||
;; buffer local notification widget is instantiated
|
||||
(ein:kernel-retrieve-session (ein:$notebook-kernel notebook))
|
||||
(setf (ein:$notebook-kernelinfo notebook)
|
||||
(ein:kernelinfo-new (ein:$notebook-kernel notebook)
|
||||
(cons #'ein:notebook-buffer-list notebook)
|
||||
(symbol-name (ein:get-mode-for-kernel (ein:$notebook-kernelspec notebook)))))
|
||||
(ein:notebook-put-opened-notebook notebook)
|
||||
(ein:notebook--check-nbformat (ein:$content-raw-content content))
|
||||
(setf (ein:$notebook-q-checkpoints notebook) q-checkpoints)
|
||||
(ein:notebook-enable-autosaves notebook)
|
||||
(ein:gc-complete-operation)
|
||||
(ein:log 'info "Notebook %s is ready" (ein:$notebook-notebook-name notebook)))
|
||||
(when callback0
|
||||
(funcall callback0)))
|
||||
(if (not (with-current-buffer (ein:notebook-buffer notebook)
|
||||
(ein:get-notebook)))
|
||||
(error "ein:notebook-open--callback: notebook instantiation failed")
|
||||
;; Start websocket only after worksheet is rendered
|
||||
;; because ein:notification-bind-events only gets called after worksheet's
|
||||
;; buffer local notification widget is instantiated
|
||||
(ein:kernel-retrieve-session (ein:$notebook-kernel notebook))
|
||||
(setf (ein:$notebook-kernelinfo notebook)
|
||||
(ein:kernelinfo-new (ein:$notebook-kernel notebook)
|
||||
(cons #'ein:notebook-buffer-list notebook)
|
||||
(symbol-name (ein:get-mode-for-kernel (ein:$notebook-kernelspec notebook)))))
|
||||
(ein:notebook-put-opened-notebook notebook)
|
||||
(ein:notebook--check-nbformat (ein:$content-raw-content content))
|
||||
(setf (ein:$notebook-q-checkpoints notebook) q-checkpoints)
|
||||
(ein:notebook-enable-autosaves notebook)
|
||||
(ein:gc-complete-operation)
|
||||
(ein:log 'info "Notebook %s is ready" (ein:$notebook-notebook-name notebook))
|
||||
(when callback0
|
||||
(funcall callback0)))))
|
||||
|
||||
(defun ein:notebook-maybe-set-kernelspec (notebook content-metadata)
|
||||
(ein:aif (plist-get content-metadata :kernelspec)
|
||||
|
@ -666,22 +669,27 @@ This is equivalent to do ``C-c`` in the console program."
|
|||
(defun ein:notebook--worksheet-render (notebook ws)
|
||||
(ein:worksheet-render ws)
|
||||
(with-current-buffer (ein:worksheet-buffer ws)
|
||||
(if ein:polymode
|
||||
(poly-ein-mode)
|
||||
;; Changing major mode here is super dangerous as it
|
||||
;; kill-all-local-variables.
|
||||
;; Our saviour has been `ein:deflocal' which applies 'permanent-local
|
||||
;; to variables assigned up to this point, but we ought not rely on it
|
||||
(funcall (ein:notebook-choose-mode))
|
||||
(ein:worksheet-reinstall-undo-hooks ws)
|
||||
(ein:aif (ein:$notebook-kernelspec notebook)
|
||||
(ein:ml-lang-setup it)))
|
||||
(ein:notebook-mode)
|
||||
(ein:notebook--notification-setup notebook)
|
||||
(ein:notebook-setup-kill-buffer-hook)
|
||||
(setq ein:%notebook% notebook)
|
||||
(when ein:polymode
|
||||
(poly-ein-fontify-buffer notebook))))
|
||||
(let (multilang-failed)
|
||||
(if ein:polymode
|
||||
(poly-ein-mode)
|
||||
;; Changing major mode here is super dangerous as it
|
||||
;; kill-all-local-variables.
|
||||
;; Our saviour has been `ein:deflocal' which applies 'permanent-local
|
||||
;; to variables assigned up to this point, but we ought not rely on it
|
||||
(funcall (ein:notebook-choose-mode))
|
||||
(ein:worksheet-reinstall-undo-hooks ws)
|
||||
(condition-case err
|
||||
(ein:aif (ein:$notebook-kernelspec notebook)
|
||||
(ein:ml-lang-setup it))
|
||||
(error (ein:log 'error (error-message-string err))
|
||||
(setq multilang-failed t))))
|
||||
(unless multilang-failed
|
||||
(ein:notebook-mode)
|
||||
(ein:notebook--notification-setup notebook)
|
||||
(ein:notebook-setup-kill-buffer-hook)
|
||||
(setq ein:%notebook% notebook)
|
||||
(when ein:polymode
|
||||
(poly-ein-fontify-buffer notebook))))))
|
||||
|
||||
(defun ein:notebook--notification-setup (notebook)
|
||||
(ein:notification-setup
|
||||
|
|
|
@ -50,6 +50,9 @@ TYPE can be 'body, nil."
|
|||
((ein:markdowncell-p cell) "markdown")
|
||||
(t "fundamental"))))
|
||||
((not (equal mode (ein:oref-safe cm :mode)))))
|
||||
(when (eq mode 'poly-fallback-mode)
|
||||
(ein:display-warning
|
||||
(format "pm:get-span: no major mode for kernelspec language '%s'" lang)))
|
||||
(setq result-cm
|
||||
(loop for ocm in (eieio-oref pm/polymode '-auto-innermodes)
|
||||
when (equal mode (ein:oref-safe ocm :mode))
|
||||
|
|
Loading…
Add table
Reference in a new issue