Giter Club home page Giter Club logo

sage-shell-mode's People

Contributors

ajirving avatar andreas-roehler avatar apresta avatar dimpase avatar emmanuelcharpentier avatar fchapoton avatar johanrosenkilde avatar stakemori avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sage-shell-mode's Issues

Using %cython directive

I can't get sage-shell-mode to accept %cython magic markers. The same code that copy-paste works in the IPython Sage shell gives the following error when C-c C-r'ing the code inside Emacs:

sage: load('/tmp/sage_shell_mode14470ZZ2/sage_shell_mode_temp.sage')
  File "<string>", line 2
    %%cython
    ^
SyntaxError: invalid syntax

Is there any way to make %%cython work?

Emulating worksheets: error in the last block of the example

sage: load('/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/sage_shell_mode1670
....: Lxp/sage_shell_mode_temp.sage')
 ---- Implement the new algorithm ---- 
sage: load('/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/sage_shel
....: l_mode1670Lxp/sage_shell_mode_temp.sage')
 ---- Check the new algorithm on small input ---- 
6
sage: load('/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/sage_shel
....: l_mode1670Lxp/sage_shell_mode_temp.sage')
 ---- Check the new algorithm on big input ---- 
800
sage: load('/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/sage_shel
....: l_mode1670Lxp/sage_shell_mode_temp.sage')
 ---- Check that my algorithm is commutative using random input ---- 
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-13-9f09adb3e820> in <module>()
----> 1 load('/var/folders/tq/f5jbfqp97y52w_y7byn05_fw0000gn/T/sage_shell_mode1670Lxp/sage_shell_mode_temp.sage')

/Applications/SageMath-7.5.1.app/Contents/Resources/sage/src/sage/structure/sage_object.pyx in sage.structure.sage_object.load (/Applications/SageMath-7.5.1.app/Contents/Resources/sage/src/build/cythonized/sage/structure/sage_object.c:12529)()
    999 
   1000     if sage.repl.load.is_loadable_filename(filename):
-> 1001         sage.repl.load.load(filename, globals())
   1002         return
   1003 

/Applications/SageMath-7.5.1.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sage/repl/load.pyc in load(filename, globals, attach)
    245             if attach:
    246                 add_attached_file(fpath)
--> 247             exec(preparse_file(open(fpath).read()) + "\n", globals)
    248     elif ext == '.spyx' or ext == '.pyx':
    249         if attach:

<string> in <module>()

NameError: name 'random_input' is not defined

Sage 9.2.beta8 breaks sage-shell-mode

Copy of this sage-release post :

Damn !

This release breaks sage-shell-mode support for a sage session into emacs. After starting an emacs session, I get the normal banner and a normal prompt. A little while after that (about 0.5 to 1 second), a warning WARNING: your terminal doesn't support cursor position requests (CPR). appears immediately below the banner and above the prompt, then the cursor goes right to the right margin (i. e. in the right scrollbar).

I still can type Sage code, which appears at the left margin on the line immediately below the prompt. Typing <Return> displays a continuation prompt (.....:) 7 spaces,, then my code,which gets executed and the answer printed on the line below the continuation prompt. Example :

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2.beta8, Release Date: 2020-08-10               │
│ Using Python 3.7.3. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
WARNING: your terminal doesn't support cursor position requests (CPR).
sage: sage:                                                                      
....:       1+1                                                                  
2
sage:

No error message appears in the terminal window from which I launched emacs ; nothing unusual in the Messages buffer either.

I’m stymied…

incompatibility with iPython 5.0

Some of that strongly disagrees with sage-shell mode!
The repl buffer is not read-only, and nothing happens when i press enter or run sage-shell:send-input manually. ob-sagemath is also broken, but i assume its happening over here

Problem with "cursor position requests"

Since the update to Sagemath 9.0, I am no longer able to use sage-shell-mode. After starting Sage in a buffer, when I send text via C-c C-r, it gives the warning WARNING: your terminal doesn't support cursor position requests (CPR). This happens no matter what terminal software I use: urxvt, xterm, gnome-terminal, or just the emacs gui.

When I run quit in the sage buffer (sage itself runs normally), it closes and then shows some messages that I haven't seen before:

Exiting Sage (CPU time 0m0.44s, Wall time 1m15.01s).
Task was destroyed but it is pending!
task: <Task pending name='Task-251' coro=<Renderer.wait_for_cpr_responses.<locals>.wait_for_responses() running at /usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py:502> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f9f22618a60>()]>>           
Task was destroyed but it is pending!
task: <Task pending name='Task-384' coro=<Renderer.wait_for_cpr_responses.<locals>.wait_for_responses() running at /usr/lib/python3.8/site-packages/prompt_toolkit/renderer.py:502> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f9f226e88e0>()]>>  

Process Sage finished

I am using Sage, emacs, ... as distributed by Arch Linux. The problem persists even when I start without a .emacs file:

  • sagemath 9.0 (2020-01-10 release)
  • GNU emacs 26.3
  • sage-shell-mode-20191103.1040 installed via ELPA

screen flash

Hi, thanks for writing such a useful mode. There is one minor issue: after it reaches the last line of the buffer, when a new "sage:" prompt comes out, the screen refresh is kind of slow, that is, the screen has a noticeable flash which is quite annoying. Sage running on eshell does not have this problem.

Is there way to avoid this flash? Right now I just "clear" when I reach the last line, but then I lost the input/output history in the buffer.

By the way, I find helm-sage-command-history very useful. Would it be possible to add a similar command for output history? This could also potentially solve the problem I mentioned above (I don't lose anything when I clear the screen). The built-in _oh command of sage is not really useful.

process filter error when start sage inferior process

error in process filter: Args out of range: "�[6D�[J�[0m�[6n�[0m�[0m�[J�[0;38;5;21msage: �[6D�[6C", 65
error in process filter: ansi-color-filter-apply: Args out of range: "�[6D�[J�[0m�[6n�[0m�[0m�[J�[0;38;5;21msage: �[6D�[6C", 65
error in process filter: Args out of range: "�[6D�[J�[0m�[6n�[0m�[0m�[J�[0;38;5;21msage: �[6D�[6C", 65

This is the error message in *Messages* buffer when I run run-sage.

Sage-shell:restart-sage messing with the window configuration after running pdb

Hi,

As written in the title, sage-shell:restart-sage is messing up my window configuration. Sometimes it's as simple as bringing up a code buffer, sometimes it completely moves my windows around... In most cases simply calling winner-undo is enough to return to my window configuration, but as the session goes longer the modifications get more complex and even sometimes appear to not be undoable.

I believe that it is linked to the pdb-tracking feature. Namely, it seems that the feature to kill the buffers when exiting pdb does not run when I exit pdb with C-d or with q.

But it's only part of the problem: it may happen that one wants the source code buffers to stay live after exiting the debugger (for instance if they were already live to begin with, which I believe the tracker takes care of), but still that the window configuration does not change when restarting sage.

Steps to reproduce the problem (tested with a vanilla emacs with only sage-shell-mode installed: ./emacs-sandbox.sh -O -i sage-shell-mode (https://github.com/alphapapa/emacs-sandbox.sh))

  1. M-x sage-shell:run-sage
  2. In the buffer, enter:
import pdb
1/0
pdb.pm()
u 3

3. This opens a buffer visiting interactiveshell.py. At that point, inspecting sage-shell-pdb:buffers-to-kill shows that interactiveshell.py is in the list
4. Exit pdb (either with q or C-d)
5. The buffer is not killed.
6. Change the buffer displayed in the window where interactiveshell.py is.
7. Move the point back to the sage-shell buffer, and M-x sage-shell:restart-sage
8. The window configuration is changed to display interactiveshell.py again.

Thanks!

sage-shell-mode doesn't handle (unicode) strings containing non-ASCII characters

Noticed in this ask.sagemath question.

I'm currently working in a Python 3-based Sage, where strings are systematically Unicode. This will soon become the default.

In a terminal:

sage: S="à"
sage: show(S)
\newcommand{\Bold}[1]{\mathbf{#1}}\verb|à|

In an emacs buffet, inline-typesettig disabled:

sage: S="à"
sage: show(S)
\newcommand{\Bold}[1]{\mathbf{#1}}\verb|à|

In an emacs buffet, inline-typesettig enabled:

sage: S="à"
sage: show(S)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-30-0b3d0aeda691> in <module>()
----> 1 show(S)

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/pretty_print.py in show(*args, **kwds)
    256         args[0].show()
    257         return
--> 258     pretty_print(*args, **kwds)

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/pretty_print.py in pretty_print(*args, **kwds)
    227             pass
    228         elif len(args) == 1:
--> 229             dm.display_immediately(*args, **kwds)
    230         else:
    231             SequencePrettyPrinter(*args, **kwds).pretty_print()

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/display_manager.py in display_immediately(self, obj, **rich_repr_kwds)
    836         """
    837         plain_text, rich_output = self._rich_output_formatter(obj, rich_repr_kwds)
--> 838         self._backend.display_immediately(plain_text, rich_output)
    839 
    840 

/usr/local/sage-P3-2/local/lib/python3.7/site-packages/sage/repl/rich_output/backend_ipython.py in display_immediately(self, plain_text, rich_output)
    302             Example plain text output
    303         """
--> 304         formatdata, metadata = self.displayhook(plain_text, rich_output)
    305         print(formatdata[u'text/plain'])
    306 

/home/charpent/.emacs.d/elpa/sage-shell-mode-20180215.835/emacs_sage_shell_view.py in displayhook(self, plain_text, rich_output)
     55         elif isinstance(rich_output, OutputLatex):
     56             text = "" + plain_text.text.get() + ""
     58             return ({u'text/plain': text}, {})
     59         else:

TypeError: can only concatenate str (not "bytes") to str

This works without error in a Jupyter notebook.

IMHO, this is a bug specific to sage-shell-mode (the last entry in the stack is in its code: .../elpa/sage-shell-mode-20180215.835/emacs_sage_shell_view.py in displayhook(self, plain_text, rich_output))...

improve accessibility of the documentation

I'm not sure (especially because Sage-mode is already very good), but it may make sense to make the html documentation (in a browser) easily accessible.

Right now, I noticed two reasons why I'd like to do this:

  1. an overview of a module:

To get an overview of a module, reading the module's docstring via, for example, sage.combinat.posets? is not always helpful, because sphinx cross-references are not resolved. This would actually be better dealt with in Sage-mode itself, but I have no idea how.

  1. pictures

(not so important for me currently)

Bug in sage-shell:delchar-or-maybe-eof

The function (sage-shell:delchar-or-maybe-eof) is supposed to check whether (point) is at end of buffer, but it doesn't. As a result, if you enter text at the prompt, then move to beginning of input (Ctrl-A), then typing Ctrl-D does the wrong (and very confusing) thing.

Otherwise very nice package!

Here is a patch:

--- a/sage-shell-mode.el
+++ b/sage-shell-mode.el
@@ -655,7 +655,7 @@ returned from the function, otherwise, this returns it self. "
 Sends an EOF only if point is at the end of the buffer and there is no input. "
   (interactive "p")
   (let ((proc (get-buffer-process (current-buffer))))
-    (if (and proc (= (point) (marker-position (process-mark proc)))
+    (if (and proc (= (point) (point-max) (marker-position (process-mark proc)))
              (sage-shell:output-finished-p)
              (sage-shell:redirect-finished-p))
         (sage-shell:send-eof)

uniq is deprecated

As of sagemath 8.7, sage.misc.all.uniq is deprecated, and should be replaced with sorted(set(x)). It is used only once, one line 177 in https://github.com/sagemath/sage-shell-mode/blob/master/emacs_sage_shell.py - the import on line 30 should then also be removed.

Thanks for all your work!

TAB gives `py-forward-statement: buffer not in python-mode`

Since upgrading Emacs and a load of packages, hitting TAB in a file with sage-mode often gives me the error py-forward-statement: buffer not in python-mode.

For instance, with a file containing:

def f():
    return 1

I get the error hitting TAB on the return line, but not on the def line.

This also happens in a clean emacs with emacs -q.

Tab-complete in `.sage` files if a Sage process is open

It should be possible to link the completion library with the Sage process in the background to provide tab-completion while editing a sage-shell:sage-mode file.

Already now we have Eldoc integration in sage-shell:sage-mode files, which is awesome, and demonstrates that the plumbing for this sort of communication is already there.

how to use dockerized sagemath

Is it possible to use dockerized sagemath with sage-shell-mode?

I understand we can set sage-shell:sage-executable to the sage executable file. So can we use

(setq sage-shell:sage-executable "docker run -it sagemath/sagemath:latest")

and expect sage-shell-mode to run in emacs as it is supposed to?

Doesn't work with the Gnu port of emacs for Windows.

What does work : using the cygwin port of emacs along with the cygwin version of sage.

What I tried :

  • Install the Gnu "native" port of emacs to Windows (works)
  • Compile Sage on Cygwin (works, sort-of : I can start sage (via a shell script) from the Windows command line and pass it whatever arguments I need, but sage -n jupyter fails, for entirely different reasons...)
  • Install sage_shell_mode on emacs (works)
  • run sage in sage_shell_mode : this fails, because I cant't think of a way to tell sage_shell_mode to start a shell script.

I have been able to build a cmd.exe shell script that starts sage in cygwin (with any argument it needs), passes keyboard input to Sage and prints answers in the Windows console. But sage_shell_mode does not accept it, and asks me to set sage-shell-sage-root and sage-shell:sage-executable correctly.

I suppose that this function wants an executable, not a script. I tried to pass cmd.exe /c <my_path>\\sage.cmd to sage-shell-sage-executable, to no avail.

Do you see a workaround for this ? I don't. And the previous solution essentially amounts to running the whole thing (Sage + Emacs + AUCTeX) on top of a Cygwin machine : not fun, and not efficient.

Icing on this unappetizing cake : I have to do that on a machine where I have no admin rights (dont ask : my administration has reasons unknown to Reason...;-). That's why I have to recompile Sage : the marvelous installer of Erik M. Bray needs admin rights.

Suggestions ?

Usage with `use-prompt-toolkit t` and `<C-j>` exits the Sage process

I use Evil in Emacs which means I'm usually writing in "insert" state and not in "emacs" state.

In the Sage shell, pressing Enter when in Emacs state works as normal. If in insert state, it inserts a newline character (visually at least) and goes to the next line. Switching to Emacs state and then pressing Enter will now evaluate the command and then exit the Sage process:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.3, Release Date: 2016-08-04                     │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: 2+2 #typed in Insert state, followed by enter, followed by enter in Emacs state
4
sage: 
Exiting Sage (CPU time 0m0.07s, Wall time 3m0.40s).

Process Sage finished

Eldoc integration in Sage fails on functions in catalogs

This is quite likely not at all the fault of sage-shell-mode, but I'm reporting this unwanted behaviour here, and we can see if something can be done about it.

Eldoc is a nice minor mode for showing the signature of functions in the minibuffer while writing:

sage: matrix(<wait a moment>
<minibuffer prints: "matrix(ring=None, nrows=None, ncols=None, sparse=None, *Args)"

This works for methods on classes as well and for functions/class constructors in modules. But it doesn't seem to work for the Sage catalogs:

sage: codes.GeneralizedReedSolomonCode(<waiting a long while>
<nothing prints in minibuffer>

Explicitly importing the functions into the namespace fixes things

sage: from sage.coding.codes_catalog import *
sage: GeneralizedReedSolomonCode(<wait>
<minibuffer prints signature>

auto complete on from sage.<TAB>

I often find myself typing "from sage.rings.all import P…" or so and it would be awesome if sage-shell-mode could offer me some auto-completion options for that.

(One option to realise this feature could be to use jedi-mode, but it's not like I understand the emacs+python eco-system well enough to judge)

Makefile `compile` target trouble

After cloning sage-shell-mode, I get the following error upon typing make:

emacs -Q -eval "(progn (setq byte-compile-delete-errors nil) (setq byte-compile-error-on-warn t))" \
-batch -f batch-byte-compile sage-shell-mode.el

In toplevel form:
sage-shell-mode.el:53:1:Error: Cannot open load file: no such file or directory, deferred
make: *** [Makefile:5: compile] Error 1

I have deferred installed, and calling byte-compile on sage-shell-mode.el from within a normally started Emacs works fine. Am I doing something wrong here?

improvements sage-shell:send-doctest

a sugestion for sage-shell:send-doctest: it would be great if it would not "leave" the current docstring.

By example, suppose I have

def foo(bar):
    """Do something really cool.

    sage: foo(1)
    yippe

    sage: foo(2)
    yes
    """

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 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. with

(sage-shell:define-keys sage-shell:sage-mode-map "C-c C-j" 'sage-shell:send-doctest)

but 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, do

sage: ColoredPermutations?

move point to the first sage:, and do sage-shell:send-doctest...

auto-complete for attached files

I tend to attach("filename.py") the files I'm currently working on. It would be nice if the functions/classes found in filename.py could be added to the auto complete database.

When ran on Windows, sage_shell_mode somehow misses Sage's prompts.

I recently attempted to test the usability of Sage on Windows 10 computers (which are still the dominant platform among "general users"). See this message for an account.

I used two different setups :

  • Erik Bray's Windows installer (available here) and Gnu Emacs native Windows port (available here)

  • The Windows Subsystem for Linux (WSL), where I installed Ubuntu Xenial (16.04), emacs 25.1, texlive and recompiled Sage 7.6.beta3 (see the thread mentioned above for details), and the VcXsrv X windows server.

In both setup, I installed sage_shell_mode via MELPA. In both setups, I observed the following behaviour :

  • In command-line, sage starts (with no problems whatsoever on Erik Brays Cygwn port, with a complaint about a missing /proc/vmstat on WSL).

  • The Jupyter notebook works (with a slow start...), and is usable.

  • Emacs works with no problems.

  • sage-shell:run-sage sort-of works : it displays the Sage banner (and, in WSL, the complaint about missing /proc/vmstat) but never displays the sage: prompt.

  • after a suitable wait, one can type 2+2, hit Return and Sage happily answers 4, but still gives no prompt. Similarly, asking integrate(arctan(x),x) will get you x*arctan(x) - 1/2*log(x^2+1)

  • typing plot(sin(x,-pi,pi), figsize=3) gives the expected graph in WSL (displayed by imagemagick) ; it does nothing in Cygwin's setup (but Sage is still functional after that).

  • toggling either "Enable inline typeset output" or "Enable inline plots" sends emacs in an endless loop, where it does not sees ^C : you have to kill it manually (via Windows' task monitor for the Cygwin setup, via killall emacs in the WLS setup).

One more data point : in the WSL setup, I have been able to use Sage's Maxima and the relevant imaxima files to get a filly working imaxima setup, with typeset math output and inline plots. I did not think of this test when testing the Cygwin setup.

This made me think of the recent problem introduced by the new IPython management of prompts, but I found nothing relevant.

This issue might be relevant to (future) Sage-on-Windows users.

Sage-shell-view-mode breaks sage.

Whenever I enable sage-shell-view-mode, sage can not process any inputs, e. g.,

sage: 2*2
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-e3c01459b706> in <module>()
----> 1 Integer(2)*Integer(2)

/usr/lib/python2.7/dist-packages/IPython/core/displayhook.pyc in __call__(self, result)
    244             self.start_displayhook()
    245             self.write_output_prompt()
--> 246             format_dict, md_dict = self.compute_format_data(result)
    247             self.update_user_ns(result)
    248             self.fill_exec_result(result)

/usr/lib/python2.7/dist-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
    148             
    149         """
--> 150         return self.shell.display_formatter.format(result)
    151 
    152     # This can be set to True by the write_output_prompt method in a subclass

/usr/lib/python2.7/dist-packages/sage/repl/display/formatter.pyc in format(self, obj, include, exclude)
    200         """
    201         # First, use Sage rich output if there is any
--> 202         sage_format, sage_metadata = self.dm.displayhook(obj)
    203         assert PLAIN_TEXT in sage_format, 'plain text is always present'
    204         if not set(sage_format.keys()).issubset(self.default_mime()):

/usr/lib/python2.7/dist-packages/sage/repl/rich_output/display_manager.pyc in displayhook(self, obj)
    806         self._backend.set_underscore_variable(obj)
    807         plain_text, rich_output = self._rich_output_formatter(obj, dict())
--> 808         return self._backend.displayhook(plain_text, rich_output)
    809 
    810     def display_immediately(self, obj, **rich_repr_kwds):

/home/tashfeen46/.emacs.d/elpa/sage-shell-mode-20191103.1040/emacs_sage_shell_view.pyc in displayhook(self, plain_text, rich_output)
     55         elif isinstance(rich_output, OutputLatex):
     56             text = "" + str(plain_text.text.get(), 'utf-8') + ""
     58             return ({'text/plain': text}, {})
     59         else:

TypeError: str() takes at most 1 argument (2 given)

Interestingly, if I just toggle the inline plots by sage-shell-view-toggle-inline-plots then everything works fine but sage-shell-view-enable-inline-output breaks sage the same way as shown above.

Here is my use-package configurations for sage shell mode,

;; sagemath
(use-package sage-shell-mode
  :ensure t
  :hook
  (sage-shell-mode . eldoc-mode)
  (sage-shell:sage-mode . eldoc-mode)
  (sage-shell-after-prompt . sage-shell-view-toggle-inline-plots))

Any help?

sage-shell-edit:send-line* C-c C-j

sage-shell-edit:send-line* currently sends the current line to the sage buffer.

In sage-mode the key C-c C-j did something related, but (in my opinion) more useful: if the current line does not begin with "sage: ", it does nothing.

Otherwise, it sends the block (possibly continued with ....:) to the sage buffer, and puts point to the next sage: prompt in the current buffer.

This is extremely useful to evaluate code from docstrings, but I also use it in email...

Strange behaviour when using `RET` on a line earlier in the Sage buffer

In sage-mode moving the point to some earlier prompt line and pressing RET 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 and sage-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.

<SAGE BANNER>
sage: 2+2
4
sage: 3+3
6

now moving the point to the line 2+2 and pressing RET results in the following buffer contents:

<SAGE BANNER>
sage: 2+2 2+2
4
sage: 

Auctex integration in environments

I use auctex with sagetex and I was wondering if there Is a way to use sage-shell-mode in latex environments such as "sageblock" "sagesilent" and others in one which to specify?

Revive sage-test-mode

With the old sage-mode, C-c C-t on a buffer was running sage -t on the corresponding file,
and the test log was rendered in a useful way, with clickable links to the failing doctests and so on.

Could this be revived in sage-shell-mode?

Thanks in advance!

elpa version 20191101.1756 is somehow partly broken for a Python 3-based sage

Seen after this morning's upgrade of my elpa packages, which installed sage-shell-mode-20191101.1756 :

  • when $SAGE_ROOT points to a Python 3-based Sage installation, sage-shell-mode displays the Sage banner, and never gets the prompt, thus becoming unusable. I had to kill emacs...

  • when $SAGE_ROOT points to a Python 2-based Sage installation, sage-shell-mode works as expected (displays 2D graphs and typesets expressions in the *Sage* buffer when the relevant toggles are set).

  • However, when I repeat the first operation (after switching a symlink to change back SAGE_ROOT to Python 3-based Sage), sage-shell-mode:

    • starts normally
    • can display 2d plots in the *Sage* buffer,
    • but won't typeset expressions, as already reported in issue #45.

The first instance of the problem may be a post-install glitch.And #45 still stands, becoming an urgent issue with Sage 9.0 (Python 3-based by default) looming over the horizon...

HTH,

Create `sage-shell:restart-sage`

I quite often restart the Sage shell. Sometimes its to flush all the globals I've created during experiments to double-check that my functions don't rely on them, and sometimes it's because I accidentally evaluate an infinite loop or something.

For this use case it would be nice with a handy restart function.

Incorrect postioning of prompt

After clean install of Sage 9.0 on Ubuntu 20.04 and cloning the latest sage-shell-mode git repository I find that running sage within Emacs 26.3 results in the prompt being positioned to the far right of the screen with preceding spaces. The first command line input and output also vanishes from the screen. Though for subsequent commands input and output are shown. However after each command the cursor is positioned to the far right of the screen., with preceding spaces. Attached is the simple .emacs file used and a screenshot. The screenshot shows the state of the screen after launching sage within emacs using M-x run-sage and then executing the command diff(x^3,x). Please do let me know what further information you may need.
dotemacs.txt
Screenshot

color in sage-shell-mode

I would like to use color in sage-shell-mode, for example using the ansi escape sequences. For example

print('\x1b[6;30;42m' + 'Success!' + '\x1b[0m')

should print "Success!" with a green background.

Is there a way to enable that? That would be really wonderful!

Suggestion : add the possibility of making sage-shell-mode work on AUCTeX's "TeX-master"

This is a bit of a specialized use-case, so it might not be of help to a great many people, but nevertheless...

I'm a biostatistician, and I work often wit .Rnw files, that merge R "chunks" in \LaTeX source. Such files are pre-processed by an R utility ("Sweave, or, in my case, knitr)that execute the code (caching is possible and damn useful !) and create a \LaTeX file, which gets compiled to get the final document, that comprises the original text and statistical tables/figures/inline insertions computed by R. In short ASCII art :

+-------+ knitr  +-------+ xxxtex  +-------+
|foo.Rnw+------->|foo.tex+-------->|foo.pdf|
+-------+        +-------+         +-------+

Setting (usually in a Local Variables: directive at the end of the file) the TeX-master AUCTeX variable as a string containing the file name sans extension ("foo", in our case) and positioning an option I can't retrieve at the moment, but is accessible through the "LaTeX" menu of AUCTeX, instructs AUCTeX to execute its commands not on the buffer file (foo.Rnw), but on the TeX-master file (foo.tex). This alows to use a .Rnw fiole (almost) transparently.

In contrast, requiring a compilation or a Sage execution from the .Rnw buffer tries to use the .Rnw file, which, of course, fails. Things work when one uses the version of commands that prompt for a file name : one can edit the proposed name (foo.Rnw) as the name of the master file (foo.tex), ant things work well.

Could sage_shell_mode use the AUCTeX mechanism to determine if it must wotrk on the current buffer or the master file ?

sage-shell-mode versus sage-view

Thanks for your great package;

For Sage 7.3 and lowever, I used to use sage-view which enabled me to do inline-graphics within emacs by adding these in .emacs :
(add-hook 'sage-startup-after-prompt-hook 'sage-view-enable-inline-output)
(add-hook 'sage-startup-after-prompt-hook 'sage-view-enable-inline-plots)

My questions:
1- Why a new package, i.e., sage-shell-mode and not elaborating on the existing one (sage-view)?
2- How can I do inline graphics in sage-shell-mode as it was in sage-view?
3- How can I do debugin for sage and python in emacs?

Thanks so much.

cannot move around in the buffer while sage is printing stuff

Consider the following silly program:

i = 2
while i<100:
    i = next_prime(i)
    print i

I have frequently programs which output a lot, and take a long time to do that - but I want them to finish.

However, while the program is working, I like to go around in the buffer and read stuff. Unfortunately, this is currently not possible in sage-shell-mode.

sage: prompt echos twice

M-x sage-shell:run-sage opens the shell but with no sage: prompt. Yet sage commands run fine.

then the sage: prompt shows up for some reason, and then it echos the same prompt on enter. Sage: prompt now shows up twice. See attached screen shot.

Versions
: SageMath version 8.1, Release Date: 2017-12-07
: Emacs version: GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version 10.11.6 (Build 15G20015))
: org version: 9.1.11

sage-shell-mode version:
;; Version: 0.3

sageprompt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.