Closed johanrosenkilde closed 7 years ago
I didn't know the feature of sage-mode
and didn't expect that users do such a thing. I will implement the feature. Thanks.
Fantastic, thanks! sage-shell-mode
is really nice :-)
I fixed this in ae72052dc00688215cf5466665ca34dedd0b2e87. If there is no problem, I will merge it to master later.
If sage-shell:use-prompt-toolkit
is non-nil, this feature may not work well. It is because prompt_toolkit
splits long input line to fit the window size.
For example if I input a number (output of factorial(100)
), then input line is split as follows:
sage: 9332621544394415268169923885626670049071596826438162146859296389521759999322991560894146397615651828625369792082
....: 7223758251185210916864000000000000000000000000
sage-shell-mode
joins the lines, but it does not work well always. For example, the input line is as follows,
a = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000; print "....: foo"
Then sage-shell-mode
is confused and thinks the input line ended with foo
. I guess it rarely happens.
If you are using helm
, you can also use M-x helm-comint-input-ring
to reuse the previous input (helm-sage
also provides a similar command).
Thank you, this is great! I'll try it out tomorrow and report back.
I confirm that this works as described. Thanks a lot.
An issue related to what you mentioned comes up in trying to replay a multi-line command:
sage: l = [ n^2 for n in range(5) ]
sage: for e in l:
....: print e
....:
0
1
4
9
16
sage: l = [ n^3 for n in range(5) ]
sage: <move point and try to replay "for e in l: ...">
sage: for e in l:
....: <point here>
I can live with that behaviour no problem.
A related user-question: is it possible to search through previous history, like
Best, Johan
A related user-question: is it possible to search through previous history, like in bash?
I guess M-r
(comint-history-isearch-backward-regexp
) works. But this may be unstable because it depends on global state. I may replace it with a command which uses ido
.
Is it necessary that long input lines are split to fit the window size? More precisely: is this required by ipython or is this a sage-shell-mode
feature?
If it is a sage-shell-mode
feature, I'd like to be able to turn it off, because I tend to resize my window frequently...
@mantepse, sage-shell-mode
doesn't split long input lines. I guess this is a feature of prompt_toolkit
or ipytohn
. sage-shell-mode
has to tell the window size (window height and window width) to the process, otherwise no prompts are displayed. I don't know how to disable the feature. I guess there are at least two solutions.
If you like the first one, I will add a variable for it. If you would like to try the second one, please try the following code (this may be unstable):
(add-hook 'window-configuration-change-hook #'sage-shell:-adjust-window-size)
@mantepse, since this is automatically closed, I've opened a new issue(#21).
In
sage-mode
moving the point to some earlier prompt line and pressingRET
will copy that earlier prompt to the current one and evaluate it. This is quite convenient sometimes.Doing the same in
sage-shell-mode
(using Sage 7.4 andsage-shell:use-python-toolkit t
) results in weird behaviour: the previous prompt is reevaluated, but the intermediate buffer contents are deleted and the prompt input is visually copied twice.now moving the point to the line
2+2
and pressingRET
results in the following buffer contents: