GNU bug report logs - #47598
cperl-mode: Highlighting confused with ternary and -x

Previous Next

Package: emacs;

Reported by: "E. Choroba" <choroba <at> matfyz.cz>

Date: Mon, 5 Apr 2021 00:06:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: haj <at> posteo.de (Harald Jörg)
To: "E. Choroba" <choroba <at> matfyz.cz>
Cc: 47598 <at> debbugs.gnu.org
Subject: bug#47598: cperl-mode: Highlighting confused with ternary and -x [PATCH]
Date: Tue, 06 Apr 2021 20:33:07 +0200
[Message part 1 (text/plain, inline)]
E. Choroba writes:

> When combining the ternary operator with file tests using the default
> argument, cperl-mode gets confused.
>
> For example:
>
> my $f = -f ? 'file'
>       : -l ? [readlink]
>       : -d ? 'dir'
>            : 'unknown';
>
> It seems to think the ?'s are not part of a ternary operator, but
> rather a match-once operator. ...

Exactly, that is what is happening here.

> ... Note that m?? without m results in a
> syntax error since Perl 5.22.

Because of that it seems appropriate to stop dealing with bare ?foo?
altogether.  So, the patch eliminates the recognition of bare ?foo?, and
also deletes the corresponding lines from CPerl's builtin short
documentation.  The test in the patch uses the text from the bug report,
and also checks that m?foo? is still processed as a regular expression,
and a bare ?foo?  isn't.
-- 
Cheers,
haj
[0001-cperl-mode-Eliminate-bad-interpretation-of-foo-bug-4.patch (text/x-diff, attachment)]

This bug report was last modified 4 years and 19 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.