##// END OF EJS Templates
%alias_magic: Use mman.register_alias API for creating new magic aliases.
Bradley M. Froehle -
Show More
@@ -83,6 +83,7 b' class BasicMagics(Magics):'
83 """
83 """
84 args = magic_arguments.parse_argstring(self.alias_magic, line)
84 args = magic_arguments.parse_argstring(self.alias_magic, line)
85 shell = self.shell
85 shell = self.shell
86 mman = self.shell.magics_manager
86 escs = ''.join(magic_escapes.values())
87 escs = ''.join(magic_escapes.values())
87
88
88 target = args.target.lstrip(escs)
89 target = args.target.lstrip(escs)
@@ -109,18 +110,10 b' class BasicMagics(Magics):'
109 args.cell = bool(m_cell)
110 args.cell = bool(m_cell)
110
111
111 if args.line:
112 if args.line:
112 def wrapper(line): return m_line(line)
113 mman.register_alias(name, target, 'line')
113 wrapper.__name__ = str(name)
114 wrapper.__doc__ = "Alias for `%s%s`." % \
115 (magic_escapes['line'], target)
116 shell.register_magic_function(wrapper, 'line', name)
117
114
118 if args.cell:
115 if args.cell:
119 def wrapper(line, cell): return m_cell(line, cell)
116 mman.register_alias(name, target, 'cell')
120 wrapper.__name__ = str(name)
121 wrapper.__doc__ = "Alias for `%s%s`." % \
122 (magic_escapes['cell'], target)
123 shell.register_magic_function(wrapper, 'cell', name)
124
117
125 def _lsmagic(self):
118 def _lsmagic(self):
126 mesc = magic_escapes['line']
119 mesc = magic_escapes['line']
General Comments 0
You need to be logged in to leave comments. Login now