# NeoMutt Configuration
# Privacy-focused setup with multi-account support, GPG/ECC signing, and mail2news via Tor

# =====================================================
# Impostazioni Generali
# =====================================================

set realname = "Your Name"
set use_from = yes
set envelope_from = yes

# Editor per comporre email
set editor = "vim"

# Permetti editing degli headers durante composizione
set edit_headers = yes
set autoedit = yes

# Headers da mostrare in composizione
my_hdr References:
my_hdr Reply-To:
my_hdr X-Newsgroups:

# Formato data
set date_format = "%d/%m/%Y %H:%M"
set index_format = "%4C %Z %d %-20.20L %s"

# Inizializza variabile account (verrà sovrascritta dall'account caricato)
set my_account_info = "[Account]"

# Status bar personalizzata (mostra account corrente)
set status_format = "$my_account_info │ %f %?M?(%M hidden)? %?n?(%n new)?%?d? (%d to delete)?%?t? (%t tagged)? %>─%?p?(%p postponed)?─"

# Sidebar
set sidebar_visible = yes
set sidebar_width = 30
set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S"
set mail_check_stats

# =====================================================
# Sicurezza
# =====================================================

set ssl_force_tls = yes
set ssl_starttls = yes

# =====================================================
# GPG/PGP (ECC)
# =====================================================

set crypt_use_gpgme = yes
set crypt_autopgp = yes
set pgp_auto_decode = yes
set crypt_verify_sig = yes
set crypt_replysign = yes
set crypt_replyencrypt = yes
set crypt_replysignencrypted = yes

# Disabilita cifratura opportunistica (attivare manualmente con 'p' in composizione)
set crypt_opportunistic_encrypt = no

# Scorciatoie GPG
# Durante composizione (compose mode):
# p = Menu completo per firmare/criptare
# e = Cripta messaggio
# s = Firma messaggio

# Verifica PGP inline
macro index,pager \Ce "<check-traditional-pgp>" "Verifica PGP inline"
macro index,pager \Cv "<view-attachments><search>application/pgp<enter><view-mailcap><exit>" "Visualizza firma/chiave PGP"

# =====================================================
# HTML
# =====================================================

set mailcap_path = "~/.config/neomutt/mailcap"
auto_view text/html
alternative_order text/html text/plain
set implicit_autoview = yes

macro index,pager \cv "<view-attachments><search>html<enter><view-mailcap><exit>" "Apri HTML in Firefox"

# =====================================================
# Ordinamento
# =====================================================

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

# =====================================================
# Cache (velocizza IMAP)
# =====================================================

set header_cache = "~/.cache/neomutt/headers"
set message_cachedir = "~/.cache/neomutt/bodies"

# =====================================================
# Tema colori cyberpunk
# =====================================================

source ~/.config/neomutt/colors.mutt

# =====================================================
# Account di default
# =====================================================

# Carica il primo account all'avvio
source ~/.config/neomutt/accounts/account1

# =====================================================
# Scorciatoie per cambiare account
# =====================================================

macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/account1<enter><change-folder>!<enter>'  "Passa a account1"
macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/account2<enter><change-folder>!<enter>'  "Passa a account2"
macro index,pager <f4> '<sync-mailbox><enter-command>source ~/.config/neomutt/accounts/account3<enter><change-folder>!<enter>'  "Passa a account3"

# F9 = Mail2news via Tor (script interattivo)
macro index,pager <f9> "<shell-escape>~/.config/neomutt/m2n-post.sh<enter>" "Post mail2news"

# =====================================================
# Scorciatoie utili
# =====================================================

bind index,pager B sidebar-toggle-visible
bind index,pager \Cp sidebar-prev
bind index,pager \Cn sidebar-next
bind index,pager \Co sidebar-open

# Vim-like navigation
bind pager j next-line
bind pager k previous-line
bind index j next-entry
bind index k previous-entry
bind index G last-entry
bind index g noop
bind index gg first-entry

# Risposta e forward
bind index,pager r reply
bind index,pager R group-reply
bind index,pager f forward-message

# Componi email HTML (scrivi in markdown, viene convertito con pandoc)
macro compose H "F pandoc -s -f markdown -t html<enter>y^T^Utext/html<enter>" "Converti in HTML"

# =====================================================
# Mail2News
# =====================================================

# F9 gestisce tutto: nuovo post e reply (se Subject inizia con Re:)
# Il mittente fisso viene letto da ~/.config/neomutt/accounts/mail2news

# Disable drafts/postponed (avoid IMAP errors)
set postponed = ""
set record = ""
