]> code.delx.au - gnu-emacs-elpa/blob - packages/notes-mode/mkindex
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / notes-mode / mkindex
1 #!/usr/bin/perl -w
2
3 #
4 # mkindex
5 # $Id: mkindex,v 1.9 2003/05/23 16:26:33 johnh Exp $
6 #
7 # Copyright (C) 1994-1996,2012 Free Software Foundation, Inc.
8 # Comments to <johnh@isi.edu>.
9 #
10 # This file is under the Gnu Public License.
11 #
12
13 sub usage {
14 print STDERR <<END;
15 usage: $0 <rawindex >index
16
17 Converts a raw index from a notes database into an index
18 suitable for notes-index-mode in emacs.
19 END
20 exit 1;
21 }
22
23 require 5.000;
24
25 while (<>) {
26 chomp;
27 ($date, $subject) = m@/(\d{6})#\* (.*)$@;
28 warn("could not find date in rawindex line ``$_''.\n"), next if (!defined($date));
29 warn("could not find subject in rawindex line ``$_''.\n"), next if (!defined($subject));
30 $lcsubject = lc($subject);
31 $subject{$lcsubject} = $subject;
32 $list{$lcsubject} = "" if (!defined($list{$lcsubject})); # for -w
33 $list{$lcsubject} .= "$date, ";
34 };
35
36 print "# -*- mode: notes-index -*-\n";
37 foreach (sort keys %list) {
38 # Trim the trailing ", ".
39 $list{$_} =~ s/, $//;
40 print "$subject{$_}: $list{$_}\n";
41 };