From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: yyoncho 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 17:27:33 +0200 Message-ID: References: <20191130143638.GA6716@ACM> <20191201150738.GB5085@ACM> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d141720598a61af3" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="103704"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 38406@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 01 16:29:12 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 1ibR9s-000QqU-0G for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Dec 2019 16:29:12 +0100 Original-Received: from localhost ([::1]:52370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibR9q-0005lJ-Mn for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Dec 2019 10:29:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34978) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibR8m-0004tF-O5 for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:28:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibR8k-0002wh-VV for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:28:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibR8k-0002wN-OS for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ibR8k-0005Db-KM for bug-gnu-emacs@gnu.org; Sun, 01 Dec 2019 10:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: yyoncho Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 Dec 2019 15:28: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.157521407420043 (code B ref 38406); Sun, 01 Dec 2019 15:28:02 +0000 Original-Received: (at 38406) by debbugs.gnu.org; 1 Dec 2019 15:27:54 +0000 Original-Received: from localhost ([127.0.0.1]:36587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ibR8c-0005DD-7m for submit@debbugs.gnu.org; Sun, 01 Dec 2019 10:27:54 -0500 Original-Received: from mail-lf1-f41.google.com ([209.85.167.41]:43985) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ibR8Z-0005Cy-Ka for 38406@debbugs.gnu.org; Sun, 01 Dec 2019 10:27:52 -0500 Original-Received: by mail-lf1-f41.google.com with SMTP id l14so25980389lfh.10 for <38406@debbugs.gnu.org>; Sun, 01 Dec 2019 07:27:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s1STr6e7h0iWM3ZsBw1T250Wv1ueieZbGLXHFG2ov3g=; b=LA+mgqsByaq8rSLLYqD00IVZhFA4QEqrikgf3OHDSKsaAerHLsBuzeMAPj5Jsphy3l Gj7Y0tSoMdLMlPkuvYIZtwHj15CY2jsEE3pBrhfSXWumBZ0m5hqlIh9Z3iJGgWnFcdou cxy1rHOIJ7phR6rexFOizUYga746h7Kv7HKonud/VeRJ1Cr2DAf2IO9GR87hVSrHzsU1 k30VuuPW5RV70a6+RoyurtPFVAr6O0FClCwUgmYNPivR/5eabOezA36Gk41jI3fNX4yS JhPpqmejbXYdZfJYQPdhGntoUN2oY43B4Hmk0FokOWzsH2+42vh+/hxVSnBB5uFjICTw VNPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s1STr6e7h0iWM3ZsBw1T250Wv1ueieZbGLXHFG2ov3g=; b=RbAxBab/x91CDiUuBefnhqFQTzFvIkE+u0r5LGINe+X+3SsbkCW7VppOyh6XJN1cFK yHQr/GuY9T28JouamCJOsoLPzCcxykuZz0LUq0Qnh+XBmV9jSaM7fX9ZlWuIE/Et1ka/ TYKItdQL6DtPRQkmVIMvDqFASkrZxL/t4I9rkUpBXE6FFmdgsRPC+lEXRj0uAHWhZJM1 3R6XEuG9R09DADytlGtjgcxIOxqdyQjyUm1fFERVLtxHpCj7DykHx7otzSuubtbcTMA1 zFYVAJsnLfGh5x8P2QA6CZ2NuR2lejGRMeBFF6jNFp+hvQNnzTFUGS2c0UkpDEfDviq9 3ejQ== X-Gm-Message-State: APjAAAWEtVP8ald+uFzoAMSyWFc26zxiKv54/MevN9jSraJEjirWbzqk WqpzsO4ij9ufAZjJ+O4kZPkzt4F9LRwhOCqP12w= X-Google-Smtp-Source: APXvYqzZVV9MYGhe6tlnNhp3PrpGxlj/1XNNg5mgNf8dKQox8d4ps6M6NXAXOl3JcB6WWBV430Oni67pXvx3H1AFE4M= X-Received: by 2002:ac2:5931:: with SMTP id v17mr12285745lfi.166.1575214065466; Sun, 01 Dec 2019 07:27:45 -0800 (PST) In-Reply-To: <20191201150738.GB5085@ACM> 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:172713 Archived-At: --000000000000d141720598a61af3 Content-Type: text/plain; charset="UTF-8" Hi Alan > 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? ATM this change breaks at least 2 packages - lsp-mode and smartparents. I am the maintainer of lsp-mode and it uses the hook for 2 things: 1. There are keys that are triggering displaying function signature. 2. There are keys that are triggering onTypeFormatting which happens asynchronously. I am not aware of how exactly smartparens uses post-insert-hook. Thanks, Ivan On Sun, Dec 1, 2019 at 5:07 PM Alan Mackenzie wrote: > 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). > --000000000000d141720598a61af3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi Alan

> = Again, how does this binding of post-self-insert-hook to nil in CC Mode
= > affect you?=C2=A0 What is it you're trying to do that this binding= makes
> difficult?

ATM this change brea= ks at least 2 packages - lsp-mode and smartparents. I
am the main= tainer of lsp-mode and it uses the hook for 2 things:

<= div>1. There are keys that are triggering displaying function signature.
2. There are keys that are triggering onTypeFormatting which happen= s asynchronously.=C2=A0

I am not aware of how exac= tly=C2=A0smartparens uses post-insert-hook.

Thanks= ,
Ivan

On Sun, Dec 1, 2019 at 5:07 PM Alan Mackenzie <acm@muc.de> wrote:
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 someho= w I don't
> > think that's what you want.

> I don't think that the code that is implemented against the contra= ct 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 r= ely on
> this hook in cc derived modes because of {implementation details}. If<= br> > 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.=C2=A0 Its implications weren't th= ought
through beforehand.=C2=A0 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.=C2=A0 An example of such a functio= n 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.=C2=A0 An example is
electric-pair-post-self-insert-function (in lisp/elec-pair.el).=C2=A0 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.=C2=A0 Binding post-self-insert-hook to nil in CC Mode,<= br> while not good, was a pragmatic workaround from around a year ago.=C2=A0 Th= is
allowed electric-pair-mode to function in CC Mode.=C2=A0 As I said, this problem is primarily a political problem.=C2=A0 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?=C2=A0 What is it you're trying to do that this binding make= s
difficult?

> Thanks,
> Ivan

--
Alan Mackenzie (Nuremberg, Germany).
--000000000000d141720598a61af3--