diff options
Diffstat (limited to 'commands/msg')
-rw-r--r-- | commands/msg/archive.go | 22 | ||||
-rw-r--r-- | commands/msg/copy.go | 12 | ||||
-rw-r--r-- | commands/msg/delete.go | 22 | ||||
-rw-r--r-- | commands/msg/envelope.go | 12 | ||||
-rw-r--r-- | commands/msg/fold.go | 7 | ||||
-rw-r--r-- | commands/msg/forward.go | 14 | ||||
-rw-r--r-- | commands/msg/invite.go | 16 | ||||
-rw-r--r-- | commands/msg/mark.go | 7 | ||||
-rw-r--r-- | commands/msg/modify-labels.go | 12 | ||||
-rw-r--r-- | commands/msg/move.go | 27 | ||||
-rw-r--r-- | commands/msg/pipe.go | 22 | ||||
-rw-r--r-- | commands/msg/read.go | 14 | ||||
-rw-r--r-- | commands/msg/recall.go | 22 | ||||
-rw-r--r-- | commands/msg/reply.go | 26 | ||||
-rw-r--r-- | commands/msg/toggle-thread-context.go | 7 | ||||
-rw-r--r-- | commands/msg/toggle-threads.go | 7 | ||||
-rw-r--r-- | commands/msg/unsubscribe.go | 44 | ||||
-rw-r--r-- | commands/msg/utils.go | 8 |
18 files changed, 148 insertions, 153 deletions
diff --git a/commands/msg/archive.go b/commands/msg/archive.go index 9753f664..f326d0c6 100644 --- a/commands/msg/archive.go +++ b/commands/msg/archive.go @@ -29,26 +29,26 @@ func (Archive) Aliases() []string { return []string{"archive"} } -func (Archive) Complete(aerc *app.Aerc, args []string) []string { +func (Archive) Complete(args []string) []string { valid := []string{"flat", "year", "month"} - return commands.CompletionFromList(aerc, valid, args) + return commands.CompletionFromList(valid, args) } -func (Archive) Execute(aerc *app.Aerc, args []string) error { +func (Archive) Execute(args []string) error { if len(args) != 2 { return errors.New("Usage: archive <flat|year|month>") } - h := newHelper(aerc) + h := newHelper() msgs, err := h.messages() if err != nil { return err } - err = archive(aerc, msgs, args[1]) + err = archive(msgs, args[1]) return err } -func archive(aerc *app.Aerc, msgs []*models.MessageInfo, archiveType string) error { - h := newHelper(aerc) +func archive(msgs []*models.MessageInfo, archiveType string) error { + h := newHelper() acct, err := h.account() if err != nil { return err @@ -74,7 +74,7 @@ func archive(aerc *app.Aerc, msgs []*models.MessageInfo, archiveType string) err archiveDir, fmt.Sprintf("%d", msg.Envelope.Date.Year()), fmt.Sprintf("%02d", msg.Envelope.Date.Month()), - }, aerc.SelectedAccount().Worker().PathSeparator(), + }, app.SelectedAccount().Worker().PathSeparator(), ) return dir }) @@ -83,7 +83,7 @@ func archive(aerc *app.Aerc, msgs []*models.MessageInfo, archiveType string) err dir := strings.Join([]string{ archiveDir, fmt.Sprintf("%v", msg.Envelope.Date.Year()), - }, aerc.SelectedAccount().Worker().PathSeparator(), + }, app.SelectedAccount().Worker().PathSeparator(), ) return dir }) @@ -104,7 +104,7 @@ func archive(aerc *app.Aerc, msgs []*models.MessageInfo, archiveType string) err case *types.Done: wg.Done() case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) success = false wg.Done() marker.Remark() @@ -117,7 +117,7 @@ func archive(aerc *app.Aerc, msgs []*models.MessageInfo, archiveType string) err wg.Wait() if success { - handleDone(aerc, acct, next, "Messages archived.", store) + handleDone(acct, next, "Messages archived.", store) } }() return nil diff --git a/commands/msg/copy.go b/commands/msg/copy.go index 3f3498a2..1a902772 100644 --- a/commands/msg/copy.go +++ b/commands/msg/copy.go @@ -22,11 +22,11 @@ func (Copy) Aliases() []string { return []string{"cp", "copy"} } -func (Copy) Complete(aerc *app.Aerc, args []string) []string { - return commands.GetFolders(aerc, args) +func (Copy) Complete(args []string) []string { + return commands.GetFolders(args) } -func (Copy) Execute(aerc *app.Aerc, args []string) error { +func (Copy) Execute(args []string) error { if len(args) == 1 { return errors.New("Usage: cp [-p] <folder>") } @@ -40,7 +40,7 @@ func (Copy) Execute(aerc *app.Aerc, args []string) error { createParents = true } } - h := newHelper(aerc) + h := newHelper() uids, err := h.markedOrSelectedUids() if err != nil { return err @@ -55,10 +55,10 @@ func (Copy) Execute(aerc *app.Aerc, args []string) error { ) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus("Messages copied.", 10*time.Second) + app.PushStatus("Messages copied.", 10*time.Second) store.Marker().ClearVisualMark() case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) } }) return nil diff --git a/commands/msg/delete.go b/commands/msg/delete.go index 37103da3..107c8a3f 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -22,16 +22,16 @@ func (Delete) Aliases() []string { return []string{"delete", "delete-message"} } -func (Delete) Complete(aerc *app.Aerc, args []string) []string { +func (Delete) Complete(args []string) []string { return nil } -func (Delete) Execute(aerc *app.Aerc, args []string) error { +func (Delete) Execute(args []string) error { if len(args) != 1 { return errors.New("Usage: :delete") } - h := newHelper(aerc) + h := newHelper() store, err := h.store() if err != nil { return err @@ -52,28 +52,28 @@ func (Delete) Execute(aerc *app.Aerc, args []string) error { store.Delete(uids, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus("Messages deleted.", 10*time.Second) + app.PushStatus("Messages deleted.", 10*time.Second) mv, isMsgView := h.msgProvider.(*app.MessageViewer) if isMsgView { if !config.Ui.NextMessageOnDelete { - aerc.RemoveTab(h.msgProvider, true) + app.RemoveTab(h.msgProvider, true) } else { // no more messages in the list if next == nil { - aerc.RemoveTab(h.msgProvider, true) + app.RemoveTab(h.msgProvider, true) acct.Messages().Select(-1) ui.Invalidate() return } lib.NewMessageStoreView(next, mv.MessageView().SeenFlagSet(), - store, aerc.Crypto, aerc.DecryptKeys, + store, app.CryptoProvider(), app.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } nextMv := app.NewMessageViewer(acct, view) - aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject, true) + app.ReplaceTab(mv, nextMv, next.Envelope.Subject, true) }) } } else { @@ -86,12 +86,12 @@ func (Delete) Execute(aerc *app.Aerc, args []string) error { case *types.Error: marker.Remark() store.Select(sel.Uid) - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) case *types.Unsupported: marker.Remark() store.Select(sel.Uid) // notmuch doesn't support it, we want the user to know - aerc.PushError(" error, unsupported for this worker") + app.PushError(" error, unsupported for this worker") } }) return nil diff --git a/commands/msg/envelope.go b/commands/msg/envelope.go index f5e50358..3a388c12 100644 --- a/commands/msg/envelope.go +++ b/commands/msg/envelope.go @@ -23,11 +23,11 @@ func (Envelope) Aliases() []string { return []string{"envelope"} } -func (Envelope) Complete(aerc *app.Aerc, args []string) []string { +func (Envelope) Complete(args []string) []string { return nil } -func (Envelope) Execute(aerc *app.Aerc, args []string) error { +func (Envelope) Execute(args []string) error { header := false fmtStr := "%-20.20s: %s" opts, _, err := getopt.Getopts(args, "hs:") @@ -43,7 +43,7 @@ func (Envelope) Execute(aerc *app.Aerc, args []string) error { } } - acct := aerc.SelectedAccount() + acct := app.SelectedAccount() if acct == nil { return errors.New("No account selected") } @@ -65,14 +65,14 @@ func (Envelope) Execute(aerc *app.Aerc, args []string) error { } n := len(list) - aerc.AddDialog(app.NewDialog( + app.AddDialog(app.NewDialog( app.NewListBox( "Message Envelope. Press <Esc> or <Enter> to close. "+ "Start typing to filter.", list, - aerc.SelectedAccountUiConfig(), + app.SelectedAccountUiConfig(), func(_ string) { - aerc.CloseDialog() + app.CloseDialog() }, ), // start pos on screen diff --git a/commands/msg/fold.go b/commands/msg/fold.go index 755a292f..1d40b90a 100644 --- a/commands/msg/fold.go +++ b/commands/msg/fold.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" ) @@ -19,15 +18,15 @@ func (Fold) Aliases() []string { return []string{"fold", "unfold"} } -func (Fold) Complete(aerc *app.Aerc, args []string) []string { +func (Fold) Complete(args []string) []string { return nil } -func (Fold) Execute(aerc *app.Aerc, args []string) error { +func (Fold) Execute(args []string) error { if len(args) != 1 { return fmt.Errorf("Usage: %s", args[0]) } - h := newHelper(aerc) + h := newHelper() store, err := h.store() if err != nil { return err diff --git a/commands/msg/forward.go b/commands/msg/forward.go index d1abbc5b..68f162cc 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -34,11 +34,11 @@ func (forward) Aliases() []string { return []string{"forward"} } -func (forward) Complete(aerc *app.Aerc, args []string) []string { +func (forward) Complete(args []string) []string { return nil } -func (forward) Execute(aerc *app.Aerc, args []string) error { +func (forward) Execute(args []string) error { opts, optind, err := getopt.Getopts(args, "AFT:eE") if err != nil { return err @@ -69,7 +69,7 @@ func (forward) Execute(aerc *app.Aerc, args []string) error { return errors.New("Options -A and -F are mutually exclusive") } - widget := aerc.SelectedTabContent().(app.ProvidesMessage) + widget := app.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -107,15 +107,15 @@ func (forward) Execute(aerc *app.Aerc, args []string) error { } addTab := func() (*app.Composer, error) { - composer, err := app.NewComposer(aerc, acct, + composer, err := app.NewComposer(acct, acct.AccountConfig(), acct.Worker(), editHeaders, template, h, &original, nil) if err != nil { - aerc.PushError("Error: " + err.Error()) + app.PushError("Error: " + err.Error()) return nil, err } - composer.Tab = aerc.NewTab(composer, subject) + composer.Tab = app.NewTab(composer, subject) if !h.Has("to") { composer.FocusEditor("to") } else { @@ -210,7 +210,7 @@ func (forward) Execute(aerc *app.Aerc, args []string) error { mu.Unlock() if err != nil { log.Errorf(err.Error()) - aerc.PushError(err.Error()) + app.PushError(err.Error()) } }) } diff --git a/commands/msg/invite.go b/commands/msg/invite.go index ceb043bb..76864f9a 100644 --- a/commands/msg/invite.go +++ b/commands/msg/invite.go @@ -26,12 +26,12 @@ func (invite) Aliases() []string { return []string{"accept", "accept-tentative", "decline"} } -func (invite) Complete(aerc *app.Aerc, args []string) []string { +func (invite) Complete(args []string) []string { return nil } -func (invite) Execute(aerc *app.Aerc, args []string) error { - acct := aerc.SelectedAccount() +func (invite) Execute(args []string) error { + acct := app.SelectedAccount() if acct == nil { return errors.New("no account selected") } @@ -128,7 +128,7 @@ func (invite) Execute(aerc *app.Aerc, args []string) error { h.SetMsgIDList("in-reply-to", []string{msg.Envelope.MessageId}) err = setReferencesHeader(h, msg.RFC822Headers) if err != nil { - aerc.PushError(fmt.Sprintf("could not set references: %v", err)) + app.PushError(fmt.Sprintf("could not set references: %v", err)) } original := models.OriginalMail{ From: format.FormatAddresses(msg.Envelope.From), @@ -155,11 +155,11 @@ func (invite) Execute(aerc *app.Aerc, args []string) error { } addTab := func(cr *calendar.Reply) error { - composer, err := app.NewComposer(aerc, acct, + composer, err := app.NewComposer(acct, acct.AccountConfig(), acct.Worker(), editHeaders, "", h, &original, cr.PlainText) if err != nil { - aerc.PushError("Error: " + err.Error()) + app.PushError("Error: " + err.Error()) return err } err = composer.AppendPart(cr.MimeType, cr.Params, cr.CalendarText) @@ -168,7 +168,7 @@ func (invite) Execute(aerc *app.Aerc, args []string) error { } composer.FocusTerminal() - composer.Tab = aerc.NewTab(composer, subject) + composer.Tab = app.NewTab(composer, subject) composer.OnClose(func(c *app.Composer) { if c.Sent() { @@ -181,7 +181,7 @@ func (invite) Execute(aerc *app.Aerc, args []string) error { store.FetchBodyPart(msg.Uid, part, func(reader io.Reader) { if cr, err := handleInvite(reader); err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } else { err := addTab(cr) diff --git a/commands/msg/mark.go b/commands/msg/mark.go index 27677609..eeaa5485 100644 --- a/commands/msg/mark.go +++ b/commands/msg/mark.go @@ -3,7 +3,6 @@ package msg import ( "fmt" - "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~sircmpwn/getopt" ) @@ -17,12 +16,12 @@ func (Mark) Aliases() []string { return []string{"mark", "unmark", "remark"} } -func (Mark) Complete(aerc *app.Aerc, args []string) []string { +func (Mark) Complete(args []string) []string { return nil } -func (Mark) Execute(aerc *app.Aerc, args []string) error { - h := newHelper(aerc) +func (Mark) Execute(args []string) error { + h := newHelper() OnSelectedMessage := func(fn func(uint32)) error { if fn == nil { return fmt.Errorf("no operation selected") diff --git a/commands/msg/modify-labels.go b/commands/msg/modify-labels.go index d61dc23b..d219a57e 100644 --- a/commands/msg/modify-labels.go +++ b/commands/msg/modify-labels.go @@ -19,17 +19,17 @@ func (ModifyLabels) Aliases() []string { return []string{"modify-labels", "tag"} } -func (ModifyLabels) Complete(aerc *app.Aerc, args []string) []string { - return commands.GetLabels(aerc, args) +func (ModifyLabels) Complete(args []string) []string { + return commands.GetLabels(args) } -func (ModifyLabels) Execute(aerc *app.Aerc, args []string) error { +func (ModifyLabels) Execute(args []string) error { changes := args[1:] if len(changes) == 0 { return errors.New("Usage: modify-labels <[+-]label> ...") } - h := newHelper(aerc) + h := newHelper() store, err := h.store() if err != nil { return err @@ -56,10 +56,10 @@ func (ModifyLabels) Execute(aerc *app.Aerc, args []string) error { ) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus("labels updated", 10*time.Second) + app.PushStatus("labels updated", 10*time.Second) store.Marker().ClearVisualMark() case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) } }) return nil diff --git a/commands/msg/move.go b/commands/msg/move.go index 847fa549..5ef9390a 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -25,11 +25,11 @@ func (Move) Aliases() []string { return []string{"mv", "move"} } -func (Move) Complete(aerc *app.Aerc, args []string) []string { - return commands.GetFolders(aerc, args) +func (Move) Complete(args []string) []string { + return commands.GetFolders(args) } -func (Move) Execute(aerc *app.Aerc, args []string) error { +func (Move) Execute(args []string) error { if len(args) == 1 { return errors.New("Usage: mv [-p] <folder>") } @@ -44,7 +44,7 @@ func (Move) Execute(aerc *app.Aerc, args []string) error { } } - h := newHelper(aerc) + h := newHelper() acct, err := h.account() if err != nil { return err @@ -71,9 +71,9 @@ func (Move) Execute(aerc *app.Aerc, args []string) error { ) { switch msg := msg.(type) { case *types.Done: - handleDone(aerc, acct, next, "Messages moved to "+joinedArgs, store) + handleDone(acct, next, "Messages moved to "+joinedArgs, store) case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) marker.Remark() } }) @@ -82,34 +82,33 @@ func (Move) Execute(aerc *app.Aerc, args []string) error { } func handleDone( - aerc *app.Aerc, acct *app.AccountView, next *models.MessageInfo, message string, store *lib.MessageStore, ) { - h := newHelper(aerc) - aerc.PushStatus(message, 10*time.Second) + h := newHelper() + app.PushStatus(message, 10*time.Second) mv, isMsgView := h.msgProvider.(*app.MessageViewer) switch { case isMsgView && !config.Ui.NextMessageOnDelete: - aerc.RemoveTab(h.msgProvider, true) + app.RemoveTab(h.msgProvider, true) case isMsgView: if next == nil { - aerc.RemoveTab(h.msgProvider, true) + app.RemoveTab(h.msgProvider, true) acct.Messages().Select(-1) ui.Invalidate() return } lib.NewMessageStoreView(next, mv.MessageView().SeenFlagSet(), - store, aerc.Crypto, aerc.DecryptKeys, + store, app.CryptoProvider(), app.DecryptKeys, func(view lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } nextMv := app.NewMessageViewer(acct, view) - aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject, true) + app.ReplaceTab(mv, nextMv, next.Envelope.Subject, true) }) default: if next == nil { diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go index e8c1e277..c9d88f40 100644 --- a/commands/msg/pipe.go +++ b/commands/msg/pipe.go @@ -28,11 +28,11 @@ func (Pipe) Aliases() []string { return []string{"pipe"} } -func (Pipe) Complete(aerc *app.Aerc, args []string) []string { +func (Pipe) Complete(args []string) []string { return nil } -func (Pipe) Execute(aerc *app.Aerc, args []string) error { +func (Pipe) Execute(args []string) error { var ( background bool pipeFull bool @@ -64,7 +64,7 @@ func (Pipe) Execute(aerc *app.Aerc, args []string) error { return errors.New("Usage: pipe [-mp] <cmd> [args...]") } - provider := aerc.SelectedTabContent().(app.ProvidesMessage) + provider := app.SelectedTabContent().(app.ProvidesMessage) if !pipeFull && !pipePart { if _, ok := provider.(*app.MessageViewer); ok { pipePart = true @@ -77,12 +77,12 @@ func (Pipe) Execute(aerc *app.Aerc, args []string) error { } doTerm := func(reader io.Reader, name string) { - term, err := commands.QuickTerm(aerc, cmd, reader) + term, err := commands.QuickTerm(cmd, reader) if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } - aerc.NewTab(term, name) + app.NewTab(term, name) } doExec := func(reader io.Reader) { @@ -102,14 +102,14 @@ func (Pipe) Execute(aerc *app.Aerc, args []string) error { }() err = ecmd.Run() if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) } else { if ecmd.ProcessState.ExitCode() != 0 { - aerc.PushError(fmt.Sprintf( + app.PushError(fmt.Sprintf( "%s: completed with status %d", cmd[0], ecmd.ProcessState.ExitCode())) } else { - aerc.PushStatus(fmt.Sprintf( + app.PushStatus(fmt.Sprintf( "%s: completed with status %d", cmd[0], ecmd.ProcessState.ExitCode()), 10*time.Second) } @@ -120,7 +120,7 @@ func (Pipe) Execute(aerc *app.Aerc, args []string) error { var uids []uint32 var title string - h := newHelper(aerc) + h := newHelper() store, err := h.store() if err != nil { if mv, ok := provider.(*app.MessageViewer); ok { @@ -174,7 +174,7 @@ func (Pipe) Execute(aerc *app.Aerc, args []string) error { case <-time.After(30 * time.Second): // TODO: find a better way to determine if store.FetchFull() // has finished with some errors. - aerc.PushError("Failed to fetch all messages") + app.PushError("Failed to fetch all messages") if len(messages) == 0 { return } diff --git a/commands/msg/read.go b/commands/msg/read.go index 10a874e3..bac2ceb3 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -21,7 +21,7 @@ func (FlagMsg) Aliases() []string { return []string{"flag", "unflag", "read", "unread"} } -func (FlagMsg) Complete(aerc *app.Aerc, args []string) []string { +func (FlagMsg) Complete(args []string) []string { return nil } @@ -32,7 +32,7 @@ func (FlagMsg) Complete(aerc *app.Aerc, args []string) []string { // // If this was called as 'read' or 'unread', it has the same effect as // 'flag' or 'unflag', respectively, but the 'Seen' flag is affected. -func (FlagMsg) Execute(aerc *app.Aerc, args []string) error { +func (FlagMsg) Execute(args []string) error { // The flag to change var flag models.Flags // User-readable name of the flag to change @@ -112,7 +112,7 @@ func (FlagMsg) Execute(aerc *app.Aerc, args []string) error { return fmt.Errorf(helpMessage) } - h := newHelper(aerc) + h := newHelper() store, err := h.store() if err != nil { return err @@ -152,10 +152,10 @@ func (FlagMsg) Execute(aerc *app.Aerc, args []string) error { store.Flag(toEnable, flag, true, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus(actionName+" flag '"+flagName+"' successful", 10*time.Second) + app.PushStatus(actionName+" flag '"+flagName+"' successful", 10*time.Second) store.Marker().ClearVisualMark() case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) } }) } @@ -163,10 +163,10 @@ func (FlagMsg) Execute(aerc *app.Aerc, args []string) error { store.Flag(toDisable, flag, false, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus(actionName+" flag '"+flagName+"' successful", 10*time.Second) + app.PushStatus(actionName+" flag '"+flagName+"' successful", 10*time.Second) store.Marker().ClearVisualMark() case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) } }) } diff --git a/commands/msg/recall.go b/commands/msg/recall.go index 4a08df29..2d999b1d 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -28,11 +28,11 @@ func (Recall) Aliases() []string { return []string{"recall"} } -func (Recall) Complete(aerc *app.Aerc, args []string) []string { +func (Recall) Complete(args []string) []string { return nil } -func (Recall) Execute(aerc *app.Aerc, args []string) error { +func (Recall) Execute(args []string) error { force := false editHeaders := config.Compose.EditHeaders @@ -54,7 +54,7 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { return errors.New("Usage: recall [-f] [-e|-E]") } - widget := aerc.SelectedTabContent().(app.ProvidesMessage) + widget := app.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -79,7 +79,7 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { if subject == "" { subject = "Recalled email" } - composer.Tab = aerc.NewTab(composer, subject) + composer.Tab = app.NewTab(composer, subject) composer.OnClose(func(composer *app.Composer) { worker := composer.Worker() uids := []uint32{msgInfo.Uid} @@ -90,9 +90,9 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { }, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: - aerc.PushStatus("Recalled message deleted", 10*time.Second) + app.PushStatus("Recalled message deleted", 10*time.Second) case *types.Error: - aerc.PushError(msg.Error.Error()) + app.PushError(msg.Error.Error()) } }) } @@ -104,10 +104,10 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { } lib.NewMessageStoreView(msgInfo, acct.UiConfig().AutoMarkRead, - store, aerc.Crypto, aerc.DecryptKeys, + store, app.CryptoProvider(), app.DecryptKeys, func(msg lib.MessageView, err error) { if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } var path []int @@ -116,11 +116,11 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { } msg.FetchBodyPart(path, func(reader io.Reader) { - composer, err := app.NewComposer(aerc, acct, + composer, err := app.NewComposer(acct, acct.AccountConfig(), acct.Worker(), editHeaders, "", msgInfo.RFC822Headers, nil, reader) if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) return } if md := msg.MessageDetails(); md != nil { @@ -159,7 +159,7 @@ func (Recall) Execute(aerc *app.Aerc, args []string) error { mu.Unlock() if err != nil { log.Errorf(err.Error()) - aerc.PushError(err.Error()) + app.PushError(err.Error()) } }) } diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 035e6aa3..b9ee050a 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -33,11 +33,11 @@ func (reply) Aliases() []string { return []string{"reply"} } -func (reply) Complete(aerc *app.Aerc, args []string) []string { +func (reply) Complete(args []string) []string { return nil } -func (reply) Execute(aerc *app.Aerc, args []string) error { +func (reply) Execute(args []string) error { opts, optind, err := getopt.Getopts(args, "acqT:eE") if err != nil { return err @@ -69,7 +69,7 @@ func (reply) Execute(aerc *app.Aerc, args []string) error { } } - widget := aerc.SelectedTabContent().(app.ProvidesMessage) + widget := app.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { @@ -169,7 +169,7 @@ func (reply) Execute(aerc *app.Aerc, args []string) error { h.SetMsgIDList("in-reply-to", []string{msg.Envelope.MessageId}) err = setReferencesHeader(h, msg.RFC822Headers) if err != nil { - aerc.PushError(fmt.Sprintf("could not set references: %v", err)) + app.PushError(fmt.Sprintf("could not set references: %v", err)) } original := models.OriginalMail{ From: format.FormatAddresses(msg.Envelope.From), @@ -177,38 +177,38 @@ func (reply) Execute(aerc *app.Aerc, args []string) error { RFC822Headers: msg.RFC822Headers, } - mv, _ := aerc.SelectedTabContent().(*app.MessageViewer) + mv, _ := app.SelectedTabContent().(*app.MessageViewer) addTab := func() error { - composer, err := app.NewComposer(aerc, acct, + composer, err := app.NewComposer(acct, acct.AccountConfig(), acct.Worker(), editHeaders, template, h, &original, nil) if err != nil { - aerc.PushError("Error: " + err.Error()) + app.PushError("Error: " + err.Error()) return err } if mv != nil && closeOnReply { - aerc.RemoveTab(mv, true) + app.RemoveTab(mv, true) } if args[0] == "reply" { composer.FocusTerminal() } - composer.Tab = aerc.NewTab(composer, subject) + composer.Tab = app.NewTab(composer, subject) composer.OnClose(func(c *app.Composer) { switch { case c.Sent() && c.Archive() != "": store.Answered([]uint32{msg.Uid}, true, nil) - err := archive(aerc, []*models.MessageInfo{msg}, c.Archive()) + err := archive([]*models.MessageInfo{msg}, c.Archive()) if err != nil { - aerc.PushStatus("Archive failed", 10*time.Second) + app.PushStatus("Archive failed", 10*time.Second) } case c.Sent(): store.Answered([]uint32{msg.Uid}, true, nil) case mv != nil && closeOnReply: //nolint:errcheck // who cares? - account.ViewMessage{}.Execute(aerc, []string{"-p"}) + account.ViewMessage{}.Execute([]string{"-p"}) } }) @@ -221,7 +221,7 @@ func (reply) Execute(aerc *app.Aerc, args []string) error { } if crypto.IsEncrypted(msg.BodyStructure) { - provider := aerc.SelectedTabContent().(app.ProvidesMessage) + provider := app.SelectedTabContent().(app.ProvidesMessage) mv, ok := provider.(*app.MessageViewer) if !ok { return fmt.Errorf("message is encrypted. can only quote reply while message is open") diff --git a/commands/msg/toggle-thread-context.go b/commands/msg/toggle-thread-context.go index 6f8b7bbb..7530bc9e 100644 --- a/commands/msg/toggle-thread-context.go +++ b/commands/msg/toggle-thread-context.go @@ -3,7 +3,6 @@ package msg import ( "errors" - "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/ui" ) @@ -17,15 +16,15 @@ func (ToggleThreadContext) Aliases() []string { return []string{"toggle-thread-context"} } -func (ToggleThreadContext) Complete(aerc *app.Aerc, args []string) []string { +func (ToggleThreadContext) Complete(args []string) []string { return nil } -func (ToggleThreadContext) Execute(aerc *app.Aerc, args []string) error { +func (ToggleThreadContext) Execute(args []string) error { if len(args) != 1 { return errors.New("Usage: toggle-entire-thread") } - h := newHelper(aerc) + h := newHelper() store, err := h.store() if err != nil { return err diff --git a/commands/msg/toggle-threads.go b/commands/msg/toggle-threads.go index 0b85e510..1d38685a 100644 --- a/commands/msg/toggle-threads.go +++ b/commands/msg/toggle-threads.go @@ -3,7 +3,6 @@ package msg import ( "errors" - "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/lib/state" "git.sr.ht/~rjarry/aerc/lib/ui" ) @@ -18,15 +17,15 @@ func (ToggleThreads) Aliases() []string { return []string{"toggle-threads"} } -func (ToggleThreads) Complete(aerc *app.Aerc, args []string) []string { +func (ToggleThreads) Complete(args []string) []string { return nil } -func (ToggleThreads) Execute(aerc *app.Aerc, args []string) error { +func (ToggleThreads) Execute(args []string) error { if len(args) != 1 { return errors.New("Usage: toggle-threads") } - h := newHelper(aerc) + h := newHelper() acct, err := h.account() if err != nil { return err diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index 23029244..069aedab 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -30,12 +30,12 @@ func (Unsubscribe) Aliases() []string { } // Complete returns a list of completions -func (Unsubscribe) Complete(aerc *app.Aerc, args []string) []string { +func (Unsubscribe) Complete(args []string) []string { return nil } // Execute runs the Unsubscribe command -func (Unsubscribe) Execute(aerc *app.Aerc, args []string) error { +func (Unsubscribe) Execute(args []string) error { editHeaders := config.Compose.EditHeaders opts, optind, err := getopt.Getopts(args, "eE") if err != nil { @@ -52,7 +52,7 @@ func (Unsubscribe) Execute(aerc *app.Aerc, args []string) error { editHeaders = false } } - widget := aerc.SelectedTabContent().(app.ProvidesMessage) + widget := app.SelectedTabContent().(app.ProvidesMessage) msg, err := widget.SelectedMessage() if err != nil { return err @@ -76,14 +76,14 @@ func (Unsubscribe) Execute(aerc *app.Aerc, args []string) error { var err error switch strings.ToLower(method.Scheme) { case "mailto": - err = unsubscribeMailto(aerc, method, editHeaders) + err = unsubscribeMailto(method, editHeaders) case "http", "https": - err = unsubscribeHTTP(aerc, method) + err = unsubscribeHTTP(method) default: err = fmt.Errorf("unsubscribe: skipping unrecognized scheme: %s", method.Scheme) } if err != nil { - aerc.PushError(err.Error()) + app.PushError(err.Error()) } } @@ -100,15 +100,15 @@ func (Unsubscribe) Execute(aerc *app.Aerc, args []string) error { dialog := app.NewSelectorDialog( title, "Press <Enter> to confirm or <ESC> to cancel", - options, 0, aerc.SelectedAccountUiConfig(), + options, 0, app.SelectedAccountUiConfig(), func(option string, err error) { - aerc.CloseDialog() + app.CloseDialog() if err != nil { if errors.Is(err, app.ErrNoOptionSelected) { - aerc.PushStatus("Unsubscribe: "+err.Error(), + app.PushStatus("Unsubscribe: "+err.Error(), 5*time.Second) } else { - aerc.PushError("Unsubscribe: " + err.Error()) + app.PushError("Unsubscribe: " + err.Error()) } return } @@ -118,10 +118,10 @@ func (Unsubscribe) Execute(aerc *app.Aerc, args []string) error { return } } - aerc.PushError("Unsubscribe: selected method not found") + app.PushError("Unsubscribe: selected method not found") }, ) - aerc.AddDialog(dialog) + app.AddDialog(dialog) return nil } @@ -148,8 +148,8 @@ func parseUnsubscribeMethods(header string) (methods []*url.URL) { } } -func unsubscribeMailto(aerc *app.Aerc, u *url.URL, editHeaders bool) error { - widget := aerc.SelectedTabContent().(app.ProvidesMessage) +func unsubscribeMailto(u *url.URL, editHeaders bool) error { + widget := app.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -162,7 +162,7 @@ func unsubscribeMailto(aerc *app.Aerc, u *url.URL, editHeaders bool) error { } composer, err := app.NewComposer( - aerc, + acct, acct.AccountConfig(), acct.Worker(), @@ -175,32 +175,32 @@ func unsubscribeMailto(aerc *app.Aerc, u *url.URL, editHeaders bool) error { if err != nil { return err } - composer.Tab = aerc.NewTab(composer, "unsubscribe") + composer.Tab = app.NewTab(composer, "unsubscribe") composer.FocusTerminal() return nil } -func unsubscribeHTTP(aerc *app.Aerc, u *url.URL) error { +func unsubscribeHTTP(u *url.URL) error { confirm := app.NewSelectorDialog( "Do you want to open this link?", u.String(), - []string{"No", "Yes"}, 0, aerc.SelectedAccountUiConfig(), + []string{"No", "Yes"}, 0, app.SelectedAccountUiConfig(), func(option string, _ error) { - aerc.CloseDialog() + app.CloseDialog() switch option { case "Yes": go func() { defer log.PanicHandler() mime := fmt.Sprintf("x-scheme-handler/%s", u.Scheme) if err := lib.XDGOpenMime(u.String(), mime, nil); err != nil { - aerc.PushError("Unsubscribe:" + err.Error()) + app.PushError("Unsubscribe:" + err.Error()) } }() default: - aerc.PushError("Unsubscribe: link will not be opened") + app.PushError("Unsubscribe: link will not be opened") } }, ) - aerc.AddDialog(confirm) + app.AddDialog(confirm) return nil } diff --git a/commands/msg/utils.go b/commands/msg/utils.go index 423be37d..42693348 100644 --- a/commands/msg/utils.go +++ b/commands/msg/utils.go @@ -15,15 +15,15 @@ type helper struct { statusInfo func(string) } -func newHelper(aerc *app.Aerc) *helper { - msgProvider, ok := aerc.SelectedTabContent().(app.ProvidesMessages) +func newHelper() *helper { + msgProvider, ok := app.SelectedTabContent().(app.ProvidesMessages) if !ok { - msgProvider = aerc.SelectedAccount() + msgProvider = app.SelectedAccount() } return &helper{ msgProvider: msgProvider, statusInfo: func(s string) { - aerc.PushStatus(s, 10*time.Second) + app.PushStatus(s, 10*time.Second) }, } } |