mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-06 09:31:39 -05:00
Use generic getters in ein-pytools.el
This commit is contained in:
parent
f510e8d50f
commit
73cadcaaa4
3 changed files with 7 additions and 28 deletions
|
@ -89,7 +89,7 @@ This is called via `ac-next'/`ac-previous'/`ac-update' and set
|
||||||
replied within `ac-quick-help-delay' seconds, auto-complete will
|
replied within `ac-quick-help-delay' seconds, auto-complete will
|
||||||
popup help string."
|
popup help string."
|
||||||
(let* ((candidate (ac-selected-candidate))
|
(let* ((candidate (ac-selected-candidate))
|
||||||
(kernel (ein:pytools-get-kernel))
|
(kernel (ein:get-kernel))
|
||||||
(callbacks (list :object_info_reply
|
(callbacks (list :object_info_reply
|
||||||
(cons #'ein:ac-set-document candidate))))
|
(cons #'ein:ac-set-document candidate))))
|
||||||
(when (and candidate
|
(when (and candidate
|
||||||
|
|
|
@ -113,7 +113,7 @@ To suppress popup, you can pass a function `ein:do-nothing' as CALLBACK."
|
||||||
(defun ein:notebooklist-ask-url-or-port ()
|
(defun ein:notebooklist-ask-url-or-port ()
|
||||||
(let* ((url-or-port-list (mapcar (lambda (x) (format "%s" x))
|
(let* ((url-or-port-list (mapcar (lambda (x) (format "%s" x))
|
||||||
ein:url-or-port))
|
ein:url-or-port))
|
||||||
(default (format "%s" (ein:aif (ein:pytools-get-notebook)
|
(default (format "%s" (ein:aif (ein:get-notebook)
|
||||||
(ein:$notebook-url-or-port it)
|
(ein:$notebook-url-or-port it)
|
||||||
(ein:aif ein:notebooklist
|
(ein:aif ein:notebooklist
|
||||||
(ein:$notebooklist-url-or-port it)
|
(ein:$notebooklist-url-or-port it)
|
||||||
|
|
|
@ -34,12 +34,7 @@
|
||||||
(require 'ein-kernel)
|
(require 'ein-kernel)
|
||||||
(require 'ein-shared-output)
|
(require 'ein-shared-output)
|
||||||
|
|
||||||
(eval-when-compile (defvar ein:notebook)
|
(eval-when-compile (defvar ein:@connect))
|
||||||
(defvar ein:@connect))
|
|
||||||
(declare-function ein:$notebook-kernel "ein-notebook")
|
|
||||||
(declare-function ein:notebook-buffer "ein-notebook")
|
|
||||||
(declare-function ein:connect-get-kernel "ein-connect")
|
|
||||||
(declare-function ein:connect-get-notebook "ein-connect")
|
|
||||||
(declare-function ein:connect-to-notebook-buffer "ein-connect")
|
(declare-function ein:connect-to-notebook-buffer "ein-connect")
|
||||||
|
|
||||||
(defun ein:goto-file (filename lineno &optional other-window)
|
(defun ein:goto-file (filename lineno &optional other-window)
|
||||||
|
@ -60,22 +55,6 @@ If OTHER-WINDOW is non-`nil', open the file in the other window."
|
||||||
(const :tag "No" nil))
|
(const :tag "No" nil))
|
||||||
:group 'ein)
|
:group 'ein)
|
||||||
|
|
||||||
(defun ein:pytools-get-kernel ()
|
|
||||||
(require 'ein-connect)
|
|
||||||
(cond
|
|
||||||
(ein:notebook (ein:$notebook-kernel ein:notebook))
|
|
||||||
(ein:@connect (ein:connect-get-kernel))
|
|
||||||
((eq major-mode 'ein:shared-output-mode) (ein:shared-output-get-kernel))))
|
|
||||||
|
|
||||||
(defun ein:pytools-get-notebook ()
|
|
||||||
(require 'ein-connect)
|
|
||||||
(cond
|
|
||||||
(ein:notebook ein:notebook)
|
|
||||||
(ein:@connect (ein:connect-get-notebook))))
|
|
||||||
|
|
||||||
(defun ein:pytools-get-notebook-buffer ()
|
|
||||||
(ein:aand (ein:pytools-get-notebook) (ein:notebook-buffer it)))
|
|
||||||
|
|
||||||
(defun ein:pytools-setup-hooks (kernel)
|
(defun ein:pytools-setup-hooks (kernel)
|
||||||
(push (cons #'ein:pytools-add-sys-path kernel)
|
(push (cons #'ein:pytools-add-sys-path kernel)
|
||||||
(ein:$kernel-after-start-hook kernel)))
|
(ein:$kernel-after-start-hook kernel)))
|
||||||
|
@ -140,13 +119,13 @@ When the prefix argument ``C-u`` is given, open the source code
|
||||||
in the other window. You can explicitly specify the object by
|
in the other window. You can explicitly specify the object by
|
||||||
selecting it."
|
selecting it."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((kernel (ein:pytools-get-kernel))
|
(let ((kernel (ein:get-kernel))
|
||||||
(object (ein:object-at-point)))
|
(object (ein:object-at-point)))
|
||||||
(assert (ein:kernel-live-p kernel) nil "Kernel is not ready.")
|
(assert (ein:kernel-live-p kernel) nil "Kernel is not ready.")
|
||||||
(assert object nil "Object at point not found.")
|
(assert object nil "Object at point not found.")
|
||||||
(ein:pytools-jump-to-source kernel object other-window
|
(ein:pytools-jump-to-source kernel object other-window
|
||||||
(when ein:propagate-connect
|
(when ein:propagate-connect
|
||||||
(ein:pytools-get-notebook-buffer)))))
|
(ein:get-notebook-buffer)))))
|
||||||
|
|
||||||
(defun ein:pytools-jump-back-command (&optional other-window)
|
(defun ein:pytools-jump-back-command (&optional other-window)
|
||||||
"Go back to the point where `ein:pytools-jump-to-source-command'
|
"Go back to the point where `ein:pytools-jump-to-source-command'
|
||||||
|
@ -162,7 +141,7 @@ given, open the last point in the other window."
|
||||||
|
|
||||||
(defun ein:pytools-eval-string-internal (code &optional popup)
|
(defun ein:pytools-eval-string-internal (code &optional popup)
|
||||||
(let ((cell (ein:shared-output-get-cell))
|
(let ((cell (ein:shared-output-get-cell))
|
||||||
(kernel (ein:pytools-get-kernel))
|
(kernel (ein:get-kernel))
|
||||||
(code (ein:trim-indent code)))
|
(code (ein:trim-indent code)))
|
||||||
(ein:cell-execute cell kernel code popup)))
|
(ein:cell-execute cell kernel code popup)))
|
||||||
|
|
||||||
|
@ -208,7 +187,7 @@ to install it if you are using newer Emacs.
|
||||||
(generate-new-buffer-name "*ein:ses pandas*"))))
|
(generate-new-buffer-name "*ein:ses pandas*"))))
|
||||||
;; fetch TSV (tab separated values) via stdout
|
;; fetch TSV (tab separated values) via stdout
|
||||||
(ein:kernel-request-stream
|
(ein:kernel-request-stream
|
||||||
(ein:pytools-get-kernel)
|
(ein:get-kernel)
|
||||||
(concat dataframe ".to_csv(__import__('sys').stdout, sep='\\t')")
|
(concat dataframe ".to_csv(__import__('sys').stdout, sep='\\t')")
|
||||||
(lambda (tsv buffer)
|
(lambda (tsv buffer)
|
||||||
(with-current-buffer buffer
|
(with-current-buffer buffer
|
||||||
|
|
Loading…
Add table
Reference in a new issue