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.devel Subject: Re: Handling extensions of programming languages Date: Sun, 21 Mar 2021 12:41:26 +0100 Message-ID: <87h7l43fa1.fsf@hajtower> References: <87o8ff560t.fsf@hajtower> <87im5lhi6i.fsf@rfc20.org> <87r1k94cnx.fsf@hajtower> <20a4ef1c-beaf-1d63-b984-12be9a856c86@gmail.com> 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="838"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Mar 21 12:46:08 2021 Return-path: Envelope-to: ged-emacs-devel@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 1lNwX1-000Aeb-Pd for ged-emacs-devel@m.gmane-mx.org; Sun, 21 Mar 2021 12:46:07 +0100 Original-Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lNwX0-0004gl-PA for ged-emacs-devel@m.gmane-mx.org; Sun, 21 Mar 2021 07:46:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNwSj-00045x-Bl for emacs-devel@gnu.org; Sun, 21 Mar 2021 07:41:42 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:51383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lNwSY-0003Fg-80 for emacs-devel@gnu.org; Sun, 21 Mar 2021 07:41:38 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 3DE8D2400FD for ; Sun, 21 Mar 2021 12:41:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1616326887; bh=FAr/Y9vlYPhjZ7JBsJ6nwmuBR6NLCIxFm/sZUFbMf7w=; h=From:To:Cc:Subject:Date:From; b=LnjYL0P310EBLVdHODNLwenor/zI/OHnuCSSIp6jE7HkFcBcoPbQ5sNtH2nePcvSk JvU+mExJJPdt+AqiLM9RW9S4rZoUCikEg1nWEGAPornAEb3u7b43DFtnnNI0BEfWu/ rzgF5nQr85gasWPYekt/2w52UtDHXoAA61pteGsSY641zNQ3ivp0lY/uFuJKcF675f LKsRNjpa67tW+gX/3EL31W1juj1no11pHs0ZNry1iF8tGfn/2eqX2aX55pFxb4GMlQ czG1y0pzwt5cVvFQpywqHL6bvZ8HtlUlGPxCygLFM1S6qy0RfKkjtYSqPll5Rde3W0 6xvKBlPKSm0Mw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4F3G1L4crJz6tmg; Sun, 21 Mar 2021 12:41:26 +0100 (CET) In-Reply-To: <20a4ef1c-beaf-1d63-b984-12be9a856c86@gmail.com> (=?utf-8?Q?=22Cl=C3=A9ment?= Pit-Claudel"'s message of "Sat, 20 Mar 2021 22:18:00 -0400") Received-SPF: pass client-ip=185.67.36.66; envelope-from=haj@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266698 Archived-At: Cl=C3=A9ment Pit-Claudel writes: > On 3/20/21 7:40 PM, Harald J=C3=B6rg wrote: >> Well, I have my doubts that Perl is a good candidate for SMIE, and >> trying to use SMIE in CPerl mode would be a major rewrite anyway. I >> guess the Emacs Losp basics (font-lock-add-keyword, hooks) will have to >> do the job. > > I'm pretty sure SMIE would work wonderfully for Perl, but I'm also not > sure how it relates to font-lock-add-keywords and hooks, so maybe > we're not thinking of the same thing? I admit that I don't know much about SMIE, so maybe I'm wrong here. Most of Perl is pretty similar to C or Java, but there are cases where Perl's syntax just can't be parsed statically. About the relation to font-lock-add-keywords - let me show an example. "Traditional" Perl has no keywords for object oriented programming, but there are dozens of extensions which add them. For example, with Object::Pad you can write (I apologize for the nonsensical example): class Coffee::Machine extends Lawn::Mower { has $grinder :reader :writer(replace_grinder) method grind { ...; } }=20 If I want to support that with CPerl mode, I need to: - highlight class, extends, method and some more I haven't included in that example as keywords. That's where font-lock-add-keywords comes into play. Also, "Dishwasher" and "clean_up" should be highlighted like package and sub names. - add "Dishwasher" and "clean_up" to the imenu index. =20 - make sure that indentation recognizes that the closing braces end a statement after "class" and "method". Perl syntax has various cases where it doesn't. I guess this is the part where SMIE would help. For the latter two tasks, I need to "hook" the logic somehow into CPerl's implementations of `imenu-create-index-function' and the various indentation functions. The current indentation code in CPerl mode is... a bit messy, and some old bugs call for attention anyway. If, however, that same class would be defined using the Dios extension, it would look like this: class Coffee::Machine is Lawn::Mower { has $.grinder is rw method grind { ... } }=20 ...and also offer the keywords "func" and "submethod" for stuff that should go into imenu, and "lex" for declaring variables. There's a dozen or more other extensions providing OO frameworks for Perl. So, if the Emacs support for an extension could be done by a separate .el file, these could be developed within GNU Emacs, in GNU ELPA, but also contributed via NonGNU elpa, MELPA or GitHub. I am aware that probably as soon as such an extension mechanism is available, _someone_ will publish a Perl extension which can't be covered :) --=20 Cheers, haj