From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Beatrix Klebe Newsgroups: gmane.emacs.bugs Subject: bug#33794: 26.1; electric-pair-mode breaks auto-newline minor mode of cc-mode Date: Fri, 21 Dec 2018 11:00:10 -0500 Message-ID: References: <20181221134829.29135.qmail@mail.muc.de> Reply-To: bea@klebe.blog NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1545407959 1531 195.159.176.226 (21 Dec 2018 15:59:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Dec 2018 15:59:19 +0000 (UTC) Cc: Alan Mackenzie , "Mx. Beatrix Klebe" , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , 33794@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 21 16:59:14 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaNCh-0000CR-H6 for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2018 16:59:11 +0100 Original-Received: from localhost ([::1]:46392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaNEn-0000qV-LX for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 Dec 2018 11:01:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaNEh-0000pA-6h for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2018 11:01:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaNEa-0002Cp-V3 for bug-gnu-emacs@gnu.org; Fri, 21 Dec 2018 11:01:13 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gaNEU-00027z-QV; Fri, 21 Dec 2018 11:01:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gaNEU-0007Ur-Bl; Fri, 21 Dec 2018 11:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Beatrix Klebe Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 21 Dec 2018 16:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33794 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 33794-submit@debbugs.gnu.org id=B33794.154540802928759 (code B ref 33794); Fri, 21 Dec 2018 16:01:02 +0000 Original-Received: (at 33794) by debbugs.gnu.org; 21 Dec 2018 16:00:29 +0000 Original-Received: from localhost ([127.0.0.1]:58682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaNDw-0007Tn-Qe for submit@debbugs.gnu.org; Fri, 21 Dec 2018 11:00:28 -0500 Original-Received: from mail-ot1-f47.google.com ([209.85.210.47]:42596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gaNDv-0007TS-Id for 33794@debbugs.gnu.org; Fri, 21 Dec 2018 11:00:27 -0500 Original-Received: by mail-ot1-f47.google.com with SMTP id v23so5493097otk.9 for <33794@debbugs.gnu.org>; Fri, 21 Dec 2018 08:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=m+QpFOnKUU40uMgA3yNm42wrVQenSbHLJOB02TBIhIE=; b=L30h7XSl1ioU4J26BiqGUcZuUCND8d7YOkDnmZqBLLjvy2DgtkuXu5yTi5+6fHBu58 5GmvXd4Tf5i8KntIFKFd4bqU77O6DudgaZ5aCxBMT1w8J5ql5zIwB2wE0DBO+wHR3Mc1 HqOFjJisxBfcDCqosCkiHgYzfSw1EUZBF6M8s6lhNqoYo+92gsLF4QWKF1RSqB72Qxob YvHopCv1AfgpRkqHc+h+xLD+VLSjj9iUWhiIFVJ+BFNBhf0r9LMiVtHjH6t6JvMtF+oC dJBLkx5jgMJDO8ihK2HH3szmzgVlgOIWOyLqBGdnhixp5wiRiNxgTooLvEVUMiOINa9P CLrw== 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:reply-to :from:date:message-id:subject:to:cc; bh=m+QpFOnKUU40uMgA3yNm42wrVQenSbHLJOB02TBIhIE=; b=ggHGkZnzMhfBcvTtrWawhjXcf8SrW8jF5bn5VmTWUq/I6FT8GfrTIp6BV7toHCdLjq NucXPlqQiqc9RUDNPxF4gXXp43bD2O1EKde33YF6tXvx604ZnMQOrwbt32axKMfUFjGR ELcM9Wvgc3hQdgrPlTPlAUw0rvRcM9OhSeRQ7T722y6k3sUKbQjf4O2NCJMokMrpe6iS 8l3pG9U5jPMWwl9FqPARv4d9gLsKVNrbJDvNgwtwh/8ugcB6syB0S1Lz/mBhu7qI/mxT Ei0XzXdB9GenvVQiS+F4vk2yYM7SlRavCn+/GtwrFCbOblpyrrpPb/k3y7wj85efO+XE P3aA== X-Gm-Message-State: AJcUukf1SvFIPXSNTFDe+DzAuuoaLF1nNpGV07nLWZSwhfiMA2UKFfcX 2batJeAHs3jX9YPCxOZA1ASi7StPVsxGHNV3GO8= X-Google-Smtp-Source: ALg8bN7KK2fGJ7P55aFgMkNacwRiur0cH+kvA/k3d3Ht3xrclhbbIEwaRgnj7rH+7ZVF5d9lHyc2EM43zGQzubTDRzU= X-Received: by 2002:a9d:3d42:: with SMTP id a60mr1952671otc.285.1545408021618; Fri, 21 Dec 2018 08:00:21 -0800 (PST) In-Reply-To: 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: 208.118.235.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:153684 Archived-At: I believe I saw your Stack Overflow answer about this while searching for the solution. electric-layout-mode works with some quirks, such as that if you put a space after parens in a function definition, the space gets carried on to the newline with that method, which is a bit annoying. What would be ideal, and what I'm looking for, is to get auto-pairing of brackets with braces being placed where they should be automatically and the insertion point getting put in between them at the correct indent level, such as what happens with Visual Studio, or Visual Studio Code, or several other editors with this functionality. Perhaps it is not emacslike to have such behavior be totally automated, but I am used to it and finds it decreases my ordinary levels of frustration when working with verbose and imperative languages. I am currently trying to write some insert specifiers for smartparens to do this, but it is proving more difficult to find an elegant solution than I had expected. On Fri, Dec 21, 2018 at 10:54 AM Stefan Monnier wrote: > > >> Yes. What is happening, from the viewpoint of CC Mode, is that on > >> inserting a {, electric-pair-mode is prematurely inserting its }, before > >> the processing for the { is complete. > > Since it's done from post-self-insert-hook, it's done at the very end of > inserting { so I'm not sure what you mean by "before the processing for > the { is complete". > > >> Also, due to the way } gets inserted, the CC Mode processing for > >> the } isn't done at all. > > I think you meant "due to the way CC-Mode hooks itself into the } > processing, ..." ;-) > > >> Would it therefore be possible, rather than having a crude insertion on > >> post-self-insert-hook, to use something like post-command-hook to allow > >> the insertion of the { first to complete? Then, rather than using the > >> brutal self-insert-command for } in electric-pair--insert, use the > >> command to which the key } is bound? > > Talking about brutal: how could electric-pair-mode run whichever command > is bound to } without taking the risk of running a much more brutal > command than one that inserts a character? > > > FWIW, I think cc-mode should rather use post-self-insert-hook instead > > of redefining commands for keys whose expected behaviour is > > (with minor variations presumably covered by abundant hookage) > > self-insertion. > > IIRC it should be able to just use electric-layout-mode for that (tho > maybe electric-layout's featureset doesn't currently cover 100% that of > CC-mode's auto-newline, in which case it would be nice to extend > electric-layout accordingly). > > For things like electric-pair, electric-indent, and electric-layout to > work correctly together, they need to agree on some convention. > > Note that CC-mode can also side-step that convention and use `insert` > instead of self-insert-command. > > > Stefan