Fix saving new notebooks, whitespace updates.

Newly created notebooks no longer error on saving - bug in how
kernelspec metadata was being filled in.

Also a number of miscellaneous fixes to indentation that have
inexplicably appeared in the code.

Some small fixes for typos and catching up on version info.
This commit is contained in:
John Miller 2016-03-01 16:02:00 -06:00
parent 261576f94b
commit c5cf44a795
10 changed files with 163 additions and 91 deletions

File diff suppressed because one or more lines are too long

View file

@ -24,7 +24,7 @@ There are a number of helper functions for returning the struct for an opened no
- ~[[file:lisp/ein-notebook.el::(defun%20ein:notebook-get-opened-notebook%20(url-or-port%20path)][ein:notebook-get-opened-notebook]]~ ::
- ~[[file:lisp/ein-notebook.el::(defun%20ein:notebook-get-opened-buffer%20(url-or-port%20path)][ein:notebook-get-opened-buffer]]~ ::
-
** Notebooklist Buffer
** Kernel communication
** Contents API
@ -50,6 +50,20 @@ ws://{server_address}:{port}/api/kernels/{kernel id from previous REST query}/ch
#+END_QUOTE
* Enhancements/Fixes
** Errors on saving new notebook
Happening because metadata slot is borked when creating new notebooks.
** Support company-mode
** Inline latex
See issue [[https://github.com/millejoh/emacs-ipython-notebook/issues/88][#88]].
** Interactive Widgets
For the most part this is a non-starter since in Jupyter this is built on web
and javascript, but maybe with emacs 25's coming integration with [[https://www.emacswiki.org/emacs/EmacsXWidgets][xwidgets]] there
is hope?
** Working with jupyterhub
Jupyterhub requires authentication using username/password, as opposed to just

View file

@ -11,6 +11,7 @@
(add-to-list 'load-path (funcall path "lib" "auto-complete"))
(add-to-list 'load-path (funcall path "lib" "popup"))) ; for auto-complete
(package-initialize)
(require 'ein-dev)
(ein:dev-require-all)

View file

@ -51,9 +51,9 @@ copyright = u'2015, John Miller'
# built documents.
#
# The short X.Y version.
version = '0.7'
version = '0.8'
# The full version, including alpha/beta/rc tags.
release = '0.7.0'
release = '0.8.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -604,7 +604,7 @@ v0.4
* ein-mumamo.el has been moved into its own package, ein-mumamo. This should get rid
of compilation errors for anyone who does not happen to have nxhtml installed.
* Restore support for heading level cells with nbformat v4 notebooks.
* New (buggy) pytools function `ein:pytools-export-buffer` for using nbconvert on a notebook
* New (buggy) pytools function :el:symbol:`ein:pytools-export-buffer` for using nbconvert on a notebook
buffer.
v0.3

View file

@ -195,10 +195,10 @@ global setting. For global setting and more information, see
(or (cl-position ?/ (ein:$content-path content) :from-end t)
0)))))
(json-encode `((:type . ,(ein:$content-type content))
(:name . ,(ein:$content-name content))
(:path . ,path)
(:format . "json")
(:content ,@(ein:$content-raw-content content))))))
(:name . ,(ein:$content-name content))
(:path . ,path)
(:format . "json")
(:content ,@(ein:$content-raw-content content))))))
(defun ein:content-from-notebook (nb)
(let ((nb-content (ein:notebook-to-json nb)))

View file

@ -238,7 +238,7 @@ Current buffer for these functions is set to the notebook buffer.")
(setq kernelspec (ein:get-kernelspec url-or-port kernelspec)))
(let ((notebook (apply #'make-ein:$notebook
:url-or-port url-or-port
:kernelspec kernelspec
:kernelspec kernelspec
:notebook-path notebook-path
args)))
notebook))
@ -379,8 +379,8 @@ See `ein:notebook-open' for more information."
(defun ein:notebook-maybe-set-kernelspec (notebook content-metadata)
(ein:aif (plist-get content-metadata :kernelspec)
(let ((kernelspec (ein:get-kernelspec (ein:$notebook-url-or-port notebook)
(plist-get it :name))))
(setf (ein:$notebook-kernelspec notebook) kernelspec))))
(plist-get it :name))))
(setf (ein:$notebook-kernelspec notebook) kernelspec))))
(defun ein:notebook-request-open-callback (notebook content)
@ -473,16 +473,16 @@ of minor mode."
(defun ein:get-kernelspec (url-or-port name)
(let ((kernelspecs (gethash url-or-port ein:available-kernelspecs))
(name (if (stringp name)
(intern (format ":%s" name))
name)))
(name (if (stringp name)
(intern (format ":%s" name))
name)))
(plist-get kernelspecs name)))
(defun ein:list-available-kernels (url-or-port)
(let ((kernelspecs (gethash url-or-port ein:available-kernelspecs)))
(if kernelspecs
(loop for (key spec) on (ein:plist-exclude kernelspecs '(:default)) by 'cddr
collecting (ein:$kernelspec-name spec)))))
(loop for (key spec) on (ein:plist-exclude kernelspecs '(:default)) by 'cddr
collecting (ein:$kernelspec-name spec)))))
(defun ein:query-kernelspecs (url-or-port)
"Query jupyter server for the list of available
@ -494,7 +494,7 @@ on server url/port."
:type "GET"
:timeout ein:content-query-timeout
:parser 'ein:json-read
:sync nil
:sync t
:success (apply-partially #'ein:query-kernelspecs-success url-or-port)
:error (apply-partially #'ein:query-kernelspecs-error)))
@ -731,11 +731,11 @@ of NOTEBOOK."
for i from 0
append (ein:worksheet-to-nb4-json ws i))))
(ein:aif (ein:$notebook-kernelspec notebook)
(if (ein:$notebook-metadata notebook)
(plist-put (ein:$notebook-metadata notebook)
:kernelspec (ein:kernelspec-for-nb-metadata it))
(setf (ein:$notebook-metadata notebook)
(cons :kernelspec (ein:kernelspec-for-nb-metadata it)))))
(if (ein:$notebook-metadata notebook)
(plist-put (ein:$notebook-metadata notebook)
:kernelspec (ein:kernelspec-for-nb-metadata it))
(setf (ein:$notebook-metadata notebook)
(list :kernelspec (ein:kernelspec-for-nb-metadata it)))))
`((metadata . ,(ein:aif (ein:$notebook-metadata notebook)
it
(make-hash-table)))
@ -1512,7 +1512,7 @@ Called via `kill-buffer-query-functions'."
(ein:worksheet-p ein:%worksheet%) ; it's not `ein:scratchsheet'
(ein:notebook-modified-p)
(not (y-or-n-p
"You have unsaved changes. Discard changes?")))
"This notebook has unsaved changes. Discard those changes?")))
(when (ein:worksheet-p ein:%worksheet%)
;; To make `ein:worksheet-save-cells' no-op.
(ein:worksheet-dont-save-cells ein:%worksheet%)

View file

@ -255,7 +255,7 @@ This function is called via `ein:notebook-after-rename-hook'."
url-or-port kernelspec path callback cbargs)))))
(defun* ein:notebooklist-new-notebook-callback (url-or-port
kernelspec
kernelspec
path
callback
cbargs
@ -385,9 +385,9 @@ Notebook list data is passed via the buffer local variable
(default-kernel (ein:get-kernelspec (ein:$notebooklist-url-or-port ein:%notebooklist%) (first kernels))))
(widget-create
'link
:notify (lambda (&rest ignore) (call-interactively (ein:notebooklist-new-notebook
(ein:$notebooklist-url-or-port ein:%notebooklist%)
default-kernel)))
:notify (lambda (&rest ignore) (ein:notebooklist-new-notebook
(ein:$notebooklist-url-or-port ein:%notebooklist%)
default-kernel))
"New Notebook")
(widget-insert " ")
(widget-create

View file

@ -235,7 +235,7 @@ See: http://api.jquery.com/jQuery.ajax/"
The version of ewoc.el you are using is too old for EIN.
Please install the newer version.
See also: https://github.com/tkf/emacs-ipython-notebook/issues/49")
(error "Incompatible EOWC version."))))
(error "Incompatible EWOC version."))))
;;; Text property
@ -600,26 +600,26 @@ directory is in a dirty git repository."
"Return string with random (version 4) UUID.
Adapted from org-mode's `org-id-uuid'."
(let ((rnd (md5 (format "%s%s%s%s%s%s%s"
(random t)
(current-time)
(user-uid)
(emacs-pid)
(user-full-name)
user-mail-address
(recent-keys)))))
(random t)
(current-time)
(user-uid)
(emacs-pid)
(user-full-name)
user-mail-address
(recent-keys)))))
(format "%s-%s-4%s-%s%s-%s"
(substring rnd 0 8)
(substring rnd 8 12)
(substring rnd 13 16)
(format "%x"
(logior
#b10000000
(logand
#b10111111
(string-to-number
(substring rnd 16 18) 16))))
(substring rnd 18 20)
(substring rnd 20 32))))
(substring rnd 0 8)
(substring rnd 8 12)
(substring rnd 13 16)
(format "%x"
(logior
#b10000000
(logand
#b10111111
(string-to-number
(substring rnd 16 18) 16))))
(substring rnd 18 20)
(substring rnd 20 32))))
(provide 'ein-utils)

View file

@ -3,7 +3,7 @@
;; Usage:
;; emacs -Q -batch -L ... -l tests/test-load.el -f ert-run-tests-batch
;; You will need to set load paths using `-L' switch.
(require 'ein-dev)
(require 'ein-testing)