* mu: allow 'recip:' in queries as a shortcut for "to:foo OR cc:foo OR bcc:foo"

This commit is contained in:
djcb 2012-10-25 12:28:55 +03:00
parent 9bf8edf03b
commit 412de6f4aa
5 changed files with 31 additions and 11 deletions

6
NEWS
View File

@ -9,6 +9,7 @@
- add 'mu script' command to run mu script, for example to do statistics on - add 'mu script' command to run mu script, for example to do statistics on
your message corpus your message corpus
- allow 'contact:' as a shortcut in queries for 'from:foo OR to:foo OR - allow 'contact:' as a shortcut in queries for 'from:foo OR to:foo OR
cc:foo OR bcc:foo', and 'recip:' as a shortcut for 'to:foo OR
cc:foo OR bcc:foo' cc:foo OR bcc:foo'
*** mu4e *** mu4e
@ -23,6 +24,11 @@
message view. Thanks to Abdó Roig-Maranges. New field ":tags". message view. Thanks to Abdó Roig-Maranges. New field ":tags".
- automatically update the headers buffer when new messages are found during - automatically update the headers buffer when new messages are found during
indexing; set `mu4e-headers-auto-update' to nil to disable this. indexing; set `mu4e-headers-auto-update' to nil to disable this.
- update mail/index with M-x mu4e-update-mail-and-index; which everywhere in
mu4e is available with key C-S-u. Use prefix argument to run in
background.
- add function `mu4e-update-index' to only update the index
* Old news * Old news
:PROPERTIES: :PROPERTIES:

View File

@ -67,6 +67,10 @@ static const MuMsgFieldId MU_MSG_FIELD_ID_NONE = (MuMsgFieldId)-1;
* in mu-query.cc and mu-str.c */ * in mu-query.cc and mu-str.c */
#define MU_MSG_FIELD_PSEUDO_CONTACT "contact" #define MU_MSG_FIELD_PSEUDO_CONTACT "contact"
/* this is a shortcut for To/Cc/Bcc in queries; handled specially in
* mu-query.cc and mu-str.c */
#define MU_MSG_FIELD_PSEUDO_RECIP "recip"
#define mu_msg_field_id_is_valid(MFID) \ #define mu_msg_field_id_is_valid(MFID) \
((MFID) < MU_MSG_FIELD_ID_NUM) ((MFID) < MU_MSG_FIELD_ID_NUM)

View File

@ -187,8 +187,7 @@ private:
void add_special_prefixes () { void add_special_prefixes () {
char pfx[] = { '\0', '\0' }; char pfx[] = { '\0', '\0' };
/* add 'contact' as a shortcut for /* add 'contact' as a shortcut for From/Cc/Bcc/To: */
* From/Cc/Bcc/To: */
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_FROM); pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_FROM);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx); _qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_TO); pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_TO);
@ -197,6 +196,14 @@ private:
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx); _qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_BCC); pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_BCC);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx); _qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
/* add 'recip' as a shortcut for Cc/Bcc/To: */
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_TO);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_RECIP, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_CC);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_RECIP, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_BCC);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_RECIP, pfx);
} }
Xapian::QueryParser _qparser; Xapian::QueryParser _qparser;

View File

@ -439,8 +439,11 @@ check_for_field (const char *str, gboolean *is_field,
&pfx); &pfx);
/* also check special prefixes... */ /* also check special prefixes... */
if (!pfx.match) if (!pfx.match)
pfx.match = g_str_has_prefix pfx.match =
(str, MU_MSG_FIELD_PSEUDO_CONTACT ":"); g_str_has_prefix
(str, MU_MSG_FIELD_PSEUDO_CONTACT ":") ||
g_str_has_prefix
(str, MU_MSG_FIELD_PSEUDO_RECIP ":");
*is_field = pfx.match; *is_field = pfx.match;
*is_range_field = pfx.range_field; *is_range_field = pfx.range_field;

View File

@ -119,14 +119,14 @@ search fields and their abbreviations:
tag,x Tags for the message (\fIX-Label\fR and/or \fIX-Keywords\fR) tag,x Tags for the message (\fIX-Label\fR and/or \fIX-Keywords\fR)
.fi .fi
There is also the special field \fBcontact\fR, which matches all There are also the special fields \fBcontact\fR, which matches all
contact-fields (\fBfrom\fR, \fBto\fR, \fBcc\fR and \fBbcc\fR). contact-fields (\fBfrom\fR, \fBto\fR, \fBcc\fR and \fBbcc\fR), and
\fBrecip\fR, which matches all recipient-fields (\fBto\fR, \fBcc\fR and
\fBbcc\fR).
The meaning of most of these fields should be clear, but some require some The meaning of most of the above fields should be clear, but some require some
extra discusion. extra discusion. First, the message flags field describes certain properties
of the message, as listed in the following table:
First, the message flags field describes certain properties of the message, as
listed in the following table:
.nf .nf
d,draft Draft Message d,draft Draft Message