<commit_before>#!/bin/sh
#
# Open the archives for a mailing list at the week containing the piped message
#
# Mutt usage:
#
#     macro pager ,a \
#       "<enter-command>set my_old_pipe_decode=\$pipe_decode nopipe_decode<enter> \
#       <pipe-message>$DOTFILES/mutt/listarchive.sh<enter> \
#       <enter-command>set pipe_decode=\$my_old_pipe_decode<enter> \
#       <top>" \
#       "Open the archive for a mailing list"
#

set -e

message="$(cat)"
archive="$(echo "$message" | grep -i "^list-archive:" | grep -o "<.*>" | tr -d "<>")"

if [ "$archive" != "" ]; then
  date=$(echo "$message" | grep -i "^Date: " | sed "s/^Date: //")

  if [ "$date" != "" ]; then
    list_date=$(date -j -v-mon -f "%a, %d %b %Y %H:%M:%S %z" "$date" "+%Y%m%d")
    # Open the date view, switch to different HTML for different format
    open "$archive/Week-of-Mon-$list_date/date.html"
  else
    open "$archive"
  fi
fi<commit_msg>Reorganize mutt list archive script<commit_after>#!/bin/sh
#
# Open the archives for a mailing list at the week containing the piped message
#
# Mutt usage:
#
#     macro pager ,a \
#       "<enter-command>set my_old_pipe_decode=\$pipe_decode nopipe_decode<enter> \
#       <pipe-message>$DOTFILES/mutt/listarchive.sh<enter> \
#       <enter-command>set pipe_decode=\$my_old_pipe_decode<enter> \
#       <top>" \
#       "Open the archive for a mailing list"
#

set -e

message="$(cat)"
archive="$(echo "$message" | grep -i "^list-archive:" | grep -o "<.*>" | tr -d "<>")"

if [ -z "$archive" ]; then
  exit
fi

date=$(echo "$message" | grep -i "^Date: " | sed "s/^Date: //")
date=""
if [ -z "$date" ]; then
  open "$archive"
  exit
fi

list_date=$(date -j -v-mon -f "%a, %d %b %Y %H:%M:%S %z" "$date" "+%Y%m%d")
# Open the date view, switch to different HTML for different format
open "$archive/Week-of-Mon-$list_date/date.html"
{'fraction_non_alphanumeric': 0.19339111592632718, 'fraction_numerical': 0.0, 'mean_word_length': 3.2953488372093025, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '70253', 'n_tokens_mistral': 699, 'n_tokens_neox': 677, 'n_words': 185}