diff options
Diffstat (limited to 'alot')
-rw-r--r-- | alot/command.py | 2 | ||||
-rw-r--r-- | alot/completion.py | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/alot/command.py b/alot/command.py index 9882d1fc..ea61ecde 100644 --- a/alot/command.py +++ b/alot/command.py @@ -876,7 +876,7 @@ def interpret_commandline(cmdline, mode): elif cmd == 'toggletag': return commandfactory(cmd, tag=params) elif cmd == 'edit': - filepath = params[0] + filepath = os.path.expanduser(params) if os.path.isfile(filepath): return commandfactory(cmd, path=filepath) else: diff --git a/alot/completion.py b/alot/completion.py index d32769b9..a64776f1 100644 --- a/alot/completion.py +++ b/alot/completion.py @@ -18,6 +18,7 @@ Copyright (C) 2011 Patrick Totzke <patricktotzke@gmail.com> """ import re +import os import command @@ -118,6 +119,7 @@ class CommandLineCompleter(Completer): self._querycompleter = QueryCompleter(dbman) self._tagscompleter = TagsCompleter(dbman) self._contactscompleter = ContactsCompleter() + self._pathcompleter = PathCompleter() def complete(self, prefix): words = prefix.split(' ', 1) @@ -133,5 +135,23 @@ class CommandLineCompleter(Completer): return self._tagscompleter.complete(params, last=True) if cmd == 'to': return self._contactscompleter.complete(params) + if cmd == 'edit': + return self._pathcompleter.complete(params) else: return [] + + +class PathCompleter(Completer): + """completion for paths""" + def complete(self, prefix): + prep = '' + if not prefix: + prefix = '~/' + prep = '~/' + dir = os.path.expanduser(os.path.dirname(prefix)) + fileprefix = os.path.basename(prefix) + res = [] + for f in os.listdir(dir): + if f.startswith(fileprefix): + res.append(os.path.join(prep, f[len(fileprefix):])) + return res |