Query Construction Advice

22 views
Skip to first unread message

Paul Hankes Drielsma

unread,
Jul 7, 2015, 1:22:28 PM7/7/15
to mu-di...@googlegroups.com
Hi all,

My work has a bunch of projects with different names, let's say "foo", "bar", and "baz".  Each project gets a bunch of mailing lists such as "foo-status", "foo-announcements", "foo-discuss", etc.  There's a common set of these suffixes that each project automatically gets.

I would like to create bookmarks to give me all the "*-announce" lists together, all the "*-status" ones, etc.  At present, I have a long query for each suffix like 
 "list:foo-status* OR list:bar-status* OR list:baz-status*" 
etc. etc.

This is particularly painful because we are regularly spinning up NEW projects with NEW codenames, and I have to go through each rule and modify them by hand.

So I thought I'd ask you experts: I realize that the wildcard can only appear rightmost in a query term, but is there any way I could build a query with the semantics
 "list:*-status*"
?

Any advice would be much appreciated.  

Thanks!
Paul.

Dirk-Jan C. Binnema

unread,
Jul 7, 2015, 11:43:55 PM7/7/15
to mu-di...@googlegroups.com
Unfortunately, the wildcard can only appear as the rightmost part of a
search term; mu supports some subset of
http://xapian.org/docs/queryparser.html

One way to accomplish what you want might be to have some tool (such as
procmail / Maildrop / Sieve) tag the messages for you.

Or perhaps you can use a little elisp to do the work of constructing
the queries, e.g.

--8<---------------cut here---------------start------------->8---
(require 'cl-lib)

(defun get-query (projects prefix)
"Get a query for lists with PREFIX for all PROJECTS."
(cl-reduce (lambda (a b) (concat a " OR " b))
(map 'list (lambda (p) (format "list:%s-%s" p prefix)) projects)))

(get-query '("foo" "bar" "baz") "announce")
--8<---------------cut here---------------end--------------->8---

and integrate something like that with setting up `mu4e-bookmarks'.

Cheers,
Dirk.


--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
Reply all
Reply to author
Forward
0 new messages