]>
code.delx.au - gnu-emacs-elpa/blob - packages/notes-mode/mkrawindex
4 # mkrawindex -- index notes files
5 # $Id: mkrawindex,v 1.17 2007/02/24 01:25:08 johnh Exp $
7 # Copyright (C) 1994-2006,2012 Free Software Foundation, Inc.
8 # Comments to <johnh@isi.edu>.
10 # This file is under the Gnu Public License, version 2.
11 # For details see the COPYING which accompanies this distribution.
16 usage: $0 [-X] [file...]
17 Writes a raw index to stdout.
19 If no files are specified as arguments,
20 they are read from stdin.
22 Option: -X means read the filesname from stdin rather than the command line.
29 # To make an index do:
30 # ./mkrawindex /h/local/users/johnh/STUFF/NOTES/9????? |
32 # sed 's:/h/local/users/johnh:~:' >index
35 BEGIN { unshift(@INC, $ENV{'NOTES_BIN_DIR'}); };
39 my($files_from_stdin) = undef;
40 if ($ARGV[0] eq '-X') {
41 $files_from_stdin = 1;
45 &usage
if ($#ARGV == 0 && $ARGV[0] eq '-?');
48 # could be localhost to have urls be file://localhost/foo instead of
55 &add_file_to_index
($_);
57 if ($files_from_stdin) {
60 &add_file_to_index
($_);
67 sub add_file_to_index
{
70 # "cannonicalize" the filename
72 if ($cannon_fn !~ m@
^/@
) {
73 $cannon_fn = $::notes
{dir
} . "/" . $cannon_fn;
74 $cannon_fn =~ s@
^$::notes
{home
}@
/~@
;
77 my($n) = new Notes
($fn);
78 my($subs_ref) = $n->subjects();
79 if (!defined($subs_ref)) {
80 warn "$0: no subjects for file $fn.\n";
83 foreach (@
$subs_ref) {
84 warn("$0: subject $_ in $fn has leading spaces.\n")
86 warn("$0: subject $_ in $fn has trailing spaces.\n")
88 warn("$0: subject $_ in $fn has an embedded number sign---this will cause problems with prev/next entries.\n")
90 print "file://$opthost$cannon_fn#* $_\n";