Upgrade packages
This commit is contained in:
parent
923c632023
commit
8983461043
389 changed files with 222 additions and 448 deletions
|
@ -1623,7 +1623,7 @@
|
|||
(:maintainer "Toby Cubitt" . "toby-predictive@dr-qubit.org")
|
||||
(:url . "http://www.dr-qubit.org/emacs.php"))])
|
||||
(rainbow-mode .
|
||||
[(1 0 3)
|
||||
[(1 0 4)
|
||||
nil "Colorize color names in buffers" single
|
||||
((:url . "http://elpa.gnu.org/packages/rainbow-mode.html")
|
||||
(:keywords "faces")
|
||||
|
@ -2046,7 +2046,7 @@
|
|||
("Oleh Krehel" . "ohwoeowho@gmail.com"))
|
||||
(:keywords "convenience"))])
|
||||
(tramp .
|
||||
[(2 4 3 2)
|
||||
[(2 4 3 3)
|
||||
((emacs
|
||||
(24 4)))
|
||||
"Transparent Remote Access, Multiple Protocol" tar
|
||||
|
|
|
@ -1,352 +0,0 @@
|
|||
;;; ein-connect.el --- Connect external buffers to IPython -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012- Takafumi Arakaki
|
||||
|
||||
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; ein-connect.el is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; ein-connect.el is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with ein-connect.el. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; FIXME: There is a problem when connected notebook is closed.
|
||||
;; This can be fixed in some ways:
|
||||
;; * Turn off ein:connect when the command that uses kernel is invoked
|
||||
;; but corresponding notebook was closed already.
|
||||
;; * Connect directly to ein:kernel and make its destructor to care
|
||||
;; about connecting buffers.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'eieio)
|
||||
(require 'anaphora)
|
||||
(require 'ein-notebook)
|
||||
|
||||
(defun ein:maybe-save-buffer (option)
|
||||
"Conditionally save current buffer.
|
||||
Return `t' if the buffer is unmodified or `nil' otherwise.
|
||||
If the buffer is modified, buffer is saved depending on the value
|
||||
of OPTION:
|
||||
ask : Ask whether the buffer should be saved.
|
||||
yes : Save buffer always.
|
||||
no : Do not save buffer."
|
||||
(if (not (buffer-modified-p))
|
||||
t
|
||||
(cl-case option
|
||||
(ask (when (y-or-n-p "Save buffer? ")
|
||||
(save-buffer)
|
||||
t))
|
||||
(yes (save-buffer)
|
||||
t)
|
||||
(t nil))))
|
||||
|
||||
|
||||
;;; Configuration
|
||||
|
||||
(defcustom ein:connect-run-command "%run"
|
||||
"``%run`` magic command used for `ein:connect-run-buffer'.
|
||||
Types same as `ein:console-security-dir' are valid."
|
||||
:type '(choice
|
||||
(string :tag "command" "%run")
|
||||
(alist :tag "command mapping"
|
||||
:key-type (choice :tag "URL or PORT"
|
||||
(string :tag "URL" "http://127.0.0.1:8888")
|
||||
(integer :tag "PORT" 8888)
|
||||
(const default))
|
||||
:value-type (string :tag "command" "%run"))
|
||||
(function :tag "command getter"
|
||||
(lambda (url-or-port) (format "%%run -n -i -t -d"))))
|
||||
:group 'ein)
|
||||
|
||||
(defcustom ein:connect-reload-command "%run -n"
|
||||
"Setting for `ein:connect-reload-buffer'.
|
||||
Same as `ein:connect-run-command'."
|
||||
:type '(choice
|
||||
(string :tag "command" "%run")
|
||||
(alist :tag "command mapping"
|
||||
:key-type (choice :tag "URL or PORT"
|
||||
(string :tag "URL" "http://127.0.0.1:8888")
|
||||
(integer :tag "PORT" 8888)
|
||||
(const default))
|
||||
:value-type (string :tag "command" "%run"))
|
||||
(function :tag "command getter"
|
||||
(lambda (url-or-port) (format "%%run -n -i -t -d"))))
|
||||
:group 'ein)
|
||||
|
||||
(defun ein:connect-run-command-get ()
|
||||
(ein:choose-setting 'ein:connect-run-command
|
||||
(ein:$notebook-url-or-port (ein:connect-get-notebook))))
|
||||
|
||||
(defcustom ein:connect-save-before-run 'yes
|
||||
"Whether the buffer should be saved before `ein:connect-run-buffer'."
|
||||
:type '(choice (const :tag "Always save buffer" yes)
|
||||
(const :tag "Always do not save buffer" no)
|
||||
(const :tag "Ask" ask))
|
||||
:group 'ein)
|
||||
|
||||
(defcustom ein:connect-aotoexec-lighter nil
|
||||
"String appended to the lighter of `ein:connect-mode' (`ein:c')
|
||||
when auto-execution mode is on. When `nil', use the same string
|
||||
as `ein:cell-autoexec-prompt'."
|
||||
:type '(choice (string :tag "String appended to ein:c" "@")
|
||||
(const :tag "Use `ein:cell-autoexec-prompt'." nil))
|
||||
:group 'ein)
|
||||
|
||||
(defcustom ein:connect-default-notebook nil
|
||||
"Notebook to be connect when `ein:connect-to-default-notebook' is called.
|
||||
|
||||
Example setting to connect to \"My_Notebook\" in the server at
|
||||
port 8888 when opening any buffer in `python-mode'::
|
||||
|
||||
(setq ein:connect-default-notebook \"8888/My_Notebook\")
|
||||
(add-hook 'python-mode-hook 'ein:connect-to-default-notebook)
|
||||
|
||||
`ein:connect-default-notebook' can also be a function without any
|
||||
argument. This function must return a string (notebook path of
|
||||
the form \"URL-OR-PORT/NOTEBOOK-NAME\").
|
||||
|
||||
As `ein:connect-to-default-notebook' requires notebook list to be
|
||||
loaded, consider using `ein:notebooklist-load' to load notebook
|
||||
list if you want to connect to notebook without manually opening
|
||||
notebook list."
|
||||
:type '(choice (string :tag "URL-OR-PORT/NOTEBOOK-NAME")
|
||||
(function :tag "Notebook path getter"))
|
||||
:group 'ein)
|
||||
|
||||
|
||||
;;; Class
|
||||
|
||||
(ein:deflocal ein:%connect% nil
|
||||
"Buffer local variable to store an instance of `ein:connect'")
|
||||
(define-obsolete-variable-alias 'ein:@connect 'ein:%connect% "0.1.2")
|
||||
|
||||
(defclass ein:connect ()
|
||||
((notebook :initarg :notebook :type ein:$notebook)
|
||||
(buffer :initarg :buffer :type buffer)
|
||||
(autoexec :initarg :autoexec :initform nil :type boolean
|
||||
:document "Auto-execution mode flag.
|
||||
|
||||
See also the document of the `autoexec' slot of `ein:codecell'
|
||||
class.")))
|
||||
|
||||
(defun ein:connect-setup (notebook buffer)
|
||||
(with-current-buffer buffer
|
||||
(setq ein:%connect%
|
||||
(ein:connect :notebook notebook :buffer buffer))
|
||||
ein:%connect%))
|
||||
|
||||
|
||||
;;; Methods
|
||||
|
||||
;; FIXME: Clarify names of these `connect-to-*' functions:
|
||||
|
||||
;;;###autoload
|
||||
(defun ein:connect-to-notebook-command (&optional not-yet-opened)
|
||||
"Connect to notebook. When the prefix argument is given,
|
||||
you can choose any notebook on your server including the ones
|
||||
not yet opened. Otherwise, already chose from already opened
|
||||
notebooks."
|
||||
(interactive "P")
|
||||
(call-interactively (if not-yet-opened
|
||||
#'ein:connect-to-notebook
|
||||
#'ein:connect-to-notebook-buffer)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ein:connect-to-notebook (nbpath &optional buffer no-reconnection)
|
||||
"Connect any buffer to notebook and its kernel."
|
||||
(interactive (list (ein:notebooklist-ask-path "notebook")))
|
||||
(cl-multiple-value-bind (url-or-port path) (ein:notebooklist-parse-nbpath nbpath)
|
||||
(ein:notebook-open url-or-port path nil
|
||||
(apply-partially
|
||||
(lambda (buffer* no-reconnection* notebook _created)
|
||||
(ein:connect-buffer-to-notebook notebook buffer* no-reconnection*))
|
||||
(or buffer (current-buffer)) no-reconnection))))
|
||||
|
||||
;;;###autoload
|
||||
(defun ein:connect-to-notebook-buffer (buffer-or-name)
|
||||
"Connect any buffer to opened notebook and its kernel."
|
||||
(interactive (list (ein:completing-read "Notebook buffer to connect: "
|
||||
(ein:notebook-opened-buffer-names))))
|
||||
(aif (get-buffer buffer-or-name)
|
||||
(let ((notebook (buffer-local-value 'ein:%notebook% it)))
|
||||
(ein:connect-buffer-to-notebook notebook))
|
||||
(error "No buffer %s" buffer-or-name)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ein:connect-buffer-to-notebook (notebook &optional buffer
|
||||
no-reconnection)
|
||||
"Connect BUFFER to NOTEBOOK."
|
||||
(unless buffer
|
||||
(setq buffer (current-buffer)))
|
||||
(with-current-buffer buffer
|
||||
(if (or (not no-reconnection)
|
||||
(not ein:%connect%))
|
||||
(let ((connection (ein:connect-setup notebook buffer)))
|
||||
(ein:connect-mode)
|
||||
(ein:log 'info "Connected to %s"
|
||||
(ein:$notebook-notebook-name notebook))
|
||||
connection)
|
||||
(ein:log 'info "Buffer is already connected to notebook."))))
|
||||
|
||||
(defun ein:connect-get-notebook ()
|
||||
(slot-value ein:%connect% 'notebook))
|
||||
|
||||
(defun ein:connect-get-kernel ()
|
||||
(ein:$notebook-kernel (ein:connect-get-notebook)))
|
||||
|
||||
(defun ein:connect-eval-buffer ()
|
||||
"Evaluate the whole buffer. Note that this will run the code
|
||||
inside the ``if __name__ == \"__main__\":`` block."
|
||||
(interactive)
|
||||
(let ((b (current-buffer)))
|
||||
(deferred:$
|
||||
(deferred:next
|
||||
(lambda ()
|
||||
(with-current-buffer b
|
||||
(ein:shared-output-eval-string (ein:connect-get-kernel) (buffer-string) :silent t))))))
|
||||
(ein:log 'info "Whole buffer is sent to the kernel."))
|
||||
|
||||
(defun ein:connect-run-buffer (&optional ask-command)
|
||||
"Run buffer using ``%run``. Ask for command if the prefix ``C-u`` is given.
|
||||
Variable `ein:connect-run-command' sets the default command."
|
||||
(interactive "P")
|
||||
(aif (ein:aand (ein:get-url-or-port)
|
||||
(ein:filename-to-python it (buffer-file-name)))
|
||||
(let* ((default-command (ein:connect-run-command-get))
|
||||
(command (if ask-command
|
||||
(read-from-minibuffer "Command: " default-command)
|
||||
default-command))
|
||||
(cmd (format "%s \"%s\"" command it)))
|
||||
(if (ein:maybe-save-buffer ein:connect-save-before-run)
|
||||
(progn
|
||||
(ein:shared-output-eval-string (ein:connect-get-kernel) cmd nil :silent t)
|
||||
(ein:log 'info "Command sent to the kernel: %s" cmd))
|
||||
(ein:log 'info "Buffer must be saved before %%run.")))
|
||||
(error (concat "This buffer has no associated file. "
|
||||
"Use `ein:connect-eval-buffer' instead."))))
|
||||
|
||||
(defun ein:connect-run-or-eval-buffer (&optional eval)
|
||||
"Run buffer using the ``%run`` magic command or eval whole
|
||||
buffer if the prefix ``C-u`` is given.
|
||||
Variable `ein:connect-run-command' sets the command to run.
|
||||
You can change the command and/or set the options.
|
||||
See also: `ein:connect-run-buffer', `ein:connect-eval-buffer'."
|
||||
(interactive "P")
|
||||
(if eval
|
||||
(ein:connect-eval-buffer)
|
||||
(ein:connect-run-buffer)))
|
||||
|
||||
(defun ein:connect-reload-buffer ()
|
||||
"Reload buffer using the command set by `ein:connect-reload-command'."
|
||||
(interactive)
|
||||
(let ((ein:connect-run-command ein:connect-reload-command))
|
||||
(call-interactively #'ein:connect-run-buffer)))
|
||||
|
||||
(defun ein:connect-eval-region (start end)
|
||||
(interactive "r")
|
||||
(ein:shared-output-eval-string (ein:connect-get-kernel) (buffer-substring start end) nil)
|
||||
(ein:log 'info "Selected region is sent to the kernel."))
|
||||
|
||||
(define-obsolete-function-alias
|
||||
'ein:connect-eval-string-internal
|
||||
'ein:shared-output-eval-string "0.1.2")
|
||||
|
||||
(define-obsolete-function-alias
|
||||
'ein:connect-request-tool-tip-or-help-command
|
||||
'ein:pytools-request-tooltip-or-help "0.1.2")
|
||||
|
||||
(defun ein:connect-pop-to-notebook ()
|
||||
(interactive)
|
||||
(ein:connect-assert-connected)
|
||||
(pop-to-buffer (ein:notebook-buffer (ein:connect-get-notebook))))
|
||||
|
||||
|
||||
;;; Generic getter
|
||||
|
||||
(defun ein:get-url-or-port--connect ()
|
||||
(ein:aand (ein:get-notebook--connect) (ein:$notebook-url-or-port it)))
|
||||
|
||||
(defun ein:get-notebook--connect ()
|
||||
(when (ein:connect-p ein:%connect%)
|
||||
(slot-value ein:%connect% 'notebook)))
|
||||
|
||||
(defun ein:get-kernel--connect ()
|
||||
(ein:aand (ein:get-notebook--connect) (ein:$notebook-kernel it)))
|
||||
|
||||
(defun ein:get-traceback-data--connect ()
|
||||
;; FIXME: Check if the TB in shared-output buffer is originated from
|
||||
;; the current buffer.
|
||||
(ein:aand (ein:shared-output-get-cell) (ein:cell-get-tb-data it)))
|
||||
(autoload 'ein:shared-output-get-cell "ein-shared-output") ; FIXME: Remove!
|
||||
|
||||
|
||||
|
||||
(defun ein:connect-assert-connected ()
|
||||
(cl-assert (ein:connect-p ein:%connect%) nil
|
||||
"Current buffer (%s) is not connected to IPython notebook."
|
||||
(buffer-name))
|
||||
(cl-assert (ein:notebook-live-p (slot-value ein:%connect% 'notebook)) nil
|
||||
"Connected notebook is not live (probably already closed)."))
|
||||
|
||||
|
||||
;;; Auto-connect
|
||||
|
||||
;;;###autoload
|
||||
(defun ein:connect-to-default-notebook ()
|
||||
"Connect to the default notebook specified by
|
||||
`ein:connect-default-notebook'. Set this to `python-mode-hook'
|
||||
to automatically connect any python-mode buffer to the
|
||||
notebook."
|
||||
(ein:log 'verbose "CONNECT-TO-DEFAULT-NOTEBOOK")
|
||||
(ein:and-let* ((nbpath ein:connect-default-notebook)
|
||||
((not (ein:worksheet-buffer-p))))
|
||||
(when (functionp nbpath)
|
||||
(setq nbpath (funcall nbpath)))
|
||||
(ein:connect-to-notebook nbpath nil t)))
|
||||
|
||||
|
||||
|
||||
;;; ein:connect-mode
|
||||
|
||||
(defvar ein:connect-mode-map (make-sparse-keymap))
|
||||
|
||||
(let ((map ein:connect-mode-map))
|
||||
(define-key map "\C-c\C-c" 'ein:connect-run-or-eval-buffer)
|
||||
(define-key map "\C-c\C-l" 'ein:connect-reload-buffer)
|
||||
(define-key map "\C-c\C-r" 'ein:connect-eval-region)
|
||||
(define-key map (kbd "C-:") 'ein:shared-output-eval-string)
|
||||
(define-key map "\C-c\C-z" 'ein:connect-pop-to-notebook)
|
||||
(define-key map "\C-c\C-x" 'ein:tb-show)
|
||||
(define-key map (kbd "C-c C-/") 'ein:notebook-scratchsheet-open)
|
||||
|
||||
map)
|
||||
|
||||
(defun ein:connect-mode-get-lighter ()
|
||||
" ein:c")
|
||||
|
||||
(define-minor-mode ein:connect-mode
|
||||
"Minor mode for communicating with IPython notebook.
|
||||
|
||||
\\{ein:connect-mode-map}"
|
||||
:lighter (:eval (ein:connect-mode-get-lighter))
|
||||
:keymap ein:connect-mode-map
|
||||
:group 'ein)
|
||||
|
||||
(put 'ein:connect-mode 'permanent-local t)
|
||||
|
||||
|
||||
(provide 'ein-connect)
|
||||
|
||||
;;; ein-connect.el ends here
|
Binary file not shown.
Binary file not shown.
|
@ -18,44 +18,6 @@
|
|||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-classes" '("ein:")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-connect" "ein-connect.el" (0 0 0 0))
|
||||
;;; Generated autoloads from ein-connect.el
|
||||
|
||||
(autoload 'ein:connect-to-notebook-command "ein-connect" "\
|
||||
Connect to notebook. When the prefix argument is given,
|
||||
you can choose any notebook on your server including the ones
|
||||
not yet opened. Otherwise, already chose from already opened
|
||||
notebooks.
|
||||
|
||||
\(fn &optional NOT-YET-OPENED)" t nil)
|
||||
|
||||
(autoload 'ein:connect-to-notebook "ein-connect" "\
|
||||
Connect any buffer to notebook and its kernel.
|
||||
|
||||
\(fn NBPATH &optional BUFFER NO-RECONNECTION)" t nil)
|
||||
|
||||
(autoload 'ein:connect-to-notebook-buffer "ein-connect" "\
|
||||
Connect any buffer to opened notebook and its kernel.
|
||||
|
||||
\(fn BUFFER-OR-NAME)" t nil)
|
||||
|
||||
(autoload 'ein:connect-buffer-to-notebook "ein-connect" "\
|
||||
Connect BUFFER to NOTEBOOK.
|
||||
|
||||
\(fn NOTEBOOK &optional BUFFER NO-RECONNECTION)" nil nil)
|
||||
|
||||
(autoload 'ein:connect-to-default-notebook "ein-connect" "\
|
||||
Connect to the default notebook specified by
|
||||
`ein:connect-default-notebook'. Set this to `python-mode-hook'
|
||||
to automatically connect any python-mode buffer to the
|
||||
notebook.
|
||||
|
||||
\(fn)" nil nil)
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-connect" '("ein:")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-contents-api" "ein-contents-api.el" (0
|
||||
|
@ -356,6 +318,14 @@ and the url-or-port argument of ein:notebooklist-open*.
|
|||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-process" '("ein:")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-python-send" "ein-python-send.el" (0 0
|
||||
;;;;;; 0 0))
|
||||
;;; Generated autoloads from ein-python-send.el
|
||||
|
||||
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ein-python-send" '("ein:python-send-")))
|
||||
|
||||
;;;***
|
||||
|
||||
;;;### (autoloads nil "ein-pytools" "ein-pytools.el" (0 0 0 0))
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
;;; Commentary:
|
||||
|
||||
|
||||
;;; Content
|
||||
(require 'eieio)
|
||||
|
||||
|
@ -89,7 +88,6 @@
|
|||
kernel
|
||||
closed-by-client)
|
||||
|
||||
|
||||
;;; Notebook
|
||||
(defstruct ein:$notebook
|
||||
"Hold notebook variables.
|
||||
|
@ -160,7 +158,6 @@
|
|||
api-version)
|
||||
|
||||
|
||||
|
||||
;;; Worksheet
|
||||
(defclass ein:worksheet ()
|
||||
((nbformat :initarg :nbformat :type integer)
|
||||
|
@ -233,7 +230,6 @@
|
|||
after-execute-hook)
|
||||
|
||||
|
||||
|
||||
;;; Cells
|
||||
|
||||
(defclass ein:basecell ()
|
|
@ -49,15 +49,7 @@
|
|||
:type 'integer
|
||||
:group 'ein)
|
||||
|
||||
(defcustom ein:content-query-timeout nil ; (* 60 1000) ;1 min
|
||||
"Query timeout for getting content from Jupyter/IPython notebook.
|
||||
If you cannot open large notebooks because of a timeout error try
|
||||
increasing this value. Setting this value to `nil' means to use
|
||||
global setting. For global setting and more information, see
|
||||
`ein:query-timeout'."
|
||||
:type '(choice (integer :tag "Timeout [ms]" 5000)
|
||||
(const :tag "Use global setting" nil))
|
||||
:group 'ein)
|
||||
(make-obsolete-variable 'ein:content-query-timeout nil "0.17.0")
|
||||
|
||||
(defcustom ein:force-sync nil
|
||||
"When non-nil, force synchronous http requests."
|
||||
|
@ -72,7 +64,6 @@ ERRBACK of arity 1 for the contents."
|
|||
(ein:query-singleton-ajax
|
||||
(ein:notebooklist-url url-or-port path)
|
||||
:type "GET"
|
||||
:timeout ein:content-query-timeout
|
||||
:parser #'ein:json-read
|
||||
:complete (apply-partially #'ein:content-query-contents--complete url-or-port path)
|
||||
:success (apply-partially #'ein:content-query-contents--success url-or-port path callback)
|
Binary file not shown.
|
@ -150,7 +150,6 @@ the source is in git repository) or elpa version."
|
|||
(ein:query-singleton-ajax
|
||||
(ein:url url-or-port "api/kernelspecs")
|
||||
:type "GET"
|
||||
:timeout ein:content-query-timeout
|
||||
:parser 'ein:json-read
|
||||
:complete (apply-partially #'ein:query-kernelspecs--complete url-or-port)
|
||||
:success (apply-partially #'ein:query-kernelspecs--success url-or-port callback)
|
||||
|
@ -226,7 +225,7 @@ the source is in git repository) or elpa version."
|
|||
(setf (gethash url-or-port *ein:notebook-version*) "2.0.0"))
|
||||
(t (ein:log 'warn "notebook version currently unknowable"))))
|
||||
(when callback (funcall callback)))
|
||||
|
||||
|
||||
;;; File name translation (tramp support)
|
||||
|
||||
;; Probably it's better to define `ein:filename-translations-get' as
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -49,6 +49,7 @@
|
|||
(require 'ein-query)
|
||||
(require 'ein-pytools)
|
||||
(require 'ein-traceback)
|
||||
(require 'ein-python-send)
|
||||
|
||||
(autoload 'ob-ein-anonymous-p "ob-ein")
|
||||
|
||||
|
@ -217,7 +218,7 @@ and put last warning in minibuffer."
|
|||
(defun ein:notebook-jump-to-opened-notebook (notebook)
|
||||
"List all opened notebook buffers and switch to one that the user selects."
|
||||
(interactive
|
||||
(list (completing-read "Jump to notebook:" (ein:notebook-opened-buffer-names) nil t)))
|
||||
(list (completing-read "Jump to notebook:" (ein:notebook-opened-buffer-names) nil t)))
|
||||
(switch-to-buffer notebook))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -1068,9 +1069,6 @@ PREDICATE is called with the buffer name for each opened notebook."
|
|||
(seq-filter predicate notebooks)
|
||||
notebooks)))
|
||||
|
||||
|
||||
;;; Generic getter
|
||||
|
||||
(defun ein:get-url-or-port--notebook ()
|
||||
(when ein:%notebook% (ein:$notebook-url-or-port ein:%notebook%)))
|
||||
|
||||
|
@ -1078,9 +1076,6 @@ PREDICATE is called with the buffer name for each opened notebook."
|
|||
(when (ein:$notebook-p ein:%notebook%)
|
||||
(ein:$notebook-kernel ein:%notebook%)))
|
||||
|
||||
|
||||
;;; Predicate
|
||||
|
||||
(defun ein:notebook-live-p (notebook)
|
||||
"Return non-`nil' if NOTEBOOK has live buffer."
|
||||
(buffer-live-p (ein:notebook-buffer notebook)))
|
||||
|
@ -1357,6 +1352,7 @@ the first argument and CBARGS as the rest of arguments."
|
|||
|
||||
(add-hook 'kill-emacs-query-functions 'ein:notebook-close-notebooks t)
|
||||
(add-hook 'kill-buffer-query-functions 'ein:notebook-kill-buffer-query)
|
||||
(ein:python-send--init)
|
||||
|
||||
(provide 'ein-notebook)
|
||||
|
BIN
elpa/ein-20200328.2131/ein-notebook.elc
Normal file
BIN
elpa/ein-20200328.2131/ein-notebook.elc
Normal file
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
(define-package "ein" "20200328.1608" "Emacs IPython Notebook"
|
||||
(define-package "ein" "20200328.2131" "Emacs IPython Notebook"
|
||||
'((emacs "25")
|
||||
(websocket "20190620.338")
|
||||
(anaphora "20180618")
|
160
elpa/ein-20200328.2131/ein-python-send.el
Normal file
160
elpa/ein-20200328.2131/ein-python-send.el
Normal file
|
@ -0,0 +1,160 @@
|
|||
;;; ein-python-send.el --- Ad hoc sending of code fragments to kernel -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2012- The Authors
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
||||
;; ein-python-send.el is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; ein-python-send.el is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with ein-python-send.el. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; python parsing code by authors of elpy (Schaefer et al)
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'ein:get-notebook "ein-notebook")
|
||||
|
||||
(defvar ein:python-send-map)
|
||||
|
||||
(defun ein:python-send--prepare (&optional reset)
|
||||
(cl-assert (boundp 'ein:python-send-map) nil
|
||||
"ein:python-send--prepare: %s not called"
|
||||
"ein:python-send--init")
|
||||
(unless (and (buffer-live-p (current-buffer))
|
||||
(eq major-mode 'python-mode))
|
||||
(error "ein:python-send--prepare: %s is not a python buffer" (buffer-name)))
|
||||
(when (or (not (ein:get-notebook)) reset)
|
||||
(aif (ein:notebook-opened-notebooks)
|
||||
(let ((choice
|
||||
(ein:completing-read
|
||||
"Notebook: "
|
||||
(mapcar (lambda (nb) (ein:$notebook-notebook-name nb)) it))))
|
||||
(setq ein:%notebook% (seq-find
|
||||
(lambda (nb)
|
||||
(string= choice (ein:$notebook-notebook-name nb)))
|
||||
it)))
|
||||
(error "ein:python-send--prepare: No open notebooks"))))
|
||||
|
||||
(defun ein:python-send-region-or-buffer (&optional reset)
|
||||
"Based on `elpy-shell--send-region-or-buffer-internal' by Schaefer et al."
|
||||
(interactive "P")
|
||||
(ein:python-send--prepare reset)
|
||||
(if (use-region-p)
|
||||
(let ((region (python-shell-buffer-substring
|
||||
(region-beginning) (region-end))))
|
||||
(when (string-match "\t" region)
|
||||
(message "Region contained tabs, this might cause weird errors"))
|
||||
;; python-shell-buffer-substring (intentionally?) does not accurately
|
||||
;; respect (region-beginning); it always start on the first character
|
||||
;; of the respective line even if that's before the region beginning
|
||||
;; Here we post-process the output to remove the characters before
|
||||
;; (region-beginning) and the start of the line. The end of the region
|
||||
;; is handled correctly and needs no special treatment.
|
||||
(let* ((bounds (save-excursion
|
||||
(goto-char (region-beginning))
|
||||
(bounds-of-thing-at-point 'line)))
|
||||
(used-part (string-trim
|
||||
(buffer-substring-no-properties
|
||||
(car bounds)
|
||||
(min (cdr bounds) (region-end)))))
|
||||
(relevant-part (string-trim
|
||||
(buffer-substring-no-properties
|
||||
(max (car bounds) (region-beginning))
|
||||
(min (cdr bounds) (region-end))))))
|
||||
(setq region
|
||||
;; replace just first match
|
||||
(replace-regexp-in-string
|
||||
(concat "\\(" (regexp-quote used-part) "\\)\\(?:.*\n?\\)*\\'")
|
||||
relevant-part
|
||||
region t t 1))
|
||||
(ein:shared-output-eval-string (ein:get-kernel) region)))
|
||||
(ein:shared-output-eval-string (ein:get-kernel) (buffer-string)))
|
||||
(if (use-region-p)
|
||||
(progn
|
||||
(goto-char (region-end))
|
||||
(deactivate-mark))
|
||||
(goto-char (point-max))))
|
||||
|
||||
(defun ein:python-send-statement (&optional reset)
|
||||
"Based on `elpy-shell-send-statement' by Schaefer et al."
|
||||
(interactive "P")
|
||||
(ein:python-send--prepare reset)
|
||||
(python-nav-beginning-of-statement)
|
||||
(unless (looking-at "[[:space:]]*$")
|
||||
(let ((beg (save-excursion (beginning-of-line) (point)))
|
||||
(end (progn (ein:python-send--nav-end-of-statement) (point))))
|
||||
(unless (eq beg end)
|
||||
(ein:shared-output-eval-string (ein:get-kernel)
|
||||
(buffer-substring beg end))))))
|
||||
|
||||
(defun ein:python-send--nav-end-of-statement ()
|
||||
"Based on `elpy-shell--nav-end-of-statement' by Schaefer et al."
|
||||
(let ((continue t)
|
||||
p)
|
||||
(while (and (not (eq p (point))) continue)
|
||||
;; is there another block at same indentation level?
|
||||
(setq p (point))
|
||||
(ein:python-send--nav-forward-block)
|
||||
(if (eq p (point))
|
||||
(progn
|
||||
;; nope, go to the end of the block and done
|
||||
(python-nav-end-of-block)
|
||||
(setq continue nil))
|
||||
(unless (eq 0 (string-match-p "\\s-*el\\(?:se:\\|if[^\w]\\)"
|
||||
(thing-at-point 'line)))
|
||||
(forward-line -1)
|
||||
(while (and (or (eq (string-match-p "\\s-*$" (thing-at-point 'line)) 0)
|
||||
(python-info-current-line-comment-p))
|
||||
(not (eq (point) (point-min))))
|
||||
(forward-line -1))
|
||||
(setq continue nil)))))
|
||||
(end-of-line))
|
||||
|
||||
(defun ein:python-send--nav-forward-block ()
|
||||
"Based on `elpy-shell--nav-forward-block' by Schaefer et al.
|
||||
|
||||
Move to the next line indented like point. This will skip over lines and
|
||||
statements with different indentation levels."
|
||||
(interactive "^")
|
||||
(let ((indent (current-column))
|
||||
(start (point))
|
||||
(cur nil))
|
||||
(when (/= (% indent python-indent-offset)
|
||||
0)
|
||||
(setq indent (* (1+ (/ indent python-indent-offset))
|
||||
python-indent-offset)))
|
||||
(python-nav-forward-statement)
|
||||
(while (and (< indent (current-indentation))
|
||||
(not (eobp)))
|
||||
(when (equal (point) cur)
|
||||
(error "Statement does not finish"))
|
||||
(setq cur (point))
|
||||
(python-nav-forward-statement))
|
||||
(when (< (current-indentation)
|
||||
indent)
|
||||
(goto-char start))))
|
||||
|
||||
(defun ein:python-send--init ()
|
||||
(unless (boundp 'ein:python-send-map)
|
||||
(require 'python)
|
||||
(setq ein:python-send-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "e") 'ein:python-send-statement)
|
||||
(define-key map (kbd "r") 'ein:python-send-region-or-buffer)
|
||||
map))
|
||||
(define-key python-mode-map (kbd "C-c C-/") ein:python-send-map)))
|
||||
|
||||
(provide 'ein-python-send)
|
||||
|
||||
;;; ein-python-send.el ends here
|
BIN
elpa/ein-20200328.2131/ein-python-send.elc
Normal file
BIN
elpa/ein-20200328.2131/ein-python-send.elc
Normal file
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
;; -*- lexical-binding: t -*-
|
||||
;;; ein-shared-output.el --- Output buffer for ein-connect.el
|
||||
;;; ein-shared-output.el --- Output buffer for ob-ein and ein-python-send
|
||||
|
||||
;; Copyright (C) 2012- Takafumi Arakaki
|
||||
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
(define-package "elpy" "20200326.2207" "Emacs Python Development Environment"
|
||||
(define-package "elpy" "20200329.1830" "Emacs Python Development Environment"
|
||||
'((company "0.9.2")
|
||||
(emacs "24.4")
|
||||
(highlight-indentation "0.5.0")
|
|
@ -884,16 +884,21 @@ item in another window.\n\n")
|
|||
(insert "\n\n"))
|
||||
|
||||
;; Pip not available in the rpc virtualenv
|
||||
(when (and (elpy-rpc--pip-missing)
|
||||
(not (gethash "jedi_version" config)))
|
||||
(elpy-insert--para
|
||||
"Pip doesn't seem to be installed in the dedicated virtualenv "
|
||||
"created by Elpy (" (elpy-rpc-get-virtualenv-path) "). "
|
||||
"This will prevent some features from working properly"
|
||||
" (completion, documentation, reformatting, ...). "
|
||||
"You can try reinstalling the virtualenv with `elpy-rpc-reinstall-virtualenv'. "
|
||||
"If the problem persists, please report on Elpy's github page."
|
||||
"\n\n"))
|
||||
(when (and
|
||||
(equal elpy-rpc-virtualenv-path 'default)
|
||||
(elpy-rpc--pip-missing))
|
||||
(elpy-insert--para
|
||||
"Pip doesn't seem to be installed in the dedicated virtualenv "
|
||||
"created by Elpy (" (elpy-rpc-get-virtualenv-path) "). "
|
||||
"This may prevent some features from working properly"
|
||||
" (completion, documentation, reformatting, ...). "
|
||||
"You can try reinstalling the virtualenv. "
|
||||
"If the problem persists, please report on Elpy's github page."
|
||||
"\n\n")
|
||||
(widget-create 'elpy-insert--generic-button
|
||||
:button-name "[Reinstall RPC virtualenv]"
|
||||
:function (lambda () (elpy-rpc-reinstall-virtualenv)))
|
||||
(insert "\n\n"))
|
||||
|
||||
;; Requested backend unavailable
|
||||
(when (and (gethash "rpc_python_executable" config)
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue