summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/mum18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/mum b/src/mum
index 77751e0..7955a71 100755
--- a/src/mum
+++ b/src/mum
@@ -41,7 +41,7 @@ my $d = qr{
# Define program state
my $MESSAGE = 0; # selected message
-my $INDEX = '-'; # loaded mbox index
+my $INDEX = ''; # loaded mbox index
my @MESSAGES; # loaded messages
my %MARKS; # saved marks
my $SEARCH; # last search regex
@@ -56,7 +56,7 @@ while () {
$MESSAGE = 1 if $MESSAGE < 1;
$MESSAGE = @MESSAGES if $MESSAGE > @MESSAGES;
- print $tty "$MESSAGE:$INDEX& ";
+ print $tty "$INDEX:$MESSAGE& ";
# Read next command from user
@@ -187,6 +187,10 @@ sub toloc {
elsif (exists $ref{next}) {
$ref{next} = $SEARCH if not $ref{next};
$SEARCH = $ref{next};
+ if (not $ref{next}) {
+ warn "missing pattern\n";
+ return;
+ }
$start = $MESSAGE+1 if not $start;
$loc = $start-1;
@@ -203,13 +207,17 @@ sub toloc {
elsif (exists $ref{prev}) {
$ref{prev} = $SEARCH if not $ref{prev};
$SEARCH = $ref{prev};
+ if (not $ref{prev}) {
+ warn "missing pattern\n";
+ return;
+ }
$start = $MESSAGE-1 if not $start;
- $loc = $start-1;
+ $loc = $start+1;
- for (@MESSAGES[0..$start-1]) {
+ for (reverse @MESSAGES[0..$start-1]) {
$loc--;
- goto found if m?$ref{prev}?;
+ goto found if /$ref{prev}/;
}
warn "pattern ?$ref{prev}? not found\n";