]> diplodocus.org Git - minc/commitdiff
Even easier .folders sorting; now all you have to do is provide a list
authorepg <>
Sat, 19 Nov 2005 00:46:01 +0000 (00:46 +0000)
committerepg <>
Sat, 19 Nov 2005 00:46:01 +0000 (00:46 +0000)
of regexps, and the sorting will be according to their order.  You can
still define your own sorter, if necessary.

minc

diff --git a/minc b/minc
index 0fcceb1..9b7e280 100755 (executable)
--- 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;