From fca7321639f77bbf825dc897156d7a21993a2c69 Mon Sep 17 00:00:00 2001 From: Yash Srivastav Date: Sat, 8 Jun 2019 01:05:23 +0530 Subject: Message list: implement index-format option --- commands/msg/reply.go | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'commands/msg') diff --git a/commands/msg/reply.go b/commands/msg/reply.go index e09a118..a9ae5a1 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -6,7 +6,6 @@ import ( "fmt" "io" gomail "net/mail" - "regexp" "strings" "git.sr.ht/~sircmpwn/getopt" @@ -15,6 +14,7 @@ import ( _ "github.com/emersion/go-message/charset" "github.com/emersion/go-message/mail" + "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/widgets" ) @@ -23,25 +23,6 @@ func init() { register("forward", Reply) } -var ( - atom *regexp.Regexp = regexp.MustCompile("^[a-z0-9!#$%7'*+-/=?^_`{}|~ ]+$") -) - -func formatAddress(addr *imap.Address) string { - if addr.PersonalName != "" { - if atom.MatchString(addr.PersonalName) { - return fmt.Sprintf("%s <%s@%s>", - addr.PersonalName, addr.MailboxName, addr.HostName) - } else { - return fmt.Sprintf("\"%s\" <%s@%s>", - strings.ReplaceAll(addr.PersonalName, "\"", "'"), - addr.MailboxName, addr.HostName) - } - } else { - return fmt.Sprintf("<%s@%s>", addr.MailboxName, addr.HostName) - } -} - func Reply(aerc *widgets.Aerc, args []string) error { opts, optind, err := getopt.Getopts(args[1:], "aq") if err != nil { @@ -96,14 +77,14 @@ func Reply(aerc *widgets.Aerc, args []string) error { } if replyAll { for _, addr := range msg.Envelope.Cc { - cc = append(cc, formatAddress(addr)) + cc = append(cc, lib.FormatAddress(addr)) } for _, addr := range msg.Envelope.To { address := fmt.Sprintf("%s@%s", addr.MailboxName, addr.HostName) if address == us.Address { continue } - to = append(to, formatAddress(addr)) + to = append(to, lib.FormatAddress(addr)) } } } -- cgit v1.2.3