--- a/weechat/python/autoload/editor.py Wed Oct 11 11:09:36 2017 -0400
+++ b/weechat/python/autoload/editor.py Wed Oct 11 11:14:41 2017 -0400
@@ -22,8 +22,8 @@
weechat_version = 0
-def get_data(initial_data):
- with tempfile.NamedTemporaryFile(suffix=".tmp", mode="w+") as tf:
+def get_data(suffix, initial_data):
+ with tempfile.NamedTemporaryFile(suffix=".%s" % suffix, mode="w+") as tf:
tf.write(initial_data)
tf.flush()
@@ -38,9 +38,11 @@
return tf.readlines()
def editor(data, buffer, args):
+ suffix = args or "tmp"
+
line = weechat.buffer_get_string(buffer, "input")
- data = get_data(line)
+ data = get_data(suffix, line)
if data:
weechat.command(buffer, "/input delete_line")
@@ -59,8 +61,8 @@
weechat.hook_command(
SCRIPT_COMMAND,
'Open $EDITOR to compose a message',
- '',
- '',
+ '[file-extension]',
+ 'If an argument is given, it will be used as the extension for the temporary file.',
'',
'editor',
'')