| 45 | # run_template))) |
| 46 | |
| 47 | def call_editor(self, filename, line=0): |
| 48 | if line is None: |
| 49 | line = 0 |
| 50 | cmd = template.format(filename=pipes.quote(filename), line=line) |
| 51 | print(">", cmd) |
| 52 | # pipes.quote doesn't work right on Windows, but it does after splitting |
| 53 | if sys.platform.startswith('win'): |
| 54 | cmd = shlex.split(cmd) |
| 55 | proc = subprocess.Popen(cmd, shell=True) |
| 56 | if proc.wait() != 0: |
| 57 | raise TryNext() |
| 58 | if wait: |
| 59 | py3compat.input("Press Enter when done editing:") |
| 60 | |
| 61 | get_ipython().set_hook('editor', call_editor) |
| 62 | get_ipython().editor = template |