]> diplodocus.org Git - minc/blobdiff - minc
Even easier .folders sorting; now all you have to do is provide a list
[minc] / minc
diff --git a/minc b/minc
index 3e30d8c..9b7e280 100755 (executable)
--- a/minc
+++ b/minc
@@ -9,7 +9,9 @@ B<minc> - incorporate mail from a maildir into mh folders
 =head1 SYNOPSIS
 
 B<minc> [B<-m> I<MAX>] [B<-n>]
+
 B<minc> B<-d>
+
 B<minc> B<-r>
 
 =head1 DESCRIPTION
@@ -176,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;
 
@@ -243,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;
@@ -641,6 +658,10 @@ sub build_dot_folders {
 }
 
 sub create_dot_folders {
+    if (-f "$HOME/.minc") {
+        require "$HOME/.minc";
+    }
+
     my %folders;
     open(my $fh, '-|', 'folders', '-fast', '-recur')
       or die("open(folders|): $!");