Commit graph

133 commits

Author SHA1 Message Date
Federico Beffa
1cab86995a ein:kernel-complete: use ':code' instead of ':line' for api-version 4. 2019-05-29 18:34:09 +02:00
dickmao
1da03d69f6 Stop bug, Image bug
Initial SIGTERM prompts server to dutifully shutdown kernel, but
another SIGTERM necessary to kill server.  Perhaps ipython changed
since the last time I tested this.

Ipython doesn't send a display_data message upon initial plot
request.  This is probably our bug, or is it?  Document this bug in an
ecukes test.

Also enforce emacs version >= 25
2019-04-29 13:15:53 -04:00
dickmao
234cf391f9 Polymode
M-x customize-group RET ein
Toggle Ein:Polymode

Avoid trying to emulate jump-to-definition, eldoc, and autocompletion
functionalities that Elpy will always do better.

Fixes #497 #482 #418
2019-04-02 09:35:17 -04:00
dickmao
dd01c4578c reconnect kernel if necessary under org-ctrl-c-ctrl-c
when `C-c C-c`, reconnect to kernel if it disconnected
2019-02-26 17:58:42 -05:00
Sam Steingold
5ee7ae7d6b last patch was too aggressive 2019-01-16 18:23:39 -05:00
Sam Steingold
48fa153435 Use standard functionality instead of ad hoc functions
(ein:filter identity ...) ---> (delete nil ...)
ein:filter --> seq-filter
hash-vals --> hash-table-values
hash-keys --> hash-table-keys
2019-01-15 11:26:09 -05:00
dickmao
129afa5fb4 Respect cursor_start and cursor_end in matches
The :cursor_start and :cursor_end fields tell us whether we need to
prepend the prefix ourselves.

Fixes #436
2018-12-28 21:14:11 -05:00
dickmao
3c18cda125 reverse hunks 2018-12-11 08:48:40 -05:00
dickmao
bead667ee0 Clean up multilang
Do not assume python... leverage ESS to improve R interaction.
Fix both undo and fontify in the presence of toggling cells (`C-c
C-t`)
Fix and test switching kernels
2018-12-08 21:25:48 -05:00
dickmao
f0984eab55 jupyterhub basic (PAM only)
`ein:login` or `ein:notebooklist-login` is the preferred way to access
jupyterhub, although `ein:jupyterhub-connect` is still autoloaded.
2018-12-04 18:31:44 -05:00
John Miller
e280bb8633 ein-company: Add completion caching, make caching kernel specific. 2018-11-22 09:07:02 -07:00
dickmao
6ca6752319 C-c C-q improved visual feedback
As `ein:notebok-kill-kernel-then-close-cmmand` must wait for the
server to delete the session, the buffer wouldn't disappear right
away, leaving the user nonplussed whether the `C-c C-q` took.  Display
a status message "Ending session" with a modest animation instead.

Also add a "Stop" test for notebooklist.  Sorry about breaking "Stop"
in ee3b0f0
2018-11-10 00:09:44 -05:00
John Miller
6f19d8bf83 Correct typos, make some code more succinct.
Let this be a lesson kids - never program while under the influence of
power antihistamines...
2018-11-09 18:53:40 -06:00
John Miller
573b745509 Reintroduce proper behavior for kernel stop from nblist buffer.
Once upon a time it was possible to stop/delete/kill running kernels from the
notebooklist buffer regardless of whether there were any open notebooks
associated with the kernel session.

Some commmits ago this behavior was changed, and the code has recently required
that there a notebook buffer associated with the active kernel/session exist
before the stop command will proceed. This is incorrect behavior and is
inconsistent with the interface provided by the notebook web browser interface.
Kernels and notebooks are independent entities and should be treated as such in
the code.
2018-11-09 18:27:23 -06:00
dickmao
84fa177a1e When I C-c C-c also C-c C-r if necessary
If user wants to execute cell, and the connection is down,
automatically reconnect, then execute the cell.
2018-11-06 18:36:46 -05:00
dickmao
d7985ffc6b sometimes travis finds bugs 2018-11-04 21:38:20 -06:00
dickmao
7d31fe7f34 fix the osx testing bug 2018-11-04 21:38:20 -06:00
dickmao
ee3b0f095c Follow-up to cleaning up websockets
Renaming of functions with better understanding of reconnects.  Under
the original logic, reconnecting blithely created a new session if
the original no longer existed.  Now it will alert the user when this
happens.

