Add labels to index format (%g)

Exposes the notmuch tags accordingly, stubs it for the maildir worker.
This commit is contained in:
Reto Brunner 2019-12-23 12:51:58 +01:00 committed by Drew DeVault
parent 6794ce0d9c
commit 63391b7dca
7 changed files with 22 additions and 0 deletions

View File

@ -59,6 +59,8 @@ These options are configured in the *[ui]* section of aerc.conf.
| %F | %F
: author name, or recipient name if the message is from you. : author name, or recipient name if the message is from you.
The adderss is shown if no name part. The adderss is shown if no name part.
| %g
: message labels (for example notmuch tags)
| %i | %i
: message id : message id
| %n | %n

View File

@ -138,6 +138,10 @@ func ParseMessageFormat(
retval = append(retval, 's') retval = append(retval, 's')
args = append(args, val) args = append(args, val)
case 'g':
retval = append(retval, 's')
args = append(args, strings.Join(msg.Labels, ", "))
case 'i': case 'i':
retval = append(retval, 's') retval = append(retval, 's')
args = append(args, msg.Envelope.MessageId) args = append(args, msg.Envelope.MessageId)

View File

@ -149,6 +149,7 @@ func merge(to *models.MessageInfo, from *models.MessageInfo) {
to.Envelope = from.Envelope to.Envelope = from.Envelope
} }
to.Flags = from.Flags to.Flags = from.Flags
to.Labels = from.Labels
if from.Size != 0 { if from.Size != 0 {
to.Size = from.Size to.Size = from.Size
} }

View File

@ -57,6 +57,7 @@ type MessageInfo struct {
BodyStructure *BodyStructure BodyStructure *BodyStructure
Envelope *Envelope Envelope *Envelope
Flags []Flag Flags []Flag
Labels []string
InternalDate time.Time InternalDate time.Time
RFC822Headers *mail.Header RFC822Headers *mail.Header
Size uint32 Size uint32

View File

@ -207,6 +207,7 @@ func parseAddressList(h *mail.Header, key string) ([]*models.Address, error) {
type RawMessage interface { type RawMessage interface {
NewReader() (io.Reader, error) NewReader() (io.Reader, error)
ModelFlags() ([]models.Flag, error) ModelFlags() ([]models.Flag, error)
Labels() ([]string, error)
UID() uint32 UID() uint32
} }
@ -233,10 +234,15 @@ func MessageInfo(raw RawMessage) (*models.MessageInfo, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
labels, err := raw.Labels()
if err != nil {
return nil, err
}
return &models.MessageInfo{ return &models.MessageInfo{
BodyStructure: bs, BodyStructure: bs,
Envelope: env, Envelope: env,
Flags: flags, Flags: flags,
Labels: labels,
InternalDate: env.Date, InternalDate: env.Date,
RFC822Headers: &mail.Header{msg.Header}, RFC822Headers: &mail.Header{msg.Header},
Size: 0, Size: 0,

View File

@ -119,3 +119,7 @@ func translateFlags(maildirFlags []maildir.Flag) []models.Flag {
func (m Message) UID() uint32 { func (m Message) UID() uint32 {
return m.uid return m.uid
} }
func (m Message) Labels() ([]string, error) {
return nil, nil
}

View File

@ -102,6 +102,10 @@ func (m *Message) Tags() ([]string, error) {
return m.db.MsgTags(m.key) return m.db.MsgTags(m.key)
} }
func (m *Message) Labels() ([]string, error) {
return m.Tags()
}
func (m *Message) ModelFlags() ([]models.Flag, error) { func (m *Message) ModelFlags() ([]models.Flag, error) {
var flags []models.Flag var flags []models.Flag
seen := true seen := true