Commit d25d33ff cleaned up some of the tag face code. However, for the
face notmuch-tag-deleted it used the test
((class color) (supports :strike-through))
to decide whether to use red strikethrough or inverse-video (emacs in
a terminal typically doesn't support red strikethrough, but in X it does).
However, it seems that test often returns true even though red
strikethrough is not supported. This breaks the tag update code -- the
wrong thing is displayed to the user.
Thus we make the test explicitly more specific, changing the test to
((class color) (supports :strike-through "red"))
Many of the external links found in the notmuch source can be resolved
using https instead of http. This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
The second argument to notmuch-tag is now called tag-changes, but the
documentation for notmuch-before-tag-hook and notmuch-after-tag-hook
still used the old argument name `tags'. This resulted in broken hooks
when following the documentation.
Currently notmuch-tag throws a "wrong-type-argument stringp nil" if
passed a nil query-string. Catch this and provide a more useful error
message. This fixes a case in notmuch-tree (if you try to tag when at
the end of the buffer).
Secondly, as pointed out by David (dme)
`notmuch-search-find-stable-query-region' can return the query string
() if there are no messages in the region. This gets passed to notmuch
tag, and due to interactions in the optimize_query code in
notmuch-tag.c becomes, in the case tag-change is -inbox, "( () ) and
(tag:inbox)". This query matches some strange collection of messages
which then get archived. This should probably be fixed, but in any
case make `notmuch-search-find-stable-query-region' return a nil
query-string in this case.
This avoids data-loss (random tag removal) in this case.
This allows (and requires) the original-tags to be passed along with
the current-tags to be passed to notmuch-tag-format-tags. This allows
the tag formatting to show added and deleted tags.By default a removed
tag is displayed with strike-through in red (if strike-through is not
available, eg on a terminal, inverse video is used instead) and an
added tag is displayed underlined in green.
If the caller does not wish to use the new feature it can pass
current-tags for both arguments and, at this point, we do exactly that
in the three callers of this function.
Note, we cannot tidily allow original-tags to be optional because we would
need to distinguish nil meaning "we are not specifying original-tags"
from nil meaning there were no original-tags (an empty list).
We use this in subsequent patches to make it clear when a message was
unread when you first loaded a show buffer (previously the unread tag
could be removed before a user realised that it had been unread).
The code adds into the existing tag formatting code. The user can
specify exactly how a tag should be displayed normally, when deleted,
or when added.
Since the formatting code matches regexps a user can match all deleted
tags with a ".*" in notmuch-tag-deleted-formats. For example setting
notmuch-tag-deleted-formats to '((".*" nil)) tells notmuch not to show
deleted tags at all.
All the variables are customizable; however, more complicated cases
like changing the face depending on the type of display will require
custom lisp.
Currently this overrides notmuch-tag-deleted-formats for the tests
setting it to '((".*" nil)) so that they get removed from the display
and, thus, all tests still pass.
Add customize options for deleted/added tag formats. These are not
used yet but will be later in the series.
We switch to using `notmuch-apply-face' rather than `propertize' in
the defcustom for faces so that the faces for deleted/added tags add
to the default face attributes for the tag.
We special case deleting the unread tag as that tag is a strong visual
cue and we don't need that cue when we are just saying it used to be
unread. Thus, we revert to the normal tag face with strikethough for
deleted unread tags.
We will re-use the customize option for format-tags for formattting
deleted tags to added tags in the next patch so split it into a
widget. There should be no functional change.
This modifies `notmuch-tag-format-tag' to treat the keys of
`notmuch-tag-formats' as (anchored) regexps, rather than literal
strings. This is clearly more flexible, as it allows for prefix
matching, defining a fallback format, etc. This may cause compatibility
problems if people have customized `notmuch-tag-formats' to match tags
that contain regexp specials, but this seems unlikely.
Regular expression matching has quite a performance hit over string
lookup, so this also introduces a simple cache from exact tags to
formatted strings. The number of unique tags is likely to be quite
small, so this cache should have a high hit rate. In addition to
eliminating the regexp lookup in the common case, this cache stores
fully formatted tags, eliminating the repeated evaluation of potentially
expensive, user-specified formatting code. This makes regexp lookup at
least as fast as assoc for unformatted tags (e.g., inbox) and *faster*
than the current code for formatted tags (e.g., unread):
inbox (usec) unread (usec)
assoc: 0.4 2.8
regexp: 3.2 7.2
regexp+caching: 0.4 0.4
(Though even at 7.2 usec, tag formatting is not our top bottleneck.)
This cache must be explicitly cleared to keep it coherent, so this adds
the appropriate clearing calls.
This combines our two face combining functions into one, easy to use
function with a much shorter name: `notmuch-apply-face'. This
function takes the full set of arguments that
`notmuch-combine-face-text-property' took, but takes them in a more
convenient order and provides smarter defaults that make the function
easy to use on both strings and buffers.
Previously tree did not use tag-format-tags: since tree wants to
distinguish matching messages from non-matching messages it is not a
perfect fit.
However, in preparation for allowing tag-changes to be shown (i.e.,
added or deleted tags to be indicated) it is convenient to make all
places displaying tags call the same routines.
We modify notmuch-tag-format-tags slightly so that it can take and
argument for the default characteristics of the face before the
special tag features are applied.
This also means that things like the star symbol for flagged messages
all work in tree.
(Unfortunately, it's difficult to first demonstrate this problem with
a known-broken test because modern Linux kernels have argument length
limits in the megabytes, which makes Emacs really slow!)
Previously, when a user fully completed a tag operation, they had to
press space to begin entering another tag operation. This is
different from, say, shell file name completion, which typically
inserts a space after an unambiguous completion under the assumption
that the user will want to enter more input.
This patch tweaks `notmuch-read-tag-changes' to act more like shell
file name completion: after an unambiguous tag completion, it now
inserts a space, ready and waiting for another tagging operation from
the user. This is backwards-compatible with old habits, since there's
no harm in putting an extra space.
We no longer use this, since we've lifted all interactive behavior to
the appropriate interactive entry points. Because of this,
`notmuch-tag' also no longer needs to return the tag changes list,
since the caller always passes it in.
This modifies the interface of `notmuch-read-tag-changes' to take an
optional prompt string as well as a list of existing tags instead of a
query. This list of tags is used to populate the tag removal
completions and lets the caller compute these in a more
efficient/consistent manner than performing a potentially large or
complex query. This patch also updates the sole current caller of
`notmuch-read-tag-changes'.
Change foreground color to `blue' like lines representing threads
with flagged messages in notmuch-search. Before tag `flagged' was
shown in notmuch-show buffers as image star on graphical frames while
there was no visible distinction to other flags on terminal frames.
When compiling notmuch-tag.el there is a compile warning:
notmuch-tag.el:27:1:Warning: cl package required at runtime
Since we have decided to allow runtime use of cl we suppress this
warning by adding a tail comment to the file.
This patch extracts the rendering of tags in notmuch-show to
the notmuch-tag file.
This file introduces a `notmuch-tag-formats' variable that associates
each tag to a particular format. This variable can be customized
thanks to the work of Austin Clements. For example,
'(("unread" (propertize tag 'face '(:foreground "red")))
("flagged" (notmuch-tag-format-image tag "star.svg")))
associates a red foreground to the "unread" tag and a star picture to
the "flagged" tag.
Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
notmuch-tag is extended to accept various formats of the tag changes.
In particular, user prompting for tag changes is now incorporated
here, so it is common for modes.
The tag binary and the notmuch-{before,after}-tag-hooks are only
called if tag changes is non-nil.
In all cases tag-changes is returned as a list.
Tagging functions are used in notmuch.el, notmuch-show.el, and
notmuch-message.el. There are enough common functions for tagging
that it makes sense to put them all in their own library.
No code is modified, just moved around.