diff options
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/envelope.py | 6 | ||||
-rw-r--r-- | alot/defaults/alot.rc | 42 | ||||
-rw-r--r-- | alot/message.py | 3 | ||||
-rw-r--r-- | alot/settings.py | 9 | ||||
-rw-r--r-- | alot/widgets.py | 16 |
5 files changed, 42 insertions, 34 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index 0c2a9e14..feab81d5 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -261,9 +261,11 @@ class SetCommand(Command): Command.__init__(self, **kwargs) def apply(self, ui): + envelope = ui.current_buffer.envelope if self.reset: - del(ui.current_buffer.envelope[self.key]) - ui.current_buffer.envelope.add(self.key, self.value) + if self.key in envelope: + del(envelope[self.key]) + envelope.add(self.key, self.value) ui.current_buffer.rebuild() diff --git a/alot/defaults/alot.rc b/alot/defaults/alot.rc index 28ca3d4d..6e031b84 100644 --- a/alot/defaults/alot.rc +++ b/alot/defaults/alot.rc @@ -32,26 +32,6 @@ envelope_headers_blacklist = In-Reply-To,References # set terminal command used for spawning shell commands terminal_cmd = x-terminal-emulator -e -###################### -# HIGHLIGHT settings # -###################### -# Thread lines in the search buffer can be highlighted if they match a query -# by theming their components. - -# dictionary of highlighting rules. The keys are queries you want highlighting -# for; values are chosen designators that identify themeing options in the -# colour scheme: -# search_thread_<component>_<id>_[focus_][fg|bg] -# Note that the sequence of the list defines the search order. The first -# specified query that matches selects the themeing. -thread_highlight_rules = { "tag:unread AND tag:flagged":"isunread+flagged", - "tag:unread":"isunread", "tag:flagged":"isflagged" } - -# comma separated list of the components of a thread line you want highlighted -# if a query matches. -# Possible components are [date|mailcount|tags|authors|subject]. -thread_highlight_components = subject - #################### # EDITOR settings # #################### @@ -195,6 +175,24 @@ clo = close bp = bprevious ls = bufferlist +[highlighting] +# Thread lines in the search buffer can be highlighted if they match a query +# by theming their components. + +# dictionary of highlighting rules. The keys are queries you want highlighting +# for; values are chosen designators that identify themeing options in the +# colour scheme: +# search_thread_<component>_<id>_[focus_][fg|bg] +# Note that the sequence of the list defines the search order. The first +# specified query that matches selects the themeing. +rules = { "tag:unread AND tag:flagged":"isunread+flagged", + "tag:unread":"isunread", + "tag:flagged":"isflagged" } + +# comma separated list of the components of a thread line you want highlighted +# if a query matches. +# Possible components are [date|mailcount|tags|authors|subject|content]. +components = subject [256c-theme] @@ -246,8 +244,12 @@ search_thread_authors_isunread+flagged_focus_fg = #8f6,bold search_thread_bg = default search_thread_content_bg = default search_thread_content_fg = #866 +search_thread_content_isunread_fg = #866,bold +search_thread_content_isunread+flagged_fg = #866,bold search_thread_content_focus_bg = #68a search_thread_content_focus_fg = #866 +search_thread_content_isunread_focus_fg = #866,bold +search_thread_content_isunread+flagged_focus_fg = #866,bold search_thread_date_bg = default search_thread_date_fg = g58 search_thread_date_isunread_fg = g58,bold diff --git a/alot/message.py b/alot/message.py index b254230c..54d29eca 100644 --- a/alot/message.py +++ b/alot/message.py @@ -502,6 +502,9 @@ class Envelope(object): if self.sent_time: self.modified_since_sent = True + def __contains__(self, name): + return self.headers.__contains__(name) + def get(self, key, fallback=None): """secure getter for header values that allows specifying a `fallback` return string (defaults to None). This returns the first matching value diff --git a/alot/settings.py b/alot/settings.py index 4dc407b2..2c410e97 100644 --- a/alot/settings.py +++ b/alot/settings.py @@ -183,14 +183,14 @@ class AlotConfigParser(FallbackConfigParser): """ rules = OrderedDict() try: - config_string = self.get('general', 'thread_highlight_rules') + config_string = self.get('highlighting', 'rules') rules = json.loads(config_string, object_pairs_hook=OrderedDict) except NoOptionError as err: logging.exception(err) except ValueError as err: report = ParsingError("Could not parse config option" \ - " 'thread_highlight_rules' in section" \ - " 'general': {reason}".format(reason=err)) + " 'rules' in section 'highlighting':" \ + " {reason}".format(reason=err)) logging.exception(report) finally: return rules @@ -230,8 +230,7 @@ class AlotConfigParser(FallbackConfigParser): base = 'tag' themes = [base, base + '_{}'.format(tag)] if (highlight and - 'tags' in self.getstringlist('general', - 'thread_highlight_components')): + 'tags' in self.getstringlist('highlighting', 'components')): themes.insert(1, base + '_{}'.format(highlight)) themes.insert(3, base + '_{}_{}'.format(tag, highlight)) if focus: diff --git a/alot/widgets.py b/alot/widgets.py index 7228d21d..b098ca9e 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -77,8 +77,8 @@ class ThreadlineWidget(urwid.AttrMap): self.tag_widgets = [] self.display_content = config.getboolean('general', 'display_content_in_threadline') - self.highlight_components = config.getstringlist('general', - 'thread_highlight_components') + self.highlight_components = config.getstringlist('highlighting', + 'components') self.highlight_rules = config.get_highlight_rules() self.rebuild() urwid.AttrMap.__init__(self, self.columns, @@ -148,9 +148,11 @@ class ThreadlineWidget(urwid.AttrMap): msgs.sort() lastcontent = ' '.join([m.get_text_content() for m in msgs]) contentstring = lastcontent.replace('\n', ' ').strip() - self.content_w = urwid.AttrMap(urwid.Text(contentstring, - wrap='clip'), - 'search_thread_content') + self.content_w = urwid.AttrMap(urwid.Text( + contentstring, + wrap='clip'), + self._get_theme('content') + ) cols.append(self.content_w) self.columns = urwid.Columns(cols, dividechars=1) @@ -170,7 +172,7 @@ class ThreadlineWidget(urwid.AttrMap): focus)}) if self.display_content: self.content_w.set_attr_map( - {None: 'search_thread_content_focus'}) + {None: self._get_theme('content', focus=True)}) else: self.date_w.set_attr_map({None: self._get_theme('date')}) self.mailcount_w.set_attr_map({None: self._get_theme('mailcount')}) @@ -179,7 +181,7 @@ class ThreadlineWidget(urwid.AttrMap): self.authors_w.set_attr_map({None: self._get_theme('authors')}) self.subject_w.set_attr_map({None: self._get_theme('subject')}) if self.display_content: - self.content_w.set_attr_map({None: 'search_thread_content'}) + self.content_w.set_attr_map({None: self._get_theme('content')}) return urwid.AttrMap.render(self, size, focus) def selectable(self): |