[emacs] jupyter-ascending integration via code-cells
Do not edit .ipynb files in the browser anymore.
This commit is contained in:
48
.emacs
48
.emacs
@@ -38,7 +38,7 @@
|
||||
'(org-agenda-files '("~/org/1.TODO.org"))
|
||||
'(package-enable-at-startup nil)
|
||||
'(package-selected-packages
|
||||
'(clang-format+ cmake-format xterm-color dockerfile-mode web-mode prettier json-mode py-isort blacken pyvenv yaml-mode lsp-pyright ng2-mode lsp-ltex lsp-treemacs treemacs-nerd-icons treemacs-projectile treemacs lsp-ui lsp-mode which-key flycheck vterm projectile yasnippet-snippets yasnippet aggressive-indent doom-themes company-go zenburn-theme langtool smart-tabs-mode typescript-mode protobuf-mode opencl-mode glsl-mode go-mode markdown-mode srefactor irony cmake-mode company magit use-package))
|
||||
'(code-cells clang-format+ cmake-format xterm-color dockerfile-mode web-mode prettier json-mode py-isort blacken pyvenv yaml-mode lsp-pyright ng2-mode lsp-ltex lsp-treemacs treemacs-nerd-icons treemacs-projectile treemacs lsp-ui lsp-mode which-key flycheck vterm projectile yasnippet-snippets yasnippet aggressive-indent doom-themes company-go zenburn-theme langtool smart-tabs-mode typescript-mode protobuf-mode opencl-mode glsl-mode go-mode markdown-mode srefactor irony cmake-mode company magit use-package))
|
||||
'(safe-local-variable-values
|
||||
'((vc-follow-symlinks . t)
|
||||
(TeX-master . t)
|
||||
@@ -853,8 +853,52 @@
|
||||
(add-hook 'before-save-hook 'py-isort-before-save)))
|
||||
)
|
||||
|
||||
(use-package code-cells
|
||||
:mode ("\\.sync.py'" . code-cells-mode)
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.h\\'" . c-c++-header))
|
||||
:config
|
||||
(defun atu/jupyter-ascending-sync ()
|
||||
"Runs synchronization with jupyter-ascending "
|
||||
(interactive)
|
||||
(when (string-match-p ".sync.py\\'" (buffer-name))
|
||||
(unless atu/jupyter-sync-inhibit
|
||||
(call-process "python"
|
||||
nil nil nil
|
||||
"-m" "jupyter_ascending.requests.sync" "--filename" (buffer-file-name)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun atu/jupyter-ascending-eval (start end)
|
||||
"Runs cell via jupyter-ascending or python-shell-send-region"
|
||||
(interactive)
|
||||
(if (not (string-match-p ".sync.py\\'" (buffer-name)))
|
||||
(python-shell-send-region start end)
|
||||
(setq-local atu/jupyter-sync-inhibit t)
|
||||
(save-buffer)
|
||||
(setq-local atu/jupyter-sync-inhibit nil)
|
||||
(call-process "python"
|
||||
nil nil nil
|
||||
"-m" "jupyter_ascending.requests.execute"
|
||||
"--filename" (buffer-file-name)
|
||||
"--linenumber" (number-to-string (line-number-at-pos))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(setq code-cells-eval-region-commands
|
||||
(mapcar (lambda (pair)
|
||||
(if (eq (car pair) 'python-mode)
|
||||
(cons 'python-mode 'atu/jupyter-ascending-eval)
|
||||
pair))
|
||||
code-cells-eval-region-commands))
|
||||
|
||||
:hook
|
||||
(python-mode . code-cells-mode-maybe)
|
||||
(code-cells-mode . (lambda ()
|
||||
(add-hook 'after-save-hook 'atu/jupyter-ascending-sync nil 'local)))
|
||||
)
|
||||
|
||||
(use-package markdown-mode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user