Also hopefully fixes #381 as there was a bug of missing argument not
being caught by lisp's undisciplined typing.
2018-11-04 21:38:20 -06:00
John Miller
85d80f4394 Merge branch 'fix-oinfo-errors' 2018-11-02 16:16:39 -05:00
dickmao
5023b0796b Reconnect is not restart #377
Upon disconnection, the jupyter server apparently returns the same kernel for a given
notebook path input.  So reconnect is a thing, and restart is very
distinct from that.

Fixes #377
2018-11-02 11:32:12 -04:00
John Miller
db310073c4 Robustly build oinfo cache.
EIN tries to build a cached of pdef's for all potential completion symbols. This
is problematic because not all completion symbols have a pdef and can cause
python to throw exceptions in entertaining and hard to catch ways. We take a
liberal approach and ignore anything that throws an exception when we try to
inspect it.

Eldoc support should also be more robust because of these changes as well.
2018-11-01 20:26:42 -05:00
dickmao
db2856f445 Restart if kernel still alive needs to work 2018-11-01 20:08:10 -04:00
dickmao
d621944797 Clean up websocket callbacks
Coursera appears to kill websockets every minute or so, and I'm
observing firsthand the buggy behaviors described in #356.  This PR
cleans up the websocket code and kernel restart logic.  Removed
backwards compatibility for the v2 messaging api
as keeping it in the presence of the refactoring would make it more
broken that it already was.
2018-10-31 23:38:45 -04:00
dickmao
b950bd3a4c Fix "Kernel is busy..." bug
One line change to fix header not updating after cell execution
(keeps saying "Kernel is busy").

The bug does not manifest when running with `ein:debug` true since
EMACS's display loop updates more frequently with debug messages.

In tracking this bug, noticed eldoc support isn't quite there.
`__import__('ein').print_object_info_for(%s)` appears in
`ein-completer` and `ein-pytools`, and is invalid python syntax
afaict.  Took a few steps to make it whole, but incomplete.
2018-10-27 23:04:04 -04:00
dickmao
0490031ec8 Sane File Navigation
As emacs users we prefer and have the luxury of fuzzy file navigation
via ido and projectile.  From a notebook or notebooklist buffer, the commands

`C-c C-f` ein:file-open
`C-c C-o` ein:notebook-open

offer an ido alternative to point and click navigation.

To populate the ido lists, retrieving the content hierarchy is on by
default.  Two custom variables determine how wide and deep the content query
probes (currently at 2 levels deep and 6 directories wide).  Set both
to zero to turn off.

tkf half finished code to quickly go from local file buffers to notebook
mode via `C-c C-z` or `C-c C-o`.  This is now possible.  EIN will
start the server from a suitable parent directory of the visited file.

Enable ido completion for `notebooklist-login`.

Remove the albatross `ein-loaddefs.el` in favor of more standard
`ein-autoloads.el` that is not git tracked.

Convenience `make install` from git source (local alternative to
melpa).
2018-10-26 18:40:19 -04:00
Tomasz Mieszkowski
80cf9808a9 Fix ein:pytools-export-buffer 2018-10-13 19:59:41 +02:00
John Miller
4d9c05f2dc Maybe fix for #334
ein wasn't using the correct protocol for "inspect_request" messages for recent
versions (>5.0) of the protocol.
2018-09-09 09:44:59 -05:00
John Miller
d117ce915f Fix for #325
EIN's complete_request wasn't using the correct parameter for recent (> 5.0)
of the jupyter messaging protocol.
2018-08-16 08:43:25 -05:00
John Miller
926055e5fb Fix for #317.
Python JSON keywords use underscores - I am too use to the lisp way which uses
dashes.
2018-08-07 08:36:26 -05:00
John Miller
9ad9b4f4e6 Hooks to customize behavior during kernel execution.
New hooks `ein:pre-kernel-execute-functions', `ein:on-execute-reply-functions'
and `ein:on-shell-reply-functions'. See variable documentation for more
information.
2018-05-12 17:32:32 -05:00
Miller
710a5a6b91 ein-kernel: Handle generic stdin channel requests
That is, stdin requests that are generated by calls to `input' in Python (and
whatever is equivalent in other kernels).
2018-03-05 15:56:16 -06:00
John Miller
9d5309af59 Trying something new with testing.
Let's do this with ert-runner instead of python. Maybe it will work for once.
2018-02-27 14:38:13 -06:00
John Miller
045d9e9a89 Adjustments to debug logging.
Added some verbosity, removed some calls that were causing errors.
2018-02-14 18:24:20 -06:00
John Miller
34902e104f ein-company: Avoid completing around punctuation.
For some reason this causes the IPython kernel to return a very large number of
potential matches.
2017-10-20 11:55:31 -05:00
John Miller
4419818dde Merge branch 'back-to-eieio' 2017-07-29 23:08:35 -05:00
John Miller
4f5f29d351 ein-jupyterhub: Fix websocket connects.
Made sure to add the right cookies to the websocket request. Websockets
authenticate and everything is peachy now.
2017-07-25 16:57:32 -05:00
John Miller
9a1579d5f6 ein-jupyterhub: Support contents api
When running against jupyterhub master (which will someday be v0.8) can know log
in and make calls to the contents api.

