|
From: | Jim Porter |
Subject: | bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode |
Date: | Sat, 18 Sep 2021 18:55:06 -0700 |
On 9/18/2021 5:20 PM, João Távora wrote:
So after having a look at this, I came up with a patch. All tests pass, and your original request is granted. Unfortunately, Stephen's desired triple-pair behaviour is also lost. However, I think that behaviour can be recovered via other more elegant, less accidental ways. python.el has 'python-electric-pair-string-delimiter' for triple-pairing that doesn't seem to be doing its thing. Here is the patch. Give it a shot. diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el index d8c377a2ef..b8b8a97651 100644 --- a/lisp/elec-pair.el +++ b/lisp/elec-pair.el @@ -198,7 +198,9 @@ electric-pair-syntax-info inside a comment or string." (let* ((pre-string-or-comment (or (bobp) (nth 8 (save-excursion - (syntax-ppss (1- (point))))))) + (skip-chars-backward + (make-string 1 command-event)) + (syntax-ppss (point)))))) (post-string-or-comment (nth 8 (syntax-ppss (point)))) (string-or-comment (and post-string-or-comment pre-string-or-comment))
Thanks, this patch works for me. It also works fine with my patch in bug#50538, so there's no conflict there.
Maybe better less brittle solutions can probably be found within the syntax tables framework.
I agree that something less brittle would be nice, but that might be tricky. I had tried a few options when I filed this bug, but nothing worked quite right.
As for Stephen's desired behavior, the code snippet I posted above[1] mostly fixes it (just the `python-electric-pair-string-delimiter' part is necessary after your patch). However, that code doesn't work right if `electric-pair-skip-self' is set to nil, so I'd need to be a bit smarter with the implementation if I wanted to merge it into Emacs. Perhaps there's an even cleaner solution though.
[1] https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-09/msg01509.html
[Prev in Thread] | Current Thread | [Next in Thread] |