set editor = "vim +$" 
set my_name = "Morten Linderud"
set mailcap_path = ~/.config/mutt/mailcap
set signature = ~/.config/mutt/signature
set header_cache = ~/.cache/neomutt
set message_cachedir = $header_cache

# Default
set realname = 'Morten Linderud'
set from = morten@linderud.pw
alternates ^foxboron@archlinux\.org$ ^mcfoxax@gmail\.com$ ^morten@linderud\.pw$
set sendmail  = "/usr/bin/msmtp"
set charset          = "utf-8" # Terminal charset for display/input
set send_charset     = "utf-8" # Charset for outgoing messages
set config_charset   = "utf-8"
set use_envelope_from 

set timeout=5           # Time out 5 seconds after last keypress to check for mail
set help=no	            # Disable the help header
set read_inc=10000
set write_inc=10000
set beep_new=yes
set quit=no
set move=no
set confirmappend=no
set collapse_unread=no
set uncollapse_jump=yes
set fast_reply=yes
set hidden_host
set pager_index_lines=10
set sidebar_width = 20
set sidebar_visible = yes

set mail_check_stats

set mime_forward
set mime_forward_rest=yes

alternative_order text/plain text/html text/enriched
auto_view text/html

set reverse_name
set sort=threads
set sort_aux=last-date-received

set crypt_replyencrypt = yes
set pgp_use_gpg_agent = yes
set pgp_default_key = "C100346676634E80C940FB9E9C02FF419FECBE16"
set pgp_sign_as = "C100346676634E80C940FB9E9C02FF419FECBE16"
set pgp_timeout = 20

# Alias
set alias_file= ~/.config/mutt/muttrc.d/aliases
set sort_alias=alias
set reverse_alias=yes

set pager_format="$from: -%Z- %C/%m: %-20.20n   %s%*  -- (%P)"
set status_format="$from: %f (%s/%S)"
set sidebar_format= '%D%*  %N/%S'

set mbox_type = Maildir
set folder = ~/mail/velox
set spoolfile="+INBOX"
set postponed=+Drafts
set record=+Sent
set trash=+Trash

bind attach <return> view-mailcap

macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'

bind index,pager \CP sidebar-prev
bind index,pager \CN sidebar-next
bind index,pager \CO sidebar-open

bind index,pager R  group-reply
bind index <space>  collapse-thread
bind index -        collapse-all

bind index,pager u        sync-mailbox

macro pager,index ,g "<pipe-message>~/.config/mutt/scripts/open_ml_url.py<return>" "Open GMAME link"
macro pager,index ,s "<pipe-message>~/.config/mutt/scripts/security_tracker.py<return>" "Open security.archlinux.org link"

bind index,pager X change-vfolder
bind index,pager B sidebar-toggle-virtual
bind index,pager + entire-thread
bind index,pager / vfolder-from-query
bind index < vfolder-window-backward
bind index > vfolder-window-forward
bind index,pager <Space> noop
macro index,pager <space> ":source ~/.config/mutt/scripts/changefolder|<enter>"



# mailboxes `find ~/mail/ -type d -name cur -printf '%h '`
set nm_default_uri = "notmuch:///home/fox/mail/velox"
set nm_query_window_current_position = 1
set nm_query_type = "threads"

virtual-mailboxes \
        "inbox"           "notmuch://?query=folder:INBOX"\
        "inbox-t"         "notmuch://?query=tag:INBOX or tag:inbox"\
        "unread"          "notmuch://?query=tag:unread"\
        "todo"            "notmuch://?query=tag:todo"\
        "important"       "notmuch://?query=tag:important"\
        "patches"         "notmuch://?query=query:mypatches"\
        "sent"            "notmuch://?query=tag:sent"\
        "draft"           "notmuch://?query=tag:draft"\
        "new"             "notmuch://?query=tag:new"\
        "replied"         "notmuch://?query=tag:replied"\
        "archive"         "notmuch://?query=tag:archive"\
        "spam"            "notmuch://?query=tag:spam"\


macro index,pager T "<modify-labels-then-hide>!todo<enter>" "Mark message as Todo"
macro index,pager I  "<modify-labels-then-hide>!important<enter>" "mark message as Important"

macro index,pager S "<modify-labels-then-hide>-INBOX -inbox -important !spam<enter>" "mark message as Spam"
macro index,pager A "<modify-labels-then-hide>-INBOX -inbox -important !archive<enter>" "mark message as Archive"
macro index,pager d "<modify-labels-then-hide>-INBOX -inbox -important !trash\n" "Delete message"
macro index,pager K "<tag-thread><tag-prefix-cond><modify-labels-then-hide>-INBOX -inbox -important -todo +archive<enter>"
macro index,pager i  "<modify-labels-then-hide>!INBOX !inbox\n" "Inbox"
bind index,pager Y modify-labels

# Unsure
#set hidden_tags = "unread,draft,flagged,passed,replied,attachment,signed,encrypted,important"
tag-transforms "attachment" "@" \
               "encrypted"  "" \
               "important"  "!" \
               "signed"     "✎" \
               "replied"    "↻" \
               "sent"       "➥" \
               "todo"       "🗹"

tag-formats "attachment"    "GA" \
            "encrypted"     "GE" \
            "signed"        "GS" \
            "important"     "GI" \
            "todo"          "GT" \
            "replied"       "GR" \
            "sent"          "Gs"

set index_format="%?GI?%GI& ? %?GT?%GT& ? %?GR?%GR& ? %?GS?%GS& ? %?GE?%GE& ? %<[y?%<[m?%<[d?%[ %H:%M]&%[%a %d]>&%[%b %d]>&%[%m/%y ]> │ %-15.15L │ %s"

# Account managament
folder-hook . "exec collapse-all"
message-hook . "source ~/.config/mutt/account.d/linderud"
message-hook "~C morten@linderud\.pw" "source ~/.config/mutt/account.d/linderud"
message-hook "~C @archlinux\.org" "source ~/.config/mutt/account.d/archlinux"
message-hook "~h 'Delivered-To: foxboron@archlinux\.org'" "source ~/.config/mutt/account.d/archlinux"
# message-hook "=h 'X-Mailer: git-send-email'" "source ~/.config/mutt/muttrc.d/colors.diff"
macro pager,index ,a ":source ~/.config/mutt/account.d/archlinux\n"
macro pager,index ,l ":source ~/.config/mutt/account.d/linderud\n"

# Source
source /home/fox/.config/mutt/muttrc.d/aliases
source /home/fox/.config/mutt/muttrc.d/colors
source /home/fox/.config/mutt/muttrc.d/ignores
source /home/fox/.config/mutt/muttrc.d/gpg.rc

