summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBence Ferdinandy <bence@ferdinandy.com>2022-12-08 14:15:33 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-14 11:24:43 +0100
commitadf74be4b5c55faa724d35ca7bea2603c3ef42f9 (patch)
tree87de802bbfef7a8455ad6e9d48f2a1f0b38a517a
parentc05c2ffe0424b048b10e7dd1aca59ae9cf631f12 (diff)
downloadaerc-adf74be4b5c55faa724d35ca7bea2603c3ef42f9.tar.gz
aerc-adf74be4b5c55faa724d35ca7bea2603c3ef42f9.zip
msglist: add attachment indicator
Add indicator of an attachment to the flags and make the character used to be configurable. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Jens Grassel <jens@wegtam.com>
-rw-r--r--config/triggers.go1
-rw-r--r--config/ui.go1
-rw-r--r--doc/aerc-config.5.scd7
-rw-r--r--lib/format/format.go10
-rw-r--r--widgets/msglist.go1
5 files changed, 17 insertions, 3 deletions
diff --git a/config/triggers.go b/config/triggers.go
index 5f315362..7b461e70 100644
--- a/config/triggers.go
+++ b/config/triggers.go
@@ -64,6 +64,7 @@ func (trig *TriggersConfig) ExecNewEmail(
Ui.ThisDayTimeFormat,
Ui.ThisWeekTimeFormat,
Ui.ThisYearTimeFormat,
+ Ui.IconAttachment,
format.Ctx{
FromAddress: account.From,
AccountName: account.Name,
diff --git a/config/ui.go b/config/ui.go
index 0fb6a248..440fccf3 100644
--- a/config/ui.go
+++ b/config/ui.go
@@ -45,6 +45,7 @@ type UIConfig struct {
IconSignedEncrypted string `ini:"icon-signed-encrypted"`
IconUnknown string `ini:"icon-unknown"`
IconInvalid string `ini:"icon-invalid"`
+ IconAttachment string `ini:"icon-attachment"`
DirListFormat string `ini:"dirlist-format"`
DirListDelay time.Duration `ini:"dirlist-delay"`
DirListTree bool `ini:"dirlist-tree"`
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 4fd04bfa..2ef3b000 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -112,7 +112,7 @@ These options are configured in the *[ui]* section of _aerc.conf_.
| _%v_
: sender first name (e.g. "Alex" in "Alex Smith <smith@example.net>")
| _%Z_
-: flags (O=old, N=new, r=answered, D=deleted, !=flagged, \*=marked)
+: flags (O=old, N=new, r=answered, D=deleted, !=flagged, \*=marked, a=attachment)
*timestamp-format* = _<timeformat>_
See time.Time#Format at https://godoc.org/time#Time.Format
@@ -323,6 +323,11 @@ These options are configured in the *[ui]* section of _aerc.conf_.
Default: _[s!]_
+*icon-attachment* = _<string>_
+ The icon to display index-format when the message has an attachment.
+
+ Default: _a_
+
*fuzzy-complete* = _true_|_false_
When typing a command or option, the popover will now show not only the
items /starting/ with the string input by the user, but it will also show
diff --git a/lib/format/format.go b/lib/format/format.go
index e340c496..346702c6 100644
--- a/lib/format/format.go
+++ b/lib/format/format.go
@@ -80,7 +80,7 @@ type Ctx struct {
}
func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
- thisWeekTimeFmt string, thisYearTimeFmt string, ctx Ctx) (
+ thisWeekTimeFmt string, thisYearTimeFmt string, iconAttachment string, ctx Ctx) (
string, []interface{}, error,
) {
if ctx.MsgInfo.Error != nil {
@@ -298,6 +298,7 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
delFlag := ""
flaggedFlag := ""
markedFlag := ""
+ hasattachment := ""
seen := false
recent := false
answered := false
@@ -333,8 +334,13 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
if ctx.MsgIsMarked {
markedFlag = "*"
}
+ for _, bS := range ctx.MsgInfo.BodyStructure.Parts {
+ if strings.ToLower(bS.Disposition) == "attachment" {
+ hasattachment = iconAttachment
+ }
+ }
retval = append(retval, '4', 's')
- args = append(args, readReplyFlag+delFlag+flaggedFlag+markedFlag)
+ args = append(args, readReplyFlag+delFlag+flaggedFlag+markedFlag+hasattachment)
// Move the below cases to proper alphabetical positions once
// implemented
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 4c805d51..a12a4687 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -257,6 +257,7 @@ func (ml *MessageList) drawRow(textWidth int, ctx *ui.Context, uid uint32, row i
uiConfig.ThisDayTimeFormat,
uiConfig.ThisWeekTimeFormat,
uiConfig.ThisYearTimeFormat,
+ uiConfig.IconAttachment,
fmtCtx)
if err != nil {
ctx.Printf(0, row, style, "%v", err)