bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#38406: 27.0.50; post-self-insert-hook does not hold its contract in


From: Alan Mackenzie
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
User-agent: Mutt/1.10.1 (2018-07-13)

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 <acm@muc.de>

> > 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).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]