From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#47902: cperl-mode: unwanted expansion of '$continue' [PATCH] Date: Tue, 20 Apr 2021 15:56:41 -0500 Message-ID: References: <87a6ptgb6b.fsf@hajtower> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24304"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47902@debbugs.gnu.org To: Harald =?UTF-8?Q?J=C3=B6rg?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 20 22:57:34 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lYxR8-0006DP-Nv for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Apr 2021 22:57:34 +0200 Original-Received: from localhost ([::1]:57664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYxR7-0007XO-Rx for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Apr 2021 16:57:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYxQg-0007Wo-JC for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2021 16:57:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lYxQd-0001FP-2K for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2021 16:57:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lYxQd-0002Lk-1e for bug-gnu-emacs@gnu.org; Tue, 20 Apr 2021 16:57:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Apr 2021 20:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47902-submit@debbugs.gnu.org id=B47902.16189522118979 (code B ref 47902); Tue, 20 Apr 2021 20:57:02 +0000 Original-Received: (at 47902) by debbugs.gnu.org; 20 Apr 2021 20:56:51 +0000 Original-Received: from localhost ([127.0.0.1]:56182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYxQQ-0002Kk-PT for submit@debbugs.gnu.org; Tue, 20 Apr 2021 16:56:51 -0400 Original-Received: from mail-pf1-f171.google.com ([209.85.210.171]:46736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYxQO-0002KO-6l for 47902@debbugs.gnu.org; Tue, 20 Apr 2021 16:56:49 -0400 Original-Received: by mail-pf1-f171.google.com with SMTP id d124so26478013pfa.13 for <47902@debbugs.gnu.org>; Tue, 20 Apr 2021 13:56:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc :content-transfer-encoding; bh=O2pFRo1z9CnwtDfQjK6tG7NoP6TQ70zCG5aotTRHMeM=; b=U3a4KRoUavPF7oyefmQILiLcvalBhtuoqeVMQ3wQPU8KTmZfXtDP3vGZMpS1iB7b1h 9HBV8lBzPidwF0QU0GqjlNjLxDuE+X31d7MSqdpQLKxOj3dY7iBFng7TqDok7iKWmsqB EEAXR9u12wsKMh/qm9yANJTeDpowE4Hy1G/XXwJyrPk8ln4f4zXxjEhQB7/4nnKhqEFF 4CxqBJwrge7Niw7dWfj0NoSsKWrdntTtEJ9X/YpdFnOinPC25l+Ppdrz1UwkUHdo4Jyl 0qh1/qC+zz3hVVBsvWFEpEqDhKaXESQJcCH1x+GY1q15CwGRxYcxWrTWfHpO2UEywJsk qNZQ== X-Gm-Message-State: AOAM533G4Sd7ObLiNB3vgAu9v0U5EPmnZedaQ5w7XSpn74RnaqKwKkNn ZVfHnbQQv+A82ikMpvTSjbx0T2K1fceZb6EJD7w= X-Google-Smtp-Source: ABdhPJxdbP4uU1n3o8V0j9i6MjDVtu4KpDs1WteS0Pm3CAbhY1KXgOqyaLJ6euHvtDycziGHUcELOHO+VlQbnlMOcqs= X-Received: by 2002:a63:942:: with SMTP id 63mr19230739pgj.67.1618952202285; Tue, 20 Apr 2021 13:56:42 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Tue, 20 Apr 2021 15:56:41 -0500 In-Reply-To: <87a6ptgb6b.fsf@hajtower> ("Harald =?UTF-8?Q?J=C3=B6rg?="'s message of "Mon, 19 Apr 2021 22:30:04 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:204552 Archived-At: tags 47902 fixed close 47902 28.1 thanks haj@posteo.de (Harald J=C3=B6rg) 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 > M-: (setq cperl-electric-keywords t) > cperl-mode > $continue =3D 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.