mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 09:01:40 -05:00
Merge pull request #611 from millejoh/better-completion
ein-completer: Use entire cell/buffer for completion context.
This commit is contained in:
commit
143b6e3a93
4 changed files with 47 additions and 7 deletions
6
Makefile
6
Makefile
|
@ -66,7 +66,7 @@ quick: test-compile test-ob-ein-recurse test-unit
|
|||
test-jupyterhub: test-compile
|
||||
# jupyterhub slightly temperamental with json-readtable-error
|
||||
# seems to be affecting ob-ipython too but probably my bug.. just need to find it
|
||||
-cask exec ecukes --tags @jupyterhub --reporter magnars
|
||||
-cask exec ecukes --tags @jupyterhub,~@complete-ipy7 --reporter magnars
|
||||
|
||||
.PHONY: test
|
||||
test: quick test-int test-poly
|
||||
|
@ -75,12 +75,12 @@ test: quick test-int test-poly
|
|||
test-poly:
|
||||
cask exec ert-runner -L ./lisp -L ./test -l test/testfunc.el test/test-poly.el test/test-func.el
|
||||
cp test/test-poly.el features/support/test-poly.el
|
||||
cask exec ecukes --reporter magnars ; (ret=$$? ; rm -f features/support/test-poly.el && exit $$ret)
|
||||
cask exec ecukes --reporter magnars --tags ~@complete-ipy7 ; (ret=$$? ; rm -f features/support/test-poly.el && exit $$ret)
|
||||
|
||||
.PHONY: test-int
|
||||
test-int:
|
||||
cask exec ert-runner -L ./lisp -L ./test -l test/testfunc.el test/test-func.el
|
||||
cask exec ecukes --reporter magnars --tags ~@poly-complete
|
||||
cask exec ecukes --reporter magnars --tags ~@poly-complete,~@complete-ipy7
|
||||
|
||||
.PHONY: test-unit
|
||||
test-unit:
|
||||
|
|
|
@ -53,6 +53,23 @@ Scenario: company completion
|
|||
Given new python notebook
|
||||
Given I set "ein:completion-backend" to eval "(quote ein:use-none-backend)"
|
||||
|
||||
@complete-ipy7
|
||||
Scenario: company completion without execution
|
||||
Given I set "ein:completion-backend" to eval "(quote ein:use-company-backend)"
|
||||
Given I kill all websocket buffers
|
||||
Given new python notebook
|
||||
And I type "import itertools"
|
||||
And I press "RET"
|
||||
And I type "itertool"
|
||||
And I call "company-complete"
|
||||
Then I should see "itertools"
|
||||
And I type ".chai"
|
||||
And I call "company-complete"
|
||||
Then I should see "itertools.chain"
|
||||
Given I set "ein:completion-backend" to eval "(quote ein:use-ac-backend)"
|
||||
Given new python notebook
|
||||
Given I set "ein:completion-backend" to eval "(quote ein:use-none-backend)"
|
||||
|
||||
@rename
|
||||
Scenario: rename notebook
|
||||
Given new python notebook
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -36,6 +36,16 @@
|
|||
kernel
|
||||
current-payload)
|
||||
|
||||
(defun ein:ipbd ()
|
||||
"Convenience function that will launch the ipython debugger,
|
||||
assuming there is an active kernel associated with the current
|
||||
buffer. For more information see the %debug magic documentation
|
||||
in ipython."
|
||||
(interactive)
|
||||
(ein:shared-output-eval-string (ein:get-kernel)
|
||||
"%debug"
|
||||
nil))
|
||||
|
||||
(defun ein:find-or-create-ipdb-session (kernel &optional buffer)
|
||||
(ein:aif (gethash (ein:$kernel-kernel-id kernel) *ein:ipdb-sessions*)
|
||||
it
|
||||
|
|
Loading…
Add table
Reference in a new issue