MCPcopy Create free account
hub / github.com/ipython/ipython / editor

Function editor

IPython/core/hooks.py:57–82  ·  view source on GitHub ↗

Open the default editor at the given filename and linenumber. This is IPython's default editor hook, you can use it as an example to write your own modified one. To set your own editor function as the new editor hook, call ip.set_hook('editor',yourfunc).

(self, filename, linenum=None, wait=True)

Source from the content-addressed store, hash-verified

55 }
56
57def editor(self, filename, linenum=None, wait=True):
58 """Open the default editor at the given filename and linenumber.
59
60 This is IPython's default editor hook, you can use it as an example to
61 write your own modified one. To set your own editor function as the
62 new editor hook, call ip.set_hook('editor',yourfunc)."""
63
64 # IPython configures a default editor at startup by reading $EDITOR from
65 # the environment, and falling back on vi (unix) or notepad (win32).
66 editor = self.editor
67
68 # marker for at which line to open the file (for existing objects)
69 if linenum is None or editor=='notepad':
70 linemark = ''
71 else:
72 linemark = '+%d' % int(linenum)
73
74 # Enclose in quotes if necessary and legal
75 if ' ' in editor and os.path.isfile(editor) and editor[0] != '"':
76 editor = '"%s"' % editor
77
78 # Call the actual editor
79 proc = subprocess.Popen('%s %s %s' % (editor, linemark, filename),
80 shell=True)
81 if wait and proc.wait() != 0:
82 raise TryNext()
83
84
85def synchronize_with_editor(self, filename, linenum, column):

Callers

nothing calls this directly

Calls 2

TryNextClass · 0.85
waitMethod · 0.80

Tested by

no test coverage detected