unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: 50236@debbugs.gnu.org
Subject: bug#50236: 27.2; electric-pair-mode is inconvenient in comint
Date: Sun, 06 Feb 2022 10:33:00 +0100	[thread overview]
Message-ID: <87zgn4nxv7.fsf@gmail.com> (raw)
In-Reply-To: <87bl5heuva.fsf@gmail.com> (Augusto Stoffel's message of "Sat, 28 Aug 2021 12:17:29 +0200")

The following quick fix works for me:

    (defun electric-pair-skip-in-field (char)
      (save-restriction
        (narrow-to-region (field-beginning) (field-end))
        (electric-pair-default-skip-self char)))

    (add-hook 'comint-mode-hook (lambda () (setq-local electric-pair-skip-self
                                                       'electric-pair-skip-in-field)))

Perhaps `electric-pair-default-skip-self' should always narrow to the
current field?

There are a few more situations where electric-pair-mode looks to far;
for instance, when inside an org src block, mismatched parenthesis
outside the block shouldn't matter.  So maybe an even more general
solution is in order.

On Sat, 28 Aug 2021 at 12:17, Augusto Stoffel <arstoffel@gmail.com> wrote:

> In comint buffers, electric pair mode should only look at the current
> input region to decide whether to skip over a closing bracket or add a
> new one.  Otherwise, it gets confused about mismatched delimiters in
> previous inputs or outputs.
>
> To give an example, if I enter, in a fresh shell
>
>     X='('
>
> at the first prompt, and then type “())” in the second prompt, I get
> the following sequence of states (where | indicates the point)
>
>     |
>     (|)
>     ()|)
>     ())|
>
> where I would instead expect the obvious:
>
>     |
>     (|)
>     ()|
>     ())|





  reply	other threads:[~2022-02-06  9:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 10:17 bug#50236: 27.2; electric-pair-mode is inconvenient in comint Augusto Stoffel
2022-02-06  9:33 ` Augusto Stoffel [this message]
2022-08-22 15:37   ` Lars Ingebrigtsen
2022-08-22 16:07     ` Augusto Stoffel
2022-08-23  9:53       ` Lars Ingebrigtsen
2022-08-23 16:56         ` Augusto Stoffel
2022-08-24 10:19           ` Lars Ingebrigtsen

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=87zgn4nxv7.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=50236@debbugs.gnu.org \
    /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).