aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Smiley <keithbsmiley@gmail.com>2015-12-10 00:14:39 -0800
committerKeith Smiley <keithbsmiley@gmail.com>2015-12-10 00:14:39 -0800
commitdcdf60573507a05c987019074c8915bb8287e69a (patch)
tree60288f6a4b634fc4070a9df7622413c1cb97b010
parent14503786d1ff3a91cee1b05698faf60e1f7bb371 (diff)
downloadedit-dcdf60573507a05c987019074c8915bb8287e69a.tar.gz
edit-dcdf60573507a05c987019074c8915bb8287e69a.zip
Allow editor configuration
-rw-r--r--README.md9
-rw-r--r--edit.py9
2 files changed, 16 insertions, 2 deletions
diff --git a/README.md b/README.md
index 40419f9..4318c52 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,15 @@ compose messages in your `$EDITOR`.
# Save and quit
```
+# Configuration
+
+If you'd like to customize the editor you use outside of the `$EDITOR`
+environment variable, you can set it in weechat.
+
+```sh
+/set plugins.var.python.edit.editor "vim -f"
+```
+
# Installation
Copy the script to `~/.weechat/python/autoload`
diff --git a/edit.py b/edit.py
index 40c3653..a44af9c 100644
--- a/edit.py
+++ b/edit.py
@@ -3,8 +3,12 @@
# Usage:
# /edit
#
+# Optional settings:
+# /set plugins.var.python.edit.editor "vim -f"
+#
# History:
# 10-18-2015
+# Version 1.0.1: Add configurable editor key
# Version 1.0.0: initial release
import os
@@ -14,11 +18,12 @@ import weechat
def edit(data, buf, args):
- editor = os.environ.get("EDITOR", "vim")
+ editor = (weechat.config_get_plugin("editor") or
+ os.environ.get("EDITOR", "vim -f"))
path = os.path.expanduser("~/.weechat/message.txt")
open(path, "w+")
- cmd = [editor, path]
+ cmd = editor.split() + [path]
code = subprocess.Popen(cmd).wait()
if code != 0:
os.remove(path)