diff --git a/features/notebooklist.feature b/features/notebooklist.feature index e3559a5..c0763b8 100644 --- a/features/notebooklist.feature +++ b/features/notebooklist.feature @@ -99,6 +99,17 @@ Scenario: Bad curl invocation produces sensible error message Scenario: jupyter not found And I start bad jupyter path +@jupyter-notebook +Scenario: Someone uses jupyter-notebook + Given I customize "ein:jupyter-default-server-command" to "jupyter-notebook" + And I set "ein:jupyter-server-use-subcommand" to eval "nil" + Given I start and login to the server configured "\n" + And I switch to log expr "ein:log-all-buffer-name" + Then I should not see "[warn]" + And I should not see "[error]" + And I customize "ein:jupyter-default-server-command" to "jupyter" + And I set "ein:jupyter-server-use-subcommand" to "notebook" + @login Scenario: With token server Given I start and login to the server configured "\n" diff --git a/features/step-definitions/ein-steps.el b/features/step-definitions/ein-steps.el index e2ca7b0..d9220d3 100644 --- a/features/step-definitions/ein-steps.el +++ b/features/step-definitions/ein-steps.el @@ -408,6 +408,10 @@ (let ((member-p (member value (symbol-value (intern variable))))) (if negate (should-not member-p) (should member-p))))) +(When "^I customize \"\\(.+\\)\" to \"\\(.+\\)\"$" + (lambda (variable value) + (custom-set-variables `(,(intern variable) ,value t)))) + (When "^I set \"\\(.+\\)\" to \"\\(.+\\)\"$" (lambda (variable value) (set (intern variable) value))) diff --git a/lisp/ein-core.el b/lisp/ein-core.el index 16495c9..9bca8b5 100644 --- a/lisp/ein-core.el +++ b/lisp/ein-core.el @@ -61,14 +61,6 @@ Notebook server." (const :tag "First value of `ein:url-or-port'" nil)) :group 'ein) -(defcustom ein:jupyter-default-server-command "jupyter" - "The default command to start a jupyter notebook server. - -It is used when the `ein:jupyter-server-start' command is -interactively called." - :group 'ein - :type '(file)) - (defcustom ein:filename-translations nil "Convert file paths between Emacs and Python process. diff --git a/lisp/ein-jupyter.el b/lisp/ein-jupyter.el index 88cf368..f79caaa 100644 --- a/lisp/ein-jupyter.el +++ b/lisp/ein-jupyter.el @@ -57,6 +57,23 @@ the notebook directory, you can set it here for future calls to (defvar *ein:last-jupyter-command* nil) (defvar *ein:last-jupyter-directory* nil) +(defcustom ein:jupyter-default-server-command "jupyter" + "The default command to start a jupyter notebook server. + +Changing this to `jupyter-notebook' requires customizing `ein:jupyter-server-use-subcommand' to nil. +" + :group 'ein + :type '(file) + :set (lambda (symbol value) + (set-default symbol value) + (setq *ein:last-jupyter-command* nil))) + +(defcustom ein:jupyter-server-use-subcommand "notebook" + "Users of \"jupyter-notebook\" (as opposed to \"jupyter notebook\") need to `Omit'." + :group 'ein + :type '(choice (string :tag "Subcommand" "notebook") + (const :tag "Omit" nil))) + (defsubst ein:jupyter-server-process () "Return the emacs process object of our session" (get-buffer-process (get-buffer ein:jupyter-server-buffer-name))) @@ -64,10 +81,10 @@ the notebook directory, you can set it here for future calls to (defun ein:jupyter-server--run (buf cmd dir &optional args) (when ein:debug (add-to-list 'ein:jupyter-server-args "--debug")) - (let* ((vargs (append (if dir - `("notebook" - ,(format "--notebook-dir=%s" - (convert-standard-filename dir)))) + (unless (stringp dir) + (error "ein:jupyter-server--run: notebook directory required")) + (let* ((vargs (append (ein:aif ein:jupyter-server-use-subcommand (list it)) + (list (format "--notebook-dir=%s" (convert-standard-filename dir))) args ein:jupyter-server-args)) (proc (apply #'start-process