purge

align pm:get-span no major mode error with diagnostic

purge
This commit is contained in:
dickmao 2019-11-08 12:47:06 -05:00
parent 47e7785f12
commit bcf1c2ac55
62 changed files with 130 additions and 6732 deletions

27
.gitignore vendored
View file

@ -1,33 +1,12 @@
doc/build/
env
.cask/*
Cask.tmp
index_error.py
redirecting_server.py
wiener_filtering.py
UTF-8-demo.txt
.gitmodules
*.stackdump
*.elc
*.el#
*.el~
lisp/ein-autoloads.el
*.py~
*.org~
*.pyc
*.ipynb~
Makefile~
*.ipynb_checkpoints*
*.png
tests/notebook
*.log
log/*
_images
_static
.travis.yml.swp
*.zip
.gitattributes
.ecukes*
dist
.*ein*.ipynb
.*ein*ipynb
.Rhistory
.ipynb_checkpoints
ein-autoloads.el

View file

@ -38,8 +38,6 @@ matrix:
include:
- os: linux
env: EMACS_CI=emacs-25-1 IPYTHON=5.8.0 PY=python PIP="${PY} -m pip install --user"
- os: linux
env: EMACS_CI=emacs-26-1 IPYTHON=6.5.0 PY=python3 PIP="${PY} -m pip install --user"
- os: linux
env: EMACS_CI=emacs-26-3 IPYTHON=7.5.0 PY=python3 PIP="${PY} -m pip install --user"
- os: osx
@ -56,7 +54,7 @@ install:
pyenv activate $TOXENV ;
fi
- ${PIP} --upgrade pip
- ${PIP} wheel jupyter ipython\<=$IPYTHON jedi\>=0.15.1 ipykernel numpy\<=1.16.0 matplotlib\<=3.0.2
- ${PIP} wheel jupyter ipython\<=$IPYTHON ipykernel numpy\<=1.16.0 matplotlib\<=3.0.2
- ${PY} -m ipykernel install --user
- sh tools/install-R.sh
- sh tools/install-julia.sh

674
COPYING
View file

@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

4
Cask
View file

@ -11,13 +11,9 @@
(depends-on "ert-runner")
(depends-on "ecukes")
(depends-on "espuds")
;; (depends-on "org-plus-contrib") ;; see https://github.com/cask/cask/issues/119
(depends-on "mocker")
(depends-on "skewer-mode")
(depends-on "deferred")
(depends-on "auto-complete")
(depends-on "company")
(depends-on "smartrep")
(depends-on "polymode")
(depends-on "markdown-mode")
(depends-on "julia-mode")

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -69,9 +69,9 @@ test-jupyterhub: test-compile
-cask exec ecukes --tags @jupyterhub --reporter magnars
.PHONY: test
test: quick test-int test-poly
test: quick test-int
.PHONY: test-poly
.PHONY: test-unpoly
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
@ -79,12 +79,12 @@ test-poly:
.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
.PHONY: test-unit
test-unit:
cask exec ert-runner -L ./lisp -L ./test -l test/testein.el test/test-ein*.el
cask exec ert-runner -L ./lisp -L ./test test/test-uncompiled.el
.PHONY: test-ob-ein-recurse
test-ob-ein-recurse:

View file

@ -62,7 +62,6 @@ Notebook server ``M-x ein:log-pop-to-request-buffer``.
Kernel messaging (must be run from notebook buffer) ``M-x ein:dev-pop-to-debug-channels``.
.. _spacemacs layer: https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/ipython-notebook
.. _auto-complete: https://github.com/auto-complete/auto-complete
.. _company-mode: https://github.com/company-mode/company-mode
.. _jupyterhub: https://github.com/jupyterhub/jupyterhub

View file

@ -121,7 +121,7 @@ Keymap (C-h m)
key binding
--- -------
C-c Prefix Command
C-x Prefix Command
ESC Prefix Command
@ -131,16 +131,16 @@ Keymap (C-h m)
<M-S-return> ein:worksheet-execute-cell-and-insert-below
<M-down> ein:worksheet-move-cell-down
<M-up> ein:worksheet-move-cell-up
C-x C-s ein:notebook-save-notebook-command
C-x C-w ein:notebook-rename-command
M-RET ein:worksheet-execute-cell-and-goto-next
M-, ein:pytools-jump-back-command
M-. ein:pytools-jump-to-source-command
M-n ein:worksheet-next-input-history
M-p ein:worksheet-previous-input-history
C-c C-a ein:worksheet-insert-cell-above
C-c C-b ein:worksheet-insert-cell-below
C-c C-c ein:worksheet-execute-cell
@ -166,7 +166,6 @@ Keymap (C-h m)
C-c C-z ein:notebook-kernel-interrupt-command
C-c ESC Prefix Command
C-c ! ein:worksheet-rename-sheet
C-c ' ein:edit-cell-contents
C-c + ein:notebook-worksheet-insert-next
C-c - ein:notebook-worksheet-delete
C-c 1 ein:notebook-worksheet-open-1th
@ -179,7 +178,6 @@ Keymap (C-h m)
C-c 8 ein:notebook-worksheet-open-8th
C-c 9 ein:notebook-worksheet-open-last
C-c S ein:worksheet-toggle-slide-type
C-c i ein:inspect-object
C-c { ein:notebook-worksheet-open-prev-or-last
C-c } ein:notebook-worksheet-open-next-or-first
C-c C-S-l ein:worksheet-clear-all-output
@ -192,10 +190,10 @@ Keymap (C-h m)
C-c C-; ein:shared-output-show-code-cell-at-point
C-c <down> ein:worksheet-move-cell-down
C-c <up> ein:worksheet-move-cell-up
C-c C-x C-l ein:notebook-toggle-latex-fragment
C-c C-x C-r ein:notebook-restart-session-command
C-c M-+ ein:notebook-worksheet-insert-prev
C-c M-w ein:worksheet-copy-cell
C-c M-{ ein:notebook-worksheet-move-prev

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View file

@ -100,9 +100,6 @@ Requirements
* `request-deferred.el`_ >= 0.2
* `dash`_ >= 2.13
* `s`_ >= 1.11
* `auto-complete.el`_ >= 1.4:
You need to configure subpackage ``ein-ac`` to enable
this feature.
* `skewer-mode`_ >= 1.6.2:
Skewer mode gives EIN the ability to execute dynamic javascript in the
note book.

View file

@ -1,29 +1,3 @@
@connect
Scenario: Company completion in a python buffer
Given I set "ein:completion-backend" to eval "(quote ein:use-company-backend)"
Given I kill all websocket buffers
Given new python notebook
When I open temp file "connect.py"
And I switch to buffer like "connect.py"
And I call "python-mode"
And I connect to default notebook
And I type "import itertools"
And I press "RET"
And I call "ein:connect-run-buffer"
And I type "itertools."
And I call "company-complete"
And I wait for completions "itertools.chain"
And I press "C-a"
And I press "C-k"
And I clear websocket log
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"
Then no completion traffic
@connect
Scenario: Test shared eval
Given new python notebook

View file

@ -1,58 +1,3 @@
@eldoc
Scenario: remote eldoc (largely unused)
Given I enable "ein:enable-eldoc-support"
Given I clear log expr "ein:log-all-buffer-name"
Given new python notebook
And I type "import math"
And I press "C-a"
And I call eldoc-documentation-function
And I switch to log expr "ein:log-all-buffer-name"
Then I should not see "ein:completions--prepare-oinfo"
@complete
Scenario: auto completion
Given I set "ein:ac-direct-matches" to eval "nil"
Given I set "ein:completion-backend" to eval "(quote ein:use-ac-backend)"
Given new python notebook
And I type "import itertool"
And I press "C-c C-i"
And I wait for the smoke to clear
Then "ein:ac-direct-matches" should include "itertools"
@complete
Scenario: no auto completion
Given I set "ein:ac-direct-matches" to eval "nil"
Given I set "ein:completion-backend" to eval "(quote ein:use-none-backend)"
Given new python notebook
And I type "import itertool"
And I press "C-c C-i"
And I wait for the smoke to clear
Then "ein:ac-direct-matches" should not include "itertools"
@complete
Scenario: company completion
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 "M-RET"
And I type "itertools."
And I call "company-complete"
And I wait for completions "itertools.chain"
And I press "C-a"
And I press "C-k"
And I clear websocket log
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"
Then no completion traffic
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

View file

@ -3,9 +3,10 @@
(require 'espuds)
(require 'ert)
(require 'undo-tree)
(with-eval-after-load "python"
(setq python-indent-guess-indent-offset-verbose nil))
(require 'python)
(require 'julia-mode)
(require 'ess-r-mode)
(require 'markdown-mode)
(let* ((support-path (f-dirname load-file-name))
(root-path (f-parent (f-parent support-path))))
@ -73,7 +74,8 @@
(Setup
(ein:dev-start-debug)
(cl-assert (boundp 'company-frontends))
(custom-set-variables '(company-frontends nil))
(custom-set-variables '(company-frontends nil)
'(python-indent-guess-indent-offset-verbose nil))
(setq ein:jupyter-default-kernel
(loop with cand = ""
for (k . spec) in
@ -90,8 +92,6 @@
do (setq cand (symbol-name k))
end
finally return (intern cand)))
(setq ein:notebook-autosave-frequency 0)
(setq ein:notebook-create-checkpoint-on-save nil)
(setq ein:testing-dump-file-log (concat default-directory "log/ecukes.log"))
(setq ein:testing-dump-file-messages (concat default-directory "log/ecukes.messages"))
(setq ein:testing-dump-file-server (concat default-directory "log/ecukes.server"))

View file

@ -23,7 +23,7 @@ Scenario: Kill yank doesn't break undo
And I press "C-<down>"
And I press "C-c C-y"
And I press "C-/"
Then the cursor should be at point "74"
Then the cursor should be at point "75"
@undo
Scenario: Collapse doesn't break undo
@ -52,7 +52,7 @@ Scenario: Collapse doesn't break undo
And I dump buffer
Then the cursor should be at point "77"
And I undo again
Then the cursor should be at point "55"
Then the cursor should be at point "53"
@undo
Scenario: Test the conflagrative commands
@ -108,7 +108,7 @@ Scenario: Clear output doesn't break undo
And I press "C-/"
Then the cursor should be at point "74"
And I undo again
Then the cursor should be at point "55"
Then the cursor should be at point "53"
@undo
Scenario: Moving cells doesn't break undo
@ -221,7 +221,7 @@ Scenario: Undo needs to at least work for reopened notebooks
And I undo again
And I undo again
And I undo again
Then the cursor should be at point "125"
Then the cursor should be at point "124"
@undo
Scenario: Toggling between markdown and codecell does not break undo
@ -291,7 +291,7 @@ Scenario: Undo (kind of) needs to work when someone explicitly requires ein-time
And I undo again
And I undo again
And I undo again
Then the cursor should be at point "125"
Then the cursor should be at point "124"
@timestamp
Scenario: Kill yank doesn't break undo

View file

@ -95,6 +95,21 @@
}
],
"metadata": {
"kernelspec": {
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"env": null,
"interrupt_mode": "signal",
"language": "python",
"metadata": null,
"name": "python3"
},
"name": "undo.ipynb"
},
"nbformat": 4,

View file

@ -1,253 +0,0 @@
;;; ein-ac.el --- Auto-complete extension
;; Copyright (C) 2012- Takafumi Arakaki
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
;; This file is NOT part of GNU Emacs.
;; ein-ac.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-ac.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-ac.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(eval-when-compile (require 'cl))
(require 'auto-complete)
(require 'ein-core)
(eval-when-compile (require 'ein-notebook)
(defvar ein:mumamo-codecell-mode))
;;; Configuration
(defcustom ein:use-auto-complete-superpack nil
"Set to `t' to use preset a little bit hacky auto-complete configuration.
When this option is enabled, cached omni completion is available."
:type 'boolean
:group 'ein)
(defvar ein:ac-sources (and (boundp 'ac-sources)
(default-value 'ac-sources))
"Extra `ac-sources' used in notebook.")
;;; Chunk (adapted from auto-complete-chunk.el)
(defvar ein:ac-chunk-regex
(rx (group (| (syntax whitespace)
(syntax open-parenthesis)
(syntax close-parenthesis)
(syntax string-quote) ; Complete files for `open("path/..`
bol))
(? (syntax punctuation)) ; to complete ``~/PATH/...``
(* (+ (| (syntax word) (syntax symbol)))
(syntax punctuation))
(+ (| (syntax word) (syntax symbol)))
(? (syntax punctuation))
point)
"A regexp that matches to a \"chunk\" containing words and dots.")
(defun ein:ac-chunk-beginning ()
"Return the position where the chunk begins."
(ignore-errors
(save-excursion
(+ (re-search-backward ein:ac-chunk-regex) (length (match-string 1))))))
(defun ein:ac-chunk-candidates-from-list (chunk-list)
"Return matched candidates in CHUNK-LIST."
(let* ((start (ein:ac-chunk-beginning)))
(when start
(loop with prefix = (buffer-substring start (point))
for cc in chunk-list
when (string-prefix-p prefix cc)
collect cc))))
;;; AC Source
(defvar ein:ac-direct-matches nil
"Variable to store completion candidates for `auto-completion'.")
;; FIXME: Maybe this should be buffer-local?
(defun ein:ac-direct-get-matches ()
(ein:ac-chunk-candidates-from-list ein:ac-direct-matches))
(ac-define-source ein-direct
'((candidates . ein:ac-direct-get-matches)
(requires . 0)
(prefix . ein:ac-chunk-beginning)
(symbol . "s")))
(ac-define-source ein-async
'((candidates . ein:ac-direct-get-matches)
(requires . 0)
(prefix . ein:ac-chunk-beginning)
(init . ein:ac-request-in-background)
(symbol . "c")))
(define-obsolete-function-alias 'ac-complete-ein-cached 'ac-complete-ein-async
"0.2.1")
(define-obsolete-variable-alias 'ac-source-ein-cached 'ac-source-ein-async
"0.2.1")
(defun ein:ac-request-in-background ()
(cl-ecase ein:completion-backend
(ein:use-ac-backend (ein:aif (ein:get-kernel)
(ein:completer-complete
it
(list :complete_reply
(cons (lambda (_ content __)
(ein:ac-prepare-completion (plist-get content :matches)))
nil))
#'ignore)))))
;;; Completer interface
(defun ein:ac-dot-complete (callback)
"Insert a dot and request completion via CALLBACK of 0-arity"
(interactive (list (lambda () (call-interactively #'ein:completer-complete))))
(insert ".")
(if (not (ac-cursor-on-diable-face-p))
(funcall callback)))
(defun ein:ac-prepare-completion (matches)
"Prepare `ac-source-ein-direct' using MATCHES from kernel.
Call this function before calling `auto-complete'."
(when matches
(setq ein:ac-direct-matches matches))) ; let-binding won't work
(defun* ein:completer-finish-completing-ac
(matched-text
matches
&key (expand ac-expand-on-auto-complete)
&allow-other-keys)
"Invoke completion using `auto-complete'.
Only the argument MATCHES is used. MATCHED-TEXT is for
compatibility with `ein:completer-finish-completing-default'."
;; I don't need to check if the point is at right position, as in
;; `ein:completer-finish-completing-default' because `auto-complete'
;; checks it anyway.
(ein:log 'debug "COMPLETER-FINISH-COMPLETING-AC: matched-text=%S matches=%S"
matched-text matches)
(ein:ac-prepare-completion matches)
(when matches ; No auto-complete drop-down list when no matches
(let ((ac-expand-on-auto-complete expand))
(ac-start))))
;;; Async document request hack
(defun ein:ac-request-document-for-selected-candidate ()
"Request object information for the candidate at point.
This is called via `ac-next'/`ac-previous'/`ac-update' and set
`document' property of the current candidate string. If server
replied within `ac-quick-help-delay' seconds, auto-complete will
popup help string."
(ein:aif (ein:get-kernel)
(let* ((candidate (ac-selected-candidate))
(kernel it)
(api-version (ein:$kernel-api-version kernel))
(callbacks (list (if (< api-version 3)
:object_info_reply
:inspect_request)
(cons #'ein:ac-set-document candidate))))
(when (and candidate
(ein:kernel-live-p kernel)
(not (get-text-property 0 'document candidate)))
(ein:log 'debug "Requesting object info for AC candidate %S"
candidate)
(ein:kernel-object-info-request kernel candidate callbacks)))))
(defun ein:ac-set-document (candidate content -metadata-not-used-)
(ein:log 'debug "EIN:AC-SET-DOCUMENT candidate=%S content=%S"
candidate content)
(put-text-property 0 (length candidate)
'document (ein:kernel-construct-help-string content)
candidate))
(defadvice ac-next (after ein:ac-next-request)
"Monkey patch `auto-complete' internal function to request
help documentation asynchronously."
(ein:ac-request-document-for-selected-candidate))
(defadvice ac-previous (after ein:ac-previous-request)
"Monkey patch `auto-complete' internal function to request
help documentation asynchronously."
(ein:ac-request-document-for-selected-candidate))
(defadvice ac-update (after ein:ac-update-request)
"Monkey patch `auto-complete' internal function to request help
documentation asynchronously. This will request info for the
first candidate when the `ac-menu' pops up."
(ein:ac-request-document-for-selected-candidate))
;;; Setup
(defun ein:ac-superpack ()
"Enable richer auto-completion.
* Enable auto-completion help by monkey patching `ac-next'/`ac-previous'"
(interactive)
(ad-enable-advice 'ac-next 'after 'ein:ac-next-request)
(ad-enable-advice 'ac-previous 'after 'ein:ac-previous-request)
(ad-enable-advice 'ac-update 'after 'ein:ac-update-request)
(ad-activate 'ac-next)
(ad-activate 'ac-previous)
(ad-activate 'ac-update))
(defun ein:ac-setup ()
"Call this function from mode hook (see `ein:ac-config')."
(setq ac-sources (append '(ac-source-ein-async) ein:ac-sources)))
(defun ein:ac-setup-maybe ()
"Setup `ac-sources' for mumamo.
.. note:: Setting `ein:notebook-mumamo-mode-hook' does not work
because `ac-sources' in `ein:notebook-mumamo-mode'-enabled
buffer is *chunk local*, rather than buffer local.
Making `ac-sources' permanent-local also addresses issue of
MuMaMo discarding `ac-sources'. However, it effects to entire
Emacs setting. So this is not the right way to do it.
Using `mumamo-make-variable-buffer-permanent' (i.e., adding
`ac-sources' to `mumamo-per-buffer-local-vars' or
`mumamo-per-main-major-local-vars') is also not appropriate.
Adding `ac-sources' to them makes it impossible to different
`ac-sources' between chunks, which is good for EIN but may not
for other package."
(and (ein:eval-if-bound 'ein:notebook-mode)
(ein:eval-if-bound 'ein:notebook-mumamo-mode)
(eql major-mode ein:mumamo-codecell-mode)
(ein:ac-setup)))
(defun ein:ac-config (&optional superpack)
"Install auto-complete-mode for notebook modes.
Specifying non-`nil' to SUPERPACK enables richer auto-completion
\(see `ein:ac-superpack')."
(add-hook 'after-change-major-mode-hook 'ein:ac-setup-maybe)
(add-hook 'ein:notebook-mode-hook 'ein:ac-setup)
(when superpack
(ein:ac-superpack)))
(ein:ac-config ein:use-auto-complete-superpack)
(provide 'ein-ac)
;;; ein-ac.el ends here

View file

@ -1,273 +0,0 @@
;;; ein-cell-edit.el --- Notebook cell editing
;; Copyright (C) 2016 John M. Miller
;; Author: John Miller <millejoh at mac.com>
;; This file is NOT part of GNU Emacs.
;; ein-cell-edit.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-cell-edit.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-worksheet.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This code inspired by borrowing from org-src.el.
;;; Code:
(require 'ein-cell)
(autoload 'julia-mode "julia-mode")
(autoload 'markdown-mode "markdown-mode")
(autoload 'R-mode "ess-r-mode")
(autoload 'org-src--remove-overlay "org-src")
(autoload 'org-src-switch-to-buffer "org-src")
(defvar ein:src--cell nil)
(defvar ein:src--ws nil)
(defvar ein:src--allow-write-back t)
(defvar ein:src--overlay nil)
(defvar ein:src--saved-window-config nil)
(defvar ein:edit-cell-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c'" 'ein:edit-cell-exit)
(define-key map "\C-c\C-k" 'ein:edit-cell-abort)
(define-key map "\C-c\C-c" 'ein:edit-cell-save-and-execute)
(define-key map "\C-x\C-s" 'ein:edit-cell-save)
(define-key map "\C-c\C-x" 'ein:edit-cell-view-traceback)
map))
(define-minor-mode ein:edit-cell-mode
"Minor mode for language major mode buffers generated by EIN.
This minor mode is turned on when editing a source code snippet with \\[ein:edit-cell-contents]
\\{ein:edit-cell-mode-map}
."
nil " EinCell" nil
(set (make-local-variable 'header-line-format)
(substitute-command-keys
"Edit, execute with \\[ein:edit-cell-execute] then exit with \\[ein:edit-cell-exit] \
or abort with \\[ein:edit-cell-abort]"))
;; Possibly activate various auto-save features (for the edit buffer
;; or the source buffer).
;; (when org-edit-src-turn-on-auto-save
;; (setq buffer-auto-save-file-name
;; (concat (make-temp-name "org-src-")
;; (format-time-string "-%Y-%d-%m")
;; ".txt")))
;; (unless (or org-src--auto-save-timer (zerop org-edit-src-auto-save-idle-delay))
;; (setq org-src--auto-save-timer
;; (run-with-idle-timer
;; org-edit-src-auto-save-idle-delay t
;; (lambda ()
;; (save-excursion
;; (let (edit-flag)
;; (dolist (b (buffer-list))
;; (with-current-buffer b
;; (when (org-src-edit-buffer-p)
;; (unless edit-flag (setq edit-flag t))
;; (when (buffer-modified-p) (org-edit-src-save)))))
;; (unless edit-flag
;; (cancel-timer org-src--auto-save-timer)
;; (setq org-src--auto-save-timer nil))))))))
)
(defun ein:cell-configure-edit-buffer ()
(when (and (bound-and-true-p org-src--from-org-mode) (boundp 'org-src--beg-marker))
(add-hook 'kill-buffer-hook #'org-src--remove-overlay nil 'local)
(if (bound-and-true-p org-src--allow-write-back)
(progn
(setq buffer-offer-save t)
(setq buffer-file-name
(concat (buffer-file-name (marker-buffer org-src--beg-marker))
"[" (buffer-name) "]"))
(setq write-contents-functions '(ein:edit-cell-save)))
(setq buffer-read-only t))))
(defun ein:edit-cell-view-traceback ()
"Jump to traceback, if there is one, for current edit."
(interactive)
(let ((buf (current-buffer))
(cell ein:src--cell))
(with-current-buffer (ein:worksheet--get-buffer ein:src--ws)
(ein:cell-goto cell)
(ein:tb-show))))
(defun ein:edit-cell-save-and-execute ()
"Save, then execute the countents of the EIN source edit buffer
and place results (if any) in output of original notebook cell."
(interactive)
(ein:edit-cell-save)
(when (and (slot-exists-p ein:src--cell 'kernel)
(slot-boundp ein:src--cell 'kernel))
(ein:cell-execute-internal ein:src--cell
(slot-value ein:src--cell 'kernel)
(buffer-string)
:silent nil)))
(defun ein:edit-cell-save ()
"Save contents of EIN source edit buffer back to original notebook
cell."
(interactive)
(set-buffer-modified-p nil)
(let* ((edited-code (buffer-string))
(cell ein:src--cell)
(overlay ein:src--overlay)
(read-only (overlay-get overlay 'modification-hooks)))
(overlay-put overlay 'modification-hooks nil)
(overlay-put overlay 'insert-in-front-hooks nil)
(overlay-put overlay 'insert-behind-hooks nil)
(with-current-buffer (ein:worksheet--get-buffer ein:src--ws)
(ein:cell-set-text cell edited-code))
;;(setf (slot-value ein:src--cell 'input) edited-code)
(overlay-put overlay 'modification-hooks read-only)
(overlay-put overlay 'insert-in-front-hooks read-only)
(overlay-put overlay 'insert-behind-hooks read-only)))
(defun ein:edit-cell-exit ()
"Close the EIN source edit buffer, saving contents back to the
original notebook cell, unless being called via
`ein:edit-cell-abort'."
(interactive)
(let ((edit-buffer (current-buffer))
(ws ein:src--ws)
(cell ein:src--cell))
(ein:remove-overlay)
(when ein:src--allow-write-back
(ein:edit-cell-save))
(kill-buffer edit-buffer)
(switch-to-buffer-other-window (ein:worksheet--get-buffer ws))
(ein:cell-goto cell)
(when ein:src--saved-window-config
(set-window-configuration ein:src--saved-window-config)
(setq ein:src--saved-window-config nil))))
(defun ein:edit-cell-abort ()
"Abort editing the current cell, contents will revert to
previous value."
(interactive)
(let (ein:src--allow-write-back) (ein:edit-cell-exit)))
(defun ein:construct-cell-edit-buffer-name (bufname cid cell-type)
(concat "*EIN Src " bufname "[ " cid "/" cell-type " ]*" ))
(defun ein:get-mode-for-kernel (kernelspec)
(if (null kernelspec)
'python ;; FIXME
(ein:case-equal (ein:$kernelspec-language kernelspec)
(("julia" "python" "R") (intern (ein:$kernelspec-language kernelspec)))
(t 'python))))
(defun ein:edit-src-continue (e)
(interactive "e")
(mouse-set-point e)
(let ((buf (get-char-property (point) 'edit-buffer)))
(if buf (org-src-switch-to-buffer buf 'continue)
(user-error "No sub-editing buffer for area at point"))))
(defun ein:make-source-overlay (beg end edit-buffer)
"Create overlay between BEG and END positions and return it.
EDIT-BUFFER is the buffer currently editing area between BEG and
END."
(let ((overlay (make-overlay beg end)))
(overlay-put overlay 'face 'secondary-selection)
(overlay-put overlay 'edit-buffer edit-buffer)
(overlay-put overlay 'help-echo
"Click with mouse-1 to switch to buffer editing this segment")
(overlay-put overlay 'face 'secondary-selection)
(overlay-put overlay 'keymap
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'ein:edit-src-continue)
map))
(let ((read-only
(list
(lambda (&rest _)
(user-error
"Cannot modify an area being edited in a dedicated buffer")))))
(overlay-put overlay 'modification-hooks read-only)
(overlay-put overlay 'insert-in-front-hooks read-only)
(overlay-put overlay 'insert-behind-hooks read-only))
overlay))
(defun ein:remove-overlay ()
"Remove overlay from current source buffer."
(when (overlayp ein:src--overlay) (delete-overlay ein:src--overlay)))
(defcustom ein:raw-cell-default-edit-mode 'LaTeX-mode
"The major mode to use when editing a cell of type 'Raw' in the
dedicated edit buffer. By default we use LaTeX-mode."
:type 'symbol
:group 'ein)
(defun ein:edit-cell-contents ()
"Edit the contents of the current cell in a buffer using an
appropriate language major mode. Functionality is very similar to
`org-edit-special'."
(interactive)
(setq ein:src--saved-window-config (current-window-configuration))
(let* ((cell (or (ein:worksheet-get-current-cell)
(error "Must be called from inside an EIN worksheet cell.")))
(nb (ein:notebook--get-nb-or-error))
(ws (ein:worksheet--get-ws-or-error))
(type (slot-value cell 'cell-type))
(name (ein:construct-cell-edit-buffer-name (buffer-name) (ein:cell-id cell) type)))
(ein:aif (get-buffer name)
(switch-to-buffer-other-window it)
(ein:create-edit-cell-buffer name cell nb ws))))
(defun ein:edit-cell-detect-type (contents notebook &optional raw-cell-p)
(if (string-match "^%%\\(.*\\)" contents)
(ein:case-equal (match-string 1 contents)
(("html" "HTML") (html-mode))
(("latex" "LATEX") (LaTeX-mode))
(("ruby") (ruby-mode))
(("sh" "bash") (sh-mode))
(("javascript" "js") (javascript-mode))
(t (funcall ein:raw-cell-default-edit-mode)))
(if raw-cell-p
(funcall ein:raw-cell-default-edit-mode)
(case (ein:get-mode-for-kernel (ein:$notebook-kernelspec notebook))
(julia (julia-mode))
(python (python-mode))
(R (R-mode))))))
(defun ein:create-edit-cell-buffer (name cell notebook worksheet)
(let* ((contents (ein:cell-get-text cell))
(type (slot-value cell 'cell-type))
(buffer (generate-new-buffer-name name))
(overlay (ein:make-source-overlay (ein:cell-input-pos-min cell)
(ein:cell-input-pos-max cell)
buffer)))
(switch-to-buffer-other-window buffer)
(insert contents)
(remove-text-properties (point-min) (point-max)
'(display nil invisible nil intangible nil))
(set-buffer-modified-p nil)
(setq buffer-file-name buffer) ;; Breaks anaconda-mode without this special fix.
(condition-case e
(ein:case-equal type
(("markdown") (markdown-mode))
(("raw") (ein:edit-cell-detect-type contents notebook t))
(("code") (ein:edit-cell-detect-type contents notebook)))
(error (message "Language mode `%s' fails with: %S"
type (nth 1 e))))
(set (make-local-variable 'ein:src--overlay) overlay)
(set (make-local-variable 'ein:src--cell) cell)
(set (make-local-variable 'ein:src--ws) worksheet)
(set (make-local-variable 'ein:src--allow-write-back) t)
(ein:edit-cell-mode)))
(provide 'ein-cell-edit)

View file

@ -42,8 +42,6 @@
(require 'ein-node)
(require 'ein-kernel)
(require 'ein-output-area)
(require 'ein-skewer)
(require 'ein-hy)
;;; Faces
@ -122,12 +120,7 @@
;;; Customization
(defcustom ein:enable-dynamic-javascript nil
"[EXPERIMENTAL] When non-nil enable support in ein for
executing dynamic javascript. This feature requires installation
of the skewer package."
:type 'boolean
:group 'ein)
(make-obsolete-variable 'ein:enable-dynamic-javascript nil "0.17.0")
(defcustom ein:cell-traceback-level 1
"Number of traceback stack to show.
@ -210,7 +203,6 @@ a number will limit the number of lines in a cell output."
(defun ein:cell-class-from-type (type)
(ein:case-equal type
(("code") 'ein:codecell)
(("hy-code") 'ein:hy-codecell)
(("text") 'ein:textcell)
(("html") 'ein:htmlcell)
(("markdown") 'ein:markdowncell)
@ -229,13 +221,7 @@ a number will limit the number of lines in a cell output."
(apply (ein:cell-class-from-type type) args))
(defun ein:cell--determine-cell-type (json-data)
(let ((base-type (plist-get json-data :cell_type))
(metadata (plist-get json-data :metadata)))
(if (and (string-equal base-type "code")
(plist-get :metadata :ein.hycell)
(not (eql (plist-get metadata :ein.hycell) :json-false)))
"hy-code"
base-type)))
(plist-get json-data :cell_type))
(defun ein:cell-from-json (data &rest args)
(let ((cell (ein:cell-init (apply #'ein:cell-from-type
@ -921,13 +907,8 @@ Called from ewoc pretty printer via `ein:cell-insert-output'."
(cl-defmethod ein:cell-append-display-data ((cell ein:codecell) json)
"Insert display-data type output in the buffer.
Called from ewoc pretty printer via `ein:cell-insert-output'."
(if (and (or (plist-get json :javascript)
(plist-get json :html))
(slot-value cell 'dynamic) ein:enable-dynamic-javascript)
(ein:execute-javascript cell json)
(progn
(ein:cell-append-mime-type json (slot-value cell 'dynamic))
(ein:insert-read-only "\n"))))
(ein:cell-append-mime-type json (slot-value cell 'dynamic))
(ein:insert-read-only "\n"))
(defcustom ein:output-type-preference
(if (and (fboundp 'shr-insert-document)
@ -1052,9 +1033,6 @@ prettified text thus be used instead of HTML type."
(setq metadata (plist-put metadata :collapsed (if (slot-value cell 'collapsed) t json-false)))
(setq metadata (plist-put metadata :autoscroll json-false))
(setq metadata (plist-put metadata :ein.tags (format "worksheet-%s" wsidx)))
(setq metadata (plist-put metadata :ein.hycell (if (ein:hy-codecell-p cell)
t
json-false)))
(setq metadata (plist-put metadata :slideshow ss-table))
(unless discard-output
(dolist (output outputs)

View file

@ -63,9 +63,6 @@
:file : Either :text or :base64
:notebook : :json.
`ein:$content-checkpoints'
Names auto-saved checkpoints for content. Stored as a list
of (<id> . <last_modified>) pairs.
"
url-or-port
notebook-version
@ -78,11 +75,7 @@
mimetype
raw-content
format
session-p
checkpoints)
session-p)
;;; Websockets
(defstruct ein:$websocket
@ -148,13 +141,6 @@
`ein:$notebook-api-version' : integer
Major version of the IPython notebook server we are talking to.
`ein:$notebook-checkpoints'
Names auto-saved checkpoints for content. Stored as a list
of (<id> . <last_modified>) pairs.
`ein:$notebook-q-checkpoints'
Whether to checkpoint on save. Overrides ein:notebook-create-checkpoint-on-save
"
url-or-port
notebook-id ;; In IPython-2.0 this is "[:path]/[:name].ipynb"
@ -171,10 +157,7 @@
events
worksheets
scratchsheets
api-version
autosave-timer
checkpoints
q-checkpoints)
api-version)
@ -306,11 +289,6 @@ This cell is executed when the connected buffer is saved,
provided that (1) this flag is `t' and (2) corresponding
auto-execution mode flag in the connected buffer is `t'.")))
;; Use this cell to execute hy code in notebook running a Python kernel.
(defclass ein:hy-codecell (ein:codecell)
((cell-type :initarg :cell-type :initform "hy-code"))
"Codecell that supports executing hy code from within a Python kernel.")
(defclass ein:textcell (ein:basecell)
((cell-type :initarg :cell-type :initform "text")
(element-names :initform (:prompt :input :footer :slidetype))))
@ -366,9 +344,7 @@ auto-execution mode flag in the connected buffer is `t'.")))
"NotebookStatus"
:s2m
'((notebook_saving.Notebook . "Saving Notebook...")
(notebook_create_checkpoint.Notebook . "Creating Checkpoint...")
(notebook_saved.Notebook . "Notebook is saved")
(notebook_checkpoint_created.Notebook . "Checkpoint created.")
(notebook_save_failed.Notebook . "Failed to save Notebook!")))
:type ein:notification-status)
(kernel

View file

@ -1,124 +0,0 @@
;;; -*- mode: emacs-lisp; lexical-binding: t; -*-
;;; ein-company.el --- Support for completion using company back-end.
;; Copyright (C) 2017 - John Miller
;; Author: John Miller <millejoh at mac.com>
;; This file is NOT part of GNU Emacs.
;; ein-company.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-company.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-company.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(eval-when-compile (require 'cl))
(require 'deferred)
(require 'ein-completer)
(require 'company nil t)
(autoload 'company-begin-backend "company")
(autoload 'company-doc-buffer "company")
(defun ein:company--deferred-complete ()
(let ((d (deferred:new #'identity)))
(ein:completer-complete
(ein:get-kernel)
(list :complete_reply
(cons (lambda (d* &rest args) (deferred:callback-post d* args))
d))
(apply-partially (lambda (d* err) (deferred:callback-post d* err)) d))
d))
(defun ein:company--complete (prefix fetcher)
(deferred:$
(deferred:next
(lambda ()
(ein:company--deferred-complete)))
(deferred:nextc it
(lambda (replies)
(unless (stringp replies) ;; if not an error
(ein:completions--prepare-matches prefix fetcher replies))))))
(defun ein:completions--prepare-matches (prefix fetcher replies)
(destructuring-bind
((&key matches cursor_start cursor_end &allow-other-keys) ; :complete_reply
_metadata)
replies
(let ((nix (- cursor_end cursor_start))
prefixed-matches)
(dolist (match matches)
(setq prefixed-matches
(nconc prefixed-matches (list (concat prefix (substring match nix))))))
(ein:completions--build-oinfo-cache prefixed-matches)
(funcall fetcher prefixed-matches))))
;;;###autoload
(defun ein:company-backend (command &optional arg &rest _)
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'ein:company-backend))
(prefix (and (eq ein:completion-backend 'ein:use-company-backend)
(or (ein:worksheet-at-codecell-p) ein:connect-mode)
(ein:get-kernel)
(ein:object-prefix-at-point)))
(annotation (let ((kernel (ein:get-kernel)))
(ein:aif (gethash arg (ein:$kernel-oinfo-cache kernel))
(plist-get it :definition))))
(doc-buffer (cons :async
(lambda (cb)
(ein:company-handle-doc-buffer arg cb))))
(location (cons :async
(lambda (cb)
(ein:pytools-find-source (ein:get-kernel-or-error)
arg
cb))))
(candidates
(let* ((kernel (ein:get-kernel-or-error))
(cached (ein:completions-get-cached arg (ein:$kernel-oinfo-cache kernel))))
(ein:aif cached it
(unless (ein:company--punctuation-check (thing-at-point 'line)
(current-column))
(case ein:completion-backend
(t
(cons :async
(lambda (cb)
(ein:company--complete arg cb)))))))))))
(defun ein:company--punctuation-check (thing col)
(or (string-match "[[:nonascii:]]" thing)
(let ((query (ein:trim-right (subseq thing 0 col) "[\n]")))
(string-match "[]()\",[{}'=: ]$" query (- col 2)))))
(defun ein:company-handle-doc-buffer-finish (packed content _metadata-not-used_)
(when (plist-get content :found)
(funcall (plist-get packed :callback) (company-doc-buffer
(ansi-color-apply (cadr (plist-get content :data)))))))
(defun ein:company-handle-doc-buffer (object cb)
(ein:kernel-object-info-request (ein:get-kernel-or-error)
object
(list :inspect_reply
(cons #'ein:company-handle-doc-buffer-finish
(list :object object
:callback cb)))))
(when (boundp 'company-backends)
(add-to-list 'company-backends 'ein:company-backend))
(provide 'ein-company)

View file

@ -26,8 +26,6 @@
;;; Code:
(declare-function ac-cursor-on-diable-face-p "auto-complete")
(eval-when-compile (require 'cl))
(require 'ein-core)
@ -35,7 +33,6 @@
(require 'ein-subpackages)
(require 'ein-kernel)
(require 'ein-pytools)
(require 'ein-ac)
(require 'dash)
(make-obsolete-variable 'ein:complete-on-dot nil "0.15.0")
@ -43,7 +40,6 @@
(defun ein:completer-choose ()
(cond
((eq ein:completion-backend 'ein:use-none-backend) #'ignore)
((ein:eval-if-bound 'auto-complete-mode) #'ein:completer-finish-completing-ac)
(t #'ein:completer-finish-completing-default)))
(defun ein:completer-beginning (matched-text)
@ -73,12 +69,7 @@
(insert word))))
(defun ein:completer-complete (kernel callbacks errback)
"Start completion for the code at point.
EXPAND keyword argument is supported by
`ein:completer-finish-completing-ac'. When it is specified,
it overrides `ac-expand-on-auto-complete' when calling
`auto-complete'."
"Start completion for the code at point."
(interactive (list (ein:get-kernel)
(list :complete_reply
(cons #'ein:completer-finish-completing '(:expand nil)))
@ -97,16 +88,9 @@
when (string-prefix-p partial candidate)
collect candidate))
(defun ein:completions--get-oinfo (obj)
(defun ein:completions--get-oinfo (_obj)
(let ((d (deferred:new #'identity))
(kernel (ein:get-kernel)))
(if (ein:kernel-live-p kernel)
(ein:kernel-execute
kernel
(format "__ein_print_object_info_for(__ein_maybe_undefined_object(r\"%s\", locals()))" obj)
(list
:output `(,(lambda (d* &rest args) (deferred:callback-post d* args)) . ,d)))
(deferred:callback-post d "kernel not live"))
(_kernel (ein:get-kernel)))
d))
(defun ein:completions--build-oinfo-cache (objs)
@ -142,16 +126,6 @@
(prin1 output #'external-debugging-output))
(setf (gethash obj (ein:$kernel-oinfo-cache kernel)) :json-false))))
;;; Support for Eldoc
(defun ein:completer--get-eldoc-signature ()
(ein:and-let* ((func (ein:function-at-point))
(kernel (ein:get-kernel)))
(ein:aif (gethash func (ein:$kernel-oinfo-cache kernel))
(ein:kernel-construct-defstring it)
(ein:completions--build-oinfo-cache (list func))
nil)))
(provide 'ein-completer)
;;; ein-completer.el ends here

View file

@ -33,7 +33,6 @@
(require 'eieio)
(require 'company nil t)
(require 'ein-notebook)
(eval-when-compile (require 'auto-complete))
(autoload 'company-mode "company")
@ -199,8 +198,6 @@ notebooks."
(if (or (not no-reconnection)
(not ein:%connect%))
(let ((connection (ein:connect-setup notebook buffer)))
(when (ein:eval-if-bound 'ac-sources)
(push 'ac-source-ein-async ac-sources))
(ein:connect-mode)
(ein:log 'info "Connected to %s"
(ein:$notebook-notebook-name notebook))
@ -398,15 +395,7 @@ notebook."
:lighter (:eval (ein:connect-mode-get-lighter))
:keymap ein:connect-mode-map
:group 'ein
(case ein:completion-backend
(ein:use-ac-backend
(define-key ein:connect-mode-map "." 'ein:ac-dot-complete)
(auto-complete-mode))
(ein:use-company-backend
(if (not (boundp 'company-backends))
(error "ein:connect-mode: company unsupported")
(cl-assert (member 'ein:company-backend company-backends))
(company-mode)))))
)
(put 'ein:connect-mode 'permanent-local t)

View file

@ -427,71 +427,6 @@ global setting. For global setting and more information, see
&aux (resp-string (format "STATUS: %s DATA: %s" (request-response-status-code response) data)))
(ein:log 'debug "ein:query-sessions--complete %s" resp-string))
;;; Checkpoints
(defun ein:content-query-checkpoints (content &optional callback cbargs)
(let* ((url (ein:content-url content "checkpoints")))
(ein:query-singleton-ajax
(list 'content-query-checkpoints url)
url
:type "GET"
:timeout ein:content-query-timeout
:parser #'ein:json-read
:sync ein:force-sync
:success (apply-partially #'ein:content-query-checkpoints-success content callback cbargs)
:error (apply-partially #'ein:content-query-checkpoints-error content))))
(defun ein:content-create-checkpoint (content &optional callback cbargs)
(let* ((url (ein:content-url content "checkpoints")))
(ein:query-singleton-ajax
(list 'content-query-checkpoints url)
url
:type "POST"
:timeout ein:content-query-timeout
:parser #'ein:json-read
:sync ein:force-sync
:success (apply-partially #'ein:content-query-checkpoints-success content callback cbargs)
:error (apply-partially #'ein:content-query-checkpoints-error content))))
(defun ein:content-restore-checkpoint (content checkpoint-id &optional callback cbargs)
(let* ((url (ein:content-url content "checkpoints" checkpoint-id)))
(ein:query-singleton-ajax
(list 'content-query-checkpoints url)
url
:type "POST"
:timeout ein:content-query-timeout
:parser #'ein:json-read
:sync ein:force-sync
:success (when callback
(apply callback cbargs))
:error (apply-partially #'ein:content-query-checkpoints-error content))))
(defun ein:content-delete-checkpoint (content checkpoint-id &optional callback cbargs)
(let* ((url (ein:content-url content "checkpoints" checkpoint-id)))
(ein:query-singleton-ajax
(list 'content-query-checkpoints url)
url
:type "DELETE"
:timeout ein:content-query-timeout
:parser #'ein:json-read
:sync ein:force-sync
:success (when callback
(apply callback cbargs))
:error (apply-partially #'ein:content-query-checkpoints-error content))))
(defun* ein:content-query-checkpoints-success (content cb cbargs &key data status response &allow-other-keys)
(unless (listp (car data))
(setq data (list data)))
(setf (ein:$content-checkpoints content) data)
(when cb
(apply cb content cbargs)))
(defun* ein:content-query-checkpoints-error (content &key symbol-status response &allow-other-keys)
(ein:log 'error "Content checkpoint operation failed with status %s (%s)." symbol-status response))
;;; Uploads

View file

@ -346,8 +346,7 @@ but can operate in different contexts."
(ein:generic-getter '(ein:get-kernel--notebook
ein:get-kernel--worksheet
ein:get-kernel--shared-output
ein:get-kernel--connect
ein:get-kernel--worksheet-in-edit-cell)))
ein:get-kernel--connect)))
(defun ein:get-kernel-or-error ()
(or (ein:get-kernel)

View file

@ -27,6 +27,7 @@
(eval-when-compile (require 'cl))
(declare-function rst-shift-region "rst")
(declare-function markdown-mode "markdown-mode")
(require 'ein-notebook)
(require 'ein-subpackages)
@ -49,8 +50,7 @@
(let* ((dir (or dir ein:source-dir))
(regex (or regex ".+"))
(files (-remove #'(lambda (x)
(or (string-match-p "ein-pkg\\.el" x)
(string-match-p "ein-smartrep\\.el" x)))
(string-match-p "ein-pkg\\.el" x))
(and
(file-accessible-directory-p dir)
(directory-files dir 'full regex)))))
@ -69,7 +69,6 @@
(loop for f in (directory-files ein:source-dir nil "^ein-.*\\.el$")
unless (or (equal f "ein-pkg.el")
(equal f "ein-autoloads.el")
(equal f "ein-smartrep.el")
(funcall ignore-p f))
do (require (intern (file-name-sans-extension f)) nil t))
;; For `widget-button-press':
@ -125,7 +124,7 @@ callback (`websocket-callback-debug-on-error') is enabled."
(setq request-log-level (quote debug))
(lexical-let ((curl-trace (concat temporary-file-directory "curl-trace")))
(nconc request-curl-options `("--trace-ascii" ,curl-trace))
(add-function :after
(add-function :after
(symbol-function 'request--curl-callback)
(lambda (&rest args)
(if (file-readable-p curl-trace)

View file

@ -1,52 +0,0 @@
;;; ein-hy.el --- Hylang Support -*- lexical-binding: t; -*-
;; (C) 2018 - John M. Miller
;; Author: John Miller <millejoh at mac.com>
;; This file is NOT part of GNU Emacs.
;; ein-hy.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-hy.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-hy.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'cl)
(require 'ein-classes)
(cl-defmethod ein:cell-insert-prompt ((cell ein:hy-codecell))
"Insert prompt of the CELL in the buffer.
Called from ewoc pretty printer via `ein:cell-pp'."
;; Newline is inserted in `ein:cell-insert-input'.
(ein:insert-read-only
(concat
(format "In (hy) [%s]" (or (ein:oref-safe cell 'input-prompt-number) " "))
(ein:maybe-show-slideshow-data cell)
(when (slot-value cell 'autoexec) " %s" ein:cell-autoexec-prompt))
'font-lock-face 'ein:cell-input-prompt))
(cl-defmethod ein:cell-execute-internal ((cell ein:hy-codecell)
kernel code &rest args)
(ein:cell-clear-output cell t t t)
(ein:cell-set-input-prompt cell "*")
(ein:cell-running-set cell t)
(setf (slot-value cell 'dynamic) t)
(apply #'ein:kernel-execute kernel (ein:pytools-wrap-hy-code code) (ein:cell-make-callbacks cell) args))
(cl-defmethod ein:cell-to-nb4-json :before ((cell ein:hy-codecell) _ &optional _ignore)
(let ((metadata (slot-value cell 'metadata)))
(setf metadata (plist-put metadata :ein.hycell t))))
(provide 'ein-hy)

View file

@ -1,125 +0,0 @@
;;; -*- mode: emacs-lisp; lexical-binding: t -*-
;;; ein-inspector.el --- An inspector, in emacs, for Python
;; Copyright (C) 2017 - John Miller
;; Authors: Takafumi Arakaki <aka.tkf at gmail.com>
;; John M. Miller <millejoh at mac.com>
;; This file is NOT part of GNU Emacs.
;; ein-inspector.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-inspector.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-inspector.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'ein-pytools)
;;;###autoload
(defun ein:inspect-object (kernel object)
(interactive (list (ein:get-kernel-or-error)
(ein:object-at-point-or-error)))
(ein:kernel-execute kernel
(format "__import__('ein_inspector').generate_inspector_data('%s', globals(), locals())"
object)
(list
:output
(cons #'ein:prepare-inspector
(list kernel object)))))
(defun ein:prepare-inspector (packed _msg-type content _metadata)
(destructuring-bind (_kernel oname)
packed
(ein:aif (or (plist-get content :text) (plist-get content :data))
(let ((oinfo (ein:json-read-from-string it)))
(if (not (plist-get oinfo :type))
(ein:log 'warn "[EIN:INSPECTOR]: %s" (plist-get oinfo :error))
(ein:render-inspector oinfo)))
(ein:log 'warn "[EIN:INSPECTOR]: Could not find inspect data for object %s." oname))))
(defclass ein:iobject ()
((name :accessor ein:iobject-name :documentation "String representation can be evaluated in python to generate the object being inspected.")
(type :accessor ein:iobject-type :documentation "Python type of object, as returned by `type()`.")
(repr :accessor ein:iobject-repr :documentation "Value of object, as returned by its `__str__` method.")
(source-file :accessor ein:iobject-sfile :documentation "If availabe, the filename where the source for this object is to be found.")
(source-lines :accessor ein:iobject-slines :documentation "If available, the line in the file where the source for this object is found.")
(doc :accessor ein:iobject-doc :documentation "If available, the documentation string for this object."))
:documentation "Class to hold information returned by Python `inspect` module for a Python object identified in the `name` slot.")
(defun ein:new-inspector-object (object-info)
(make-instance 'ein:iobject
:name (plist-get object-info :name)
:type (plist-get object-info :type)
:repr (plist-get object-info :repr)
:source-file (plist-get object-info :source_file)
:source-lines (plist-get object-info :source_lines)
:doc (plist-get object-info :doc)))
(defvar ein:inspector-visit-source-map (make-sparse-keymap))
(defvar ein:inspector-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map (make-composed-keymap widget-keymap
special-mode-map))
map)
"Keymap for ein:inspector-mode.")
(define-derived-mode ein:inspector-mode special-mode "EIN:INSPECTOR-MODE"
"Major mode for inspector Python objects from the emacs-ipython-notebook."
)
(defun ein:render-inspector (oinfo)
(let ((name (plist-get oinfo :name)))
(switch-to-buffer (format "*EIN Inspector: %s*" name))
(kill-all-local-variables)
(let ((inhibit-read-only t))
(erase-buffer))
(remove-overlays)
(lexical-let* ((type (plist-get oinfo :type))
(repr (plist-get oinfo :repr))
(sfile (plist-get oinfo :source_file))
(slines (last (plist-get oinfo :source_lines)))
(info-str (format "%s = {%s} %s" name type repr)))
(if sfile
(widget-create 'link
:notify
(lambda (&rest _ignore)
(ein:goto-file sfile (car slines)))
info-str)
(widget-insert (propertize info-str 'face 'bold)))
(widget-insert (format "\n\n%s\n\n" (make-string 80 ?\u2501)))
(widget-insert (format "%s\n\n%s\n\n" (plist-get oinfo :doc) (make-string 80 ?\u2501)))
(widget-insert (propertize (format "%s: %s\n" type name)
'face 'bold))))
(ein:inspector-mode)
(widget-setup))
(defun ein:inspector-visit-source ()
(message "Visit source!"))
(defun ein:inspector-visit-thing ())
(defun ein:inspector-section-toggle (_section))
(defun ein:inspector-section-show (_section))
(defun ein:inspector-section-hide (_section)
)
(provide 'ein-inspector)

View file

@ -213,8 +213,6 @@ the log of the running jupyter server."
(if (numberp port)
`("--port" ,(format "%s" port)
"--port-retries" "0")))))
(when (eql system-type 'windows-nt)
(accept-process-output proc (/ ein:jupyter-server-run-timeout 1000)))
(loop repeat 30
until (car (ein:jupyter-server-conn-info ein:jupyter-server-buffer-name))
do (sleep-for 0 500)
@ -255,19 +253,14 @@ the log of the running jupyter server."
do (ein:query-running-process-table)
until (zerop (hash-table-count ein:query-running-process-table))
do (sleep-for 0 500))
(if (eq system-type 'windows-nt)
(progn
(ein:undocumented-shutdown url-or-port)
(ein:aif (ein:jupyter-server-process)
(delete-process it)))
(lexical-let* ((proc (ein:jupyter-server-process))
(pid (process-id proc)))
(ein:log 'info "Signaled %s with pid %s" proc pid)
(signal-process pid 15)
(run-at-time 2 nil
(lambda ()
(ein:log 'info "Resignaled %s with pid %s" proc pid)
(signal-process pid 15)))))
(lexical-let* ((proc (ein:jupyter-server-process))
(pid (process-id proc)))
(ein:log 'info "Signaled %s with pid %s" proc pid)
(signal-process pid 15)
(run-at-time 2 nil
(lambda ()
(ein:log 'info "Resignaled %s with pid %s" proc pid)
(signal-process pid 15))))
;; `ein:notebooklist-sentinel' frequently does not trigger
(ein:notebooklist-list-remove url-or-port)

View file

@ -41,76 +41,17 @@ in these buffer will be synced with the kernel's cwd.")
(hostname
:initarg :hostname :type string
:documentation "Host name of the machine where the kernel is running on.")
(language
:initarg :language :type string
:accessor ein:kernelinfo-language
:documentation "Language for the running kernel.")
(ccwd
:initarg :ccwd :type string
:documentation "cached CWD (last time checked CWD)."))
:documentation "Info related (but unimportant) to kernel")
(defun ein:kernelinfo-new (kernel get-buffers kernel-language)
(defun ein:kernelinfo-new (kernel get-buffers)
"Make a new `ein:kernelinfo' instance based on KERNEL and GET-BUFFERS."
(let ((kerinfo (make-instance 'ein:kernelinfo)))
(setf (slot-value kerinfo 'kernel) kernel)
(setf (slot-value kerinfo 'get-buffers) get-buffers)
(setf (slot-value kerinfo 'language) kernel-language)
(ein:case-equal kernel-language
("python" (ein:kernelinfo-setup-hooks kerinfo)))
kerinfo))
(defun ein:kernelinfo-setup-hooks (kerinfo)
"Add `ein:kernelinfo-update-*' to `ein:$kernel-after-*-hook'."
(with-slots (kernel) kerinfo
(push (cons #'ein:kernelinfo-update-all kerinfo)
(ein:$kernel-after-start-hook kernel))
(push (cons #'ein:kernelinfo-update-ccwd kerinfo)
(ein:$kernel-after-execute-hook kernel))))
(defun ein:kernelinfo-update-all (kerinfo)
"Update KERINFO slots by triggering all update functions."
(ein:log 'debug "(ein:kernel-live-p kernel) = %S"
(ein:kernel-live-p (slot-value kerinfo 'kernel)))
(ein:kernelinfo-update-ccwd kerinfo)
(ein:kernelinfo-update-hostname kerinfo))
(defun ein:kernelinfo-update-ccwd (kerinfo)
"Update cached current working directory (CCWD) and change
`default-directory' of kernel related buffers."
(let ((ccwd-string (ein:case-equal (ein:kernelinfo-language kerinfo)
(("python") "__import__('sys').stdout.write(__import__('os').getcwd())")
((t) nil))))
(when ccwd-string
(ein:kernel-request-stream
(slot-value kerinfo 'kernel)
ccwd-string
(lambda (cwd kerinfo)
(with-slots (kernel get-buffers) kerinfo
(setq cwd (ein:kernel-filename-from-python kernel cwd))
(oset kerinfo :ccwd cwd)
;; sync buffer's `default-directory' with CWD
(when (file-accessible-directory-p cwd)
(dolist (buffer (ein:funcall-packed get-buffers))
(when (buffer-live-p buffer)
(with-current-buffer buffer
(setq default-directory (file-name-as-directory cwd))))))))
(list kerinfo)))))
(defun ein:kernelinfo-update-hostname (kerinfo)
"Get hostname in which kernel is running and store it in KERINFO."
(let ((hostname-string (ein:case-equal (ein:kernelinfo-language kerinfo)
(("python") "__import__('sys').stdout.write(__import__('socket').gethostname())")
((t) nil))))
(when hostname-string
(ein:kernel-request-stream
(slot-value kerinfo 'kernel)
hostname-string ; "__import__('sys').stdout.write(__import__('socket').gethostname())" ; uname() not available in windows
(lambda (hostname kerinfo)
(oset kerinfo :hostname hostname))
(list kerinfo)))))
(provide 'ein-kernelinfo)
;;; ein-kernelinfo.el ends here

View file

@ -102,10 +102,6 @@ This function may raise an error."
'ein:worksheet-end-of-cell-input)
(ein:ml-set-font-lock-defaults))
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'ein:notebook-multilang-mode))
;;; Language setup functions
(defun ein:ml-narrow-to-cell ()

View file

@ -34,7 +34,6 @@
(eval-when-compile (require 'cl))
(eval-when-compile (require 'auto-complete))
(require 'ewoc)
(require 'mumamo nil t)
@ -50,7 +49,6 @@
(require 'ein-kernel)
(require 'ein-kernelinfo)
(require 'ein-cell)
(require 'ein-cell-edit)
(require 'ein-cell-output)
(require 'ein-worksheet)
(require 'ein-iexec)
@ -65,7 +63,6 @@
(require 'ein-query)
(require 'ein-pytools)
(require 'ein-traceback)
(require 'ein-inspector)
(require 'ein-shared-output)
(require 'ein-notebooklist)
(require 'ein-multilang)
@ -74,51 +71,6 @@
;;; Configuration
(make-obsolete-variable 'ein:notebook-discard-output-on-save nil "0.2.0")
(declare-function ein:smartrep-config "ein-smartrep")
(defcustom ein:use-smartrep nil
"Set to `t' to use preset smartrep configuration.
.. warning:: When used with MuMaMo (see `ein:notebook-modes'),
keyboard macro which manipulates cell (add, remove, move,
etc.) may start infinite loop (you need to stop it with
``C-g``). Please be careful using this option if you are a
heavy keyboard macro user. Using keyboard macro for other
commands is fine.
.. (Comment) I guess this infinite loop happens because the three
modules (kmacro.el, mumamo.el and smartrep.el) touches to
`unread-command-events' in somehow inconsistent ways."
:type 'boolean
:group 'ein)
(defvar *ein:notebook--pending-query* (make-hash-table :test 'equal)
"A map: (URL-OR-PORT . PATH) => t/nil")
(defcustom ein:notebook-autosave-frequency 300
"Sets the frequency (in seconds) at which the notebook is
automatically saved, per IPEP15. Set to 0 to disable this feature.
Autosaves are automatically enabled when a notebook is opened,
but can be controlled manually via `ein:notebook-enable-autosave'
and `ein:notebook-disable-autosave'.
If you wish to change the autosave frequency for the current
notebook call `ein:notebook-update-autosave-freqency'.
"
:type 'number
:group 'ein)
(defcustom ein:notebook-create-checkpoint-on-save t
"If non-nil a checkpoint will be created every time the
notebook is saved. Otherwise checkpoints must be created manually
via `ein:notebook-create-checkpoint'."
:type 'boolean
:group 'ein)
(defcustom ein:notebook-discard-output-on-save 'no
"Configure if the output part of the cell should be saved or not.
@ -140,6 +92,16 @@ a function
(const :tag "Yes" 'yes)
)
:group 'ein)
(make-obsolete-variable 'ein:use-smartrep nil "0.17.0")
(defvar *ein:notebook--pending-query* (make-hash-table :test 'equal)
"A map: (URL-OR-PORT . PATH) => t/nil")
(make-obsolete-variable 'ein:notebook-autosave-frequency nil "0.17.0")
(make-obsolete-variable 'ein:notebook-create-checkpoint-on-save nil "0.17.0")
(make-obsolete-variable 'ein:notebook-discard-output-on-save nil "0.17.0")
(defun ein:notebook-cell-has-image-output-p (-ignore- cell)
(ein:cell-has-image-ouput-p cell))
@ -405,11 +367,11 @@ where `created' indicates a new notebook or an existing one.
(add-function :before errback pending-clear)
(ein:content-query-contents url-or-port path
(apply-partially #'ein:notebook-open--callback
notebook callback0 (not no-pop))
notebook callback0)
errback))))
notebook))
(defun ein:notebook-open--callback (notebook callback0 q-checkpoints content)
(defun ein:notebook-open--callback (notebook callback0 content)
(ein:log 'verbose "Opened notebook %s" (ein:$notebook-notebook-path notebook))
(let ((notebook-path (ein:$notebook-notebook-path notebook)))
(ein:gc-prepare-operation)
@ -433,12 +395,9 @@ where `created' indicates a new notebook or an existing one.
(ein:$notebook-notebook-name notebook)))
(setf (ein:$notebook-kernelinfo notebook)
(ein:kernelinfo-new (ein:$notebook-kernel notebook)
(cons #'ein:notebook-buffer-list notebook)
(symbol-name (ein:get-mode-for-kernel (ein:$notebook-kernelspec notebook)))))
(cons #'ein:notebook-buffer-list notebook)))
(ein:notebook-put-opened-notebook notebook)
(ein:notebook--check-nbformat (ein:$content-raw-content content))
(setf (ein:$notebook-q-checkpoints notebook) q-checkpoints)
(ein:notebook-enable-autosaves notebook)
(ein:gc-complete-operation))))
(defun ein:notebook-maybe-set-kernelspec (notebook content-metadata)
@ -478,56 +437,6 @@ of minor mode."
;;; Initialization.
(defun ein:notebook-enable-autosaves (notebook)
"Enable automatic, periodic saving for notebook."
(interactive
(list (or (ein:get-notebook)
(ein:aand (ein:notebook-opened-buffer-names)
(with-current-buffer (ein:completing-read
"Notebook: " it nil t)
(ein:get-notebook))))))
(when (and (ein:$notebook-q-checkpoints notebook)
(> ein:notebook-autosave-frequency 0))
(setf (ein:$notebook-autosave-timer notebook)
(run-at-time ein:notebook-autosave-frequency
ein:notebook-autosave-frequency
#'ein:notebook-maybe-save-notebook
notebook))
(ein:log 'verbose "Enabling autosaves for %s with frequency %s seconds."
(ein:$notebook-notebook-name notebook)
ein:notebook-autosave-frequency)))
(defun ein:notebook-disable-autosaves (notebook)
"Disable automatic, periodic saving for current notebook."
(interactive
(list (or (ein:get-notebook)
(ein:aand (ein:notebook-opened-buffer-names)
(with-current-buffer (ein:completing-read
"Notebook: " it nil t)
(ein:get-notebook))))))
(if (and notebook (ein:$notebook-autosave-timer notebook))
(progn
(ein:log 'verbose "Disabling auto checkpoints for notebook %s" (ein:$notebook-notebook-name notebook))
(cancel-timer (ein:$notebook-autosave-timer notebook)))))
(defun ein:notebook-update-autosave-frequency (new-frequency notebook)
"Change the autosaves frequency for the current notebook, or
for a notebook selected by the user if not currently inside a
notebook buffer."
(interactive
(list (read-number "New autosaves frequency (0 to disable): ")
(or (ein:get-notebook)
(ein:aand (ein:notebook-opened-buffer-names)
(with-current-buffer (ein:completing-read
"Notebook: " it nil t)
(ein:get-notebook))))))
(if notebook
(progn
(setq ein:notebook-autosave-frequency new-frequency)
(ein:notebook-disable-autosaves notebook)
(ein:notebook-enable-autosaves notebook))
(message "Open notebook first")))
(defun ein:notebook-bind-events (notebook events)
"Bind events related to PAGER to the event handler EVENTS."
(setf (ein:$notebook-events notebook) events)
@ -607,9 +516,7 @@ notebook buffer then the user will be prompted to select an opened notebook."
base-url
(ein:$notebook-events notebook)
(ein:$notebook-api-version notebook))))
(setf (ein:$notebook-kernel notebook) kernel)
(when (eq (ein:get-mode-for-kernel (ein:$notebook-kernelspec notebook)) 'python)
(ein:pytools-setup-hooks kernel notebook))))
(setf (ein:$notebook-kernel notebook) kernel)))
(defun ein:notebook-reconnect-session-command ()
"It seems convenient but undisciplined to blithely create a new session if the original one no longer exists."
@ -628,14 +535,6 @@ notebook buffer then the user will be prompted to select an opened notebook."
'ein:notebook-request-tool-tip-or-help-command
'ein:pytools-request-tooltip-or-help "0.1.2")
(defun ein:notebook-ac-dot-complete ()
"Insert dot and request completion."
(interactive)
(if (and (ein:get-notebook)
(ein:codecell-p (ein:get-cell-at-point)))
(call-interactively #'ein:ac-dot-complete)
(insert ".")))
(defun ein:notebook-kernel-interrupt-command ()
"Interrupt the kernel.
This is equivalent to do ``C-c`` in the console program."
@ -888,8 +787,6 @@ This is equivalent to do ``C-c`` in the console program."
(ein:$notebook-worksheets notebook))
(ein:events-trigger (ein:$notebook-events notebook)
'notebook_saved.Notebook)
(when ein:notebook-create-checkpoint-on-save
(ein:notebook-create-checkpoint notebook))
(when callback
(apply callback cbargs)))
@ -1041,48 +938,6 @@ notebook worksheets."
:type "notebook"
:notebook-version (ein:$notebook-api-version notebook)))
(defun ein:notebook-create-checkpoint (notebook)
"Create checkpoint for current notebook based on most recent save."
(interactive (list (ein:get-notebook)))
(if (ein:$notebook-q-checkpoints notebook)
(ein:content-create-checkpoint
(ein:fast-content-from-notebook notebook)
(lexical-let ((notebook notebook))
#'(lambda (content)
(ein:log 'verbose "Checkpoint %s for %s generated."
(plist-get (first (ein:$content-checkpoints content)) :id)
(ein:$notebook-notebook-name notebook))
(setf (ein:$notebook-checkpoints notebook)
(ein:$content-checkpoints content)))))))
(defun ein:notebook-list-checkpoint-ids (notebook)
(unless (ein:$notebook-checkpoints notebook)
(ein:content-query-checkpoints (ein:fast-content-from-notebook notebook)
(lexical-let ((notebook notebook))
#'(lambda (content)
(setf (ein:$notebook-checkpoints notebook)
(ein:$content-checkpoints content)))))
(sleep-for 0.5))
(loop for cp in (ein:$notebook-checkpoints notebook)
collecting (plist-get cp :last_modified)))
(defun ein:notebook-restore-to-checkpoint (notebook checkpoint)
"Restore notebook to previous checkpoint saved on the Jupyter
server. Note that if there are multiple checkpoints the user will
be prompted on which one to use."
(interactive
(let* ((notebook (ein:get-notebook))
(checkpoint (ein:completing-read
"Select checkpoint: "
(ein:notebook-list-checkpoint-ids notebook))))
(list notebook checkpoint)))
(ein:content-restore-checkpoint (ein:fast-content-from-notebook notebook)
checkpoint)
(ein:notebook-close notebook)
(ein:notebook-open (ein:$notebook-url-or-port notebook)
(ein:$notebook-notebook-path notebook)))
;;; Worksheet
(defmacro ein:notebook--worksheet-render-new (notebook type)
@ -1466,10 +1321,6 @@ Use simple `python-mode' based notebook mode when MuMaMo is not installed::
(defvar ein:notebook-mode-map (make-sparse-keymap))
(with-eval-after-load "ein-smartrep"
(ein:smartrep-config ein:notebook-mode-map))
(defmacro ein:notebook--define-key (keymap key defn)
"Ideally we could override just the keymap binding with a (string . wrapped) cons pair (as opposed to messing with the DEFN itself), but then describe-minor-mode unhelpfully shows ?? for the keymap commands."
`(progn
@ -1480,8 +1331,6 @@ Use simple `python-mode' based notebook mode when MuMaMo is not installed::
(define-key ,keymap ,key ,defn)))
(let ((map ein:notebook-mode-map))
(ein:notebook--define-key map "\C-ci" 'ein:inspect-object)
(ein:notebook--define-key map "\C-c'" 'ein:edit-cell-contents)
(ein:notebook--define-key map "\C-c\C-c" 'ein:worksheet-execute-cell)
(ein:notebook--define-key map (kbd "M-RET") 'ein:worksheet-execute-cell-and-goto-next)
(ein:notebook--define-key map (kbd "<M-S-return>")
@ -1582,8 +1431,7 @@ Use simple `python-mode' based notebook mode when MuMaMo is not installed::
)))
("Cell/Code"
,@(ein:generate-menu
'(("Edit cell contents in dedicated buffer" ein:edit-cell-contents)
("Execute cell" ein:worksheet-execute-cell
'(("Execute cell" ein:worksheet-execute-cell
:active (ein:worksheet-at-codecell-p))
("Execute cell and go to next"
ein:worksheet-execute-cell-and-goto-next
@ -1694,28 +1542,12 @@ watch the fireworks!"
;; It is executed after toggling the mode, and before running MODE-hook.
(when ein:notebook-mode
(case ein:completion-backend
(ein:use-ac-backend
(ein:notebook--define-key ein:notebook-mode-map "." 'ein:notebook-ac-dot-complete)
(auto-complete-mode))
(ein:use-company-backend
(if (not (boundp 'company-backends))
(error "ein:connect-mode: company unsupported")
(cl-assert (member 'ein:company-backend company-backends))
(ein:notebook--define-key ein:notebook-mode-map "." nil)
(company-mode))))
(ein:aif ein:helm-kernel-history-search-key
(ein:notebook--define-key ein:notebook-mode-map it 'helm-ein-kernel-history))
(ein:aif ein:anything-kernel-history-search-key
(ein:notebook--define-key ein:notebook-mode-map it 'anything-ein-kernel-history))
(setq indent-tabs-mode nil) ;; Being T causes problems with Python code.
(when (and (featurep 'eldoc) ein:enable-eldoc-support)
(add-function :before-until (local 'eldoc-documentation-function)
#'ein:completer--get-eldoc-signature)
(eldoc-mode))
(ein:worksheet-imenu-setup)
(when ein:use-smartrep
(require 'ein-smartrep))))
(ein:worksheet-imenu-setup)))
;; To avoid MuMaMo to discard `ein:notebook-mode', make it
;; permanent local.
@ -1790,7 +1622,6 @@ the first argument and CBARGS as the rest of arguments."
;; nor `ein:notebook-close' updates ein:notebook--opened-map
(ein:log 'debug "ein:notebook-kill-buffer-callback called")
(when (ein:$notebook-p ein:%notebook%)
(ein:notebook-disable-autosaves ein:%notebook%)
(ein:notebook-close-worksheet ein:%notebook% ein:%worksheet%)))
(defun ein:notebook-setup-kill-buffer-hook ()

View file

@ -35,8 +35,6 @@
(require 'ein-file)
(require 'ein-contents-api)
(require 'ein-subpackages)
(require 'ein-ac)
(require 'ein-company)
(require 'deferred)
(require 'dash)
(require 'ido)
@ -51,10 +49,9 @@
(defcustom ein:notebooklist-render-order
'(render-header
render-opened-notebooks
render-directory)
"Order of notebook list sections.
Must contain render-header, render-opened-notebooks, and render-directory."
Must contain render-header, and render-directory."
:group 'ein
:type 'list
)
@ -623,33 +620,6 @@ This function is called via `ein:notebook-after-rename-hook'."
(symbol-name ein:jupyter-default-kernel))))
(widget-insert "\n"))))))
(defun render-opened-notebooks (url-or-port &rest args)
"Render the opened notebooks section (for ipython>=3)."
;; Opened Notebooks Section
(with-current-buffer (ein:notebooklist-get-buffer url-or-port)
(widget-insert "\n---------- All Opened Notebooks ----------\n\n")
(loop for buffer in (ein:notebook-opened-buffers)
do (progn (widget-create
'link
:notify (lexical-let ((buffer buffer))
(lambda (&rest ignore)
(condition-case err
(switch-to-buffer buffer)
(error
(message "%S" err)
(ein:notebooklist-reload)))))
"Open")
(widget-create
'link
:notify (lexical-let ((buffer buffer))
(lambda (&rest ignore)
(if (buffer-live-p buffer)
(kill-buffer buffer))
(run-at-time 1 nil #'ein:notebooklist-reload)))
"Close")
(widget-insert " : " (buffer-name buffer))
(widget-insert "\n")))))
(defun ein:format-nbitem-data (name last-modified)
(let ((dt (date-to-time last-modified)))
(format "%-40s%+20s" name
@ -935,62 +905,6 @@ and the url-or-port argument of ein:notebooklist-open*."
(ein:notebooklist-login--success-1 url-or-port callback errback))
(t (ein:notebooklist-login--error-1 url-or-port error-thrown response errback))))
;;;###autoload
(defun ein:notebooklist-change-url-port (new-url-or-port)
"Update the ipython/jupyter notebook server URL for all the
notebooks currently opened from the current notebooklist buffer.
This function works by calling `ein:notebook-update-url-or-port'
on all the notebooks opened from the current notebooklist."
(interactive (list (ein:notebooklist-ask-url-or-port)))
(unless (eql major-mode 'ein:notebooklist-mode)
(error "This command needs to be called from within a notebooklist buffer."))
(let* ((current-nblist ein:%notebooklist%)
(old-url (ein:$notebooklist-url-or-port current-nblist))
(new-url-or-port new-url-or-port)
(open-nb (ein:notebook-opened-notebooks #'(lambda (nb)
(equal (ein:$notebook-url-or-port nb)
(ein:$notebooklist-url-or-port current-nblist))))))
(ein:notebooklist-open* new-url-or-port)
(loop for x upfrom 0 by 1
until (or (get-buffer (format ein:notebooklist-buffer-name-template new-url-or-port))
(= x 100))
do (sit-for 0.1))
(dolist (nb open-nb)
(ein:notebook-update-url-or-port new-url-or-port nb))
(kill-buffer (ein:notebooklist-get-buffer old-url))
(ein:notebooklist-open* new-url-or-port nil nil nil (lambda (buffer url-or-port)
(pop-to-buffer buffer)))))
(defun ein:notebooklist-change-url-port--deferred (new-url-or-port)
(lexical-let* ((current-nblist ein:%notebooklist%)
(old-url (ein:$notebooklist-url-or-port current-nblist))
(new-url-or-port new-url-or-port)
(open-nb (ein:notebook-opened-notebooks
(lambda (nb)
(equal (ein:$notebook-url-or-port nb)
(ein:$notebooklist-url-or-port current-nblist))))))
(deferred:$
(deferred:next
(lambda ()
(ein:notebooklist-open* new-url-or-port)
(loop until (get-buffer (format ein:notebooklist-buffer-name-template new-url-or-port))
do (sit-for 0.1))))
(deferred:nextc it
(lambda ()
(dolist (nb open-nb)
(ein:notebook-update-url-or-port new-url-or-port nb))))
(deferred:nextc it
(lambda ()
(kill-buffer (ein:notebooklist-get-buffer old-url))
(ein:notebooklist-open* new-url-or-port nil nil nil (lambda (buffer url-or-port)
(pop-to-buffer buffer))))))))
;;; Generic getter
(defun ein:get-url-or-port--notebooklist ()
(when (ein:$notebooklist-p ein:%notebooklist%)
(ein:$notebooklist-url-or-port ein:%notebooklist%)))

View file

@ -74,13 +74,6 @@ where NS is `:kernel' or `:notebook' slot of NOTIFICATION."
st ; = event-type
#'ein:notification--callback
(cons ns st))))
(ein:events-on events
'notebook_checkpoint_created.Notebook
#'ein:notification--fadeout-callback
(list (slot-value notification 'notebook)
"Checkpoint created."
'notebook_checkpoint_created.Notebook
nil))
(ein:events-on events
'notebook_saved.Notebook
#'ein:notification--fadeout-callback
@ -320,16 +313,6 @@ Generated by `ein:header-line-define-mouse-commands'" slot)
(ein:notification-tab-create-line
(slot-value ein:%notification% 'tab)))))))
(defun ein:header-line-setup-maybe ()
"Setup `header-line-format' for mumamo.
As `header-line-format' is buffer local variable, it must be set
for each chunk when in
See also `ein:ac-setup-maybe'."
(and (ein:eval-if-bound 'ein:notebook-mode)
(ein:eval-if-bound 'mumamo-multi-major-mode)
(setq header-line-format ein:header-line-format)))
(add-hook 'after-change-major-mode-hook 'ein:header-line-setup-maybe)
(provide 'ein-notification)
;;; ein-notification.el ends here

View file

@ -3,11 +3,9 @@
"Emacs IPython Notebook"
'((emacs "25")
(websocket "20190620.338")
(auto-complete "1.4.0")
(request "20190621.1622")
(deferred "0.5")
(polymode "20190426.1729")
(markdown-mode "20171116.756")
(dash "2.13.0")
(s "1.11.0")
(skewer-mode "1.6.2")))
(s "1.11.0")))

View file

@ -1,82 +0,0 @@
;;; ein-python.el --- Workarounds for python.el
;; Copyright (C) 2012 Takafumi Arakaki
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
;; This file is NOT part of GNU Emacs.
;; ein-python.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.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.el.
;; If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'python)
(require 'ein-worksheet)
(defvar ein:python-block-start
(rx line-start
symbol-start
(or "def" "class" "if" "elif" "else" "try"
"except" "finally" "for" "while" "with")
symbol-end))
(defun ein:python-indent-calculate-indentation--around (orig &rest args)
"False if there is no python block yet in this cell."
(condition-case _
(ein:and-let* ((cell (ein:worksheet-get-current-cell))
(beg (ein:cell-input-pos-min cell))
(p (point))
((< beg (point))))
(if (not (search-backward-regexp ein:python-block-start beg t))
0
(goto-char p)
(apply orig args)))
(error (apply orig args))))
(advice-add 'python-indent--calculate-indentation :around #'ein:python-indent-calculate-indentation--around)
;; (defadvice python-indent-calculate-indentation
;; (around ein:python-indent-calculate-levels activate)
;; "Hack `python-indent-calculate-levels' to reset indent per cell.
;; Let's say you have a notebook something like this::
;; In [1]:
;; def func():
;; pass
;; In [2]:
;; something[]
;; Here, ``[]`` is the cursor position. When you hit the tab here,
;; you don't expect it to indent. However, python.el tries to follow
;; the indent of ``func()`` then you get indentation. This advice
;; workaround this problem.
;; Note that this workaround does not work with the MuMaMo based
;; notebook mode."
;; (if (ein:ein-block-start-p)
;; ad-do-it
;; 0))
(provide 'ein-python)
;;; ein-python.el ends here

View file

@ -56,9 +56,6 @@ If OTHER-WINDOW is non-`nil', open the file in the other window."
(push (cons #'ein:pytools-load-safely kernel)
(ein:$kernel-after-start-hook kernel)))
(defun ein:pytools-wrap-hy-code (code)
(format "__import__('hy').eval(__import__('hy').read_str('''%s'''))" code))
(defun ein:pytools-load-safely (kernel)
(with-temp-buffer
(let ((pytools-file (format "%s/%s" ein:source-dir "ein_remote_safe.py")))

View file

@ -1,98 +0,0 @@
;;; -*- mode: emacs-lisp; lexical-binding: t; -*-
;;; ein-skewer.el --- Cell module
;; (C) 2016 - John M Miller
;; Author: John M Miller <millejoh at mac.com>
;; This file is NOT part of GNU Emacs.
;; ein-skewer.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-skewre.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-cell.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This depends on the skewer package, so likely will get split into
;; its own package at some point.
;;; Code:
(require 'skewer-mode)
(require 'skewer-html)
(require 'simple-httpd)
(defvar *ein:skewer-running-p* nil "True if the emacs httpd server has been started.")
(defun ein:js-prepare-result (result type)
(list :output_type type :text result))
(defun ein:update-javascript-output (cell json result)
(let ((val (ein:js-prepare-result
(or (cdr (assoc 'value result)) "See browser for result.")
(plist-get json :output_type))))
(setf (slot-value cell 'outputs) (list val))
(ein:cell-append-output cell val (slot-value cell 'dynamic))))
(defservlet current-jupyter-cell-output text/html (path)
(let ((cell-id (file-name-nondirectory path)))
(insert (gethash cell-id *ein:skewer-cell-output-cache*))))
(defvar *ein:skewer-html-template*
"<html>
<head>
<title>Emacs IPython Notebook</title>
<script src=\"/skewer\"></script>
</head>
<body>
%s
</body>
</html>")
(defvar *ein:skewer-cell-output-cache* (make-hash-table :test #'equal))
(defun ein:skewer--handle-html (cell string)
(setf (gethash (slot-value cell 'cell-id) *ein:skewer-cell-output-cache*)
(format *ein:skewer-html-template* string) ))
;; Format of result is ((id . STR) (type . STR) (status . STR) (value . STR) (time . FLOAT))
(defun ein:execute-javascript (cell json)
(unless (httpd-running-p) ;; *ein:skewer-running-p*
(run-skewer))
(deferred:$
(deferred:next
(lambda ()
(let ((result nil))
(ein:aif (plist-get json :html)
(progn
(let ((cell-id (slot-value cell 'cell-id)))
(ein:skewer--handle-html cell it)
(setq result (list '(id . nil)
'(type . str)
'(stats . nil)
(cons 'value (format "Open http://localhost:8080/current-jupyter-cell-output/%s" cell-id))
'(time . nil)))
(browse-url (format "http://localhost:8080/current-jupyter-cell-output/%s" cell-id))))
(skewer-eval (plist-get json :javascript)
(lambda (v)
(setq result v))
:type (if (plist-get json :html)
"html"
"eval")))
(cl-loop until result
do (accept-process-output nil 0.01)
finally (return result)))))
(deferred:nextc it
(lambda (result)
(ein:update-javascript-output cell json result)))))
(provide 'ein-skewer)

View file

@ -1,55 +0,0 @@
;;; ein-smartrep.el --- smartrep integration
;; Copyright (C) 2012- Takafumi Arakaki
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
;; This file is NOT part of GNU Emacs.
;; ein-smartrep.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-smartrep.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-smartrep.el. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'smartrep nil t)
(defcustom ein:smartrep-notebook-mode-alist
'(("C-t" . ein:worksheet-toggle-cell-type)
("C-l" . ein:worksheet-clear-output)
("C-k" . ein:worksheet-kill-cell)
("C-y" . ein:worksheet-yank-cell)
("C-a" . ein:worksheet-insert-cell-above)
("C-b" . ein:worksheet-insert-cell-below)
("C-n" . ein:worksheet-goto-next-input)
("C-p" . ein:worksheet-goto-prev-input)
("C-m" . ein:worksheet-merge-cell)
("<up>" . ein:worksheet-move-cell-up)
("<down>" . ein:worksheet-move-cell-down))
"alist passed to `smartrep-define-key'."
:type '(repeat (cons string function))
:group 'ein)
(when (fboundp 'smartrep-define-key)
(defmacro ein:smartrep-config (map)
`(smartrep-define-key
,map
"C-c"
ein:smartrep-notebook-mode-alist)))
(provide 'ein-smartrep)
;;; ein-smartrep.el ends here

View file

@ -31,13 +31,9 @@
"EIN defaults to your individual company-mode or auto-complete-mode configuration. Change this setting to gather completions from the jupyter server::
* ein:use-none-backend: local completions only (configured outside EIN)
* ein:use-company-backend: company-style remote completions (elpy takes precedence)
* ein:use-ac-backend: deprecated auto-complete remote completions
"
:type '(choice
(const ein:use-none-backend)
(const ein:use-company-backend)
(const ein:use-ac-backend))
(const ein:use-none-backend))
:group 'ein)
(provide 'ein-subpackages)

View file

@ -666,7 +666,6 @@ Use `ein:log' for debugging and logging."
(defun ein:get-docstring (function)
"Return docstring of FUNCTION."
;; Borrowed from `ac-symbol-documentation'.
(with-temp-buffer
;; import help-xref-following
(require 'help-mode)

View file

@ -795,7 +795,7 @@ directly."
Prompt will appear in the minibuffer.
When used in as a Lisp function, TYPE (string) should be chose
from \"code\", \"hy-code\", \"markdown\", \"raw\" and \"heading\". LEVEL is
from \"code\", \"markdown\", \"raw\" and \"heading\". LEVEL is
an integer used only when the TYPE is \"heading\"."
(interactive
(let* ((ws (ein:worksheet--get-ws-or-error))
@ -808,7 +808,6 @@ an integer used only when the TYPE is \"heading\"."
(format "Cell type [%s]: " choices) choices))
(type (case key
(?c "code")
(?h "hy-code")
(?m "markdown")
(?r "raw")
(t "heading")))
@ -1173,13 +1172,6 @@ in the history."
(defun ein:get-kernel--worksheet ()
(when (ein:worksheet-p ein:%worksheet%) (slot-value ein:%worksheet% 'kernel)))
;; in edit-cell-mode, worksheet is bound as src--ws
;; used by ein:get-kernel as a last option so completion, tooltips
;; work in edit-cell-mode
(defun ein:get-kernel--worksheet-in-edit-cell ()
"Get kernel when in edit-cell-mode."
(when (ein:worksheet-p ein:src--ws) (slot-value ein:src--ws 'kernel)))
(defun ein:get-cell-at-point--worksheet ()
(ein:worksheet-get-current-cell :noerror t))

View file

@ -1,46 +0,0 @@
"""
Python utilities for the ein inspector.
Copyright (C) 2017- John M. Miller
Author: John Miller <millejoh at gmail.com>
ein_inspector.py 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_inspector.py 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_inspector.py. If not, see <http://www.gnu.org/licenses/>.
"""
import json
import inspect
def generate_inspector_data(obj_str, globals, locals):
odata = {'name': obj_str}
try:
obj = eval(obj_str, globals, locals)
except NameError:
odata['error'] = 'Object {} not found.'.format(obj_str)
else:
odata['doc'] = inspect.getdoc(obj)
odata['type'] = str(type(obj))
odata['repr'] = str(obj)
try:
odata['source_file'] = inspect.getsourcefile(obj)
odata['source_lines'] = inspect.getsourcelines(obj)
except:
odata['source_file'] = None
odata['source_lines'] = None
print(json.dumps(odata))
return odata

View file

@ -1,120 +0,0 @@
"""
Python utilities to use it from ein.el
Copyright (C) 2012- Takafumi Arakaki
Author: Takafumi Arakaki <aka.tkf at gmail.com>
ein.py 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.py 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.py. If not, see <http://www.gnu.org/licenses/>.
"""
def __ein_export_nb(nb_json, format):
import IPython.nbconvert as nbconvert
import IPython.nbformat as nbformat
nb = nbformat.reads(nb_json, nbformat.NO_CONVERT)
output = nbconvert.export_by_name(format, nb)
print(output[0])
def __ein_find_edit_target_012(*args, **kwds):
from IPython.core.interactiveshell import InteractiveShell
inst = InteractiveShell.instance()
return inst._find_edit_target(*args, **kwds)
def __ein_find_edit_target_013(*args, **kwds):
from IPython.core.interactiveshell import InteractiveShell
inst = InteractiveShell.instance()
return CodeMagics._find_edit_target(inst, *args, **kwds)
def __ein_find_edit_target_python(name):
from inspect import getsourcefile, getsourcelines
try:
obj = eval(name)
except NameError:
return False
else:
sfile = getsourcefile(obj)
sline = getsourcelines(obj)[-1]
if sfile and sline:
return(sfile, sline, False)
else:
return False
try:
from IPython.core.magics import CodeMagics
__ein_find_edit_target = __ein_find_edit_target_013
except ImportError:
__ein_find_edit_target = __ein_find_edit_target_012
def __ein_set_figure_size(*dim):
try:
from matplotlib.pyplot import rcParams
rcParams['figure.figsize'] = dim
except:
raise RuntimeError("Matplotlib not installed in this instance of python!")
def __ein_find_source(name):
"""Given an object as string, `name`, print its place in source code."""
# FIXME: use JSON display object instead of stdout
ret = __ein_find_edit_target_python(name) or __ein_find_edit_target(name, {}, [])
if ret:
(filename, lineno, use_temp) = ret
if not use_temp:
print(filename)
print(lineno)
return
raise RuntimeError("Source code for {0} cannot be found".format(name))
def __ein_run_docstring_examples(obj, verbose=True):
from IPython.core.interactiveshell import InteractiveShell
import doctest
inst = InteractiveShell.instance()
globs = inst.user_ns
return doctest.run_docstring_examples(obj, globs, verbose=verbose)
def __ein_maybe_undefined_object(obj, locals=None):
try:
return eval(obj, None, locals)
except Exception:
return None
except SyntaxError:
return None
def __ein_print_object_info_for(obj):
import IPython.core.oinspect
import json
inspector = IPython.core.oinspect.Inspector()
try:
print(json.dumps(inspector.info(obj)))
except Exception:
print(json.dumps(inspector.info(None)))
def __ein_eval_hy_string(obj):
try:
import hy
except ImportError:
print("Hy not supported in this kernel. Execute `pip install hy` if you want this support.")
expr = hy.read_str(obj)
ret = hy.eval(expr)
return ret

View file

@ -70,8 +70,7 @@
("ein-python" . python)
("ein-R" . R)
("ein-r" . R)
("ein-julia" . julia)
("ein-hy" . hy))
("ein-julia" . julia))
"ob-ein has knowledge of these (ein-LANG . LANG-MODE) pairs."
:type '(repeat (cons string symbol))
:group 'ein)
@ -162,8 +161,7 @@ Based on ob-ipython--configure-kernel."
(fset (intern (concat "org-babel-execute:" lang-name))
`(lambda (body params)
(require (quote ,(intern (format "ob-%s" lang-mode))) nil t)
(if (boundp 'python-indent-guess-indent-offset-verbose)
(setq python-indent-guess-indent-offset-verbose nil))
(custom-set-variables '(python-indent-guess-indent-offset-verbose nil))
(let* ((parser
(quote
,(intern
@ -366,53 +364,6 @@ if necessary. Install CALLBACK (i.e., cell execution) upon notebook retrieval."
(t (url-port parsed-url)))))))
(t (ein:notebooklist-login url-or-port callback-login)))))
(defun ob-ein--edit-ctrl-c-ctrl-c ()
"C-c C-c mapping in ein:connect-mode-map."
(interactive)
(if (not (org-src-edit-buffer-p))
(ein:connect-run-buffer)
(org-edit-src-save)
(when (boundp 'org-src--beg-marker)
(let* ((beg org-src--beg-marker)
(buf (marker-buffer beg)))
(with-current-buffer buf
(save-excursion
(goto-char beg)
(org-ctrl-c-ctrl-c)))))))
(defcustom ob-ein-babel-edit-polymode-ignore nil
"When false override default python mode key mapping for `\C-c\C-c' while inside a babel edit buffer.
Instead the binding will be to `ob-ein--edit-ctrl-c-ctrl-c', which will execute the code block being edited."
:group 'ein
:type '(boolean))
(defun org-babel-edit-prep:ein (babel-info)
(if (and ein:polymode (not ob-ein-babel-edit-polymode-ignore))
(progn
(use-local-map (copy-keymap python-mode-map))
(local-set-key "\C-c\C-c" 'ob-ein--edit-ctrl-c-ctrl-c))
(let* ((buffer (current-buffer))
(processed-parameters (nth 2 babel-info))
(session (or (ein:aand (cdr (assoc :session processed-parameters))
(unless (string= "none" it)
(format "%s" it)))
ein:url-localhost))
(lang "ein-python")
(kernelspec (or (cdr (assoc :kernelspec processed-parameters))
(ein:aif (cdr (assoc lang org-src-lang-modes))
(cons 'language (format "%s" it))
(error "ob-ein--execute-body: %s not among %s"
lang (mapcar #'car org-src-lang-modes))))))
(ob-ein--initiate-session
session
kernelspec
(lambda (notebook)
(ein:connect-buffer-to-notebook notebook buffer t)
(define-key ein:connect-mode-map "\C-c\C-c" 'ob-ein--edit-ctrl-c-ctrl-c))))))
(defun org-babel-edit-prep:ein-python (babel-info)
(org-babel-edit-prep:ein babel-info))
(loop for (lang . mode) in ob-ein-languages
do (ob-ein--babelize-lang lang mode))

View file

@ -4,7 +4,7 @@
(declare-function polymode-inhibit-during-initialization "polymode-core")
(defcustom ein:polymode nil
(defcustom ein:polymode t
"When enabled ein will use polymode to provide multi-major mode
support in a notebook buffer, otherwise ein's custom and outdated
multi-major mode support will be used. Emacs must be restarted
@ -181,15 +181,14 @@ TYPE can be 'body, nil."
(error (message "%s: defaulting language to python"
(error-message-string err))
"python")))
(mode
(pm-get-mode-symbol-from-name
(cond ((ein:codecell-p cell) lang)
((ein:markdowncell-p cell) "markdown")
(t "fundamental"))))
(what (cond ((ein:codecell-p cell) lang)
((ein:markdowncell-p cell) "markdown")
(t "fundamental")))
(mode (pm-get-mode-symbol-from-name what))
((not (equal mode (ein:oref-safe cm :mode)))))
(when (eq mode 'poly-fallback-mode)
(ein:display-warning
(format "pm:get-span: no major mode for kernelspec language '%s'" lang)))
(format "pm:get-span: no major mode for kernelspec language '%s'" what)))
(setq result-cm
(loop for ocm in (eieio-oref pm/polymode '-auto-innermodes)
when (equal mode (ein:oref-safe ocm :mode))

View file

@ -1,132 +0,0 @@
* Tests
This is a [[ipynb:(:url-or-port%20"http://localhost:8888"%20:name%20"emacs-ipython-notebook/The%20Emacs%20IPython%20Notebook.ipynb")][link]] to an ein notebook. It might not work if your setup is not the same as mine!
Note that code is executed asynchronously, so executing the following won't
block Emacs. You can even queue up a number of source code blocks and they will
execute sequentially as the previous finishes execution!
#+NAME: 6d0ec9b7-249c-46e9-bdf1-c48b7bcf7fbd
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb
import sys
import time
time.sleep(10)
print("Hello dood!")
#+END_SRC
#+RESULTS: 6d0ec9b7-249c-46e9-bdf1-c48b7bcf7fbd
: Hello dood!
#+NAME: 744c7889-aec1-495f-9d07-6efc17329e94
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb
1+4
#+END_SRC
#+RESULTS: 744c7889-aec1-495f-9d07-6efc17329e94
: 5
Tracebacks will be printed out, but if you want to use ein's traceback and
debugging support you have to jump to the ~*ein:shared-output*~ buffer for
traceback support or the notebook running the session and execute ~%debug~ in a
cell there.
#+NAME: 47c36fa5-1b53-413b-8f5b-814f1ae66a3b
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results output drawer
1/0
#+END_SRC
#+RESULTS: 47c36fa5-1b53-413b-8f5b-814f1ae66a3b
:results:
ZeroDivisionErrorTraceback (most recent call last)
<ipython-input-23-9e1622b385b6> in <module>
----> 1 1/0
ZeroDivisionError: division by zero
:end:
#+NAME: 00052904-6ca5-46e0-9797-c6039d0daf5e
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results output drawer
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
x = np.linspace(0, 1, 100)
y = np.random.rand(100,1)
plt.plot(x,y)
x
#+END_SRC
#+RESULTS: 00052904-6ca5-46e0-9797-c6039d0daf5e
:results:
array([0. , 0.01010101, 0.02020202, 0.03030303, 0.04040404,
0.05050505, 0.06060606, 0.07070707, 0.08080808, 0.09090909,
0.1010101 , 0.11111111, 0.12121212, 0.13131313, 0.14141414,
0.15151515, 0.16161616, 0.17171717, 0.18181818, 0.19191919,
0.2020202 , 0.21212121, 0.22222222, 0.23232323, 0.24242424,
0.25252525, 0.26262626, 0.27272727, 0.28282828, 0.29292929,
0.3030303 , 0.31313131, 0.32323232, 0.33333333, 0.34343434,
0.35353535, 0.36363636, 0.37373737, 0.38383838, 0.39393939,
0.4040404 , 0.41414141, 0.42424242, 0.43434343, 0.44444444,
0.45454545, 0.46464646, 0.47474747, 0.48484848, 0.49494949,
0.50505051, 0.51515152, 0.52525253, 0.53535354, 0.54545455,
0.55555556, 0.56565657, 0.57575758, 0.58585859, 0.5959596 ,
0.60606061, 0.61616162, 0.62626263, 0.63636364, 0.64646465,
0.65656566, 0.66666667, 0.67676768, 0.68686869, 0.6969697 ,
0.70707071, 0.71717172, 0.72727273, 0.73737374, 0.74747475,
0.75757576, 0.76767677, 0.77777778, 0.78787879, 0.7979798 ,
0.80808081, 0.81818182, 0.82828283, 0.83838384, 0.84848485,
0.85858586, 0.86868687, 0.87878788, 0.88888889, 0.8989899 ,
0.90909091, 0.91919192, 0.92929293, 0.93939394, 0.94949495,
0.95959596, 0.96969697, 0.97979798, 0.98989899, 1. ])
[[file:ein-images/ob-ein-958ea9b193e7657e6b8b77069728be7a.png]]
:end:
#+NAME: 84b146f2-0b8d-46ca-9fb9-96759657927c
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results output
from sympy import *
init_printing()
x = symbols('x')
x
#+END_SRC
#+RESULTS: 84b146f2-0b8d-46ca-9fb9-96759657927c
#+begin_example
ModuleNotFoundErrorTraceback (most recent call last)
<ipython-input-21-a0c2aa571a36> in <module>
----> 1 from sympy import *
2
3 init_printing()
4 x = symbols('x')
5 x
ModuleNotFoundError: No module named 'sympy'
#+end_example
* SVG Images
* Issue #468: Results in org mode
#+NAME: ffbf0b19-515a-4966-9220-70063cf2948d
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results value
import numpy as np
np.zeros(18)
#+END_SRC
#+RESULTS: ffbf0b19-515a-4966-9220-70063cf2948d
: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
: 0.])

View file

@ -49,10 +49,10 @@
(ein:kernel-new 8888 "" nil "/kernels" (ein:$notebook-events notebook) (ein:need-notebook-version (ein:$notebook-url-or-port notebook))))
(setf (ein:$kernel-events (ein:$notebook-kernel notebook))
(ein:events-new))
; matryoshka: new-content makes a ein:$content using CONTENT as template
; matryoshka: new-content makes a ein:$content using CONTENT as template
; populating its raw_content field with DATA's content field
(ein:notebook-open--callback
notebook nil nil
notebook nil
(ein:new-content (ein:$notebook-url-or-port notebook)
(ein:$notebook-notebook-path notebook) data))
(ein:notebook-buffer notebook)))))
@ -85,8 +85,8 @@
"Make new notebook. One empty cell will be inserted
automatically if CELLS is nil."
(ein:testing-notebook-from-json
(json-encode (ein:testing-notebook-make-data
(or name ein:testing-notebook-dummy-name)
(json-encode (ein:testing-notebook-make-data
(or name ein:testing-notebook-dummy-name)
(or path name ein:testing-notebook-dummy-name)
cells))))
@ -112,7 +112,7 @@ The new cell is bound to a variable `cell'."
LIST-OUTPUTS is a list of list of strings (pyout text). Number
of LIST-OUTPUTS equals to the number cells to be contained in the
notebook."
(ein:testing-notebook-make-new
(ein:testing-notebook-make-new
ein:testing-notebook-dummy-name nil
(mapcar (lambda (outputs)
(ein:testing-codecell-data

View file

@ -1,17 +0,0 @@
(eval-when-compile (require 'cl))
(require 'ert)
(require 'ein-ac)
(require 'ein-testing-kernel)
(ert-deftest ein:ac-set-document ()
(let ((string "candidate string"))
(should-not (get-text-property 0 'document string))
(ein:testing-kernel-construct-help-string-loop
(lambda (content result)
(ein:ac-set-document string content '-not-used-)
(let ((props (text-properties-at 0 string)))
;; document property may be nil, but must be set.
(should (member 'document props))
(should (equal (plist-get props 'document) result)))))))

View file

@ -17,7 +17,7 @@
(dummy-response (make-request-response))
got-url)
(setf (ein:$notebook-kernel notebook) kernel)
(cl-letf (((symbol-function 'request)
(cl-letf (((symbol-function 'request)
(lambda (url &rest ignore) (setq got-url url) dummy-response))
((symbol-function 'set-process-query-on-exit-flag) #'ignore)
((symbol-function 'ein:kernel-stop-channels) #'ignore)
@ -30,31 +30,35 @@
(should (equal got-url desired-url)))))
(ert-deftest ein:kernel-interrupt-check-url ()
(let* ((kernel (eintest:kernel-new 8888))
(kernel-id "KERNEL-ID")
(desired-url "http://127.0.0.1:8888/api/kernels/KERNEL-ID/interrupt")
(dummy-response (make-request-response))
got-url)
(flet ((request (url &rest ignore) (setq got-url url) dummy-response)
(set-process-query-on-exit-flag (process flag))
(ein:kernel-stop-channels (&rest ignore))
(ein:websocket (url kernel on-message on-close on-open) (make-ein:$websocket :ws nil :kernel kernel :closed-by-client nil))
(ein:websocket-open-p (websocket) t))
(lexical-let* ((kernel (eintest:kernel-new 8888))
(kernel-id "KERNEL-ID")
(desired-url "http://127.0.0.1:8888/api/kernels/KERNEL-ID/interrupt")
(dummy-response (make-request-response))
got-url)
(cl-letf (((symbol-function 'request)
(lambda (url &rest ignore) (setq got-url url) dummy-response))
((symbol-function 'set-process-query-on-exit-flag) #'ignore)
((symbol-function 'ein:kernel-stop-channels) #'ignore)
((symbol-function 'ein:websocket) (lambda (&rest ignore) (make-ein:$websocket :ws nil :kernel kernel :closed-by-client nil)))
((symbol-function 'ein:websocket-open-p) (lambda (&rest ignore) t)))
(ein:kernel-retrieve-session--success
kernel nil :data (list :ws_url "ws://127.0.0.1:8888" :id kernel-id))
(ein:kernel-interrupt kernel)
(should (equal got-url desired-url)))))
(ert-deftest ein:kernel-kill-check-url ()
(let* ((kernel (eintest:kernel-new 8888))
(kernel-id "KERNEL-ID")
(desired-url "http://127.0.0.1:8888/api/sessions/KERNEL-ID")
(dummy-response (make-request-response))
got-url)
(flet ((request (url &rest ignore) (setq got-url url) dummy-response)
(set-process-query-on-exit-flag (process flag))
(ein:kernel-stop-channels (&rest ignore))
(ein:websocket (url kernel on-message on-close on-open) (make-ein:$websocket :ws nil :kernel kernel :closed-by-client nil)))
(lexical-let* ((kernel (eintest:kernel-new 8888))
(kernel-id "KERNEL-ID")
(desired-url "http://127.0.0.1:8888/api/sessions/KERNEL-ID")
(dummy-response (make-request-response))
got-url)
(cl-letf (((symbol-function 'request)
(lambda (url &rest ignore) (setq got-url url) dummy-response))
((symbol-function 'set-process-query-on-exit-flag) #'ignore)
((symbol-function 'ein:kernel-stop-channels) #'ignore)
((symbol-function 'ein:websocket) (lambda (&rest ignore) (make-ein:$websocket :ws nil :kernel kernel :closed-by-client nil)))
((symbol-function 'ein:websocket-open-p) (lambda (&rest ignore) t)))
(ein:kernel-retrieve-session--success
kernel nil :data (list :ws_url "ws://127.0.0.1:8888" :id kernel-id))
(ein:kernel-delete-session kernel))

View file

@ -57,8 +57,6 @@
'(notebook_saved.Notebook
notebook_saving.Notebook
notebook_save_failed.Notebook
notebook_create_checkpoint.Notebook
notebook_checkpoint_created.Notebook
execution_count.Kernel
status_idle.Kernel
status_busy.Kernel

View file

@ -1,8 +0,0 @@
(eval-when-compile (require 'cl))
(require 'ert)
(require 'ein-smartrep)
(ert-deftest ein:smartrep-notebook-mode-alist-fboundp ()
(loop for (k . f) in ein:smartrep-notebook-mode-alist
do (should (fboundp f))))

View file

@ -1,239 +0,0 @@
(eval-when-compile (require 'cl))
(require 'ert)
(require 'ein-notebooklist)
(require 'ein-jupyter)
(require 'wid-edit)
(require 'ein-testing)
(require 'ein-testing-cell)
(let ((backend (getenv "EL_REQUEST_BACKEND")))
(when (and backend (not (equal backend "")))
(setq request-backend (intern backend))
(message "Using request-backend = %S" request-backend)))
(defvar *ein:testing-notebook-name* nil
"This is the name of the notebook the server creates for this test. It could be Untitled.ipynb or if that was already there, Untitled1.ipynb, etc.")
(setq message-log-max t)
(defun ein:testing-get-notebook (url-or-port &rest paths)
(ein:log 'debug "TESTING-GET-NOTEBOOK start")
(ein:notebooklist-open* url-or-port)
(ein:testing-wait-until (lambda () (and (bufferp (get-buffer (format ein:notebooklist-buffer-name-template url-or-port)))
(ein:notebooklist-get-buffer url-or-port))))
(with-current-buffer (ein:notebooklist-get-buffer url-or-port)
(prog1 (ein:notebook-get-opened-notebook url-or-port (apply #'ein:glom-paths paths))
(ein:log 'debug "TESTING-GET-NOTEBOOK end"))))
(defun ein:testing-get-untitled0-or-create (url-or-port &optional path)
(ein:log 'debug "TESTING-GET-UNTITLED0-OR-CREATE start")
(let ((notebook (ein:testing-get-notebook url-or-port path *ein:testing-notebook-name*)))
(if notebook
(progn (ein:log 'debug
"TESTING-GET-UNTITLED0-OR-CREATE notebook already exists")
notebook)
(ein:log 'debug
"TESTING-GET-UNTITLED0-OR-CREATE creating notebook")
(lexical-let (done-p
(kernelspec (ein:get-kernelspec url-or-port "default")))
(ein:notebooklist-new-notebook url-or-port kernelspec
(lambda (notebook created)
(setq *ein:testing-notebook-name*
(ein:$notebook-notebook-name notebook))
(setq done-p t)))
(ein:testing-wait-until (lambda () done-p) nil 10000 2000)
(prog1
(ein:testing-get-notebook url-or-port path *ein:testing-notebook-name*)
(with-current-buffer (ein:notebooklist-get-buffer url-or-port)
(lexical-let (done-p)
(ein:notebooklist-reload nil t (lambda (&rest args) (setq done-p t)))
(ein:testing-wait-until (lambda () done-p) nil 10000 1000)))
(ein:log 'debug "TESTING-GET-UNTITLED0-OR-CREATE end"))))))
(defvar ein:notebooklist-after-open-hook nil)
(defadvice ein:notebooklist-open--finish
(after ein:testing-notebooklist-open--finish activate)
"Advice to add `ein:notebooklist-after-open-hook'."
(run-hooks 'ein:notebooklist-after-open-hook))
;; (ert-deftest 00-jupyter-start-server ()
;; (ein:log 'verbose "ERT TESTING-JUPYTER-START-SERVER start")
;; (condition-case err
;; (ein:testing-start-server)
;; (error (ein:log 'verbose "ERT TESTING-JUPYTER-START-SERVER error when launching: %s" err)
;; (sit-for 10)
;; (ein:jupyter-server-login-and-open)))
;; (should (processp %ein:jupyter-server-session%))
;; (ein:log 'verbose "ERT TESTING-JUPYTER-START-SERVER end"))
(ert-deftest 01-open-notebooklist ()
(ein:log 'verbose "ERT OPEN-NOTEBOOKLIST start")
(ein:notebooklist-open* *ein:testing-port*)
(ein:testing-wait-until
(lambda () (ein:aand
(ein:notebooklist-get-buffer *ein:testing-port*)
(with-current-buffer it (eq major-mode 'ein:notebooklist-mode))))))
(ert-deftest 00-query-kernelspecs ()
(ein:log 'info "ERT QUERY-KERNELSPECS")
(ein:log 'info (format "ERT QUERY-KERNELSPECS: Pre-query kernelspec count %s." (hash-table-count *ein:kernelspecs*)))
(should (>= (hash-table-count *ein:kernelspecs*) 1))
(ein:log 'info (format "ERT QUERY-KERNELSPECS: Post-query kernelspec %S." (ein:need-kernelspecs *ein:testing-port*))))
(ert-deftest 10-get-untitled0-or-create ()
(ein:log 'verbose "ERT TESTING-GET-UNTITLED0-OR-CREATE start")
(let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook)
(should (equal (ein:$notebook-notebook-name ein:%notebook%)
*ein:testing-notebook-name*))))
(ein:log 'verbose "ERT TESTING-GET-UNTITLED0-OR-CREATE end"))
(ert-deftest 20-delete-untitled0 ()
(ein:log 'verbose "----------------------------------")
(ein:log 'verbose "ERT TESTING-DELETE-UNTITLED0 start")
(with-current-buffer (ein:notebooklist-get-buffer *ein:testing-port*)
(let* ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*))
(the-url (ein:url *ein:testing-port* (ein:$notebook-notebook-path notebook))))
(should (member the-url (ein:notebooklist-list-paths "notebook")))
(ein:log 'verbose "ERT TESTING-DELETE-UNTITLED0 deleting notebook")
(lexical-let (done-p)
(ein:notebooklist-delete-notebook
(ein:$notebook-notebook-path notebook)
(lambda (&rest args) (setq done-p t)))
(ein:testing-wait-until (lambda () done-p) nil 10000 1000))
(lexical-let (done-p)
(ein:content-query-hierarchy
(ein:url *ein:testing-port*)
(lambda (&rest args) (setq done-p t)))
(ein:testing-wait-until (lambda () done-p) nil 10000 1000))
(should-not (member the-url (ein:notebooklist-list-paths "notebook")))))
(ein:log 'verbose "ERT TESTING-DELETE-UNTITLED0 end"))
(ert-deftest 11-notebook-execute-current-cell-simple ()
(let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook)
(call-interactively #'ein:worksheet-insert-cell-below)
(insert "a = 100\na")
(let ((cell (call-interactively #'ein:worksheet-execute-cell)))
(ein:testing-wait-until (lambda () (not (slot-value cell 'running)))))
;; (message "%s" (buffer-string))
(save-excursion
(should (search-forward-regexp "Out \\[[0-9]+\\]" nil t))
(should (search-forward "100" nil t))))))
(defun ein:testing-image-type (image)
"Return the type of IMAGE.
See the definition of `create-image' for how it works."
(assert (and (listp image) (eq (car image) 'image)) nil
"%S is not an image." image)
(plist-get (cdr image) :type))
(ert-deftest 12-notebook-execute-current-cell-pyout-image ()
(let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(if (image-type-available-p 'svg)
(with-current-buffer (ein:notebook-buffer notebook)
(call-interactively #'ein:worksheet-insert-cell-below)
;; Use IPython.core.display rather than IPython.display to
;; test it with older (< 0.13) IPython.
(insert (concat "from IPython.core.display import SVG\n"
(format "SVG(data=\"\"\"%s\"\"\")"
ein:testing-example-svg)))
(let ((cell (call-interactively #'ein:worksheet-execute-cell)))
;; It seems in this case, watching `:running' does not work
;; well sometimes. Probably "output reply" (iopub) comes
;; before "execute reply" in this case.
(ein:testing-wait-until (lambda () (slot-value cell 'outputs)))
;; This cell has only one input
(should (= (length (oref cell :outputs)) 1))
;; This output is a SVG image
(let ((out (nth 0 (oref cell :outputs))))
(should (equal (plist-get out :output_type) "execute_result"))
(should (plist-get out :svg))))
;; Check the actual output in the buffer:
(save-excursion
(should (search-forward-regexp "Out \\[[0-9]+\\]" nil t))
(should (= (forward-line) 0))
(let ((image (get-text-property (point) 'display)))
(should (eq (ein:testing-image-type image) 'svg)))))
(ein:log 'info
"Skipping image check as SVG image type is not available."))))
(ert-deftest 13-notebook-execute-current-cell-stream ()
(let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook)
(call-interactively #'ein:worksheet-insert-cell-below)
(insert "print('Hello')")
(let ((cell (call-interactively #'ein:worksheet-execute-cell)))
(ein:testing-wait-until (lambda () (not (oref cell :running)))
))
(save-excursion
(should-not (search-forward-regexp "Out \\[[0-9]+\\]" nil t))
(should (search-forward-regexp "^Hello$" nil t))))))
(ert-deftest 14-notebook-execute-current-cell-question ()
(lexical-let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook)
(call-interactively #'ein:worksheet-insert-cell-below)
(insert "range?")
(lexical-let ((cell (call-interactively #'ein:worksheet-execute-cell)))
(ein:testing-wait-until
(lambda ()
(and (not (oref cell :running))
(ein:$notebook-pager notebook)
(get-buffer (ein:$notebook-pager notebook))))))
(with-current-buffer (get-buffer (ein:$notebook-pager notebook))
(should (search-forward "Docstring:"))))))
(ert-deftest 15-notebook-request-help ()
(let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(with-current-buffer (ein:notebook-buffer notebook)
(call-interactively #'ein:worksheet-insert-cell-below)
(let ((pager-name (ein:$notebook-pager ein:%notebook%)))
(ein:aif (get-buffer pager-name)
(kill-buffer it))
(insert "file")
(call-interactively #'ein:pytools-request-help)
;; Pager buffer will be created when got the response
(ein:testing-wait-until
(lambda () (get-buffer pager-name)))
(with-current-buffer (get-buffer pager-name)
(should (search-forward "Docstring:")))))))
(ert-deftest 30-testing-jupyter-stop-server ()
(ein:log 'verbose "ERT TESTING-JUPYTER-STOP-SERVER start")
(let ((notebook (ein:testing-get-untitled0-or-create *ein:testing-port*)))
(ein:testing-wait-until
(lambda () (ein:aand (ein:$notebook-kernel notebook)
(ein:kernel-live-p it))))
(ein:jupyter-server-stop t ein:testing-dump-file-server)
(cl-flet ((orphans-find (pid) (search (ein:$kernel-kernel-id (ein:$notebook-kernel notebook)) (alist-get 'args (process-attributes pid)))))
(should-not (loop repeat 10
with orphans = (seq-filter #'orphans-find
(list-system-processes))
until (and (null orphans) (ein:jupyter-server-process))
do (sleep-for 0 1000)
(setq orphans (seq-filter #'orphans-find (list-system-processes)))
finally return orphans))))
(ein:log 'verbose "ERT TESTING-JUPYTER-STOP-SERVER end"))

View file

@ -1,2 +1,2 @@
(custom-set-variables
'(ein:polymode t))
'(ein:polymode nil))

View file

@ -1,5 +1,10 @@
(custom-set-variables '(company-frontends nil)
'(python-indent-guess-indent-offset-verbose nil)
'(ein:polymode nil))
(require 'ein-dev)
(require 'ein-testing)
(require 'ert)
(require 'poly-ein)
(require 'byte-compile)
(ert-deftest ein:should-not-compile-advised ()

View file

@ -1,3 +1,7 @@
(custom-set-variables '(company-frontends nil)
'(python-indent-guess-indent-offset-verbose nil))
(require 'python)
(require 'ein-dev)
(require 'ein-testing)

View file

@ -1,29 +0,0 @@
(prefer-coding-system 'utf-8)
(require 'ein-dev)
(require 'ein-testing)
(require 'ein-jupyter)
(require 'ein-notebooklist)
(require 'deferred)
(ein:log 'info "Starting jupyter notebook server.")
(defvar *ein:testing-jupyter-server-command* (or (getenv "JUPYTER_TESTING_COMMAND")
(executable-find "jupyter"))
"Path to command that starts the jupyter notebook server.")
(defvar *ein:testing-jupyter-server-directory* (or (getenv "JUPYTER_TESTING_DIR") (concat default-directory "test"))
"Location where to start the jupyter notebook server.")
(setq ein:testing-dump-file-log (concat default-directory "log/testfunc.log"))
(setq ein:testing-dump-file-messages (concat default-directory "log/testfunc.messages"))
(setq ein:testing-dump-file-server (concat default-directory "log/testfunc.server"))
(setq ein:testing-dump-file-websocket (concat default-directory "log/testfunc.websocket"))
(setq ein:testing-dump-file-request (concat default-directory "log/testfunc.request"))
(with-eval-after-load "python"
(setq python-indent-guess-indent-offset-verbose nil))
(ein:dev-start-debug)
(ein:jupyter-server-start *ein:testing-jupyter-server-command* *ein:testing-jupyter-server-directory*)
(ein:testing-wait-until (lambda () (ein:notebooklist-list)) nil 15000 1000)
(defvar *ein:testing-port* (car (ein:jupyter-server-conn-info)))
(fset 'y-or-n-p (lambda (prompt) nil))

View file

@ -1,6 +0,0 @@
jedi <= 0.13.3
jupyter
ipython
numpy
matplotlib
invoke