summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-02 17:38:57 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-02 17:38:57 +0100
commit4926a655feafd039fd34a9e273fd168f9d14b0a1 (patch)
tree4f8fc9d74954b129b2e88cfc0134e8d0a1ac5e14 /alot
parent5b32229ae74ccc3ce3331a11ef0885b441afcea9 (diff)
initial command instead of search: issue #79
Diffstat (limited to 'alot')
-rw-r--r--alot/defaults/alot.rc4
-rwxr-xr-xalot/init.py22
-rw-r--r--alot/ui.py10
3 files changed, 21 insertions, 15 deletions
diff --git a/alot/defaults/alot.rc b/alot/defaults/alot.rc
index 917eabfe..1829b0f2 100644
--- a/alot/defaults/alot.rc
+++ b/alot/defaults/alot.rc
@@ -54,8 +54,8 @@ timestamp_format = ''
# muttprint/a2ps works nicely
print_cmd = ''
-# initial searchstring when none is given as argument:
-initial_searchstring = tag:inbox AND NOT tag:killed
+# initial command when none is given as argument:
+initial_command = search tag:inbox AND NOT tag:killed
# in case more than one account has an addressbook:
# Set this to True to make tabcompletion for recipients during compose only
diff --git a/alot/init.py b/alot/init.py
index 1e347171..563c998f 100755
--- a/alot/init.py
+++ b/alot/init.py
@@ -25,6 +25,7 @@ import settings
from account import AccountManager
from db import DBManager
from ui import UI
+from command import interpret_commandline
def parse_args():
@@ -51,9 +52,9 @@ def parse_args():
parser.add_argument('-l', dest='logfile',
default='/dev/null',
help='logfile')
- parser.add_argument('query', nargs='?',
+ parser.add_argument('command', nargs='?',
default='',
- help='initial searchstring')
+ help='initial command')
return parser.parse_args()
@@ -61,7 +62,7 @@ def main():
# interpret cml arguments
args = parse_args()
- #locate and read config file
+ # locate and read config file
configfiles = [
os.path.join(os.environ.get('XDG_CONFIG_HOME',
os.path.expanduser('~/.config')),
@@ -77,8 +78,9 @@ def main():
for configfilename in configfiles:
if os.path.exists(configfilename):
settings.config.read(configfilename)
- break # use only the first
+ break # use only the first
+ # read notmuch config
notmuchfile = os.path.expanduser(args.notmuchconfigfile)
settings.notmuchconfig.read(notmuchfile)
settings.hooks.setup(settings.config.get('general', 'hooksfile'))
@@ -96,15 +98,19 @@ def main():
dbman = DBManager(path=args.db_path, ro=args.read_only)
# get initial searchstring
- query = settings.config.get('general', 'initial_searchstring')
- if args.query != '':
- query = args.query
+ if args.command != '':
+ cmd = interpret_commandline(args.command, 'global')
+ if cmd is None:
+ sys.exit('Invalid command: ' + args.command)
+ else:
+ default_commandline = settings.config.get('general', 'initial_command')
+ cmd = interpret_commandline(default_commandline, 'global')
# set up and start interface
ui = UI(dbman,
logger,
aman,
- query,
+ cmd,
args.colours,
)
diff --git a/alot/ui.py b/alot/ui.py
index 320f8efe..d58b561c 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -49,7 +49,7 @@ class UI(object):
buffers = []
current_buffer = None
- def __init__(self, dbman, log, accountman, initialquery, colourmode):
+ def __init__(self, dbman, log, accountman, initialcmd, colourmode):
self.dbman = dbman
self.dbman.ui = self # register ui with dbman
self.logger = log
@@ -68,15 +68,15 @@ class UI(object):
self.show_statusbar = config.getboolean('general', 'show_statusbar')
self.notificationbar = None
- self.mode = ''
+ self.mode = 'global'
self.commandprompthistory = []
+ self.logger.debug('setup bindings')
for key, value in config.items('urwid-maps'):
command_map[key] = value
- self.logger.debug('setup bindings')
- cmd = commandfactory('search', query=initialquery)
- self.apply_command(cmd)
+ self.logger.debug('fire first command')
+ self.apply_command(initialcmd)
self.mainloop.run()
def keypress(self, key):