GNU bug report logs -
#40865
26.3; Electric pair mode and syntax class $
Previous Next
Full log
Message #8 received at 40865 <at> debbugs.gnu.org (full text, mbox):
Augusto Stoffel <arstoffel <at> gmail.com> writes:
Hi Augusto, thank you for the report.
> Electric pair mode does not treat string quote characters and paired
> delimiters (syntax class "$") in the same way, but it should probably
> do so.
Paired delimiters don't formally define any kind of syntactic region
between them, contrary to string delimiters.
Therefore, electric-pair-mode can't easily know if a decision to skip or
auto-pair would be benefitting the balance of the syntax buffer.
Therefore, it decides to be dumb and always autopair, never autoskip.
If I had chosen the alternative, having your point just before a '$foo$'
would make autoskip put it inside the group, instead of creating a new
'$$$foo$', which is probably what you wanted in that particular
situation.
Maybe, even though flawed, that is more defensible as a default
behaviour than the current one. At least it doesn't seem to break any
tests.
The "correct" way to fix this is to make latex-mode treat paired
delimiters like it does string delimiteres. But that probably has other
negative implications that I'm not aware of.
I have the vague recollection that this came up when I was developing
electric-pair-mode, particularly in latex-mode, some 6 years ago, but I
can't remember anymore.
Anyway, if you do prefer the alternative I gave earlier you can do this:
(add-hook 'latex-mode-hook
(lambda ()
(add-function :before-until
(local 'electric-pair-skip-self)
(lambda (char) (eq char ?$))
'((name . latex-skip-paired-delimiters)))))
João
PS: On a related note, note that AUCTex mode (a different mode to edit
TeX files) has a special binding for the dollar sign, TeX-insert-dollar,
which doesn't follow _any_ of electric-pair-mode.
This bug report was last modified 3 years and 359 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.