GNU bug report logs - #47902
cperl-mode: unwanted expansion of '$continue' [PATCH]

Previous Next

Package: emacs;

Reported by: haj <at> posteo.de (Harald Jörg)

Date: Mon, 19 Apr 2021 22:31:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Stefan Kangas <stefan <at> marxist.se>

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 47902 in the body.
You can then email your comments to 47902 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#47902; Package emacs. (Mon, 19 Apr 2021 22:31:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to haj <at> posteo.de (Harald Jörg):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 19 Apr 2021 22:31:01 GMT) Full text and rfc822 format available.

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

From: haj <at> posteo.de (Harald Jörg)
To: bug-gnu-emacs <at> gnu.org
Subject: cperl-mode: unwanted expansion of '$continue' [PATCH]
Date: Mon, 19 Apr 2021 22:30:04 +0000
[Message part 1 (text/plain, inline)]
The symptom: When typing "$continue", abbrev expansion kicks in and
converts this to "$continue { }" - which immediately catches the eye as
suddenly it is formatted as a hash access.

How to reproduce from Emacs -Q:

    C-x b demo.pl <RET>
    M-: (setq cperl-electric-keywords t)
    cperl-mode <RET>
    $continue = 1;

It is quite usual to activate 'cperl-electric-keywords', either directly
or with the catch-all customization value 'cperl-hairy'.

Root cause: The expansion routine in 'cperl-electric-else' attempts to
verify that the keyword starts a statement, by jumping back over the
keyword with (backward-sexp 1).  For a scalar variable "$else" or
"$continue", this expression also skips back over the dollar (which has
syntax type "escape" in CPerl mode), and "$continue" does start a
statement, so unwanted expansion happens.

The patch replaces (backward-sexp 1) by (skip-chars-backward "[:alpha:]")
and avoids skipping over anything which doesn't belong to the keyword.

-- 
Cheers,
haj
[0001-cperl-mode-Avoid-abbrev-expansion-in-variable-names.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47902; Package emacs. (Tue, 20 Apr 2021 20:57:03 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Harald Jörg <haj <at> posteo.de>
Cc: 47902 <at> debbugs.gnu.org
Subject: Re: bug#47902: cperl-mode: unwanted expansion of '$continue' [PATCH]
Date: Tue, 20 Apr 2021 15:56:41 -0500
tags 47902 fixed
close 47902 28.1
thanks

haj <at> posteo.de (Harald Jörg) writes:

> The symptom: When typing "$continue", abbrev expansion kicks in and
> converts this to "$continue { }" - which immediately catches the eye as
> suddenly it is formatted as a hash access.
>
> How to reproduce from Emacs -Q:
>
>     C-x b demo.pl <RET>
>     M-: (setq cperl-electric-keywords t)
>     cperl-mode <RET>
>     $continue = 1;
>
> It is quite usual to activate 'cperl-electric-keywords', either directly
> or with the catch-all customization value 'cperl-hairy'.
>
> Root cause: The expansion routine in 'cperl-electric-else' attempts to
> verify that the keyword starts a statement, by jumping back over the
> keyword with (backward-sexp 1).  For a scalar variable "$else" or
> "$continue", this expression also skips back over the dollar (which has
> syntax type "escape" in CPerl mode), and "$continue" does start a
> statement, so unwanted expansion happens.
>
> The patch replaces (backward-sexp 1) by (skip-chars-backward "[:alpha:]")
> and avoids skipping over anything which doesn't belong to the keyword.

Thanks!  This makes sense and works fine here so I've pushed this to
master as commit c4c9a60c13.

I've made some minor adjustment of the commit message and added the bug
number.  I also added a blank line before the "ends here" line as a
minor stylistic point.




Added tag(s) fixed. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 20 Apr 2021 20:57:04 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47902 <at> debbugs.gnu.org and haj <at> posteo.de (Harald Jörg) Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 20 Apr 2021 20:57:04 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. (Wed, 19 May 2021 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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