mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-04 16:51:38 -05:00
makes test
This commit is contained in:
parent
22f3534423
commit
f7180405d6
40 changed files with 280 additions and 262 deletions
1
Cask
1
Cask
|
@ -7,6 +7,7 @@
|
|||
(development
|
||||
(depends-on "anaphora")
|
||||
(depends-on "websocket")
|
||||
(depends-on "kubernetes")
|
||||
(depends-on "request")
|
||||
(depends-on "dash")
|
||||
(depends-on "ert-runner")
|
||||
|
|
|
@ -32,27 +32,27 @@
|
|||
(defvar eldomain-prefix nil)
|
||||
|
||||
(defun eldomain-get-symbols (predicate)
|
||||
(loop for x being the symbols
|
||||
(cl-loop for x being the symbols
|
||||
with regexp = (format "^%s" eldomain-prefix)
|
||||
if (and (funcall predicate x)
|
||||
(string-match regexp (format "%S" x)))
|
||||
collect x))
|
||||
|
||||
(defun eldomain-get-function-data ()
|
||||
(loop for x in (eldomain-get-symbols #'fboundp)
|
||||
(cl-loop for x in (eldomain-get-symbols #'fboundp)
|
||||
for name = (format "%S" x)
|
||||
for arg = (help-function-arglist x)
|
||||
for doc = (documentation x)
|
||||
collect `((name . ,name) (arg . ,arg) (doc . ,doc))))
|
||||
|
||||
(defun eldomain-get-variable-data ()
|
||||
(loop for x in (eldomain-get-symbols #'boundp)
|
||||
(cl-loop for x in (eldomain-get-symbols #'boundp)
|
||||
for name = (format "%S" x)
|
||||
for doc = (documentation-property x 'variable-documentation t)
|
||||
collect `((name . ,name) (doc . ,doc))))
|
||||
|
||||
(defun eldomain-get-face-data ()
|
||||
(loop for x in (eldomain-get-symbols #'facep)
|
||||
(cl-loop for x in (eldomain-get-symbols #'facep)
|
||||
for name = (format "%S" x)
|
||||
for doc = (documentation-property x 'face-documentation t)
|
||||
collect `((name . ,name) (doc . ,doc))))
|
||||
|
@ -82,7 +82,7 @@
|
|||
data))
|
||||
|
||||
(defun eldomain-get-keymap-data ()
|
||||
(loop for x in (eldomain-get-symbols
|
||||
(cl-loop for x in (eldomain-get-symbols
|
||||
(lambda (v) (and (boundp v) (keymapp (eval v)))))
|
||||
for name = (format "%S" x)
|
||||
for doc = (documentation-property x 'variable-documentation t)
|
||||
|
|
|
@ -114,8 +114,6 @@ Scenario: Specific port, portless localhost refers to same, concurrent execution
|
|||
|
||||
@org
|
||||
Scenario: portless url with path, image, C-c ' lets you C-c C-c as well
|
||||
Given I set "ein:completion-backend" to eval "(quote ein:use-none-backend)"
|
||||
Given I stop the server
|
||||
When I open temp file "path.org"
|
||||
And I call "org-mode"
|
||||
And I type "<s"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
(lambda (kernel-name)
|
||||
(cl-letf (((symbol-function 'R-mode) #'ignore))
|
||||
(let ((notebook (ein:notebook-switch-kernel (ein:get-notebook) kernel-name)))
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
until (ein:kernel-live-p (ein:$notebook-kernel notebook))
|
||||
do (sleep-for 0 500)
|
||||
finally do (should (string= "R" (ein:$kernelspec-language
|
||||
|
@ -174,7 +174,7 @@
|
|||
(cancel-function-timers #'ein:notebooklist-reload)
|
||||
(cl-letf (((symbol-function 'y-or-n-p) #'ignore))
|
||||
(ein:jupyter-server-stop t))
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
with buffer = (get-buffer *ein:jupyter-server-buffer-name*)
|
||||
until (null (get-buffer-process buffer))
|
||||
do (sleep-for 0 1000)
|
||||
|
@ -272,7 +272,7 @@
|
|||
|
||||
(When "^I wait for completions \"\\(.+\\)\"$"
|
||||
(lambda (key)
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
until (gethash key (ein:$kernel-oinfo-cache (ein:get-kernel)))
|
||||
do (sleep-for 0 500)
|
||||
finally do (should (gethash key (ein:$kernel-oinfo-cache (ein:get-kernel)))))))
|
||||
|
@ -284,7 +284,7 @@
|
|||
|
||||
(When "^I keep clicking \"\\(.+\\)\" until \"\\(.+\\)\"$"
|
||||
(lambda (go stop)
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
until (search stop (buffer-string))
|
||||
do (And (format "I click on \"%s\"" go))
|
||||
do (sleep-for 0 1000)
|
||||
|
@ -301,7 +301,7 @@
|
|||
(backward-char)
|
||||
(let ((was (widget-at)))
|
||||
(When "I press \"RET\"")
|
||||
(loop until (not (equal was (widget-at)))
|
||||
(cl-loop until (not (equal was (widget-at)))
|
||||
do (sleep-for 0 500))))))
|
||||
|
||||
(When "^I click on dir \"\\(.+\\)\"$"
|
||||
|
@ -310,18 +310,18 @@
|
|||
(re-search-backward "Dir" nil t)
|
||||
(let ((was (widget-at)))
|
||||
(When "I press \"RET\"")
|
||||
(loop until (not (equal was (widget-at)))
|
||||
(cl-loop until (not (equal was (widget-at)))
|
||||
do (sleep-for 0 500)))))
|
||||
|
||||
(When "^I click on dir \"\\(.+\\)\" until \"\\(.+\\)\"$"
|
||||
(lambda (dir stop)
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
until (search stop (buffer-string))
|
||||
do (When (format "I go to word \"%s\"" dir))
|
||||
do (re-search-backward "Dir" nil t)
|
||||
do (let ((was (widget-at)))
|
||||
(When "I press \"RET\"")
|
||||
(loop until (not (equal was (widget-at)))
|
||||
(cl-loop until (not (equal was (widget-at)))
|
||||
do (sleep-for 0 500)))
|
||||
finally do (should (search stop (buffer-string))))))
|
||||
|
||||
|
@ -329,7 +329,7 @@
|
|||
(lambda (path)
|
||||
(lexical-let ((url-or-port (car (ein:jupyter-server-conn-info))) notebook)
|
||||
(with-current-buffer (ein:notebooklist-get-buffer url-or-port)
|
||||
(loop repeat 2
|
||||
(cl-loop repeat 2
|
||||
until (and notebook
|
||||
(ein:aand (ein:$notebook-kernel notebook)
|
||||
(ein:kernel-live-p it)))
|
||||
|
|
|
@ -43,10 +43,10 @@
|
|||
(defun ein:testing-after-scenario ()
|
||||
(ein:testing-flush-queries)
|
||||
(with-current-buffer (ein:notebooklist-get-buffer (car (ein:jupyter-server-conn-info)))
|
||||
(loop for notebook in (ein:notebook-opened-notebooks)
|
||||
(cl-loop for notebook in (ein:notebook-opened-notebooks)
|
||||
for path = (ein:$notebook-notebook-path notebook)
|
||||
do (ein:notebook-kill-kernel-then-close-command notebook)
|
||||
do (loop repeat 16
|
||||
do (cl-loop repeat 16
|
||||
until (not (ein:notebook-live-p notebook))
|
||||
do (sleep-for 0 1000)
|
||||
finally do (when (ein:notebook-live-p notebook)
|
||||
|
@ -55,7 +55,7 @@
|
|||
(search "Untitled" path)
|
||||
(search "Renamed" path))
|
||||
(ein:notebooklist-delete-notebook path)
|
||||
(loop repeat 16
|
||||
(cl-loop repeat 16
|
||||
with fullpath = (concat (file-name-as-directory ein:testing-jupyter-server-root) path)
|
||||
for extant = (file-exists-p fullpath)
|
||||
until (not extant)
|
||||
|
@ -63,7 +63,7 @@
|
|||
finally do (when extant
|
||||
(ein:display-warning (format "cannot del %s" path)))))))
|
||||
(aif (ein:notebook-opened-notebooks)
|
||||
(loop for nb in it
|
||||
(cl-loop for nb in it
|
||||
for path = (ein:$notebook-notebook-path nb)
|
||||
do (ein:log 'debug "Notebook %s still open" path)
|
||||
finally do (assert nil))))
|
||||
|
@ -75,7 +75,7 @@
|
|||
'(python-indent-guess-indent-offset-verbose nil)
|
||||
'(ein:jupyter-use-containers nil))
|
||||
(setq ein:jupyter-default-kernel
|
||||
(loop with cand = ""
|
||||
(cl-loop with cand = ""
|
||||
for (k . spec) in
|
||||
(alist-get
|
||||
'kernelspecs
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
(data . (,data)))))
|
||||
|
||||
(defun ein:maybe-get-output-mime-data (output)
|
||||
(loop for type in '(:svg :png :jpeg :html :latex :javascript :text)
|
||||
(cl-loop for type in '(:svg :png :jpeg :html :latex :javascript :text)
|
||||
if (plist-get output type)
|
||||
collecting (cons (ein:output-property type) (plist-get output type))))
|
||||
|
||||
|
@ -71,7 +71,7 @@
|
|||
(metadata . ,(make-hash-table)))))
|
||||
|
||||
(defun ein:find-and-make-outputs (output-plist)
|
||||
(loop for prop in ein:output-type-map
|
||||
(cl-loop for prop in ein:output-type-map
|
||||
when (plist-get output-plist (cdr prop))
|
||||
collect (list (cdr prop) (plist-get output-plist (cdr prop)))))
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ a number will limit the number of lines in a cell output."
|
|||
(cl-defmethod ein:cell-convert ((cell ein:basecell) type)
|
||||
(let ((new (ein:cell-from-type type)))
|
||||
;; copy attributes
|
||||
(loop for k in '(read-only ewoc)
|
||||
(cl-loop for k in '(read-only ewoc)
|
||||
do (setf (slot-value new k) (slot-value cell k)))
|
||||
;; copy input
|
||||
(setf (slot-value new 'input) (if (ein:cell-active-p cell)
|
||||
|
@ -325,14 +325,14 @@ a number will limit the number of lines in a cell output."
|
|||
"Convert CELL to TYPE and redraw corresponding ewoc nodes."
|
||||
(let ((new (ein:cell-convert cell type)))
|
||||
;; copy element attribute
|
||||
(loop for k in (slot-value new 'element-names)
|
||||
(cl-loop for k in (slot-value new 'element-names)
|
||||
with old-element = (slot-value cell 'element)
|
||||
do (progn
|
||||
(setf (slot-value new 'element)
|
||||
(plist-put (slot-value new 'element) k
|
||||
(plist-get old-element k)))))
|
||||
;; setting ewoc nodes
|
||||
(loop for en in (ein:cell-all-element cell)
|
||||
(cl-loop for en in (ein:cell-all-element cell)
|
||||
for node = (ewoc-data en)
|
||||
do (setf (ein:$node-data node) new))
|
||||
(let ((inhibit-read-only t)
|
||||
|
@ -342,12 +342,12 @@ a number will limit the number of lines in a cell output."
|
|||
#'ewoc-delete (slot-value new 'ewoc)
|
||||
(apply
|
||||
#'append
|
||||
(loop for name in (slot-value cell 'element-names)
|
||||
(cl-loop for name in (slot-value cell 'element-names)
|
||||
unless (memq name (slot-value new 'element-names))
|
||||
collect (let ((ens (ein:cell-element-get cell name)))
|
||||
(if (listp ens) ens (list ens))))))
|
||||
;; draw ewoc node
|
||||
(loop with ewoc = (slot-value new 'ewoc)
|
||||
(cl-loop with ewoc = (slot-value new 'ewoc)
|
||||
for en in (ein:cell-all-element new)
|
||||
do (ein:cell--ewoc-invalidate ewoc en)))
|
||||
new))
|
||||
|
@ -358,7 +358,7 @@ a number will limit the number of lines in a cell output."
|
|||
(buffer-undo-list t)) ; disable undo recording
|
||||
(setf (slot-value cell 'level) level)
|
||||
;; draw ewoc node
|
||||
(loop with ewoc = (slot-value cell 'ewoc)
|
||||
(cl-loop with ewoc = (slot-value cell 'ewoc)
|
||||
for en in (ein:cell-all-element cell)
|
||||
do (ein:cell--ewoc-invalidate ewoc en))))
|
||||
|
||||
|
@ -421,7 +421,7 @@ Return language name as a string or `nil' when not defined.
|
|||
(fn cell)")
|
||||
|
||||
(cl-defmethod ein:cell-language ((cell ein:codecell))
|
||||
(ein:and-let* ((kernel (slot-value cell 'kernel))
|
||||
(ein:and-let* ((kernel (ein:oref-safe cell 'kernel))
|
||||
(kernelspec (ein:$kernel-kernelspec kernel)))
|
||||
(ein:$kernelspec-language kernelspec)))
|
||||
(cl-defmethod ein:cell-language ((cell ein:markdowncell)) nil "markdown")
|
||||
|
@ -436,7 +436,7 @@ Return language name as a string or `nil' when not defined.
|
|||
(list
|
||||
:prompt (funcall make-node 'prompt)
|
||||
:input (funcall make-node 'input)
|
||||
:output (loop for i from 0 below num-outputs
|
||||
:output (cl-loop for i from 0 below num-outputs
|
||||
collect (funcall make-node 'output i))
|
||||
:footer (funcall make-node 'footer))))
|
||||
|
||||
|
@ -972,7 +972,7 @@ prettified text thus be used instead of HTML type."
|
|||
(defun ein:cell-append-mime-type (json dynamic)
|
||||
(when (plist-get json :data)
|
||||
(setq json (plist-get json :data))) ;; For nbformat v4 support.
|
||||
(loop
|
||||
(cl-loop
|
||||
for key in (cond
|
||||
((functionp ein:output-type-preference)
|
||||
(funcall ein:output-type-preference json))
|
||||
|
@ -1024,6 +1024,7 @@ prettified text thus be used instead of HTML type."
|
|||
,@(aif (ein:oref-safe cell 'input-prompt-number)
|
||||
`((prompt_number . ,it)))
|
||||
(outputs . ,(if discard-output [] (apply #'vector (slot-value cell 'outputs))))
|
||||
(language . ,(or (ein:cell-language cell) "python"))
|
||||
(collapsed . ,(if (slot-value cell 'collapsed) t json-false))))
|
||||
|
||||
(defvar ein:output-type-map
|
||||
|
@ -1056,7 +1057,7 @@ prettified text thus be used instead of HTML type."
|
|||
(append renamed-outputs
|
||||
(list (let ((ocopy (cl-copy-list output))
|
||||
(new-output '()))
|
||||
(loop while ocopy
|
||||
(cl-loop while ocopy
|
||||
do (let ((prop (pop ocopy))
|
||||
(value (pop ocopy)))
|
||||
(ein:log 'debug "Checking property %s for output type '%s'"
|
||||
|
@ -1229,7 +1230,7 @@ prettified text thus be used instead of HTML type."
|
|||
|
||||
|
||||
(defun ein:output-area-convert-mime-types (json data)
|
||||
(loop for (prop . mime) in '((:text . :text/plain)
|
||||
(cl-loop for (prop . mime) in '((:text . :text/plain)
|
||||
(:html . :text/html)
|
||||
(:svg . :image/svg+xml)
|
||||
(:png . :image/png)
|
||||
|
@ -1258,7 +1259,7 @@ prettified text thus be used instead of HTML type."
|
|||
|
||||
(cl-defmethod ein:cell-has-image-ouput-p ((cell ein:codecell))
|
||||
"Return `t' if given cell has image output, `nil' otherwise."
|
||||
(loop for out in (slot-value cell 'outputs)
|
||||
(cl-loop for out in (slot-value cell 'outputs)
|
||||
when (or (plist-member out :svg)
|
||||
(plist-member out :image/svg+xml)
|
||||
(plist-member out :png)
|
||||
|
@ -1271,7 +1272,7 @@ prettified text thus be used instead of HTML type."
|
|||
nil)
|
||||
|
||||
(cl-defmethod ein:cell-get-tb-data ((cell ein:codecell))
|
||||
(loop for out in (slot-value cell 'outputs)
|
||||
(cl-loop for out in (slot-value cell 'outputs)
|
||||
when (and (plist-get out :traceback)
|
||||
(member (plist-get out :output_type) '("pyerr" "error")))
|
||||
return (plist-get out :traceback)))
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
(setf (ein:$kernel-oinfo-cache kernel) (make-hash-table :test #'equal)))
|
||||
|
||||
(defun ein:completions-get-cached (partial oinfo-cache)
|
||||
(loop for candidate being the hash-keys of oinfo-cache
|
||||
(cl-loop for candidate being the hash-keys of oinfo-cache
|
||||
when (string-prefix-p partial candidate)
|
||||
collect candidate))
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ global setting. For global setting and more information, see
|
|||
|
||||
(defun ein:fix-legacy-content-data (data)
|
||||
(if (listp (car data))
|
||||
(loop for item in data
|
||||
(cl-loop for item in data
|
||||
collecting
|
||||
(ein:fix-legacy-content-data item))
|
||||
(if (string= (plist-get data :path) "")
|
||||
|
@ -221,7 +221,7 @@ global setting. For global setting and more information, see
|
|||
(callback callback)
|
||||
(items (ein:$content-raw-content content))
|
||||
(directories (if (< depth ein:content-query-max-depth)
|
||||
(loop for item in items
|
||||
(cl-loop for item in items
|
||||
with result
|
||||
until (>= (length result) ein:content-query-max-branch)
|
||||
if (string= "directory" (plist-get item :type))
|
||||
|
@ -229,7 +229,7 @@ global setting. For global setting and more information, see
|
|||
into result
|
||||
end
|
||||
finally return result)))
|
||||
(others (loop for item in items
|
||||
(others (cl-loop for item in items
|
||||
with c0
|
||||
if (not (string= "directory" (plist-get item :type)))
|
||||
do (setf c0 (ein:new-content url-or-port path item))
|
||||
|
@ -240,7 +240,7 @@ global setting. For global setting and more information, see
|
|||
(deferred:$
|
||||
(apply
|
||||
#'deferred:parallel
|
||||
(loop for c0 in directories
|
||||
(cl-loop for c0 in directories
|
||||
collect
|
||||
(lexical-let
|
||||
((c0 c0)
|
||||
|
|
|
@ -144,7 +144,7 @@ the source is in git repository) or elpa version."
|
|||
(intern (format ":%s" name))
|
||||
name))
|
||||
(ks (or (plist-get kernelspecs name)
|
||||
(loop for (key spec) on (ein:plist-exclude kernelspecs '(:default)) by 'cddr
|
||||
(cl-loop for (key spec) on (ein:plist-exclude kernelspecs '(:default)) by 'cddr
|
||||
if (string= (ein:$kernelspec-language spec) lang)
|
||||
return spec
|
||||
end))))
|
||||
|
@ -325,7 +325,7 @@ as `defgeneric' in EIEIO, but it takes no argument. Actual
|
|||
implementation is chosen based on context (buffer, point, etc.).
|
||||
This helps writing generic commands which requires same object
|
||||
but can operate in different contexts."
|
||||
(loop for func in func-list
|
||||
(cl-loop for func in func-list
|
||||
if (and (functionp func) (funcall func))
|
||||
return it))
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
(ein:load-files "^ein-.*\\.el$"))
|
||||
|
||||
(cl-defun ein:dev-require-all (&key (ignore-p #'ignore))
|
||||
(loop for f in (directory-files ein:source-dir nil "^ein-.*\\.el$")
|
||||
(cl-loop for f in (directory-files ein:source-dir nil "^ein-.*\\.el$")
|
||||
unless (or (equal f "ein-pkg.el")
|
||||
(equal f "ein-autoloads.el")
|
||||
(funcall ignore-p f))
|
||||
|
@ -201,7 +201,7 @@ callback (`websocket-callback-debug-on-error') is enabled."
|
|||
|
||||
(defun ein:dev-sys-info--lib (name)
|
||||
(let* ((libsym (intern-soft name))
|
||||
(version-var (loop for fmt in '("%s-version" "%s:version")
|
||||
(version-var (cl-loop for fmt in '("%s-version" "%s:version")
|
||||
if (intern-soft (format fmt name))
|
||||
return it))
|
||||
(version (symbol-value version-var)))
|
||||
|
@ -212,7 +212,7 @@ callback (`websocket-callback-debug-on-error') is enabled."
|
|||
:version version)))
|
||||
|
||||
(defun ein:dev-dump-vars (names)
|
||||
(loop for var in names
|
||||
(cl-loop for var in names
|
||||
collect (intern (format ":%s" var))
|
||||
collect (symbol-value (intern (format "ein:%s" var)))))
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
(require 'ein-core)
|
||||
(require 'ein-notebooklist)
|
||||
(require 'ein-dev)
|
||||
(require 'ein-k8s)
|
||||
|
||||
(defcustom ein:jupyter-use-containers nil
|
||||
"Take EIN in a different direcsh."
|
||||
|
@ -91,7 +92,7 @@ with the call to the jupyter notebook."
|
|||
(condition-case err
|
||||
(mapcar
|
||||
(lambda (x) `(const :tag ,(cdr x) ,(car x)))
|
||||
(loop
|
||||
(cl-loop
|
||||
for (k . spec) in
|
||||
(alist-get
|
||||
'kernelspecs
|
||||
|
@ -108,6 +109,19 @@ with the call to the jupyter notebook."
|
|||
(defvar *ein:jupyter-server-buffer-name*
|
||||
(format "*%s*" *ein:jupyter-server-process-name*))
|
||||
|
||||
(defun ein:jupyter-process-lines (url-or-port command &rest args)
|
||||
"If URL-OR-PORT registered as a k8s url, preface COMMAND ARGS with `kubectl exec'."
|
||||
(condition-case err
|
||||
(cond ((and url-or-port (string= url-or-port (ein:k8s-service-url-or-port)))
|
||||
(let ((pod-name (kubernetes-state-resource-name (ein:k8s-get-pod))))
|
||||
(apply #'process-lines kubernetes-kubectl-executable
|
||||
(nconc
|
||||
(split-string (format "exec %s -- %s" pod-name command))
|
||||
args))))
|
||||
(t (apply #'process-lines command args)))
|
||||
(error (ein:log 'info "ein:jupyter-process-lines: %s" (error-message-string err))
|
||||
nil)))
|
||||
|
||||
(defsubst ein:jupyter-server-process ()
|
||||
"Return the emacs process object of our session."
|
||||
(get-buffer-process (get-buffer *ein:jupyter-server-buffer-name*)))
|
||||
|
@ -241,7 +255,7 @@ server command."
|
|||
(if (numberp port)
|
||||
`("--port" ,(format "%s" port)
|
||||
"--port-retries" "0")))))
|
||||
(loop repeat 30
|
||||
(cl-loop repeat 30
|
||||
until (car (ein:jupyter-server-conn-info *ein:jupyter-server-buffer-name*))
|
||||
do (sleep-for 0 500)
|
||||
finally do
|
||||
|
@ -277,7 +291,7 @@ server command."
|
|||
(ein:and-let* ((url-or-port (first (ein:jupyter-server-conn-info)))
|
||||
(_ok (or force (y-or-n-p "Stop server and close notebooks?"))))
|
||||
(ein:notebook-close-notebooks t)
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
do (ein:query-running-process-table)
|
||||
until (zerop (hash-table-count ein:query-running-process-table))
|
||||
do (sleep-for 0 500))
|
||||
|
|
|
@ -202,7 +202,7 @@
|
|||
"Log on to a jupyterhub server using PAM authentication. Requires jupyterhub version 0.8 or greater. CALLBACK takes two arguments, the resulting buffer and the singleuser url-or-port"
|
||||
(interactive (let ((url-or-port (ein:notebooklist-ask-url-or-port))
|
||||
(pam-plist (ein:notebooklist-ask-user-pw-pair "User" "Password")))
|
||||
(loop for (user pw) on pam-plist by (function cddr)
|
||||
(cl-loop for (user pw) on pam-plist by (function cddr)
|
||||
return (list url-or-port (symbol-name user) pw (lambda (buffer _url-or-port) (pop-to-buffer buffer))))))
|
||||
(ein:jupyterhub--query-version url-or-port callback username password))
|
||||
|
||||
|
|
|
@ -90,9 +90,7 @@
|
|||
(kubernetes-state)
|
||||
#'kubernetes-kubectl-config-view)))
|
||||
(-let* [((&alist 'contexts contexts 'current-context current) response)
|
||||
(names (--map (alist-get 'name it) (append contexts nil)))
|
||||
(state (kubernetes-state))
|
||||
(current (alist-get 'name (kubernetes-state-current-context state)))]
|
||||
(names (--map (alist-get 'name it) (append contexts nil)))]
|
||||
(when (member current names)
|
||||
(setq names (cons current (-remove-item current names))))
|
||||
names)))
|
||||
|
@ -102,47 +100,52 @@
|
|||
(-let* [(deployments (kubernetes-state-deployments (kubernetes-state)))
|
||||
((&alist 'items items) deployments)]
|
||||
(seq-some (lambda (it)
|
||||
(-let [(&alist 'metadata (&alist 'name name 'creationTimestamp created-time)
|
||||
'spec (&alist 'replicas desired)
|
||||
'status (&alist 'replicas current
|
||||
'availableReplicas available
|
||||
'updatedReplicas up-to-date))
|
||||
it]
|
||||
(-let [(&alist 'metadata (&alist 'name)) it]
|
||||
(and (string= name ein:k8s-name-deployment) it)))
|
||||
items)))
|
||||
|
||||
(defun ein:k8s-get-service ()
|
||||
(kubernetes-services-refresh-now)
|
||||
(-let* [(services (kubernetes-state-services (kubernetes-state)))
|
||||
((&alist 'items items) services)]
|
||||
(seq-some (lambda (it)
|
||||
(-let [(&alist 'metadata (&alist 'name 'creationTimestamp)
|
||||
'spec (&alist 'selector)
|
||||
'status)
|
||||
it]
|
||||
(and (string= name ein:k8s-name-service) it)))
|
||||
items)))
|
||||
|
||||
(defun ein:k8s-service-url-or-port ()
|
||||
(when-let ((service (ein:k8s-get-service)))
|
||||
(-let [(&alist 'spec (&alist 'ports [(&alist 'nodePort)])) service]
|
||||
nodePort)))
|
||||
|
||||
(defun ein:k8s-get-node ()
|
||||
(kubernetes-nodes-refresh-now)
|
||||
(when-let ((pod (ein:k8s-get-pod)))
|
||||
(-let* (((&alist 'spec (&alist 'nodeName)) pod))
|
||||
(when-let ((node (kubernetes-state-lookup-node
|
||||
nodeName
|
||||
(kubernetes-state))))
|
||||
(-let (((&alist 'metadata (&alist 'name)) node))
|
||||
name)
|
||||
node))))
|
||||
|
||||
(defun ein:k8s-get-pod ()
|
||||
(kubernetes-pods-refresh-now)
|
||||
(when-let ((deployment (ein:k8s-get-deployment)))
|
||||
(cl-first (kubernetes-overview--pods-for-deployment (kubernetes-state)
|
||||
deployment))))
|
||||
(defun ein:k8s-get-service ()
|
||||
(kubernetes-services-refresh-now)
|
||||
(-let* [(services (kubernetes-state-services (kubernetes-state)))
|
||||
((&alist 'items items) services)]
|
||||
(seq-some (lambda (it)
|
||||
(-let [(&alist 'metadata (&alist 'name)) it]
|
||||
(and (string= name ein:k8s-name-service) it)))
|
||||
items)))
|
||||
|
||||
(defun ein:k8s-get-node ()
|
||||
(kubernetes-nodes-refresh-now)
|
||||
(-when-let* ((pod (ein:k8s-get-pod))
|
||||
((&alist 'spec (&alist 'nodeName)) pod)
|
||||
(node (kubernetes-state-lookup-node nodeName (kubernetes-state)))
|
||||
((&alist 'metadata (&alist 'name)) node))
|
||||
node))
|
||||
|
||||
(defsubst ein:k8s-p ()
|
||||
(and (executable-find kubernetes-kubectl-executable)
|
||||
(or (kubernetes-state-current-context (kubernetes-state))
|
||||
(unless noninteractive
|
||||
(condition-case err
|
||||
(ein:k8s-select-context)
|
||||
(error (ein:log 'info "ein:k8s-p %s" (error-message-string err))
|
||||
nil))))))
|
||||
|
||||
(defun ein:k8s-service-url-or-port ()
|
||||
(-when-let* ((k8s-p (ein:k8s-p))
|
||||
(service (ein:k8s-get-service))
|
||||
((&alist 'spec (&alist 'ports [(&alist 'nodePort)])) service)
|
||||
(node (ein:k8s-get-node))
|
||||
((&alist 'status (&alist 'addresses)) node)
|
||||
(host-ip
|
||||
(seq-some (lambda (address)
|
||||
(when (string= (alist-get 'type address) "InternalIP")
|
||||
(alist-get 'address address)))
|
||||
addresses)))
|
||||
(ein:url (concat host-ip ":" (number-to-string nodePort)))))
|
||||
|
||||
(provide 'ein-k8s)
|
||||
|
|
|
@ -726,7 +726,7 @@ We need this to have proper behavior for the 'Stop' command in the ein:notebookl
|
|||
(ein:events-trigger events 'execution_count.Kernel it))))))))
|
||||
|
||||
(defun ein:kernel--handle-payload (kernel callbacks payload)
|
||||
(loop with events = (ein:$kernel-events kernel)
|
||||
(cl-loop with events = (ein:$kernel-events kernel)
|
||||
for p in payload
|
||||
for text = (or (plist-get p :text)
|
||||
(plist-get (plist-get p :data)
|
||||
|
@ -851,7 +851,7 @@ See `ein:kernel-history-request' for other usable options."
|
|||
(setq finished t))
|
||||
nil))
|
||||
args)
|
||||
(loop repeat (floor (/ timeout tick-time))
|
||||
(cl-loop repeat (floor (/ timeout tick-time))
|
||||
do (sit-for tick-time)
|
||||
when finished
|
||||
return t
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
(setq ein:log-message-level (ein:log-level-name-to-int level)))
|
||||
|
||||
(defun ein:log-level-int-to-name (int)
|
||||
(loop for (n . i) in ein:log-level-def
|
||||
(cl-loop for (n . i) in ein:log-level-def
|
||||
when (>= int i)
|
||||
return n
|
||||
finally 'error))
|
||||
|
|
|
@ -60,7 +60,7 @@ Modified version of `org-src-get-lang-mode'."
|
|||
(unless (eq major-mode lang-mode) (funcall lang-mode))
|
||||
(font-lock-ensure)
|
||||
(setq pos (point-min))
|
||||
(loop for next = (next-single-property-change pos 'face nil (point-max))
|
||||
(cl-loop for next = (next-single-property-change pos 'face nil (point-max))
|
||||
do (put-text-property
|
||||
;; `font-lock-face' property is used instead of `font'.
|
||||
;; This is the only difference from org-src.
|
||||
|
|
|
@ -187,7 +187,7 @@ This function may raise an error."
|
|||
"Parent modes for `ein:notebook-multilang-mode' to register in yasnippet.")
|
||||
|
||||
(defun ein:ml-setup-yasnippet ()
|
||||
(loop for define-parents in '(yas/define-parents
|
||||
(cl-loop for define-parents in '(yas/define-parents
|
||||
yas--define-parents)
|
||||
when (fboundp define-parents)
|
||||
do (ignore-errors
|
||||
|
|
|
@ -49,9 +49,9 @@
|
|||
(memq class (ein:$node-class node)))
|
||||
|
||||
(defun ein:node-filter (ewoc-node-list &rest args)
|
||||
(loop for (key . class) in (ein:plist-iter args)
|
||||
(cl-loop for (key . class) in (ein:plist-iter args)
|
||||
do (setq ewoc-node-list
|
||||
(loop for ewoc-node in ewoc-node-list
|
||||
(cl-loop for ewoc-node in ewoc-node-list
|
||||
for node = (ewoc-data ewoc-node)
|
||||
when (case key
|
||||
(:is (ein:node-has-class node class))
|
||||
|
|
|
@ -179,7 +179,7 @@ Current buffer for these functions is set to the notebook buffer.")
|
|||
(let ((kernelspec
|
||||
(cond ((ein:$kernelspec-p pre-kernelspec) pre-kernelspec)
|
||||
((consp pre-kernelspec)
|
||||
(loop for (name ks) on (ein:need-kernelspecs url-or-port) by 'cddr
|
||||
(cl-loop for (name ks) on (ein:need-kernelspecs url-or-port) by 'cddr
|
||||
when (and (ein:$kernelspec-p ks)
|
||||
(string= (cdr pre-kernelspec)
|
||||
(cl-struct-slot-value
|
||||
|
@ -241,7 +241,7 @@ combo must match exactly these url/port you used format
|
|||
|
||||
(defun ein:notebook-buffer (notebook)
|
||||
"Return first buffer in NOTEBOOK's worksheets."
|
||||
(loop for ws in (append (ein:$notebook-worksheets notebook)
|
||||
(cl-loop for ws in (append (ein:$notebook-worksheets notebook)
|
||||
(ein:$notebook-scratchsheets notebook))
|
||||
if (ein:worksheet-buffer ws)
|
||||
return it))
|
||||
|
@ -453,7 +453,7 @@ of minor mode."
|
|||
|
||||
(defun ein:list-available-kernels (url-or-port)
|
||||
(when-let ((kernelspecs (ein:need-kernelspecs url-or-port)))
|
||||
(sort (loop for (key spec) on (ein:plist-exclude kernelspecs '(:default)) by 'cddr
|
||||
(sort (cl-loop for (key spec) on (ein:plist-exclude kernelspecs '(:default)) by 'cddr
|
||||
collecting (cons (ein:$kernelspec-name spec)
|
||||
(ein:$kernelspec-display-name spec)))
|
||||
(lambda (c1 c2) (string< (cdr c1) (cdr c2))))))
|
||||
|
@ -481,7 +481,7 @@ notebook buffer then the user will be prompted to select an opened notebook."
|
|||
(ein:$kernelspec-name kernelspec) (ein:$kernelspec-spec kernelspec))))
|
||||
(ein:notebook-save-notebook notebook #'ein:notebook-kill-kernel-then-close-command
|
||||
(list notebook))
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
until (null (ein:$kernel-websocket (ein:$notebook-kernel notebook)))
|
||||
do (sleep-for 0 500)
|
||||
finally return (ein:notebook-open (ein:$notebook-url-or-port notebook)
|
||||
|
@ -708,7 +708,7 @@ This is equivalent to do ``C-c`` in the console program."
|
|||
(plist-put spec :name name)))
|
||||
|
||||
(defun ein:write-nbformat4-worksheets (notebook)
|
||||
(let ((all-cells (loop for ws in (ein:$notebook-worksheets notebook)
|
||||
(let ((all-cells (cl-loop for ws in (ein:$notebook-worksheets notebook)
|
||||
for i from 0
|
||||
append (ein:worksheet-to-nb4-json ws i))))
|
||||
;; should be in notebook constructor, not here
|
||||
|
@ -872,7 +872,7 @@ NAME is any non-empty string that does not contain '/' or '\\'.
|
|||
(add-function :before callback0 (lambda () (setq success-positive 1)))
|
||||
(ein:notebook-save-notebook notebook callback0 nil
|
||||
(lambda () (setq success-positive -1)))
|
||||
(loop repeat 10
|
||||
(cl-loop repeat 10
|
||||
until (not (zerop success-positive))
|
||||
do (sleep-for 0 200)
|
||||
finally return (> success-positive 0)))
|
||||
|
@ -1019,7 +1019,7 @@ given."
|
|||
#'switch-to-buffer))
|
||||
(let ((next (if (ein:scratchsheet-p ws)
|
||||
(car (ein:$notebook-worksheets notebook))
|
||||
(loop with worksheets = (ein:$notebook-worksheets notebook)
|
||||
(cl-loop with worksheets = (ein:$notebook-worksheets notebook)
|
||||
for current in worksheets
|
||||
for next in (cdr worksheets)
|
||||
when (eq current ws) return next))))
|
||||
|
@ -1034,7 +1034,7 @@ See also `ein:notebook-worksheet-open-next'."
|
|||
#'switch-to-buffer))
|
||||
(let ((prev (if (ein:scratchsheet-p ws)
|
||||
(car (last (ein:$notebook-worksheets notebook)))
|
||||
(loop for (prev current) on (ein:$notebook-worksheets notebook)
|
||||
(cl-loop for (prev current) on (ein:$notebook-worksheets notebook)
|
||||
when (eq current ws) return prev))))
|
||||
(ein:notebook-worksheet--open-new notebook prev "previous" show)
|
||||
prev))
|
||||
|
@ -1057,7 +1057,7 @@ See also `ein:notebook-worksheet-open-next'."
|
|||
|
||||
(defmacro ein:notebook-worksheet--defun-all-open-nth (min max)
|
||||
`(progn
|
||||
,@(loop for n from min to max
|
||||
,@(cl-loop for n from min to max
|
||||
collect `(ein:notebook-worksheet--defun-open-nth ,n))))
|
||||
|
||||
(ein:notebook-worksheet--defun-all-open-nth 1 8)
|
||||
|
@ -1138,7 +1138,7 @@ When used as a lisp function, delete worksheet WS from NOTEBOOk."
|
|||
(cl-defun ein:notebook-worksheet-index
|
||||
(&optional (notebook ein:%notebook%) (ws ein:%worksheet%))
|
||||
"Return an index of the worksheet WS in NOTEBOOK."
|
||||
(loop for i from 0
|
||||
(cl-loop for i from 0
|
||||
for ith-ws in (ein:$notebook-worksheets notebook)
|
||||
when (eq ith-ws ws)
|
||||
return i))
|
||||
|
@ -1246,7 +1246,7 @@ associated with current buffer (if any)."
|
|||
(and (ein:$notebook-p notebook)
|
||||
(ein:notebook-live-p notebook)
|
||||
(or (ein:$notebook-dirty notebook)
|
||||
(loop for ws in (ein:$notebook-worksheets notebook)
|
||||
(cl-loop for ws in (ein:$notebook-worksheets notebook)
|
||||
when (ein:worksheet-modified-p ws)
|
||||
return t))))
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ associated with current buffer (if any)."
|
|||
(defun ein:notebook-choose-mode ()
|
||||
"Return usable (defined) notebook mode."
|
||||
(autoload 'ein:notebook-multilang-mode "ein-multilang")
|
||||
(loop for mode in ein:notebook-modes
|
||||
(cl-loop for mode in ein:notebook-modes
|
||||
if (functionp mode)
|
||||
return mode))
|
||||
|
||||
|
@ -1452,7 +1452,7 @@ Tried add-function: the &rest from :around is an emacs-25 compilation issue."
|
|||
"---"
|
||||
,@(ein:generate-menu
|
||||
(append
|
||||
(loop for n from 1 to 8
|
||||
(cl-loop for n from 1 to 8
|
||||
collect
|
||||
(list
|
||||
(format "Open %d-th worksheet" n)
|
||||
|
|
|
@ -170,37 +170,47 @@ This function adds NBLIST to `ein:notebooklist-map'."
|
|||
|
||||
(defun ein:crib-token (url-or-port)
|
||||
"Shell out to jupyter for its credentials knowledge. Return list of (PASSWORD TOKEN)."
|
||||
(aif (loop for line in (ein:process-lines
|
||||
ein:jupyter-server-command
|
||||
(append (aif ein:jupyter-server-use-subcommand (list it))
|
||||
'("list" "--json")))
|
||||
with token0
|
||||
with password0
|
||||
when (destructuring-bind
|
||||
(&key password url token &allow-other-keys)
|
||||
(ein:json-read-from-string line)
|
||||
(prog1 (equal (ein:url url) url-or-port)
|
||||
(setq password0 password) ;; t or :json-false
|
||||
(setq token0 token)))
|
||||
return (list password0 token0))
|
||||
(aif (cl-loop for line in
|
||||
(apply #'ein:jupyter-process-lines url-or-port
|
||||
ein:jupyter-server-command
|
||||
(split-string
|
||||
(format "%s%s %s"
|
||||
(aif ein:jupyter-server-use-subcommand
|
||||
(concat it " ") "")
|
||||
"list" "--json")))
|
||||
with token0
|
||||
with password0
|
||||
when (destructuring-bind
|
||||
(&key password url token &allow-other-keys)
|
||||
(ein:json-read-from-string line)
|
||||
(prog1 (equal (ein:url url) url-or-port)
|
||||
(setq password0 password) ;; t or :json-false
|
||||
(setq token0 token)))
|
||||
return (list password0 token0))
|
||||
it (list nil nil)))
|
||||
|
||||
(defun ein:crib-running-servers ()
|
||||
"Shell out to jupyter for running servers."
|
||||
(loop for line in (condition-case err
|
||||
(apply #'process-lines
|
||||
ein:jupyter-server-command
|
||||
(append (aif ein:jupyter-server-use-subcommand
|
||||
(list it))
|
||||
'("list" "--json")))
|
||||
(error (ein:log 'info "ein:crib-running-servers: %s" err)
|
||||
nil))
|
||||
collecting (destructuring-bind
|
||||
(&key url &allow-other-keys)
|
||||
(ein:json-read-from-string line) (ein:url url))))
|
||||
(cl-loop for line in
|
||||
(nconc
|
||||
(apply #'ein:jupyter-process-lines nil
|
||||
ein:jupyter-server-command
|
||||
(split-string
|
||||
(format "%s%s %s"
|
||||
(aif ein:jupyter-server-use-subcommand
|
||||
(concat it " ") "")
|
||||
"list" "--json")))
|
||||
(aif (ein:k8s-service-url-or-port) (list it)))
|
||||
collecting (destructuring-bind
|
||||
(&key url &allow-other-keys)
|
||||
(ein:json-read-from-string line) (ein:url url))))
|
||||
|
||||
(defun ein:notebooklist-token-or-password (url-or-port)
|
||||
"Return token or password (jupyter requires one or the other but not both) for URL-OR-PORT. Empty string token means all authentication disabled. Nil means don't know."
|
||||
"Return token or password for URL-OR-PORT.
|
||||
|
||||
Jupyter requires one or the other but not both.
|
||||
Return empty string token if all authentication disabled.
|
||||
Return nil if unclear what, if any, authentication applies."
|
||||
(multiple-value-bind (password-p token) (ein:crib-token url-or-port)
|
||||
(autoload 'ein:jupyter-server-conn-info "ein-jupyter")
|
||||
(multiple-value-bind (my-url-or-port my-token) (ein:jupyter-server-conn-info)
|
||||
|
@ -630,7 +640,7 @@ This function is called via `ein:notebook-after-rename-hook'."
|
|||
(ein:make-sorting-widget "Sort by" ein:notebooklist-sort-field)
|
||||
(ein:make-sorting-widget "In Order" ein:notebooklist-sort-order)
|
||||
(widget-insert "\n")
|
||||
(loop for note in (ein:notebooklist--order-data (ein:$notebooklist-data ein:%notebooklist%)
|
||||
(cl-loop for note in (ein:notebooklist--order-data (ein:$notebooklist-data ein:%notebooklist%)
|
||||
ein:notebooklist-sort-field
|
||||
ein:notebooklist-sort-order)
|
||||
for name = (plist-get note :name)
|
||||
|
@ -732,10 +742,10 @@ Notebook list data is passed via the buffer local variable
|
|||
(defun ein:notebooklist-list-paths (&optional content-type)
|
||||
"Return all files of CONTENT-TYPE for all sessions"
|
||||
(apply #'append
|
||||
(loop for nblist in (ein:notebooklist-list)
|
||||
(cl-loop for nblist in (ein:notebooklist-list)
|
||||
for url-or-port = (ein:$notebooklist-url-or-port nblist)
|
||||
collect
|
||||
(loop for content in (ein:content-need-hierarchy url-or-port)
|
||||
(cl-loop for content in (ein:content-need-hierarchy url-or-port)
|
||||
when (or (null content-type)
|
||||
(string= (ein:$content-type content) content-type))
|
||||
collect (ein:url url-or-port (ein:$content-path content))))))
|
||||
|
@ -743,7 +753,7 @@ Notebook list data is passed via the buffer local variable
|
|||
|
||||
(defun ein:notebooklist-parse-nbpath (nbpath)
|
||||
"Return `(,url-or-port ,path) from URL-OR-PORT/PATH"
|
||||
(loop for url-or-port in (ein:notebooklist-keys)
|
||||
(cl-loop for url-or-port in (ein:notebooklist-keys)
|
||||
if (cl-search url-or-port nbpath :end2 (length url-or-port))
|
||||
return (list (substring nbpath 0 (length url-or-port))
|
||||
(substring nbpath (1+ (length url-or-port))))
|
||||
|
@ -833,7 +843,7 @@ and the url-or-port argument of ein:notebooklist-open*."
|
|||
(let* ((parsed-url (url-generic-parse-url (file-name-as-directory url-or-port)))
|
||||
(domain (url-host parsed-url))
|
||||
(securep (string-match "^wss://" url-or-port)))
|
||||
(loop for (name content) on cookie-plist by (function cddr)
|
||||
(cl-loop for (name content) on cookie-plist by (function cddr)
|
||||
for line = (mapconcat #'identity (list domain "FALSE" (car (url-path-and-query parsed-url)) (if securep "TRUE" "FALSE") "0" (symbol-name name) (concat content "\n")) "\t")
|
||||
do (write-region line nil (request--curl-cookie-jar) 'append))))
|
||||
|
||||
|
@ -854,15 +864,8 @@ and the url-or-port argument of ein:notebooklist-open*."
|
|||
(interactive `(,(lambda (buffer url-or-port) (pop-to-buffer buffer))))
|
||||
(unless callback (setq callback #'ignore))
|
||||
(call-interactively #'ein:k8s-select-context)
|
||||
(-if-let* ((url-or-port (ein:k8s-service-url-or-port))
|
||||
(node (ein:k8s-get-node))
|
||||
((&alist 'status (&alist 'addresses)) node)
|
||||
(address
|
||||
(seq-some (lambda (address)
|
||||
(when (string= (alist-get 'type address) "InternalIP")
|
||||
(alist-get 'address address)))
|
||||
addresses)))
|
||||
(concat address ":" (number-to-string url-or-port))
|
||||
(if-let ((url-or-port (ein:k8s-service-url-or-port)))
|
||||
url-or-port
|
||||
(error "ein:cluster-login: No jupyter node found for %s"
|
||||
(alist-get 'name (kubernetes-state-current-context (kubernetes-state))))))
|
||||
|
||||
|
@ -899,7 +902,7 @@ and the url-or-port argument of ein:notebooklist-open*."
|
|||
((request-response-header response "x-jupyterhub-version")
|
||||
(let ((pam-plist (ein:notebooklist-ask-user-pw-pair "User" "Password")))
|
||||
(destructuring-bind (user pw)
|
||||
(loop for (user pw) on pam-plist by (function cddr)
|
||||
(cl-loop for (user pw) on pam-plist by (function cddr)
|
||||
return (list (symbol-name user) pw))
|
||||
(ein:jupyterhub-connect url-or-port user pw callback))))
|
||||
(t (ein:notebooklist-login--success-1 url-or-port callback errback))))
|
||||
|
|
|
@ -66,10 +66,10 @@ S-mouse-1/3 (Shift + left/right click): move this tab to left/right"
|
|||
just set the status (= event-type):
|
||||
(ein:notification-status-set NS EVENT-TYPE)
|
||||
where NS is `:kernel' or `:notebook' slot of NOTIFICATION."
|
||||
(loop for ns in (list (slot-value notification 'kernel)
|
||||
(cl-loop for ns in (list (slot-value notification 'kernel)
|
||||
(slot-value notification 'notebook))
|
||||
for statuses = (mapcar #'car (slot-value ns 's2m))
|
||||
do (loop for st in statuses
|
||||
do (cl-loop for st in statuses
|
||||
do (ein:events-on events
|
||||
st ; = event-type
|
||||
#'ein:notification--callback
|
||||
|
@ -173,7 +173,7 @@ insert-prev insert-next move-prev move-next)"
|
|||
(ein:join-str
|
||||
" "
|
||||
(append
|
||||
(loop for i from 1
|
||||
(cl-loop for i from 1
|
||||
for elem in list
|
||||
if (eq elem current)
|
||||
collect (propertize
|
||||
|
@ -266,7 +266,7 @@ insert-prev insert-next move-prev move-next)"
|
|||
|
||||
(defmacro ein:header-line-define-mouse-commands (&rest name-slot-list)
|
||||
`(progn
|
||||
,@(loop for (name slot) on name-slot-list by 'cddr
|
||||
,@(cl-loop for (name slot) on name-slot-list by 'cddr
|
||||
collect
|
||||
`(defun ,name (key-event)
|
||||
,(format "Run slot %s
|
||||
|
|
|
@ -45,7 +45,7 @@ can be handled by the xml module."
|
|||
(defun ein:xml-tree-apply (dom operation)
|
||||
"Apply OPERATION on nodes in DOM. Apply the same OPERATION on
|
||||
the next level children when it returns `nil'."
|
||||
(loop for child in (xml-node-children dom)
|
||||
(cl-loop for child in (xml-node-children dom)
|
||||
if (and (not (funcall operation child))
|
||||
(ein:xml-node-p child))
|
||||
do (ein:xml-tree-apply child operation)))
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
(defun ein:process-suitable-notebook-dir (filename)
|
||||
"Return the uppermost parent dir of DIR that contains ipynb files."
|
||||
(let ((fn (expand-file-name filename)))
|
||||
(loop with directory = (directory-file-name
|
||||
(cl-loop with directory = (directory-file-name
|
||||
(if (file-regular-p fn)
|
||||
(file-name-directory (directory-file-name fn))
|
||||
fn))
|
||||
|
@ -119,15 +119,10 @@
|
|||
(setq directory (directory-file-name (file-name-directory directory)))
|
||||
finally return suitable)))
|
||||
|
||||
(defun ein:process-lines (command &rest args)
|
||||
"Shell out COMMAND ARGS... via kubectl if necessary."
|
||||
;; ein:cluster-login
|
||||
)
|
||||
|
||||
(defun ein:process-refresh-processes ()
|
||||
"Use `jupyter notebook list --json` to populate ein:%processes%"
|
||||
(clrhash ein:%processes%)
|
||||
(loop for line in (condition-case err
|
||||
(cl-loop for line in (condition-case err
|
||||
(apply #'process-lines
|
||||
ein:jupyter-server-command
|
||||
(append (aif ein:jupyter-server-use-subcommand
|
||||
|
@ -146,13 +141,13 @@
|
|||
|
||||
(defun ein:process-dir-match (filename)
|
||||
"Return ein:process whose directory is prefix of FILENAME."
|
||||
(loop for dir in (hash-table-keys ein:%processes%)
|
||||
(cl-loop for dir in (hash-table-keys ein:%processes%)
|
||||
when (cl-search dir filename)
|
||||
return (gethash dir ein:%processes%)))
|
||||
|
||||
(defun ein:process-url-match (url-or-port)
|
||||
"Return ein:process whose url matches URL-OR-PORT."
|
||||
(loop with parsed-url-or-port = (url-generic-parse-url url-or-port)
|
||||
(cl-loop with parsed-url-or-port = (url-generic-parse-url url-or-port)
|
||||
for proc in (ein:process-processes)
|
||||
for parsed-url-proc = (url-generic-parse-url (ein:process-url-or-port proc))
|
||||
when (and (string= (url-host parsed-url-or-port) (url-host parsed-url-proc))
|
||||
|
|
|
@ -134,7 +134,7 @@ KEY, then call `request' with URL and SETTINGS. KEY is compared by
|
|||
(with-local-quit
|
||||
(when timeout
|
||||
(setq settings (plist-put settings :timeout (/ timeout 1000.0))))
|
||||
(loop do (ein:query-running-process-table)
|
||||
(cl-loop do (ein:query-running-process-table)
|
||||
for running = (hash-table-count ein:query-running-process-table)
|
||||
until (< running ein:max-simultaneous-queries)
|
||||
do (ein:log 'warn "ein:query-singleton-ajax: %d running processes"
|
||||
|
|
|
@ -195,7 +195,7 @@ at point, i.e. any word before then \"(\", if it is present."
|
|||
(defvar ein:url-localhost "127.0.0.1")
|
||||
|
||||
(defsubst ein:glom-paths (&rest paths)
|
||||
(loop with result = ""
|
||||
(cl-loop with result = ""
|
||||
for p in paths
|
||||
if (not (zerop (length p)))
|
||||
do (setq result (concat result (ein:trim-left (directory-file-name p) "/") "/"))
|
||||
|
@ -348,13 +348,13 @@ number of lines is less than `nlines' then just return the string."
|
|||
(let* ((lines (split-string string "\n"))
|
||||
(indent
|
||||
(let ((lens
|
||||
(loop for line in lines
|
||||
(cl-loop for line in lines
|
||||
for stripped = (ein:trim-left line)
|
||||
unless (equal stripped "")
|
||||
collect (- (length line) (length stripped)))))
|
||||
(if lens (apply #'min lens) 0)))
|
||||
(trimmed
|
||||
(loop for line in lines
|
||||
(cl-loop for line in lines
|
||||
if (> (length line) indent)
|
||||
collect (ein:trim-right (substring line indent))
|
||||
else
|
||||
|
@ -420,7 +420,7 @@ Adapted from twittering-mode.el's `case-string'."
|
|||
(defun ein:plist-iter (plist)
|
||||
"Return list of (key . value) in PLIST."
|
||||
;; FIXME: this is not needed. See: `ein:plist-exclude'.
|
||||
(loop for p in plist
|
||||
(cl-loop for p in plist
|
||||
for i from 0
|
||||
for key-p = (= (% i 2) 0)
|
||||
with key = nil
|
||||
|
@ -433,7 +433,7 @@ Adapted from twittering-mode.el's `case-string'."
|
|||
Example::
|
||||
|
||||
(ein:plist-exclude '(:a 1 :b 2 :c 3 :d 4) '(:b :c))"
|
||||
(loop for (k v) on plist by 'cddr
|
||||
(cl-loop for (k v) on plist by 'cddr
|
||||
unless (memq k keys)
|
||||
nconc (list k v)))
|
||||
|
||||
|
@ -443,7 +443,7 @@ Example::
|
|||
Example::
|
||||
|
||||
(ein:clip-list '(1 2 3 4 5 6) 2 4) ;=> (2 3 4)"
|
||||
(loop for elem in list
|
||||
(cl-loop for elem in list
|
||||
with clipped
|
||||
with in-region-p = nil
|
||||
when (eq elem first)
|
||||
|
@ -457,7 +457,7 @@ Example::
|
|||
"Insert NEW after PIVOT in LIST destructively.
|
||||
Note: do not rely on that `ein:list-insert-after' change LIST in place.
|
||||
Elements are compared using the function TEST (default: `eq')."
|
||||
(loop for rest on list
|
||||
(cl-loop for rest on list
|
||||
when (funcall test (car rest) pivot)
|
||||
return (progn (push new (cdr rest)) list)
|
||||
finally do (error "PIVOT %S is not in LIST %S" pivot list)))
|
||||
|
@ -468,7 +468,7 @@ Note: do not rely on that `ein:list-insert-before' change LIST in place.
|
|||
Elements are compared using the function TEST (default: `eq')."
|
||||
(if (and list (funcall test (car list) pivot))
|
||||
(cons new list)
|
||||
(loop for rest on list
|
||||
(cl-loop for rest on list
|
||||
when (funcall test (cadr rest) pivot)
|
||||
return (progn (push new (cdr rest)) list)
|
||||
finally do (error "PIVOT %S is not in LIST %S" pivot list))))
|
||||
|
@ -480,7 +480,7 @@ Elements are compared using the function TEST (default: `eq')."
|
|||
((== (car list) elem)
|
||||
(append (cdr list) (list (car list))))
|
||||
(t
|
||||
(loop for rest on list
|
||||
(cl-loop for rest on list
|
||||
when (== (cadr rest) elem)
|
||||
return (let ((prev (car rest)))
|
||||
(setf (car rest) elem)
|
||||
|
@ -490,7 +490,7 @@ Elements are compared using the function TEST (default: `eq')."
|
|||
|
||||
(cl-defun ein:list-move-right (list elem &key (test #'eq))
|
||||
"Move ELEM in LIST right. TEST is used to compare elements"
|
||||
(loop with first = t
|
||||
(cl-loop with first = t
|
||||
for rest on list
|
||||
when (funcall test (car rest) elem)
|
||||
return (if (cdr rest)
|
||||
|
@ -545,14 +545,14 @@ FUNC is called as (apply FUNC ARG ARGS)."
|
|||
(defun ein:remove-by-index (list indices)
|
||||
"Remove elements from LIST if its index is in INDICES.
|
||||
NOTE: This function creates new list."
|
||||
(loop for l in list
|
||||
(cl-loop for l in list
|
||||
for i from 0
|
||||
when (not (memq i indices))
|
||||
collect l))
|
||||
|
||||
(defun ein:ask-choice-char (prompt choices)
|
||||
"Show PROMPT and read one of acceptable key specified as CHOICES."
|
||||
(let ((char-list (loop for i from 0 below (length choices)
|
||||
(let ((char-list (cl-loop for i from 0 below (length choices)
|
||||
collect (elt choices i)))
|
||||
(answer 'recenter))
|
||||
(while
|
||||
|
@ -584,7 +584,7 @@ PREDARGS is argument list for the PREDICATE function.
|
|||
Make TIMEOUT-SECONDS larger \(default 5) to wait longer before timeout."
|
||||
(ein:log 'debug "WAIT-UNTIL start")
|
||||
(unless timeout-seconds (setq timeout-seconds 5))
|
||||
(unless (loop repeat (/ timeout-seconds 0.05)
|
||||
(unless (cl-loop repeat (/ timeout-seconds 0.05)
|
||||
when (apply predicate predargs)
|
||||
return t
|
||||
;; borrowed from `deferred:sync!':
|
||||
|
@ -623,7 +623,7 @@ DONEBACK returns t or 'error when calling process is done, and nil if not done."
|
|||
;; "complicated timings of macro expansion lexical-let, deferred:lambda"
|
||||
;; using deferred:loop instead
|
||||
(deferred:$
|
||||
(deferred:loop (loop for i from 1 below 30 by 1 collect i)
|
||||
(deferred:loop (cl-loop for i from 1 below 30 by 1 collect i)
|
||||
(lambda ()
|
||||
(deferred:$
|
||||
(deferred:next
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
(read-cookies-func (lambda (path)
|
||||
(request-cookie-alist
|
||||
(url-host parsed-url) path securep)))
|
||||
(cookies (loop repeat 4
|
||||
(cookies (cl-loop repeat 4
|
||||
for cand = (cl-mapcan read-cookies-func
|
||||
`("/" "/hub/"
|
||||
,(ein:maybe-get-jhconn-user url)))
|
||||
|
|
|
@ -668,14 +668,14 @@ Prefixes are act same as the normal `yank' command."
|
|||
(t (1- arg))))))
|
||||
(let* ((cell (ein:worksheet-get-current-cell :noerror t)) ; can be nil
|
||||
(killed (ein:current-kill n)))
|
||||
(loop for c in killed
|
||||
(cl-loop for c in killed
|
||||
with last = cell
|
||||
do (setq last (ein:worksheet-insert-clone ws c last "below"))
|
||||
finally (ein:cell-goto last))))
|
||||
|
||||
(defun ein:worksheet--node-positions (cell)
|
||||
(let ((result))
|
||||
(loop for k in (slot-value cell 'element-names)
|
||||
(cl-loop for k in (slot-value cell 'element-names)
|
||||
do (setq result
|
||||
(plist-put result k
|
||||
(let* ((en-or-list (ein:cell-element-get cell k))
|
||||
|
@ -870,7 +870,7 @@ When NTH is specified, return NTH cell. Note that this function is
|
|||
(setq nth (* nth -1))
|
||||
(setq up (not up)))
|
||||
(let ((cell (ein:worksheet-next-input-cell-1 ewoc-node up)))
|
||||
(loop repeat (1- nth)
|
||||
(cl-loop repeat (1- nth)
|
||||
with next = (if up #'ein:cell-prev #'ein:cell-next)
|
||||
if (funcall next cell)
|
||||
do (setq cell it)
|
||||
|
@ -1184,7 +1184,7 @@ in the history."
|
|||
|
||||
(defun ein:worksheet--cells-before-cell (ws cell)
|
||||
(let ((cells (ein:worksheet-get-cells ws)))
|
||||
(loop for c in cells
|
||||
(cl-loop for c in cells
|
||||
collecting c
|
||||
until (eql (ein:cell-id c) (ein:cell-id cell)))))
|
||||
|
||||
|
@ -1194,7 +1194,7 @@ in the history."
|
|||
(seq-drop cells prior-cells)))
|
||||
|
||||
(defun ein:worksheet-first-executing-cell (cells)
|
||||
(loop for c in cells
|
||||
(cl-loop for c in cells
|
||||
when (and (ein:codecell-p c)
|
||||
(slot-value c 'running))
|
||||
return c))
|
||||
|
@ -1264,10 +1264,10 @@ function."
|
|||
"`imenu-create-index-function' for notebook buffer."
|
||||
;; As Imenu does not provide the way to represent level *and*
|
||||
;; position, use #'s to do that.
|
||||
(loop for cell in (when (ein:worksheet-p ein:%worksheet%)
|
||||
(cl-loop for cell in (when (ein:worksheet-p ein:%worksheet%)
|
||||
(seq-filter #'ein:headingcell-p
|
||||
(ein:worksheet-get-cells ein:%worksheet%)))
|
||||
for sharps = (loop repeat (slot-value cell 'level) collect "#")
|
||||
for sharps = (cl-loop repeat (slot-value cell 'level) collect "#")
|
||||
for text = (ein:cell-get-text cell)
|
||||
for name = (ein:join-str "" (append sharps (list " " text)))
|
||||
collect (cons name (ein:cell-input-pos-min cell))))
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
(base64-decode-region (point-min) (point-max)))))
|
||||
|
||||
(defun ob-ein--return-mime-type (json file)
|
||||
(loop
|
||||
(cl-loop
|
||||
for key in ein:output-types-text-preferred
|
||||
for type = (intern (format ":%s" key)) ; something like `:text'
|
||||
for value = (plist-get json type) ; FIXME: optimize
|
||||
|
@ -137,7 +137,7 @@
|
|||
(defun ob-ein--process-outputs (outputs params)
|
||||
(let ((file (cdr (assoc :image params))))
|
||||
(ein:join-str "\n"
|
||||
(loop for o in outputs
|
||||
(cl-loop for o in outputs
|
||||
collecting (ob-ein--return-mime-type o file)))))
|
||||
|
||||
|
||||
|
@ -210,7 +210,7 @@ Based on ob-ipython--configure-kernel."
|
|||
(ob-ein--initiate-session session kernelspec callback)
|
||||
(if (ein:eval-if-bound 'org-current-export-file)
|
||||
(save-excursion
|
||||
(loop with interval = 2000
|
||||
(cl-loop with interval = 2000
|
||||
with pending = t
|
||||
repeat (/ (* ob-ein-timeout-seconds 1000) interval)
|
||||
do (progn
|
||||
|
@ -312,7 +312,7 @@ if necessary. Install CALLBACK (i.e., cell execution) upon notebook retrieval."
|
|||
(substring nbpath 0 (- (length slash-path)))))
|
||||
(notebook (ein:notebook-get-opened-notebook url-or-port path))
|
||||
(callback-nbopen (lambda (nb _created)
|
||||
(loop repeat 50
|
||||
(cl-loop repeat 50
|
||||
for live-p = (ein:kernel-live-p (ein:$notebook-kernel nb))
|
||||
until live-p
|
||||
do (sleep-for 0 300)
|
||||
|
@ -338,18 +338,20 @@ if necessary. Install CALLBACK (i.e., cell execution) upon notebook retrieval."
|
|||
path (ein:$kernelspec-name (ein:$notebook-kernelspec notebook))
|
||||
kernelspec)
|
||||
(cl-letf (((symbol-function 'y-or-n-p) #'ignore))
|
||||
(ein:notebook-close notebook)
|
||||
(ein:query-singleton-ajax
|
||||
(list 'ob-ein--initiate-session (ein:url url-or-port path))
|
||||
(ein:notebook-url notebook)
|
||||
:type "DELETE"))
|
||||
(loop repeat 8
|
||||
for extant = (file-exists-p path)
|
||||
until (not extant)
|
||||
do (sleep-for 0 500)
|
||||
finally do (if extant
|
||||
(ein:display-warning (format "cannot del %s" path))
|
||||
(ob-ein--initiate-session session kernelspec callback))))
|
||||
(ein:notebook-close notebook))
|
||||
(ein:query-singleton-ajax
|
||||
(list 'ob-ein--initiate-session (ein:url url-or-port path))
|
||||
(ein:notebook-url notebook)
|
||||
:type "DELETE")
|
||||
(cl-loop repeat 8
|
||||
with fullpath = (concat (file-name-as-directory nbpath) path)
|
||||
for extant = (file-exists-p fullpath)
|
||||
until (not extant)
|
||||
do (sleep-for 0 500)
|
||||
finally do (if extant
|
||||
(ein:display-warning
|
||||
(format "cannot del path=%s nbpath=%s" fullpath nbpath))
|
||||
(ob-ein--initiate-session session kernelspec callback))))
|
||||
(notebook (funcall callback notebook))
|
||||
((string= (url-host parsed-url) ein:url-localhost)
|
||||
(ein:process-refresh-processes)
|
||||
|
@ -367,7 +369,7 @@ if necessary. Install CALLBACK (i.e., cell execution) upon notebook retrieval."
|
|||
(t (url-port parsed-url)))))))
|
||||
(t (ein:notebooklist-login url-or-port callback-login)))))
|
||||
|
||||
(loop for (lang . mode) in ob-ein-languages
|
||||
(cl-loop for (lang . mode) in ob-ein-languages
|
||||
do (ob-ein--babelize-lang lang mode))
|
||||
|
||||
;;;###autoload
|
||||
|
|
|
@ -190,7 +190,7 @@ TYPE can be 'body, nil."
|
|||
(ein:display-warning
|
||||
(format "pm:get-span: no major mode for kernelspec language '%s'" what)))
|
||||
(setq result-cm
|
||||
(loop for ocm in (eieio-oref pm/polymode '-auto-innermodes)
|
||||
(cl-loop for ocm in (eieio-oref pm/polymode '-auto-innermodes)
|
||||
when (equal mode (ein:oref-safe ocm 'mode))
|
||||
return ocm
|
||||
finally return (let ((new-mode (clone cm :mode mode)))
|
||||
|
|
|
@ -67,18 +67,18 @@ construct CONTENT and RESULT."
|
|||
(unless pdocstring-list
|
||||
(setq pdocstring-list
|
||||
ein:testing-kernel-construct-help-string-pdocstring-list))
|
||||
(loop with callsig = "function(a=1, b=2, c=d)"
|
||||
with docstring = "This function does what."
|
||||
for pcallsig in pcallsig-list
|
||||
do (loop for pdoc in pdocstring-list
|
||||
for content = (append
|
||||
(when pcallsig (list pcallsig callsig))
|
||||
(when pdoc (list pdoc docstring)))
|
||||
for result = (aif (append
|
||||
(when pcallsig (list callsig))
|
||||
(when pdoc (list docstring)))
|
||||
(ein:join-str "\n" it))
|
||||
do (funcall test content result))))
|
||||
(cl-loop with callsig = "function(a=1, b=2, c=d)"
|
||||
with docstring = "This function does what."
|
||||
for pcallsig in pcallsig-list
|
||||
do (cl-loop for pdoc in pdocstring-list
|
||||
for content = (append
|
||||
(when pcallsig (list pcallsig callsig))
|
||||
(when pdoc (list pdoc docstring)))
|
||||
for result = (aif (append
|
||||
(when pcallsig (list callsig))
|
||||
(when pdoc (list docstring)))
|
||||
(ein:join-str "\n" it))
|
||||
do (funcall test content result))))
|
||||
|
||||
(provide 'ein-testing-kernel)
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
;;; Code:
|
||||
|
||||
(require 'ein-log)
|
||||
(require 'ein-jupyter)
|
||||
(require 'request)
|
||||
(require 'anaphora)
|
||||
|
||||
|
@ -54,7 +55,7 @@
|
|||
|
||||
(defun ein:testing-dump-logs ()
|
||||
(ein:testing-save-buffer "*Messages*" ein:testing-dump-file-messages)
|
||||
(ein:testing-save-buffer "*ein:jupyter-server*" ein:testing-dump-file-server)
|
||||
(ein:testing-save-buffer *ein:jupyter-server-buffer-name* ein:testing-dump-file-server)
|
||||
(mapc (lambda (b)
|
||||
(ein:and-let* ((bname (buffer-name b))
|
||||
(prefix "kernels/")
|
||||
|
@ -91,7 +92,7 @@ if I call this between links in a deferred chain. Adding a flush-queue."
|
|||
}
|
||||
" 'utf-8 (concat (file-name-as-directory parent) "bar.ipynb")))
|
||||
(if (< current-depth depth)
|
||||
(loop for w from 1 to width
|
||||
(cl-loop for w from 1 to width
|
||||
for dir = (concat (file-name-as-directory parent) (number-to-string w))
|
||||
do (f-mkdir dir)
|
||||
(ein:testing-make-directory-level dir (1+ current-depth) width depth))))
|
||||
|
@ -102,7 +103,7 @@ if I call this between links in a deferred chain. Adding a flush-queue."
|
|||
MS is milliseconds to wait. INTERVAL is polling interval in milliseconds."
|
||||
(let* ((int (aif interval it (aif ms (max 300 (/ ms 10)) 300)))
|
||||
(count (max 1 (if ms (truncate (/ ms int)) 25))))
|
||||
(unless (or (loop repeat count
|
||||
(unless (or (cl-loop repeat count
|
||||
when (apply predicate predargs)
|
||||
return t
|
||||
do (sleep-for 0 int))
|
||||
|
|
|
@ -108,7 +108,7 @@ some input
|
|||
(test-display-data
|
||||
(intern (format "ein:cell-insert-output-display-data-%s" name)))
|
||||
(outputs-pyout
|
||||
(loop for i from 1
|
||||
(cl-loop for i from 1
|
||||
for x in outputs
|
||||
collect
|
||||
;; ein:cell--handle-output doesn't get called
|
||||
|
@ -120,7 +120,7 @@ some input
|
|||
(regexp-pyout
|
||||
(ein:join-str
|
||||
""
|
||||
(loop for i from 1
|
||||
(cl-loop for i from 1
|
||||
for x in regexps
|
||||
collect (format "Out \\[%s\\]:\n%s\n" i x))))
|
||||
(regexp-display-data
|
||||
|
|
|
@ -206,7 +206,7 @@
|
|||
(should (equal (oref new :input) input))))
|
||||
|
||||
(ert-deftest ein:cell-copy-text-types ()
|
||||
(loop for cell-type in '("text" "html" "markdown" "raw" "heading")
|
||||
(cl-loop for cell-type in '("text" "html" "markdown" "raw" "heading")
|
||||
for cell-p = (intern (format "ein:%scell-p" cell-type))
|
||||
do
|
||||
(let* ((input (ein:join-str "\n" '("first input" "second input")))
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
;;; File name translation
|
||||
(ert-deftest ein:filename-translations-from-to-tramp ()
|
||||
;; I really don't understand this https://github.com/magit/with-editor/issues/29
|
||||
(loop with ein:filename-translations =
|
||||
(cl-loop with ein:filename-translations =
|
||||
`((8888 . ,(ein:tramp-create-filename-translator "HOST" "USER")))
|
||||
with filename = "/file/name"
|
||||
for port in '(7777 8888) ; check for the one w/o translation
|
||||
|
@ -33,7 +33,7 @@
|
|||
filename))))
|
||||
|
||||
(ert-deftest ein:filename-translations-to-from-tramp ()
|
||||
(loop with ein:filename-translations =
|
||||
(cl-loop with ein:filename-translations =
|
||||
`((8888 . ,(ein:tramp-create-filename-translator "HOST" "USER")))
|
||||
with filename = "/ssh:USER@HOST:/filename"
|
||||
for port in '(8888)
|
||||
|
@ -46,7 +46,7 @@
|
|||
(let* ((port 8888)
|
||||
(ein:filename-translations
|
||||
`((,port . ,(ein:tramp-create-filename-translator "DUMMY")))))
|
||||
(loop with python-filename = "/file/name"
|
||||
(cl-loop with python-filename = "/file/name"
|
||||
for emacs-filename in '("/scpc:HOST:/file/name"
|
||||
"/ssh:USER@HOST:/file/name")
|
||||
do (should
|
||||
|
@ -56,7 +56,7 @@
|
|||
(should-error (ein:filename-to-python port "/file/name"))))
|
||||
|
||||
(ert-deftest ein:filename-from-python-tramp ()
|
||||
(loop with ein:filename-translations =
|
||||
(cl-loop with ein:filename-translations =
|
||||
`((8888 . ,(ein:tramp-create-filename-translator "HOST" "USER")))
|
||||
with python-filename = "/file/name"
|
||||
for emacs-filename in '("/ssh:USER@HOST:/file/name" "/file/name")
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
(should (equal (ein:current-kill 0) 1))))
|
||||
|
||||
(defun eintest:kill-ring-simple-repeat-setup ()
|
||||
(loop for i from 0 below 5
|
||||
do (ein:kill-new i)
|
||||
do (should (equal (ein:current-kill 0) i))))
|
||||
(cl-loop for i from 0 below 5
|
||||
do (ein:kill-new i)
|
||||
do (should (equal (ein:current-kill 0) i))))
|
||||
|
||||
(ert-deftest ein:kill-ring-simple-repeat ()
|
||||
(let (ein:kill-ring
|
||||
|
@ -25,8 +25,8 @@
|
|||
(let (ein:kill-ring
|
||||
ein:kill-ring-yank-pointer)
|
||||
(eintest:kill-ring-simple-repeat-setup)
|
||||
(loop for i in '(3 2 1 0 4 3 2)
|
||||
do (should (equal (ein:current-kill 1) i)))
|
||||
(cl-loop for i in '(3 2 1 0 4 3 2)
|
||||
do (should (equal (ein:current-kill 1) i)))
|
||||
(should-not (equal ein:kill-ring ein:kill-ring-yank-pointer))
|
||||
(should (equal ein:kill-ring '(4 3 2 1 0)))
|
||||
(should (equal ein:kill-ring-yank-pointer '(2 1 0)))))
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
},
|
||||
\"nbformat\": 3,
|
||||
\"nbformat_minor\": 0,
|
||||
|
||||
|
||||
\"worksheets\": [
|
||||
{
|
||||
\"cells\": [
|
||||
|
@ -137,7 +137,7 @@ is not found."
|
|||
|
||||
(ert-deftest ein:notebook-from-json-all-cell-types ()
|
||||
(with-current-buffer
|
||||
(ein:testing-notebook-make-new
|
||||
(ein:testing-notebook-make-new
|
||||
ein:testing-notebook-dummy-name
|
||||
nil
|
||||
(list (ein:testing-codecell-data "import numpy")
|
||||
|
@ -162,7 +162,7 @@ is not found."
|
|||
(should (equal (ein:cell-get-text (nth 1 cells)) "*markdown* text"))
|
||||
(should (equal (ein:cell-get-text (nth 2 cells)) "`raw` cell text"))
|
||||
(should (equal (ein:cell-get-text (nth 3 cells)) "<b>HTML</b> text"))
|
||||
(loop for i from 4 to 9
|
||||
(cl-loop for i from 4 to 9
|
||||
for level from 1
|
||||
for cell = (nth i cells)
|
||||
do (should (ein:headingcell-p cell))
|
||||
|
@ -250,10 +250,10 @@ When NUM-OPEN = NUM-CLOSE, notebook should be closed."
|
|||
|
||||
(ert-deftest ein:notebook-delete-cell-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-above))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-delete-cell))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 0))))
|
||||
|
||||
|
@ -274,10 +274,10 @@ some text
|
|||
(ert-deftest ein:notebook-kill-cell-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(let (ein:kill-ring ein:kill-ring-yank-pointer)
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-above))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
(loop for i from 1 to 3
|
||||
(cl-loop for i from 1 to 3
|
||||
do (call-interactively #'ein:worksheet-kill-cell)
|
||||
do (should (equal (length ein:kill-ring) i))
|
||||
do (should (equal (ein:worksheet-ncells ein:%worksheet%) (- 3 i)))))))
|
||||
|
@ -285,10 +285,10 @@ some text
|
|||
(ert-deftest ein:notebook-copy-cell-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(let (ein:kill-ring ein:kill-ring-yank-pointer)
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-above))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-copy-cell))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
(should (equal (length ein:kill-ring) 3)))))
|
||||
|
@ -296,17 +296,17 @@ some text
|
|||
(ert-deftest ein:notebook-yank-cell-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(let (ein:kill-ring ein:kill-ring-yank-pointer)
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-above))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-kill-cell))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 0))
|
||||
(should (equal (length ein:kill-ring) 3))
|
||||
(loop repeat 3
|
||||
(cl-loop repeat 3
|
||||
do (call-interactively #'ein:worksheet-yank-cell))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
(loop for cell in (ein:worksheet-get-cells ein:%worksheet%)
|
||||
(cl-loop for cell in (ein:worksheet-get-cells ein:%worksheet%)
|
||||
do (should (ein:codecell-p cell))
|
||||
do (should (slot-boundp cell :kernel))
|
||||
do (should (slot-boundp cell :events))))))
|
||||
|
@ -366,10 +366,10 @@ some text
|
|||
(should (funcall cell-p new)))
|
||||
(should (looking-back "some text"))))))
|
||||
;; change type: code (no change) -> markdown -> raw
|
||||
(loop for type in '("code" "markdown" "raw")
|
||||
(cl-loop for type in '("code" "markdown" "raw")
|
||||
do (funcall check type))
|
||||
;; change level: 1 to 6
|
||||
(loop for level from 1 to 6
|
||||
(cl-loop for level from 1 to 6
|
||||
do (funcall check "heading" level))
|
||||
;; back to code
|
||||
(funcall check "code")
|
||||
|
@ -457,12 +457,12 @@ NO-TRIM is passed to `ein:notebook-split-cell-at-point'."
|
|||
|
||||
(ert-deftest ein:notebook-goto-next-input-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(loop for i downfrom 2 to 0
|
||||
(cl-loop for i downfrom 2 to 0
|
||||
do (call-interactively #'ein:worksheet-insert-cell-above)
|
||||
do (insert (format "Cell %s" i)))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
;; (message "%s" (buffer-string))
|
||||
(loop for i from 0 below 2
|
||||
(cl-loop for i from 0 below 2
|
||||
do (beginning-of-line) ; This is required, I need to check why
|
||||
do (should (looking-at (format "Cell %s" i)))
|
||||
do (call-interactively #'ein:worksheet-goto-next-input)
|
||||
|
@ -470,12 +470,12 @@ NO-TRIM is passed to `ein:notebook-split-cell-at-point'."
|
|||
|
||||
(ert-deftest ein:notebook-goto-prev-input-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(loop for i from 0 below 3
|
||||
(cl-loop for i from 0 below 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-below)
|
||||
do (insert (format "Cell %s" i)))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) 3))
|
||||
;; (message "%s" (buffer-string))
|
||||
(loop for i downfrom 2 to 1
|
||||
(cl-loop for i downfrom 2 to 1
|
||||
do (beginning-of-line) ; This is required, I need to check why
|
||||
do (should (looking-at (format "Cell %s" i)))
|
||||
do (call-interactively #'ein:worksheet-goto-prev-input)
|
||||
|
@ -614,12 +614,12 @@ NO-TRIM is passed to `ein:notebook-split-cell-at-point'."
|
|||
|
||||
(ert-deftest ein:notebook-move-cell-up-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(loop for i from 0 below 3
|
||||
(cl-loop for i from 0 below 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-below)
|
||||
do (insert (format "Cell %s" i)))
|
||||
(beginning-of-line)
|
||||
(should (looking-at "Cell 2"))
|
||||
(loop repeat 2
|
||||
(cl-loop repeat 2
|
||||
do (call-interactively #'ein:worksheet-move-cell-up))
|
||||
;; (message "%s" (buffer-string))
|
||||
(beginning-of-line)
|
||||
|
@ -630,10 +630,10 @@ NO-TRIM is passed to `ein:notebook-split-cell-at-point'."
|
|||
|
||||
(ert-deftest ein:notebook-move-cell-down-command-simple ()
|
||||
(with-current-buffer (ein:testing-notebook-make-empty)
|
||||
(loop for i from 0 below 3
|
||||
(cl-loop for i from 0 below 3
|
||||
do (call-interactively #'ein:worksheet-insert-cell-above)
|
||||
do (insert (format "Cell %s" i)))
|
||||
(loop repeat 2
|
||||
(cl-loop repeat 2
|
||||
do (call-interactively #'ein:worksheet-move-cell-down))
|
||||
(beginning-of-line)
|
||||
(should (looking-at "Cell 2"))
|
||||
|
@ -654,7 +654,7 @@ NO-TRIM is passed to `ein:notebook-split-cell-at-point'."
|
|||
(should-not (oref cell :collapsed)))))
|
||||
|
||||
(defun ein:testing-insert-cells (list-type-or-cell &optional pivot callback)
|
||||
(loop with ws = ein:%worksheet%
|
||||
(cl-loop with ws = ein:%worksheet%
|
||||
with cell = pivot
|
||||
for type in list-type-or-cell
|
||||
for i from 0
|
||||
|
@ -665,7 +665,7 @@ NO-TRIM is passed to `ein:notebook-split-cell-at-point'."
|
|||
(defun* ein:testing-insert-cells-with-format (num &optional
|
||||
(format "Cell %s")
|
||||
(type 'code))
|
||||
(ein:testing-insert-cells (loop repeat num collect type)
|
||||
(ein:testing-insert-cells (cl-loop repeat num collect type)
|
||||
nil
|
||||
(lambda (i &rest _) (insert (format format i))))
|
||||
(should (equal (ein:worksheet-ncells ein:%worksheet%) num)))
|
||||
|
@ -1122,7 +1122,7 @@ In [ ]:
|
|||
(let* ((text "print 'Hello World\\n' * 10")
|
||||
(next-text "something")
|
||||
(output-text
|
||||
(apply #'concat (loop repeat 10 collect "Hello World\n")))
|
||||
(apply #'concat (cl-loop repeat 10 collect "Hello World\n")))
|
||||
(cell (ein:worksheet-get-current-cell))
|
||||
(next-cell (ein:cell-next cell))
|
||||
(kernel (ein:$notebook-kernel ein:%notebook%))
|
||||
|
|
|
@ -72,11 +72,11 @@
|
|||
(mapc (lambda (s) (should (gethash s callbacks))) event-symbols)
|
||||
(should (= (hash-table-count callbacks) (length event-symbols)))
|
||||
(should (equal (oref kernel :status) nil))
|
||||
(loop for et in (mapcar #'car (oref kernel :s2m))
|
||||
(cl-loop for et in (mapcar #'car (oref kernel :s2m))
|
||||
do (ein:events-trigger events et)
|
||||
do (should (equal (oref kernel :status) et))
|
||||
do (should (equal (oref notebook :status) nil)))
|
||||
(loop for et in (mapcar #'car (oref notebook :s2m))
|
||||
(cl-loop for et in (mapcar #'car (oref notebook :s2m))
|
||||
do (ein:events-trigger events et)
|
||||
do (should (equal (oref kernel :status) 'status_disconnected.Kernel))
|
||||
do (should (equal (oref notebook :status) et)))))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
(defmacro ein:testing-insert-html--fix-urls-deftests (args-list)
|
||||
`(progn
|
||||
,@(loop for i from 0
|
||||
,@(cl-loop for i from 0
|
||||
for args in args-list
|
||||
for test = (intern (format "ein:insert-html--fix-urls/%s" i))
|
||||
collect
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
(should (equal (ein:url "datasci-1" "foo" "bar") "https://datasci-1/foo/bar"))
|
||||
(should (equal (ein:glom-paths "" nil "Untitled1.ipynb") "Untitled1.ipynb"))
|
||||
(should (equal (ein:glom-paths) ""))
|
||||
(loop for url in '("http://127.0.0.1:8888" "http://localhost:8888" "http://127.0.0.1:8888/" "http://localhost:8888/" "8888" 8888)
|
||||
(cl-loop for url in '("http://127.0.0.1:8888" "http://localhost:8888" "http://127.0.0.1:8888/" "http://localhost:8888/" "8888" 8888)
|
||||
do (should (equal (ein:url "http://localhost:8888") (ein:url url)))))
|
||||
|
||||
(ert-deftest ein-url-slashes ()
|
||||
(loop for a in '("a" "a/" "/a")
|
||||
do (loop for b in '("b" "/b")
|
||||
(cl-loop for a in '("a" "a/" "/a")
|
||||
do (cl-loop for b in '("b" "/b")
|
||||
do (should (equal (ein:url 8888 a b)
|
||||
"http://127.0.0.1:8888/a/b")))
|
||||
do (should (equal (ein:url 8888 a "b/")
|
||||
|
@ -99,7 +99,7 @@ def func():
|
|||
;;; Text manipulation on buffer
|
||||
|
||||
(ert-deftest ein:find-leftmot-column-simple-cases ()
|
||||
(loop for (indent text) in
|
||||
(cl-loop for (indent text) in
|
||||
'(;; No indent
|
||||
(0 "\
|
||||
def f():
|
||||
|
|
Loading…
Add table
Reference in a new issue