~sircmpwn/aerc

notmuch - Add support for new message notifications with a 'recent' tag. v2 PROPOSED

James Walmsley: 1
 notmuch - Add support for new message notifications with a 'recent' tag.

 2 files changed, 27 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/16311/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH v2] notmuch - Add support for new message notifications with a 'recent' tag. Export this patch

- In .notmuch-config ensure new-mails have the 'recent' tag added.

`.notmuch-config`
```
[new]
tags=unread;inbox;recent
```
---
 worker/notmuch/message.go | 25 ++++++++++++++++++++++++-
 worker/notmuch/worker.go  |  3 +++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/worker/notmuch/message.go b/worker/notmuch/message.go
index 82d00f3..4103059 100644
--- a/worker/notmuch/message.go
+++ b/worker/notmuch/message.go
@@ -70,6 +70,8 @@ func (m *Message) SetFlag(flag models.Flag, enable bool) error {
	// Translate the flag into a notmuch tag, ignoring no-op flags.
	var tag string
	switch flag {
	case models.RecentFlag:
		tag = "recent"
	case models.SeenFlag:
		// Note: Inverted properly later
		tag = "unread"
@@ -134,7 +136,26 @@ func (m *Message) Tags() ([]string, error) {
}

func (m *Message) Labels() ([]string, error) {
	return m.Tags()
	var labels, err = m.Tags()

	recentidx := 0
	recent := false

	for i, label := range labels {
		if(label == "recent") {
			recentidx = i
			recent = true
			break
		}
	}

	if(recent) {
		labels[recentidx] = labels[len(labels)-1]
		labels[len(labels)-1] = ""
		labels = labels[:len(labels)-1]
	}

	return labels, err
}

func (m *Message) ModelFlags() ([]models.Flag, error) {
@@ -152,6 +173,8 @@ func (m *Message) ModelFlags() ([]models.Flag, error) {
			flags = append(flags, models.FlaggedFlag)
		case "unread":
			seen = false
		case "recent":
			flags = append(flags, models.RecentFlag)
		default:
			continue
		}
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index 6281744..12f1f3c 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -536,6 +536,9 @@ func (w *worker) emitMessageInfo(m *Message,
	if err != nil {
		return fmt.Errorf("could not get MessageInfo: %v", err)
	}

	m.SetFlag(models.RecentFlag, false);

	w.w.PostMessage(&types.MessageInfo{
		Message: types.RespondTo(parent),
		Info:    info,
-- 
2.25.1
Hi,
Replied to the wrong version of the patch just earlier, but the same applies here.
Recent is not a magic tag of notmuch and we can't assume that to be the case.


On Fri, Jan 01, 2021 at 11:33:16PM +0000, James Walmsley wrote: