hi:
i have this script which reads a txt file and outputs a list of tasks grouped by context.
it was made to work with emacs org mode but i want to use vim instead.
how should i change it to scan all lines of text and group context that appear as @work @home etc.
for example if my text file is
project: website 123
create logo @work
call client @phone
project conquer world
research @computer
call friends @phone
then the script outputs
@computer:
research
@phone:
call client
call friends
you get the idea.
the script:
---------------
use strict;
use warnings;
# Read an org file and create lists by context (tag)
# Written by Charles Cave charles.cave (at) gmail.com
# 28th June 2006
my $orgfile = shift;
defined($orgfile) or die "syntax is orghip.pl orgfilename\n";
open(my $org, "<", $orgfile) or die "Cannot open $orgfile\n";
my %lists = ();
my $now = localtime();
while (<$org>) {
my $line = $_;
chomp($line);
if ($line =~ /^\*+\s*(.*?)
[A-Za-z]+):/) {
my $hdng = "$1";
my $tag = $2;
if ( defined($lists{$tag}) ) {
$lists{$tag} = $lists{$tag}."\n".$hdng;
} else {
$lists{$tag} = $hdng;
}
}
}
print "Date Printed: $now\n";
process_context("PROJECT");
process_context("OFFICE");
process_context("HOME");
process_context("COMPUTER");
process_context("DVD");
process_context("READING");
# print any remaining contexts
foreach my $key (sort keys %lists) {
process_context($key);
}
sub process_context {
my $context = shift;
print "\n\n$context:\n";
foreach my $item( split(/\n/, $lists{$context}) ) {
print "[ ] $item\n";
}
delete $lists{$context};
}
i have this script which reads a txt file and outputs a list of tasks grouped by context.
it was made to work with emacs org mode but i want to use vim instead.
how should i change it to scan all lines of text and group context that appear as @work @home etc.
for example if my text file is
project: website 123
create logo @work
call client @phone
project conquer world
research @computer
call friends @phone
then the script outputs
@computer:
research
@phone:
call client
call friends
you get the idea.
the script:
---------------
use strict;
use warnings;
# Read an org file and create lists by context (tag)
# Written by Charles Cave charles.cave (at) gmail.com
# 28th June 2006
my $orgfile = shift;
defined($orgfile) or die "syntax is orghip.pl orgfilename\n";
open(my $org, "<", $orgfile) or die "Cannot open $orgfile\n";
my %lists = ();
my $now = localtime();
while (<$org>) {
my $line = $_;
chomp($line);
if ($line =~ /^\*+\s*(.*?)

my $hdng = "$1";
my $tag = $2;
if ( defined($lists{$tag}) ) {
$lists{$tag} = $lists{$tag}."\n".$hdng;
} else {
$lists{$tag} = $hdng;
}
}
}
print "Date Printed: $now\n";
process_context("PROJECT");
process_context("OFFICE");
process_context("HOME");
process_context("COMPUTER");
process_context("DVD");
process_context("READING");
# print any remaining contexts
foreach my $key (sort keys %lists) {
process_context($key);
}
sub process_context {
my $context = shift;
print "\n\n$context:\n";
foreach my $item( split(/\n/, $lists{$context}) ) {
print "[ ] $item\n";
}
delete $lists{$context};
}