Everything is working except for opening websocket connections.
2017-07-25 15:36:07 -05:00
John Miller
c78711a7c4 Back to eieio
It seems there are enough people out there still on Emacs 24 to warrant undoing
some of my recent moves away from eieio to cl-generic. For the near future I
will try to keep any changes that are incompatible with Emacs 24 to a
development branch. There is still probably plenty of opportunity to make the
code more future-proof for an eventual move away from eieio (I'm looking at you
oref and sref...)
2017-07-12 14:38:04 -05:00
John Miller
4b92b3adcc ein-kernel: Support (anew) starting kernels in older versions of jupyter.
Overzealously looking to the future was my sin here.
2017-05-18 09:04:49 -05:00
John Miller
91b5f605ee Implementat company doc-buffer command.
ein company backend will now show results of inspect_request in a company
documentation buffer when company requests documentation via the doc-buffer
command.
2017-04-21 17:57:16 -05:00
John Miller
d13e85b370 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.
2017-04-19 10:12:45 -05:00
John Miller
f0f0c0d206 Typos, more efficient kernelspec querying.
Silly typo in ein-kernel.el. Querying kernelspecs is slightly more efficient,
caching results when url is a string or port (previously just cached results for
ports).
2017-04-11 17:09:30 -05:00
John Miller
39f5d329f1 Functional tests start jupyter using ein:jupyter-server-start
This reduces some of the complexity in testein.py, but unfortunately running
tests is still unreliable. Running batchwise tests don't work at all in Windows,
and running from inside emacs tests often need to be run multiple times before
they pass.

The worst offender is the delete notebook test, which will pass on usually only
1 out of 3 tries.

Testing seems to have revealed a couple bugs, so win??
2017-04-07 08:18:41 -05:00
John Miller
8cb69fe4e7 Update to latest sessions API
Set POST body during session creation per
http://jupyter-api.surge.sh/#!/sessions/get_sessions.
2017-03-16 22:28:17 -05:00
John Miller
1b3aa10d51 Properly detect set_next_input payloads.
With this change %load magic works correctly.
2016-12-18 23:09:07 -06:00
John Miller
2b7b9f20fa Improving ipdb support.
EIN ipdb buffer should look better on Linux machines now. The extra characters
were someone's (ipython?) attempt at doing ansi coloring I think.

Also trying to make the ipdb comint buffer more canonical, with the hope to get
it to work with realgud. Not quite there yet, unfortunately.
2016-11-29 22:06:03 -06:00
John Miller
c70dee7733 Taceback from cell edit buffer, more informative version
Jump to tracebacks from cell edit buffers.

Slightly more informative on version of jupyter we are working with.
2016-11-05 17:49:52 -05:00
John Miller
19303cb637 Fix notebooklist render, remove connect_request
Notebooklist was not showing kernel status anymore.

Connect_request messages are deprecated since v5.0 of the messaging
spec, and ein never did much anyway with the message.
2016-10-29 09:43:40 -05:00
John Miller
586879598a Switch kernel in running notebook.
Does so by changing kernelspec and restarting notebook.
2016-08-26 20:52:54 -05:00
John Miller
8aaae29a23 Fix what introducing kernelspecs broke.
Embarassing, really. Missing parameters and some poorly placed branching
logic conspired to bring down ein on IPython 2.x. Should be better now.
2016-04-15 16:08:53 -05:00