emacs-devel
[Top][All Lists]
Advanced

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

Re: electric-pair-mode as a minor mode?


From: Stefan Monnier
Subject: Re: electric-pair-mode as a minor mode?
Date: Sun, 29 Mar 2015 00:01:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> But this is precisely the use case for the "message mode hack" earlier:

Yes, you can add more hacks to try and handle a few special cases, but
each one of those hacks is heuristic (i.e. will have false positives and
false negatives) and they'll never cover all actual cases (they're very
dependent on specific conventions used by people, which change
significantly between communities).

> I haven't tested, because I don't have time to learn about implementing
> comment syntaxes right now (I also probably won't if you tell me it's
> futile or problematic for some other reason).

It might be a good idea to do it in general (i.e. not as part of
electric-pair-mode but as part of message-mode for example).  But it
doesn't change the fact that syntax-ppss is unreliable.

> assessment it should work as well as it already does for programming
> modes, where `(' and `)' thingies can exist unpaired in comments and
> string literals.

In programming modes, there's a formal and unambiguous definition of what
is correct syntax and what isn't (or at least there should be for any
sane programming language), so we can hope to refine Emacs's rules until
they're correct.  But for natural language, there's no such perfection.

> Yes, I understand, but what do you suggest? I just hope it's not
> changing the default value of `electric-pair-preserve-balance', which I
> personally like very much... Why don't you
>
>    (add-hook 'text-mode-hook
>      (lambda () (setq-local electric-pair-preserve-balance nil)))
>
> in your configuration?

Ah, that might do it, indeed.  At least a quick experiment seems to
handle the cases I mentioned so far.


        Stefan




reply via email to

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