From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Fixing post-self-insert-hook. Date: Sun, 19 Sep 2021 12:14:18 +0000 Message-ID: References: <874kahcx4h.fsf_-_@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18882"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel@gnu.org To: =?iso-8859-1?Q?Jo=E3o_T=E1vora?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 19 14:17:12 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 1mRvku-0004m9-9P for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Sep 2021 14:17:12 +0200 Original-Received: from localhost ([::1]:57576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mRvks-0000H5-MN for ged-emacs-devel@m.gmane-mx.org; Sun, 19 Sep 2021 08:17:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mRviQ-0006LX-Uv for emacs-devel@gnu.org; Sun, 19 Sep 2021 08:14:40 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:11144 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1mRviO-00041e-Pk for emacs-devel@gnu.org; Sun, 19 Sep 2021 08:14:38 -0400 Original-Received: (qmail 35568 invoked by uid 3782); 19 Sep 2021 12:14:19 -0000 Original-Received: from acm.muc.de (p2e5d5c04.dip0.t-ipconnect.de [46.93.92.4]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 19 Sep 2021 14:14:18 +0200 Original-Received: (qmail 8451 invoked by uid 1000); 19 Sep 2021 12:14:18 -0000 Content-Disposition: inline In-Reply-To: <874kahcx4h.fsf_-_@gmail.com> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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:275048 Archived-At: Hello, Joćo On Sat, Sep 18, 2021 at 23:55:10 +0100, Joćo Tįvora wrote: > Joćo Tįvora writes: > > it's just done. I've asked Joćo about such an interface over the last > > few years, now and then, but such has not yet been forthcoming. > I've made my opinion clear now and then, over the years. But here I go > again: > 'electric-pair-post-self-insert-function' (aka e-p-p-s-i-f) existed > before I have laid my programmer eyes on it. It's not an internal > function, it has a defined protocol .... It doesn't even have a doc string. > .... and exists to be a member of 'post-self-insert-hook'. Exactly. There is a need for a stable functional interface to electric-pair-mode which CC Mode can use. Despite how little effort it would be to create and formalise this, you have refused to do so over the years. > Its purpose is -- and has always been -- to insert aditional > delimiters related to the one just typed or, alternatively, to delete > the character just inserted when it happens to skip a closing > delimiter. Yes. Would you please write this into a doc string for electric-pair-post-self-insert-function, together with information about where that function gets its information from, and what it does with point. [ .... ] > Nevertheless, if you want to extract things from e-p-p-s-i-f and use > them in your function, you can refactor its innards. As long as you > don't break anything (fortunately there are good tests) or convolute > elec-pair.el's code beyond recognition. Don't expect me to spend my > time any time in this effort: I won't. I think it would be a very gross > waste of time. _My_ time, at least. You may convince someone else of > that idea. What a wonderful attitude for a maintainer. ;-( You will perhaps recall bug #33794 "26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode". Despite a large part of the problem lying within electric-pair-mode, I don't think you changed a single line of your code to fix the problem. As a result, I was forced to implement ugly workarounds, which are still there almost three years later, the alternative being leaving the bug unfixed. > My alternative suggestion, which I've offered now and then, over the > years, is for you to study how cc-mode behaves when you bind the > delimiter keys simply to 'self-insert-command' .... You know full well that this is problematic. > and refrain from re-inventing 'electric-pair-mode' inside cc-mode. I sometimes wonder if such a reimplementation inside CC Mode might have been less work than all the email exchange with you trying to get you to fix things. > I do this in my .emacs, and I see that other users have settled on the > same practice. If you were to try that, you could theoretically > arrive at the conclusion that it is possible to do everything cc-mode > does today w.r.t. electricity via the existing interfaces of > 'electric-pair-mode', 'electric-layout-mode' and > 'electric-indent-mode'. Sure, anything's possible. But doing so whilst retaining functionality would fragment the code, and lead inevitably to bugs in what is currently an exceptionally stable part of CC Mode. > I must be honest. I don't really expect you arrive at that conclusion > or even try that experiment. No. I have a user base to consider. > That's OK, I can't force anyone to reason the way I do. My personal > hopes for C/C++/Java editing in Emacs are a completely new major mode > where syntax is handled by TreeSitter and all the keys are bound to > 'self-insert-command'. I'd bet good money that 'electric-pair-mode' > is going to work there fine and with 0 configuration, like it does in > all other major modes. > With best regards, > Joćo -- Alan Mackenzie (Nuremberg, Germany).