# HG changeset patch # User Steve Losh # Date 1507734881 14400 # Node ID f433f96e0b210f7a74565ce589352163fb430f40 # Parent bfd9b1f910a3e81117683cf43ac4b7fa804271a3 Allow file extensions diff -r bfd9b1f910a3 -r f433f96e0b21 weechat/python/autoload/editor.py --- 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', '')