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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47598 in the body.
You can then email your comments to 47598 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47598; Package emacs. (Mon, 05 Apr 2021 00:06:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "E. Choroba" <choroba <at> matfyz.cz>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 05 Apr 2021 00:06:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "E. Choroba" <choroba <at> matfyz.cz>
To: bug-gnu-emacs <at> gnu.org
Subject: cperl-mode: Highlighting confused with ternary and -x
Date: Mon, 5 Apr 2021 02:04:56 +0200 (CEST)
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. Note that m?? without m results in a syntax error since 
Perl 5.22.

Ch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47598; Package emacs. (Tue, 06 Apr 2021 18:34:02 GMT) Full text and rfc822 format available.

Message #8 received at 47598 <at> debbugs.gnu.org (full text, mbox):

From: haj <at> posteo.de (Harald Jörg)
To: "E. Choroba" <choroba <at> matfyz.cz>
Cc: 47598 <at> debbugs.gnu.org
Subject: Re: 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)]

Added tag(s) patch. Request was from haj <at> posteo.de (Harald Jörg) to control <at> debbugs.gnu.org. (Fri, 09 Apr 2021 10:06:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47598; Package emacs. (Thu, 06 May 2021 10:35:01 GMT) Full text and rfc822 format available.

Message #13 received at 47598 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: haj <at> posteo.de (Harald Jörg)
Cc: 47598 <at> debbugs.gnu.org, "E. Choroba" <choroba <at> matfyz.cz>
Subject: Re: bug#47598: cperl-mode: Highlighting confused with ternary and -x
Date: Thu, 06 May 2021 12:34:00 +0200
haj <at> posteo.de (Harald Jörg) writes:

> 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.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 06 May 2021 10:36:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47598 <at> debbugs.gnu.org and "E. Choroba" <choroba <at> matfyz.cz> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 06 May 2021 10:36:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Jun 2021 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 328 days ago.

Previous Next


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