From e9128ebb2aae6983965e2a7901577e81fdb1a2fd Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Fri, 22 Jan 2016 20:55:37 +0000 Subject: [PATCH] Relax editor templating I tried to set my editor to `termite -e "vim -f {}"`, termite being a pretty cool and light terminal I use within my i3wm Arch linux box. So when I open my editor I want it to launch a terminal with Vim inside instead of GVim for various reasons. The validation rejected this at first because it was looking for '{}' inside ['foo', 'bar', 'baz {}'], essentially. So I need it to look inside the sub-strings, not just the list. Then after validation I need to perform the '{}' replacement inside the sub-string too, not just replacing the whole string. --- qutebrowser/config/configtypes.py | 2 +- qutebrowser/misc/editor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 177f55456..65ea745c1 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1094,7 +1094,7 @@ class ShellCommand(BaseType): shlex.split(value) except ValueError as e: raise configexc.ValidationError(value, str(e)) - if self.placeholder and '{}' not in self.transform(value): + if self.placeholder and '{}' not in value: raise configexc.ValidationError(value, "needs to contain a " "{}-placeholder.") diff --git a/qutebrowser/misc/editor.py b/qutebrowser/misc/editor.py index 2fa9791e9..d844cdc80 100644 --- a/qutebrowser/misc/editor.py +++ b/qutebrowser/misc/editor.py @@ -124,6 +124,6 @@ class ExternalEditor(QObject): self._proc.error.connect(self.on_proc_error) editor = config.get('general', 'editor') executable = editor[0] - args = [self._filename if arg == '{}' else arg for arg in editor[1:]] + args = [arg.replace('{}', self._filename) if '{}' in arg else arg for arg in editor[1:]] log.procs.debug("Calling \"{}\" with args {}".format(executable, args)) self._proc.start(executable, args)