mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 09:01:40 -05:00
Merge pull request #592 from dickmao/nix
Follow-up customizable default kernel; make ob-ein usable
This commit is contained in:
commit
8abb37f844
5 changed files with 31 additions and 27 deletions
|
@ -57,7 +57,6 @@ install:
|
|||
pyenv activate $TOXENV ;
|
||||
fi
|
||||
- ${PIP} --upgrade pip
|
||||
- ${PIP} wheel
|
||||
- ${PIP} wheel jupyter ipython\<=$IPYTHON jedi\<=0.13.3 ipykernel numpy\<=1.16.0 matplotlib\<=3.0.2
|
||||
- ${PY} -m ipykernel install --user
|
||||
- sh tools/install-R.sh
|
||||
|
|
6
Makefile
6
Makefile
|
@ -60,7 +60,7 @@ test-compile: clean autoloads
|
|||
cask clean-elc
|
||||
|
||||
.PHONY: quick
|
||||
quick: test-compile test-unit
|
||||
quick: test-compile test-ob-ein-recurse test-unit
|
||||
|
||||
.PHONY: test-jupyterhub
|
||||
test-jupyterhub: test-compile
|
||||
|
@ -86,6 +86,10 @@ test-int:
|
|||
test-unit:
|
||||
cask exec ert-runner -L ./lisp -L ./test -l test/testein.el test/test-ein*.el
|
||||
|
||||
.PHONY: test-ob-ein-recurse
|
||||
test-ob-ein-recurse:
|
||||
cask eval "(progn (custom-set-variables (quote (org-babel-load-languages (quote ((emacs-lisp . t) (ein . t)))))) (org-version))"
|
||||
|
||||
.PHONY: test-install
|
||||
test-install:
|
||||
mkdir -p test/test-install
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
|
||||
(Setup
|
||||
(ein:dev-start-debug)
|
||||
(setq ein:notebooklist-default-kernel
|
||||
(setq ein:jupyter-default-kernel
|
||||
(loop with cand = ""
|
||||
for (k . spec) in
|
||||
(alist-get
|
||||
|
|
|
@ -74,6 +74,27 @@ Changing this to `jupyter-notebook' requires customizing `ein:jupyter-server-use
|
|||
:type '(choice (string :tag "Subcommand" "notebook")
|
||||
(const :tag "Omit" nil)))
|
||||
|
||||
(defcustom ein:jupyter-default-kernel 'first-alphabetically
|
||||
"With which of ${XDG_DATA_HOME}/jupyter/kernels to create new notebooks."
|
||||
:group 'ein
|
||||
:type (append
|
||||
'(choice (other :tag "First alphabetically" first-alphabetically))
|
||||
(condition-case err
|
||||
(mapcar
|
||||
(lambda (x) `(const :tag ,(cdr x) ,(car x)))
|
||||
(loop
|
||||
for (k . spec) in
|
||||
(alist-get
|
||||
'kernelspecs
|
||||
(let ((json-object-type 'alist))
|
||||
(json-read-from-string
|
||||
(shell-command-to-string
|
||||
(format "%s kernelspec list --json"
|
||||
ein:jupyter-default-server-command)))))
|
||||
collect `(,k . ,(alist-get 'display_name (alist-get 'spec spec)))))
|
||||
(error (ein:log 'warn "ein:jupyter-default-kernel: %s" err)
|
||||
'((string :tag "Ask"))))))
|
||||
|
||||
(defsubst ein:jupyter-server-process ()
|
||||
"Return the emacs process object of our session"
|
||||
(get-buffer-process (get-buffer ein:jupyter-server-buffer-name)))
|
||||
|
|
|
@ -49,26 +49,6 @@
|
|||
:type 'integer
|
||||
)
|
||||
|
||||
(defcustom ein:notebooklist-default-kernel 'first-alphabetically
|
||||
"With which of ${XDG_DATA_HOME}/jupyter/kernels to create new notebooks."
|
||||
:group 'ein
|
||||
:type (append
|
||||
'(choice (other :tag "First alphabetically" first-alphabetically))
|
||||
(condition-case nil
|
||||
(mapcar
|
||||
(lambda (x) `(const :tag ,(cdr x) ,(car x)))
|
||||
(loop
|
||||
for (k . spec) in
|
||||
(alist-get
|
||||
'kernelspecs
|
||||
(let ((json-object-type 'alist))
|
||||
(json-read-from-string
|
||||
(shell-command-to-string
|
||||
(format "%s kernelspec list --json"
|
||||
ein:jupyter-default-server-command)))))
|
||||
collect `(,k . ,(alist-get 'display_name (alist-get 'spec spec)))))
|
||||
(error '((string :tag "Ask"))))))
|
||||
|
||||
(defcustom ein:notebooklist-render-order
|
||||
'(render-header
|
||||
render-opened-notebooks
|
||||
|
@ -619,12 +599,12 @@ This function is called via `ein:notebook-after-rename-hook'."
|
|||
(widget-radio-add-item radio-widget (list 'item
|
||||
:value (car k)
|
||||
:format (format "%s\n" (cdr k)))))
|
||||
(unless (eq ein:notebooklist-default-kernel 'first-alphabetically)
|
||||
(unless (eq ein:jupyter-default-kernel 'first-alphabetically)
|
||||
(widget-radio-value-set
|
||||
radio-widget
|
||||
(if (stringp ein:notebooklist-default-kernel)
|
||||
ein:notebooklist-default-kernel
|
||||
(symbol-name ein:notebooklist-default-kernel))))
|
||||
(if (stringp ein:jupyter-default-kernel)
|
||||
ein:jupyter-default-kernel
|
||||
(symbol-name ein:jupyter-default-kernel))))
|
||||
(widget-insert "\n"))))))
|
||||
|
||||
(defun render-opened-notebooks (url-or-port &rest args)
|
||||
|
|
Loading…
Add table
Reference in a new issue