Subject: Re: bug#77823: 31.0.50; M-j regression since commit 4c6b1712a4d

From: Elijah Gabe Pérez <[email-masked]>
Date: Sat, 19 Apr 2025 23:11:38 -0600

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

>>  lisp/electric.el                     | 24 ++++++++++++++----------
>>  lisp/emacs-lisp/lisp-mode.el         |  3 +--
>>  lisp/newcomment.el                   |  9 ++++-----
>>  lisp/nxml/nxml-mode.el               |  3 +--
>>  lisp/progmodes/c-ts-common.el        |  6 ++----
>>  lisp/progmodes/go-ts-mode.el         |  3 +--
>>  lisp/progmodes/js.el                 |  3 +--
>>  lisp/progmodes/json-ts-mode.el       |  3 +--
>>  lisp/progmodes/lua-ts-mode.el        |  3 +--
>>  lisp/progmodes/opascal.el            |  3 +--
>>  lisp/progmodes/pascal.el             |  3 +--
>>  lisp/progmodes/typescript-ts-mode.el |  3 +--
>>  lisp/textmodes/css-mode.el           |  5 +----
>>  lisp/textmodes/sgml-mode.el          |  3 +--
>>  14 files changed, 31 insertions(+), 43 deletions(-)
>
> IIRC, the recent changes also added setting to
> `block-comment-start/end` in CC-modes, so there may need to be more reversals.

Oops, i forgot it.

>>  (define-minor-mode electric-block-comment-mode
>>    "Toggle automatic closing of block comments (Electric Block Comment mode).
>>  
>> +When enabled, typing the beginning of a block comment closes it inserting their
>> +corresponding block comment end."
>
> So, IIUC what is meant by "block comment" here is a comment that's not
> closed by the next EOL but by some other sequence of characters.
>
> Interesting cases to consider:
>
> - In SNMP mode, IIRC, comments take the shape of
>
>        -- a comment --
>
>   so you have to check `syntax-ppss` to figure out if the `--` that was
>   just inserted was a comment starter or ender.

I didn't know that were possible.

> - In OPascal mode there is more than one kind of "block
>   comment":
>
>         { a comment }
>         (* another comment *)
>         /* yet another comment */
>
>   so your `electric-block-comments` should probably support not just
>   a single pair but a list of pairs.

Yeah, i realized when i made the changes.

> - It might make sense to extend this to related constructs and/or to
>   merge it into `electric-pair-mode`.

I originally planned to merge it with electric-pair, but electric-pair
is something complex for this little feature (and also electric-pair
uses characters, not strings), so I decided to make it standalone.

>   By related constructs, I'm thinking of things like [OCaml's
>   quotations](https://caml.inria.fr/pub/docs/tutorial-camlp4/tutorial004.html)
>   that take the form `<:FOO<...>>` or [OCaml's quoted
>   strings](https://ocaml.org/manual/5.2/lex.html#quoted-string-id)
>   that look like `{FOO|...|FOO}`.

It looks outside the purpose of this minor mode, but I have nothing
against implementing it, it can handle it.  Honestly, if that were the
case, I don't know what name to give this mode.

-- 
                                          - E.G via GNU Emacs and Org.