A minimal email TUI where you read with Markdown and write in Neovim. neomd.ssp.sh/docs
email markdown neovim tui
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

automatically pick right "from" address if more are configured and used in the same mailbox

sspaeti 57852425 bbd52521

+25
+25
internal/ui/model.go
··· 2752 2752 func (m Model) launchReplyWithCC(extraCC string, replyAll bool) (tea.Model, tea.Cmd) { 2753 2753 e := m.openEmail 2754 2754 2755 + // Auto-select the From address that matches the email's To/CC field. 2756 + // E.g. if email was sent to simon@ssp.sh, reply from simon@ssp.sh. 2757 + if idx := m.matchFromIndex(e.To, e.CC); idx >= 0 { 2758 + m.presendFromI = idx 2759 + } 2760 + 2755 2761 // Use Reply-To if present, else From 2756 2762 to := e.ReplyTo 2757 2763 if to == "" { ··· 2825 2831 } 2826 2832 return editorDoneMsg{to: pto, cc: pcc, bcc: "", subject: psubject, body: string(raw)} 2827 2833 }) 2834 + } 2835 + 2836 + // matchFromIndex returns the presendFroms() index whose email address matches 2837 + // one of the addresses in the email's To or CC fields. Returns -1 if no match. 2838 + // This auto-selects the correct From when replying to an email sent to an alias. 2839 + func (m Model) matchFromIndex(toField, ccField string) int { 2840 + froms := m.presendFroms() 2841 + recipients := make(map[string]bool) 2842 + for _, addr := range splitAddrs(toField + "," + ccField) { 2843 + if a := strings.ToLower(extractEmailAddr(addr)); a != "" { 2844 + recipients[a] = true 2845 + } 2846 + } 2847 + for i, from := range froms { 2848 + if recipients[strings.ToLower(extractEmailAddr(from))] { 2849 + return i 2850 + } 2851 + } 2852 + return -1 2828 2853 } 2829 2854 2830 2855 // extractEmailAddr returns the bare email address from "Name <addr>" or "addr".