From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.bugs Subject: bug#46889: cperl-mode: Fix indentation issues [PATCH] Date: Thu, 04 Mar 2021 19:19:42 +0100 Message-ID: <87ft1au6gx.fsf@hajtower> References: <87im68uwld.fsf@hajtower> <87tupqvn9i.fsf@gnus.org> 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="18690"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 46889@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 04 19:20:10 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 1lHsa2-0004jv-2q for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Mar 2021 19:20:10 +0100 Original-Received: from localhost ([::1]:37038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHsa0-0003G3-Qi for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Mar 2021 13:20:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHsZu-0003Fv-87 for bug-gnu-emacs@gnu.org; Thu, 04 Mar 2021 13:20:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lHsZu-0005Cu-0s for bug-gnu-emacs@gnu.org; Thu, 04 Mar 2021 13:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lHsZt-0003pC-Rw for bug-gnu-emacs@gnu.org; Thu, 04 Mar 2021 13:20:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Mar 2021 18:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46889 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46889-submit@debbugs.gnu.org id=B46889.161488199214681 (code B ref 46889); Thu, 04 Mar 2021 18:20:01 +0000 Original-Received: (at 46889) by debbugs.gnu.org; 4 Mar 2021 18:19:52 +0000 Original-Received: from localhost ([127.0.0.1]:60172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHsZj-0003oj-KR for submit@debbugs.gnu.org; Thu, 04 Mar 2021 13:19:51 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:35693) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lHsZi-0003oV-1Q for 46889@debbugs.gnu.org; Thu, 04 Mar 2021 13:19:50 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 57E5A240100 for <46889@debbugs.gnu.org>; Thu, 4 Mar 2021 19:19:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1614881983; bh=0UobGKpbtFrShD8boWfknu4Lnvg9lTx/zLJfEAYHIPs=; h=From:To:Cc:Subject:Date:From; b=hSC5CnDAuKM4J/kL0wc31GM85rychZMKQnNtu311plxsYnE8dMRrF5RXbVg/NAKPL XXzvDo92Y+DMi09Yc+jTFWlXJTNau87yQCG1QSSgK1U6e7P1VSeQo9am8NRDiauC58 ko4TI+YQUu7FYYEKT7z/CFumgP4GI/uRxN+IMVLJiWRYt9bsDRU57VNVvt8CcZb6Y5 gK2mvSDiKT+FT44+qYq5WFbgaA1vh4JUVzzLK2rWKpRnV4cfm4F7IbfCEI1zpaebL4 q61ChOEbTs+/OoWyu26Z5hGPXDo9bIK0STJCjP7Td4fbRVJK0eKSD6097sB1HX4mcI PME1YtP+cZdnA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Drzfk3XX6z9rxW; Thu, 4 Mar 2021 19:19:42 +0100 (CET) In-Reply-To: <87tupqvn9i.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 04 Mar 2021 18:31:37 +0100") 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:201432 Archived-At: Lars Ingebrigtsen writes: > [...] >> Many thanks to Mattias Engdeg=C3=A5rd for his patient explanations how rx >> expressions can be used without breaking compatibility to Emacs 26.1. >> Until now, this allowed two ugly regexp literals to be eliminated. > > Funnily enough, that's the one thing I was going to ask you about with > this patch. > > I'm not an experienced rx user -- at all -- but is this the best way to > do this? > >> +(eval-and-compile >> + (defconst cperl--ws-rx >> + '(sequence (or space "\n")) > > It was the eval-and-compile that made me look at this bit... I am not an experienced rx user at all, I only recently discovered it :) I'm always happy when somebody else is looking over my changes. The patch was a result of a my understanding of an off-the-lists dialog between Mattias and me, where it is totally possible that I misunderstood or misimplemented things. What led me to eval-and-compile was that I want to "compose" Perl syntax elements from those defined earlier - and I also want to write unit tests for the rx form in cperl-mode-tests.el. > [...] > >> +(defconst cperl-maybe-white-and-comment-rex >> + (rx-to-string `(group (eval cperl--ws*-rx))) > > I'm thinking of the rx `eval' things everywhere. Wouldn't defining > these rx expressions with `rx-define' be more straighforward, and then > you'd have: Yes, it would be. The downside is that I'd have to abandon the plan to move CPerl mode to ELPA and make it available for Emacs 26.1 and up. Perl coders might want to try the new CPerl mode without having to build Emacs 28 - and I want their feedback. I'm ready to upgrade that stuff to `rx-define' when the typical Linux distributions ship with an Emacs version supporting it! >> +(defconst cperl-maybe-white-and-comment-rex >> + (rx-to-string `(group cperl--ws*-rx)) > > (Similarly for basically all the rx `eval' bits. > > Now, rx expands the `eval' at compile time, I think, so it doesn't > really make that much difference in practice, but it seems slightly > clearer, perhaps? Sure, I understand that. By the way, the journey isn't over yet. What I plan to do next is to add support for popular Perl extensions which bring new syntax (also, a new Perl version might sooner or later bring the same keywords, probably with "better" syntax). So I guess there will be a basic compile-time-syntax, plus modifications at runtime when I know which exact syntax applies to a buffer. --=20 Cheers, haj