gui.editor.default_template

gui.editor.default_template(
    which=shutil.which,
    platform=None,
    exists=os.path.exists,
)

The editor template to use when the settings name none.

VS Code is the default: code --goto {file}:{line} when find_code finds it. Vim is the fallback: MacVim (mvim) if it is on the PATH, otherwise Vim in a new Terminal.app window on macOS and in xterm on other systems.

Parameters

Name Type Description Default
which Callable[[str], str | None] Looks up an executable on the PATH; replaceable for tests. shutil.which
platform str | None The platform name. Defaults to sys.platform. None
exists Callable[[str], bool] Tells whether a path exists; replaceable for tests. os.path.exists

Returns

Name Type Description
str str A template for editor_argv.

Examples

from spotregen.gui.editor import default_template

print(default_template(lambda name: "/usr/local/bin/code", "darwin"))
print(default_template(lambda name: None, "darwin", lambda path: False)[:9])
print(default_template(lambda name: None, "linux", lambda path: False))
code --goto {file}:{line}
osascript
xterm -e vim +{line} -- {file}