]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/notes-mode/mkindex
Add notes-mode.
[gnu-emacs-elpa] / packages / notes-mode / mkindex
diff --git a/packages/notes-mode/mkindex b/packages/notes-mode/mkindex
new file mode 100755 (executable)
index 0000000..2ec8ae5
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -w
+
+#
+# mkindex
+# $Id: mkindex,v 1.9 2003/05/23 16:26:33 johnh Exp $
+#
+# Copyright (C) 1994-1996 by John Heidemann.
+# Comments to <johnh@isi.edu>.
+#
+# This file is under the Gnu Public License.
+#
+
+sub usage {
+    print STDERR <<END;
+usage: $0 <rawindex >index
+
+Converts a raw index from a notes database into an index
+suitable for notes-index-mode in emacs.
+END
+    exit 1;
+}
+
+require 5.000;
+
+while (<>) {
+    chomp;
+    ($date, $subject) = m@/(\d{6})#\* (.*)$@;
+    warn("could not find date in rawindex line ``$_''.\n"), next if (!defined($date));
+    warn("could not find subject in rawindex line ``$_''.\n"), next if (!defined($subject));
+    $lcsubject = lc($subject);
+    $subject{$lcsubject} = $subject;
+    $list{$lcsubject} = "" if (!defined($list{$lcsubject}));   # for -w
+    $list{$lcsubject} .= "$date, ";
+};
+
+print "# -*- mode: notes-index -*-\n";
+foreach (sort keys %list) {
+    # Trim the trailing ", ".
+    $list{$_} =~ s/, $//;
+    print "$subject{$_}: $list{$_}\n";
+};