From: Jim Porter <jporterbugs@gmail.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: 49518@debbugs.gnu.org, Stephen Berman <stephen.berman@gmx.net>,
Daniel Fleischer <danflscr@gmail.com>
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 [thread overview]
Message-ID: <eb92b0b4-5b89-ba7e-5547-c44aa1382ea9@gmail.com> (raw)
In-Reply-To: <87v92xbelt.fsf@gmail.com>
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
next prev parent reply other threads:[~2021-09-19 1:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-11 1:32 bug#49518: 28.0.50; electric-pair-mode skip-self fails for single-quotes in python-mode Jim Porter
2021-07-11 8:11 ` Stephen Berman
2021-07-11 17:34 ` Jim Porter
2021-09-18 12:55 ` Daniel Fleischer
2021-09-18 16:56 ` Jim Porter
2021-09-18 23:43 ` João Távora
2021-09-19 0:20 ` João Távora
2021-09-19 1:55 ` Jim Porter [this message]
2021-09-19 10:44 ` João Távora
2021-09-19 16:35 ` João Távora
2021-09-21 9:59 ` João Távora
2021-09-22 20:04 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb92b0b4-5b89-ba7e-5547-c44aa1382ea9@gmail.com \
--to=jporterbugs@gmail.com \
--cc=49518@debbugs.gnu.org \
--cc=danflscr@gmail.com \
--cc=joaotavora@gmail.com \
--cc=stephen.berman@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).