diff options
-rw-r--r-- | alot/command.py | 12 | ||||
-rw-r--r-- | alot/settings.py | 19 | ||||
-rw-r--r-- | data/example.full.rc | 4 |
3 files changed, 23 insertions, 12 deletions
diff --git a/alot/command.py b/alot/command.py index aa9d3797..804604b4 100644 --- a/alot/command.py +++ b/alot/command.py @@ -724,14 +724,6 @@ class TaglistSelectCommand(Command): ui.apply_command(cmd) -aliases = {'clo': 'close', - 'bn': 'bnext', - 'bp': 'bprevious', - 'bcf': 'buffer close focussed', - 'ls': 'bufferlist', - 'quit': 'exit', -} - COMMANDS = { 'search': { 'refine': (RefineCommand, {}), @@ -814,8 +806,8 @@ def interpret_commandline(cmdline, mode): params = '' # unfold aliases - if cmd in aliases: - cmd = aliases[cmd] + if settings.config.has_option('command-aliases', cmd): + cmd = settings.config.get('command-aliases', cmd) # allow to shellescape without a space after '!' if cmd.startswith('!'): diff --git a/alot/settings.py b/alot/settings.py index efc31da0..62eb5eda 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -242,6 +242,13 @@ DEFAULTS = { 'bufferlist-maps': { 'd': 'closefocussed', 'enter': 'openfocussed', + }, + 'command-aliases': { + 'clo': 'close', + 'bn': 'bnext', + 'bp': 'bprevious', + 'ls': 'bufferlist', + 'quit': 'exit', } } @@ -256,13 +263,21 @@ class CustomConfigParser(SafeConfigParser): self.add_section(sec) def get(self, section, option, fallback=None, *args, **kwargs): - if self.has_option(section, option): + if SafeConfigParser.has_option(self, section, option): return SafeConfigParser.get(self, section, option, *args, **kwargs) elif section in self.defaults: if option in self.defaults[section]: return self.defaults[section][option] return fallback + def has_option(self, section, option, *args, **kwargs): + if SafeConfigParser.has_option(self, section, option): + return True + elif section in self.defaults: + if option in self.defaults[section]: + return True + return False + def getstringlist(self, section, option, **kwargs): value = self.get(section, option, **kwargs) return [s.strip() for s in value.split(',')] @@ -273,7 +288,7 @@ class CustomConfigParser(SafeConfigParser): SafeConfigParser.readfp(self, codecs.open(file, "r", "utf8")) if self.has_option('general', 'hooksfile'): - hf = os.path.expanduser(config.get('general', 'hooksfile')) + hf = os.path.expanduser(self.get('general', 'hooksfile')) if hf is not None: try: config.hooks = imp.load_source('hooks', hf) diff --git a/data/example.full.rc b/data/example.full.rc index a8bb9348..85922674 100644 --- a/data/example.full.rc +++ b/data/example.full.rc @@ -46,6 +46,10 @@ sent_mailbox = maildir:///home/john/mail/gmail/Sent # we accept mbox,maildir,mh # possible modi are: envelope, search, thread, bufferlist, taglist t = toggletag todo + +[command-aliases] +quit = exit + [normal-theme] bufferlist_focus_bg = dark gray bufferlist_focus_fg = white |