Mainly code style changes

This commit is contained in:
Nathaniel Nicandro 2018-05-13 09:06:55 -05:00
parent 670611ded1
commit 7d7b7650b9
4 changed files with 21 additions and 26 deletions

View file

@ -723,10 +723,9 @@ received for it."
with secs = '(0 1) with secs = '(0 1)
for req in (hash-table-values requests) for req in (hash-table-values requests)
for id = (jupyter-request-id req) for id = (jupyter-request-id req)
for ltime = (jupyter-request-last-message-time req)
when (and (jupyter-request-idle-received-p req) when (and (jupyter-request-idle-received-p req)
(time-less-p (time-less-p secs (time-subtract ctime ltime)))
secs (time-subtract
ctime (jupyter-request-last-message-time req))))
do (when jupyter--debug do (when jupyter--debug
(message "DROPPING-REQ: %s" id)) (message "DROPPING-REQ: %s" id))
(remhash id requests))) (remhash id requests)))

View file

@ -176,8 +176,8 @@
(declare (indent 1)) (declare (indent 1))
(cl-destructuring-bind (msg-id . msg) (cl-destructuring-bind (msg-id . msg)
(jupyter--encode-message session type :content message) (jupyter--encode-message session type :content message)
(zmq-send-multipart socket msg flags) (prog1 msg-id
msg-id)) (zmq-send-multipart socket msg flags))))
(cl-defmethod jupyter-recv ((session jupyter-session) socket &optional flags) (cl-defmethod jupyter-recv ((session jupyter-session) socket &optional flags)
(let ((msg (zmq-recv-multipart socket flags))) (let ((msg (zmq-recv-multipart socket flags)))

View file

@ -1393,14 +1393,12 @@ takes."
(setq matches (cdr matches)))) (setq matches (cdr matches))))
(when types (when types
(let ((max-len (apply #'max (mapcar #'length matches)))) (let ((max-len (apply #'max (mapcar #'length matches))))
(cl-mapcar (cl-mapc
(lambda (match meta) (lambda (match meta)
(put-text-property (let ((prefix (make-string (1+ (- max-len (length match))) ? )))
0 1 'annot (put-text-property
(concat (make-string (1+ (- max-len (length match))) ? ) 0 1 'annot (concat prefix (plist-get meta :type))
(plist-get meta :type)) match)))
match)
match)
matches types))) matches types)))
matches)) matches))
@ -1620,7 +1618,7 @@ A kernel can be interrupted if it was started using a
(oref jupyter-repl-current-client manager)))) (oref jupyter-repl-current-client manager))))
;; TODO: Make timeouts configurable ;; TODO: Make timeouts configurable
(defun jupyter-repl-restart-kernel (shutdown) (defun jupyter-repl-restart-kernel (&optional shutdown)
"Restart the kernel. "Restart the kernel.
With a prefix argument, SHUTDOWN the kernel completely instead." With a prefix argument, SHUTDOWN the kernel completely instead."
(interactive "P") (interactive "P")
@ -1647,9 +1645,10 @@ With a prefix argument, SHUTDOWN the kernel completely instead."
(jupyter-shutdown-kernel manager (not shutdown))) (jupyter-shutdown-kernel manager (not shutdown)))
(message "Starting dead kernel...") (message "Starting dead kernel...")
(jupyter-start-kernel manager))) (jupyter-start-kernel manager)))
(when (null (jupyter-wait-until-received :shutdown-reply (unless (jupyter-wait-until-received :shutdown-reply
(jupyter-shutdown-request jupyter-repl-current-client (jupyter-shutdown-request jupyter-repl-current-client
:restart (not shutdown)))) :restart (not shutdown)))
(jupyter-set jupyter-repl-current-client 'jupyter-include-other-output nil)
(message "Kernel did not respond to shutdown request")))) (message "Kernel did not respond to shutdown request"))))
(defun jupyter-repl-display-kernel-buffer () (defun jupyter-repl-display-kernel-buffer ()
@ -2041,12 +2040,10 @@ Otherwise, in a non-interactive call, return the
"Run a Jupyter REPL using a kernel's connection FILE-OR-PLIST. "Run a Jupyter REPL using a kernel's connection FILE-OR-PLIST.
FILE-OR-PLIST can be either a file holding the connection FILE-OR-PLIST can be either a file holding the connection
information or a property list of connection information. information or a property list of connection information.
ASSOCIATE-BUFFER has the same meaning as in `run-jupyter-repl'. ASSOCIATE-BUFFER has the same meaning as in `run-jupyter-repl'.
When called interactively, display the new REPL buffer. Return the `jupyter-repl-client' connected to the kernel. When
Otherwise, in a non-interactive call return the called interactively, display the new REPL buffer as well."
`jupyter-repl-client' connected to the kernel."
(interactive (list (read-file-name "Connection file: ") t)) (interactive (list (read-file-name "Connection file: ") t))
(let ((client (make-instance 'jupyter-repl-client))) (let ((client (make-instance 'jupyter-repl-client)))
(jupyter-initialize-connection client file-or-plist) (jupyter-initialize-connection client file-or-plist)
@ -2063,9 +2060,9 @@ Otherwise, in a non-interactive call return the
(when (and associate-buffer (when (and associate-buffer
(eq major-mode (jupyter-repl-language-mode client))) (eq major-mode (jupyter-repl-language-mode client)))
(jupyter-repl-associate-buffer client)) (jupyter-repl-associate-buffer client))
(if (called-interactively-p 'interactive) (when (called-interactively-p 'interactive)
(pop-to-buffer (oref client buffer)) (pop-to-buffer (oref client buffer)))
client)))) client)))
(provide 'jupyter-repl-client) (provide 'jupyter-repl-client)

View file

@ -34,7 +34,6 @@
(require 'jupyter) (require 'jupyter)
(require 'ob) (require 'ob)
(declare-function cddar "cl" (x))
(declare-function org-element-at-point "org-element") (declare-function org-element-at-point "org-element")
(declare-function org-at-drawer-p "org") (declare-function org-at-drawer-p "org")
(declare-function org-element-property "org-element" (property element)) (declare-function org-element-property "org-element" (property element))
@ -557,8 +556,8 @@ the PARAMS alist."
(lambda () (lambda ()
(org-babel-jupyter--clear-render-param render-param params) (org-babel-jupyter--clear-render-param render-param params)
(org-babel-jupyter--inject-render-param "append" params) (org-babel-jupyter--inject-render-param "append" params)
(org-babel-jupyter-insert-results (org-babel-jupyter-insert-results (cdr results) params kernel-lang)
(cdr results) params kernel-lang))))))))))) (set-marker block-beginning nil)))))))))))
(defun org-babel-jupyter-make-language-alias (kernel lang) (defun org-babel-jupyter-make-language-alias (kernel lang)
"Simimilar to `org-babel-make-language-alias' but for Jupyter src-blocks. "Simimilar to `org-babel-make-language-alias' but for Jupyter src-blocks.