~sircmpwn/aerc

Config option to set index format for sent folder v2 PROPOSED

I would prefer to build out something more general for this, like config
options which take effect in a certain folder.

[ui]
index-format=...

[ui:folder=Sent]
index-format=...

[ui:folder~Archive/\d+/.*]
index-format=...

Thoughts?
> I would prefer to build out something more general for this, like config
> options which take effect in a certain folder.
> 
> [ui]
> index-format=...
> 
> [ui:folder=Sent]
> index-format=...
> 
> [ui:folder~Archive/\d+/.*]
> index-format=...
> 
> Thoughts?
Totally makes sense, let me work on this a bit more and send another patch.
Making this more general will make it more customizable.
--
Cheers,
Srivathsan Murali (sri)
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/%3C20191002181648.1643248-1-sri%40vathsan.com%3E/mbox | git am -3
Learn more about email & git

[PATCH v2] Config option to set index format for sent folder Export this patch

Adds a config option "sent-index-format" that sets the
index format for messages in the sent directory.
The default value is set to show the address of the
first recepient instead of the sender.

This could be possible implementation for #292.
---
Fixes the formatting issue in v1

 config/aerc.conf.in   | 7 +++++++
 config/config.go      | 2 ++
 doc/aerc-config.5.scd | 6 ++++++
 widgets/msglist.go    | 7 ++++++-
 4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index ec89ff7e9d26..9fe318b71022 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -9,6 +9,13 @@
 # Default:
 index-format=%D %-17.17n %s
 
+#
+# Describes the format for each row in a mailbox view of the sent directory.
+# This field is compatible with mutt's printf-like syntax.
+#
+# Default: %D %-17.17t %s
+sent-index-format=%D %-17.17t %s
+
 #
 # See time.Time#Format at https://godoc.org/time#Time.Format
 #
diff --git a/config/config.go b/config/config.go
index 133a7f4ed5ca..d320939a14f2 100644
--- a/config/config.go
+++ b/config/config.go
@@ -24,6 +24,7 @@ type GeneralConfig struct {
 
 type UIConfig struct {
 	IndexFormat         string   `ini:"index-format"`
+	SentIndexFormat     string   `ini:"sent-index-format"`
 	TimestampFormat     string   `ini:"timestamp-format"`
 	ShowHeaders         []string `delim:","`
 	RenderAccountTabs   string   `ini:"render-account-tabs"`
@@ -343,6 +344,7 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 
 		Ui: UIConfig{
 			IndexFormat:     "%D %-17.17n %s",
+			SentIndexFormat: "%D %-17.17t %s",
 			TimestampFormat: "2006-01-02 03:04 PM",
 			ShowHeaders: []string{
 				"From", "To", "Cc", "Bcc", "Subject", "Date",
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index f4f02f2cb0f3..9b9f9432c8dc 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -40,6 +40,12 @@ These options are configured in the *[ui]* section of aerc.conf.
 
 	Default: %D %-17.17n %s
 
+*sent-index-format*
+	Describes the format for each row in a mailbox view of the sent directory.
+	This field is compatible with mutt's printf-like syntax.
+
+	Default: %D %-17.17t %s
+
 [- *Format specifier*
 :[ *Description*
 |  %%
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 5c2d2f447852..d44a96acf60d 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -69,6 +69,11 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
 	)
 	uids := store.Uids()
 
+	indexFormat := ml.conf.Ui.IndexFormat
+	if ml.aerc.SelectedAccount().Directories().Selected() == "Sent" {
+		indexFormat = ml.conf.Ui.SentIndexFormat
+	}
+
 	for i := len(uids) - 1 - ml.scroll; i >= 0; i-- {
 		uid := uids[i]
 		msg := store.Messages[uid]
@@ -107,7 +112,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
 
 		ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
 		fmtStr, args, err := format.ParseMessageFormat(
-			ml.conf.Ui.IndexFormat,
+			indexFormat,
 			ml.conf.Ui.TimestampFormat, "", i, msg)
 		if err != nil {
 			ctx.Printf(0, row, style, "%v", err)
-- 
2.23.0
I would prefer to build out something more general for this, like config
options which take effect in a certain folder.

[ui]
index-format=...

[ui:folder=Sent]
index-format=...

[ui:folder~Archive/\d+/.*]
index-format=...

Thoughts?
View this thread in the archives