diff options
-rw-r--r-- | alot/defaults/alot.rc.spec | 2 | ||||
-rw-r--r-- | alot/settings.py | 23 |
2 files changed, 17 insertions, 8 deletions
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index 296d58f0..6240fe57 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -118,6 +118,8 @@ user_agent = string(default='alot/$VERSION') focus_bg = string(default=None) # alternative string representation translated = string(default=None) + # substitution to generate translated from section name + translation = mixed_list(string, string, default=None) [accounts] [[__many__]] diff --git a/alot/settings.py b/alot/settings.py index b95595d7..455b34e1 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -292,14 +292,21 @@ class SettingsManager(object): # default attributes: normal and focussed default = self._theme.get_attribute('global', 'tag', colours) default_f = self._theme.get_attribute('global', 'tag_focus', colours) - if tag in self._config['tags']: - fg = self._config['tags'][tag]['fg'] or default.foreground - bg = self._config['tags'][tag]['bg'] or default.background - normal = urwid.AttrSpec(fg, bg, colours) - ffg = self._config['tags'][tag]['focus_fg'] or default_f.foreground - fbg = self._config['tags'][tag]['focus_bg'] or default_f.background - focussed = urwid.AttrSpec(ffg, fbg, colours) - translated = self._config['tags'][tag]['translated'] or tag + for sec in self._config['tags'].sections: + if re.match(sec, tag): + logging.debug('sec: %s matches %s' %(sec,tag)) + fg = self._config['tags'][sec]['fg'] or default.foreground + bg = self._config['tags'][sec]['bg'] or default.background + normal = urwid.AttrSpec(fg, bg, colours) + ffg = self._config['tags'][sec]['focus_fg'] or default_f.foreground + fbg = self._config['tags'][sec]['focus_bg'] or default_f.background + focussed = urwid.AttrSpec(ffg, fbg, colours) + + translated = self._config['tags'][sec]['translated'] or tag + translation = self._config['tags'][sec]['translation'] + if translation: + translated = re.sub(translation[0], translation[1], tag) + break else: normal = default focussed = default_f |