aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

commit 455c6f0b774bb5e37906dd3fb8c786892f0b1519
parent fa5d8d7a007aa0030a4b2bfb122dabab3e69ad4b
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 19 May 2019 18:23:34 -0400

Rename :delete-message et al to :delete et al

Diffstat:
Dcommands/account/delete-message.go | 38--------------------------------------
Acommands/account/delete.go | 39+++++++++++++++++++++++++++++++++++++++
Dcommands/account/next-message.go | 55-------------------------------------------------------
Acommands/account/next.go | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rcommands/account/select-message.go -> commands/account/select.go | 0
Dcommands/account/view-message.go | 29-----------------------------
Acommands/account/view.go | 30++++++++++++++++++++++++++++++
Mconfig/binds.conf | 28++++++++++++++--------------
8 files changed, 140 insertions(+), 136 deletions(-)

diff --git a/commands/account/delete-message.go b/commands/account/delete-message.go @@ -1,38 +0,0 @@ -package account - -import ( - "errors" - "time" - - "github.com/gdamore/tcell" - - "git.sr.ht/~sircmpwn/aerc/widgets" - "git.sr.ht/~sircmpwn/aerc/worker/types" -) - -func init() { - register("delete-message", DeleteMessage) -} - -func DeleteMessage(aerc *widgets.Aerc, args []string) error { - if len(args) != 1 { - return errors.New("Usage: :delete-message") - } - acct := aerc.SelectedAccount() - if acct == nil { - return errors.New("No account selected") - } - store := acct.Messages().Store() - msg := acct.Messages().Selected() - acct.Messages().Next() - store.Delete([]uint32{msg.Uid}, func(msg types.WorkerMessage) { - switch msg := msg.(type) { - case *types.Done: - aerc.PushStatus("Messages deleted.", 10*time.Second) - case *types.Error: - aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). - Color(tcell.ColorDefault, tcell.ColorRed) - } - }) - return nil -} diff --git a/commands/account/delete.go b/commands/account/delete.go @@ -0,0 +1,39 @@ +package account + +import ( + "errors" + "time" + + "github.com/gdamore/tcell" + + "git.sr.ht/~sircmpwn/aerc/widgets" + "git.sr.ht/~sircmpwn/aerc/worker/types" +) + +func init() { + register("delete", DeleteMessage) + register("delete-message", DeleteMessage) +} + +func DeleteMessage(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: :delete") + } + acct := aerc.SelectedAccount() + if acct == nil { + return errors.New("No account selected") + } + store := acct.Messages().Store() + msg := acct.Messages().Selected() + acct.Messages().Next() + store.Delete([]uint32{msg.Uid}, func(msg types.WorkerMessage) { + switch msg := msg.(type) { + case *types.Done: + aerc.PushStatus("Messages deleted.", 10*time.Second) + case *types.Error: + aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second). + Color(tcell.ColorDefault, tcell.ColorRed) + } + }) + return nil +} diff --git a/commands/account/next-message.go b/commands/account/next-message.go @@ -1,55 +0,0 @@ -package account - -import ( - "errors" - "fmt" - "strconv" - "strings" - - "git.sr.ht/~sircmpwn/aerc/widgets" -) - -func init() { - register("next-message", NextPrevMessage) - register("prev-message", NextPrevMessage) -} - -func nextPrevMessageUsage(cmd string) error { - return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd)) -} - -func NextPrevMessage(aerc *widgets.Aerc, args []string) error { - if len(args) > 2 { - return nextPrevMessageUsage(args[0]) - } - var ( - n int = 1 - err error - pct bool - ) - if len(args) > 1 { - if strings.HasSuffix(args[1], "%") { - pct = true - args[1] = args[1][:len(args[1])-1] - } - n, err = strconv.Atoi(args[1]) - if err != nil { - return nextPrevMessageUsage(args[0]) - } - } - acct := aerc.SelectedAccount() - if acct == nil { - return errors.New("No account selected") - } - if pct { - n = int(float64(acct.Messages().Height()) * (float64(n) / 100.0)) - } - for ; n > 0; n-- { - if args[0] == "prev-message" { - acct.Messages().Prev() - } else { - acct.Messages().Next() - } - } - return nil -} diff --git a/commands/account/next.go b/commands/account/next.go @@ -0,0 +1,57 @@ +package account + +import ( + "errors" + "fmt" + "strconv" + "strings" + + "git.sr.ht/~sircmpwn/aerc/widgets" +) + +func init() { + register("next", NextPrevMessage) + register("next-message", NextPrevMessage) + register("prev", NextPrevMessage) + register("prev-message", NextPrevMessage) +} + +func nextPrevMessageUsage(cmd string) error { + return errors.New(fmt.Sprintf("Usage: %s [<n>[%%]]", cmd)) +} + +func NextPrevMessage(aerc *widgets.Aerc, args []string) error { + if len(args) > 2 { + return nextPrevMessageUsage(args[0]) + } + var ( + n int = 1 + err error + pct bool + ) + if len(args) > 1 { + if strings.HasSuffix(args[1], "%") { + pct = true + args[1] = args[1][:len(args[1])-1] + } + n, err = strconv.Atoi(args[1]) + if err != nil { + return nextPrevMessageUsage(args[0]) + } + } + acct := aerc.SelectedAccount() + if acct == nil { + return errors.New("No account selected") + } + if pct { + n = int(float64(acct.Messages().Height()) * (float64(n) / 100.0)) + } + for ; n > 0; n-- { + if args[0] == "prev-message" || args[0] == "prev" { + acct.Messages().Prev() + } else { + acct.Messages().Next() + } + } + return nil +} diff --git a/commands/account/select-message.go b/commands/account/select.go diff --git a/commands/account/view-message.go b/commands/account/view-message.go @@ -1,29 +0,0 @@ -package account - -import ( - "errors" - - "git.sr.ht/~sircmpwn/aerc/widgets" -) - -func init() { - register("view-message", ViewMessage) -} - -func ViewMessage(aerc *widgets.Aerc, args []string) error { - if len(args) != 1 { - return errors.New("Usage: view-message") - } - acct := aerc.SelectedAccount() - if acct.Messages().Empty() { - return nil - } - store := acct.Messages().Store() - msg := acct.Messages().Selected() - if msg == nil { - return nil - } - viewer := widgets.NewMessageViewer(aerc.Config(), store, msg) - aerc.NewTab(viewer, msg.Envelope.Subject) - return nil -} diff --git a/commands/account/view.go b/commands/account/view.go @@ -0,0 +1,30 @@ +package account + +import ( + "errors" + + "git.sr.ht/~sircmpwn/aerc/widgets" +) + +func init() { + register("view", ViewMessage) + register("view-message", ViewMessage) +} + +func ViewMessage(aerc *widgets.Aerc, args []string) error { + if len(args) != 1 { + return errors.New("Usage: view-message") + } + acct := aerc.SelectedAccount() + if acct.Messages().Empty() { + return nil + } + store := acct.Messages().Store() + msg := acct.Messages().Selected() + if msg == nil { + return nil + } + viewer := widgets.NewMessageViewer(aerc.Config(), store, msg) + aerc.NewTab(viewer, msg.Envelope.Subject) + return nil +} diff --git a/config/binds.conf b/config/binds.conf @@ -8,26 +8,26 @@ [messages] q = :quit<Enter> -j = :next-message<Enter> -<Down> = :next-message<Enter> -<C-d> = :next-message 50%<Enter> -<C-f> = :next-message 100%<Enter> -<PgDn> = :next-message -s 100%<Enter> +j = :next<Enter> +<Down> = :next<Enter> +<C-d> = :next 50%<Enter> +<C-f> = :next 100%<Enter> +<PgDn> = :next -s 100%<Enter> -k = :prev-message<Enter> -<Up> = :prev-message<Enter> -<C-u> = :prev-message 50%<Enter> -<C-b> = :prev-message 100%<Enter> -<PgUp> = :prev-message -s 100%<Enter> -g = :select-message 0<Enter> -G = :select-message -1<Enter> +k = :prev<Enter> +<Up> = :prev<Enter> +<C-u> = :prev 50%<Enter> +<C-b> = :prev 100%<Enter> +<PgUp> = :prev -s 100%<Enter> +g = :select 0<Enter> +G = :select -1<Enter> J = :next-folder<Enter> K = :prev-folder<Enter> -<Enter> = :view-message<Enter> +<Enter> = :view<Enter> d = :confirm 'Really delete this message?' ':delete-message<Enter>'<Enter> -D = :delete-message<Enter> +D = :delete<Enter> rr = :reply<Enter> rq = :reply -q<Enter>