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: Sun, 1 Dec 2019 15:07:38 +0000 Message-ID: <20191201150738.GB5085@ACM> References: <20191130143638.GA6716@ACM> 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="20753"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 38406@debbugs.gnu.org To: yyoncho Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 01 16:08: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 1ibQpZ-0005H8-CB for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Dec 2019 16:08:13 +0100 Original-Received: from localhost ([::1]:52140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibQpX-0002xn-KW for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Dec 2019 10:08:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60475) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibQpQ-0002x7-LA for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:08:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibQpO-00025x-JR for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:08:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibQpO-00025X-FG for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ibQpO-0004as-AC for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:08: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: Sun, 01 Dec 2019 15:08: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.157521286417631 (code B ref 38406); Sun, 01 Dec 2019 15:08:02 +0000 Original-Received: (at 38406) by debbugs.gnu.org; 1 Dec 2019 15:07:44 +0000 Original-Received: from localhost ([127.0.0.1]:36567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ibQp6-0004aE-75 for submit@debbugs.gnu.org; Sun, 01 Dec 2019 10:07:44 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:14157 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1ibQp4-0004a2-Cq for 38406@debbugs.gnu.org; Sun, 01 Dec 2019 10:07:43 -0500 Original-Received: (qmail 9933 invoked by uid 3782); 1 Dec 2019 15:07:40 -0000 Original-Received: from acm.muc.de (p2E5D5336.dip0.t-ipconnect.de [46.93.83.54]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 01 Dec 2019 16:07:38 +0100 Original-Received: (qmail 6172 invoked by uid 1000); 1 Dec 2019 15:07:38 -0000 Content-Disposition: inline In-Reply-To: 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:172712 Archived-At: Hello, Ivan. On Sun, Dec 01, 2019 at 12:02:56 +0200, yyoncho wrote: > Hi Alan, > > There are other possible "fixes", for example modifying these functions > > so that they don't use self-insert-command at all, but somehow I don't > > think that's what you want. > I don't think that the code that is implemented against the contract listed > in the hook documentation should be rewritten. If electric stuff is so > that important and there is no way to disable it by default then at > least a function to unbind the electric functionality the > documentation of post-self-insert-hook should state: "Don't rely on > this hook in cc derived modes because of {implementation details}. If > you still want to use post-self-insert-hook disable use > {implementation details} to turn electric off." The problem you have stumbled over is more of a political problem than a technical one. post-self-insert-hook was introduced relatively recently as a quick and dirty method of doing certain things. Its implications weren't thought through beforehand. In particular, it breaks major modes which use self-insert-command as part of their processing, including CC Mode. If functions put onto post-self-insert-hook didn't violate the definition of self-insert-command (inserting exactly one copy of the key typed), there wouldn't be a problem. An example of such a function is blink-paren-post-self-insert-function (see lisp/simple.el L7801). However, there are several functions put onto this hook that make extensive buffer changes. An example is electric-pair-post-self-insert-function (in lisp/elec-pair.el). These mess up self-insert-command, and violate the principle that major modes should be in charge of what text goes where in a window. People like using post-self-insert-hook without worrying about the problems it causes. Binding post-self-insert-hook to nil in CC Mode, while not good, was a pragmatic workaround from around a year ago. This allowed electric-pair-mode to function in CC Mode. As I said, this problem is primarily a political problem. Forgive me not wanting to draw too much attention to it at the moment. Again, how does this binding of post-self-insert-hook to nil in CC Mode affect you? What is it you're trying to do that this binding makes difficult? > Thanks, > Ivan -- Alan Mackenzie (Nuremberg, Germany).