# temporary, to migrate old patch preferences
list_remove_both() {
  local list="$1"
  shift
  list_remove "$list" "$@" "${@/#/-}"
}

OLD_PATCHES="$PATCHES" &&
list_remove OLD_PATCHES "compressed_folders" "trash_folder" \
     "imap_copy_for_trash" &&
list_remove OLD_PATCHES "-attachment_counting" "-current_shortcut" \
     "-date_conditional" "-deepif" "-edit_threads" "-indexcolor" "-isalias" \
     "-libesmtp" "-maildir_header_cache" "-purge_message" "-sidebar" \
     "-signatures_menu" "-xtitles" "-compressed_folders" "-message_count" \
     "-trash_folder" &&

# Not available patches
list_remove_both PATCHES \
	"attachment_counting" \
	"current_shortcut" \
	"message_count" \
	"date_conditional" \
	"deepif" \
	"edit_threads" \
	"indexcolor" \
	"isalias" \
	"libesmtp" \
	"maildir_header_cache" \
	"purge_message" \
	"sidebar" \
	"signatures_menu" \
	"xtitles" &&

if [[ $OLD_PATCHES ]]; then
  message "$PROBLEM_COLOR" &&
  message "This new version of the mutt spell only includes the following patches:" &&
  message "$SPELL_COLOR" &&
  grep -v '^#' "$SPELL_DIRECTORY/PATCH_ORDER" &&
  message "$PROBLEM_COLOR" &&
  message "You were using other patches, you can continue casting without these" &&
  message "or abort. If you'd like a particular patch to be available" &&
  message "again in the future, please post a request on bugs.sourcemage.org" &&
  message "Perhaps you should consider using the devel or scm version of mutt" &&
  message "which already includes some of the patches available earlier" &&
  message "You had the following, now unavailable, patches enabled:" &&
  message "$OLD_PATCHES" &&
  message "$DEFAULT_COLOR" &&
  if ! query "Do you wish to continue casting mutt without these patches?" n; then
    return 1
  fi
fi

message "The mutt spell provides three different versions of mutt; stable," &&
message "which apart from security fixes has not been developed in a long" &&
message "time, devel, the current development releases and scm, which pulls" &&
message "a snapshot from the mutt source repository." &&

. ${GRIMOIRE}/FUNCTIONS &&
prepare_select_branch stable scm
