How to not synchronize drafts folder?

193 views
Skip to first unread message

Mekeor Melire

unread,
Mar 5, 2017, 6:43:26 PM3/5/17
to mu-di...@googlegroups.com
Hello friends. :)

I'm reading Chapter “6.5 Signing and encrypting” from the manual. It
states:

“Important note: the messages are encrypted when they are sent: this
means that draft messages are not encrypted. So if you are using
e.g. offlineimap or mbsync to synchronize with some remote
IMAP-service, make sure the drafts folder is not in the set of
synchronized folders, for obvious reasons.”

That's why I'm now wondering how synchronization actually really works.
I'm using “mbsync” to fetch my mails. So, my (draft) mails will only be
synchronized when I invoke mu4e-update-mail-and-index, right?

To make sure no draft mails are synchronized, I decided to re-define
mu4e~draft-determine-path function so that it doesn't store the draft
mails in the synchronized maildir. Like so:

(defun mu4e~draft-determine-path (draft-dir)
"Determine the path for a new draft file."
(format "/home/user/drafts/%s"
(mu4e~draft-message-filename-construct "DS")))

Is this safe? Will it prevent synchronization of draft mails for sure?
Or am I missing something? Is there a better/easier way to do this?

--
mekeor ~ EDD3 DFFA 76F6 11C0 145F 9A99 AC85 BAD8 A2F8 C868

Ævar Arnfjörð Bjarmason

unread,
Mar 6, 2017, 7:16:05 AM3/6/17
to mu-di...@googlegroups.com
Instead of doing this with mu4e, it's better just to define a
"Patterns" config key in your "Channel", e.g. for one account I have:

Patterns INBOX Sent Drafts Trash Archives

You can just leave "Drafts" out, or don't and use the "Sync" directive
so e.g. it gets synced /from/ upstream but never pushed.

In offlineimap the "folderfilter" is the analogous facility.

Stig Brautaset

unread,
Mar 6, 2017, 7:27:18 AM3/6/17
to mu-di...@googlegroups.com

Mekeor Melire <mekeor...@gmail.com> writes:

> Hello friends. :)
>
> (defun mu4e~draft-determine-path (draft-dir)
> "Determine the path for a new draft file."
> (format "/home/user/drafts/%s"
> (mu4e~draft-message-filename-construct "DS")))
>
> Is this safe? Will it prevent synchronization of draft mails for sure?
> Or am I missing something? Is there a better/easier way to do this?

It's not really safe to rely on redefining any function/variable name
with `~'in it, as these can change at any time. (They're not part of the
public API.) However, you can "just" set the `mu4e-drafts-folder' to
something that is not handled by mbsync.

For me mbsync manages folders under ~/Maildir/Private and
~/Maildir/Work; I make my draft folder ~/Maildir/drafts (with `(setq
mu4e-drafts-folder "/drafts")') which is not in that set. Neither
Private nor Work mbsync config does include the server's drafts folder.

Stig
--
; GNU Emacs 25.1.1, Mu4e 0.9.19
Reply all
Reply to author
Forward
0 new messages