Tag based management of Gmail Labels (other than archiving!)

145 views
Skip to first unread message

Herschel Krustofsky

unread,
Mar 26, 2017, 4:17:40 PM3/26/17
to mu-discuss
Hi all,

I've been using some great contributed code to use mu4e very effectively with just the "All Mail" folder of Gmail, moving items to the Archive via label management. The code works well because it strips off any labels.

Has anyone successfully created code that can interactively retag messages to new labels? I'd like to be able to mark by a pattern and retag to a new or changed label. This is the equivalent to moving to a folder that is more standard mu4e behavior.

Thanks in advance if anyone has ideas or working code!


Stig Brautaset

unread,
Mar 26, 2017, 5:31:27 PM3/26/17
to mu-di...@googlegroups.com

Hi Herschel,

Herschel Krustofsky <krust...@gmail.com> writes:

> Hi all,
>
> I've been using some great contributed code to use mu4e very effectively
> with just the "All Mail" folder of Gmail, moving items to the Archive via
> label management. The code works well because it strips off any
> labels.

I believe you can safely ignore the Gmail "All Mail" folder and its
irritating IMAP behaviour. I don't sync that folder to my local machine
at all. Instead I created an "Archived"[1] label that I sync locally and
refile to that. Hope this helps.


Stig

[1] Annoyingly, "Archive" is a reserved word, so I can't use that :-(

Eduardo Mercovich

unread,
Mar 28, 2017, 7:44:31 AM3/28/17
to mu-di...@googlegroups.com
Hi Stig, hi everyone.

>> I've been using some great contributed code to use mu4e very
>> effectively
>> with just the "All Mail" folder of Gmail, moving items to the
>> Archive via
>> label management. The code works well because it strips off any
>> labels.

> I believe you can safely ignore the Gmail "All Mail" folder and
> its
> irritating IMAP behaviour. I don't sync that folder to my local
> machine
> at all. Instead I created an "Archived"[1] label that I sync
> locally and
> refile to that. Hope this helps.

Here I just sync the "All mail" + INBOX + drafts + trash.

If it's useful for someone, everything I did with labels can be
done (at least in my case) with searches, so there is no need to
label anything. :)

Best...


--
Eduardo Mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.
(Anónimo)

Magnus Therning

unread,
Apr 4, 2017, 4:48:28 AM4/4/17
to mu-di...@googlegroups.com

Eduardo Mercovich <eduardo....@gmail.com> writes:

> Hi Stig, hi everyone.
>
>>> I've been using some great contributed code to use mu4e very effectively
>>> with just the "All Mail" folder of Gmail, moving items to the Archive via
>>> label management. The code works well because it strips off any
>>> labels.
>
>> I believe you can safely ignore the Gmail "All Mail" folder and its
>> irritating IMAP behaviour. I don't sync that folder to my local machine
>> at all. Instead I created an "Archived"[1] label that I sync locally and
>> refile to that. Hope this helps.
>
> Here I just sync the "All mail" + INBOX + drafts + trash.
>
> If it's useful for someone, everything I did with labels can be done (at least
> in my case) with searches, so there is no need to label anything. :)

I even skip syncing INBOX, instead having a bookmarked search for
\Inbox.

/M

--
Magnus Therning OpenPGP: 0x927912051716CE39
email: mag...@therning.org jabber: mag...@therning.org
twitter: magthe http://therning.org/magnus

There does not now, nor will there ever, exist a programming language
in which it is the least bit hard to write bad programs.
— Flon's Axiom
signature.asc

Herschel Krustofsky

unread,
Apr 4, 2017, 11:07:07 AM4/4/17
to mu-di...@googlegroups.com
Hi there,

I think I am doing the same as Magnus. I just sync All Mail and work with labels. The code that's been shared is great for bulk archiving, because you don't need to programatically input the right label - you just set everything to the Archive tag (or strip labels and get the same thing). But when I want to go set 10 things to "Dog" and another to "Cat" and a third to "Followup" - I can't figure it out.

Net/Net - I like the Gmail Labels & tag approach and want to be able to use it from mu4e without reverting to folders. Any ideas? Magnus - do you already have this and I am not understanding some of the code you've shared?

Thanks,

Herschel

Eduardo Mercovich

unread,
Apr 6, 2017, 7:15:31 AM4/6/17
to mu-di...@googlegroups.com
Hi Magnus, hi everyone.

[...]

