neomutt icon indicating copy to clipboard operation
neomutt copied to clipboard

How to refresh a virtual-mailbox?

Open rionda opened this issue 3 years ago • 12 comments

I have virtual-mailboxes based on notmuch tags. I use nm_query_type=thread. Assume that I'm in the index for the virtual-mailbox foo, and there is a thread with one message with tag foo and one message without tag foo. I use <modify-labels> to remove the tag foo from the message that has this tag. Then I use <sync-mailbox>.

I would expect the whole thread to not show up anymore in the index. Instead, the thread (both messages) is still there. If I use <modify-labels-then-hide> to remove the tag, only the message that originally already did not contain the foo tag shows up (which is possibly even more confusing, although it makes some sense).

Is this expected behavior?

rionda avatar Mar 02 '22 20:03 rionda

@scottkosty @flatcap Wanted to bump this. I'm running into a simple use case that would benefit from a feature where we re-read a vfolder.

I'm using lierr and notmuch and often will archive a message in the gmail interface. After syncing using a script bound to s, I land back on a virtual-mailbox called "Inbox" which is simply notmuch://?query=tag:inbox". The sync would have caused one of the messages to have the inbox tag removed but the index doesn't get updated with this change. The only way (that I've found) to force the index is to update is to <change-vfolder> and then neomutt re-reads the virtual query.

Any better suggestions on how to force a re-read of a virtual mailbox from notmuch?

nickwynja avatar May 31 '22 17:05 nickwynja

@nickwynja I have the same setup as you do. Perhaps I'm using a different function than you do. The trick is in modify-tags-then-hide This is my bindings to archive a message(s)

macro index,pager ,a      "<modify-tags-then-hide>-unread -inbox\n<sync-mailbox><check-stats>"

jindraj avatar May 31 '22 17:05 jindraj

@jindraj I'm referring to a slightly different workflow. In this case, I'm actually doing the archiving on the gmail web interface.

What I'm looking for is a way to force the index to reload from disk. From my understanding, <sync-mailbox> writes changes to disk but doesn't read changes. So the only way I can get the index to update to reflect the changes on disk is the change vfolder. Maybe something like a <read-mailbox>?

nickwynja avatar May 31 '22 17:05 nickwynja

ah, understood. I'm afraid that only reopening the current mailbox is currently the only way. Sometimes I need to do this also. For this case I have some bindings for most commonly used mailboxes.

macro index,pager gi      "<change-vfolder>!<enter>"                  "Go to Inbox"

jindraj avatar May 31 '22 18:05 jindraj

@jindraj What is ! in this case? I'm hoping it's a shortcut for "current folder" 🤞

nickwynja avatar May 31 '22 18:05 nickwynja

@nickwynja sorry I do not have any knowledge about what's under the hood regarding NeoMutt and notmuch. I'm glad @jindraj jumped in :)

scottkosty avatar May 31 '22 18:05 scottkosty

unfortunately it's not. ! refers to spoolfile (usually inbox). But having a special character to represent current folder sounds like a good idea to me. Let's wait for @flatcap, what does he think about this.

jindraj avatar May 31 '22 18:05 jindraj

An undesirable side effect of chaining a change-vfolder command to my sync macro is that my message selection always seems to be reset to the next unread message or the bottom of the index list, if there are no unread messages.

Any idea if there's a setting to change this behavior? I haven't been able to find one yet.

nickwynja avatar May 31 '22 18:05 nickwynja

Will <change-folder>^ work?

https://neomutt.org/guide/advancedusage.html#shortcuts

flatcap avatar May 31 '22 18:05 flatcap

@flatcap That does work. Any pointers on avoiding the selection jumping to next unread or last message on <change-folder>^?

nickwynja avatar May 31 '22 18:05 nickwynja

Hmm... There's a way to mark a specific message, ~ + a letter, e.g ~z<enter> As long as the threads aren't collapsed it seems to work. Something like:

macro index <f5> "<mark-message>z<enter><change-folder>^<enter>'z"

flatcap avatar May 31 '22 18:05 flatcap

That works perfectly! This was a long-term minor nuisance so thanks, all, for the help here.

nickwynja avatar May 31 '22 18:05 nickwynja