sage-shell-mode icon indicating copy to clipboard operation
sage-shell-mode copied to clipboard

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

Open johanrosenkilde opened this issue 9 years ago • 8 comments

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.

johanrosenkilde avatar Sep 08 '16 15:09 johanrosenkilde

It is already possible if you use auto-complete-sage (available from Melpa) or company-sage (not available from Melpa). But they are not tab completion but auto-completion. They just complete global objects in the shell session. Of cource it is easy to implement tab completion in a sage-mode buffer.

stakemori avatar Sep 09 '16 00:09 stakemori

OK, thank you! auto-complete-sage looks very impressive :-)

johanrosenkilde avatar Sep 09 '16 08:09 johanrosenkilde

I added a completion-at-point function for sage-shell:sage-mode in 52bf492946726bfbcc127fcc32a3ad2c935ce25a. But I guess using ac-sage with emacs-jedi or company-mode with anaconda-mode would be more convenient.

stakemori avatar Sep 15 '16 23:09 stakemori

@stakemori I am wondering are you still working on it. It seems that this doesn't work.

iromise avatar Feb 09 '18 09:02 iromise

@iromise, the implementation was done in 2016. But this is still open because I am lazy. To use this feature, please make sure that a Sage process is running in Emacs and sage-shell:process-buffer is set.

The variable sage-shell:process-buffer is automatically set when you load a buffer, region or file to the process buffer. You can also set the variable explicitly by M-x sage-shell:set-process-buffer.

stakemori avatar Feb 09 '18 19:02 stakemori

But it seems not ok.. for example

from sage.all import *

m = matrix([1, 2])

m.

I can not get complete at m. ...

iromise avatar Feb 10 '18 05:02 iromise

@iromise, currently, completion-at-point in a sage-mode buffer only completes global variables and does not complete methods of global/local variables. In a Sage process buffer, it is possible to complete methods of m if m = matrix([1, 2]) is already evaluated. sage-shell-mode does not evaluate user's code that calls methods/functions since it is unsafe. So to complete methods in a sage-mode buffer, I think it is necessary to parse Python and Cython modules and it seems difficult for me. And I am not working on it. For what it's worth, packages such as jedi.el or anaconda-mode provide auto completion for pure Python objects. They can complete methods of variables to some extent.

stakemori avatar Feb 10 '18 10:02 stakemori

Ok, thanks a lot. I will try it.

iromise avatar Feb 10 '18 10:02 iromise