query: add related: combi-field + test
Add a new combination (pseudo) field "related:", which combines "message-id" and "references"
This commit is contained in:
@ -38,6 +38,10 @@ Mu::combi_fields()
|
|||||||
field_from_id(Field::Id::Cc),
|
field_from_id(Field::Id::Cc),
|
||||||
field_from_id(Field::Id::Bcc),
|
field_from_id(Field::Id::Bcc),
|
||||||
field_from_id(Field::Id::From)}},
|
field_from_id(Field::Id::From)}},
|
||||||
|
CombiField { "related",
|
||||||
|
{ field_from_id(Field::Id::MessageId),
|
||||||
|
field_from_id(Field::Id::References)}
|
||||||
|
},
|
||||||
CombiField { "",
|
CombiField { "",
|
||||||
{ field_from_id(Field::Id::To),
|
{ field_from_id(Field::Id::To),
|
||||||
field_from_id(Field::Id::Cc),
|
field_from_id(Field::Id::Cc),
|
||||||
|
|||||||
@ -217,10 +217,6 @@ Boo!
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_related()
|
test_related()
|
||||||
{
|
{
|
||||||
@ -262,7 +258,6 @@ Child
|
|||||||
TempDir tdir;
|
TempDir tdir;
|
||||||
auto store{make_test_store(tdir.path(), test_msgs, {})};
|
auto store{make_test_store(tdir.path(), test_msgs, {})};
|
||||||
{
|
{
|
||||||
// direct matches
|
|
||||||
auto qr = store.run_query("msgid:aap@foo.bar", Field::Id::Date,
|
auto qr = store.run_query("msgid:aap@foo.bar", Field::Id::Date,
|
||||||
QueryFlags::None);
|
QueryFlags::None);
|
||||||
g_assert_true(!!qr);
|
g_assert_true(!!qr);
|
||||||
@ -271,7 +266,6 @@ Child
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// skip duplicate messages; which one is skipped is arbitrary.
|
|
||||||
auto qr = store.run_query("msgid:aap@foo.bar", Field::Id::Date,
|
auto qr = store.run_query("msgid:aap@foo.bar", Field::Id::Date,
|
||||||
QueryFlags::IncludeRelated);
|
QueryFlags::IncludeRelated);
|
||||||
g_assert_true(!!qr);
|
g_assert_true(!!qr);
|
||||||
@ -280,7 +274,6 @@ Child
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// skip duplicate messages; which one is skipped is arbitrary.
|
|
||||||
auto qr = store.run_query("msgid:mies@foo.bar", Field::Id::Date,
|
auto qr = store.run_query("msgid:mies@foo.bar", Field::Id::Date,
|
||||||
QueryFlags::IncludeRelated);
|
QueryFlags::IncludeRelated);
|
||||||
g_assert_true(!!qr);
|
g_assert_true(!!qr);
|
||||||
@ -289,7 +282,6 @@ Child
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// skip duplicate messages; which one is skipped is arbitrary.
|
|
||||||
auto qr = store.run_query("ref:aap@foo.bar", Field::Id::Date,
|
auto qr = store.run_query("ref:aap@foo.bar", Field::Id::Date,
|
||||||
QueryFlags::None);
|
QueryFlags::None);
|
||||||
g_assert_true(!!qr);
|
g_assert_true(!!qr);
|
||||||
@ -297,8 +289,14 @@ Child
|
|||||||
g_assert_cmpuint(qr->size(), ==, 2);
|
g_assert_cmpuint(qr->size(), ==, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto qr = store.run_query("related:aap@foo.bar", Field::Id::Date,
|
||||||
|
QueryFlags::None);
|
||||||
|
g_assert_true(!!qr);
|
||||||
|
g_assert_false(qr->empty());
|
||||||
|
g_assert_cmpuint(qr->size(), ==, 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_dups_related()
|
test_dups_related()
|
||||||
|
|||||||
@ -183,6 +183,8 @@ fields at once:
|
|||||||
+-------------+-----------------------------------------+
|
+-------------+-----------------------------------------+
|
||||||
| contact | to, cc, bcc, from |
|
| contact | to, cc, bcc, from |
|
||||||
+-------------+-----------------------------------------+
|
+-------------+-----------------------------------------+
|
||||||
|
| related | message-id, references |
|
||||||
|
+-------------+-----------------------------------------+
|
||||||
| <empty> | to, cc, bcc, from, subject, body, embed |
|
| <empty> | to, cc, bcc, from, subject, body, embed |
|
||||||
+-------------+-----------------------------------------+
|
+-------------+-----------------------------------------+
|
||||||
#+end_example
|
#+end_example
|
||||||
|
|||||||
@ -352,10 +352,38 @@ either `future' or `past'."
|
|||||||
(read-string prompt initial-input 'mu4e--search-hist)))
|
(read-string prompt initial-input 'mu4e--search-hist)))
|
||||||
|
|
||||||
(defconst mu4e--search-query-keywords
|
(defconst mu4e--search-query-keywords
|
||||||
'("and" "or" "not"
|
'(;; logical
|
||||||
"from:" "to:" "cc:" "bcc:" "contact:" "recip:" "date:" "subject:" "body:"
|
"and"
|
||||||
"list:" "maildir:" "flag:" "mime:" "file:" "prio:" "tag:" "msgid:"
|
"or"
|
||||||
"size:" "embed:"))
|
"not"
|
||||||
|
;; fields
|
||||||
|
"bcc:"
|
||||||
|
"body:"
|
||||||
|
"cc:"
|
||||||
|
"changed:"
|
||||||
|
"date:"
|
||||||
|
"embed:"
|
||||||
|
"file:"
|
||||||
|
"flag:"
|
||||||
|
"from:"
|
||||||
|
"lang:"
|
||||||
|
"maildir:"
|
||||||
|
"list:"
|
||||||
|
"msgid"
|
||||||
|
"mime:"
|
||||||
|
"path:"
|
||||||
|
"prio:"
|
||||||
|
"ref"
|
||||||
|
"size:"
|
||||||
|
"subject:"
|
||||||
|
"tags:"
|
||||||
|
"thread:"
|
||||||
|
"to:"
|
||||||
|
;; combin fields
|
||||||
|
"recip:"
|
||||||
|
"contact:"
|
||||||
|
"related:")
|
||||||
|
"Mu4e query-keywords for completion.")
|
||||||
|
|
||||||
(defun mu4e--search-completion-contacts-action (match _status)
|
(defun mu4e--search-completion-contacts-action (match _status)
|
||||||
"Delete contact alias from contact autocompletion, leaving just email address.
|
"Delete contact alias from contact autocompletion, leaving just email address.
|
||||||
@ -378,7 +406,8 @@ status, STATUS."
|
|||||||
(list (match-beginning 1)
|
(list (match-beginning 1)
|
||||||
(match-end 1)
|
(match-end 1)
|
||||||
'("attach" "draft" "flagged" "list" "new" "passed" "replied"
|
'("attach" "draft" "flagged" "list" "new" "passed" "replied"
|
||||||
"seen" "trashed" "unread" "encrypted" "signed" "personal")))
|
"seen" "trashed" "unread" "encrypted" "signed" "personal"
|
||||||
|
"calendar")))
|
||||||
((looking-back "maildir:\\([a-zA-Z0-9/.]*\\)" nil)
|
((looking-back "maildir:\\([a-zA-Z0-9/.]*\\)" nil)
|
||||||
(list (match-beginning 1)
|
(list (match-beginning 1)
|
||||||
(match-end 1)
|
(match-end 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user