summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-08-26 13:34:38 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-08-26 13:34:38 +0100
commit5f11411ce92eaf3e8a928025c8580793e93f6475 (patch)
tree0eda4b2b556e84fa8a078f07ed314c67ab567cdd
parentcc8fac4c631ef9e47304fff1b40f7e93b242a6b3 (diff)
shortened attachment code. issue #37
-rw-r--r--alot/command.py26
-rw-r--r--alot/settings.py2
2 files changed, 13 insertions, 15 deletions
diff --git a/alot/command.py b/alot/command.py
index 7ccf49c4..cdbc9a42 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -870,26 +870,24 @@ class EnvelopeSendCommand(Command):
class EnvelopeAttachCommand(Command):
def __init__(self, path=None, mail=None, **kwargs):
Command.__init__(self, **kwargs)
- self.files = []
- if path:
- self.files = glob.glob(os.path.expanduser(path))
self.mail = mail
+ self.path = path
def apply(self, ui):
- if not self.files:
- path = ui.prompt(prefix='attach files matching:', text='~/',
- completer=completion.PathCompleter())
- if path:
- self.files = glob.glob(os.path.expanduser(path))
- if not self.files:
- ui.notify('no matches, abort')
- return
- logging.info(self.files)
-
msg = self.mail
if not msg:
msg = ui.current_buffer.get_email()
- for path in self.files:
+
+ if self.path:
+ files = glob.glob(os.path.expanduser(self.path))
+ if not files:
+ ui.notify('no matches, abort')
+ return
+ else:
+ ui.notify('no files specified, abort')
+
+ logging.info("attaching: %s" % files)
+ for path in files:
helper.attach(path, msg)
if not self.mail: # set the envelope msg iff we got it from there
diff --git a/alot/settings.py b/alot/settings.py
index 55b543a3..5a6e992a 100644
--- a/alot/settings.py
+++ b/alot/settings.py
@@ -252,7 +252,7 @@ DEFAULTS = {
'enter': 'select',
},
'envelope-maps': {
- 'a': 'attach',
+ 'a': 'prompt attach ~/',
'y': 'send',
'enter': 'reedit',
't': 'prompt to ',