From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#38406: 27.0.50; post-self-insert-hook does not hold its contract in cc-mode derived modes Date: Fri, 6 Dec 2019 22:24:59 +0000 Message-ID: <20191206222459.GB3999@ACM> References: <20191201192709.GE5085@ACM> <83blsrn58a.fsf@gnu.org> <20191204204159.GA7587@ACM> <83immuj0g7.fsf@gnu.org> <20191205190951.GA6252@ACM> <83pnh2h8x1.fsf@gnu.org> <20191205201713.GC6252@ACM> <83eexhho8o.fsf@gnu.org> <20191206182842.GA3999@ACM> <83y2vpffyd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="216272"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: yyoncho@gmail.com, 38406@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 06 23:26:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1idM3B-000u97-2T for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2019 23:26:13 +0100 Original-Received: from localhost ([::1]:45950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idM39-0005LK-Gh for geb-bug-gnu-emacs@m.gmane.org; Fri, 06 Dec 2019 17:26:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54829) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idM31-0005Kl-IM for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:26:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1idM30-0003iV-CB for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:26:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1idM30-0003gE-1y for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1idM2z-0007VR-Sg for bug-gnu-emacs@gnu.org; Fri, 06 Dec 2019 17:26:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Dec 2019 22:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38406 X-GNU-PR-Package: emacs Original-Received: via spool by 38406-submit@debbugs.gnu.org id=B38406.157567110628466 (code B ref 38406); Fri, 06 Dec 2019 22:26:01 +0000 Original-Received: (at 38406) by debbugs.gnu.org; 6 Dec 2019 22:25:06 +0000 Original-Received: from localhost ([127.0.0.1]:47141 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1idM26-0007P3-4Q for submit@debbugs.gnu.org; Fri, 06 Dec 2019 17:25:06 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:25353 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1idM24-0007Oo-0E for 38406@debbugs.gnu.org; Fri, 06 Dec 2019 17:25:04 -0500 Original-Received: (qmail 29406 invoked by uid 3782); 6 Dec 2019 22:25:02 -0000 Original-Received: from acm.muc.de (p4FE15A40.dip0.t-ipconnect.de [79.225.90.64]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 06 Dec 2019 23:24:59 +0100 Original-Received: (qmail 9234 invoked by uid 1000); 6 Dec 2019 22:24:59 -0000 Content-Disposition: inline In-Reply-To: <83y2vpffyd.fsf@gnu.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172986 Archived-At: Hello, Eli. On Fri, Dec 06, 2019 at 20:48:26 +0200, Eli Zaretskii wrote: > > Date: Fri, 6 Dec 2019 18:28:42 +0000 > > Cc: yyoncho@gmail.com, 38406@debbugs.gnu.org > > From: Alan Mackenzie > > > There might be a misunderstanding on my part here. Could you please > > > explain how come electric-pair-post-self-insert-function is called > > > twice if it isn't removed from the hook? where's the second (or the > > > first) call? > > The first call is an explicit call from c-electric-brace to > > electric-pair-post-self-insert-function. Depending on the changes to the > > buffer this call causes (amongst other things), differing electric > > actions are performed by c-electric-brace. This call is itself a > > workaround, there being no purpose designed function for this purpose in > > elec-pair.el. > > The second call happens when c-electric-brace run-hook's > > post-self-insert-hook - _if_ electric-pair-post-self-insert-function > > hasn't been filtered out of that hook. > If you already call that particular function explicitly, then calling > it one more time is indeed redundant. No, it's not redundant. It's positively harmful. > But is this the case with all the other functions that you suggest to > filter from post-self-insert-hook? No. They have individual reasons for being filtered out. Don't forget that this is a particularly sensitive hook, allowing hook functions to interfere in an unsynchronised way with partially complete command processing. Let's go through them again: smie-blink-matching-open is inapplicable to CC Mode and just takes up processor cycles. electric-pair-post-self-insert-function we've already discussed. blink-paren-post-self-insert-function would do nothing anyhow, since blink-paren-function has been bound to nil - this is so that the actual blinking doesn't occur until the newly inserted brace is at its final position. electric-indent-post-self-insert-function is redundant and possibly harmful. electric-layout-post-self-insert-function is undocumented, thus likely to be harmful. Its name suggests it is redundant. electric-quote-post-self-insert-function is undocumented, uncommented and obscure. It is safer not to risk running it. Given that the mechanism for filtering post-self-insert-hook is there, why is there the resistance to filtering out redundant and effect-free functions? And how come functions without meaningful doc strings are allowed onto Emacs hooks? -- Alan Mackenzie (Nuremberg, Germany).