unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Allen Li <darkfeline@felesatra.moe>
To: 49629@debbugs.gnu.org
Subject: bug#49629: Acknowledgement (27.2; electric-pair-mode doesn't work for angle brackets in HTML file)
Date: Thu, 22 Jul 2021 07:03:29 +0000	[thread overview]
Message-ID: <CADbSrJza5cLbirYh3dr-HLmGE=CbatKF3N=1RscoyFuruzhpWQ@mail.gmail.com> (raw)
In-Reply-To: <801r7vgoxm.fsf@felesatra.moe>

> To reproduce:
>
> 1. emacs -Q
> 2. C-x C-f /tmp/tmp.html RET
> 3. M-x electric-pair-local-mode RET
> 4. < >
>
> Expected:
>
> Buffer contains <>
>
> Actual:
>
> Buffer contains <>>
>
> By default, typing > should skip over the > inserted by
> electric-pair-mode when the first < is type (but it doesn't).
>
> I tried stepping through with Edebug, but the bug disappears when using
> Edebug.  The difference seems to be in what is returned by
> electric-pair--balance-info, but that function is big and unfamiliar to
> me.

What I've found so far is that using Edebug to step through
electric-pair-skip-if-helps-balance, if I manually step past
(delete-char -1) and then press g (edebug-go-mode) then the bug
disappears.  Pressing g before stepping past (delete-char -1) causes
the bug.

For reference, here is the function:

(defun electric-pair-skip-if-helps-balance (char)
  "Return non-nil if skipping CHAR would benefit parentheses' balance.
Works by first removing the character from the buffer, then doing
some list calculations, finally restoring the situation as if nothing
happened."
  (pcase (electric-pair-syntax-info char)
    (`(,syntax ,pair ,_ ,s-or-c)
     (unwind-protect
         (progn
           (delete-char -1)
           (cond ((eq syntax ?\))
                  (let* ((pair-data
                          (electric-pair--balance-info
                           -1 s-or-c))
                         (innermost (car pair-data))
                         (outermost (cdr pair-data)))
                    (and
                     (cond ((car outermost)
                            (car innermost))
                           ((car innermost)
                            (not (eq (cdr outermost) pair)))))))
                 ((eq syntax ?\")
                  (electric-pair--inside-string-p char))))
       (insert char)))))





  reply	other threads:[~2021-07-22  7:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-18 23:52 bug#49629: 27.2; electric-pair-mode doesn't work for angle brackets in HTML file Allen Li
2021-07-22  7:03 ` Allen Li [this message]
2021-07-22 23:34   ` Lars Ingebrigtsen
2021-07-25 10:08     ` Allen Li
2021-07-28 15:42       ` Lars Ingebrigtsen
2021-08-01  5:06         ` Allen Li
2021-08-01 10:41           ` Lars Ingebrigtsen
2021-12-09 10:31             ` Allen Li
2021-12-09 13:30               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-24 10:07                 ` Allen Li
2021-12-24 14:23                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-26  8:41               ` Allen Li
2022-06-26  9:38                 ` Allen Li
2022-06-26 12:17                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-27  0:33                     ` Allen Li
2022-06-27 12:39                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-02 10:48                         ` Allen Li
2022-07-03 10:32                           ` 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='CADbSrJza5cLbirYh3dr-HLmGE=CbatKF3N=1RscoyFuruzhpWQ@mail.gmail.com' \
    --to=darkfeline@felesatra.moe \
    --cc=49629@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).