How to get all emails addressed to me directly

20 views
Skip to first unread message

Damien Cassou

unread,
Apr 16, 2015, 7:32:08 AM4/16/15
to mu-di...@googlegroups.com
Hi,

I would like a search query that takes all emails addressed to me
directly (either through to:, cc: or bcc:) as opposed to mails sent to a
mailing list. I thought about doing something like "NOT list:*" but that
would filter emails sent to mailing list where I'm on CC.

Do any of you have an idea?

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Ken Mankoff

unread,
Apr 16, 2015, 7:39:42 AM4/16/15
to mu-di...@googlegroups.com

I think you can form complex queries with nested parentheses. Have you tried

(to:me AND (NOT list:*)) OR cc:me

-k.

Damien Cassou

unread,
Apr 16, 2015, 10:58:41 AM4/16/15
to mu-di...@googlegroups.com

Ken Mankoff <man...@gmail.com> writes:

> I think you can form complex queries with nested parentheses. Have you tried
>
> (to:me AND (NOT list:*)) OR cc:me

"me" in queries never worked for me. Does it work for others? I always
have to write to:damien* but this is not really satisfactory in this
case.

Ken Mankoff

unread,
Apr 16, 2015, 11:04:21 AM4/16/15
to mu-di...@googlegroups.com

On 2015-04-16 at 10:58, Damien Cassou <damien...@gmail.com> wrote:
> Ken Mankoff <man...@gmail.com> writes:
>>
>> I think you can form complex queries with nested parentheses. Have you tried
>>
>> (to:me AND (NOT list:*)) OR cc:me
>
> "me" in queries never worked for me. Does it work for others? I always
> have to write to:damien* but this is not really satisfactory in this
> case.

Why not satisfactory? Replace "to:me" with (to:a OR to:b OR to:c) for multiple 'me'...

-k.

Damien Cassou

unread,
Apr 16, 2015, 11:31:22 AM4/16/15
to mu-di...@googlegroups.com
because:

1- I have several email addresses, not all of them with the prefix
"damien". This means I have to write them all in the query.

2- There are other "damien" in the world who are not me (shame on them)

Because mu knows all my email addresses (through
`mu4e-user-mail-address-list`), I thought this could be automatically
handled.

Ken Mankoff

unread,
Apr 16, 2015, 11:57:05 AM4/16/15
to mu-di...@googlegroups.com

On 2015-04-16 at 11:31, Damien Cassou <damien...@gmail.com> wrote:
> Ken Mankoff <man...@gmail.com> writes:
>
>> On 2015-04-16 at 10:58, Damien Cassou <damien...@gmail.com> wrote:
>>> Ken Mankoff <man...@gmail.com> writes:
>>>> (to:me AND (NOT list:*)) OR cc:me
>>>
>>> "me" in queries never worked for me. Does it work for others? I always
>>> have to write to:damien* but this is not really satisfactory in this
>>> case.
>>
>> Why not satisfactory? Replace "to:me" with (to:a OR to:b OR to:c) for multiple 'me'...
>
> 1- I have several email addresses, not all of them with the prefix
> "damien". This means I have to write them all in the query.

Yes you have to write it, but just 1x. Unless you are changing emails frequently...

> 2- There are other "damien" in the world who are not me (shame on them)

Use the full address.

> Because mu knows all my email addresses (through
> `mu4e-user-mail-address-list`), I thought this could be automatically
> handled.

Yes, that would be nice...

-k.

Josiah Schwab

unread,
Apr 16, 2015, 3:46:25 PM4/16/15
to mu-di...@googlegroups.com
Hi Damien,

>> Because mu knows all my email addresses (through
>> `mu4e-user-mail-address-list`), I thought this could be automatically
>> handled.
>
> Yes, that would be nice...

Can you solve your problem with a bookmark? Something like

(defun jws/mu4e-addressed-to-me ()
(mapconcat (lambda (a) (format "to:%s" a)) mu4e-user-mail-address-list " OR "))

(setq mu4e-bookmarks
`( (,(jws/mu4e-addressed-to-me) "To Me" ?m)))

You likely want to replace the lambda with something more general (to &
cc, etc.)

Best,
Josiah

Damien Cassou

unread,
Apr 17, 2015, 5:35:11 AM4/17/15
to mu-di...@googlegroups.com
Josiah Schwab <jsc...@gmail.com> writes:

> Can you solve your problem with a bookmark? Something like
>
> (defun jws/mu4e-addressed-to-me ()
> (mapconcat (lambda (a) (format "to:%s" a)) mu4e-user-mail-address-list " OR "))
>
> (setq mu4e-bookmarks
> `( (,(jws/mu4e-addressed-to-me) "To Me" ?m)))


that's what I had in mind but was looking for a better solution.


> You likely want to replace the lambda with something more general (to &
> cc, etc.)

the 'recip' field matches to, cc and bcc directly.

Here is what I came up with:

(setq my:mu4e-account-alist
'(("GMail"
...
("Pro"
...
("Lille1"
...
("Perso"
...)))

(defun my:mu4e-account-names ()
(mapcar #'car my:mu4e-account-alist))

(defun my:mu4e-addressed-to-me ()
(mapconcat
(lambda (address) (format "recip:%s" address))
mu4e-user-mail-address-list " OR "))

(defun my:mu4e-in-inbox ()
(mapconcat
(lambda (account-name) (format "maildir:/%s/INBOX" account-name))
(my:mu4e-account-names)
" OR "))

(add-to-list 'mu4e-bookmarks
`(,(concat
"("
(my:mu4e-addressed-to-me)
") AND ("
(my:mu4e-in-inbox)
" OR maildir:\"/GMail/All Mail\") AND (tag:\\\\Inbox OR NOT maildir:\"/GMail/All Mail\")") "Inbox" ?i))

Yes, that's a bit complex :-).


Thanks for your help
Reply all
Reply to author
Forward
0 new messages