emacs-devel
[Top][All Lists]
Advanced

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

Re: Fixing post-self-insert-hook.


From: Alan Mackenzie
Subject: Re: Fixing post-self-insert-hook.
Date: Sun, 19 Sep 2021 12:14:18 +0000

Hello, João

On Sat, Sep 18, 2021 at 23:55:10 +0100, João Távora wrote:
> João Távora <joaotavora@gmail.com> writes:

> > it's just done.  I've asked João about such an interface over the last
> > few years, now and then, but such has not yet been forthcoming.

> I've made my opinion clear now and then, over the years.  But here I go
> again:

> 'electric-pair-post-self-insert-function' (aka e-p-p-s-i-f) existed
> before I have laid my programmer eyes on it.  It's not an internal
> function, it has a defined protocol ....

It doesn't even have a doc string.

> .... and exists to be a member of 'post-self-insert-hook'.

Exactly.  There is a need for a stable functional interface to
electric-pair-mode which CC Mode can use.  Despite how little effort it
would be to create and formalise this, you have refused to do so over
the years.

> Its purpose is -- and has always been -- to insert aditional
> delimiters related to the one just typed or, alternatively, to delete
> the character just inserted when it happens to skip a closing
> delimiter.

Yes.  Would you please write this into a doc string for
electric-pair-post-self-insert-function, together with information about
where that function gets its information from, and what it does with
point.

[ .... ]

> Nevertheless, if you want to extract things from e-p-p-s-i-f and use
> them in your function, you can refactor its innards.  As long as you
> don't break anything (fortunately there are good tests) or convolute
> elec-pair.el's code beyond recognition.  Don't expect me to spend my
> time any time in this effort: I won't.  I think it would be a very gross
> waste of time.  _My_ time, at least.  You may convince someone else of
> that idea.

What a wonderful attitude for a maintainer.  ;-(

You will perhaps recall bug #33794 "26.1; electric-pair-mode breaks
auto-newline minor mode of cc-mode".  Despite a large part of the
problem lying within electric-pair-mode, I don't think you changed a
single line of your code to fix the problem.  As a result, I was forced
to implement ugly workarounds, which are still there almost three years
later, the alternative being leaving the bug unfixed.

> My alternative suggestion, which I've offered now and then, over the
> years, is for you to study how cc-mode behaves when you bind the
> delimiter keys simply to 'self-insert-command' ....

You know full well that this is problematic.

> and refrain from re-inventing 'electric-pair-mode' inside cc-mode.

I sometimes wonder if such a reimplementation inside CC Mode might have
been less work than all the email exchange with you trying to get you to
fix things.

> I do this in my .emacs, and I see that other users have settled on the
> same practice.  If you were to try that, you could theoretically
> arrive at the conclusion that it is possible to do everything cc-mode
> does today w.r.t. electricity via the existing interfaces of
> 'electric-pair-mode', 'electric-layout-mode' and
> 'electric-indent-mode'.

Sure, anything's possible.  But doing so whilst retaining functionality
would fragment the code, and lead inevitably to bugs in what is
currently an exceptionally stable part of CC Mode.

> I must be honest.  I don't really expect you arrive at that conclusion
> or even try that experiment.

No.  I have a user base to consider.

> That's OK, I can't force anyone to reason the way I do.  My personal
> hopes for C/C++/Java editing in Emacs are a completely new major mode
> where syntax is handled by TreeSitter and all the keys are bound to
> 'self-insert-command'.  I'd bet good money that 'electric-pair-mode'
> is going to work there fine and with 0 configuration, like it does in
> all other major modes.

> With best regards,
> João

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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