#Editor:
set editor=`echo \$EDITOR`

#vim keybinding
bind pager j next-line
bind pager k previous-line
bind attach,index,pager \CD next-page
bind attach,index,pager \CU previous-page
bind pager g top
bind pager G bottom
bind attach,index g first-entry
bind attach,index G last-entry

#mailcap
set mailcap_path 	= ~/.mutt/mailcap
auto_view text/html

#encryption
source ~/.mutt/gpg.rc

# Allow Mutt to open a new IMAP connection automatically.
unset imap_passive

# Keep the IMAP connection alive by polling intermittently (time in seconds).
set imap_keepalive = 300

# How often to check for new mail (time in seconds).
set mail_check = 60


set header_cache = "~/.cache/mutt"
set imap_check_subscribed

## gmail
source "~/.mutt/gmail"  
folder-hook *gmailuser@gmail.com/ 'source ~/.mutt/gmail'

## perso
source "~/.mutt/perso"
# Here we use the $folder variable that has just been set in the sourced file.
# We must set it right now otherwise the 'folder' variable will change in the next sourced file.
folder-hook $folder 'source ~/.mutt/perso'


macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/perso<enter><change-folder>!<enter>'
macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.mutt/gmail<enter><change-folder>!<enter>'

#colors
source ~/.mutt/colors.linux

#automate change directory
macro index 'c' '<change-folder>?<change-dir><home>^K=<enter>'

macro index \cb "\
:set my_tmp_pipe_decode=\$pipe_decode\n\
:set pipe_decode\n\
|urlview\n\
:set pipe_decode=\$my_tmp_pipe_decode\n\
:unset my_tmp_pipe_decode\n" \
'call urlview to extract URLs out of a message'

#contact management with abook
set query_command= "abook --mutt-query '%s'"
macro index,pager  a "<pipe-message>abook --add-email-quiet<return>" "Add this sender to Abook"
bind editor        <Tab> complete-query

#speed up folders switch
set sleep_time = 0