mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 09:01:40 -05:00
ein-completer: Use entire cell/buffer for completion context.
The modern Jupyter messaging spec (> 5.0) simplified `complete_request` to allow sending blocks of text as completion context. EIN now takes advantage of this by sending the entire contents of the worksheet cell, when in a notebook buffer, or, when in a non-notebook buffer, the entire contents of the buffer. This allows backends like jedi to do better context-sensitive completion without having to execute code. In general this should improve completion behavior, though may result in an initial performance hit when working in large buffers while EIN builds the oinfo cache. Note that oinfo (i.e., function call signatures) will not be available until code in the buffer/cell is executed.
This commit is contained in:
parent
91b7375dbf
commit
3aa68f2a00
1 changed files with 17 additions and 4 deletions
|
@ -81,10 +81,23 @@
|
|||
(list :complete_reply
|
||||
(cons #'ein:completer-finish-completing '(:expand nil)))
|
||||
#'ignore))
|
||||
(ein:kernel-complete kernel
|
||||
(thing-at-point 'line)
|
||||
(current-column)
|
||||
callbacks errback))
|
||||
(multiple-value-bind (code pos) (ein:get-completion-context (ein:$kernel-api-version kernel))
|
||||
(ein:log 'debug (format "EIN:COMPLETER-COMPLETE Code block: %s at position :%s" code pos))
|
||||
(ein:kernel-complete kernel
|
||||
code ;; (thing-at-point 'line)
|
||||
pos ;; (current-column)
|
||||
callbacks errback)))
|
||||
|
||||
(defun ein:get-completion-context (api-version)
|
||||
(cond ((< api-version 5)
|
||||
(values (thing-at-point 'line) (current-column)))
|
||||
((and (ein:get-kernel) (ein:get-cell-at-point))
|
||||
(let* ((cell (ein:get-cell-at-point))
|
||||
(code (ein:cell-get-text cell))
|
||||
(beg (ein:cell-input-pos-min cell)))
|
||||
(values code (- (point) beg))))
|
||||
((ein:get-kernel)
|
||||
(values (buffer-string) (1- (point))))))
|
||||
|
||||
;;; Retrieving Python Object Info
|
||||
(defun ein:completions--reset-oinfo-cache (kernel)
|
||||
|
|
Loading…
Add table
Reference in a new issue