mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 09:01:40 -05:00
Minimally functional company-mode support.
There is now a company mode backend for ein. It generates completions by sending complete_request to the running kernel so for the moment no jedi integration. Configuring is maybe non-obvious - user should at minimum set `ein:use-auto-complete` and `ein:use-auto-complete-superpack` to nil. Adding a `(require 'ein-company)` probably should be done somewhere in the user's init file. This could all be done better so I will attempt to address in later commits.
This commit is contained in:
parent
63b064cc33
commit
d13e85b370
5 changed files with 13 additions and 10 deletions
1
Cask
1
Cask
|
@ -8,6 +8,7 @@
|
|||
(development
|
||||
(depends-on "websocket")
|
||||
(depends-on "request")
|
||||
(depends-on "dash")
|
||||
(depends-on "cl-generic")
|
||||
(depends-on "ecukes")
|
||||
(depends-on "mocker")
|
||||
|
|
|
@ -39,13 +39,6 @@
|
|||
(default-value 'ac-sources))
|
||||
"Extra `ac-sources' used in notebook.")
|
||||
|
||||
(make-obsolete-variable 'ein:ac-max-cache nil "0.1.2")
|
||||
(defcustom ein:ac-max-cache 1000
|
||||
"[This value is not used anymore!]
|
||||
Maximum number of cache to store."
|
||||
:type 'integer
|
||||
:group 'ein)
|
||||
|
||||
|
||||
;;; Chunk (adapted from auto-complete-chunk.el)
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
(interactive (list 'interactive))
|
||||
(cl-case command
|
||||
(interactive (company-begin-backend 'ein:company-backend) )
|
||||
(prefix (and (--filter (and (boundp it) (symbol-value it)) minor-mode-list)
|
||||
(prefix (and (--filter (and (boundp it) (symbol-value it) (eql it 'ein:notebook-minor-mode))
|
||||
minor-mode-list)
|
||||
(thing-at-point 'line)))
|
||||
(candidates () (lexical-let ((kernel (ein:get-kernel-or-error))
|
||||
(arg arg)
|
||||
|
@ -56,7 +57,11 @@
|
|||
(matched-text (buffer-substring beg (- beg delta)))
|
||||
(matches (plist-get content :matches)))
|
||||
(ein:log 'debug "EIN:COMPANY-FINISH-COMPLETING: matches=%s" matches)
|
||||
(funcall callback matches)))
|
||||
(condition-case err
|
||||
(funcall (car callback) matches)
|
||||
(error (error (format "Error %s running ein company completer." err))))))
|
||||
|
||||
(add-to-list 'company-backends #'ein:company-backend)
|
||||
|
||||
(setq ein:complete-on-dot nil)
|
||||
|
||||
|
|
|
@ -109,12 +109,15 @@
|
|||
:date (format-time-string "%Y-%m-%dT%T" (current-time)) ; ISO 8601 timestamp
|
||||
:msg_type msg-type)
|
||||
:metadata (make-hash-table)
|
||||
|
||||
:content content
|
||||
:parent_header (make-hash-table)))
|
||||
|
||||
|
||||
(defun ein:kernel-start (kernel notebook)
|
||||
"Start kernel of the notebook whose id is NOTEBOOK-ID."
|
||||
(assert (and (ein:$notebook-p notebook)
|
||||
(ein:$kernel-p kernel)))
|
||||
(unless (ein:$kernel-running kernel)
|
||||
(if (= (ein:$kernel-api-version kernel) 2)
|
||||
(let ((path (substring (ein:$notebook-notebook-path notebook)
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
"Emacs IPython Notebook"
|
||||
'((websocket "1.7")
|
||||
(request "0.3")
|
||||
(cl-generic "0.3")))
|
||||
(cl-generic "0.3")
|
||||
(dash "2.13.0")))
|
||||
|
|
Loading…
Add table
Reference in a new issue