>> Here I just sync the "All mail" + INBOX + drafts + trash.

[...]

> I even skip syncing INBOX, instead having a bookmarked search
> for
> \Inbox.

I thought about it too, but left this because for a quick check
it's faster to sync only the inbox.
So along the usual complete sync I set up a channel -in mbsync
parlance- to sync just the inbox and that's done in a flinch. :)

Eduardo Mercovich

unread,
Apr 6, 2017, 7:16:57 AM4/6/17
to mu-di...@googlegroups.com
Hi Herschel.

[...]

> I think I am doing the same as Magnus. I just sync All Mail and
> work with labels.

> [...] I like the Gmail Labels & tag approach and want to be able

Magnus Therning

unread,
May 9, 2017, 8:04:42 AM5/9/17
to mu-di...@googlegroups.com

Sorry for taking so long to respond.

Herschel Krustofsky <krust...@gmail.com> writes:

> I think I am doing the same as Magnus. I just sync All Mail and work
> with labels. The code that's been shared is great for bulk archiving,
> because you don't need to programatically input the right label - you
> just set everything to the Archive tag (or strip labels and get the
> same thing). But when I want to go set 10 things to "Dog" and another
> to "Cat" and a third to "Followup" - I can't figure it out.

The interface for labelling is slightly clunky, but it's not something I
do often enough to get irritated with it. Instead I have a rather long
list of filters configured on the GMail side that sets labels
automatically.

> Net/Net - I like the Gmail Labels & tag approach and want to be able
> to use it from mu4e without reverting to folders. Any ideas? Magnus -
> do you already have this and I am not understanding some of the code
> you've shared?

I'm not sure I understand what you are after. What I have is some
bookmarks (based on searches):

- bi - inbox
- bf - flagged (starred) messages
- bu - unread messages

It would help me greatly to know what code it is you are referring to :)

/M

--
Magnus Therning OpenPGP: 0x927912051716CE39
email: mag...@therning.org jabber: mag...@therning.org
twitter: magthe http://therning.org/magnus

Some people, when confronted with a problem, think,
“I know, I’ll write my own LISP.” Now they are Paul Graham.
signature.asc

Aaron Jensen

unread,
May 14, 2017, 1:58:26 PM5/14/17
to mu-discuss
On Tuesday, April 4, 2017 at 1:48:28 AM UTC-7, Magnus Therning wrote:
I even skip syncing INBOX, instead having a bookmarked search for
\Inbox.

I've tried to get this working, but I'm not seeing any X-Keywords headers at all, and none w/ \Inbox. Is there something wrong w/ my setup, or did something change w/ Gmail? I'm using mbsync btw.

Eduardo Mercovich

unread,
May 15, 2017, 7:03:52 PM5/15/17
to mu-di...@googlegroups.com
Hi Aaron.

> [...] I'm not seeing any X-Keywords headers at all, and none w/
> \Inbox. Is there something wrong w/ my setup, or did something
> change w/ Gmail? I'm using mbsync btw.

Is it possible to share your mbsyncrc, of course without the
sensible information?
Maybe we can help you better in that way.

Aaron Jensen

unread,
May 15, 2017, 7:13:11 PM5/15/17
to mu-di...@googlegroups.com
Sure, here's my personal one as of now, note that I'm using inbox and
all mail as separate folders now. This actually seems to be working
pretty well for me, but I haven't tried the various cases of reading
the email in all mail first and having that read state get synced. I
do seem to see the mail in all mail get read if I read it in inbox
then refile to all.

IMAPAccount personal
Host imap.gmail.com
User email
PassCmd "...'"
AuthMechs PLAIN
SSLType IMAPS

IMAPStore personal-remote
Account personal

MaildirStore personal-local
Path ~/Maildir/personal/

Channel sync-personal-trash
Master :personal-remote:"[Gmail]/Trash"
Slave :personal-local:trash

Channel sync-personal-inbox
Master :personal-remote:"INBOX"
Slave :personal-local:inbox

Channel sync-personal-all
Master :personal-remote:"[Gmail]/All Mail"
Slave :personal-local:all

Channel sync-personal-sent
Master :personal-remote:"[Gmail]/Sent Mail"
Slave :personal-local:sent

Channel sync-personal-drafts
Master :personal-remote:"[Gmail]/Drafts"
Slave :personal-local:drafts

Channel sync-personal-spam
Master :personal-remote:"[Gmail]/Spam"
Slave :personal-local:spam

