Ticket #6288: trac_6288.patch

File trac_6288.patch, 1.8 KB (added by mhansen, 9 years ago)
  • sage/misc/sage_extension.py

    # HG changeset patch
    # User Mike Hansen <mhansen@gmail.com>
    # Date 1374585815 -3600
    # Node ID 2184cf6e85de0c400898638653614d4e9464dacc
    # Parent  606e63c67ba9905f6cdf2a758259b516cab1b826
    #6288: %lisp mode on the command line doesn't work.  why?
    
    diff --git a/sage/misc/sage_extension.py b/sage/misc/sage_extension.py
    a b  
    404404
    405405    def register_interface_magics(self):
    406406        """Register magics for each of the Sage interfaces"""
    407         interfaces = sorted([ obj.name()
    408                               for obj in sage.interfaces.all.__dict__.values()
    409                               if isinstance(obj, sage.interfaces.interface.Interface) ])
    410         for name in interfaces:
    411             def tmp(line,name=name):
     407        from sage.misc.superseded import deprecation
     408        interfaces = [(name, obj)
     409                      for name, obj in sage.interfaces.all.__dict__.items()
     410                      if isinstance(obj, sage.interfaces.interface.Interface)]
     411
     412        for real_name, obj in interfaces:
     413            def tmp(line,name=real_name):
    412414                self.shell.run_cell('%s.interact()'%name)
    413             tmp.__doc__="Interact with %s"%name
    414             self.shell.register_magic_function(tmp, magic_name=name)
     415            tmp.__doc__="Interact with %s"%real_name
     416            self.shell.register_magic_function(tmp, magic_name=real_name)
     417
     418            obj_name = obj.name()
     419            if name != obj_name:
     420                def tmp_deprecated(line, name=real_name):
     421                    deprecation(6288, 'Use %%%s instead of %%%s.'%(real_name, obj_name))
     422                    self.shell.run_cell('%s.interact()'%name)
     423                self.shell.register_magic_function(tmp_deprecated, magic_name=obj_name)
     424
    415425
    416426   
    417427    def set_quit_hook(self):