From: epg <> Date: Sat, 19 Nov 2005 00:46:01 +0000 (+0000) Subject: Even easier .folders sorting; now all you have to do is provide a list X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/5ea1f701fa7d300541542b4c191aea657903166e Even easier .folders sorting; now all you have to do is provide a list of regexps, and the sorting will be according to their order. You can still define your own sorter, if necessary. --- diff --git a/minc b/minc index 0fcceb1..9b7e280 100755 --- a/minc +++ b/minc @@ -178,13 +178,8 @@ our (@start_hooks, @stop_hooks, @filter_hooks, @post_store_hooks); our $SCAN_P_FOLDER = 0.1; our $SCAN_P_MESSAGE = 0.0625; our $SCAN_P_FROM = 0.175; - -our $folder_sorter = - sub { my ($a,$b) = @_; - $a eq 'inbox' and return -1; - $b eq 'inbox' and return 1; - return $a cmp $b; -}; +our @folder_sort_list = (qr/^inbox$/); +our $folder_sorter = sub { sort_by_list(@_, @folder_sort_list) }; my $mh; @@ -245,6 +240,26 @@ sub log_headers { ############################################################################### # Utility procedures +sub sort_by_list { + my $a = shift; + my $b = shift; + + for my $i (@_) { + my $am = $a =~ $i; + my $bm = $b =~ $i; + if ($am) { + if ($bm) { + last; + } + return -1; + } elsif ($bm) { + return 1; + } + } + + return $a cmp $b; +} + sub mkfolder { my $folder = shift; my $target;