From 66ea1c1f3fe6602eee4233cd2ef10010a8a13f13 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Wed, 18 May 2022 10:41:01 +0900 Subject: Make the editor and terminal options more flexible This is to support tmux better. Maintains backward compatibility. --- edit.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/edit.py b/edit.py index fe2919f..5075ddc 100644 --- a/edit.py +++ b/edit.py @@ -83,12 +83,15 @@ def read_file(buf): def hook_editor_process(terminal, editor, buf): - term_cmd = "{} -e".format(terminal) - editor_cmd = "{} {}".format(editor, FILE) - weechat.hook_process("{} \"{}\"".format( - term_cmd, - editor_cmd - ), 0, "editor_process_cb", buf) + if "{}" in editor: + editor_cmd = editor.format(FILE) + else: + editor_cmd = "{} {}".format(editor, FILE) + if "{}" in terminal: + command = terminal.format(editor_cmd) + else: + command = "{} -e \"{}\"".format(terminal, editor_cmd) + weechat.hook_process(command, 0, "editor_process_cb", buf) def run_blocking(editor, buf): -- cgit v1.2.3-70-g09d2