unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Apropos 54f297904e0c: Temporarily comment out CC Mode from tests which are incompatible with it.
Date: Mon, 21 Jan 2019 20:45:44 +0000	[thread overview]
Message-ID: <20190121204544.GC4514@ACM> (raw)
In-Reply-To: <jwv7eeycdgc.fsf-monnier+emacs@gnu.org>

Hello, Stefan.

On Mon, Jan 21, 2019 at 13:04:57 -0500, Stefan Monnier wrote:
> > If I said the sky was blue would you say "where's your evidence?"?

> > It is a fact that c-electric-brace controls, and must control, each
> > change to the buffer which is done.

> Not only I don't think that this is true, but I don't even know exactly
> what it means (IOW, yes it's probably true for some interpretation of
> it, but not for others).

> > This is self evident from reading the source code.

> I don't see this evidence.

Look in c-do-brace-electrics in an up to date (i.e. within the last few
days) version of cc-cmds.el.  This function is called from several
places in c-electric-brace.

About 60% the way through is the "brace-else-brace" cleanup.  It works
by scanning the buffer for a particular pattern.  If arbitrary changes
(i.e. those not controlled by the major mode) have been made to the
buffer, the pattern might not be found when it should be.  For example.

This was precisely the cause of bug #33794.  The user typed "{", but
unknown to c-electric-brace, self-insert-command randomly inserted "{}".
This extra "}" prevented auto-newline from working.

With the advent of post-self-insert-hook, it is clear that calling
self-insert-command from a function can lead to arbitrary buffer
changes.  To prevent this, c-electric-brace and friends bind
post-self-insert to nil.  Another way to proceed would be your recent
suggestion of using insert rather than self-insert-command.

It is thus clear that the use of post-self-insert-hook is incompatible
with Lisp code which calls self-insert-command, since that use
effectively makes that function undefined.  The way this hook is
typically used is much more like advice (which modifies a function's
function) than a traditional hook (where the hook performs things
incidental to what triggers it, leaving the triggering event untouched).

> > Please read the source code for c-electric-brace and its immediate
> > sub-functions, understand it (it's not hard), and then come back to me
> > with any questions you may have.

> expand-abbrev also can be extensive changes during self-insert-command,
> and so can the auto-fill-function.

In practice, they haven't done so.  If they did, then using insert would
solve the problem.

> > It is a fact that electric-layout-mode and electric-pair-mode are
> > allowed to run from post-self-insert-hook, that they make buffer changes
> > which are outside the control of c-electric-brace.

> If you use electric-layout-mode and electric-pair-mode, then all that's
> left for c-electric-brace is to call self-insert-command.

No.  There's more to it than that.

> And indeed, I hope in the future that the { and } bindings will simply
> be removed from CC-mode.

Maybe in the medium future, when the pertinent generic functions are in
all Emacs versions supported by CC Mode (assuming that XEmacs support
will cease quite soon).

These generic functions have some way to go before they match the
functionality of CC Mode's own features.

> I understand that there's a transition needed between these two and this
> intermediate state can require more work, but it's important to keep the
> long term goal in mind when designing the current solution.

Whose long term goal?  My goal, both long and short term, is to keep CC
Mode working properly.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2019-01-21 20:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 14:57 Apropos 54f297904e0c: Temporarily comment out CC Mode from tests which are incompatible with it João Távora
2019-01-17 16:43 ` Alan Mackenzie
2019-01-17 17:57   ` João Távora
2019-01-17 18:55     ` João Távora
2019-01-18 17:54     ` Alan Mackenzie
2019-01-18 19:55       ` João Távora
2019-01-18 22:53         ` Alan Mackenzie
2019-01-19  3:18           ` João Távora
2019-01-19 11:07             ` Alan Mackenzie
2019-01-19 13:52               ` João Távora
2019-01-19 17:45                 ` Alan Mackenzie
2019-01-19 19:15                   ` João Távora
2019-01-19 20:58                     ` Alan Mackenzie
2019-01-19 23:18                       ` João Távora
2019-01-21 18:04                       ` Stefan Monnier
2019-01-21 20:45                         ` Alan Mackenzie [this message]
2019-01-21 21:46                           ` Stefan Monnier
2019-01-21 22:41                             ` João Távora
2019-01-19 22:37                     ` Drew Adams
2019-01-20 19:05                 ` Richard Stallman
2019-01-20 21:18                   ` João Távora
2019-01-21 20:59                     ` Richard Stallman
2019-01-21 21:49                       ` João Távora
2019-01-18 21:06       ` Stefan Monnier
2019-01-19  3:25         ` João Távora
2019-01-18 22:47       ` Michael Albinus
2019-01-19 20:18       ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190121204544.GC4514@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).