Skip to content

Commit

Permalink
mu4e: add mu4e-trash-without-flag
Browse files Browse the repository at this point in the history
Allow trashing with adding the T flag.
  • Loading branch information
djcb committed Dec 12, 2024
1 parent 3accb5f commit bd6a862
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
15 changes: 14 additions & 1 deletion mu4e/mu4e-mark.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ of message, showing the target makes this quite a bit
slower (showing the target uses Emacs overlays, which can be slow
when overused).")

(defvar mu4e-trash-without-flag nil
"Non-nil means avoid adding the Maildir T flag when trashing.
When \"trashing\" a message, it is moved to the \"trash\"-folder.
Furthermore, as per the Maildir-spec, the \"T\" flag is added to
its filename. This marks it for *manual* removal later.
Some message retrieval and IMAP synchronization tools, however,
interpret this flag instead as a trigger for *automatic* removal,
may not be what the user expects. If, so set the flag to non-nil.
This makes the \"trashing\" merely a move the trash-folder.")

;;; Insert stuff

(defvar mu4e--mark-map nil
Expand Down Expand Up @@ -160,7 +172,8 @@ The current buffer must be either a headers or view buffer."
:dyn-target (lambda (target msg) (mu4e-get-trash-folder msg))
:action (lambda (docid msg target)
(mu4e--server-move docid
(mu4e--mark-check-target target) "+T-N")))
(mu4e--mark-check-target target)
(if mu4e-trash-without-flag "-N" "+T-N"))))
(unflag
:char ("-" . "")
:prompt "-unflag"
Expand Down
39 changes: 25 additions & 14 deletions mu4e/mu4e.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,7 @@ can happen in both the @ref{Headers view} and the @ref{Message view}.
* Marking messages::Selecting message do something with them
* What to mark for::What can we do with them
* Executing the marks::Do it
* Trashing messages::Exceptions for mailboxes like Gmail
* Trashing messages::Marking messages for removal
* Leaving the headers buffer::Handling marks automatically when leaving
* Built-in marking functions::Helper functions for dealing with them
* Custom mark functions::Define your own mark function
Expand Down Expand Up @@ -2418,14 +2418,17 @@ arguments, the mark and the message itself.
@node Trashing messages
@section Trashing messages

For regular mailboxes, trashing works like other marks: when executed,
the message is flagged as trashed. Depending on your mailbox provider,
the trash flag is used to automatically move the message to the trash
folder (@code{mu4e-trash-folder}) for instance.
When ``trashing'' a message, it is moved to a trash-folder (i.e.,
@code{mu4e-trash-folder}) and is flagged as ``trashed'' (a ``T'' is added to its
filename).

Some mailboxes behave differently however and they don't interpret the
trash flag. In cases like Gmail, the message must be @emph{moved} to
the trash folder and the trash flag must not be used.
Following the Maildir specification, this flag is to be interpreted as ``marked
for manual removal later''. However, some mail retrieval and IMAP
synchronization programs interpret this instead as a trigger for
@emph{immediate} removal.

For such cases, you can influence @t{mu4e}'s behavior; see
@code{mu4e-trash-without-flag}.

@node Leaving the headers buffer
@section Leaving the headers buffer
Expand Down Expand Up @@ -4223,12 +4226,19 @@ seems to work quite well.
@subsection How can I disable the @t{Indexing...} messages?
Set the variable @code{mu4e-hide-index-messages} to non-@t{nil}.

@subsection IMAP-synchronization and file-name changes
Some IMAP-synchronization programs such as @t{mbsync} (but not
@t{offlineimap}) don't like it when message files do not change their
names when they are moved to different folders. @t{mu4e} can attempt to
help with this - you can set the variable
@code{mu4e-change-filenames-when-moving} to non-@t{nil}.
@subsection IMAP-synchronization

Some IMAP-synchronization programs such as @t{mbsync} (but not @t{offlineimap})
don't like it when message files do not change their names when they are moved
to different folders. @t{mu4e} can attempt to help with this - you can set the
variable @code{mu4e-change-filenames-when-moving} to non-@t{nil}.

Also, some of these programs may interpret the ``trash'' flag differently; see
@code{mu4e-trash-without-flag} for how to influence that.

Finally, we would warn against synchronizing the ``Drafts'' folder; the messages
in @t{mu4e}'s draft are in @t{mu4e}'s (i.e., Gnus') format, which is not
necessarily usable by other clients.

@subsection @command{offlineimap} and UTF-7
@command{offlineimap} uses IMAP's UTF-7 for encoding non-ascii folder
Expand All @@ -4240,6 +4250,7 @@ see @uref{https://github.com/djcb/mu/issues/68#issuecomment-8598652,this
ticket}.

@subsection @command{mbsync} or @command{offlineimap} do not sync properly

Unfortunately, @command{mbsync} and/or @command{offlineimap} do not
always agree with @t{mu} about the meaning of various Maildir-flags. If
you encounter unexpected behavior, it is recommended you check before
Expand Down

0 comments on commit bd6a862

Please sign in to comment.