From 5f11411ce92eaf3e8a928025c8580793e93f6475 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Fri, 26 Aug 2011 13:34:38 +0100 Subject: shortened attachment code. issue #37 --- alot/command.py | 26 ++++++++++++-------------- alot/settings.py | 2 +- 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 ', -- cgit v1.2.3