App-orgdaemon

 view release on metacpan or  search on metacpan

bin/org-daemon  view on Meta::CPAN

		} else {
		    $text = $textline;
		}
		if ($text =~ m{^\*+\s+(?:DONE|WONTFIX)\b}) {
		    next; # ignore DONE and WONTFIX items
		}
		my @tags;
		if ($text =~ m{\s:(\S+):(\s|$)}) {
		    @tags = split /:/, $1;
		    my $next;
		    for (@tags) {
			if ($ignore_tags{$_}) {
			    $next = 1;
			    last;
			}
		    }
		    next if $next;
		}
		my %date_params = (epoch => $epoch,
				   date  => $date,
				   time  => $time,
				   early_warning => $early_warning,
				   date_end => $date_end,
				   time_end => $time_end,
				   text  => $text,
				   file  => $file,
				   line  => $linenumber,
				   seek  => $last_seek,
				   tags  => \@tags,
				  );

		my $early_warning_secs;
		if ($early_warning) {
		    $early_warning_secs = _get_head_warning_secs($early_warning);
		}
		if (!defined $early_warning_secs) {
		    $early_warning_secs = !defined $time || !length $time ? $default_timeless_early_warning : $default_early_warning;
		}
		if ($early_warning_secs > 0) {
		    $date_params{early_warning_epoch} = $epoch - $early_warning_secs;
		}

		my $date = Emacs::Org::Daemon::Date->new(%date_params);
		my $date_state = $date->state;
		if ($date_state =~ m{^(wait|early|due)}) {
		    push @dates, $date;
		}
	    }
	}
    }

    @dates;
}

sub _get_head_warning_secs {
    my($s) = @_;
    if (my($count, $unit) = $s =~ m{-([0-9]+)(s|min|h|d|w|m|y)}) {
	$count * {s   => 1,
		  min => 60,
		  h   => 60*60,
		  d   => 60*60*24,
		  w   => 60*60*24*7,
		  # as suggested in org-get-wdays in org.el
		  m   => 60*60*24*30.4,
		  y   => 60*60*24*365.25,
		 }->{$unit};
    } else {
	warn "Cannot parse '$s'";
	undef;
    }
}

sub open_warning {
    my $file = shift;
    $open_warning{$file} ||= 0;
    if ($open_warning{$file} > 3) {
    } elsif ($open_warning{$file} == 3) {
	warn "Can't open $file: $!. Won't warn anymore!\n";
    } else {
	warn "Can't open $file: $!";
    }
    $open_warning{$file}++;
}

sub set_x11_properties {
    my $t = shift;
    if ($Tk::platform eq 'unix') {
	my($wrapper) = $t->wrapper;
	if (!eval {
	    require Sys::Hostname;
	    $t->property("set", "_NET_WM_PID", "CARDINAL", 32, [$$], $wrapper);
	    $t->property("set", "WM_CLIENT_MACHINE", "STRING", 8, [Sys::Hostname::hostname()], $wrapper);
	    1;
	}) {
	    warn "WARNING: Setting _NET_WM_PID and WM_CLIENT_MACHINE properies failed: $@";
	}
    }
}

sub stay_on_top {
    my $t = shift;
    no warnings 'once';
    if ($Tk::platform eq 'unix') {
	my($wrapper) = $t->wrapper;
	# set sticky flag for gnome and fvwm2
	eval q{
	$t->property('set','_WIN_STATE','CARDINAL',32,[1],$wrapper); # sticky
	$t->property('set','_WIN_LAYER','CARDINAL',32,[6],$wrapper); # ontop
	};
	warn $@ if $@;
    }
    
    eval { $t->attributes(-topmost => 1) };
    warn $@ if $@;
}

# Code taken from bbbike
sub start_ptksh {
    # Is there already a (withdrawn) ptksh?
    foreach my $mw0 (Tk::MainWindow::Existing()) {
	if ($mw0->title =~ /^ptksh/) {
	    $mw0->deiconify;
	    $mw0->raise;
	    return;
	}



( run in 3.791 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )