# Binds are of the form <key sequence> = <command to run>
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"

# GLOBAL Navigation & Contacts
( = :term abook<Enter>
,ab = :term abook<Enter>
,ca = :term khal interactive<Enter>
,c1 = :term khal interactive -a personal<Enter>
,c2 = :term khal interactive -a healplaylove<Enter>
,c3 = :term khal interactive -a glarisegg<Enter>
,ta = :term taskwarrior-tui<Enter>

<A-p> = :prev-tab<Enter>
<A-n> = :next-tab<Enter>
<C-t> = :terminal<Enter>
? = :help keys<Enter>
<C-c> = :prompt 'Quit?' quit<Enter>
<C-q> = :prompt 'Quit?' quit<Enter>
<C-z> = :suspend<Enter>

[messages]
# Sync
u = :term /home/liph/.local/bin/mailsync<Enter>

# Navigation
j = :next<Enter>
k = :prev<Enter>
<Down> = :next<Enter>
<Up> = :prev<Enter>
g = :select 0<Enter>
G = :select -1<Enter>
J = :next-folder<Enter>
K = :prev-folder<Enter>
H = :collapse-folder<Enter>
L = :expand-folder<Enter>
<Left> = :collapse-folder<Enter>
<Right> = :expand-folder<Enter>

# Marking/Flagging
v = :mark -v<Enter>
V = :mark -t<Enter>
<Space> = :mark -t<Enter>:next<Enter>
<Esc> = :unmark -a<Enter>

# Accounts
,1 = :change-tab phil<Enter>
,2 = :change-tab spam<Enter>
,3 = :change-tab proton<Enter>

# Folders
,i = :cf Inbox<Enter>
,u = :cf Unread<Enter>
,n = :cf Newsletters<Enter>
,f = :cf Finance<Enter>
,s = :cf Shopping<Enter>
,v = :cf Travel<Enter>
,d = :cf Development<Enter>
,x = :cf Spam<Enter>
,tr = :cf Trash<Enter>
,aa = :cf All Mail<Enter>

# Actions
<Enter> = :view<Enter>
s = :split<Enter>
S = :vsplit<Enter>
d = :modify-labels +deleted -inbox<Enter>
a = :archive flat<Enter>
C = :compose<Enter>
m = :compose<Enter>
rr = :reply -a<Enter>
rq = :reply -aq<Enter>
Rr = :reply<Enter>
Rq = :reply -q<Enter>
/ = :search<space>
\ = :filter<space>
n = :next-result<Enter>
N = :prev-result<Enter>

# Threads
T = :toggle-threads<Enter>
zc = :fold<Enter>
zo = :unfold<Enter>
za = :fold -t<Enter>

[messages:folder=Drafts]
<Enter> = :recall<Enter>

[view]
# Navigation & UI
q = :close<Enter>
x = :close<Enter>
| = :pipe<space>
D = :delete<Enter>
A = :archive flat<Enter>
f = :forward<Enter>
rr = :reply -a<Enter>
rq = :reply -aq<Enter>
Rr = :reply<Enter>
Rq = :reply -q<Enter>
H = :toggle-headers<Enter>
,l = :pipe urlscan<Enter>

# Attachment Handling
n = :next-part<Enter>
p = :prev-part<Enter>
J = :next<Enter>
K = :prev<Enter>
o = :open<Enter>
O = :open<Enter>
s = :save ~/Downloads/<Enter>
S = :save<space>
,sa = :save -a ~/Downloads/<Enter>

[view::passthrough]
$noinherit = true
$ex = <C-x>
<Esc> = :toggle-key-passthrough<Enter>

[compose]
# General compose view
$noinherit = true
$ex = <C-x>
$complete = <C-o>
<C-k> = :attach<space>
<C-a> = :attach<space>
<F4> = :attach<space>
<A-p> = :prev-tab<Enter>
<A-n> = :next-tab<Enter>
<tab> = :next-field<Enter>
<backtab> = :prev-field<Enter>

[compose::editor]
# While focused in the text editor (nvim)
$noinherit = true
$ex = <C-x>
<C-k> = :attach<space>
<C-a> = :attach<space>
<F4> = :attach<space>

[compose::review]
# After exiting the editor
y = :multipart text/html<Enter>:send<Enter>
n = :abort<Enter>
v = :preview<Enter>
p = :postpone<Enter>
q = :choose -o d discard abort -o p postpone postpone<Enter>
e = :edit<Enter>
a = :attach<space>
<C-k> = :attach<space>
<C-a> = :attach<space>
d = :detach<space>

[terminal]
# Clear keys to allow passthrough to Khal/Taskwarrior
$ex = <C-x>
<C-p> = 
<C-n> = 
<tab> = 
<backtab> = 
<A-p> = :prev-tab<Enter>
<A-n> = :next-tab<Enter>
