sagemath / sage-shell-mode

Emacs front end for SageMath
GNU General Public License v3.0
98 stars 16 forks source link

Sage 9.8.beta7 totally freezes emacs #69

Closed EmmanuelCharpentier closed 1 year ago

EmmanuelCharpentier commented 1 year ago

After upgrading from 9.8.beta6 to 9.6.beta7, launching sage in emacs (M-x run-sage) makes emacs totally unresponsive. The only way to escape is to kill emacs (killall emacs in console).

This happens either from the sole frame of a "fresh" emacs or from a new frame of an otherwise running emacs, whose other frames are also totally frozen.

Extremely annoying, since it deprieves sage-shell-mode of all uses...

EmmanuelCharpentier commented 1 year ago

One more data point :

One can successfully open a new (temporary) buffer, put it in sage-mode and type some code, which is correctly formatted. However, when requesting its interpretation (via C-c C-C), a new window appears, where Sage start, one gets the message mentionning loading sage_shell_mode_temp.sage ... but nothing in printed, never retirns, and emacs is totally frozen.

Its process can be stopped or killed from Gnomes "system monitor", but noit by clicking the "Close window" button of the Emacs frame.

EmmanuelCharpentier commented 1 year ago

Following this suggestin, I tried to fully recompile Sage.

To no avail : M-x run-sage still freezes Emacs, with the same symptoms.

EmmanuelCharpentier commented 1 year ago

I checked that reverting to Sage 9.6.beta6 fixes the issue.

So the question seems to be "What has changed in the interface used by sage-shell-mode?".

mkoeppe commented 1 year ago

Was your build of 9.6.beta7 using Python 3.11?

EmmanuelCharpentier commented 1 year ago

Was your build of 9.6.beta7 using Python 3.11?

As far as I can remember, this build (no longer available, since disk space is tight on bmy current laptop) used the system's Python, which is currently at 3.10.6 in Debian testing (the inclusion of 3.11 in testing seems a bit problematic, due to unsolved dependencies downstream Python...)

I do not remember if there is a way to force Sage's make to use NO system software : that should be the only way to start from an healthy base.

mantepse commented 1 year ago

It is really strange: I have a 9.8.beta7 build and a 9.8.beta6 build. Apparently, if I first use the beta6 one for sage-shell-mode, I can then use beta7 in the same emacs session.

mantepse commented 1 year ago

see https://trac.sagemath.org/ticket/34935

interfaces = ['gap', 'gap3', 'giac', 'gp', 'mathematica', 'gnuplot',
              'kash', 'magma', 'macaulay2', 'maple', 'maxima',
              'mathematica', 'mwrank', 'octave', 'r', 'singular',
              'sage0', 'sage']

It is unclear to me, why we special case these words for the tab-completion:

def all_attributes(compl_dct):
    varname = compl_dct["var-base-name"]
    try:
        regexp = re.compile("^[ a-zA-Z0-9._\\[\\]]+$")
        if regexp.match(varname) is None:
            return []
        if varname in interfaces:
            ls = ip.ev('dir(%s)' % (varname,))
        else:
            ls = _completions_attributes(preparse(varname))
            ls.extend(ip.ev('dir(%s)' % (preparse(varname),)))
            ls = list(sorted(set(ls)))
        return ls
    except:
        return []

It is also unclear to me, why we would extend the list of completions obtained from ipython with the result of dir().

I think we should simplify this and let ipython handle it.

EmmanuelCharpentier commented 1 year ago

This issue has been fixed in 9.8.beta8 (IIRC). Forgot to close it.

Which I do now.