Add labels to index format (%g)
Exposes the notmuch tags accordingly, stubs it for the maildir worker.
This commit is contained in:
parent
6794ce0d9c
commit
63391b7dca
7 changed files with 22 additions and 0 deletions
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue