Closed OldIMP closed 4 years ago
Could you put a (message "got here")
on this line?
Working assumption is that it doesn't get there. In the notebook, C-h v after-change-major-mode-hook
verify poly-ein--neuter-markdown-mode is there.
I've added the message and another one at the beginning of poly-ein--neuter-markdown-mode
to debug minor-mode-map-alist
. Following are the messages that I got (some noises were stripped):
[yas] Prepared just-in-time loading of snippets successfully.
Turning on magit-auto-revert-mode...done (0.324s, 9 buffers checked)
(caar minor-mode-map-alist): magit-blame-read-only-mode
got here
(caar minor-mode-map-alist): ein:notebook-mode [5 times]
Restoring clock data
(caar minor-mode-map-alist): gnus-dead-summary-mode
got here
Desktop: 1 frame, 5 buffers restored.
(caar minor-mode-map-alist): ein:notebook-mode
(caar minor-mode-map-alist): ein:notebook-mode [2 times]
Formats have changed, recompiling...done
(caar minor-mode-map-alist): ein:notebook-mode
Updating buffer list...done
(caar minor-mode-map-alist): ein:notebook-mode [3 times]
ein: [info] ein:jupyter-server--run: c:/Users/shouh/Anaconda3/envs/tf1/Scripts/jupyter.exe notebook --notebook-dir=c:/dev/handson-ml --no-browser
ein: [info] Login to http://127.0.0.1:8888 complete.
(caar minor-mode-map-alist): ein:notebook-mode
ein: [info] Worksheet exercises_3.ipynb is ready
(caar minor-mode-map-alist): ein:notebook-mode [11 times]
That looks right. To be sure, can you run the following:
emacs -Q --batch "Worksheet exercises_3.ipynb" -f package-initialize \
--eval "(require 'ein)" \
--eval "(require 'ein-process)" \
--eval "(setq done-p nil)" \
--eval "(setq hooked-p nil)" \
--eval "(cl-loop until done-p \
do (ein:process-open-notebook* (expand-file-name buffer-file-name) \
(lambda (nb &rest _args) \
(with-current-buffer (ein:notebook-buffer nb) \
(goto-char (point-min)) \
(cl-assert (string= major-mode \"fundamental-mode\")) \
(princ (format \"%s %s \n\" major-mode (buffer-name))) \
(cl-assert (memq (function poly-ein--neuter-markdown-mode) after-change-major-mode-hook)) \
(add-hook (quote after-change-major-mode-hook) (lambda () (setf hooked-p t)) t) \
(call-interactively (function ein:worksheet-goto-next-input)) \
(pm-switch-to-buffer) \
(princ (format \"%s %s\n\" major-mode (buffer-name))) \
) \
(setq done-p t))) \
do (sleep-for 0 3000) \
finally (princ (format \"all %s\n\" (if hooked-p \"good\" \"bad\"))))"
When I run it, I get something like:
ein: [info] Login to http://127.0.0.1:8888 complete.
ein: [info] Worksheet Untitled.ipynb is ready
Can’t guess python-indent-offset, using defaults: 4
fundamental-mode *ein: http://127.0.0.1:8888/Untitled.ipynb*
ein:markdown-mode *ein: http://127.0.0.1:8888/Untitled.ipynb*[ein:markdown]
ein: [info] Notebook Untitled.ipynb is ready
all good
ein: [info] Login to http://127.0.0.1:8888 complete.
(caar minor-mode-map-alist): magit-popup-help-mode
got here
ein: [info] Worksheet exercises_3.ipynb is ready
(caar minor-mode-map-alist): ein:notebook-mode
(caar minor-mode-map-alist): outline-minor-mode
got here
ein: [info] Notebook exercises_3.ipynb is already open
fundamental-mode *ein: http://127.0.0.1:8888/exercises_3.ipynb*
python-mode *ein: http://127.0.0.1:8888/exercises_3.ipynb*[python]
fundamental-mode *ein: http://127.0.0.1:8888/exercises_3.ipynb*
python-mode *ein: http://127.0.0.1:8888/exercises_3.ipynb*[python]
ein: [info] Notebook exercises_3.ipynb is ready
(caar minor-mode-map-alist): ein:notebook-mode
(caar minor-mode-map-alist): ein:notebook-mode
all good
ein: [info] Signaled ein server with pid 17972
Try this then:
emacs "exercises_3.ipynb" \
--eval "(defun oldimp-print () \
(princ (format \"%s %s\n\" major-mode (buffer-name)) (function external-debugging-output)) \
(mapc (lambda (x) (when x (princ (format \"%s: %s\n\" (symbol-name x) (symbol-value x)) (function external-debugging-output)))) \
(mapcar (function intern-soft) (split-string \"overriding-terminal-local-map overriding-local-map emulation-mode-map-alists minor-mode-overriding-map-alist\"))) \
(princ (format \"char-prop: %s\" (get-char-property (point) (quote keymap))) (function external-debugging-output)) \
(princ (format \"local-map: %s\" (get-text-property (point) (quote local-map))) (function external-debugging-output)) \
(princ (format \"current-local-map: %s\" (current-local-map)) (function external-debugging-output)) \
(princ (format \"current-global-map: %s\" (current-global-map)) (function external-debugging-output)))" > oldimp-print 2>&1
Then C-c C-o
exercises_3.ipynb. Move the cursor to the python cell. Invoke M-: (oldimp-print)
. Exit emacs. Look for "elpy" in the file oldimp-print
.
Sry but "elpy" is not in it: oldimp-print.txt
ein:notebook-mode gets disabled inside a code cell when using elpy
emacs -Q -f package-initialize
(elpy-enable)
("EIN system info"
:emacs-version "GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
of 2019-08-29"
:emacs-bzr-version "96dd0196c28bc36779584e47fffcca433c9309cd"
:window-system w32
:emacs-variant nil
:os
(:uname nil
:lsb-release nil)
:notebook
"Name: notebook
Version: 6.0.3
Summary: A web-based notebook environment for interactive computing
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.com
License: BSD
Location: c:\\users\\shouh\\anaconda3\\envs\\tf1\\lib\\site-packages
Requires: ipython-genutils, pyzmq, ipykernel, tornado, nbformat, traitlets, Send2Trash, terminado, prometheus-client, jupyter-core, jupyter-client, jinja2, nbconvert
Required-by: widgetsnbextension, nbdime, jupyterlab, jupyterlab-server
"
:ipython "7.10.1
"
:image-types
(svg png gif tiff jpeg xpm xbm pbm)
:image-types-available
(svg png gif tiff jpeg xpm xbm pbm)
:request
(:backend curl)
:ein
(:version "20200209.35"
:source-dir "c:/Users/shouh/AppData/Roaming/.emacs.d/elpa/ein-20200209.35/")
:lib
((:name "websocket"
:path "~/.emacs.d/elpa/websocket-20200102.637/websocket.elc"
:featurep t
:version-var websocket-version
:version "1.12")
(:name "anaphora"
:path "~/.emacs.d/elpa/anaphora-20180618.2200/anaphora.elc"
:featurep t
:version-var nil
:version nil)
(:name "request"
:path "~/.emacs.d/elpa/request-20200127.21/request.elc"
:featurep t
:version-var request-version
:version "0.3.0")
(:name "deferred"
:path "~/.emacs.d/elpa/deferred-20170901.1330/deferred.elc"
:featurep t
:version-var deferred:version
:version "0.5.0")
(:name "polymode"
:path "~/.emacs.d/elpa/polymode-20191208.1239/polymode.elc"
:featurep t
:version-var nil
:version nil)
(:name "kubernetes"
:path "~/.emacs.d/elpa/kubernetes-20200114.436/kubernetes.elc"
:featurep t
:version-var nil
:version nil)
(:name "dash"
:path "~/.emacs.d/elpa/dash-20200119.2310/dash.elc"
:featurep t
:version-var nil
:version nil)
(:name "s"
:path "~/.emacs.d/elpa/s-20180406.808/s.elc"
:featurep t
:version-var nil
:version nil)))
Thank you for reporting this bug and staying with it.
I was able to finally reproduce the error with emacs -Q -f package-initialize --eval "(setq debug-on-error t)" --eval "(elpy-enable)"
. Sorry I should have tried this much earlier -- I had assumed it was a keymap issue, and not a general bug.
I hope the above PR fixes. Thanks again.
Verified that bug was fixed in 20200210.452.
Thx for the professional work! This fixed lots of other problems w/ elpy, too, e.g. now the notebook is opened in the front ground.
Whenever the cursor is inside a code cell, the Notebook minor mode will disappear and only appear again if the cursor is outside the cell or in a markdown cell.
I know this might be a feature but it makes the notebook unusable since all the keybindings belonging to the Notebook mode are replaced by the elpy ones:
C-c C-c
will send the whole buffer to shell interpreter (elpy-shell-send-region-or-buffer
) instead of eval only the code cell (ein:worksheet-execute-cell-km
)C-c C-n
will callelpy-flymake-next-error
instead of going to the next cell (ein:worksheet-goto-next-input-km
)I'm not sure if it's an issue here or in elpy.
Thanks for any fix / workaround!