diff options
author | John Ankarström <john@ankarstrom.se> | 2021-05-26 14:52:21 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-05-26 14:52:21 +0200 |
commit | 55e8dbfa92eb9c549dfb28c808cfb1d3b978f104 (patch) | |
tree | f20dcbd50bc93ea82e75783a19b40247c2d2f846 | |
parent | 2e44e619a89589f79253f95d3d6428f411b842e4 (diff) | |
download | mum-55e8dbfa92eb9c549dfb28c808cfb1d3b978f104.tar.gz |
mum: Fix ?? bug
-rwxr-xr-x | src/mum | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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"; |