emacs' sage_mode no longer typesets in 6.2 (Linux)

164 views
Skip to first unread message

Emmanuel Charpentier

unread,
May 13, 2014, 2:46:21 AM5/13/14
to sage-s...@googlegroups.com
Dear list,

I just installed sage 6.2 from source on Deblan testing/amd64 ; I also installed sage_mode.

 plot(sin(x), [x, -2*pi, 2*pi], figsize=4)

gives me the expected plot. but
 diff(sin(x),x)
gives me
cos(x)
typed, not typeset.

Ouch !

For light work, where my sage's use is incidental, I'm used to work in emacs with sage mode, copying interesting results as latex (via right-click==>copy as latex) and pasting them in latex/noweb files. This swell work environment just disappeared.

Has anyone already seen this problem ? Has anyone successfully used emacs_mode in Sage 6.2 ?

Sincerely yours,

--
Emmanuel Charpentier

Emmanuel Charpentier

unread,
May 13, 2014, 1:28:26 PM5/13/14
to sage-s...@googlegroups.com
Update : same problem (same symptoms) wuth the Ubuntu ppa package under Ubuntu 14.04.

HTH,

--
Emmanuel Charpentier

Ivan Andrus

unread,
May 13, 2014, 10:22:36 PM5/13/14
to sage-s...@googlegroups.com
It looks like `%display typeset` no longer works (if it ever did).  I’m fairly sure that I had tested it before (when working on #15271 where Volker suggested using it), but maybe not.  So, at the end of the day, I’m not sure how to turn on typesetting in Sage 6.2.

-Ivan

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Emmanuel Charpentier

unread,
May 15, 2014, 1:52:46 AM5/15/14
to sage-s...@googlegroups.com
In 6.2, %display seems restricted to ('simple', 'ascii_art'). From a terminal :

sage: %display typeset
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-65343e720bd4> in <module>()
----> 1 get_ipython().magic(u'display typeset')

/usr/local/sage-6.2/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2163         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2164         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2165         return self.run_line_magic(magic_name, magic_arg_s)
   2166
   2167     #-------------------------------------------------------------------------

/usr/local/sage-6.2/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2084                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2085             with self.builtin_trap:
-> 2086                 result = fn(*args,**kwargs)
   2087             return result
   2088

/usr/local/sage-6.2/local/lib/python2.7/site-packages/sage/repl/ipython_extension.pyc in display(self, args)

/usr/local/sage-6.2/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    189     # but it's overkill for just that one bit of state.
    190     def magic_deco(arg):
--> 191         call = lambda f, *a, **k: f(*a, **k)
    192
    193         if callable(arg):

/usr/local/sage-6.2/local/lib/python2.7/site-packages/sage/repl/ipython_extension.pyc in display(self, args)
    252             mode = args[0]
    253             if mode not in ('simple', 'ascii_art'):
--> 254                 raise ValueError('unrecognized display type "%s"'%mode)
    255             self._magic_display_status = mode
    256

ValueError: unrecognized display type "typeset"

In other words, the ability may exist but is unreachable...

HTH,

--
Emmanuel Charpentier

Ivan Andrus

unread,
May 20, 2014, 1:07:35 AM5/20/14
to sage-s...@googlegroups.com
Any help?  What should I be using in place of `%display typeset`, which no longer works?

-Ivan

Johan S. R. Nielsen

unread,
Aug 5, 2014, 10:43:58 AM8/5/14
to sage-s...@googlegroups.com
Hmm, it seems that the ipython_extension.py should be patched to know about typeset. Directly setting the flag in IPython seems to do the trick:
get_ipython().display_formatter.formatters['text/plain'].set_display("typeset")

Regards,
Johan

Volker Braun

unread,
Aug 5, 2014, 10:49:28 AM8/5/14
to sage-s...@googlegroups.com
Has been fixed in #16389 (6.3.beta2)

Emmanuel Charpentier

unread,
Aug 8, 2014, 6:12:45 PM8/8/14
to sage-s...@googlegroups.com
For future reference :

Ivan Andrus did create a version of sage_mode that fixes the problem. It is currently available at the development site, and not yet in the sage spkgs set. Works nicely for me (with sage 6.3rc0).

HTH,

--
Emmanuel Charpentier

Ivan Andrus

unread,
Aug 10, 2014, 11:11:34 PM8/10/14
to sage-s...@googlegroups.com
Thanks for reminding me.  I released a new version of sage-mode (0.12—only the version number has changed), and opened http://trac.sagemath.org/ticket/16795 which needs review.  I should have hurried to get it into 6.3 so that things weren’t broken.  Sorry.

-Ivan

Emmanuel Charpentier

unread,
Aug 11, 2014, 3:04:08 AM8/11/14
to sage-s...@googlegroups.com
May I express a wish ?

The current solution uses the same output mode as the notebook. This has a somewhat serious drawback : no debugging...

An alternative is to go through GUD to execute a "sageified" version of pdb, as suggested by one of the discussions pointed to by the relevant issue of the home site. But that introduces behaviour differences between command line sage and sage under emacs. Not good...

HTH,

--
Emmanuel Charpentier

Ivan Andrus

unread,
Aug 11, 2014, 9:25:35 PM8/11/14
to sage-s...@googlegroups.com
I’m not sure I understand.  What do you mean when you say there is no debugging?  A recipe for what used to work and doesn’t now would be great.  

I certainly didn’t intend to make things harder to debug, but maybe that’s why EMBEDDED_MODE wasn’t used before.  I like the interface a lot better this way though.  I guess I could change the plot functionality to recognize EMACS_MODE or something.

-Ivan

Emmanuel Charpentier

unread,
Aug 12, 2014, 9:05:37 AM8/12/14
to sage-s...@googlegroups.com


Le mardi 12 août 2014 03:25:35 UTC+2, Ivan Andrus a écrit :
I’m not sure I understand.  What do you mean when you say there is no debugging?  A recipe for what used to work and doesn’t now would be great.  

Wekk, for oe thng, you can't trace a call :

[ In emacs ]

sage: sage: def fact(n):
....: if(n==1):return(1)
....: else:return(n*fact(n-1))
....: 

sage: trace("fact(3)")
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-20-a765fe6277a4> in <module>()
----> 1 trace("fact(3)")

/usr/local/sage-6.3/local/lib/python2.7/site-packages/sage/misc/trace.pyc in trace(code, preparse)
     74     from sage.plot.plot import EMBEDDED_MODE
     75     if EMBEDDED_MODE:
---> 76         raise NotImplementedError("the trace command is not implemented in the Sage notebook; you must use the command line.")
     77
     78     from IPython.core.debugger import Pdb

NotImplementedError: the trace command is not implemented in the Sage notebook; you must use the command line.


This is the same message you get when attempting trace in the notebook.

[ in command line ]

sage: def fact(n):
....:     if(n==1):return(1)
....:     else:return(n*fact(n-1))
....:    
sage: fact(3)
6
sage: trace("fact(3)")
> <string>(1)<module>()

ipdb> s
--Call--
> <ipython-input-1-0a880cb62556>(1)fact()
----> 1 def fact(n):
      2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
> <ipython-input-1-0a880cb62556>(2)fact()
      1 def fact(n):
----> 2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
> <ipython-input-1-0a880cb62556>(3)fact()
      2     if(n==Integer(1)):return(Integer(1))
----> 3     else:return(n*fact(n-Integer(1)))
      4    

ipdb> s
--Call--
> <ipython-input-1-0a880cb62556>(1)fact()
----> 1 def fact(n):
      2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
> <ipython-input-1-0a880cb62556>(2)fact()
      1 def fact(n):
----> 2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
> <ipython-input-1-0a880cb62556>(3)fact()
      2     if(n==Integer(1)):return(Integer(1))
----> 3     else:return(n*fact(n-Integer(1)))
      4    

ipdb> s
--Call--
> <ipython-input-1-0a880cb62556>(1)fact()
----> 1 def fact(n):
      2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
> <ipython-input-1-0a880cb62556>(2)fact()
      1 def fact(n):
----> 2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
--Return--
1
> <ipython-input-1-0a880cb62556>(2)fact()
      1 def fact(n):
----> 2     if(n==Integer(1)):return(Integer(1))
      3     else:return(n*fact(n-Integer(1)))

ipdb> s
--Return--
2
> <ipython-input-1-0a880cb62556>(3)fact()
      2     if(n==Integer(1)):return(Integer(1))
----> 3     else:return(n*fact(n-Integer(1)))
      4    

ipdb> s
--Return--
6
> <ipython-input-1-0a880cb62556>(3)fact()
      2     if(n==Integer(1)):return(Integer(1))
----> 3     else:return(n*fact(n-Integer(1)))
      4    

ipdb> s
--Return--
None
> <string>(1)<module>()

ipdb> s
> /usr/local/sage-6.3/local/lib/python/bdb.py(404)run()
    403         finally:
--> 404             self.quitting = 1
    405             sys.settrace(None)

ipdb> s
sage:



I certainly didn’t intend to make things harder to debug, but maybe that’s why EMBEDDED_MODE wasn’t used before.  I like the interface a lot better this way though.  I guess I could change the plot functionality to recognize EMACS_MODE or something.

It could be interesting to search if the reasons forbidding trace in the notebook are still valid. ut the notebook seem to be in "maintenance mode" according to various threads in sage-devel, and has no clear successor (a special mode of ipython-notebook ?Something like the SMC notebook ? Something else ?)
,

Ivan Andrus

unread,
Sep 4, 2014, 2:17:38 PM9/4/14
to sage-s...@googlegroups.com
Sorry it took so long to get back to you with a fix.  

I have added the ability to use emacsclient+function to view plot inline.  This should be robust across all versions of Sage (though I haven’t tested it) since it simply replaces the PNG_VIEWER with the emacsclient command.  I haven’t made it the default since it requires that emacsclient be set up properly.  So just customize `sage-view-inline-plots-method’, and you should be good to go.  You will also have to ensure that `sage-view-emacsclient’ is set properly.  I think it should work for most people, but I’m not entirely sure.  You’ll also need to run (server-start) in your .emacs, but it will warn you of that.

Anyway, the new spkg is at

Emmanuel Charpentier

unread,
Sep 14, 2014, 4:03:50 PM9/14/14
to sage-s...@googlegroups.com
Sorry for 10 days of silence : we are in the grant proposal season...

This spkg doesn't install.(see enclose log).

Curiously, the 0.12 version I had before trying to install your newer version worked as advertised (typesetting math and putting plots on the emacs buffer).

I'm currently updating my sage to see what happents with the current (6.4beta3) sage.


Sincerely yours,

--
Emmanuel Charpentier


sage_mode-20140904.log

Emmanuel Charpentier

unread,
Sep 14, 2014, 5:02:51 PM9/14/14
to sage-s...@googlegroups.com
Sage 6.4beta3 works as 6.3 : the September spkg doesn't install, the 0.12 works as advertised in emacs.

HTH,
--
Emmanuel Charpentier

Ivan Andrus

unread,
Sep 15, 2014, 2:08:03 AM9/15/14
to sage-s...@googlegroups.com
Hmm.  It looks like I used a bashism and told it to use sh.  But, that part hasn’t changed since 0.10, so I’m not sure how previous versions were working.  Anyway, I’ll get it fixed and we can try again.  (But write your grant proposals first. :-)

-Ivan

<sage_mode-20140904.log>

Reply all
Reply to author
Forward
0 new messages