#                                                                                            -*-shell-script-*-
# Personal configuration of Mutt.
#
# See also:
#   • /etc/mutt/Muttrc
#   • http://www.mutt.org/doc/manual/
#   • https://wiki.gentoo.org/wiki/Mutt
#
# "Note: new email is detected by comparing the last modification time to the last access time. Utilities
# like biff or frm or any other program which accesses the mail box might cause Mutt to never detect new
# email for that mail box if they do not properly reset the access time. Backup tools are another common
# reason for updated access times."  There is apparently no way to get Mutt to honour new flags (N) on
# messages, and treat those as actually being new.
#
# PUBLIC at `http://reluk.ca/.mutt/muttrc` — for no particular reason.


  # set folder=~/.email # Already set in `/etc/mutt/Muttrc`.
    source ~/.mutt/alias
    set alias_file=~/.mutt/alias # for use by, e.g., create-alias function

    unset help
    set menu_scroll
    unset user_agent

    bind editor <delete> delete-char # though this binding is supposed to be the default

  # macro attach W "<save-entry><bol>~/tmp/<eol>" "Save to ~/tmp"
  #   # http://superuser.com/a/695571
  ## no effect


   # Addressing
   # ----------
    folder-hook . 'set from="Michael Allan <mike@reluk.ca>"'
  # folder-hook . 'set from="Michael Allan <mikebysilva@teksavvy.com>"'
    folder-hook . 'set signature=~/.mutt/signature'
  # folder-hook vsb 'set from= ...
  ## see instead `muttrc-secret`
  # folder-hook vsb 'set signature=~/.mutt/signature-vsb'
  ## retained as an example


   # Colouring
   # ---------
   # Used to dislike higher colours (over color7), maybe because of what $TERM is set to.
   # Sometimes the 'bright' prefix would give the high colour, as though by adding 8.
   # Unfortunately it also made the font bold at the same time.  But the higher colours
   # seem to be working.
    color attachment color8 black # less blinding in compose menu # but no effect there

      message-hook   ~P "color body color7 black '^.*$'"
      message-hook ! ~P "color body color6 black '^.*$'"

 #    message-hook . \
 # "color body color5 black '^ *>.*$'" # quote other (all) by default
 ## apparently not called when message changes, so use explicit rules for other:
      message-hook   ~P "color body color5 black '^ *>( *> *>)* *[^ >].*$'"
        # from me, quote other odd
      message-hook ! ~P "color body color8 black '^ *>( *> *>)* *[^ >].*$'"
        # from other, quote me odd
      message-hook   ~P "color body color8 black '^( *> *>)+ *[^ >].*$'"
        # from me, quote me even
      message-hook ! ~P "color body color5 black '^( *> *>)+ *[^ >].*$'"
        # from other, quote other even
    # message-hook ~p "color body color5 black '^ *>( *> *>)* *[^ >].*$'"
    #   # to me, quote me odd
    # message-hook ! ~p "color body color8 black '^ *>( *> *>)* *[^ >].*$'"
    #   # to other, quote other odd
    ## but may be formally to list, while actually to me.  So assume to me, if not from me.

    color hdrdefault color8 black
    # note that header colours below affect entire lines # cannot use pattern matching to distinguish between header names and header content within a line
  # color header … see `muttrc-secret`
    color header color10 black '^subject: '
    color header brightcolor1 black '^x-tmda-confirmed'

    color index brightcolor3 black '~A' # should never occur, if rules below are correct ()
    color index color7  black ' ~P !(~F | ~N | ~O) !~D' # from me
    color index color15 black ' ~P  (~F | ~N | ~O) !~D' # from me, flagged or new
    color index color5 black '!~P !(~F | ~N | ~O) !~D' # from other
    color index brightcolor14 black '!~P  (~F | ~N | ~O) !~D' # from other, flagged or new
    color index color4 black '~D' # deleted

    set arrow_cursor # instead of altering entire line
    color indicator green black

    color markers color8 color4
    color signature color8 black
    color status color8 color4
    color tree brightcolor0 black


   # Composition
   # -----------
    unset abort_nosubject
    set edit_headers
  # set editor='emacs --funcall=mutt-mail-mode'
  # set editor='emacs --execute=mutt-mail-mode'
  ## no luck with either, so instead I added something to ~/.emacs auto-mode-alist
  # set editor='emacs --geometry=93x56+2503+0'
  ## does not work well in terminal mode # instead use EDITOR='emacs --geometry=93x56+2503+0' on command line, when in windowed enviornment
  # set editor='/home/mike/sys/bin/desk-launch editor'
  ## fails, because asynch (for sake of cascade-pilot) -- no need anyway
    set fast_reply
    set include=yes

    set attribution="%n said:"


   # Index
   # -----
    unset mark_old
    set strict_threads

  # set sort=threads
  ## annoying lack of context, unread messages are initially off the bottom of the screen
    set sort=reverse-threads
    set sort_aux=last-date-sent

  # set index_format=                    "%30.30L %{%m%d} %Z%T %s" # %T ($to_chars) as workaround for bug in which $to_chars in %Z is overwritten by status, such as important (!)
  # folder-hook .      'set index_format="%30.30L %{%m%d} %Z %s"'
  # folder-hook /list/ 'set index_format="%30.30F %{%m%d} %Z %s"'
    set index_format=                    "%30.30F %{%m%d} %Z %s"
    set to_chars='0 23 L'
                # 0       not to|cc me
                #         to me alone
                #   2     to me and others
                #    3    cc me and to|cc others
                #         from me
                #      L  to list
    set status_format=" %f   %?M?%M / ?%m messages%?u?  %n unread?%?d?  %d deleted?%?F?  %F flagged?%?t?  %t tagged?%?p?  %p postponed?%> %?l?%l? "


   # Mailboxes, folders and lists
   # ----------------------------
    # See also `/etc/mutt/Muttrc`.
    mailboxes \
      =etc \
      =recent \
      =textbender \
      =valet \
      =votorola \
      =waymaker
      # Formally a `mailbox` is a folder whose new messages will show up on status bar.

    lists \
      ag-liquid-democracy  ag-meinungsfindungstool  air-l \
      election-methods  electionscience  exchange \
      google-web-toolkit \
      lib-gwt-svg  liberationtech liquid-democracy-international \
      main mir-in misc \
      national-dialogue  ncdd-discussion no7-in \
      oddi \
      pdi-comunicacion \
      semediawiki-devel semediawiki-user social-theory  start  sunlightlabs \
      textbender  tmda-users  tmda-workers \
      users \
      votorola \
      waymaker  web
    subscribe \
      textbender  tmda-users  tmda-workers \
      votorola \
      waymaker

    set postponed==_/postponed

    folder-hook . 'set record=^'
      # (overriding $record, which is the place to save copies of outgoing messages)
      # when reading a mail box (`folder-hook`), then save copies of outgoing messages there (^) instead.
    set save_name
      # (overriding $record) when local part of destination address (e.g. name of mailing list)
      # matches a mail box name, then save copies of outgoing messages there instead
  # fcc-hook '^start@metagovernment\.org$' =metagov
      # (customizing $save_name) when outgoing message is to 'start', then save a copy to =metagov instead

  # unset fcc_attach
      # whether or not attachments on outgoing messages are saved along with the main body of your message


   # Pager.
   # - - - -
    set pager_format=" %3C / %m     %c"
    set pager_index_lines=11
    set pager_stop

   # - - - header weedings - - toggle at runtime with key h -- see also variable 'weed'
    ignore *
    unignore date: subject: # though I'm unsure if bcc really ever occurs
    unignore from: to: cc: bcc: # though I'm unsure if bcc really ever occurs
    unignore posted-to: x-mailer: x-newsreader: x-mailing-list:
    unignore x-tmda-confirmed:


   # Transport
   # ---------
    send-hook . 'unmy_hdr From:'
      # Defeat any my_hdr command that was triggered by the send-hook(s) below during this Mutt session,
      # viz. for a previously sent message.  http://www.mutt.org/doc/manual/#hooks
    send-hook \
      '~l ~t"aoir\.org|votorola"' \
      'my_hdr From: Michael Allan <mike@zelea.com>'
      # Revert to my older address when addressing a known list (~l), specifically one with the given
      # address pattern (~t), whose subscriptions are older and not yet updated to my new address.


   # Secret
   # ------
    source ~/.mutt/muttrc-secret