summaryrefslogtreecommitdiff
path: root/alot/commands/globals.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-19 15:35:16 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-19 15:35:16 +0100
commite4aeb78803525e49663ca1fa20e5381a679a0e30 (patch)
tree5ba457abca7be867eb793d68c29ce702fad0d037 /alot/commands/globals.py
parentd648b0f083500debe628d01ef52decc21943946b (diff)
smarter discovery of editor command
This will respect EDITOR env var or use /usr/bin/editor if editor_cmd is unset (default)
Diffstat (limited to 'alot/commands/globals.py')
-rw-r--r--alot/commands/globals.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index cda492a0..17b37ab2 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -8,6 +8,7 @@ from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import urwid
from twisted.internet import defer
+import logging
from alot.commands import Command, registerCommand
from alot import buffers
@@ -177,11 +178,23 @@ class EditCommand(ExternalCommand):
self.thread = thread
else:
self.thread = settings.config.getboolean('general', 'editor_in_thread')
- editor_cmd = settings.config.get('general', 'editor_cmd')
- ExternalCommand.__init__(self, editor_cmd, path=self.path,
+ self.editor_cmd = None
+ if os.path.isfile('/usr/bin/editor'):
+ self.editor_cmd = '/usr/bin/editor'
+ self.editor_cmd = os.environ.get('EDITOR', self.editor_cmd)
+ self.editor_cmd = settings.config.get('general', 'editor_cmd',
+ fallback=self.editor_cmd)
+ logging.debug('using editor_cmd: %s' %self.editor_cmd)
+
+ ExternalCommand.__init__(self, self.editor_cmd, path=self.path,
spawn=self.spawn, thread=self.thread,
**kwargs)
+ def apply(self, ui):
+ if self.editor_cmd == None:
+ ui.notify('no editor set', priority='error')
+ else:
+ return ExternalCommand.apply(self, ui)
@registerCommand(MODE, 'pyshell',