]>
code.delx.au - gnu-emacs-elpa/blob - packages/notes-mode/catsubject
5 # $Id: catsubject,v 1.7 2003/05/23 16:26:24 johnh Exp $
7 # Copyright (C) 1996 by John Heidemann.
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.
17 usage: $0 [-m] subject
19 Outputs (to stdout) the contents of all entries with the given subject.
21 Assumes that rawindex is up-to-date.
24 -m match subjects with a perl regexp
34 &usage
if ($#ARGV >= 0 && $ARGV[0] eq '-?');
36 &GetOptions
(\
%opts, qw(m));
37 &usage
if ($#ARGV < 0);
40 # $home_dir = ((getpwuid($<))[7]);
41 # @config = `$home_dir/.notesrc perl`;
42 # die "$0: missing .notesrc\n" if ($#config == -1);
43 # eval join("", @config);
44 # unshift(@INC, $notes{'bin_dir'});
48 BEGIN { unshift(@INC, "/home/johnh/NOTES/BIN"); };
56 # NEEDSWORK: replace with real argument parsing
58 my($subject) = lc($Subject);
59 my($match_subject) = ($opts{'m'});
61 my($subject_description) = ($match_subject ?
"match on " : "") . $Subject;
65 # Say what we're doing.
67 print "\n* What\n------\n\nOutput of:\n\t$0 " . $subject_description . "\n" .
68 "as of " . localtime(time) . "\n\n\n";
70 my($notes_index) = new NotesIndex
($::notes
{dir
} . "/rawindex");
79 my($code) = '$s =~ m{' . $subject . '}';
81 foreach $s ($notes_index->subjects()) {
86 print "Subjects:\n", join("\n", @subjects), "\n\n";
88 @subjects = ($subject);
96 foreach $s (@subjects) {
97 foreach $url ($notes_index->by_subject($s)) {
98 my($notes) = new Notes
(url_to_pathname
($url));
100 foreach $entry ($notes->by_subject($s)) {
101 my($this) = "this: <$url>";
102 my(@lines) = split(/\n/, $entry);
103 if ($lines[2] =~ /^prev: /) {
104 print join("\n", @lines[0..2], $this, @lines[3..$#lines], "\n\n");
106 print join("\n", @lines[0..1], $this, @lines[2..$#lines], "\n\n");