# Get all the channels together into a group.
Group personal
Channel sync-personal-trash
Channel sync-personal-inbox
Channel sync-personal-all
Channel sync-personal-sent
Channel sync-personal-drafts
Channel sync-personal-spam

# Automatically create missing mailboxes, both locally and on the serv
Create Both
# Save the synchronization state files in the relevant directory
SyncState *
# Gmail is configured to auto-expunge, so just expunge locally.
Expunge Slave
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "mu-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/mu-discuss/c3ywnDYQJ9g/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> mu-discuss+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Eduardo Mercovich

unread,
May 17, 2017, 5:24:47 PM5/17/17
to mu-di...@googlegroups.com
Hi Aaron.

> Sure, here's my personal one as of now, note that I'm using
> inbox and all mail as separate folders now. This actually seems
> to be working pretty well for me, [...] I do seem to see the
> mail in all mail get read if I read it in inbox then refile to
> all.

It works, that how I have it. :)

> IMAPAccount personal
> Host imap.gmail.com
[...]

Everything looks ok to me... :)

> # Get all the channels together into a group.
> Group personal
> Channel sync-personal-trash
> Channel sync-personal-inbox
> Channel sync-personal-all
> Channel sync-personal-sent
> Channel sync-personal-drafts
> Channel sync-personal-spam

You can create a specific channel to check inbox(es) also, without
touching this "all channels". But it looks ok to me. Maybe someone
more knowledgeable may spot something.

However, I don't know if this will work with your desired
X-Keywords headers...

Aaron Jensen

unread,
May 18, 2017, 1:20:17 AM5/18/17
to mu-di...@googlegroups.com

Eduardo Mercovich writes:

> Hi Aaron.
>
> It works, that how I have it. :)

Yeah, it's still working for me, so I'll probably just keep it as such.

> You can create a specific channel to check inbox(es) also, without
> touching this "all channels".

Does this mean a Group that groups all of my inbox Channels together for faster
syncing? I've thought about this, but right now I'm relying on mu4e's background
updating because I couldn't get mbsync working via a cron job on macOS.

> But it looks ok to me. Maybe someone more knowledgeable may spot something.

Thank you for taking a look.

> However, I don't know if this will work with your desired
> X-Keywords headers...

Yeah, I'm not sure how to get those headers from gmail. Maybe that's a legacy
thing or a setting. I haven't seen anything like it.

--
Aaron

Eduardo Mercovich

unread,
May 18, 2017, 3:00:26 PM5/18/17
to mu-di...@googlegroups.com
Hi Aaron.

[...]
>> You can create a specific channel to check inbox(es) also,
>> without
>> touching this "all channels".

> Does this mean a Group that groups all of my inbox Channels
> together for faster
> syncing? I've thought about this, but right now I'm relying on
> mu4e's background
> updating because I couldn't get mbsync working via a cron job on
> macOS. [...]

I do the same too, background sync every 10 minutes.

However, when you're in a specific hurry (like "I forgot my
password" and I need it now to access that site), this trick is
quite handy. ;)

1. Make your channel into a script.

2 Then -since you can launch any shell command from within
mu4e(emacs) with "Meta-!"- go for it. That updates just your
desired inbox(es).

3. Couple that with launching mu4e-update-index (binded in my case
to the small "u" since big "U" is update mail and index) and there
you are.

Inbox checking in a pinch. :)

Magnus Therning

unread,
May 26, 2017, 6:55:08 AM5/26/17
to mu-di...@googlegroups.com
No idea. Those headers are there for me, and always have ;)

I'm using offlineimap with a setup like this:

~~~
[Repository HomeRemote]
type = Gmail
remoteuser = <my user>
remotepass = <my passwd>
folderfilter = lambda folder: folder.startswith('[Gmail]/') and \
folder[8:] in ['All Mail', 'Bin', 'Drafts', 'Spam']
trashfolder = [Gmail]/Bin
maxconnections = 3
realdelete = no
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
~~~

Maybe it's worth setting up offlineimap just to see if the pulled emails
differ?

/M

--
Magnus Therning OpenPGP: 0x927912051716CE39
email: mag...@therning.org jabber: mag...@therning.org
twitter: magthe http://therning.org/magnus

For a successful technology, reality must take precedence over public
relations, for nature cannot be fooled.
— R.P. Feynman
signature.asc
Reply all
Reply to author
Forward
0 new messages