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: Thu, 5 Dec 2019 19:09:51 +0000 Message-ID: <20191205190951.GA6252@ACM> References: <20191130143638.GA6716@ACM> <20191201150738.GB5085@ACM> <83imn0lyed.fsf@gnu.org> <20191201192709.GE5085@ACM> <83blsrn58a.fsf@gnu.org> <20191204204159.GA7587@ACM> <83immuj0g7.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="90669"; 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 Thu Dec 05 20:13:58 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 1icwZZ-000NP6-G5 for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Dec 2019 20:13:57 +0100 Original-Received: from localhost ([::1]:59990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icwZY-0006pQ-DI for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Dec 2019 14:13:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41408) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icwVn-0004ee-P8 for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2019 14:10:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icwVm-0006P3-Jx for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2019 14:10:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icwVm-0006O8-Ee for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2019 14:10:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1icwVm-000151-7P for bug-gnu-emacs@gnu.org; Thu, 05 Dec 2019 14:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Dec 2019 19:10:02 +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.15755729984134 (code B ref 38406); Thu, 05 Dec 2019 19:10:02 +0000 Original-Received: (at 38406) by debbugs.gnu.org; 5 Dec 2019 19:09:58 +0000 Original-Received: from localhost ([127.0.0.1]:45213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1icwVh-00014c-L0 for submit@debbugs.gnu.org; Thu, 05 Dec 2019 14:09:57 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:54428 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1icwVg-00014S-6P for 38406@debbugs.gnu.org; Thu, 05 Dec 2019 14:09:57 -0500 Original-Received: (qmail 35418 invoked by uid 3782); 5 Dec 2019 19:09:55 -0000 Original-Received: from acm.muc.de (p4FE15A39.dip0.t-ipconnect.de [79.225.90.57]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 05 Dec 2019 20:09:51 +0100 Original-Received: (qmail 6453 invoked by uid 1000); 5 Dec 2019 19:09:51 -0000 Content-Disposition: inline In-Reply-To: <83immuj0g7.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:172925 Archived-At: Hello, Eli. On Thu, Dec 05, 2019 at 16:45:12 +0200, Eli Zaretskii wrote: > > Date: Wed, 4 Dec 2019 20:41:59 +0000 > > Cc: 38406@debbugs.gnu.org > > From: Alan Mackenzie > > OK, here's a patch which I think does just what's wanted. Would you > > please try it out, Ivan, then let me know that it works, or about any > > problems which there still may be? Thanks. > Thanks. Actually, I forgot about testing for the existence of post-self-insert-hook. So the following will go in, too, with the obvious definition for ....-1: (defmacro c--call-post-self-insert-hook-more-safely () ;; Call post-self-insert-hook, if such exists. See comment for ;; `c--call-post-self-insert-hook-more-safely-1'. (if (boundp 'post-self-insert-hook) '(c--call-post-self-insert-hook-more-safely-1) '(progn))) > > +(defvar c--unsafe-post-self-insert-hook-functions > > + '(smie-blink-matching-open > > + electric-pair-post-self-insert-function > > + blink-paren-post-self-insert-function > > + electric-indent-post-self-insert-function > > + electric-layout-post-self-insert-function > > + electric-quote-post-self-insert-function) > > + "Known unsafe functions when members of `post-self-insert-hook' in CC Mode") > Can you explain why you exempt these from being called from CC Mode? There is already a call to the matching-paren blink functionality in cc-cmds.el, which must stay for older Emacsen. If blink-paren-p-s-i-f was allowed to run too, the result would probably be a doubling of the blink time. This is not desirable. The same applies to smie-blink-m-o, which in any case will not be used for CC Mode. electric-pair-post-self-insert-function must not run in c-electric-brace/paren except as carefully coded in these functions explicitly; it would otherwise foul things up, one way or another, as it did in the scenario for which bug #33794 was raised. Of the other three electric-* functions, only one has a complete doc string, so it is work to work out what the other two do. electric-indent-post-self-insert-function is redundant in CC Mode, and probably harmful. At best it will just take up processor cycles. I believe electric-layout-p-s-i-f just duplicates the auto-newline behaviour of the c-electric-* functions, making it redundant. I don't know exactly what electric-quote-p-s-i-f does, but it is likely to be something to do with quotes, and thus likely to clash with CC Mode's handling of quotes. > AFAIU, by disabling them when CC Mode reacts to insertion, you have > solved the conflict between any such hook and CC Mode, so why not call > any such hook afterwards? See above. -- Alan Mackenzie (Nuremberg, Germany).