Closed mantepse closed 7 years ago
Thanks for suggesting. I will investigate the implementation of sage-send-doctest
in sage-mode
.
Besides: how can I bind sage-shell:send-doctest to a key in my .emacs? (I can only do it interactively in the scratch.
Packages in Melpa use autoload
to reduce the start up time of Emacs. You can bind the key as follows:
(with-eval-after-load 'sage-shell-mode
(define-key sage-mode-map (kbd "C-c C-j") 'sage-shell:send-doctest))
You need to put this code after (package-initialize)
and (sage-shell:define-alias)
.
If you don't mind the start up time, you can write as follows.
(package-initialize)
(require 'sage-shell-mode)
(sage-shell:define-alias)
(define-key sage-mode-map (kbd "C-c C-j") 'sage-shell:send-doctest)
Another observation: when I am in a Sage Document buffer, sage-shell:send-doctest doesn't like to send the first line.
With the current implementation, the point has to be before the sage:
prompt. I will fix it.
Thank you! Your support is wonderful!
I fixed this in recent commits. Please update and try it. I also added sage-shell:send-all-doctests
which evaluates all doctests in the current docstring. You can call it by C-u C-c C-j
.
It works sometimes, but not always. Here is a testcase:
class Foo():
r"""
A class modelling foo
EXAMPLES::
sage: 1+1
2
"""
def bang(self):
r"""
doit
TESTS::
sage: 2+3
5
"""
pass
Hitting C-c d
(by the way: why not C-c C-d
?) on the first sage: 1+1
line puts point on the sage: 2+3
line...
@mantepse, thanks for reporting. I thought it was an expected behavior since sage-mode
uses end-of-defun
and end-of-defun
sometimes returns the end point of the class.
I just fixed this in e8ca471d473ff7973e22149cbd03da2c789b21cf. I also fixed sage-shell:send-all-doctests
and change the key-bind (C-c d
=> C-c C-d
).
Thank you!
besides: do you use some kind of testsuite to make sure nothing breaks?
besides: do you use some kind of testsuite to make sure nothing breaks?
Yes. I use ert
for unit testing. I wrote tests in https://github.com/sagemath/sage-shell-mode/blob/master/test/sage-shell-mode-test.el. But I write unit tests for low level functions. I usually test interactive functions such as sage-shell:send-doctest
by hand.
I think you can close this. I use sage-shell-mode every day, and C-c C-d roughly once a minute, and didn't notice any unexpected behaviour! Thank you so much!
BTW: C-c C-d is actually a very clever key binding for me!
@mantepse, thank you for your report.
a sugestion for sage-shell:send-doctest: it would be great if it would not "leave" the current docstring.
By example, suppose I have
Then doing "sage-shell:send-doctest" in the line with foo(2) will move point to the next appearance of "sage: ", which may be anywhere.
It would be great if
sage-shell-mode
would "restrict" attention to the current docstring. (This worked insage-mode
.)Besides: how can I bind
sage-shell:send-doctest
to a key in my.emacs
? (I can only do it interactively in the scratch. withbut if I put this into
.emacs
, emacs complains at startup.Another observation: when I am in a Sage Document buffer,
sage-shell:send-doctest
doesn't like to send the first line. To reproduce, domove point to the first
sage:
, and dosage-shell:send-doctest
...