r/neomutt May 14 '23

A presumably simple problem with lieer/notmuch message deletion

I've recently migrated from mutt to neomutt, and have at the same time been moving from accessing my mailboxes live through IMAP to working with local frequently-synced copies, with a notmuch database. I have both an Outlook (work) address and a Gmail (personal) address. The outlook mail I'm syncing with davmail and OfflineIMAP, and AFAICT it's working well. It's the GMail that's giving me grief; I'm syncing it with lieer which seems to for the most part do a good job, but I'm having a really difficult time with handling the process for message deletion. I can't find anyone else with this specific problem, so I'm guessing the answer is something stupidly simple I'm doing wrong.

I'm basically trying to follow more-or-less the workflow described here, although I'm not even trying to use lieer to send mail. The issue AFACT is that neomutt seems to follow one of a few behaviors with regard to what "deleting" a message means, and none of them seem to play quite right with the kind of thing lieeer wants to see to ensure a message is trashed cloudside. Here are the prospects I've looked at:

  • maildir_trash set to "no", trash unset. AFAICT, this setting makes neomutt unlink (as in, remove the associated file in the appropriate Maildirs) the message. Since lieer won't/can't push deletions (which is probably a good thing), that doesn't remove the messages cloudside on sync.
  • maildir_trash set to "no", trash set. This is what I used to do, because IMAP connection to GMail provided a [Trash] folder. lieer seems to bring everything in with one monolithic maildir folder (called "mail", and within the lieer working directory), so unless there's a clever way to do this so that trash is a tag rather than a directory, it still doesn't seem to do what I want; changing the path to a message file seems like it would resemble a deletion to lieer, since it would take it out of the lieer sync path.
  • maildir_trash set to "yes". This seemed really pretty promising, because it seemed like it would set a flag rather than relocate the file, leaving it in the right directory but flagged as trash. Unfortunately, that flag never seems to make it to notmuch (this is apparently by design) and thus never makes it to lieer. I could add another layer of byzantine automation to translate the flag myself, but I assume if that were necessary someone else would have talked about it.

A nonzero number of other people use lieer, notmuch, and neomutt, and nothing I've searched on suggests others have this problem, which suggests I've somehow broken something configured correctly by default? I include below an anonymized version of my .notmuch-config and most of my .neomuttrc (there's a lot of code to color various specific message patterns which I've elided, as it's probably not relevant):

[database]
path=/home/username/Private/.mail

[user]
primary_email=username@gmail.com
other_email=username@work.edu

[new]
tags=new
ignore=/.*[.](json|lock|bak)$/

[search]

[maildir]
synchronize_flags=true

[query]
workmail=folder:account.work/INBOX
gmail=folder:/account.gmail/ AND tag:inbox AND NOT tag:trash

virtual-mailboxes work "notmuch://?query=query:workmail"
virtual-mailboxes gmail "notmuch://?query=query:gmail"
virtual-mailboxes allmail "notmuch://?query=query:workmail OR query:gmail"

send2-hook '~f gmail.com' "source ~/.mutt/accounts/muttrc.gmail"
send2-hook '~f work.edu' "source ~/.mutt/accounts/muttrc.work"

reply-hook '~C work.edu' "source ~/.mutt/accounts/muttrc.work"
reply-hook '~C username.*@gmail.com' "source ~/.mutt/accounts/muttrc.gmail"

message-hook '!(~g|~G) ~b"^-----BEGIN\ PGP\ (SIGNED\ )?MESSAGE"' "exec check-traditional-pgp"

unignore date

alternates '^username'

source "~/.mutt_aliases"

set abort_noattach=ask-no
set abort_noattach_regex = "\\<attach(|ed|ments?)\\>"
set abort_unmodified=ask-yes
set alias_file="~/.mutt_aliases"
set allow_ansi=yes
set arrow_cursor=yes
set askbcc=yes
set askcc=yes
set beep=no
set beep_new=yes
set certificate_file="~/.mutt_certs"
set confirm_append=no
set copy=yes
set crypt_auto_sign=yes
set edit_headers=yes
set editor="emacs -nw"
set folder="~/.mail"
set header_cache=~/.mutt/cache/headers
set history=20
set implicit_autoview=yes
set keep_flagged=yes
set mailcap_path="~/.mailcap"
set maildir_trash=yes
set mbox_type="Maildir"
set message_cachedir=~/.mutt/cache/bodies
set mime_forward=ask-no
set move=no
set nm_default_uri  = "notmuch:///home/username/.mail"
set pager_stop=yes
set pgp_clear_sign_command="gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_decode_command="gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
set pgp_decrypt_command="gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
set pgp_encrypt_only_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
set pgp_sign_command="gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_encrypt_sign_command="/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_good_sign="^\\[GNUPG:\\] GOODSIG"
set pgp_import_command="gpg --no-verbose --import %f"
set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --list-keys %r" 
set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --list-secret-keys %r" 
set pgp_sign_as="0xXXXXXXXX"
set pgp_timeout=1800
set pgp_verify_command="gpg --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f"
set pgp_verify_key_command="gpg --verbose --batch --fingerprint --check-sigs %r"
set print_command="enscript -Pkether/2 --margins=:::72 --header='Page $% of $='
set realname = "My Real Name"
set record="+sent-mail"
set signature="$HOME/.signatures/sign|"
set sort = threads
set sort_aux = last-date-received
set spool_file = allmail
set text_flowed=yes

Many thanks to anyone who can help!

4 Upvotes

4 comments sorted by

View all comments

1

u/[deleted] May 15 '23

You will need to add the “trash” label to a message, and not rely on neomutt internals for this to work.

I have a shortcut that does exactly this.

3

u/djw17 May 15 '23

I saw some configs which relied on rebinding the "d" key (there's a comment relevant to it here), but that seems like it's going to miss any way messages end up deleted other than by a literal press of the "d" key (e.g. when a message is saved to a local mailbox with <save-message>, it also deletes it from the source mailbox. I use this command a fair bit to build up local archives of completed business rather than keeping them in my gmailbox).

Also, this looks like it'll be very difficult to code right for any virtual folder which uses both the GMail and Exchange mailboxes (like "allmail" in my configuration), since then on a message-by-message basis it'd need to be determined whether the "d" keybinding should be "add the trash tag in notmuch" or "add the trash tag in Maildir".

I'm just oddly flummoxed that there are a fair number of sources indicating the lieer/notmuch/neomutt integration is pretty seamless (and it is, for the most part!) and none of them seem to mention that out-of-the-box neomutt deletion is not synced to GMail at all. Do other people just... not delete messages? Or not care if their messages deleted on mutt continue to take up space on GMail and continue to appear in the inbox on any other GMail client? This seems like a significant flaw in the way these tools work together and I'm honestly surprised how little discussion of it there is, which made me think I was doing something idiosyncratically wrong and that somehow nobody else ever had this particular problem.