Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Inline graphics in sage-shell-mode #5

Closed
PythonNut opened this issue Mar 8, 2016 · 9 comments
Closed

[feature] Inline graphics in sage-shell-mode #5

PythonNut opened this issue Mar 8, 2016 · 9 comments

Comments

@PythonNut
Copy link

It would be really cool if sage-shell-mode could display graphics inline, like the official sage-mode does. I'm not sure how difficult this would be to implement, but clearly it is possible. :)

@stakemori
Copy link
Collaborator

Thanks for posting this issue.
I think it is not so difficult to implement such a feature if I support only recent versions of Sage. I will try to implement it when I have free time. For what it's worth, I made an org-babel package for Sage recently.
It supports inline display of graphs.

@PythonNut
Copy link
Author

For what it's worth, I made an org-babel package for Sage recently.
It supports inline display of graphs.

Indeed. I've recently started using it, and I much appreciate it. In fact, that's what inspired me to open this issue.

@EmmanuelCharpentier
Copy link
Collaborator

I second the original idea, and add that displaying a (\LaTeX|markdown) rendering of Sage utput would be extremely useful : I'm much more used to standard mathematical notation than to code output.

You could do that by comparing the output to be displayed with \newcommand{\Bold}[1]{, which seems to prefix any \LaTeX output from Sage.

You might also force \LaTeX rendering of all Sage output (possibly under the control of an option...).

That's (approximately) what did the late sage_mode. And that was damnably useful. Combined with the "code blocks" feature, you'd get almost all the features of the Jupyter notebook...

@stakemori
Copy link
Collaborator

@EmmanuelCharpentier, unfortunately, I don't enough time for implementing it this month. I will implement it in a few month. By the way, ob-sagemath is also similar to Sage's notebook and might be useful.

@stakemori
Copy link
Collaborator

@PythonNut, @EmmanuelCharpentier, I just added this feature. You can enable sage-shell-view minor mode by (add-hook 'sage-shell-after-prompt-hook #'sage-shell-view). Sorry for taking a long time.

@EmmanuelCharpentier
Copy link
Collaborator

EmmanuelCharpentier commented Dec 23, 2016 via email

@stakemori
Copy link
Collaborator

@EmmanuelCharpentier, thank you very much for the feedback.

Note that, at first start (i. e. immediately after updating the
package), emacs gave me the Sage banner, but I never got a Sage prompt,
and emacs was quite unresponsive. Things went better after killing emacs
and its subprocesses (via console) and restarting (from console again).

I think it would be better to restart Emacs when upgrading any elisp package.

If possible in your implementation (the code in sage-shell-view.el is
not clear about it), the ability to toggle separately plot output and
LaTeX output (i. e. two menu entries) would be even nicer

Yes, it is possible. To enable only LaTeX output, please set sage-shell-view-default-commands as follows:

(setq sage-shell-view-default-commands 'output)

I also added commands sage-shell-view-toggle-inline-output and sage-shell-view-toggle-inline-plots and added them to the menu.

I also suggest to advertize the existence of the "Sage Shell View"
customization group, ad possibly to document what can and cannot be
customized (e. g. scale for latex output) somewhere in the REAME.md of
the Github page.

I updated sage-shell-view section of README.org. The variable sage-shell-view-scale exists but it is not a customizable variable. Please use sage-shell-view-default-resolution instead. It is passed to the -r option of the gs command and has clearer meaning.

By the way, when inline typesetting enabled, a blank line is inserted before each output. I guess it is due to a bug of Sage 7.4 and should be fixed.

@EmmanuelCharpentier
Copy link
Collaborator

Since this issue is still open (while almost perfectly fixed, IMHO, modulo an extra blank line...), I'll use it to warn you that I updated the Sage Wiki Sage mode comparison page, to advertise the recent changes (inline typesetting, inline plots, blocks).

I also mentioned the AUCTeX integration as "customizable". I have some half-cooked ideas about that, but I need to think more about them...

The extra blank line : why do you think it is a Sage bug ? What is the problem ? The Sage view function does not seem to be affected ; maybe you should have a peek ?

Again, thank you very much !

@stakemori
Copy link
Collaborator

@EmmanuelCharpentier, thank you very much for updating the wiki (I always forget updating it) and I look forward to your idea about AUCTeX.

The extra blank line : why do you think it is a Sage bug ? What is the problem ? The Sage view function does not seem to be affected ; maybe you should have a peek ?

I have just noticed that if repr(obj) contains a newline character, then an extra blank line is inserted. The Sage version is 7.4. One can also reproduce this in Sage in the terminal. I'm not sure if this is a known bug. I will report this at sage-devel.

When sage-shell-view minor mode enabled, the output is actually as follows:

BEGIN_TEXT:obj:END_TEXT
BEGIN_LATEX:\newcommand{\Bold}[1]{\mathbf{#1}}latex(obj):END_LATEX

So the output always contains a newline. In the latest commit, I removed the newline character from the output.

By the way, I close this issue since porting sage-view.el has been done and open a new issue for the extra blank line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants